mirror of
https://github.com/osmarks/website
synced 2024-12-23 16:40:31 +00:00
add openring "webring" bit
This commit is contained in:
parent
17a7847c9e
commit
fc8688ff97
4
.gitignore
vendored
4
.gitignore
vendored
@ -1,2 +1,4 @@
|
|||||||
node_modules
|
node_modules
|
||||||
out
|
out
|
||||||
|
openring
|
||||||
|
draft
|
16
openring.html
Normal file
16
openring.html
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<h3>From other blogs</h3>
|
||||||
|
<section class="atl">
|
||||||
|
{{range .Articles}}
|
||||||
|
<div class="art">
|
||||||
|
<h4>
|
||||||
|
<a href="{{.Link}}" target="_blank" rel="noopener">{{.Title}}</a>
|
||||||
|
</h4>
|
||||||
|
<p class="sum">{{.Summary}}</p>
|
||||||
|
<small class="src">
|
||||||
|
via <a href="{{.SourceLink}}">{{.SourceTitle}}</a>
|
||||||
|
</small>
|
||||||
|
<small class="dat">{{.Date | datef "02/01/2006"}}</small>
|
||||||
|
</div>
|
||||||
|
{{end}}
|
||||||
|
</section>
|
||||||
|
<p class="atr">Generated by <a href="https://git.sr.ht/~sircmpwn/openring">openring</a></p>
|
@ -1,5 +1,14 @@
|
|||||||
{
|
{
|
||||||
"name": "Oliver's Website",
|
"name": "Oliver's Website",
|
||||||
"domain": "osmarks.tk",
|
"domain": "osmarks.tk",
|
||||||
"siteDescription": "Whimsical uselessness available conveniently online."
|
"siteDescription": "Whimsical uselessness available conveniently online.",
|
||||||
|
"feeds": [
|
||||||
|
"https://blogs.sciencemag.org/pipeline/feed",
|
||||||
|
"https://www.rtl-sdr.com/feed/",
|
||||||
|
"https://slatestarcodex.com/feed/",
|
||||||
|
"https://www.rifters.com/crawl/?feed=rss2",
|
||||||
|
"https://drewdevault.com/feed.xml",
|
||||||
|
"https://www.giantitp.com/comics/oots.rss",
|
||||||
|
"https://qntm.org/rss.php"
|
||||||
|
]
|
||||||
}
|
}
|
63
src/index.js
63
src/index.js
@ -13,7 +13,8 @@ const customParseFormat = require("dayjs/plugin/customParseFormat")
|
|||||||
const nanoid = require("nanoid")
|
const nanoid = require("nanoid")
|
||||||
const htmlMinifier = require("html-minifier").minify
|
const htmlMinifier = require("html-minifier").minify
|
||||||
const terser = require("terser")
|
const terser = require("terser")
|
||||||
const { minify } = require("html-minifier")
|
const util = require("util")
|
||||||
|
const childProcess = require("child_process")
|
||||||
|
|
||||||
dayjs.extend(customParseFormat)
|
dayjs.extend(customParseFormat)
|
||||||
|
|
||||||
@ -140,29 +141,44 @@ const processAssets = async templates => {
|
|||||||
const outAssets = path.join(outDir, "assets")
|
const outAssets = path.join(outDir, "assets")
|
||||||
await fse.ensureDir(outAssets)
|
await fse.ensureDir(outAssets)
|
||||||
|
|
||||||
applyTemplate(templates.experiment, path.join(assetsDir, "offline.html"), () => path.join(outAssets, "offline.html"), {})
|
|
||||||
|
|
||||||
// Write out the web manifest after templating it using somewhat misapplied frontend templating stuff
|
// Write out the web manifest after templating it using somewhat misapplied frontend templating stuff
|
||||||
const manifest = mustache.render(await readFile(path.join(assetsDir, "manifest.webmanifest")), globalData)
|
const runManifest = async () => {
|
||||||
await fsp.writeFile(path.join(outAssets, "manifest.webmanifest"), manifest)
|
const m = mustache.render(await readFile(path.join(assetsDir, "manifest.webmanifest")), globalData)
|
||||||
|
fsp.writeFile(path.join(outAssets, "manifest.webmanifest"), m)
|
||||||
|
}
|
||||||
|
|
||||||
|
const runJS = async () => {
|
||||||
|
const jsDir = path.join(assetsDir, "js")
|
||||||
|
const jsOutDir = path.join(outAssets, "js")
|
||||||
|
await Promise.all((await fsp.readdir(jsDir)).map(async file => {
|
||||||
|
const fullpath = path.join(jsDir, file)
|
||||||
|
await minifyJSFile(await readFile(fullpath), file, path.join(jsOutDir, file))
|
||||||
|
}))
|
||||||
|
|
||||||
|
const serviceWorker = mustache.render(await readFile(path.join(assetsDir, "sw.js")), globalData)
|
||||||
|
await minifyJSFile(serviceWorker, "sw.js", path.join(outDir, "sw.js"))
|
||||||
|
}
|
||||||
|
|
||||||
const copyAsset = subpath => fse.copy(path.join(assetsDir, subpath), path.join(outAssets, subpath))
|
const copyAsset = subpath => fse.copy(path.join(assetsDir, subpath), path.join(outAssets, subpath))
|
||||||
// Directly copy images, JS, CSS
|
// Directly copy images, JS, CSS
|
||||||
await Promise.all([await copyAsset("images"), await copyAsset("css")])
|
await Promise.all([
|
||||||
|
copyAsset("images"),
|
||||||
const jsDir = path.join(assetsDir, "js")
|
copyAsset("css"),
|
||||||
const jsOutDir = path.join(outAssets, "js")
|
runManifest,
|
||||||
await Promise.all((await fsp.readdir(jsDir)).map(async file => {
|
runJS,
|
||||||
const fullpath = path.join(jsDir, file)
|
applyTemplate(templates.experiment, path.join(assetsDir, "offline.html"), () => path.join(outAssets, "offline.html"), {})
|
||||||
await minifyJSFile(await readFile(fullpath), file, path.join(jsOutDir, file))
|
])
|
||||||
}))
|
|
||||||
|
|
||||||
const serviceWorker = mustache.render(await readFile(path.join(assetsDir, "sw.js")), globalData)
|
|
||||||
await minifyJSFile(serviceWorker, "sw.js", path.join(outDir, "sw.js"))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
globalData.renderDate = date => date.format("DD/MM/YYYY")
|
globalData.renderDate = date => date.format("DD/MM/YYYY")
|
||||||
|
|
||||||
|
const runOpenring = async () => {
|
||||||
|
// wildly unsafe but only runs on input from me anyway
|
||||||
|
const out = await util.promisify(childProcess.exec)(`./openring -n6 ${globalData.feeds.map(x => "-s " + x).join(" ")} < openring.html`)
|
||||||
|
console.log(out.stderr)
|
||||||
|
return out.stdout
|
||||||
|
}
|
||||||
|
|
||||||
const run = async () => {
|
const run = async () => {
|
||||||
const css = await sass.renderSync({
|
const css = await sass.renderSync({
|
||||||
data: await readFile(path.join(root, "style.sass")),
|
data: await readFile(path.join(root, "style.sass")),
|
||||||
@ -172,12 +188,17 @@ const run = async () => {
|
|||||||
globalData.css = css
|
globalData.css = css
|
||||||
|
|
||||||
const templates = await loadDir(templateDir, async fullPath => pug.compile(await readFile(fullPath), { filename: fullPath }))
|
const templates = await loadDir(templateDir, async fullPath => pug.compile(await readFile(fullPath), { filename: fullPath }))
|
||||||
const experimentsList = R.sortBy(x => x.title, R.values(await processExperiments(templates)))
|
const [exp, blg, opr, ..._] = await Promise.all([
|
||||||
const blogList = R.sortBy(x => x.updated ? -x.updated.valueOf() : 0, R.values(await processBlog(templates)))
|
processExperiments(templates),
|
||||||
await processAssets(templates)
|
processBlog(templates),
|
||||||
await processErrorPages(templates)
|
runOpenring(),
|
||||||
|
processAssets(templates),
|
||||||
|
processErrorPages(templates)
|
||||||
|
])
|
||||||
|
const experimentsList = R.sortBy(x => x.title, R.values(exp))
|
||||||
|
const blogList = R.sortBy(x => x.updated ? -x.updated.valueOf() : 0, R.values(blg))
|
||||||
|
|
||||||
const index = templates.index({ ...globalData, title: "Index", experiments: experimentsList, posts: blogList })
|
const index = templates.index({ ...globalData, title: "Index", experiments: experimentsList, posts: blogList, openring: opr })
|
||||||
await fsp.writeFile(path.join(outDir, "index.html"), index)
|
await fsp.writeFile(path.join(outDir, "index.html"), index)
|
||||||
|
|
||||||
const rssFeed = templates.rss({ ...globalData, items: blogList, lastUpdate: new Date() })
|
const rssFeed = templates.rss({ ...globalData, items: blogList, lastUpdate: new Date() })
|
||||||
|
27
style.sass
27
style.sass
@ -68,4 +68,29 @@ ul
|
|||||||
.smallinfo
|
.smallinfo
|
||||||
font-size: 0.8em
|
font-size: 0.8em
|
||||||
margin-top: 0.5em
|
margin-top: 0.5em
|
||||||
margin-bottom: 0.5em
|
margin-bottom: 0.5em
|
||||||
|
|
||||||
|
.ring
|
||||||
|
.atl
|
||||||
|
display: flex
|
||||||
|
flex-wrap: wrap
|
||||||
|
margin: -0.5rem
|
||||||
|
|
||||||
|
h4
|
||||||
|
margin: 0
|
||||||
|
|
||||||
|
.art
|
||||||
|
flex: 1 1 0
|
||||||
|
display: flex
|
||||||
|
flex-direction: column
|
||||||
|
margin: 0.5rem
|
||||||
|
padding: 0.5rem
|
||||||
|
background: #eee
|
||||||
|
min-width: 20em
|
||||||
|
.sum
|
||||||
|
font-size: 0.8rem
|
||||||
|
flex: 1 1 0
|
||||||
|
.atr
|
||||||
|
text-align: right
|
||||||
|
font-size: 0.8rem
|
||||||
|
color: #555
|
||||||
|
@ -22,4 +22,8 @@ block content
|
|||||||
span= ` `
|
span= ` `
|
||||||
span.description!= experiment.description
|
span.description!= experiment.description
|
||||||
|
|
||||||
p Get updates to the blog (not experiments) in your favourite RSS reader using the <a href="/rss.xml">RSS feed</a>.
|
p Get updates to the blog (not experiments) in your favourite RSS reader using the <a href="/rss.xml">RSS feed</a>.
|
||||||
|
p View some of my projects (and whatever else)
|
||||||
|
a(href=`https://git.${domain}/`) my git hosting.
|
||||||
|
|
||||||
|
.ring!= openring
|
Loading…
Reference in New Issue
Block a user