fix footer styles
This commit is contained in:
parent
655fad8240
commit
289a1a4a4d
2
Makefile
2
Makefile
|
@ -2,7 +2,7 @@ build:
|
|||
cargo run
|
||||
|
||||
deploy: build
|
||||
rsync -Pavz ./dist/ kamoshi:/var/www/kamoshi.org --delete --mkpath
|
||||
rsync -Pavzq ./dist/ kamoshi:/var/www/kamoshi.org --delete
|
||||
|
||||
serve:
|
||||
python -m http.server -d ./dist
|
||||
|
|
8
content/wiki/index.md
Normal file
8
content/wiki/index.md
Normal 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.
|
|
@ -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/>
|
|
@ -3,10 +3,11 @@ use std::path::{Path, PathBuf};
|
|||
use std::io::Write;
|
||||
|
||||
use crate::html::LinkableData;
|
||||
use crate::Everything;
|
||||
|
||||
|
||||
pub enum AssetKind {
|
||||
Html(Box<dyn Fn(&[&Asset]) -> String>),
|
||||
Html(Box<dyn Fn(&Everything) -> String>),
|
||||
Image,
|
||||
Unknown,
|
||||
Bib(hayagriva::Library),
|
||||
|
@ -19,13 +20,13 @@ pub struct Asset {
|
|||
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 {
|
||||
pub fn new<P, F>(path: P, call: F) -> Self
|
||||
where
|
||||
P: AsRef<Path>,
|
||||
F: Fn(&[&Asset]) -> String + 'static
|
||||
F: Fn(&Everything) -> String + 'static
|
||||
{
|
||||
Self(path.as_ref().into(), Box::new(call))
|
||||
}
|
||||
|
@ -58,16 +59,18 @@ pub fn render(items: &[Item]) {
|
|||
})
|
||||
.collect();
|
||||
|
||||
let everything = Everything { assets: &assets };
|
||||
|
||||
for item in items {
|
||||
match item {
|
||||
Item::Real(real) => render_real(real, &assets),
|
||||
Item::Fake(fake) => render_fake(fake, &assets),
|
||||
Item::Real(real) => render_real(real, &everything),
|
||||
Item::Fake(fake) => render_fake(fake, &everything),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fn render_real(item: &Asset, assets: &[&Asset]) {
|
||||
fn render_real(item: &Asset, assets: &Everything) {
|
||||
match &item.kind {
|
||||
AssetKind::Html(render) => {
|
||||
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 o = Path::new("dist").join(&out);
|
||||
|
|
|
@ -5,6 +5,8 @@ use crate::REPO;
|
|||
|
||||
|
||||
pub fn head(title: &str) -> impl Renderable + '_ {
|
||||
let title = format!("{} | kamoshi.org", title);
|
||||
|
||||
maud_move!(
|
||||
meta charset="utf-8";
|
||||
meta name="viewport" content="width=device-width, initial-scale=1";
|
||||
|
@ -81,8 +83,7 @@ pub fn navbar() -> impl Renderable {
|
|||
}
|
||||
|
||||
pub fn footer() -> impl Renderable {
|
||||
let year = chrono::Utc::now().year();
|
||||
let copy = format!("Copyright © {} Maciej Jur", year);
|
||||
let copy = format!("Copyright © {} Maciej Jur", &REPO.year);
|
||||
let mail = "maciej@kamoshi.org";
|
||||
let href = format!("mailto:{}", mail);
|
||||
let repo = format!("{}/tree/{}", &REPO.link, &REPO.hash);
|
||||
|
@ -97,8 +98,13 @@ pub fn footer() -> impl Renderable {
|
|||
(mail)
|
||||
}
|
||||
}
|
||||
a href=(repo) {
|
||||
"view source"
|
||||
div .repo {
|
||||
a href=(repo) {
|
||||
(&REPO.hash)
|
||||
}
|
||||
div {
|
||||
(&REPO.date)
|
||||
}
|
||||
}
|
||||
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";
|
||||
|
|
83
src/main.rs
83
src/main.rs
|
@ -1,7 +1,7 @@
|
|||
use std::process::Command;
|
||||
use std::{collections::HashMap, path::Path};
|
||||
use std::fs;
|
||||
use chrono::Datelike;
|
||||
use chrono::{Datelike, Utc};
|
||||
use grass;
|
||||
use html::LinkableData;
|
||||
use hypertext::{Raw, Renderable};
|
||||
|
@ -15,26 +15,49 @@ mod utils;
|
|||
|
||||
|
||||
#[derive(Debug)]
|
||||
struct RepoInfo {
|
||||
struct BuildInfo {
|
||||
pub year: i32,
|
||||
pub date: String,
|
||||
pub link: String,
|
||||
pub hash: String,
|
||||
}
|
||||
|
||||
|
||||
static REPO: Lazy<RepoInfo> = Lazy::new(|| RepoInfo {
|
||||
link: "https://github.com/kamoshi/kamoshi.org".into(),
|
||||
hash: String::from_utf8(
|
||||
Command::new("git")
|
||||
.args(["rev-parse", "HEAD"])
|
||||
.output()
|
||||
static REPO: Lazy<BuildInfo> = Lazy::new(|| {
|
||||
let time = chrono::Utc::now();
|
||||
|
||||
BuildInfo {
|
||||
year: time.year(),
|
||||
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()
|
||||
.stdout
|
||||
)
|
||||
.unwrap()
|
||||
.trim()
|
||||
.into()
|
||||
.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 {
|
||||
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 link = T::as_link(&fm, Path::new("/").join(&loc).to_str().unwrap().to_owned());
|
||||
|
||||
let call = move |assets: &[&gen::Asset]| {
|
||||
// let lib = assets.iter().filter_map(|&a| match &a.kind {
|
||||
// gen::AssetKind::Bib(lib) => Some(lib),
|
||||
// _ => None,
|
||||
// }).next();
|
||||
//
|
||||
// println!("{:?}", lib);
|
||||
|
||||
|
||||
let call = move |_: &Everything| {
|
||||
let data = T::render(&md);
|
||||
let data = T::transform(&fm, Raw(data)).render().into();
|
||||
data
|
||||
|
@ -217,8 +232,6 @@ fn transform<T>(meta: gen::Source) -> gen::Asset
|
|||
}
|
||||
|
||||
fn main() {
|
||||
println!("{:?}", &*REPO);
|
||||
|
||||
if fs::metadata("dist").is_ok() {
|
||||
println!("Cleaning dist");
|
||||
fs::remove_dir_all("dist").unwrap();
|
||||
|
@ -245,22 +258,12 @@ fn main() {
|
|||
path: "content/index.md".into()
|
||||
}
|
||||
}.into(),
|
||||
gen::Virtual("posts/index.html".into(), Box::new(|assets| {
|
||||
let pattern = glob::Pattern::new("posts/**/*.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::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::Virtual("posts/index.html".into(), Box::new(|all|
|
||||
to_list(all.get_linkable("posts/**/*.html"))
|
||||
)).into(),
|
||||
gen::Virtual("slides/index.html".into(), Box::new(|all|
|
||||
to_list(all.get_linkable("slides/**/*.html"))
|
||||
)).into(),
|
||||
],
|
||||
gen::gather("content/about.md", &["md"].into())
|
||||
.into_iter()
|
||||
|
|
|
@ -75,5 +75,3 @@ pub fn render(raw: &str) -> String {
|
|||
String::from_utf8(html).unwrap()
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
grid-template-columns: 1fr auto 1fr;
|
||||
grid-column-gap: 0.25em;
|
||||
justify-items: center;
|
||||
align-items: center;
|
||||
|
||||
max-height: min-content;
|
||||
padding: 0.5em;
|
||||
|
@ -18,6 +19,12 @@
|
|||
margin-right: auto;
|
||||
}
|
||||
|
||||
.repo {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.right {
|
||||
margin-left: auto;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue