summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2023-02-06 19:35:08 +0200
committerLars Wirzenius <liw@liw.fi>2023-02-06 19:35:08 +0200
commitdbef527278c9beebfdeaa7b36c036aaff3ca114d (patch)
treec6d11dae11801085e029c634e9026200748d9db0
parentc09ae93ca87dec1815b77b0e9456f14cd5f56f0a (diff)
downloadriki-dbef527278c9beebfdeaa7b36c036aaff3ca114d.tar.gz
feat: add dummy brokenlinks directive
We won't want this in the long run, but it helps while I test with my journal. Sponsored-by: author
-rw-r--r--src/directive/brokenlinks.rs26
-rw-r--r--src/directive/mod.rs14
2 files changed, 40 insertions, 0 deletions
diff --git a/src/directive/brokenlinks.rs b/src/directive/brokenlinks.rs
new file mode 100644
index 0000000..b95c0aa
--- /dev/null
+++ b/src/directive/brokenlinks.rs
@@ -0,0 +1,26 @@
+use crate::directive::{DirectiveError, DirectiveImplementation, Processed};
+use crate::page::PageMeta;
+use crate::site::Site;
+use crate::wikitext::ParsedDirective;
+use log::warn;
+
+#[derive(Debug, Default, Eq, PartialEq)]
+pub struct Brokenlinks {}
+
+impl DirectiveImplementation for Brokenlinks {
+ const REQUIRED: &'static [&'static str] = &["pages"];
+ const ALLOWED: &'static [&'static str] = &[];
+ const ALLOW_ANY_UNNAMED: bool = false;
+
+ fn from_parsed(_: &ParsedDirective) -> Self {
+ Self::default()
+ }
+
+ fn process(&self, _site: &Site, meta: &mut PageMeta) -> Result<Processed, DirectiveError> {
+ warn!(
+ "page {} uses unimplemented brokenlinks",
+ meta.path().display()
+ );
+ Ok(Processed::Markdown("\n".into()))
+ }
+}
diff --git a/src/directive/mod.rs b/src/directive/mod.rs
index 4efde55..a5f6b77 100644
--- a/src/directive/mod.rs
+++ b/src/directive/mod.rs
@@ -61,6 +61,7 @@ pub enum Directive {
QuotedArg,
MultilineArg,
+ Brokenlinks(Brokenlinks),
Calendar(Calendar),
Format(Format),
Graph(Graph),
@@ -111,6 +112,15 @@ impl TryFrom<&ParsedDirective> for Directive {
Directive::MultilineArg
}
+ "brokenlinks" => {
+ Self::check_args(
+ p,
+ Brokenlinks::REQUIRED,
+ Brokenlinks::ALLOWED,
+ Brokenlinks::ALLOW_ANY_UNNAMED,
+ )?;
+ Directive::Brokenlinks(Brokenlinks::from_parsed(p))
+ }
"calendar" => {
Self::check_args(
p,
@@ -264,6 +274,7 @@ impl Directive {
| Self::MultilineArg => {
panic!("directive {:?} may only be used in parsing tests", self)
}
+ Self::Brokenlinks(x) => x.process(site, meta),
Self::Calendar(x) => x.process(site, meta),
Self::Format(x) => x.process(site, meta),
Self::Graph(x) => x.process(site, meta),
@@ -323,3 +334,6 @@ use calendar::Calendar;
mod sidebar;
use sidebar::Sidebar;
+
+mod brokenlinks;
+use brokenlinks::Brokenlinks;