aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGabriel A. Giovanini <mail@gabrielgio.me>2022-06-09 20:10:19 +0200
committerGabriel A. Giovanini <mail@gabrielgio.me>2022-06-09 20:10:19 +0200
commitb4472b41214eeeacce071df41bf0f782e1f16d6d (patch)
treeefb666792785ba98c177990cfc349cdb9d6a56c7 /src
parente44658641b75076b702e690df166820c1d133f24 (diff)
downloadmacroblog.rs-b4472b41214eeeacce071df41bf0f782e1f16d6d.tar.gz
macroblog.rs-b4472b41214eeeacce071df41bf0f782e1f16d6d.tar.bz2
macroblog.rs-b4472b41214eeeacce071df41bf0f782e1f16d6d.zip
feat: Move from pico to custom css
Use css from my current blog, which is a lot smaller. The text itself looks good but the code still breaks the page. Metrics: - hyper: 16.37 KB / 16.47 KB transferred - 1 request
Diffstat (limited to 'src')
-rw-r--r--src/blog.rs32
-rw-r--r--src/router.rs11
2 files changed, 20 insertions, 23 deletions
diff --git a/src/blog.rs b/src/blog.rs
index 6bbda49..0fa9543 100644
--- a/src/blog.rs
+++ b/src/blog.rs
@@ -1,9 +1,9 @@
+use chrono::NaiveDate;
+use regex::Regex;
use rust_embed::RustEmbed;
use sailfish::TemplateOnce;
-use chrono::NaiveDate;
-use regex::{Regex};
+use std::cmp::{Eq, Ord, PartialEq, PartialOrd};
use std::str;
-use std::cmp::{PartialOrd, Ord, PartialEq, Eq};
const BLOG_REGEX: &str = r"(?P<date>[\d]{4}-[\d]{2}-[\d]{2})(?P<title>[a-zA-Z0-9-_]*)";
@@ -11,7 +11,6 @@ const BLOG_REGEX: &str = r"(?P<date>[\d]{4}-[\d]{2}-[\d]{2})(?P<title>[a-zA-Z0-9
#[folder = "content/posts/"]
struct PostAsset;
-
#[derive(TemplateOnce)]
#[template(path = "index.html")]
struct IndexTemplate {
@@ -23,7 +22,7 @@ struct IndexTemplate {
struct PostTemplate {
content: String,
title: String,
- date: String
+ date: String,
}
#[derive(PartialEq, Eq, PartialOrd, Ord)]
@@ -43,12 +42,11 @@ impl BlogEntry {
BlogEntry {
title: String::from(title),
file: String::from(path),
- datetime: NaiveDate::parse_from_str(date, "%Y-%m-%d").unwrap()
+ datetime: NaiveDate::parse_from_str(date, "%Y-%m-%d").unwrap(),
}
}
pub fn read_assets() -> Vec<BlogEntry> {
-
let mut entries: Vec<BlogEntry> = PostAsset::iter()
.map(|e| format!("{}", e))
.map(|e| BlogEntry::new(&e))
@@ -61,29 +59,27 @@ impl BlogEntry {
}
fn get_file_content(path: &str) -> String {
- let buffer = PostAsset::get(path)
- .unwrap()
- .data
- .into_owned();
+ let buffer = PostAsset::get(path).unwrap().data.into_owned();
return String::from_utf8(buffer).unwrap();
}
-
pub fn render_post_page(path: &String) -> String {
let blog = BlogEntry::new(path);
PostTemplate {
content: get_file_content(path),
title: blog.title,
- date: blog.datetime.format("%Y-%m-%d").to_string()
+ date: blog.datetime.format("%Y-%m-%d").to_string(),
}
- .render_once()
- .unwrap()
+ .render_once()
+ .unwrap()
}
pub fn render_index_page() -> String {
- IndexTemplate { posts: BlogEntry::read_assets() }
- .render_once()
- .unwrap()
+ IndexTemplate {
+ posts: BlogEntry::read_assets(),
+ }
+ .render_once()
+ .unwrap()
}
diff --git a/src/router.rs b/src/router.rs
index 0bba091..35fdf3e 100644
--- a/src/router.rs
+++ b/src/router.rs
@@ -1,4 +1,4 @@
-use regex::{Regex};
+use regex::Regex;
const ACTION_REGEX: &str = r"/{0,1}(?P<action>\w*)/(?P<id>.+)";
@@ -14,14 +14,15 @@ impl Router {
let caps = re.captures(path);
let action = match caps {
Some(ref value) => &value["action"],
- None => "index"
+ None => "index",
};
match action {
- "posts" => Router::Post { page: caps.unwrap()["id"].to_string() },
+ "posts" => Router::Post {
+ page: caps.unwrap()["id"].to_string(),
+ },
"index" => Router::Index,
- _ => Router::NotFound
+ _ => Router::NotFound,
}
}
}
-