fix footer styles

This commit is contained in:
Maciej Jur 2024-04-14 20:43:08 +02:00
parent 655fad8240
commit 289a1a4a4d
Signed by: kamov
GPG key ID: 191CBFF5F72ECAFD
8 changed files with 79 additions and 70 deletions

View file

@ -2,7 +2,7 @@ build:
cargo run cargo run
deploy: build deploy: build
rsync -Pavz ./dist/ kamoshi:/var/www/kamoshi.org --delete --mkpath rsync -Pavzq ./dist/ kamoshi:/var/www/kamoshi.org --delete
serve: serve:
python -m http.server -d ./dist python -m http.server -d ./dist

8
content/wiki/index.md Normal file
View file

@ -0,0 +1,8 @@
---
title: Wiki home page
---
Welcome! In this wiki I'll write about various things which don't really fit
into any other place. This wiki is very much inspired by [Nikita Voloboev's wiki](https://wiki.nikiv.dev/),
as well as [Gwern Branwen's really amazing website](https://gwern.net/),
and I do really mean it! It's a marvel. But these are only some of the
inspirations which I am always on the lookout for.

View file

@ -1,16 +0,0 @@
---
layout: ../../layouts/Wiki.astro
title: Wiki home page
---
import ProjectSizeChart from '@components/wiki/SizeChart.astro';
Welcome! In this wiki I'll write about various things which don't really fit into any other place.
This wiki is very much inspired by [Nikita Voloboev's wiki](https://wiki.nikiv.dev/), as well as [Gwern Branwen's really amazing website](https://gwern.net/), and I do really mean it! It's a marvel.
But these are only some of the inspirations which I am always on the lookout for.
## Project size
The following chart displays the number of lines of code categorized by file extension within the repository of this website.
<ProjectSizeChart/>

View file

@ -3,10 +3,11 @@ use std::path::{Path, PathBuf};
use std::io::Write; use std::io::Write;
use crate::html::LinkableData; use crate::html::LinkableData;
use crate::Everything;
pub enum AssetKind { pub enum AssetKind {
Html(Box<dyn Fn(&[&Asset]) -> String>), Html(Box<dyn Fn(&Everything) -> String>),
Image, Image,
Unknown, Unknown,
Bib(hayagriva::Library), Bib(hayagriva::Library),
@ -19,13 +20,13 @@ pub struct Asset {
pub meta: super::Source, pub meta: super::Source,
} }
pub struct Virtual(pub PathBuf, pub Box<dyn Fn(&[&Asset]) -> String>); pub struct Virtual(pub PathBuf, pub Box<dyn Fn(&Everything) -> String>);
impl Virtual { impl Virtual {
pub fn new<P, F>(path: P, call: F) -> Self pub fn new<P, F>(path: P, call: F) -> Self
where where
P: AsRef<Path>, P: AsRef<Path>,
F: Fn(&[&Asset]) -> String + 'static F: Fn(&Everything) -> String + 'static
{ {
Self(path.as_ref().into(), Box::new(call)) Self(path.as_ref().into(), Box::new(call))
} }
@ -58,16 +59,18 @@ pub fn render(items: &[Item]) {
}) })
.collect(); .collect();
let everything = Everything { assets: &assets };
for item in items { for item in items {
match item { match item {
Item::Real(real) => render_real(real, &assets), Item::Real(real) => render_real(real, &everything),
Item::Fake(fake) => render_fake(fake, &assets), Item::Fake(fake) => render_fake(fake, &everything),
} }
} }
} }
fn render_real(item: &Asset, assets: &[&Asset]) { fn render_real(item: &Asset, assets: &Everything) {
match &item.kind { match &item.kind {
AssetKind::Html(render) => { AssetKind::Html(render) => {
let i = &item.meta.path; let i = &item.meta.path;
@ -98,7 +101,7 @@ fn render_real(item: &Asset, assets: &[&Asset]) {
} }
} }
fn render_fake(item: &Virtual, assets: &[&Asset]) { fn render_fake(item: &Virtual, assets: &Everything) {
let Virtual(out, render) = item; let Virtual(out, render) = item;
let o = Path::new("dist").join(&out); let o = Path::new("dist").join(&out);

View file

@ -5,6 +5,8 @@ use crate::REPO;
pub fn head(title: &str) -> impl Renderable + '_ { pub fn head(title: &str) -> impl Renderable + '_ {
let title = format!("{} | kamoshi.org", title);
maud_move!( maud_move!(
meta charset="utf-8"; meta charset="utf-8";
meta name="viewport" content="width=device-width, initial-scale=1"; meta name="viewport" content="width=device-width, initial-scale=1";
@ -81,8 +83,7 @@ pub fn navbar() -> impl Renderable {
} }
pub fn footer() -> impl Renderable { pub fn footer() -> impl Renderable {
let year = chrono::Utc::now().year(); let copy = format!("Copyright &copy; {} Maciej Jur", &REPO.year);
let copy = format!("Copyright &copy; {} Maciej Jur", year);
let mail = "maciej@kamoshi.org"; let mail = "maciej@kamoshi.org";
let href = format!("mailto:{}", mail); let href = format!("mailto:{}", mail);
let repo = format!("{}/tree/{}", &REPO.link, &REPO.hash); let repo = format!("{}/tree/{}", &REPO.link, &REPO.hash);
@ -97,8 +98,13 @@ pub fn footer() -> impl Renderable {
(mail) (mail)
} }
} }
a href=(repo) { div .repo {
"view source" a href=(repo) {
(&REPO.hash)
}
div {
(&REPO.date)
}
} }
a .right.footer__cc-wrap rel="license" href="http://creativecommons.org/licenses/by/4.0/" { a .right.footer__cc-wrap rel="license" href="http://creativecommons.org/licenses/by/4.0/" {
img .footer__cc-stamp alt="Creative Commons License" width="88" height="31" src="/static/svg/by.svg"; img .footer__cc-stamp alt="Creative Commons License" width="88" height="31" src="/static/svg/by.svg";

View file

@ -1,7 +1,7 @@
use std::process::Command; use std::process::Command;
use std::{collections::HashMap, path::Path}; use std::{collections::HashMap, path::Path};
use std::fs; use std::fs;
use chrono::Datelike; use chrono::{Datelike, Utc};
use grass; use grass;
use html::LinkableData; use html::LinkableData;
use hypertext::{Raw, Renderable}; use hypertext::{Raw, Renderable};
@ -15,26 +15,49 @@ mod utils;
#[derive(Debug)] #[derive(Debug)]
struct RepoInfo { struct BuildInfo {
pub year: i32,
pub date: String,
pub link: String, pub link: String,
pub hash: String, pub hash: String,
} }
static REPO: Lazy<RepoInfo> = Lazy::new(|| RepoInfo { static REPO: Lazy<BuildInfo> = Lazy::new(|| {
link: "https://github.com/kamoshi/kamoshi.org".into(), let time = chrono::Utc::now();
hash: String::from_utf8(
Command::new("git") BuildInfo {
.args(["rev-parse", "HEAD"]) year: time.year(),
.output() date: time.format("%Y/%m/%d %H:%M").to_string(),
link: "https://github.com/kamoshi/kamoshi.org".into(),
hash: String::from_utf8(
Command::new("git")
.args(["rev-parse", "--short", "HEAD"])
.output()
.unwrap()
.stdout
)
.unwrap() .unwrap()
.stdout .trim()
) .into()
.unwrap() }
.trim()
.into()
}); });
/// This struct allows for querying the website hierarchy
struct Everything<'a> {
assets: &'a [&'a gen::Asset],
}
impl Everything<'_> {
fn get_linkable(&self, path: &str) -> Vec<LinkableData> {
let pattern = glob::Pattern::new(path).unwrap();
self.assets.iter()
.filter(|f| pattern.matches_path(&f.out))
.filter_map(|f| f.link.clone())
.collect()
}
}
trait Transformable { trait Transformable {
fn transform<'f, 'm, 'html, T>(&'f self, content: T) -> impl Renderable + 'html fn transform<'f, 'm, 'html, T>(&'f self, content: T) -> impl Renderable + 'html
@ -157,15 +180,7 @@ fn transform<T>(meta: gen::Source) -> gen::Asset
let (fm, md) = md::preflight::<T>(&data); let (fm, md) = md::preflight::<T>(&data);
let link = T::as_link(&fm, Path::new("/").join(&loc).to_str().unwrap().to_owned()); let link = T::as_link(&fm, Path::new("/").join(&loc).to_str().unwrap().to_owned());
let call = move |assets: &[&gen::Asset]| { let call = move |_: &Everything| {
// let lib = assets.iter().filter_map(|&a| match &a.kind {
// gen::AssetKind::Bib(lib) => Some(lib),
// _ => None,
// }).next();
//
// println!("{:?}", lib);
let data = T::render(&md); let data = T::render(&md);
let data = T::transform(&fm, Raw(data)).render().into(); let data = T::transform(&fm, Raw(data)).render().into();
data data
@ -217,8 +232,6 @@ fn transform<T>(meta: gen::Source) -> gen::Asset
} }
fn main() { fn main() {
println!("{:?}", &*REPO);
if fs::metadata("dist").is_ok() { if fs::metadata("dist").is_ok() {
println!("Cleaning dist"); println!("Cleaning dist");
fs::remove_dir_all("dist").unwrap(); fs::remove_dir_all("dist").unwrap();
@ -245,22 +258,12 @@ fn main() {
path: "content/index.md".into() path: "content/index.md".into()
} }
}.into(), }.into(),
gen::Virtual("posts/index.html".into(), Box::new(|assets| { gen::Virtual("posts/index.html".into(), Box::new(|all|
let pattern = glob::Pattern::new("posts/**/*.html").unwrap(); to_list(all.get_linkable("posts/**/*.html"))
let posts = assets.iter() )).into(),
.filter(|f| pattern.matches_path(&f.out)) gen::Virtual("slides/index.html".into(), Box::new(|all|
.filter_map(|f| f.link.clone()) to_list(all.get_linkable("slides/**/*.html"))
.collect(); )).into(),
to_list(posts)
})).into(),
gen::Virtual("slides/index.html".into(), Box::new(|assets| {
let pattern = glob::Pattern::new("slides/**/*.html").unwrap();
let posts = assets.iter()
.filter(|f| pattern.matches_path(&f.out))
.filter_map(|f| f.link.clone())
.collect();
to_list(posts)
})).into(),
], ],
gen::gather("content/about.md", &["md"].into()) gen::gather("content/about.md", &["md"].into())
.into_iter() .into_iter()

View file

@ -75,5 +75,3 @@ pub fn render(raw: &str) -> String {
String::from_utf8(html).unwrap() String::from_utf8(html).unwrap()
} }

View file

@ -3,6 +3,7 @@
grid-template-columns: 1fr auto 1fr; grid-template-columns: 1fr auto 1fr;
grid-column-gap: 0.25em; grid-column-gap: 0.25em;
justify-items: center; justify-items: center;
align-items: center;
max-height: min-content; max-height: min-content;
padding: 0.5em; padding: 0.5em;
@ -18,6 +19,12 @@
margin-right: auto; margin-right: auto;
} }
.repo {
display: flex;
flex-direction: column;
align-items: center;
}
.right { .right {
margin-left: auto; margin-left: auto;
} }