Skip to content

Commit

Permalink
wip: card pages
Browse files Browse the repository at this point in the history
  • Loading branch information
Arteneko committed Aug 17, 2023
1 parent 250ecfb commit 28eff2e
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 20 deletions.
29 changes: 29 additions & 0 deletions src/card.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
use maud::{html, Markup, DOCTYPE};

use crate::{
config::{Neighbor, Node},
fragments::head,
};

pub fn make_card_page(
_node: &Node,
// dependencies
_neighbors: &Vec<Neighbor>,
) -> Markup {
html! {
(DOCTYPE)
head {
(head())

// TODO: Social card stuff!!!
title { "WOOF TODO" }
}

body {
// TODO: make the header pretty??
// maybe not the full logo, or maybe a "back to" link

// TODO: re-make the card here, with extra stuff?? maybe
}
}
}
25 changes: 25 additions & 0 deletions src/fragments.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
use maud::{html, Markup};

pub fn banner() -> Markup {
html! {
header.banner {
h1.title {
span.banner {
span.block {
span { "Cypher" }
span { "Weavers" }
}
span.aside { "Cafe" }
}
}
}
}
}

pub fn head() -> Markup {
html! {
meta charset="utf-8";
meta name="viewport" content="width=device-width, initial-scale=1";
link rel="stylesheet" href="style.css";
}
}
20 changes: 16 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,19 @@ use std::{
fs::{self, copy, create_dir_all},
};

use crate::{config::Ring, page::make_page};
use crate::{card::make_card_page, config::Ring, page::make_page};

mod cache;
mod card;
mod config;
mod fragments;
mod page;

fn make_output(content: &String, config: &String) -> Result<(), Box<dyn Error>> {
fn make_output(
content: &String,
_cards: &Vec<String>,
config: &String,
) -> Result<(), Box<dyn Error>> {
copy("style.css", "public/style.css")?;
fs::write("public/index.html", content)?;
fs::write("public/config.json", config)?;
Expand Down Expand Up @@ -60,12 +66,18 @@ fn main() {
}
}

println!(":: making the hypersoup document");
println!(":: making the hypersoup documents");
let web_page = make_page(&ring.clone().into());
let card_pages: Vec<String> = ring
.nodes
.clone()
.into_iter()
.map(|node| make_card_page(&node, &ring.neighbors).into_string())
.collect();

let json_config = json!(ring);

make_output(&web_page.0, &json_config.to_string())
make_output(&web_page.0, &card_pages, &json_config.to_string())
.expect("somehow failed to create the website on-disk");

println!(":: woof!");
Expand Down
23 changes: 7 additions & 16 deletions src/page.rs
Original file line number Diff line number Diff line change
@@ -1,30 +1,21 @@
use maud::{html, Markup, DOCTYPE};

use crate::config::Ring;
use crate::{
config::Ring,
fragments::{banner, head},
};

pub fn make_page(data: &Ring) -> Markup {
html! {
(DOCTYPE)
html {
head {
meta charset="utf-8";
meta name="viewport" content="width=device-width, initial-scale=1";
title { (data.title) }
(head())

link rel="stylesheet" href="style.css";
title { (data.title) }
}
body {
header.banner {
h1.title {
span.banner {
span.block {
span { "Cypher" }
span { "Weavers" }
}
span.aside { "Cafe" }
}
}
}
(banner())

section.page {
h2 { "Home" span.cursor-blink; }
Expand Down

0 comments on commit 28eff2e

Please sign in to comment.