From 894bde0db758f2db03fd43d9fa2cd13a33d20643 Mon Sep 17 00:00:00 2001 From: s-ol Date: Mon, 7 Oct 2019 15:05:00 +0000 Subject: little meta-link updates --- README.md | 14 +++++++- build/import.moon | 55 ++++++++++++++++++++++++++++++ build/import_all.moon | 55 ------------------------------ build/layout.moon | 9 ++--- build/render_all.moon | 6 +++- root/text$moonscript -> fn -> mmm$dom.moon | 2 +- 6 files changed, 79 insertions(+), 62 deletions(-) create mode 100644 build/import.moon delete mode 100644 build/import_all.moon diff --git a/README.md b/README.md index 35cccd4..f687309 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,11 @@ You can build the static content with: $ tup init $ tup -Then, run some kind of HTTP server from within `root`, e.g. with python 3 installed: +Next you can render a sqlite3 mmmfs database using + + $ moon build/render_all.moon db.sqlite3 + +Then, run some kind of HTTP server from within `out`, e.g. with python 3 installed: $ cd root $ python -m http.server @@ -37,6 +41,14 @@ You can do this with the following command: $ tup monitor -f -a +### Dependencies +You will need: + +- [MoonScript][moonscript]: `luarocks install moonscript` +- [lua-sqlite3](https://luarocks.org/modules/moteus/sqlite3): `luarocks install sqlite3` +- [discount](https://luarocks.org/modules/craigb/discount): `luarocks install discount` (requires libmarkdown2) +- [busted](https://olivinelabs.com/busted/): `luarocks install busted` (for testing only) + [moonscript]: https://moonscript.org/ [mmm]: https://mmm.s-ol.nu/ [tup]: https://gittup.org/tup diff --git a/build/import.moon b/build/import.moon new file mode 100644 index 0000000..624b54a --- /dev/null +++ b/build/import.moon @@ -0,0 +1,55 @@ +add = (tmpl) -> + package.path ..= ";#{tmpl}.lua" + package.moonpath ..= ";#{tmpl}.moon" + +add '?' +add '?.server' +add '?/init' +add '?/init.server' + +require 'mmm' +require 'lfs' +import Fileder, Key from require 'mmm.mmmfs.fileder' +import SQLStore from require 'mmm.mmmfs.drivers.sql' + +-- usage: +-- moon import.moon [output.sqlite3] +{ root, output } = arg + +assert root, "please specify the root directory" + +-- load a fs file as a fileder facet +load_facet = (filename, filepath) -> + key = (filename\match '(.*)%.%w+') or filename + key = Key key\gsub '%$', '/' + key.filename = filename + + file = assert (io.open filepath, 'r'), "couldn't open facet file '#{filename}'" + value = file\read '*all' + file\close! + + key, value + + +with SQLStore name: output, verbose: true + import_fileder = (fileder, dirpath) -> + for file in lfs.dir dirpath + continue if '.' == file\sub 1, 1 + continue if file == 'Tupdefault.lua' + continue if file == 'index.html' + continue if file == '$order' + + filepath = "#{dirpath}/#{file}" + attr = lfs.attributes filepath + switch attr.mode + when 'file' + key, value = load_facet file, filepath + \create_facet fileder, key.name, key.type, value + when 'directory' + next_fileder = \create_fileder fileder, file + -- \create_facet next_fileder, 'name', 'alpha', file + import_fileder next_fileder, filepath + else + warn "unknown entry type '#{attr.mode}'" + + import_fileder '', root diff --git a/build/import_all.moon b/build/import_all.moon deleted file mode 100644 index 3a2ac61..0000000 --- a/build/import_all.moon +++ /dev/null @@ -1,55 +0,0 @@ -add = (tmpl) -> - package.path ..= ";#{tmpl}.lua" - package.moonpath ..= ";#{tmpl}.moon" - -add '?' -add '?.server' -add '?/init' -add '?/init.server' - -require 'mmm' -require 'lfs' -import Fileder, Key from require 'mmm.mmmfs.fileder' -import SQLStore from require 'mmm.mmmfs.drivers.sql' - --- usage: --- moon import_all.moon -{ root } = arg - -assert root, "please specify the root directory" - --- load a fs file as a fileder facet -load_facet = (filename, filepath) -> - key = (filename\match '(.*)%.%w+') or filename - key = Key key\gsub '%$', '/' - key.filename = filename - - file = assert (io.open filepath, 'r'), "couldn't open facet file '#{filename}'" - value = file\read '*all' - file\close! - - key, value - - -with SQLStore verbose: true - import_fileder = (fileder, dirpath) -> - for file in lfs.dir dirpath - continue if '.' == file\sub 1, 1 - continue if file == 'Tupdefault.lua' - continue if file == 'index.html' - continue if file == '$order' - - filepath = "#{dirpath}/#{file}" - attr = lfs.attributes filepath - switch attr.mode - when 'file' - key, value = load_facet file, filepath - \create_facet fileder, key.name, key.type, value - when 'directory' - next_fileder = \create_fileder fileder, file - -- \create_facet next_fileder, 'name', 'alpha', file - import_fileder next_fileder, filepath - else - warn "unknown entry type '#{attr.mode}'" - - import_fileder '', root diff --git a/build/layout.moon b/build/layout.moon index 6d6e072..61f93cb 100644 --- a/build/layout.moon +++ b/build/layout.moon @@ -6,11 +6,11 @@ pick = (...) -> i = math.ceil math.random! * num select i, ... - iconlink = (href, src, alt, style) -> a { class: 'iconlink', - :href, target: '_blank', + rel: 'me', + :href, img :src, :alt, :style } @@ -69,8 +69,9 @@ logo = svg { } div { class: 'icons', - iconlink 'https://github.com/s-ol/mmm', 'https://cdn.jsdelivr.net/npm/simple-icons@latest/icons/github.svg', - iconlink 'https://twitter.com/S0lll0s', 'https://cdn.jsdelivr.net/npm/simple-icons@latest/icons/twitter.svg', + iconlink 'https://github.com/s-ol', 'https://cdn.jsdelivr.net/npm/simple-icons@latest/icons/github.svg', 'github' + iconlink 'https://merveilles.town/@s_ol', 'https://cdn.jsdelivr.net/npm/simple-icons@latest/icons/mastodon.svg', 'mastodon' + iconlink 'https://twitter.com/S0lll0s', 'https://cdn.jsdelivr.net/npm/simple-icons@latest/icons/twitter.svg', 'twitter' iconlink 'https://webring.xxiivv.com/#random', 'https://webring.xxiivv.com/icon.black.svg', 'webring', { height: '1.3em', 'margin-left': '.3em', 'margin-top': '-0.12em' } } diff --git a/build/render_all.moon b/build/render_all.moon index e2f171e..dfbed27 100644 --- a/build/render_all.moon +++ b/build/render_all.moon @@ -12,6 +12,10 @@ import tohtml from require 'mmm.component' import Browser from require 'mmm.mmmfs.browser' import get_meta, header, footer from require 'build.layout' +-- usage: +-- moon render_all.moon [db.sqlite3] +{ file } = arg + export BROWSER render = (fileder, output) -> @@ -106,7 +110,7 @@ load_tree = (store, root='') -> root -tree = load_tree SQLStore! +tree = load_tree SQLStore :name for fileder in coroutine.wrap tree\iterate print "rendering '#{fileder.path}'..." diff --git a/root/text$moonscript -> fn -> mmm$dom.moon b/root/text$moonscript -> fn -> mmm$dom.moon index 84aed7f..8c06030 100644 --- a/root/text$moonscript -> fn -> mmm$dom.moon +++ b/root/text$moonscript -> fn -> mmm$dom.moon @@ -17,7 +17,7 @@ import link_to from (require 'mmm.mmmfs.util') require 'mmm.dom' '.' br! 'You can find the source code of everything ' - a { 'here', href: 'https://github.com/s-ol/mmm' } + a { 'here', href: 'https://git.s-ol.nu/mmm' } '.' br! 'Most of the inner-workings of this page are documented in ' -- cgit v1.2.3