From 0ff62ea7886bdeff160682d3d5713c2c8a6dd4b1 Mon Sep 17 00:00:00 2001 From: sanine Date: Thu, 13 Jan 2022 17:41:02 -0600 Subject: initial commit --- .gitignore | 1 + config.lua | 12 +++++++++ layouts/base.lua | 45 +++++++++++++++++++++++++++++++ layouts/blog.lua | 8 ++++++ plugins/navigation.lua | 0 plugins/toolkit.lua | 42 +++++++++++++++++++++++++++++ public/about.html | 19 +++++++++++++ public/blog/announcing_honeysuckle.html | 44 ++++++++++++++++++++++++++++++ public/index.html | 19 +++++++++++++ public/projects/index.html | 15 +++++++++++ public/rss.xml | 15 +++++++++++ public/style.css | 44 ++++++++++++++++++++++++++++++ serve-http.sh | 19 +++++++++++++ site_root/about.lua | 17 ++++++++++++ site_root/blog/announcing_honeysuckle.lua | 37 +++++++++++++++++++++++++ site_root/index.lua | 28 +++++++++++++++++++ site_root/projects/index.lua | 12 +++++++++ site_root/style.css | 44 ++++++++++++++++++++++++++++++ 18 files changed, 421 insertions(+) create mode 100644 .gitignore create mode 100644 config.lua create mode 100644 layouts/base.lua create mode 100644 layouts/blog.lua create mode 100644 plugins/navigation.lua create mode 100644 plugins/toolkit.lua create mode 100644 public/about.html create mode 100644 public/blog/announcing_honeysuckle.html create mode 100644 public/index.html create mode 100644 public/projects/index.html create mode 100644 public/rss.xml create mode 100644 public/style.css create mode 100755 serve-http.sh create mode 100644 site_root/about.lua create mode 100644 site_root/blog/announcing_honeysuckle.lua create mode 100644 site_root/index.lua create mode 100644 site_root/projects/index.lua create mode 100644 site_root/style.css diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b25c15b --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*~ diff --git a/config.lua b/config.lua new file mode 100644 index 0000000..1f797ce --- /dev/null +++ b/config.lua @@ -0,0 +1,12 @@ +return { + site_name = 'sanine.net', + site_address = 'https://sanine.net/', + site_directory = 'site_root', + + layout_directory = 'layouts', + plugin_directory = 'plugins', + + exclude = { '.*~' }, + + rss_include = { 'blog' }, +} diff --git a/layouts/base.lua b/layouts/base.lua new file mode 100644 index 0000000..aae2081 --- /dev/null +++ b/layouts/base.lua @@ -0,0 +1,45 @@ +local navigation_table = { + {'home', '/index.html'}, + {'projects', '/projects/'}, + {'git', '/git'}, + {'about', '/about.html'}, +} + +local navlinks = '' + +for _, link in pairs(navigation_table) do + navlinks = navlinks .. + string.format('%s ', link[2], link[1]) +end +navlinks = string.sub(navlinks, 1, -4) + +local navigation = string.format('', navlinks) + +return function(html, page_tbl) + local html = string.gsub( + html, + '

(.-)

', + '

%1
================================

' + ) + + local fmt = [[ + + + + %s + + + + %s +
+ %s +
+ + +]] +return string.format( + fmt, + string.format('%s | %s', page_tbl.title, argent.config.site_name), + navigation, + html) +end diff --git a/layouts/blog.lua b/layouts/blog.lua new file mode 100644 index 0000000..94dc685 --- /dev/null +++ b/layouts/blog.lua @@ -0,0 +1,8 @@ +local base = require('layouts.base') + +return function(html, page_tbl) + local html = string.format( + '

%s

\n

%s

\n\n%s', + page_tbl.title, page_tbl.date, html) + return base(html, page_tbl) +end diff --git a/plugins/navigation.lua b/plugins/navigation.lua new file mode 100644 index 0000000..e69de29 diff --git a/plugins/toolkit.lua b/plugins/toolkit.lua new file mode 100644 index 0000000..e5f162a --- /dev/null +++ b/plugins/toolkit.lua @@ -0,0 +1,42 @@ +local toolkit = {} + +toolkit.file_iterator = function(directory) + local _, files = argent.scanDirectory(directory) + local i = 0 + local n = table.getn(files) + return function() + i = i+1 + if i<=n then return files[i] end + end +end + + +toolkit.basename = function(filename) + return string.gsub(filename, '%.lua$', '') +end + + +local function extract_page(file) + if not string.match(file, '%.lua$') then return nil end + + local success, result = pcall(loadfile(file), 0, 1) + if not success then return nil end + return result +end + +toolkit.pages = function(directory) + page_array = {} + local path = argent.config.site_directory..directory + for file in toolkit.file_iterator(path) do + local page = extract_page(path..file) + if page then + page.href = '/'..directory..toolkit.basename(file)..'.html' + table.insert(page_array, page) + end + end + + return page_array +end + + +return toolkit diff --git a/public/about.html b/public/about.html new file mode 100644 index 0000000..001244f --- /dev/null +++ b/public/about.html @@ -0,0 +1,19 @@ + + + + about me | sanine.net + + + + +
+

about me
================================

+

hey! i'm kate (aka sanine) and i like to write code, hack circuits, and grow plants. +i mostly use this site for documenting and sharing various projects. +i also (very occasionally) make games!! you can see them over on itch.io.

+

if you need to get in contact with me, you can send me an email at kate AT sanine DOT net. +i hope you're having a good day. <3

+ +
+ + diff --git a/public/blog/announcing_honeysuckle.html b/public/blog/announcing_honeysuckle.html new file mode 100644 index 0000000..9c2ac0c --- /dev/null +++ b/public/blog/announcing_honeysuckle.html @@ -0,0 +1,44 @@ + + + + announcing honeysuckle | sanine.net + + + + +
+

announcing honeysuckle
================================

+

2021-05-23

+ +

As I’ve been working on various projects for the past couple of years +I have continued to find that a combination of C and Lua is my favorite +way to write code. The ongoing development of my game engine honey +uses that pair and I’m planning on using it (whenever I get around to it) for my dream +atlas project. But, and I’ll be the first +to admit this, the C API is a little clunky. +I don’t generally mind that all too much (after all, one of my favorite things about +both C and Lua is that they’re languages you can carry around in your head, and having +a very explicit API means you only need to understand the fundamental concepts to use it) +but it does mean that dev work goes a bit slower.

+

I did a good bit of work streamlining the process of writing Lua bindings in C when +tinkering with honey and ever since then I’ve found myself peeking back at that code +and re-implementing it in other projects. A colleague of mine once said that the time +to write a library is when you’ve done something once, you’re doing it now, and you +re pretty sure you’ll do it again, and I think I’ve quite handily cleared that condition +So! I’m splitting that code out and refactoring it into its own library which, due +to its historical roots, I’ve chosen to call honeysuckle.

+

honeysuckle is still under development – the API is a bit different from the one I +came up with when working on honey and imo is easier to use – but when it’s ready +it will provide a whole host of helpful functions that make integrating Lua scripting +into C applications simple and fast. I am (attempting) to employ readme-driven development +so I’ve written up a readme for honeysuckle. Any feedback on the proposed API and +features would be much appreciated! As of writing, honeysuckle is planned to include +functions for parsing arguments to C functions from Lua, creating and processing tables +throwing and handling Lua errors, using the Lua registry, and creating printf-formatted strings.

+

I’ve already created a repository for honeysuckle. There’s just a README in there +for now, but that will probably have changed even just later today, since I’m planning +on working on it more this afternoon. :p

+ +
+ + diff --git a/public/index.html b/public/index.html new file mode 100644 index 0000000..f31c9b7 --- /dev/null +++ b/public/index.html @@ -0,0 +1,19 @@ + + + + home | sanine.net + + + + +
+

home
================================

+

welcome to sanine.net!

+ +

subscribe via rss

+ +
+ + diff --git a/public/projects/index.html b/public/projects/index.html new file mode 100644 index 0000000..0e8b6c1 --- /dev/null +++ b/public/projects/index.html @@ -0,0 +1,15 @@ + + + + projects | sanine.net + + + + +
+

projects
================================

+

tl;dr projects go here

+ +
+ + diff --git a/public/rss.xml b/public/rss.xml new file mode 100644 index 0000000..2297f97 --- /dev/null +++ b/public/rss.xml @@ -0,0 +1,15 @@ + + + sanine.net + https://sanine.net/ + + argent v0.1.0 + https://www.rssboard.org/rss-specification + + + announcing honeysuckle + https://sanine.net/blog/announcing_honeysuckle.html + 23 May 2021 00:00:00 Z + + + \ No newline at end of file diff --git a/public/style.css b/public/style.css new file mode 100644 index 0000000..f43e73d --- /dev/null +++ b/public/style.css @@ -0,0 +1,44 @@ +body { + color: #eee; + background: #1c1c1c; + font-family: monospace; + font-size: 16px; +} + +#navigation { + text-align: center; +} + +.centered { + text-align: center; +} + +#content { + width: 600px; + max-width: 100%; + margin: auto; +} + +a { + color: #ff3a21; +} + +a:hover { + color: #1c1c1c; + background: #ff3a21; + text-decoration: none; +} + +ul { + list-style: none; +} + +li:before { + content: '* '; +} + +code { + background: black; + padding: 0 6px; + border-radius: 4px; +} diff --git a/serve-http.sh b/serve-http.sh new file mode 100755 index 0000000..874b586 --- /dev/null +++ b/serve-http.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +# this script is for previewing site changes ONLY!! it should not be used to +# actually serve a site. use apache or nginx or something for that. + +# launch webserver +python3 -m http.server --directory public/ & +server_pid="$!" +echo "server launched with PID $server_pid" + +# kill server on exit +trap "kill $server_pid && echo && echo \"bye!\"" EXIT + +# rebuild on file changes (inotifywait is from inotify-tools) +while inotifywait -qr --event modify .; do + echo "rebuilding site..." + argent + echo "done." +done diff --git a/site_root/about.lua b/site_root/about.lua new file mode 100644 index 0000000..ea832e1 --- /dev/null +++ b/site_root/about.lua @@ -0,0 +1,17 @@ +local md = [[ +about me +======== + +hey! i'm kate (aka sanine) and i like to write code, hack circuits, and grow plants. +i mostly use this site for documenting and sharing various projects. +i also (very occasionally) make games!! you can see them [over on itch.io](https://sanine.itch.io/). + +if you need to get in contact with me, you can send me an email at `kate AT sanine DOT net`. +i hope you're having a good day. <3 +]] + +return { + title='about me', + layout='base', + markdown=md, +} diff --git a/site_root/blog/announcing_honeysuckle.lua b/site_root/blog/announcing_honeysuckle.lua new file mode 100644 index 0000000..5fb97fb --- /dev/null +++ b/site_root/blog/announcing_honeysuckle.lua @@ -0,0 +1,37 @@ +return { + title='announcing honeysuckle', + layout='blog', + date='2021-05-23', + markdown=[[ +As I’ve been working on various projects for the past couple of years +I have continued to find that a combination of C and Lua is my favorite +way to write code. The ongoing development of [my game engine honey](https://honey3d.org/) +uses that pair and I’m planning on using it (whenever I get around to it) for my [dream +atlas project](https://sanine.net/projects/dream-atlas). But, and I’ll be the first +to admit this, the C API is a little clunky. +I don’t generally mind that all too much (after all, one of my favorite things about +both C and Lua is that they’re languages you can carry around in your head, and having +a very explicit API means you only need to understand the fundamental concepts to use it) +but it does mean that dev work goes a bit slower. + +I did a good bit of work streamlining the process of writing Lua bindings in C when +tinkering with honey and ever since then I’ve found myself peeking back at that code +and re-implementing it in other projects. A colleague of mine once said that the time +to write a library is when you’ve done something once, you’re doing it now, and you +re pretty sure you’ll do it again, and I think I’ve quite handily cleared that condition +So! I’m splitting that code out and refactoring it into its own library which, due +to its historical roots, I’ve chosen to call honeysuckle. + +honeysuckle is still under development – the API is a bit different from the one I +came up with when working on honey and imo is easier to use – but when it’s ready +it will provide a whole host of helpful functions that make integrating Lua scripting +into C applications simple and fast. I am (attempting) to employ readme-driven development +so I’ve written up a readme for honeysuckle. Any feedback on the proposed API and +features would be much appreciated! As of writing, honeysuckle is planned to include +functions for parsing arguments to C functions from Lua, creating and processing tables +throwing and handling Lua errors, using the Lua registry, and creating printf-formatted strings. + +I’ve already created a repository for honeysuckle. There’s just a README in there +for now, but that will probably have changed even just later today, since I’m planning +on working on it more this afternoon. :p +]]} diff --git a/site_root/index.lua b/site_root/index.lua new file mode 100644 index 0000000..cc5f699 --- /dev/null +++ b/site_root/index.lua @@ -0,0 +1,28 @@ +local tk = require 'toolkit' + +function get_blog_links() + local links = '' +end + + +local md = string.format([[ +home +==== + +welcome to sanine.net! + +%s + +[subscribe via rss](/rss.xml) +]], get_blog_links()) + +return { + title='home', + layout='base', + markdown=md, +} diff --git a/site_root/projects/index.lua b/site_root/projects/index.lua new file mode 100644 index 0000000..96e3abe --- /dev/null +++ b/site_root/projects/index.lua @@ -0,0 +1,12 @@ +local md = [[ +projects +======== + +tl;dr projects go here +]] + +return { + title='projects', + layout='base', + markdown=md, +} diff --git a/site_root/style.css b/site_root/style.css new file mode 100644 index 0000000..f43e73d --- /dev/null +++ b/site_root/style.css @@ -0,0 +1,44 @@ +body { + color: #eee; + background: #1c1c1c; + font-family: monospace; + font-size: 16px; +} + +#navigation { + text-align: center; +} + +.centered { + text-align: center; +} + +#content { + width: 600px; + max-width: 100%; + margin: auto; +} + +a { + color: #ff3a21; +} + +a:hover { + color: #1c1c1c; + background: #ff3a21; + text-decoration: none; +} + +ul { + list-style: none; +} + +li:before { + content: '* '; +} + +code { + background: black; + padding: 0 6px; + border-radius: 4px; +} -- cgit v1.2.1