add a link to repo in footer

This commit is contained in:
Maciej Jur 2024-04-13 17:29:26 +02:00
parent dc96e49b34
commit 655fad8240
Signed by: kamov
GPG key ID: 191CBFF5F72ECAFD
3 changed files with 46 additions and 13 deletions

View file

@ -1,6 +1,8 @@
use chrono::{self, Datelike};
use hypertext::{html_elements, maud, maud_move, GlobalAttributes, Raw, Renderable};
use crate::REPO;
pub fn head(title: &str) -> impl Renderable + '_ {
maud_move!(
@ -83,10 +85,11 @@ pub fn footer() -> impl Renderable {
let copy = format!("Copyright © {} Maciej Jur", year);
let mail = "maciej@kamoshi.org";
let href = format!("mailto:{}", mail);
let repo = format!("{}/tree/{}", &REPO.link, &REPO.hash);
maud_move!(
footer .footer {
div {
div .left {
div {
(Raw(copy))
}
@ -94,7 +97,10 @@ pub fn footer() -> impl Renderable {
(mail)
}
}
a .footer__cc-wrap rel="license" href="http://creativecommons.org/licenses/by/4.0/" {
a href=(repo) {
"view source"
}
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";
}
}

View file

@ -1,9 +1,11 @@
use std::process::Command;
use std::{collections::HashMap, path::Path};
use std::fs;
use chrono::Datelike;
use grass;
use html::LinkableData;
use hypertext::{Raw, Renderable};
use once_cell::sync::Lazy;
mod md;
mod html;
@ -12,6 +14,28 @@ mod gen;
mod utils;
#[derive(Debug)]
struct RepoInfo {
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()
.unwrap()
.stdout
)
.unwrap()
.trim()
.into()
});
trait Transformable {
fn transform<'f, 'm, 'html, T>(&'f self, content: T) -> impl Renderable + 'html
where
@ -193,12 +217,7 @@ fn transform<T>(meta: gen::Source) -> gen::Asset
}
fn main() {
let xd = Command::new("git")
.args(["rev-parse", "HEAD"])
.output()
.unwrap();
println!("{:?}", String::from_utf8(xd.stdout).unwrap());
println!("{:?}", &*REPO);
if fs::metadata("dist").is_ok() {
println!("Cleaning dist");
@ -281,8 +300,6 @@ fn main() {
let css = grass::from_path("styles/styles.scss", &grass::Options::default()).unwrap();
fs::write("dist/styles.css", css).unwrap();
use std::process::Command;
let res = Command::new("pagefind")
.args(&["--site", "dist"])
.output()

View file

@ -1,7 +1,9 @@
.footer {
display: flex;
align-items: center;
justify-content: space-between;
display: grid;
grid-template-columns: 1fr auto 1fr;
grid-column-gap: 0.25em;
justify-items: center;
max-height: min-content;
padding: 0.5em;
font-size: var(--fs-sm);
@ -12,6 +14,14 @@
color: var(--c-primary);
}
.left {
margin-right: auto;
}
.right {
margin-left: auto;
}
&__cc-wrap {
display: block;
}