aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authors-ol <s-ol@users.noreply.github.com>2018-10-26 06:29:45 +0000
committers-ol <s-ol@users.noreply.github.com>2018-10-26 06:36:37 +0000
commit86f59196895bdc401daf63b4b7a6c9f503845729 (patch)
treef6fdec9e6a3f86fca4b5abf071c4da7622cbde77
parentfinish koch (diff)
downloadmmm-86f59196895bdc401daf63b4b7a6c9f503845729.tar.gz
mmm-86f59196895bdc401daf63b4b7a6c9f503845729.zip
add tablefs
-rw-r--r--app/init.moon4
-rw-r--r--app/tablefs/init.moon4
-rw-r--r--app/tablefs/tablefs.moon108
m---------dist0
-rw-r--r--lib/html.client.moon12
-rw-r--r--lib/html.server.moon12
6 files changed, 122 insertions, 18 deletions
diff --git a/app/init.moon b/app/init.moon
index 0cf846a..1aaf969 100644
--- a/app/init.moon
+++ b/app/init.moon
@@ -33,6 +33,10 @@ experiments =
desc: 'Playground for Functional Tags'
render: -> require '.tags'
},
+ tablefs: {
+ desc: 'A system bigger than filesystems'
+ render: -> require '.tablefs'
+ },
koch: {
desc: "lil' fractal thing",
render: -> require '.koch'
diff --git a/app/tablefs/init.moon b/app/tablefs/init.moon
new file mode 100644
index 0000000..5a9a4fd
--- /dev/null
+++ b/app/tablefs/init.moon
@@ -0,0 +1,4 @@
+require = relative ...
+root = require '.tablefs'
+
+append root['moon -> text/html'] root
diff --git a/app/tablefs/tablefs.moon b/app/tablefs/tablefs.moon
new file mode 100644
index 0000000..08e3084
--- /dev/null
+++ b/app/tablefs/tablefs.moon
@@ -0,0 +1,108 @@
+{
+ 'moon -> text/html': () =>
+ import article, h1, h3, p, div, a, sup, ol, li, span, code, br from require 'lib.html'
+
+ content = {}
+ append = (stuff) -> table.insert content, stuff
+
+ footnote, getnotes = do
+ local *
+ notes = {}
+
+ id = (i) -> "footnote-#{i}"
+
+ footnote = (stuff) ->
+ i = #notes + 1
+ notes[i] = stuff
+ sup a "[#{i}]", style: { 'text-decoration': 'none' }, href: '#' .. id i
+
+ footnote, ->
+ args = for i, note in ipairs notes
+ li (span i, id: id i), ': ', note
+ notes = {}
+ table.insert args, style: { 'list-style': 'none', 'font-size': '0.8em' }
+ ol unpack args
+
+ append h1 'Tablefs', style: { 'margin-bottom': 0 }
+ append p "(it's a terrible name, isn't it)", style: { 'margin-top': 0, 'margin-bottom': '1em' }
+
+ append p do
+ fileder = footnote "fileder: file + folder. 'node', 'table' etc. are too general to be used all over."
+ child = footnote "fileders can have multiple values, like the mentioned script, but these are not considered
+ children of the fileder, as they are not fileders themselves. One fileder can have many values of different
+ types/keys associated, but these have unspecified schemas and don't nest. In addition it can have many
+ children, which are fileders themselves and can nest, but they are not labelled."
+
+ "in Tablefs, directories are files and files are directories, or something like that.
+ Listen, I don't really know yet either. The idea is that every node knows how to render it's contents;
+ so for example your 'Pictures' fileder", fileder, " contains a script within itself that renders
+ all the picture files you put into it at the children level", child, "."
+
+ append p "What you are viewing right now is a fileder that has a value set at the ", (code 'moon -> text/html'), " key;
+ That value is the Lua/Moonscript function that is generating this text.", br!,
+ "The function is passed the fileder itself (as a Lua table) and potentially also receives some other
+ helpers for accessing it's environment (parent fileders, functions for querying the tree etc) or info
+ specific to the function key/type, but I haven't built or thought about any of that yet. Sorry."
+
+ append do
+ github = footnote a 's-ol/mmm', href: 'https://github.com/s-ol/mmm'
+ p "Anyway, this node is set up as some sort of wiki/index thing and just lists its children-fileders' ", (code 'title: text/plain'),
+ " values and ", (code 'preview: moon -> text/html'), " previews (if set). Oh and also everything is on github and stuff", github,
+ " if you care about that."
+
+
+ append p "Here's the Children:"
+
+ mb_render = (child, key) ->
+ if child[key]
+ child[key] child
+
+
+ title = (text) -> h3 text, style: { margin: 0 }
+
+ append div for child in *@
+ div {
+ title child['title: text/plain'],
+ mb_render child, 'preview: moon -> text/html',
+ style: {
+ display: 'inline-block',
+ width: '300px',
+ height: '200px',
+ padding: '4px',
+ margin: '8px',
+ border: '4px solid #eeeeee',
+ overflow: 'hidden',
+ },
+ }
+
+ append getnotes!
+
+ article content
+
+ 'text/markdown': "this is a markdown version or something. I don't really know how this would work, how do you share stuff and shit?"
+
+ {
+ 'title: text/plain': "Hey I'm an ad-hoc child with no content for shit",
+ }
+
+ {
+ 'title: text/plain': "Hey I'm like a link to picture or smth",
+ 'http -> png': 'https://picsum.photos/200?random',
+ 'preview: moon -> text/html': =>
+ import img from require 'lib.html'
+ img src: @['http -> png']
+ }
+
+ {
+ 'title: text/plain': "I'm not even five lines of markdown but i render myself!",
+ 'text/markdown': "See I have like
+
+- a list of things
+- (two things)
+
+and some bold **text** and `code tags` with me.",
+ 'preview: moon -> text/html': =>
+ compile = require 'discount'
+ compile @['text/markdown']
+ }
+}
diff --git a/dist b/dist
-Subproject 3316238d9f30a897545e26458ef9f5bd324747c
+Subproject 27151d24984d95e190468c20d666ab569a9e02e
diff --git a/lib/html.client.moon b/lib/html.client.moon
index 098b974..eb4d7fe 100644
--- a/lib/html.client.moon
+++ b/lib/html.client.moon
@@ -24,12 +24,6 @@ element = (element) -> (...) ->
else
e\appendChild child
-elements = {}
-add = (e) -> elements[e] = element e
-
-for e in *{'div', 'form', 'span', 'a', 'p', 'button', 'ul', 'ol', 'li', 'i', 'b', 'u', 'tt'} do add e
-for e in *{'article', 'section', 'header', 'footer', 'content', 'pre'} do add e
-for e in *{'br', 'hr', 'img', 'input', 'p', 'canvas', 'textarea', 'script'} do add e
-for i=1,8 do add "h" .. i
-
-elements
+setmetatable {}, __index: (name) =>
+ with val = element name
+ @[name] = val
diff --git a/lib/html.server.moon b/lib/html.server.moon
index 335e193..e1d1f59 100644
--- a/lib/html.server.moon
+++ b/lib/html.server.moon
@@ -28,12 +28,6 @@ element = (element) -> (...) ->
b ..= "</#{element}>"
b
-elements = {}
-add = (e) -> elements[e] = element e
-
-for e in *{'div', 'form', 'span', 'a', 'p', 'button', 'ul', 'ol', 'li', 'i', 'b', 'u', 'tt'} do add e
-for e in *{'article', 'section', 'header', 'footer', 'content', 'pre'} do add e
-for e in *{'br', 'hr', 'img', 'input', 'p', 'canvas', 'textarea', 'script'} do add e
-for i=1,8 do add "h" .. i
-
-elements
+setmetatable {}, __index: (name) =>
+ with val = element name
+ @[name] = val