Merge branch 'master' into pages

This commit is contained in:
Jon Dough
2024-01-17 12:45:47 +05:30
8 changed files with 93 additions and 29 deletions

View File

@@ -7,30 +7,31 @@ import _posts_metadata from "./posts/_metadata.json";
import _site_info from "./site_info.json";
export interface PostMetadata {
title: string,
slug: string,
filename: string,
date: string,
author: string,
tags: string[],
title: string;
slug: string;
filename: string;
date: string;
author: string;
tags: string[];
archived: boolean;
}
export interface Post extends PostMetadata {
md_lines: string[],
html: string,
tags_exist: boolean,
md_lines: string[];
html: string;
tags_exist: boolean;
}
export interface RSSPost extends PostMetadata {
url: string,
last_updated: string,
html: string,
url: string;
last_updated: string;
html: string;
}
export interface SiteInfo {
title: string,
url: string,
icon: string,
title: string;
url: string;
icon: string;
}
let renderer: Renderer = new Renderer("templates", "components");
@@ -42,7 +43,13 @@ builder.serve_static_folder("static");
//home page
builder.serve_template(renderer, "/", "index", {
posts: posts_metadata,
posts: posts_metadata.filter((post) => !post.archived),
});
//archive page
builder.serve_template(renderer, "/archive", "archive", {
archived_posts: posts_metadata.filter((post) => post.archived),
no_archived_posts: posts_metadata.filter((post) => post.archived).length === 0,
});
//404 page (github pages)
@@ -86,7 +93,7 @@ for (let i=0; i < posts_metadata.length; i++) {
{
post,
next_post,
author_expected: post.author.toLowerCase().startsWith("jetstream0") || post.author.toLowerCase().startsWith("prussia"),
author_expected: post.author.toLowerCase().startsWith("jetstream0") || post.author.toLowerCase().startsWith("prussia") || post.author.toLowerCase().startsWith("stjet"),
}
);
}
@@ -110,7 +117,7 @@ for (let i=0; i < tags.length; i++) {
builder.serve_templates(renderer, tags_serve_paths, "tags", tags_vars);
//build rss feed
let first_posts: PostMetadata[] = posts_metadata.slice(0, 5); //not truly the recents, actually the first 5 posts in the json file, which is decided by me and usually the most recent posts
let first_posts: PostMetadata[] = posts_metadata.filter((post) => !post.archived).slice(0, 5); //not truly the recents, actually the first 5 posts in the json file, which is decided by me and usually the most recent posts
const site_info: SiteInfo = _site_info;

View File

@@ -10,14 +10,14 @@
},
"repository": {
"type": "git",
"url": "git+https://github.com/jetstream0/hedgeblog.git"
"url": "git+https://github.com/stjet/hedgeblog.git"
},
"author": "jetstream0/prussia",
"author": "stjet/prussia",
"license": "AGPL-3.0",
"bugs": {
"url": "https://github.com/jetstream0/hedgeblog/issues"
"url": "https://github.com/stjet/hedgeblog/issues"
},
"homepage": "https://github.com/jetstream0/hedgeblog#readme",
"homepage": "https://github.com/stjet/hedgeblog#readme",
"dependencies": {
"makoto": "^1.0.1"
},

1
posts/archived_post.md Normal file
View File

@@ -0,0 +1 @@
This post is *archived*.

View File

@@ -1,6 +1,6 @@
import { readFileSync } from "fs";
export const SYNTAX_REGEX = /\[\[ [a-zA-Z0-9.:/\-_!]+ \]\]/g;
export const SYNTAX_REGEX = /\[\[ [a-zA-Z0-9.:/\*\-_!]+ \]\]/g;
export type file_extension = `.${string}`;
@@ -89,10 +89,10 @@ export class Renderer {
if (recursion_layer > 5) throw Error("Components more than 5 layers deep, components may be referencing each other in infinite loop.");
if (typeof exp_parts[1] !== "string") throw Error("`component:` statement missing component file name afterwards");
let file_name: string = exp_parts[1];
if (!file_name.includes(".")) {
file_name += this.file_extension;
}
rendered += this.render_template(Renderer.concat_path(this.components_dir, file_name), vars, recursion_layer+1);
if (!file_name.includes(".")) {
file_name += this.file_extension;
}
rendered += this.render_template(Renderer.concat_path(this.components_dir, file_name), vars, recursion_layer+1);
} else if (exp_parts[0] === "for") {
if (for_loops[for_loops.length-1]?.index === index) {
//for loop already exists, just continue and do nothing
@@ -185,12 +185,21 @@ export class Renderer {
} else {
//compare with second var
let var_name2: string = exp_parts[2];
let if_in: boolean = false;
let if_not: boolean = false;
//*! is valid
if (var_name2.startsWith("*")) {
var_name2 = var_name2.slice(1, var_name2.length);
if_in = true;
}
if (var_name2.startsWith("!")) {
var_name2 = var_name2.slice(1, var_name2.length);
if_not = true;
}
let var_value2 = Renderer.get_var(var_name2, vars);
if (if_in) {
var_value2 = var_value2.find((ele) => ele === var_value);
}
if (if_not) {
//make sure the two compared variables are NOT equal
if (var_value !== var_value2) {

39
templates/archive.html Normal file
View File

@@ -0,0 +1,39 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>prussia fan club</title>
<link rel="icon" type="image/png" href="/favicon.ico">
<link rel="stylesheet" href="/styles/global.css">
<link rel="stylesheet" href="/styles/index.css">
<link rel="alternate" type="application/atom+xml" title="atom/rss feed for prussia fan club" href="/atom.xml"/>
</head>
<body>
[[ component:return ]]
[[ component:dark-mode-checkbox ]]
<div id="main">
<div>
<input id="fancy-title" type="checkbox"/><label for="fancy-title">Fancy Title</label>
<br>
<h2>prussiafan.club</h2>
<br>
<p>This is the archive of my blog, where posts bad enough to be hidden, but not terrible enough to be deleted, live.</p>
<p>Ah, what else? Uhhh... My favourite projects at the moment are <a href="https://github.com/stjet/pla-den-tor">pla-den-tor</a>, <a href="https://ztmy.prussia.dev">ztmy</a>, <a href="https://github.com/stjet/bananopie">bananopie</a>, <a href="https://mingde.prussia.dev">mingde</a>, and <a href="https://github.com/stjet/hedgeblog">this blog</a>. My favourite language is probably Lisp Scheme, but Typescript is nice too, except when it isn't.</p>
<p>You can also hire me!</p>
</div>
<div>
<ul>
[[ for:archived_posts:post ]]
[[ component:post-listing ]]
[[ endfor ]]
[[ if:no_archived_posts ]]
<li>No archived posts yet</li>
[[ endif ]]
</ul>
</div>
</div>
</body>
</html>
//, and a place where you can <a href="https://prussia.dev/sample">hire me</a>

View File

@@ -0,0 +1,6 @@
<div class="random" id="archive">
<div class="random-content">
<a href="/archive">Visit the archives</a>
</div>
<a href="/#quote1">More random stuff</a>
</div>

View File

@@ -8,5 +8,5 @@
<img src="88x31/mh.gif" alt="Certified mostly harmless" loading="lazy"/>
<img src="88x31/salt.gif" alt="Salt your passwords, OR ELSE!" loading="lazy"/>
</div>
<a href="/#quote1">More random stuff</a>
<a href="/#archive">More random stuff</a>
</div>

View File

@@ -7,6 +7,7 @@
<link rel="icon" type="image/png" href="/favicon.ico">
<link rel="stylesheet" href="/styles/global.css">
<link rel="stylesheet" href="/styles/index.css">
<link rel="alternate" type="application/atom+xml" title="atom/rss feed for prussia fan club" href="/atom.xml"/>
</head>
<body>
[[ component:dark-mode-checkbox ]]
@@ -16,7 +17,7 @@
<br>
<h2>prussiafan.club</h2>
<br>
<p>This is my blog. I also have a <a href="https://prussia.dev">portfolio</a>, <a href="https://prussia.dev/retro">retro style personal website</a>, and a place where you can <a href="https://prussia.dev/sample">hire me</a>.</p>
<p>This is my blog. I also have a <a href="https://prussia.dev">portfolio</a>, <a href="https://prussia.dev/retro">retro style personal website</a>. I like free software, privacy, yada yada.</p>
</div>
<div>
<ul>
@@ -27,6 +28,7 @@
</div>
<div>
[[ component:random/badges ]]
[[ component:random/archive ]]
[[ component:random/quote1 ]]
[[ component:random/quote2 ]]
[[ component:random/minesweeper ]]