blob: 6f47d45dfc782be61f64c3ae3ec84c74b006d50c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
use crate::error::SiteError;
use crate::page::PageMeta;
use crate::site::Site;
use crate::wikitext::ParsedDirective;
#[derive(Default, Debug, Eq, PartialEq)]
pub struct Meta {
title: Option<String>,
}
impl Meta {
pub const REQUIRED: &'static [&'static str] = &[];
pub const ALLOWED: &'static [&'static str] = &["date", "link", "title", "author"];
pub const ALLOW_ANY_UNNAMED: bool = false;
fn set_title(&mut self, title: &str) {
self.title = Some(title.into());
}
pub fn process(&self, _site: &Site, meta: &mut PageMeta) -> Result<String, SiteError> {
if let Some(title) = &self.title {
meta.set_title(title.into());
}
Ok("".into())
}
}
impl From<&ParsedDirective> for Meta {
fn from(p: &ParsedDirective) -> Self {
let mut meta = Meta::default();
let args = p.args();
if let Some(title) = args.get("title") {
meta.set_title(title);
}
meta
}
}
|