From 51f773726a9b6640e21c0601e61700603c18d462 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Fri, 5 Aug 2022 22:38:24 +0300 Subject: feat: placeholder directive pagestats Sponsored-by: author --- src/directive/mod.rs | 9 +++++++++ src/directive/pagestats.rs | 27 +++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 src/directive/pagestats.rs 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 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 { + Ok("FIXME:inline".into()) + } +} + +impl From for PageStats { + fn from(_p: ParsedDirective) -> Self { + Self::new() + } +} -- cgit v1.2.1