little meta-link updates
s-ol
3 years ago
23 | 23 | $ tup init |
24 | 24 | $ tup |
25 | 25 | |
26 | Then, run some kind of HTTP server from within `root`, e.g. with python 3 installed: | |
26 | Next you can render a sqlite3 mmmfs database using | |
27 | ||
28 | $ moon build/render_all.moon db.sqlite3 | |
29 | ||
30 | Then, run some kind of HTTP server from within `out`, e.g. with python 3 installed: | |
27 | 31 | |
28 | 32 | $ cd root |
29 | 33 | $ python -m http.server |
36 | 40 | |
37 | 41 | $ tup monitor -f -a |
38 | 42 | |
43 | ### Dependencies | |
44 | You will need: | |
45 | ||
46 | - [MoonScript][moonscript]: `luarocks install moonscript` | |
47 | - [lua-sqlite3](https://luarocks.org/modules/moteus/sqlite3): `luarocks install sqlite3` | |
48 | - [discount](https://luarocks.org/modules/craigb/discount): `luarocks install discount` (requires libmarkdown2) | |
49 | - [busted](https://olivinelabs.com/busted/): `luarocks install busted` (for testing only) | |
50 | ||
39 | 51 | [moonscript]: https://moonscript.org/ |
40 | 52 | [mmm]: https://mmm.s-ol.nu/ |
41 | 53 | [tup]: https://gittup.org/tup |
0 | add = (tmpl) -> | |
1 | package.path ..= ";#{tmpl}.lua" | |
2 | package.moonpath ..= ";#{tmpl}.moon" | |
3 | ||
4 | add '?' | |
5 | add '?.server' | |
6 | add '?/init' | |
7 | add '?/init.server' | |
8 | ||
9 | require 'mmm' | |
10 | require 'lfs' | |
11 | import Fileder, Key from require 'mmm.mmmfs.fileder' | |
12 | import SQLStore from require 'mmm.mmmfs.drivers.sql' | |
13 | ||
14 | -- usage: | |
15 | -- moon import.moon <root> [output.sqlite3] | |
16 | { root, output } = arg | |
17 | ||
18 | assert root, "please specify the root directory" | |
19 | ||
20 | -- load a fs file as a fileder facet | |
21 | load_facet = (filename, filepath) -> | |
22 | key = (filename\match '(.*)%.%w+') or filename | |
23 | key = Key key\gsub '%$', '/' | |
24 | key.filename = filename | |
25 | ||
26 | file = assert (io.open filepath, 'r'), "couldn't open facet file '#{filename}'" | |
27 | value = file\read '*all' | |
28 | file\close! | |
29 | ||
30 | key, value | |
31 | ||
32 | ||
33 | with SQLStore name: output, verbose: true | |
34 | import_fileder = (fileder, dirpath) -> | |
35 | for file in lfs.dir dirpath | |
36 | continue if '.' == file\sub 1, 1 | |
37 | continue if file == 'Tupdefault.lua' | |
38 | continue if file == 'index.html' | |
39 | continue if file == '$order' | |
40 | ||
41 | filepath = "#{dirpath}/#{file}" | |
42 | attr = lfs.attributes filepath | |
43 | switch attr.mode | |
44 | when 'file' | |
45 | key, value = load_facet file, filepath | |
46 | \create_facet fileder, key.name, key.type, value | |
47 | when 'directory' | |
48 | next_fileder = \create_fileder fileder, file | |
49 | -- \create_facet next_fileder, 'name', 'alpha', file | |
50 | import_fileder next_fileder, filepath | |
51 | else | |
52 | warn "unknown entry type '#{attr.mode}'" | |
53 | ||
54 | import_fileder '', root |
0 | add = (tmpl) -> | |
1 | package.path ..= ";#{tmpl}.lua" | |
2 | package.moonpath ..= ";#{tmpl}.moon" | |
3 | ||
4 | add '?' | |
5 | add '?.server' | |
6 | add '?/init' | |
7 | add '?/init.server' | |
8 | ||
9 | require 'mmm' | |
10 | require 'lfs' | |
11 | import Fileder, Key from require 'mmm.mmmfs.fileder' | |
12 | import SQLStore from require 'mmm.mmmfs.drivers.sql' | |
13 | ||
14 | -- usage: | |
15 | -- moon import_all.moon <root> | |
16 | { root } = arg | |
17 | ||
18 | assert root, "please specify the root directory" | |
19 | ||
20 | -- load a fs file as a fileder facet | |
21 | load_facet = (filename, filepath) -> | |
22 | key = (filename\match '(.*)%.%w+') or filename | |
23 | key = Key key\gsub '%$', '/' | |
24 | key.filename = filename | |
25 | ||
26 | file = assert (io.open filepath, 'r'), "couldn't open facet file '#{filename}'" | |
27 | value = file\read '*all' | |
28 | file\close! | |
29 | ||
30 | key, value | |
31 | ||
32 | ||
33 | with SQLStore verbose: true | |
34 | import_fileder = (fileder, dirpath) -> | |
35 | for file in lfs.dir dirpath | |
36 | continue if '.' == file\sub 1, 1 | |
37 | continue if file == 'Tupdefault.lua' | |
38 | continue if file == 'index.html' | |
39 | continue if file == '$order' | |
40 | ||
41 | filepath = "#{dirpath}/#{file}" | |
42 | attr = lfs.attributes filepath | |
43 | switch attr.mode | |
44 | when 'file' | |
45 | key, value = load_facet file, filepath | |
46 | \create_facet fileder, key.name, key.type, value | |
47 | when 'directory' | |
48 | next_fileder = \create_fileder fileder, file | |
49 | -- \create_facet next_fileder, 'name', 'alpha', file | |
50 | import_fileder next_fileder, filepath | |
51 | else | |
52 | warn "unknown entry type '#{attr.mode}'" | |
53 | ||
54 | import_fileder '', root |
5 | 5 | i = math.ceil math.random! * num |
6 | 6 | select i, ... |
7 | 7 | |
8 | ||
9 | 8 | iconlink = (href, src, alt, style) -> a { |
10 | 9 | class: 'iconlink', |
10 | target: '_blank', | |
11 | rel: 'me', | |
11 | 12 | :href, |
12 | target: '_blank', | |
13 | 13 | img :src, :alt, :style |
14 | 14 | } |
15 | 15 | |
68 | 68 | } |
69 | 69 | div { |
70 | 70 | class: 'icons', |
71 | iconlink 'https://github.com/s-ol/mmm', 'https://cdn.jsdelivr.net/npm/simple-icons@latest/icons/github.svg', | |
72 | iconlink 'https://twitter.com/S0lll0s', 'https://cdn.jsdelivr.net/npm/simple-icons@latest/icons/twitter.svg', | |
71 | iconlink 'https://github.com/s-ol', 'https://cdn.jsdelivr.net/npm/simple-icons@latest/icons/github.svg', 'github' | |
72 | iconlink 'https://merveilles.town/@s_ol', 'https://cdn.jsdelivr.net/npm/simple-icons@latest/icons/mastodon.svg', 'mastodon' | |
73 | iconlink 'https://twitter.com/S0lll0s', 'https://cdn.jsdelivr.net/npm/simple-icons@latest/icons/twitter.svg', 'twitter' | |
73 | 74 | iconlink 'https://webring.xxiivv.com/#random', 'https://webring.xxiivv.com/icon.black.svg', 'webring', |
74 | 75 | { height: '1.3em', 'margin-left': '.3em', 'margin-top': '-0.12em' } |
75 | 76 | } |
10 | 10 | import tohtml from require 'mmm.component' |
11 | 11 | import Browser from require 'mmm.mmmfs.browser' |
12 | 12 | import get_meta, header, footer from require 'build.layout' |
13 | ||
14 | -- usage: | |
15 | -- moon render_all.moon [db.sqlite3] | |
16 | { file } = arg | |
13 | 17 | |
14 | 18 | export BROWSER |
15 | 19 | |
105 | 109 | |
106 | 110 | root |
107 | 111 | |
108 | tree = load_tree SQLStore! | |
112 | tree = load_tree SQLStore :name | |
109 | 113 | |
110 | 114 | for fileder in coroutine.wrap tree\iterate |
111 | 115 | print "rendering '#{fileder.path}'..." |