blob: 534300ab8bd9ff2c6a81278af8bd07e21e7786f8 (
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
|
use crate::error::SiteError;
use crate::page::PageMeta;
use crate::site::{Shortcut as S, Site};
use crate::wikitext::ParsedDirective;
#[derive(Debug, Eq, PartialEq)]
pub struct Shortcut {
shortcut: S,
}
impl Shortcut {
pub const REQUIRED: &'static [&'static str] = &["desc", "name", "url"];
pub const ALLOWED: &'static [&'static str] = &[];
pub const ALLOW_ANY_UNNAMED: bool = false;
pub fn new(shortcut: S) -> Self {
Self { shortcut }
}
pub fn process(&self, site: &mut Site, _meta: &mut PageMeta) -> Result<String, SiteError> {
site.add_shortcut(self.shortcut.clone());
Ok("".into())
}
}
impl From<&ParsedDirective> for Shortcut {
fn from(p: &ParsedDirective) -> Self {
let args = p.args();
let name = args.get("name").unwrap();
let desc = args.get("desc").unwrap();
let url = args.get("url").unwrap();
Self::new(S::new(name, desc, url))
}
}
|