summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2022-08-05 22:38:24 +0300
committerLars Wirzenius <liw@liw.fi>2022-08-06 07:25:14 +0300
commit51f773726a9b6640e21c0601e61700603c18d462 (patch)
treeb07fa35d850f3e46556c27d54829097329e37c17
parentea1a5a1e9c837816a0c89793e13f032f2cba50e1 (diff)
downloadriki-51f773726a9b6640e21c0601e61700603c18d462.tar.gz
feat: placeholder directive pagestats
Sponsored-by: author
-rw-r--r--src/directive/mod.rs9
-rw-r--r--src/directive/pagestats.rs27
2 files changed, 36 insertions, 0 deletions
diff --git a/src/directive/mod.rs b/src/directive/mod.rs
index a97f3a5..59c352c 100644
--- a/src/directive/mod.rs
+++ b/src/directive/mod.rs
@@ -15,6 +15,7 @@ pub enum Directive {
Meta(Meta),
Img(Img),
Inline(Inline),
+ PageStats(PageStats),
Tag(Tag),
}
@@ -55,6 +56,10 @@ impl TryFrom<ParsedDirective> for Directive {
Self::check_args(&p, Meta::REQUIRED, Meta::ALLOWED, Meta::ALLOW_ANY_UNNAMED)?;
Directive::Meta(Meta::from(p))
}
+ "pagestats" => {
+ Self::check_args(&p, PageStats::REQUIRED, PageStats::ALLOWED, PageStats::ALLOW_ANY_UNNAMED)?;
+ Directive::PageStats(PageStats::from(p))
+ }
"tag" => {
Self::check_args(&p, Tag::REQUIRED, Tag::ALLOWED, Tag::ALLOW_ANY_UNNAMED)?;
Directive::Tag(Tag::from(p))
@@ -108,6 +113,7 @@ impl Directive {
Self::Img(x) => x.process(site, meta),
Self::Inline(x) => x.process(site, meta),
Self::Meta(x) => x.process(site, meta),
+ Self::PageStats(x) => x.process(site, meta),
Self::Tag(x) => x.process(site, meta),
}
}
@@ -122,5 +128,8 @@ pub use img::Img;
mod inline;
pub use inline::Inline;
+mod pagestats;
+pub use pagestats::PageStats;
+
mod tag;
use tag::Tag;
diff --git a/src/directive/pagestats.rs b/src/directive/pagestats.rs
new file mode 100644
index 0000000..1a6f811
--- /dev/null
+++ b/src/directive/pagestats.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 PageStats {}
+
+impl PageStats {
+ pub const REQUIRED: &'static [&'static str] = &["pages"];
+ pub const ALLOWED: &'static [&'static str] = &["style"];
+ pub const ALLOW_ANY_UNNAMED: bool = true;
+
+ 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 PageStats {
+ fn from(_p: ParsedDirective) -> Self {
+ Self::new()
+ }
+}