shrub/ren/collections/elem.hoon

297 lines
7.3 KiB
Plaintext
Raw Normal View History

2018-07-31 07:00:49 +03:00
::
::::
::
/? 309
/+ collections, cram
/= gas /$ fuel:html
2018-08-01 02:31:30 +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-08-01 02:31:30 +03:00
/: /===/web/landscape/collections/post /% /!noun/
2018-07-31 07:00:49 +03:00
/= collection-details
/^ manx
2018-08-01 02:31:30 +03:00
/: /===/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
;input
2018-08-08 21:34:04 +03:00
=type "hidden"
=name "urb-header"
=value (trip -.itm)
=show (trip sho)
=path "{<(flop s.bem.gas)>}"
=ship "{(scow %p p.bem.gas)}";
2018-07-31 07:00:49 +03:00
;div.row
;div.col-sm-10.col-sm-offset-2
;div.collection-index.mt-12
;+
?- -.itm
::
%collection
2018-08-01 02:31:30 +03:00
?+ sho !!
%default (collection-to-elem col.itm)
2018-08-03 04:04:52 +03:00
%post (collection-post ~ (flop s.bem.gas))
2018-08-01 02:31:30 +03:00
%edit !!
%details collection-details
2018-07-31 07:00:49 +03:00
==
::
%raw
2018-08-01 02:31:30 +03:00
?+ sho !!
%default (raw-to-elem raw.itm)
%post !!
2018-08-03 04:04:52 +03:00
%edit (collection-post `raw.itm (flop s.bem.gas))
2018-08-01 02:31:30 +03:00
%details collection-details
2018-07-31 07:00:49 +03:00
==
::
%both
2018-08-01 02:31:30 +03:00
?+ sho !!
%default (both-to-elem col.itm raw.itm)
%post !!
2018-08-03 04:04:52 +03:00
%edit (collection-post `raw.itm (flop s.bem.gas))
2018-08-01 02:31:30 +03:00
%details collection-details
2018-07-31 07:00:49 +03:00
==
::
==
==
==
==
==
++ collection-to-elem
|= col=collection:collections
^- manx
2018-08-21 02:24:43 +03:00
;div
;+ (config-to-elem meta.col)
;ul
;* %+ 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
2018-08-21 02:24:43 +03:00
;+ (front-to-elem meta.raw)
2018-07-31 07:00:49 +03:00
;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
;div
;div.collection-date: {<date-created.meta.col>}
;h3
;a(href "{(trip -.s.bem.gas)}/{(trip nom)}"): {(trip name.meta.col)}
==
;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')
::
;div
;div.collection-date: {(trip date)}
;h3
;+ ?~ hed.ht
;a(href "{(trip -.s.bem.gas)}/{(trip nom)}"): {(trip title)}
;a(href "{(trip -.s.bem.gas)}/{(trip nom)}"): *{hed.ht}
==
;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)
::
;div
;div.collection-date: {<date-created.meta.col>}
;h3
;+ ?~ hed.ht
;a(href "{(trip -.s.bem.gas)}/{(trip nom)}"): {(trip title)}
;a(href "{(trip -.s.bem.gas)}/{(trip nom)}"): *{hed.ht}
==
;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
::
++ front-to-elem
|= fro=(map knot cord)
^- manx
:_ ~
:- %div
%+ turn ~(tap by (~(put by fro) %class %item-meta))
|= [a=knot b=cord]
^- [mane tape]
[((hard @tas) a) (trip b)]
::
++ config-to-elem
|= con=config:collections
^- manx
;div.collection-meta
=urb-full-path (spud (en-beam:format full-path.con))
=urb-name (trip name.con)
=urb-description (trip description.con)
=urb-owner (scow %p owner.con)
=urb-date-created (scow %da date-created.con)
=urb-last-modified (scow %da last-modified.con)
=urb-type (trip type.con);
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]]
::
::
::
--