git.s-ol.nu mmm / 894bde0
little meta-link updates s-ol 3 years ago
6 changed file(s) with 79 addition(s) and 62 deletion(s). Raw diff Collapse all Expand all
2323 $ tup init
2424 $ tup
2525
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:
2731
2832 $ cd root
2933 $ python -m http.server
3640
3741 $ tup monitor -f -a
3842
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
3951 [moonscript]: https://moonscript.org/
4052 [mmm]: https://mmm.s-ol.nu/
4153 [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
-55
build/import_all.moon less more
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
55 i = math.ceil math.random! * num
66 select i, ...
77
8
98 iconlink = (href, src, alt, style) -> a {
109 class: 'iconlink',
10 target: '_blank',
11 rel: 'me',
1112 :href,
12 target: '_blank',
1313 img :src, :alt, :style
1414 }
1515
6868 }
6969 div {
7070 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'
7374 iconlink 'https://webring.xxiivv.com/#random', 'https://webring.xxiivv.com/icon.black.svg', 'webring',
7475 { height: '1.3em', 'margin-left': '.3em', 'margin-top': '-0.12em' }
7576 }
1010 import tohtml from require 'mmm.component'
1111 import Browser from require 'mmm.mmmfs.browser'
1212 import get_meta, header, footer from require 'build.layout'
13
14 -- usage:
15 -- moon render_all.moon [db.sqlite3]
16 { file } = arg
1317
1418 export BROWSER
1519
105109
106110 root
107111
108 tree = load_tree SQLStore!
112 tree = load_tree SQLStore :name
109113
110114 for fileder in coroutine.wrap tree\iterate
111115 print "rendering '#{fileder.path}'..."
1616 '.'
1717 br!
1818 'You can find the source code of everything '
19 a { 'here', href: 'https://github.com/s-ol/mmm' }
19 a { 'here', href: 'https://git.s-ol.nu/mmm' }
2020 '.'
2121 br!
2222 'Most of the inner-workings of this page are documented in '