initial commit
This commit is contained in:
commit
6c1c2fc043
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,15 @@
|
|||
[package]
|
||||
name = "sepiatones_xyz"
|
||||
version = "1.0.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
# webserver framework
|
||||
rocket = "0.5.1"
|
||||
rocket_dyn_templates = { version = "0.2.0", features = ["handlebars"] }
|
||||
# data serialization
|
||||
serde = { version = "1.0.210", features = ["derive"] }
|
||||
# HTML parsing
|
||||
scraper = "0.20.0"
|
||||
# handling times/dates
|
||||
chrono = { version = "0.4.38", features = ["serde"] }
|
|
@ -0,0 +1,11 @@
|
|||
<article>
|
||||
<h2>About</h2>
|
||||
<p>I program sometimes. I can't decide on a language.</p>
|
||||
<p>Lately I'm focused on processing e-sports statistics in rust for degenerate betting purposes, and writing games in zig with raylib.</p>
|
||||
<p>This blog was made with htmx and rust. I will not post the code unless you bother me about it, because I am lazy.</p>
|
||||
<h3>Socials</h3>
|
||||
<ul>
|
||||
<li><a href="https://x.com/sepiatonal">x</a></li>
|
||||
<li><a href="https://discord.com/users/105121538805669888">discord</a></li>
|
||||
</ul>
|
||||
</article>
|
|
@ -0,0 +1,8 @@
|
|||
<head>
|
||||
<meta name="title" content="Other Post">
|
||||
<meta name="date" content="2024-09-24T00:00:00Z">
|
||||
</head>
|
||||
<article>
|
||||
<h1>Welcome to another post!</h1>
|
||||
<p>another one!</p>
|
||||
</article>
|
|
@ -0,0 +1,4 @@
|
|||
<article>
|
||||
<h1>Test</h1>
|
||||
<p>This is just a test!</p>
|
||||
</article>
|
|
@ -0,0 +1,464 @@
|
|||
@import url('https://fonts.cdnfonts.com/css/jetbrains-mono-2');
|
||||
|
||||
:root {
|
||||
--font-family: "JetBrains Mono", monospace;
|
||||
--line-height: 1.20rem;
|
||||
--border-thickness: 2px;
|
||||
--text-color: #000;
|
||||
--text-color-alt: #666;
|
||||
--background-color: #fff;
|
||||
--background-color-alt: #eee;
|
||||
|
||||
--font-weight-normal: 500;
|
||||
--font-weight-medium: 600;
|
||||
--font-weight-bold: 800;
|
||||
|
||||
font-family: var(--font-family);
|
||||
font-optical-sizing: auto;
|
||||
font-weight: var(--font-weight-normal);
|
||||
font-style: normal;
|
||||
font-variant-numeric: tabular-nums lining-nums;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
:root {
|
||||
--text-color: #fff;
|
||||
--text-color-alt: #aaa;
|
||||
--background-color: #000;
|
||||
--background-color-alt: #111;
|
||||
}
|
||||
}
|
||||
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
html {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
background: var(--background-color);
|
||||
color: var(--text-color);
|
||||
}
|
||||
|
||||
body {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
margin: 0;
|
||||
padding: var(--line-height) 2ch;
|
||||
max-width: calc(min(80ch, round(down, 100%, 1ch)));
|
||||
line-height: var(--line-height);
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
@media screen and (max-width: 480px) {
|
||||
:root {
|
||||
font-size: 14px;
|
||||
}
|
||||
body {
|
||||
padding: var(--line-height) 1ch;
|
||||
}
|
||||
}
|
||||
|
||||
h1, h2, h3, h4, h5, h6 {
|
||||
font-weight: var(--font-weight-bold);
|
||||
margin: 0 0;
|
||||
line-height: var(--line-height);
|
||||
}
|
||||
|
||||
h1, h2 {
|
||||
margin-bottom: var(--line-height);
|
||||
}
|
||||
|
||||
h3, h4, h5, h6 {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 2rem;
|
||||
line-height: calc(2 * var(--line-height));
|
||||
text-transform: uppercase;
|
||||
}
|
||||
h2 {
|
||||
font-size: 1.5rem;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
h3 {
|
||||
font-size: 1.0rem;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
hr {
|
||||
position: relative;
|
||||
display: block;
|
||||
height: var(--line-height);
|
||||
margin: calc(var(--line-height) * 1.5) 0;
|
||||
border: none;
|
||||
color: var(--text-color);
|
||||
}
|
||||
hr:after {
|
||||
display: block;
|
||||
content: "";
|
||||
position: absolute;
|
||||
top: calc(var(--line-height) / 2 - var(--border-thickness));
|
||||
left: 0;
|
||||
width: 100%;
|
||||
border-top: calc(var(--border-thickness) * 3) double var(--text-color);
|
||||
height: 0;
|
||||
}
|
||||
|
||||
a {
|
||||
text-decoration-thickness: var(--border-thickness);
|
||||
}
|
||||
|
||||
a:link, a:visited {
|
||||
color: var(--text-color);
|
||||
}
|
||||
|
||||
p {
|
||||
margin-bottom: var(--line-height);
|
||||
}
|
||||
|
||||
strong {
|
||||
font-weight: var(--font-weight-bold);
|
||||
}
|
||||
em {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
sub {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
margin: 0;
|
||||
vertical-align: sub;
|
||||
line-height: 0;
|
||||
width: calc(1ch / 0.75);
|
||||
font-size: .75rem;
|
||||
}
|
||||
|
||||
table {
|
||||
position: relative;
|
||||
top: calc(var(--line-height) / 2);
|
||||
width: calc(round(down, 100%, 1ch));
|
||||
border-collapse: collapse;
|
||||
margin: 0 0 calc(var(--line-height) * 2);
|
||||
}
|
||||
|
||||
th, td {
|
||||
border: var(--border-thickness) solid var(--text-color);
|
||||
padding:
|
||||
calc((var(--line-height) / 2))
|
||||
calc(1ch - var(--border-thickness) / 2)
|
||||
calc((var(--line-height) / 2) - (var(--border-thickness)))
|
||||
;
|
||||
line-height: var(--line-height);
|
||||
vertical-align: top;
|
||||
text-align: left;
|
||||
}
|
||||
table tbody tr:first-child > * {
|
||||
padding-top: calc((var(--line-height) / 2) - var(--border-thickness));
|
||||
}
|
||||
|
||||
|
||||
th {
|
||||
font-weight: 700;
|
||||
}
|
||||
.width-min {
|
||||
width: 0%;
|
||||
}
|
||||
.width-auto {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.header {
|
||||
margin-bottom: calc(var(--line-height) * 2);
|
||||
}
|
||||
.header h1 {
|
||||
margin: 0;
|
||||
}
|
||||
.header tr td:last-child {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
p {
|
||||
word-break: break-word;
|
||||
word-wrap: break-word;
|
||||
hyphens: auto;
|
||||
}
|
||||
|
||||
img, video {
|
||||
display: block;
|
||||
width: 100%;
|
||||
object-fit: contain;
|
||||
overflow: hidden;
|
||||
}
|
||||
img {
|
||||
font-style: italic;
|
||||
color: var(--text-color-alt);
|
||||
}
|
||||
|
||||
details {
|
||||
border: var(--border-thickness) solid var(--text-color);
|
||||
padding: calc(var(--line-height) - var(--border-thickness)) 1ch;
|
||||
margin-bottom: var(--line-height);
|
||||
}
|
||||
|
||||
summary {
|
||||
font-weight: var(--font-weight-medium);
|
||||
cursor: pointer;
|
||||
}
|
||||
details[open] summary {
|
||||
margin-bottom: var(--line-height);
|
||||
}
|
||||
|
||||
details ::marker {
|
||||
display: inline-block;
|
||||
content: '▶';
|
||||
margin: 0;
|
||||
}
|
||||
details[open] ::marker {
|
||||
content: '▼';
|
||||
}
|
||||
|
||||
details :last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
pre {
|
||||
white-space: pre;
|
||||
overflow-x: auto;
|
||||
margin: var(--line-height) 0;
|
||||
overflow-y: hidden;
|
||||
}
|
||||
figure pre {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
pre, code {
|
||||
font-family: var(--font-family);
|
||||
}
|
||||
|
||||
code {
|
||||
font-weight: var(--font-weight-medium);
|
||||
}
|
||||
|
||||
figure {
|
||||
margin: calc(var(--line-height) * 2) 3ch;
|
||||
overflow-x: auto;
|
||||
overflow-y: hidden;
|
||||
}
|
||||
|
||||
figcaption {
|
||||
display: block;
|
||||
font-style: italic;
|
||||
margin-top: var(--line-height);
|
||||
}
|
||||
|
||||
ul, ol {
|
||||
padding: 0;
|
||||
margin: 0 0 var(--line-height);
|
||||
}
|
||||
|
||||
ul {
|
||||
list-style-type: square;
|
||||
padding: 0 0 0 2ch;
|
||||
}
|
||||
ol {
|
||||
list-style-type: none;
|
||||
counter-reset: item;
|
||||
padding: 0;
|
||||
}
|
||||
ol ul,
|
||||
ol ol,
|
||||
ul ol,
|
||||
ul ul {
|
||||
padding: 0 0 0 3ch;
|
||||
margin: 0;
|
||||
}
|
||||
ol li:before {
|
||||
content: counters(item, ".") ". ";
|
||||
counter-increment: item;
|
||||
font-weight: var(--font-weight-medium);
|
||||
}
|
||||
|
||||
li {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
li::marker {
|
||||
line-height: 0;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar {
|
||||
height: var(--line-height);
|
||||
}
|
||||
|
||||
input, button, textarea {
|
||||
border: var(--border-thickness) solid var(--text-color);
|
||||
padding:
|
||||
calc(var(--line-height) / 2 - var(--border-thickness))
|
||||
calc(1ch - var(--border-thickness));
|
||||
margin: 0;
|
||||
font: inherit;
|
||||
font-weight: inherit;
|
||||
height: calc(var(--line-height) * 2);
|
||||
width: auto;
|
||||
overflow: visible;
|
||||
background: var(--background-color);
|
||||
color: var(--text-color);
|
||||
line-height: normal;
|
||||
-webkit-font-smoothing: inherit;
|
||||
-moz-osx-font-smoothing: inherit;
|
||||
-webkit-appearance: none;
|
||||
}
|
||||
|
||||
input[type=checkbox] {
|
||||
display: inline-grid;
|
||||
place-content: center;
|
||||
vertical-align: top;
|
||||
width: 2ch;
|
||||
height: var(--line-height);
|
||||
cursor: pointer;
|
||||
}
|
||||
input[type=checkbox]:checked:before {
|
||||
content: "";
|
||||
width: 1ch;
|
||||
height: calc(var(--line-height) / 2);
|
||||
background: var(--text-color);
|
||||
}
|
||||
|
||||
button:focus, input:focus {
|
||||
--border-thickness: 3px;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
input {
|
||||
width: calc(round(down, 100%, 1ch));
|
||||
}
|
||||
::placeholder {
|
||||
color: var(--text-color-alt);
|
||||
opacity: 1;
|
||||
}
|
||||
::-ms-input-placeholder {
|
||||
color: var(--text-color-alt);
|
||||
}
|
||||
button::-moz-focus-inner {
|
||||
padding: 0;
|
||||
border: 0
|
||||
}
|
||||
|
||||
button {
|
||||
text-transform: uppercase;
|
||||
font-weight: var(--font-weight-medium);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
button:hover {
|
||||
background: var(--background-color-alt);
|
||||
}
|
||||
button:active {
|
||||
transform: translate(2px, 2px);
|
||||
}
|
||||
|
||||
label {
|
||||
display: block;
|
||||
width: calc(round(down, 100%, 1ch));
|
||||
height: auto;
|
||||
line-height: var(--line-height);
|
||||
font-weight: var(--font-weight-medium);
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
label input {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.tree, .tree ul {
|
||||
position: relative;
|
||||
padding-left: 0;
|
||||
list-style-type: none;
|
||||
line-height: var(--line-height);
|
||||
}
|
||||
.tree ul {
|
||||
margin: 0;
|
||||
}
|
||||
.tree ul li {
|
||||
position: relative;
|
||||
padding-left: 1.5ch;
|
||||
margin-left: 1.5ch;
|
||||
border-left: var(--border-thickness) solid var(--text-color);
|
||||
}
|
||||
.tree ul li:before {
|
||||
position: absolute;
|
||||
display: block;
|
||||
top: calc(var(--line-height) / 2);
|
||||
left: 0;
|
||||
content: "";
|
||||
width: 1ch;
|
||||
border-bottom: var(--border-thickness) solid var(--text-color);
|
||||
}
|
||||
.tree ul li:last-child {
|
||||
border-left: none;
|
||||
}
|
||||
.tree ul li:last-child:after {
|
||||
position: absolute;
|
||||
display: block;
|
||||
top: 0;
|
||||
left: 0;
|
||||
content: "";
|
||||
height: calc(var(--line-height) / 2);
|
||||
border-left: var(--border-thickness) solid var(--text-color);
|
||||
}
|
||||
|
||||
.grid {
|
||||
--grid-cells: 0;
|
||||
display: flex;
|
||||
gap: 1ch;
|
||||
width: calc(round(down, 100%, (1ch * var(--grid-cells)) - (1ch * var(--grid-cells) - 1)));
|
||||
margin-bottom: var(--line-height);
|
||||
}
|
||||
|
||||
.grid > *,
|
||||
.grid > input {
|
||||
flex: 0 0 calc(round(down, (100% - (1ch * (var(--grid-cells) - 1))) / var(--grid-cells), 1ch));
|
||||
}
|
||||
.grid:has(> :last-child:nth-child(1)) { --grid-cells: 1; }
|
||||
.grid:has(> :last-child:nth-child(2)) { --grid-cells: 2; }
|
||||
.grid:has(> :last-child:nth-child(3)) { --grid-cells: 3; }
|
||||
.grid:has(> :last-child:nth-child(4)) { --grid-cells: 4; }
|
||||
.grid:has(> :last-child:nth-child(5)) { --grid-cells: 5; }
|
||||
.grid:has(> :last-child:nth-child(6)) { --grid-cells: 6; }
|
||||
.grid:has(> :last-child:nth-child(7)) { --grid-cells: 7; }
|
||||
.grid:has(> :last-child:nth-child(8)) { --grid-cells: 8; }
|
||||
.grid:has(> :last-child:nth-child(9)) { --grid-cells: 9; }
|
||||
|
||||
/* DEBUG UTILITIES */
|
||||
|
||||
.debug .debug-grid {
|
||||
--color: color-mix(in srgb, var(--text-color) 10%, var(--background-color) 90%);
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
z-index: -1;
|
||||
background-image:
|
||||
repeating-linear-gradient(var(--color) 0 1px, transparent 1px 100%),
|
||||
repeating-linear-gradient(90deg, var(--color) 0 1px, transparent 1px 100%);
|
||||
background-size: 1ch var(--line-height);
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.debug .off-grid {
|
||||
background: rgba(255, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.debug-toggle-label {
|
||||
text-align: right;
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
:root {
|
||||
--text-color: #575279;
|
||||
--text-color-alt: #797593;
|
||||
--background-color: #faf4ed;
|
||||
--background-color-alt: #fffaf3;
|
||||
--background-overlay: #f2e9e1;
|
||||
}
|
||||
|
||||
a {
|
||||
color: #56949f;
|
||||
text-decoration: underline;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
color: #286983;
|
||||
}
|
||||
|
||||
a:visited {
|
||||
color: #907aa9;
|
||||
}
|
||||
|
||||
::selection {
|
||||
background-color: #cecacd;
|
||||
color: #fffaf3;
|
||||
}
|
||||
|
||||
aside {
|
||||
background-color: var(--background-overlay);
|
||||
}
|
||||
|
||||
aside:empty {
|
||||
display: none;
|
||||
}
|
||||
|
||||
h1 {
|
||||
color: #b4637a;
|
||||
}
|
||||
|
||||
h2 {
|
||||
color: #d7827e;
|
||||
}
|
||||
|
||||
h3 {
|
||||
color: #ea9d34;
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
[Unit]
|
||||
Description=Blog of sepiatones
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
WorkingDirectory=/www/sepiatones_xyz
|
||||
ExecStart=/www/sepiatones_xyz/sepiatones_xyz
|
||||
Restart=always
|
||||
User=sepiatones_xyz
|
||||
Group=sepiatones_xyz
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
|
@ -0,0 +1,102 @@
|
|||
#[macro_use]
|
||||
extern crate rocket;
|
||||
|
||||
use chrono::{DateTime, Utc};
|
||||
use rocket::fs::NamedFile;
|
||||
use rocket_dyn_templates::{context, Template};
|
||||
use scraper::{Html, Selector};
|
||||
use serde::Serialize;
|
||||
use std::collections::HashMap;
|
||||
use std::path::Path;
|
||||
|
||||
#[get("/")]
|
||||
fn serve_main() -> Template {
|
||||
Template::render(
|
||||
"index",
|
||||
context! {
|
||||
content: std::fs::read_to_string("data/pages/about.html").unwrap_or_else(|_| "Error loading about page.".to_string())
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
#[get("/posts/<post_name>")]
|
||||
async fn serve_post(post_name: &str) -> Template {
|
||||
let file_path = Path::new("data/posts").join(format!("{}.html", post_name));
|
||||
let file_maybe = std::fs::read_to_string(file_path);
|
||||
let file = match file_maybe.ok() {
|
||||
Some(s) => s,
|
||||
None => "404: File not found.".to_string(),
|
||||
};
|
||||
Template::render(
|
||||
"index",
|
||||
context! {
|
||||
content: file
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
#[get("/style/<file>")]
|
||||
async fn serve_css(file: &str) -> Option<NamedFile> {
|
||||
let file_path = Path::new("data/style").join(format!("{}", file));
|
||||
NamedFile::open(file_path).await.ok()
|
||||
}
|
||||
|
||||
#[get("/recent_posts")]
|
||||
fn list_recent_posts() -> Template {
|
||||
#[derive(Serialize)]
|
||||
struct Post {
|
||||
title: String,
|
||||
path: String,
|
||||
date: String,
|
||||
date_utc: DateTime<Utc>,
|
||||
}
|
||||
|
||||
let posts_dir = Path::new("data/posts");
|
||||
|
||||
let mut posts = Vec::new();
|
||||
if let Ok(entries) = std::fs::read_dir(posts_dir) {
|
||||
for entry in entries {
|
||||
if let Ok(entry) = entry {
|
||||
if let Some(file_name) = entry.file_name().to_str() {
|
||||
if file_name.ends_with(".html") {
|
||||
let file = match std::fs::read_to_string(posts_dir.join(file_name)) {
|
||||
Ok(s) => s,
|
||||
Err(_) => continue,
|
||||
};
|
||||
let document = Html::parse_document(file.as_str());
|
||||
let mut tags: HashMap<&str, &str> = HashMap::new();
|
||||
for meta_tag in document.select(&Selector::parse("meta").unwrap()) {
|
||||
let name = meta_tag.value().attr("name").unwrap_or("");
|
||||
let content = meta_tag.value().attr("content").unwrap_or("");
|
||||
tags.insert(name, content);
|
||||
}
|
||||
let title = tags.get("title").unwrap_or(&"Untitled Post").to_string();
|
||||
let date_utc = tags
|
||||
.get("date")
|
||||
.and_then(|s_date| DateTime::parse_from_rfc3339(s_date).ok())
|
||||
.map(|dt| dt.with_timezone(&Utc))
|
||||
.unwrap_or_else(|| DateTime::from_timestamp(0, 0).unwrap());
|
||||
let date = date_utc.format("%d-%m-%Y").to_string();
|
||||
posts.push(Post {
|
||||
title,
|
||||
date_utc,
|
||||
date,
|
||||
path: format!("/posts/{}", file_name.trim_end_matches(".html")),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
posts.sort_by_key(|post| std::cmp::Reverse(post.date_utc));
|
||||
|
||||
Template::render("posts_list", context! { posts: posts })
|
||||
}
|
||||
|
||||
#[launch]
|
||||
fn rocket() -> _ {
|
||||
rocket::build()
|
||||
.mount("/", routes![serve_post, serve_main, serve_css, list_recent_posts])
|
||||
.attach(Template::fairing())
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
<html>
|
||||
<head>
|
||||
<script src="https://unpkg.com/htmx.org@2.0.3" integrity="sha384-0895/pl2MU10Hqc6jd4RvrthNlDiE9U1tWmX7WRESftEDRosgxNsQG/Ze9YMRzHq" crossorigin="anonymous"></script>
|
||||
<link rel="stylesheet" href="/style/monospace.css">
|
||||
<link rel="stylesheet" href="/style/style.css">
|
||||
</head>
|
||||
<body style="max-width: 120ch; margin: auto;">
|
||||
<header style="display: flex; justify-content: space-between; width: 100%;">
|
||||
<h1>sepiatones.xyz</h1>
|
||||
<nav>
|
||||
<a href="/">about</a>
|
||||
<a hx-get="/recent_posts" hx-target="#sidebar">posts</a>
|
||||
</nav>
|
||||
</header>
|
||||
<main id="primary" style="display: flex; justify-content: space-between;">
|
||||
{{{content}}}
|
||||
<aside id="sidebar" style="width: 60ch; padding: var(--line-height) 1ch;"></aside>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,9 @@
|
|||
<h2 style="display: flex; justify-content: space-between; align-items: center;">
|
||||
Posts
|
||||
<span style="cursor: pointer;" hx-on:click="document.getElementById('sidebar').innerHTML = ''">X</span>
|
||||
</h2>
|
||||
<ul>
|
||||
{{#each posts}}
|
||||
<li><a href="{{path}}">{{title}} - {{date}}</a></li>
|
||||
{{/each}}
|
||||
</ul>
|
Loading…
Reference in New Issue