aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authors-ol <s-ol@users.noreply.github.com>2020-02-15 15:04:44 +0000
committers-ol <s-ol@users.noreply.github.com>2020-02-15 15:04:44 +0000
commit52c9149663fd77925e3dd9a4e9d164f6132dd418 (patch)
tree9458a319996ba4e188bc4c72d302e2b21dd4df22
parentrealities default to clientside (diff)
downloadmmm-52c9149663fd77925e3dd9a4e9d164f6132dd418.tar.gz
mmm-52c9149663fd77925e3dd9a4e9d164f6132dd418.zip
link_interactive for hybrid pages
-rw-r--r--build/server.moon2
-rw-r--r--mmm/mmmfs/util.moon15
-rw-r--r--root/blog/aspect_ratios/interactive/_base: text$moonscript -> table.moon35
-rw-r--r--root/research/realities/_web_view: type1
-rw-r--r--root/research/realities/text$moonscript -> mmm$component.moon7
5 files changed, 38 insertions, 22 deletions
diff --git a/build/server.moon b/build/server.moon
index bb7537b..a19edb0 100644
--- a/build/server.moon
+++ b/build/server.moon
@@ -101,7 +101,7 @@ class Server
when 'GET', 'HEAD'
root = Fileder @store
export BROWSER
- BROWSER = :root
+ BROWSER = :root, :path
fileder = root\walk path -- Fileder @store, path
if not fileder
diff --git a/mmm/mmmfs/util.moon b/mmm/mmmfs/util.moon
index 4f6b9bf..db59012 100644
--- a/mmm/mmmfs/util.moon
+++ b/mmm/mmmfs/util.moon
@@ -5,10 +5,12 @@ merge = (orig={}, extra={}) ->
for k,v in pairs extra
attr[k] = v
-tourl = (path) ->
+tourl = (path, _view) ->
path ..= '/'
if STATIC and STATIC.root
path = STATIC.root .. path
+ if _view
+ path ..= _view
path
(elements) ->
@@ -42,7 +44,7 @@ tourl = (path) ->
BROWSER\navigate path
a name, opts
- link_to = (fileder, name, origin, attr) ->
+ link_to = (fileder, name, origin, attr, _view) ->
fileder = find_fileder fileder, origin
name or= fileder\get 'title: mmm/dom'
@@ -52,12 +54,18 @@ tourl = (path) ->
a name, merge attr, :href, target: '_blank'
else
a name, merge attr, {
- href: tourl fileder.path
+ href: tourl fileder.path, _view
onclick: if MODE == 'CLIENT' then (e) =>
e\preventDefault!
BROWSER\navigate fileder.path
}
+ interactive_link = (text, view=':text/html+interactive') ->
+ assert MODE == 'SERVER'
+ path = BROWSER.path
+ path = table.concat path, '/' if 'table' == type BROWSER.path
+ a text, href: tourl path, view
+
embed = (fileder, name='', origin, opts={}) ->
if opts.raw
warn "deprecated option 'raw' set on embed"
@@ -135,6 +143,7 @@ tourl = (path) ->
{
:find_fileder
:link_to
+ :interactive_link
:navigate_to
:embed
}
diff --git a/root/blog/aspect_ratios/interactive/_base: text$moonscript -> table.moon b/root/blog/aspect_ratios/interactive/_base: text$moonscript -> table.moon
index 419eef0..0219af6 100644
--- a/root/blog/aspect_ratios/interactive/_base: text$moonscript -> table.moon
+++ b/root/blog/aspect_ratios/interactive/_base: text$moonscript -> table.moon
@@ -1,22 +1,27 @@
-import div from require 'mmm.dom'
+import div, a from require 'mmm.dom'
+import interactive_link from (require 'mmm.mmmfs.util') require 'mmm.dom'
if MODE ~= 'CLIENT'
class Dummy
render: =>
- div 'Interactive Example not available with Server-Side rendering', style:
- position: 'relative'
- resize: 'horizontal'
- overflow: 'hidden'
-
- width: '480px'
- height: '270px'
- 'min-width': '270px'
- 'max-width': '100%'
-
- margin: 'auto'
- padding: '10px'
- boxSizing: 'border-box'
- background: 'var(--gray-bright)'
+ div {
+ style:
+ position: 'relative'
+ resize: 'horizontal'
+ overflow: 'hidden'
+
+ width: '480px'
+ height: '270px'
+ 'min-width': '270px'
+ 'max-width': '100%'
+
+ margin: 'auto'
+ padding: '10px'
+ boxSizing: 'border-box'
+ background: 'var(--gray-bright)'
+
+ interactive_link '(click here for the interactive version of this article)'
+ }
return {
UIDemo: Dummy
diff --git a/root/research/realities/_web_view: type b/root/research/realities/_web_view: type
deleted file mode 100644
index bde5644..0000000
--- a/root/research/realities/_web_view: type
+++ /dev/null
@@ -1 +0,0 @@
-text/html+interactive
diff --git a/root/research/realities/text$moonscript -> mmm$component.moon b/root/research/realities/text$moonscript -> mmm$component.moon
index a7dc365..f6947db 100644
--- a/root/research/realities/text$moonscript -> mmm$component.moon
+++ b/root/research/realities/text$moonscript -> mmm$component.moon
@@ -1,5 +1,6 @@
import elements from require 'mmm.component'
import h1, h2, p, a, i, div, ol, li, br, hr, span, button, section, article from elements
+import interactive_link from (require 'mmm.mmmfs.util') elements
_content = div!
append = _content\append
@@ -11,7 +12,9 @@ if MODE == 'SERVER'
display: 'inline-block',
width: '150px',
height: '80px',
- 'line-height': '80px',
+ padding: '12px'
+ 'line-height': '20px',
+ 'box-sizing': 'border-box'
color: '#fff',
background: '#666',
}
@@ -23,7 +26,7 @@ if MODE == 'SERVER'
render: =>
rplc = with div id: @id, :style
- \append '(diagram goes here)'
+ \append interactive_link 'click for interactive version'
-- \append "<script type=\"text/lua\">
-- local rplc = js.global.document:getElementById('#{@id}');
-- local fn = #{compile @func}