mirror of
				https://github.com/osmarks/website
				synced 2025-10-31 13:53:01 +00:00 
			
		
		
		
	add openring "webring" bit
This commit is contained in:
		
							
								
								
									
										4
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							| @@ -1,2 +1,4 @@ | ||||
| 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", | ||||
|     "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 htmlMinifier = require("html-minifier").minify | ||||
| const terser = require("terser") | ||||
| const { minify } = require("html-minifier") | ||||
| const util = require("util") | ||||
| const childProcess = require("child_process") | ||||
|  | ||||
| dayjs.extend(customParseFormat) | ||||
|  | ||||
| @@ -140,29 +141,44 @@ const processAssets = async templates => { | ||||
|     const outAssets = path.join(outDir, "assets") | ||||
|     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  | ||||
|     const manifest = mustache.render(await readFile(path.join(assetsDir, "manifest.webmanifest")), globalData) | ||||
|     await fsp.writeFile(path.join(outAssets, "manifest.webmanifest"), manifest) | ||||
|     const runManifest = async () => { | ||||
|         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)) | ||||
|     // Directly copy images, JS, CSS | ||||
|     await Promise.all([await copyAsset("images"), await copyAsset("css")]) | ||||
|      | ||||
|     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")) | ||||
|     await Promise.all([ | ||||
|         copyAsset("images"),  | ||||
|         copyAsset("css"),  | ||||
|         runManifest, | ||||
|         runJS, | ||||
|         applyTemplate(templates.experiment, path.join(assetsDir, "offline.html"), () => path.join(outAssets, "offline.html"), {}) | ||||
|     ]) | ||||
| } | ||||
|  | ||||
| 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 css = await sass.renderSync({ | ||||
|         data: await readFile(path.join(root, "style.sass")), | ||||
| @@ -172,12 +188,17 @@ const run = async () => { | ||||
|     globalData.css = css | ||||
|  | ||||
|     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 blogList = R.sortBy(x => x.updated ? -x.updated.valueOf() : 0, R.values(await processBlog(templates))) | ||||
|     await processAssets(templates) | ||||
|     await processErrorPages(templates) | ||||
|     const [exp, blg, opr, ..._] = await Promise.all([ | ||||
|         processExperiments(templates),  | ||||
|         processBlog(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) | ||||
|  | ||||
|     const rssFeed = templates.rss({ ...globalData, items: blogList, lastUpdate: new Date() }) | ||||
|   | ||||
							
								
								
									
										27
									
								
								style.sass
									
									
									
									
									
								
							
							
						
						
									
										27
									
								
								style.sass
									
									
									
									
									
								
							| @@ -68,4 +68,29 @@ ul | ||||
| .smallinfo | ||||
|     font-size: 0.8em | ||||
|     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.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 | ||||
		Reference in New Issue
	
	Block a user