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 --- build/import.moon | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++ build/import_all.moon | 55 --------------------------------------------------- build/layout.moon | 9 +++++---- build/render_all.moon | 6 +++++- 4 files changed, 65 insertions(+), 60 deletions(-) create mode 100644 build/import.moon delete mode 100644 build/import_all.moon (limited to 'build') 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}'..." -- cgit v1.2.3