sitemap generates URL

This commit is contained in:
realaravinth 2021-07-25 20:15:44 +05:30
parent 189510c008
commit 0a8d36dc9f
No known key found for this signature in database
GPG key ID: AD9F0F08E855ED88
7 changed files with 33 additions and 15 deletions

View file

@ -66,6 +66,7 @@ pub mod routes {
pub sitekey: Sitekey, pub sitekey: Sitekey,
pub notifications: &'static str, pub notifications: &'static str,
pub settings: Settings, pub settings: Settings,
pub stats: &'static str,
} }
impl Panel { impl Panel {
@ -75,10 +76,11 @@ pub mod routes {
sitekey: Sitekey::new(), sitekey: Sitekey::new(),
notifications: "/notifications", notifications: "/notifications",
settings: Settings::new(), settings: Settings::new(),
stats: "/stats",
} }
} }
pub const fn get_sitemap() -> [&'static str; 5] { pub const fn get_sitemap() -> [&'static str; 6] {
const PANEL: Panel = Panel::new(); const PANEL: Panel = Panel::new();
const S: [&str; 2] = Sitekey::get_sitemap(); const S: [&str; 2] = Sitekey::get_sitemap();
@ -88,6 +90,7 @@ pub mod routes {
S[0], S[0],
S[1], S[1],
Settings::get_sitemap()[0], Settings::get_sitemap()[0],
PANEL.stats,
] ]
} }
} }

View file

@ -26,12 +26,19 @@ use crate::PAGES;
#[template(path = "sitemap.html")] #[template(path = "sitemap.html")]
struct IndexPage { struct IndexPage {
urls: [&'static str; 7], urls: [&'static str; 7],
domain: &'static str,
} }
impl Default for IndexPage { impl Default for IndexPage {
fn default() -> Self { fn default() -> Self {
let urls = Routes::get_sitemap(); let urls = Routes::get_sitemap();
Self { urls } let domain = if crate::SETTINGS.server.domain.ends_with('/') {
&crate::SETTINGS.server.domain[0..crate::SETTINGS.server.domain.len() - 1]
} else {
&crate::SETTINGS.server.domain
};
Self { urls, domain }
} }
} }

View file

@ -68,6 +68,10 @@ pub mod assets {
FILES.get("./static/cache/img/icon-trans.png").unwrap(), FILES.get("./static/cache/img/icon-trans.png").unwrap(),
"Logo" "Logo"
); );
pub static ref BAR_CHART: Img = (
FILES.get("./static/cache/img/svg/bar-chart.svg").unwrap(),
"Statistics"
);
} }
} }

1
static/cache/img/svg/bar-chart.svg vendored Normal file
View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-bar-chart"><line x1="12" y1="20" x2="12" y2="10"></line><line x1="18" y1="20" x2="18" y2="4"></line><line x1="6" y1="20" x2="6" y2="16"></line></svg>

After

Width:  |  Height:  |  Size: 353 B

View file

@ -1,4 +0,0 @@
<svg>
<title><=. ALT.></title>
<use xlink:href="<=. PATH .>#icon"></use>
</svg>

Before

Width:  |  Height:  |  Size: 84 B

View file

@ -30,7 +30,14 @@
</div> </div>
</a> </a>
</li> </li>
<li class="secondary-menu__item">
<a class="secondary-menu__item-link" href="<.= crate::PAGES.panel.sitekey.list .>">
<img class="secondary-menu__icon" src="<.= crate::BAR_CHART.0 .>" alt="<.= crate::BAR_CHART.1 .>" />
<div class="secondary-menu__item-name">
Statistics
</div>
</a>
</li>
<li class="secondary-menu__item"> <li class="secondary-menu__item">
<a class="secondary-menu__item-link" href="<.= crate::PAGES.panel.settings.home .>"> <a class="secondary-menu__item-link" href="<.= crate::PAGES.panel.settings.home .>">
<img class="secondary-menu__icon" src="<.= crate::SETTINGS_ICON.0 .>" alt="<.= crate::SETTINGS_ICON.1 .>" /> <img class="secondary-menu__icon" src="<.= crate::SETTINGS_ICON.0 .>" alt="<.= crate::SETTINGS_ICON.1 .>" />

View file

@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<. for url in urls.iter(){ .> <. for url in urls.iter(){ .>
<url> <url>
<loc><.= url .></loc> <loc>http://<.= domain .><.= url .></loc>
<lastmod><.= crate::COMPILED_DATE .></lastmod> <lastmod><.= crate::COMPILED_DATE .></lastmod>
<changefreq>weekly</changefreq> <changefreq>weekly</changefreq>
<priority>0.8</priority> <priority>0.8</priority>
</url> </url>
<. } .> <. } .>
</urlset> </urlset>