git.s-ol.nu mmm / 1ae9276
link to the correct facet if specified in mmm-embed s-ol 2 months ago
1 changed file(s) with 11 addition(s) and 11 deletion(s). Raw diff Collapse all Expand all
44 for k,v in pairs extra
55 attr[k] = v
66
7 tourl = (path, _view) ->
7 tourl = (path, facet) ->
88 path ..= '/'
99 if STATIC and STATIC.root
1010 path = STATIC.root .. path
11 if _view
12 path ..= _view
11 if facet
12 path ..= facet
1313 path
1414
1515 (elements) ->
4242 BROWSER\navigate path
4343 a name, opts
4444
45 link_to = (fileder, name, origin, attr, _view) ->
45 link_to = (fileder, name, origin, attr, facet) ->
4646 fileder = find_fileder fileder, origin
4747
4848 name or= fileder\get 'title: mmm/dom'
5252 a name, merge attr, :href, target: '_blank'
5353 else
5454 a name, merge attr, {
55 href: tourl fileder.path, _view
55 href: tourl fileder.path, facet
5656 onclick: if MODE == 'CLIENT' then (e) =>
5757 e\preventDefault!
5858 BROWSER\navigate fileder.path
6464 path = table.concat path, '/' if 'table' == type BROWSER.path
6565 a text, href: tourl path, view
6666
67 embed = (fileder, name='', origin, opts={}) ->
67 embed = (fileder, facet='', origin, opts={}) ->
6868 if opts.raw
6969 warn "deprecated option 'raw' set on embed"
7070 assert not opts.wrap, "raw and wrap cannot both be set on embed"
7373
7474 fileder = find_fileder fileder, origin
7575
76 -- node = fileder\gett name, 'mmm/dom'
77 ok, node = pcall fileder.gett, fileder, name, 'mmm/dom'
76 -- node = fileder\gett facet, 'mmm/dom'
77 ok, node = pcall fileder.gett, fileder, facet, 'mmm/dom'
7878
7979 if not ok
80 warn "couldn't embed #{fileder} #{name}: #{node}"
80 warn "couldn't embed #{fileder} #{facet}: #{node}"
8181 return span {
8282 class: 'embed'
8383 style:
8484 background: 'var(--gray-fail)'
8585 padding: '1em'
8686
87 "couldn't embed #{fileder} #{name}"
87 "couldn't embed #{fileder} #{facet}"
8888 (pre node)
8989 }
9090
108108 if opts.nolink
109109 node
110110 else
111 link_to fileder, node, nil, opts.attr
111 link_to fileder, node, nil, opts.attr, facet
112112
113113 when 'sidenote'
114114 key = tostring refs\get!