feat: bundle and serve logo + favicon too

~500kB more, but binary is already ~24MB
to change those just replace files inside ./web/ and rebuild, at runtime
it's possible to add hrefs to other locations but not to change the
static file served (because we don't read fs at runtime)
This commit is contained in:
əlemi 2024-01-03 22:29:13 +01:00
parent da2f1bf9d0
commit 5d83cf39b9
Signed by: alemi
GPG key ID: A4895B84D311642C
6 changed files with 22 additions and 3 deletions

View file

@ -38,7 +38,7 @@ pub struct ConfigTemplate {
#[serde_inline_default("guestbook".into())] #[serde_inline_default("guestbook".into())]
pub title: String, pub title: String,
#[serde_inline_default("https://cdn.alemi.dev/social/someriver.jpg".into())] #[serde_inline_default("/logo.jpg".into())]
pub logo: String, pub logo: String,
#[serde_inline_default("you found my guestbook! please take a moment to sign it (:".into())] #[serde_inline_default("you found my guestbook! please take a moment to sign it (:".into())]

View file

@ -16,6 +16,8 @@ pub fn create_router_with_app_routes(state: Context) -> Router {
use sailfish::TemplateOnce; use sailfish::TemplateOnce;
let template = state.template.clone(); let template = state.template.clone();
router = router router = router
.route("/favicon.ico", get(|| async { crate::web::STATIC_FAVICON }))
.route("/logo.jpg", get(|| async { crate::web::STATIC_LOGO }))
.route("/style.css", get(|| async { Css(crate::web::STATIC_CSS) })) .route("/style.css", get(|| async { Css(crate::web::STATIC_CSS) }))
.route("/infiniscroll.js", get(|| async { JavaScript(crate::web::STATIC_JS) })) .route("/infiniscroll.js", get(|| async { JavaScript(crate::web::STATIC_JS) }))
.route("/", get(|| async move { .route("/", get(|| async move {

View file

@ -4,6 +4,8 @@ use crate::config::ConfigTemplate;
pub const STATIC_CSS : &str = include_str!("../web/style.css"); pub const STATIC_CSS : &str = include_str!("../web/style.css");
pub const STATIC_JS : &str = include_str!("../web/infiniscroll.js"); pub const STATIC_JS : &str = include_str!("../web/infiniscroll.js");
pub const STATIC_FAVICON : &[u8] = include_bytes!("../web/favicon.ico");
pub const STATIC_LOGO : &[u8] = include_bytes!("../web/logo.jpg");
#[derive(Debug, TemplateOnce)] #[derive(Debug, TemplateOnce)]
#[template(path = "index.stpl")] #[template(path = "index.stpl")]

BIN
web/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

BIN
web/logo.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 500 KiB

View file

@ -49,6 +49,21 @@ table.center {
font-size: .65em; font-size: .65em;
} }
.moreinfo {
cursor: help;
text-decoration: underline;
color: #AAAAAA;
}
.moreinfo:hover {
font-weight: bold;
}
.hidden-text {
color: #333333;
}
img.avatar { img.avatar {
border-radius: 50%; border-radius: 50%;
padding: .25em; padding: .25em;
@ -110,7 +125,7 @@ textarea:focus {
} }
@media screen and (max-width: 1600px) { @media screen and (max-width: 1600px) {
img.pixar { img.round-cover {
width: 60%; width: 60%;
border: solid 15px var(--accent); border: solid 15px var(--accent);
} }
@ -138,7 +153,7 @@ textarea:focus {
} }
@media screen and (max-width: 700px) { @media screen and (max-width: 700px) {
img.pixar { img.round-cover {
border: solid 10px var(--accent); border: solid 10px var(--accent);
padding: 15px; padding: 15px;
} }