Skip to content

Commit

Permalink
Add a simple permlink mechanism
Browse files Browse the repository at this point in the history
  • Loading branch information
utensil committed Oct 9, 2024
1 parent 04ed19d commit a0aab05
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 7 deletions.
12 changes: 12 additions & 0 deletions assets/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Redirecting...</title>
<meta http-equiv="refresh" content="0; url=./index.xml">
</head>
<body>
<p>If you are not redirected automatically, follow this <a href="./index.xml">link</a>.</p>
</body>
</html>
3 changes: 2 additions & 1 deletion biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"dev.ts",
"bun_build.js",
"postcss.config.js",
"tailwind.config.js"
"tailwind.config.js",
"permlink.js"
],
"ignoreUnknown": false,
"ignore": []
Expand Down
6 changes: 3 additions & 3 deletions dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ const app = new Elysia({
idleTimeout: 960,
},
})
.get('/', ({ redirect }) => {
return redirect('/index.xml')
})
// .get('/', ({ redirect }) => {
// return redirect('/index.xml')
// })
.use(
staticPlugin({
assets: 'output',
Expand Down
21 changes: 21 additions & 0 deletions permlink.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { mkdirSync } from 'node:fs'

const file = Bun.file('./output/forest.json')
const output = await file.text()
const all_trees = JSON.parse(output)
const index_html = await Bun.file('./assets/index.html').text()

for (const [tree_id, tree] of Object.entries(all_trees)) {
if (tree.metas) {
// console.log(tree_id, tree.metas);
if (tree.metas.permlink) {
const permlink = tree.metas.permlink
console.log(tree_id, permlink)
mkdirSync(`./output/${permlink}`, { recursive: true })
await Bun.write(
`./output/${permlink}/index.html`,
index_html.replaceAll('./index.xml', `../${tree_id}.xml`),
)
}
}
}
3 changes: 1 addition & 2 deletions trees/cg-macros.tree
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
\tag{macro}

\def\normbar{\verb~|\|~}
\def\norm[x]{\normbar\x\normbar}

\def\norm[x]{\lVert\x\rVert}
\def\point[x]{\boldsymbol{\x}}


Expand Down
2 changes: 2 additions & 0 deletions trees/uts-0018.tree
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
\import{macros}
% clifford hopf spin tt ag math draft tech exp notes readings
\tag{root}
% \meta{permlink}{reading-diary}

\put\transclude/numbered{false}

Expand All @@ -17,6 +18,7 @@
\mdblock{10-09}{
- read [C++ Package Managers: The Ultimate Roundup](https://moderncppdevops.com/pkg-mngr-roundup/), and might start using [xrepo](https://xrepo.xmake.io/) for C/C++ package management, it also supports a wide range of [package repositories](https://xmake.io/#/home?id=supported-package-repositories), including Conan, Conda, Vcpkg, Homebrew, Apt, and Cargo. But not [BinaryBuilder.jl ecosystem](https://github.com/JuliaPackaging/BinaryBuilder.jl) (see also [this FAQ](https://docs.binarybuilder.org/dev/FAQ/#Hey,-this-is-cool,-can-I-use-this-for-my-non-Julia-related-project?)).
- clarify the license for GinacLean, laying the ground for potential future work around [Cadabra 2](https://github.com/kpeeters/cadabra2), which is licensed under GPLv3
- learn about [Kento Okura's forest and Glade](https://kentookura.srht.site/) and [Nota](https://nota-lang.org/)

}

Expand Down
2 changes: 1 addition & 1 deletion trees/uts-002F.tree
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ I'm a bit rusty on Vim mode of VS Code, here are some useful keys that I like us

Recalled by [VSCode Vim ROADMAP](https://github.com/VSCodeVim/Vim/blob/HEAD/ROADMAP.md).

Got to this because of trying Vim mode in Zed lately. Should check out [zed-101-setup](https://github.com/jellydn/zed-101-setup) for configurations and key maps inspirations.
Got to this because of trying Vim mode in Zed lately. Should also check out [zed-101-setup](https://github.com/jellydn/zed-101-setup) for configurations and key maps inspirations.
}

0 comments on commit a0aab05

Please sign in to comment.