diff options
| author | s-ol <s-ol@users.noreply.github.com> | 2019-10-29 13:18:16 +0000 |
|---|---|---|
| committer | s-ol <s-ol@users.noreply.github.com> | 2019-10-29 13:18:16 +0000 |
| commit | d9eafa21ad1d6ad340b5744d69e9fc68ce2083cb (patch) | |
| tree | c5e4c1ce74094b5feebbca944e316fb2833fe027 /root | |
| parent | small styling fixes (diff) | |
| download | mmm-d9eafa21ad1d6ad340b5744d69e9fc68ce2083cb.tar.gz mmm-d9eafa21ad1d6ad340b5744d69e9fc68ce2083cb.zip | |
add sandbox
Diffstat (limited to 'root')
11 files changed, 79 insertions, 0 deletions
diff --git a/root/sandbox/description: text$markdown.md b/root/sandbox/description: text$markdown.md new file mode 100644 index 0000000..250bb4e --- /dev/null +++ b/root/sandbox/description: text$markdown.md @@ -0,0 +1,5 @@ +Everything in this Fileder is world-editable on the internet. +It will be reset to its' default state whenever I push my repository. +Please behave. + +Here is a list of this fileders content: diff --git a/root/sandbox/dynamic-children/a/text$lua -> table b/root/sandbox/dynamic-children/a/text$lua -> table new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/root/sandbox/dynamic-children/a/text$lua -> table diff --git a/root/sandbox/dynamic-children/b/text$markdown.md b/root/sandbox/dynamic-children/b/text$markdown.md new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/root/sandbox/dynamic-children/b/text$markdown.md diff --git a/root/sandbox/dynamic-children/c/text$javascript -> text$markdown.js b/root/sandbox/dynamic-children/c/text$javascript -> text$markdown.js new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/root/sandbox/dynamic-children/c/text$javascript -> text$markdown.js diff --git a/root/sandbox/dynamic-children/description: text$markdown.md b/root/sandbox/dynamic-children/description: text$markdown.md new file mode 100644 index 0000000..32216ce --- /dev/null +++ b/root/sandbox/dynamic-children/description: text$markdown.md @@ -0,0 +1 @@ +dynamically embedding children fileders with Lua diff --git a/root/sandbox/dynamic-children/text$lua -> fn -> mmm$dom.lua b/root/sandbox/dynamic-children/text$lua -> fn -> mmm$dom.lua new file mode 100644 index 0000000..a3a019b --- /dev/null +++ b/root/sandbox/dynamic-children/text$lua -> fn -> mmm$dom.lua @@ -0,0 +1,19 @@ +local d = require 'mmm.dom' +local u = require('mmm.mmmfs.util')(d) + +-- we need to return a function to get access to the current fileder +-- (thats why there is the '-> fn ->' in the type) +return function(self) + local children = {} + for i, child in ipairs(self.children) do + table.insert(children, d.li { + 'child ' .. i .. ': ', + u.link_to(child), + }) + end + + return d.article { + d.h1 'The Children are:', + d.ul(children), + } +end diff --git a/root/sandbox/javascript/description: text$markdown.md b/root/sandbox/javascript/description: text$markdown.md new file mode 100644 index 0000000..eb0ca7c --- /dev/null +++ b/root/sandbox/javascript/description: text$markdown.md @@ -0,0 +1 @@ +an example of how to use JS to create (dynamic) DOM / mmmfs content diff --git a/root/sandbox/javascript/text$javascript -> mmm$dom.js b/root/sandbox/javascript/text$javascript -> mmm$dom.js new file mode 100644 index 0000000..58deb23 --- /dev/null +++ b/root/sandbox/javascript/text$javascript -> mmm$dom.js @@ -0,0 +1,24 @@ +// a little helper function for creating DOM elements +const e = (elem, children) => { + const node = document.createElement(elem); + + if (typeof children === 'string') + node.innerText = children; + else + children.forEach(child => node.appendChild(child)); + + return node; +}; + +/* creating the equivalent of the following HTML directly as DOM content: + * + * <article> + * <h1>JavaScript</h1> + * <p>...</p> + * </article> + */ + +return e('article', [ + e('h1', 'JavaScript'), + e('p', 'JavaScript is supported natively in the browser but is not currently pre-rendered on the server.'), +]); diff --git a/root/sandbox/lua/description: text$markdown.md b/root/sandbox/lua/description: text$markdown.md new file mode 100644 index 0000000..3071697 --- /dev/null +++ b/root/sandbox/lua/description: text$markdown.md @@ -0,0 +1 @@ +an example of how to use Lua to create (dynamic) DOM / mmmfs content diff --git a/root/sandbox/lua/text$lua -> mmm$dom.lua b/root/sandbox/lua/text$lua -> mmm$dom.lua new file mode 100644 index 0000000..db420ce --- /dev/null +++ b/root/sandbox/lua/text$lua -> mmm$dom.lua @@ -0,0 +1,10 @@ +-- see /meta/mmm.dom for documentation +local d = require 'mmm.dom' + +local lua = d.a { 'Lua', href = 'https://www.lua.org/' } +local fengari = d.a { 'fengari.io', href = 'https://fengari.io/' } + +return d.article { + d.h1 'Lua', + d.p { lua, ' is fully supported using ', fengari, ' on the Client.' } +} diff --git a/root/sandbox/text$lua -> fn -> mmm$dom.lua b/root/sandbox/text$lua -> fn -> mmm$dom.lua new file mode 100644 index 0000000..18206bb --- /dev/null +++ b/root/sandbox/text$lua -> fn -> mmm$dom.lua @@ -0,0 +1,18 @@ +local d = require 'mmm.dom' +local u = require('mmm.mmmfs.util')(d) + +return function(self) + local children = {} + for i, child in ipairs(self.children) do + table.insert( + children, + d.li(u.link_to(child), ': ', (child:get('description: mmm/dom'))) + ) + end + + return d.div({ + d.h3(u.link_to(self)), + self:gett('description: mmm/dom'), + d.ul(children), + }) +end |
