some bugfixes and readded x-ship renderers

This commit is contained in:
Isaac Visintainer 2018-07-31 13:56:38 -07:00
parent a8850c8695
commit 90289cfa1d
19 changed files with 383 additions and 4 deletions

4
.gitignore vendored
View File

@ -1 +1,5 @@
/sec/**/*.atom
*.swp
*.swo
/web/collections
!/web/collection

View File

@ -197,6 +197,7 @@
:~ [%owner (scot %p src.bol)]
[%date-created dat]
[%last-modified dat]
[%type %comments]
==
[%write (weld pax.a /[dat]/umd) %umd (update-umd-front front content.a)]
::

View File

@ -136,6 +136,9 @@
:- /ren/run "not meant to be called except on a (different) hoon file"
:- /ren/collection "temporarily disabled"
:- /ren/x-urb "temporarily disabled"
:- /ren/x-htm "temporarily disabled"
:- /ren/x-collections-snip "temporarily disabled"
:- /ren/x-collections-json "temporarily disabled"
:- /ren/urb "temporarily disabled"
::
:- /app/gh "hangs for some reason"

View File

@ -18,7 +18,7 @@
::
+= config
$: full-path=beam
name=@t
name=@ta
description=@t
::
owner=@p

View File

@ -80,12 +80,14 @@
desc+so:dejs
comments+bo:dejs
visible+bo:dejs
type+(su:dejs sym)
==
::
++ post
%- ot:dejs
:~ path+(su:dejs ;~(pfix fas (more fas urs:ab)))
name+sa
type+(su:dejs sym)
comments+bo:dejs
content+so:dejs
==
@ -93,8 +95,6 @@
++ comment
%- ot:dejs
:~ path+(su:dejs ;~(pfix fas (more fas urs:ab)))
name+sa
comments+bo:dejs
content+so:dejs
==
::

View File

@ -0,0 +1,26 @@
::
:::: /hoon/x-collections-json/mar
::
/? 310
::
:::: compute
::
=, eyre
=, format
=, html
|_ jon/json
::
++ grow :: convert to
|%
++ mime [/application/json (as-octs:mimes txt)] :: convert to %mime
++ txt (crip (en-json jon))
--
++ grab
|% :: convert from
++ mime |=({p/mite q/octs} (fall (rush (@t q.q) apex:de-json) *json))
++ noun json :: clam from %noun
++ numb numb:enjs
++ time time:enjs
--
++ grad %mime
--

View File

@ -0,0 +1,3 @@
|_ a=json
++ grab |% ++ noun json
-- --

View File

@ -0,0 +1,20 @@
/? 310
|_ [hed=marl tal=marl]
++ grow
|%
++ mime
=< mime
|%
++ elem ;div:(h1:"*{hed}" div:"*{tal}") :: convert to %elem
++ hymn ;html:(head:title:"snip" body:"+{elem}") :: convert to %hymn
++ html (crip (en-xml:^html hymn)) :: convert to %html
++ mime [/text/html (as-octs:mimes:^html html)] :: convert to %mime
--
++ collections-snip [hed tal]
--
++ grab
|%
++ noun [marl marl]
--
--

View File

@ -0,0 +1,3 @@
|_ a=manx
++ grab |% ++ noun manx
-- --

3
mar/x-htm.hoon Normal file
View File

@ -0,0 +1,3 @@
|_ a=manx
++ grow |% ++ htm a
-- --

3
mar/x-htm/elem.hoon Normal file
View File

@ -0,0 +1,3 @@
|_ a=manx
++ grab |% ++ noun manx
-- --

269
ren/collection/snip.hoon Normal file
View File

@ -0,0 +1,269 @@
::
::::
::
/? 309
/+ collections, cram
/= gas /$ fuel:html
/= itm /% /collection-web-item/
::
::
/= collection-post
/^ manx
/: /===/web/landscape/collection/post /% /!hymn/
/= collection-details
/^ manx
/: /===/web/landscape/collection/details /% /!hymn/
::
::
=< (item-to-elem itm)
|%
++ item-to-elem
|= itm=item:collections
^- manx
=/ sho (~(get by qix.gas) %show)
;div.container
;input
=type "hidden"
=name "urb-header"
=value "collection"
=station "{(scow %p p.bem.gas)}/{<(flop s.bem.gas)>}"
=ship "{(scow %p p.bem.gas)}";
;div.row
;div.col-sm-10.col-sm-offset-2
;div.collection-index.mt-12
;+
?- -.itm
::
%collection
?+ sho !!
~ (collection-to-elem col.itm)
[~ %post] collection-post
[~ %edit] !!
[~ %details] collection-details
==
::
%raw
?+ sho !!
~ (raw-to-elem raw.itm)
[~ %post] !!
[~ %edit] collection-post
[~ %details] collection-details
==
::
%both
?+ sho !!
~ (both-to-elem col.itm raw.itm)
[~ %post] !!
[~ %edit] collection-post
[~ %details] collection-details
==
::
==
==
==
==
==
++ collection-to-elem
|= col=collection:collections
^- manx
;ul
;* %+ turn ~(tap by data.col)
|= [nom=knot ite=item:collections]
^- manx
;li.collection-post.mt-6
;+ (item-to-snip nom ite)
==
==
::
++ 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)
?> =(%comments (~(got by meta.raw.ite) %type))
=/ 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))
==
;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
==
==
==
::::
:::: /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]]
::
::
::
--

View File

@ -0,0 +1,13 @@
::
:::: /hoon/json/ren
::
/? 309
/= page /%
/^ json
/, /web/collections
/& json
/collection-json/
/
/!json/
==
page

View File

@ -0,0 +1 @@
|=(a=json a)

View File

@ -0,0 +1,16 @@
::
:: no snip view for collections, only items
::
/= snipped-umd
/& snip
/& elem
/umd/
^- manx
;div
;h1
;* hed.snipped-umd
==
;* tal.snipped-umd
==

View File

@ -0,0 +1 @@
|=(a=manx [*marl ~[a]])

12
ren/x-htm/elem.hoon Normal file
View File

@ -0,0 +1,12 @@
::
:::: /hoon/elem/x-htm/ren
::
/? 309
/= page /%
/^ manx
/, /web/collections
/collection-elem/
/
/!hymn/
==
page

1
ren/x-htm/wrap.hoon Normal file
View File

@ -0,0 +1 @@
|=(a=manx a)

View File

@ -10,7 +10,7 @@
:: ==
:: %coll
:: ''
/= gas /$ fuel:html
/= gas /$ fuel:html ::
^- manx
;div
;div(urb-component "TopicCreatePage", urb-ship "{(scow %p p.bem.gas)}");