use crate::prelude::*;
const LINK: &str = "<a href=\"https://pagetop.cillero.es\" rel=\"noopener noreferrer\">PageTop</a>";
#[derive(AutoDefault, Clone, Debug, Getters)]
pub struct PoweredBy {
copyright: Option<String>,
}
impl Component for PoweredBy {
fn new() -> Self {
let year = Utc::now().format("%Y").to_string();
let c = util::join!(year, " © ", global::SETTINGS.app.name);
PoweredBy { copyright: Some(c) }
}
fn prepare(&self, cx: &mut Context) -> Result<Markup, ComponentError> {
Ok(html! {
div id=[self.id()] class="poweredby" {
@if let Some(c) = self.copyright() {
span class="poweredby__copyright" { (c) "." } " "
}
span class="poweredby__pagetop" {
(L10n::l("poweredby_pagetop").with_arg("pagetop_link", LINK).using(cx))
}
}
})
}
}
impl PoweredBy {
#[builder_fn]
pub fn with_copyright(mut self, copyright: Option<impl Into<String>>) -> Self {
self.copyright = copyright.map(Into::into);
self
}
}