shrub/ren/collections/elem.hoon

311 lines
7.8 KiB
Plaintext
Raw Normal View History

2018-07-31 07:00:49 +03:00
::
::::
::
/? 309
/+ collections, cram
/= gas /$ fuel:html
2018-09-06 21:10:08 +03:00
/= itm /collections-web-item/
2018-07-31 07:00:49 +03:00
::
::
/= collection-post
2018-08-03 04:04:52 +03:00
:: /^ $-(raw-item:collections manx)
2018-09-07 02:39:02 +03:00
/: /===/web/landscape/collections/post /!noun/
::/= collection-details
:: /^ manx
:: /: /===/web/landscape/collections/details /% /!hymn/
2018-07-31 07:00:49 +03:00
::
::
=< (item-to-elem itm)
|%
++ item-to-elem
|= itm=item:collections
^- manx
2018-08-01 02:31:30 +03:00
=/ sho (fall (~(get by qix.gas) %show) %default)
2018-07-31 07:00:49 +03:00
;div.container
;div.row
;div.col-sm-10.col-sm-offset-2
;div.collection-index.mt-12
;+ (meta-to-elem itm sho)
;+
?- -.itm
::
%collection
?+ sho !!
%default (collection-to-elem col.itm)
%post (collection-post ~ (flop s.bem.gas))
%edit !!
==
::
%raw
?+ sho !!
%default (raw-to-elem raw.itm)
%post !!
%edit (collection-post `raw.itm (flop s.bem.gas))
==
::
%both
?+ sho !!
%default (both-to-elem col.itm raw.itm)
%post !!
%edit (collection-post `raw.itm (flop s.bem.gas))
==
::
2018-08-23 02:34:49 +03:00
==
==
==
==
2018-07-31 07:00:49 +03:00
==
++ collection-to-elem
|= col=collection:collections
^- manx
;ul.vanilla
2018-08-23 02:34:49 +03:00
;* %+ turn ~(tap by data.col)
|= [nom=knot ite=item:collections]
^- manx
;li.collection-post.mt-6
;+ (item-to-snip nom ite)
==
2018-07-31 07:00:49 +03:00
==
::
++ raw-to-elem
|= raw=raw-item:collections
^- manx
=/ elm elm:(static:cram (ream data.raw))
=/ ht (hedtal +.elm)
=/ title (fall (~(get by meta.raw) %name) -.s.bem.gas)
=/ date (fall (~(get by meta.raw) %date-created) 'missing date')
=/ owner (fall (~(get by meta.raw) %owner) 'anonymous')
::
;div
;div.collection-date: {(trip date)}
::
;div#show
;div.row.tit.mt-6.collection-title
;+ ?~ hed.ht
;h3: {(trip title)}
;h3: *{hed.ht}
==
==
::
;div.who.text-mono.text-600: {(trip owner)}
;div.row.content.mb-18.mt-6
;+ elm
==
::
:: if comments are enabled it should be a %both not a %raw
:: XX REVIEW ^^ not robust enough?
==
::
++ both-to-elem
|= [col=collection:collections raw=raw-item:collections]
^- manx
;div
;+ (raw-to-elem raw)
::
;div
;div.mb-2
;span(urb-component "IconComment");
;span: {<~(wyt by data.col)>}
==
::
;ul
;* %+ turn ~(tap by data.col) :: XX TODO: sort
|= [nom=knot ite=item:collections]
^- manx
:: XX TODO: accept types other than comments
?> ?=(%raw -.ite)
2018-08-21 00:16:57 +03:00
:: ?> =(%comments (~(got by meta.raw.ite) %type))
2018-07-31 07:00:49 +03:00
=/ owner (fall (~(get by meta.raw.ite) %owner) 'anonymous')
=/ date (fall (~(get by meta.raw.ite) %date-created) 'missing date')
;li.collection-comment
;div.collection-comment-avatar
;div(urb-component "AvatarSample1");
==
;div
;a.collection-comment-author.text-mono
=href "/~~/landscape/profile"
; {(trip owner)}
==
;+ elm:(static:cram (ream data.raw.ite))
2018-07-31 07:00:49 +03:00
==
;span.collection-date: {(trip date)}
==
==
::
;div
=urb-component "CommentCreate"
=urb-pax "{<(flop s.bem.gas)>}"
=urb-ship "{(scow %p p.bem.gas)}";
==
==
::
::
++ item-to-snip
|= [nom=knot itm=item:collections]
^- manx
?- -.itm
%collection
(collection-to-snip nom col.itm)
%raw
(raw-to-snip nom raw.itm)
%both
(both-to-snip nom col.itm raw.itm)
==
::
++ collection-to-snip
|= [nom=knot col=collection:collections]
^- manx
=/ lnk=tape
"/~~/{(scow %p p.full-path.meta.col)}/=={(spud (flop (slag 1 s.full-path.meta.col)))}"
2018-07-31 07:00:49 +03:00
;div
;div.collection-date: {<date-created.meta.col>}
;h3
;a(href lnk): {(trip name.meta.col)}
2018-07-31 07:00:49 +03:00
==
;div.who.text-mono.text-600: {<owner.meta.col>}
;div.meta-cont
;div.com-count.ml-12
; {(trip (scot %ud ~(wyt by data.col)))} comments
==
==
==
::
++ raw-to-snip
|= [nom=knot raw=raw-item:collections]
^- manx
=/ elm=manx elm:(static:cram (ream data.raw))
=/ ht (hedtal +.elm)
=? tal.ht ?=(~ hed.ht)
(scag 5 c.elm)
=/ title (fall (~(get by meta.raw) %name) nom)
=/ date (fall (~(get by meta.raw) %date-created) 'missing date')
=/ owner (fall (~(get by meta.raw) %owner) 'anonymous')
=/ lnk=tape
"/~~/{(scow %p p.bem.gas)}/=={(spud (flop s.bem.gas))}/{(trip nom)}"
2018-07-31 07:00:49 +03:00
::
;div
;div.collection-date: {(trip date)}
;h3
;+ ?~ hed.ht
;a(href lnk): {(trip title)}
;a(href lnk): *{hed.ht}
2018-07-31 07:00:49 +03:00
==
;div.who.text-mono.text-600: {(trip owner)}
;div.snippet
;* tal.ht
==
==
::
++ both-to-snip
|= [nom=knot col=collection:collections raw=raw-item:collections]
^- manx
=/ elm=manx elm:(static:cram (ream data.raw))
=/ ht (hedtal +.elm)
=? tal.ht ?=(~ hed.ht)
(scag 5 c.elm)
=/ title (fall (~(get by meta.raw) %name) nom)
=/ lnk=tape
"/~~/{(scow %p p.bem.gas)}/=={(spud (flop s.bem.gas))}/{(trip nom)}"
2018-07-31 07:00:49 +03:00
::
;div
;div.collection-date: {<date-created.meta.col>}
;h3
;+ ?~ hed.ht
;a(href lnk): {(trip title)}
;a(href lnk): *{hed.ht}
2018-07-31 07:00:49 +03:00
==
;div.who.text-mono.text-600: {<owner.meta.col>}
;div.snippet: *{tal.ht}
;div.meta-cont
;div.com-count.ml-12
; {(trip (scot %ud ~(wyt by data.col)))} comments
==
==
==
2018-08-21 02:24:43 +03:00
::
2018-08-23 02:34:49 +03:00
++ meta-to-elem
|= [itm=item:collections sho=@tas]
2018-08-21 02:24:43 +03:00
^- manx
2018-08-23 02:34:49 +03:00
=/ mat=mart
:~ [%type "hidden"]
[%name "urb-metadata"]
[%urb-show (trip sho)]
[%urb-path (spud (flop s.bem.gas))]
==
:_ ~
:- %input
2018-08-23 02:34:49 +03:00
%+ weld mat
^- mart
?- -.itm
%collection
=* met meta.col.itm
:~ [%urb-name (trip name.met)]
[%urb-owner (scow %p owner.met)]
[%urb-date-created (scow %da date-created.met)]
[%urb-last-modified (scow %da last-modified.met)]
[%urb-content-type (trip type.met)]
[%urb-structure-type "collection-index"]
==
%raw
=/ met ~(got by meta.raw.itm)
:~ [%urb-name (trip (met %name))]
[%urb-owner (trip (met %owner))]
[%urb-date-created (trip (met %date-created))]
[%urb-last-modified (trip (met %last-modified))]
[%urb-content-type (trip (met %type))]
[%urb-structure-type "collection-post"]
==
%both
=/ met ~(got by meta.raw.itm)
:~ [%urb-name (trip (met %name))]
[%urb-owner (trip (met %owner))]
[%urb-date-created (trip (met %date-created))]
[%urb-last-modified (trip (met %last-modified))]
[%urb-content-type (trip (met %type))]
[%urb-structure-type "collection-post"]
==
==
2018-07-31 07:00:49 +03:00
::::
:::: /mar/snip
::::
++ words 1
++ hedtal
=| met/marl
|= a/marl ^- {hed/marl tal/marl}
?~ a [~ ~]
:: looks like it only terminates if it finds an h1?
?. ?=($h1 n.g.i.a)
?: ?=($meta n.g.i.a)
$(a t.a, met [i.a met])
=+ had=$(a c.i.a)
?^ -.had had
$(a t.a)
[c.i.a (weld (flop met) (limit words t.a))]
::
::
++ limit
|= {lim/@u mal/marl}
=< res
|- ^- {rem/@u res/marl}
?~ mal [lim ~]
?~ lim [0 ~]
=+ ^- {lam/@u hed/manx}
?: ?=(_;/(**) i.mal)
[lim ;/(tay)]:(deword lim v.i.a.g.i.mal)
[rem ele(c res)]:[ele=i.mal $(mal c.i.mal)]
[rem - res]:[hed $(lim lam, mal t.mal)]
::
++ deword
|= {lim/@u tay/tape} ^- {lim/@u tay/tape}
?~ tay [lim tay]
?~ lim [0 ~]
=+ wer=(dot 1^1 tay)
?~ q.wer
[lim - tay]:[i.tay $(tay t.tay)]
=+ nex=$(lim (dec lim), tay q.q.u.q.wer)
[-.nex [(wonk wer) +.nex]]
::
::
::
--