summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2022-08-05 22:53:02 +0300
committerLars Wirzenius <liw@liw.fi>2022-08-06 07:25:14 +0300
commit186176b499dd7d1db6089bf8f666e3770162d782 (patch)
tree3b658f64f5a207c366896dce38565432ea668600
parent4d20badb243c2ae57b8b54d0c5e025b43957dd8f (diff)
downloadriki-186176b499dd7d1db6089bf8f666e3770162d782.tar.gz
feat: placeholder for brokenlinks directive
Sponsored-by: author
-rw-r--r--src/directive/brokenlinks.rs27
-rw-r--r--src/directive/mod.rs26
2 files changed, 50 insertions, 3 deletions
diff --git a/src/directive/brokenlinks.rs b/src/directive/brokenlinks.rs
new file mode 100644
index 0000000..c6364a4
--- /dev/null
+++ b/src/directive/brokenlinks.rs
@@ -0,0 +1,27 @@
+use crate::error::SiteError;
+use crate::page::PageMeta;
+use crate::site::Site;
+use crate::wikitext::ParsedDirective;
+
+#[derive(Debug, Default, Eq, PartialEq)]
+pub struct BrokenLinks {}
+
+impl BrokenLinks {
+ pub const REQUIRED: &'static [&'static str] = &["pages"];
+ pub const ALLOWED: &'static [&'static str] = &[];
+ pub const ALLOW_ANY_UNNAMED: bool = false;
+
+ pub fn new() -> Self {
+ Self::default()
+ }
+
+ pub fn process(&self, _site: &Site, _meta: &mut PageMeta) -> Result<String, SiteError> {
+ Ok("FIXME:inline".into())
+ }
+}
+
+impl From<ParsedDirective> for BrokenLinks {
+ fn from(_p: ParsedDirective) -> Self {
+ Self::new()
+ }
+}
diff --git a/src/directive/mod.rs b/src/directive/mod.rs
index 0767c9d..16d55c1 100644
--- a/src/directive/mod.rs
+++ b/src/directive/mod.rs
@@ -12,9 +12,10 @@ pub enum Directive {
QuotedArg,
MultilineArg,
- Meta(Meta),
+ BrokenLinks(BrokenLinks),
Img(Img),
Inline(Inline),
+ Meta(Meta),
PageStats(PageStats),
Tag(Tag),
Toc(Toc),
@@ -45,12 +46,22 @@ impl TryFrom<ParsedDirective> for Directive {
Self::check_args(&p, &["yo"], &["then", "else"], false)?;
Directive::MultilineArg
}
+
+ "brokenlinks" => {
+ Self::check_args(&p, BrokenLinks::REQUIRED, BrokenLinks::ALLOWED, BrokenLinks::ALLOW_ANY_UNNAMED)?;
+ Directive::BrokenLinks(BrokenLinks::from(p))
+ }
"img" => {
Self::check_args(&p, Img::REQUIRED, Img::ALLOWED, Img::ALLOW_ANY_UNNAMED)?;
Directive::Img(Img::from(p))
}
"inline" => {
- Self::check_args(&p, Inline::REQUIRED, Inline::ALLOWED, Inline::ALLOW_ANY_UNNAMED)?;
+ Self::check_args(
+ &p,
+ Inline::REQUIRED,
+ Inline::ALLOWED,
+ Inline::ALLOW_ANY_UNNAMED,
+ )?;
Directive::Inline(Inline::from(p))
}
"meta" => {
@@ -58,7 +69,12 @@ impl TryFrom<ParsedDirective> for Directive {
Directive::Meta(Meta::from(p))
}
"pagestats" => {
- Self::check_args(&p, PageStats::REQUIRED, PageStats::ALLOWED, PageStats::ALLOW_ANY_UNNAMED)?;
+ Self::check_args(
+ &p,
+ PageStats::REQUIRED,
+ PageStats::ALLOWED,
+ PageStats::ALLOW_ANY_UNNAMED,
+ )?;
Directive::PageStats(PageStats::from(p))
}
"tag" => {
@@ -115,6 +131,7 @@ impl Directive {
| Self::MultilineArg => {
panic!("directive {:?} may only be used in parsing tests", self)
}
+ Self::BrokenLinks(x) => x.process(site, meta),
Self::Img(x) => x.process(site, meta),
Self::Inline(x) => x.process(site, meta),
Self::Meta(x) => x.process(site, meta),
@@ -125,6 +142,9 @@ impl Directive {
}
}
+mod brokenlinks;
+use brokenlinks::BrokenLinks;
+
mod meta;
use meta::Meta;