aboutsummaryrefslogtreecommitdiffstats
path: root/root/articles/mmmfs/examples
diff options
context:
space:
mode:
authors-ol <s-ol@users.noreply.github.com>2019-10-26 11:30:58 +0000
committers-ol <s-ol@users.noreply.github.com>2019-10-26 11:30:58 +0000
commit6a30fbd239b31e293c0833c2bbcbb8def44707f1 (patch)
tree1c6501c3d36f4b09ac5648e44026fd224ccf19c6 /root/articles/mmmfs/examples
parentfix bug in deep_tostring (diff)
downloadmmm-6a30fbd239b31e293c0833c2bbcbb8def44707f1.tar.gz
mmm-6a30fbd239b31e293c0833c2bbcbb8def44707f1.zip
mmmfs cleanup
Diffstat (limited to 'root/articles/mmmfs/examples')
-rw-r--r--root/articles/mmmfs/examples/empty/title: text$plain1
-rw-r--r--root/articles/mmmfs/examples/gallery/actual_image/image$png.pngbin0 -> 678429 bytes
-rw-r--r--root/articles/mmmfs/examples/gallery/actual_image/preview: image$png.pngbin0 -> 31880 bytes
-rw-r--r--root/articles/mmmfs/examples/gallery/link_to_image/URL -> image$png1
-rw-r--r--root/articles/mmmfs/examples/gallery/link_to_image/preview: URL -> image$png1
-rw-r--r--root/articles/mmmfs/examples/gallery/preview: text$moonscript -> fn -> mmm$dom.moon7
-rw-r--r--root/articles/mmmfs/examples/gallery/slideshow: text$moonscript -> fn -> mmm$component.moon19
-rw-r--r--root/articles/mmmfs/examples/gallery/text$moonscript -> fn -> mmm$dom.moon12
-rw-r--r--root/articles/mmmfs/examples/gallery/title: text$plain1
-rw-r--r--root/articles/mmmfs/examples/image/URL -> image$png1
-rw-r--r--root/articles/mmmfs/examples/image/preview: text$moonscript -> fn -> mmm$dom.moon5
-rw-r--r--root/articles/mmmfs/examples/image/title: text$plain1
-rw-r--r--root/articles/mmmfs/examples/language_support/javascript/text$javascript -> mmm$dom.js15
-rw-r--r--root/articles/mmmfs/examples/language_support/javascript/title: text$plain1
-rw-r--r--root/articles/mmmfs/examples/language_support/lua/text$lua -> mmm$dom.lua9
-rw-r--r--root/articles/mmmfs/examples/language_support/lua/title: text$plain1
-rw-r--r--root/articles/mmmfs/examples/language_support/moonscript/text$moonscript -> mmm$dom.moon10
-rw-r--r--root/articles/mmmfs/examples/language_support/moonscript/title: text$plain1
-rw-r--r--root/articles/mmmfs/examples/language_support/preview: text$markdown6
-rw-r--r--root/articles/mmmfs/examples/language_support/text$moonscript -> fn -> mmm$dom.moon16
-rw-r--r--root/articles/mmmfs/examples/language_support/title: text$plain1
-rw-r--r--root/articles/mmmfs/examples/markdown/preview: text$markdown.md6
-rw-r--r--root/articles/mmmfs/examples/markdown/title: text$plain1
-rw-r--r--root/articles/mmmfs/examples/text$moonscript -> fn -> mmm$dom.moon32
24 files changed, 148 insertions, 0 deletions
diff --git a/root/articles/mmmfs/examples/empty/title: text$plain b/root/articles/mmmfs/examples/empty/title: text$plain
new file mode 100644
index 0000000..911f98b
--- /dev/null
+++ b/root/articles/mmmfs/examples/empty/title: text$plain
@@ -0,0 +1 @@
+Hey I'm an almost empty Fileder.
diff --git a/root/articles/mmmfs/examples/gallery/actual_image/image$png.png b/root/articles/mmmfs/examples/gallery/actual_image/image$png.png
new file mode 100644
index 0000000..b499413
--- /dev/null
+++ b/root/articles/mmmfs/examples/gallery/actual_image/image$png.png
Binary files differ
diff --git a/root/articles/mmmfs/examples/gallery/actual_image/preview: image$png.png b/root/articles/mmmfs/examples/gallery/actual_image/preview: image$png.png
new file mode 100644
index 0000000..f9dbfad
--- /dev/null
+++ b/root/articles/mmmfs/examples/gallery/actual_image/preview: image$png.png
Binary files differ
diff --git a/root/articles/mmmfs/examples/gallery/link_to_image/URL -> image$png b/root/articles/mmmfs/examples/gallery/link_to_image/URL -> image$png
new file mode 100644
index 0000000..7cf76ff
--- /dev/null
+++ b/root/articles/mmmfs/examples/gallery/link_to_image/URL -> image$png
@@ -0,0 +1 @@
+https://picsum.photos/600/600/?image=101
diff --git a/root/articles/mmmfs/examples/gallery/link_to_image/preview: URL -> image$png b/root/articles/mmmfs/examples/gallery/link_to_image/preview: URL -> image$png
new file mode 100644
index 0000000..2b2233b
--- /dev/null
+++ b/root/articles/mmmfs/examples/gallery/link_to_image/preview: URL -> image$png
@@ -0,0 +1 @@
+https://picsum.photos/200/200/?image=101
diff --git a/root/articles/mmmfs/examples/gallery/preview: text$moonscript -> fn -> mmm$dom.moon b/root/articles/mmmfs/examples/gallery/preview: text$moonscript -> fn -> mmm$dom.moon
new file mode 100644
index 0000000..5285629
--- /dev/null
+++ b/root/articles/mmmfs/examples/gallery/preview: text$moonscript -> fn -> mmm$dom.moon
@@ -0,0 +1,7 @@
+import div, img, br from require 'mmm.dom'
+
+=> div {
+ 'the first pic as a little taste:',
+ br!,
+ img src: @children[1]\get 'preview', 'URL -> image/png'
+}
diff --git a/root/articles/mmmfs/examples/gallery/slideshow: text$moonscript -> fn -> mmm$component.moon b/root/articles/mmmfs/examples/gallery/slideshow: text$moonscript -> fn -> mmm$component.moon
new file mode 100644
index 0000000..0178ac2
--- /dev/null
+++ b/root/articles/mmmfs/examples/gallery/slideshow: text$moonscript -> fn -> mmm$component.moon
@@ -0,0 +1,19 @@
+import ReactiveVar, text, elements from require 'mmm.component'
+import div, a, img from elements
+
+=>
+ index = ReactiveVar 1
+
+ prev = (i) -> math.max 1, i - 1
+ next = (i) -> math.min #@children, i + 1
+
+ div {
+ div {
+ a 'prev', href: '#', onclick: -> index\transform prev
+ index\map (i) -> text " image ##{i} "
+ a 'next', href: '#', onclick: -> index\transform next
+ },
+ index\map (i) ->
+ child = assert @children[i], "image not found!"
+ img src: @children[i]\gett 'URL -> image/png'
+ }
diff --git a/root/articles/mmmfs/examples/gallery/text$moonscript -> fn -> mmm$dom.moon b/root/articles/mmmfs/examples/gallery/text$moonscript -> fn -> mmm$dom.moon
new file mode 100644
index 0000000..9bdac54
--- /dev/null
+++ b/root/articles/mmmfs/examples/gallery/text$moonscript -> fn -> mmm$dom.moon
@@ -0,0 +1,12 @@
+import div, h1, a, img, br from require 'mmm.dom'
+
+=>
+ link = (child) -> a {
+ href: '#',
+ onclick: -> BROWSER\navigate child.path
+ img src: child\gett 'preview', 'URL -> image/png'
+ }
+
+ content = [link child for child in *@children]
+ table.insert content, 1, h1 'gallery index'
+ div content
diff --git a/root/articles/mmmfs/examples/gallery/title: text$plain b/root/articles/mmmfs/examples/gallery/title: text$plain
new file mode 100644
index 0000000..ad74eec
--- /dev/null
+++ b/root/articles/mmmfs/examples/gallery/title: text$plain
@@ -0,0 +1 @@
+A Gallery of 25 random pictures, come on in!
diff --git a/root/articles/mmmfs/examples/image/URL -> image$png b/root/articles/mmmfs/examples/image/URL -> image$png
new file mode 100644
index 0000000..c586722
--- /dev/null
+++ b/root/articles/mmmfs/examples/image/URL -> image$png
@@ -0,0 +1 @@
+https://picsum.photos/200?random
diff --git a/root/articles/mmmfs/examples/image/preview: text$moonscript -> fn -> mmm$dom.moon b/root/articles/mmmfs/examples/image/preview: text$moonscript -> fn -> mmm$dom.moon
new file mode 100644
index 0000000..6c431d0
--- /dev/null
+++ b/root/articles/mmmfs/examples/image/preview: text$moonscript -> fn -> mmm$dom.moon
@@ -0,0 +1,5 @@
+import img from require 'mmm.dom'
+
+-- look for main content with 'URL to png' type
+-- and wrap in an mmm/dom image tag
+=> img src: @gett 'URL -> image/png'
diff --git a/root/articles/mmmfs/examples/image/title: text$plain b/root/articles/mmmfs/examples/image/title: text$plain
new file mode 100644
index 0000000..60a556f
--- /dev/null
+++ b/root/articles/mmmfs/examples/image/title: text$plain
@@ -0,0 +1 @@
+Hey I'm like a link to a picture or smth
diff --git a/root/articles/mmmfs/examples/language_support/javascript/text$javascript -> mmm$dom.js b/root/articles/mmmfs/examples/language_support/javascript/text$javascript -> mmm$dom.js
new file mode 100644
index 0000000..de56531
--- /dev/null
+++ b/root/articles/mmmfs/examples/language_support/javascript/text$javascript -> mmm$dom.js
@@ -0,0 +1,15 @@
+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;
+};
+
+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/articles/mmmfs/examples/language_support/javascript/title: text$plain b/root/articles/mmmfs/examples/language_support/javascript/title: text$plain
new file mode 100644
index 0000000..581fbc7
--- /dev/null
+++ b/root/articles/mmmfs/examples/language_support/javascript/title: text$plain
@@ -0,0 +1 @@
+JavaScript
diff --git a/root/articles/mmmfs/examples/language_support/lua/text$lua -> mmm$dom.lua b/root/articles/mmmfs/examples/language_support/lua/text$lua -> mmm$dom.lua
new file mode 100644
index 0000000..62e79f1
--- /dev/null
+++ b/root/articles/mmmfs/examples/language_support/lua/text$lua -> mmm$dom.lua
@@ -0,0 +1,9 @@
+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/articles/mmmfs/examples/language_support/lua/title: text$plain b/root/articles/mmmfs/examples/language_support/lua/title: text$plain
new file mode 100644
index 0000000..0f9d550
--- /dev/null
+++ b/root/articles/mmmfs/examples/language_support/lua/title: text$plain
@@ -0,0 +1 @@
+Lua
diff --git a/root/articles/mmmfs/examples/language_support/moonscript/text$moonscript -> mmm$dom.moon b/root/articles/mmmfs/examples/language_support/moonscript/text$moonscript -> mmm$dom.moon
new file mode 100644
index 0000000..5cc50e6
--- /dev/null
+++ b/root/articles/mmmfs/examples/language_support/moonscript/text$moonscript -> mmm$dom.moon
@@ -0,0 +1,10 @@
+import a, article, h1, p from require 'mmm.dom'
+
+moonscript = a 'MoonScript', href: 'https://moonscript.org/'
+lua = a 'Lua', href: 'https://www.lua.org/'
+fengari = a 'fengari.io', href: 'https://fengari.io/'
+
+article {
+ h1 'MoonScript',
+ p moonscript, " is compiled to ", lua, " on the server, which is then executed on the client using ", fengari, "."
+}
diff --git a/root/articles/mmmfs/examples/language_support/moonscript/title: text$plain b/root/articles/mmmfs/examples/language_support/moonscript/title: text$plain
new file mode 100644
index 0000000..f8871ac
--- /dev/null
+++ b/root/articles/mmmfs/examples/language_support/moonscript/title: text$plain
@@ -0,0 +1 @@
+MoonScript
diff --git a/root/articles/mmmfs/examples/language_support/preview: text$markdown b/root/articles/mmmfs/examples/language_support/preview: text$markdown
new file mode 100644
index 0000000..d6c2845
--- /dev/null
+++ b/root/articles/mmmfs/examples/language_support/preview: text$markdown
@@ -0,0 +1,6 @@
+this Fileder contains some minimal examples showing support for various languages `mmmfs` supports currently.
+
+Language support is mostly limited by the fact that `mmmfs` currently targets web browsers,
+on the server any scripting language that can be executed can theoretically be integrated with minimal effort.
+
+Using the inspector mode to view the source of the Fileders below is encouraged.
diff --git a/root/articles/mmmfs/examples/language_support/text$moonscript -> fn -> mmm$dom.moon b/root/articles/mmmfs/examples/language_support/text$moonscript -> fn -> mmm$dom.moon
new file mode 100644
index 0000000..4ae0679
--- /dev/null
+++ b/root/articles/mmmfs/examples/language_support/text$moonscript -> fn -> mmm$dom.moon
@@ -0,0 +1,16 @@
+import article, h1, p, ul, li, a from require 'mmm.dom'
+
+single = (a) -> a
+
+=>
+ children = for child in *@children
+ title = child\gett 'title: text/plain'
+ li a title, href: child.path, onclick: (e) =>
+ e\preventDefault!
+ BROWSER\navigate child.path
+
+ article {
+ h1 single @gett 'title: text/plain'
+ p single @gett 'preview: mmm/dom'
+ ul children
+ }
diff --git a/root/articles/mmmfs/examples/language_support/title: text$plain b/root/articles/mmmfs/examples/language_support/title: text$plain
new file mode 100644
index 0000000..ae06474
--- /dev/null
+++ b/root/articles/mmmfs/examples/language_support/title: text$plain
@@ -0,0 +1 @@
+scripting language support
diff --git a/root/articles/mmmfs/examples/markdown/preview: text$markdown.md b/root/articles/mmmfs/examples/markdown/preview: text$markdown.md
new file mode 100644
index 0000000..4b38ef2
--- /dev/null
+++ b/root/articles/mmmfs/examples/markdown/preview: text$markdown.md
@@ -0,0 +1,6 @@
+See I have like
+
+- a list of things
+- (two things)
+
+and some bold **text** and `code tags` with me.
diff --git a/root/articles/mmmfs/examples/markdown/title: text$plain b/root/articles/mmmfs/examples/markdown/title: text$plain
new file mode 100644
index 0000000..319068d
--- /dev/null
+++ b/root/articles/mmmfs/examples/markdown/title: text$plain
@@ -0,0 +1 @@
+ I'm not even five lines of markdown but i render myself!
diff --git a/root/articles/mmmfs/examples/text$moonscript -> fn -> mmm$dom.moon b/root/articles/mmmfs/examples/text$moonscript -> fn -> mmm$dom.moon
new file mode 100644
index 0000000..ca9078c
--- /dev/null
+++ b/root/articles/mmmfs/examples/text$moonscript -> fn -> mmm$dom.moon
@@ -0,0 +1,32 @@
+-- main content
+-- doesn't have a name prefix (e.g. preview: fn -> mmm/dom)
+-- uses the 'fn ->' conversion to execute the lua function on @get
+-- resolves to a value of type mmm/dom
+=>
+ html = require 'mmm.dom'
+ import h4, div, a, span from html
+
+ -- render a preview block
+ preview = (child) ->
+ -- get 'title' as 'text/plain' (error if no value or conversion possible)
+ title = child\gett 'title', 'text/plain'
+
+ -- get 'preview' as a DOM description (nil if no value or conversion possible)
+ content = child\get 'preview', 'mmm/dom'
+
+ div {
+ h4 title, style: { margin: 0, cursor: 'pointer' }, onclick: -> BROWSER\navigate child.path
+ content or span '(no renderable content)', style: { color: 'red' },
+ style: {
+ display: 'inline-block',
+ width: '300px',
+ height: '200px',
+ padding: '4px',
+ margin: '8px',
+ border: '4px solid #eeeeee',
+ overflow: 'hidden',
+ },
+ }
+
+ div for child in *@children
+ preview child