Added in landscape integrated with Light and Modulo

This commit is contained in:
Logan Allen 2019-03-19 13:47:19 -07:00 committed by Isaac Visintainer
parent ea180d7416
commit 6ecf041609
21 changed files with 83394 additions and 192 deletions

116
app/landscape.hoon Normal file
View File

@ -0,0 +1,116 @@
/+ *server
/= index
/: /===/app/landscape/index /!noun/
/= script
/^ octs
/; as-octs:mimes:html
/: /===/app/landscape/js/index /js/
/= style
/^ octs
/; as-octs:mimes:html
/: /===/app/landscape/css/index /css/
/= profile
/: /===/app/landscape/profile /!noun/
/= inbox
/: /===/app/landscape/inbox /!noun/
/= stream
/: /===/app/landscape/stream /!noun/
/= coll-elem
/: /===/app/landscape/collections/elem /!noun/
/= coll-new
/: /===/app/landscape/collections/new /!noun/
::
|%
:: +move: output effect
::
+$ move [bone card]
:: +card: output effect payload
::
+$ card
$% [%poke wire dock poke]
[%http-response =http-event:http]
==
+$ poke
$% [%modulo-bind app=term]
[%modulo-unbind app=term]
==
--
::
|_ [bol=bowl:gall sta=@t]
::
++ this .
::
++ prep
|= old=(unit @t)
^- (quip move _this)
:- [ost.bol %poke / [our.bol %modulo] [%modulo-bind %landscape]]~
?~ old
this
this(sta u.old)
::
++ poke-handle-http-request
%- (require-authorization ost.bol move this)
|= =inbound-request:http-server
^- (quip move _this)
=+ request-line=(parse-request-line url.request.inbound-request)
=+ back-path=(flop site.request-line)
=/ name=@t
?~ back-path
!!
i.back-path
?< ?=(~ site.request-line)
?+ t.site.request-line
=/ index-html=octs (manx-to-octs (index inbox))
[[ost.bol %http-response (html-response index-html)]~ this]
::
[%css *]
[[ost.bol %http-response (css-response style)]~ this]
::
[%js *]
[[ost.bol %http-response (js-response script)]~ this]
::
[%profile @t *]
=/ profile-html=octs
(manx-to-octs (index (profile i.t.t.site.request-line)))
[[ost.bol %http-response (html-response profile-html)]~ this]
::
[%stream *]
=/ stream-html=octs (manx-to-octs (index stream))
[[ost.bol %http-response (html-response stream-html)]~ this]
::
[%collections @t @t *]
=/ shp/@p (slav %p i.t.t.site.request-line)
=/ col/@da (slav %da i.t.t.t.site.request-line)
=* tal t.t.t.t.site.request-line
:: top level collection
::
?: ?=(~ tal)
=/ top-html=octs (manx-to-octs (index (coll-elem shp col ~)))
[[ost.bol %http-response (html-response top-html)]~ this]
:: make a new post, or view an old one
::
?: ?=([@t ~] tal)
:: make a new post
::
?: =(-.tal 'new')
=/ new-html=octs (manx-to-octs (index (coll-new shp col)))
[[ost.bol %http-response (html-response new-html)]~ this]
:: view a post
::
=/ pos=[@da ?(%default %edit)]
[(slav %da i.tal) %default]
=/ post-html=octs (manx-to-octs (index (coll-elem shp col `pos)))
[[ost.bol %http-response (html-response post-html)]~ this]
:: edit a post
::
?: ?=([@t @t ~] tal)
?: =(+<.tal 'edit')
=/ pos=[@da ?(%default %edit)]
[(slav %da i.tal) %edit]
=/ edit-html=octs (manx-to-octs (index (coll-elem shp col `pos)))
[[ost.bol %http-response (html-response edit-html)]~ this]
[~ this]
[~ this]
==
--

View File

@ -0,0 +1,14 @@
::
::::
::
|= [shp=@p col=@da pos=@da dat=@t]
^- manx
;div.container
;div
=urb-component "TopicCreatePage"
=urb-ship "{<shp>}"
=urb-claypath "{<col>}"
=urb-content (trip dat)
;input(type "hidden", name "urb-header", value "collection-write", station "query");
==
==

View File

@ -0,0 +1,314 @@
::
::::
::
/? 309
/+ collections, cram
/= coll-new
/: /===/app/landscape/collections/new /!noun/
/= coll-edit
/: /===/app/landscape/collections/edit /!noun/
/= cols
/^ collection:collections
/; |= a=(map knot item:collections)
[*config:collections a]
/: /===/web/collections /_ /collections-item/
::
::
|%
+$ post-page [p=@da q=?(%default %edit)]
--
|= [shp=@p col=@da pos=(unit post-page)]
^- manx
=/ itm=(unit item:collections) (~(get by data.cols) (scot %da col))
?~ itm
;div: Invalid collection
=< (item-to-elem u.itm)
|%
++ item-to-elem
!:
|= itm=item:collections
?~ pos
?> ?=(%collection -.itm)
^- manx
;div.container
;div.row
;div.flex-col-2;
;div.flex-col-x
;div.collection-index
;+ (meta-to-elem itm)
;+ (collection-to-elem col.itm)
==
==
;+ ?: =(type.meta.col.itm %blog)
;div.flex-col-5;
?: =(type.meta.col.itm %fora)
;div.flex-col-4;
;div.flex-col-4;
==
==
::
::
?> ?=(%collection -.itm)
=/ posttt=(unit item:collections) (~(get by data.col.itm) (scot %da p.u.pos))
?~ posttt
;div: Invalid collection
?> ?=(%both -.u.posttt)
^- manx
;div.row
;div.flex-col-2;
;div.flex-col-x
;div.collection-index
;+ (meta-to-elem u.posttt)
;+
?- q.u.pos
%default
(both-to-elem col.u.posttt raw.u.posttt)
::
%edit
=/ dat data.raw.u.posttt
(coll-edit shp col p.u.pos dat)
==
==
==
;div.flex-col-2;
==
::
++ collection-to-elem
|= col=collection:collections
^- manx
;ul.vanilla
;* %+ roll
%+ sort ~(tap by data.col)
|= [[knot a=item:collections] [knot b=item:collections]]
=/ a-dat (extract-date-created a)
=/ b-dat (extract-date-created b)
(lth a-dat b-dat)
|= [[nom=knot ite=item:collections] out=marl]
^- marl
?: ?=(%error -.ite)
out
:_ out
^- 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:collections +.elm)
=/ title (fall (~(get by meta.raw) %name) /spur)
=/ date (fall (~(get by meta.raw) %date-created) 'missing date')
=/ author (fall (~(get by meta.raw) %author) 'anonymous')
::
;div.mb-18.mt-4
;+ elm
==
::
++ both-to-elem
|= [col=collection:collections raw=raw-item:collections]
^- manx
;div
;+ (raw-to-elem raw)
::
;div
;div.flex.align-center.mb-5
;div(urb-component "IconComment");
;div.ml-2.text-small.text-mono.text-600: {<~(wyt by data.col)>}
==
::
;ul.vanilla
;* %+ turn
%+ sort ~(tap by data.col)
|= [[knot a=item:collections] [knot b=item:collections]]
=/ a-dat (extract-date-created a)
=/ b-dat (extract-date-created b)
(lte a-dat b-dat)
|= [nom=knot ite=item:collections]
^- manx
?> ?=(%raw -.ite)
=/ author (fall (~(get by meta.raw.ite) %author) 'anonymous')
=/ host (fall (~(get by meta.raw.ite) %host) 'anonymous')
=/ date (fall (~(get by meta.raw.ite) %date-created) 'missing date')
;li.mb-6
;div.flex.align-center
;div.mr-2
=urb-component "Sigil"
=urb-ship "{(trip author)}"
=urb-size "18"
=urb-suffix "true";
;div
;a.vanilla.text-mono.text-small.text-700.mr-4
=href "/~~/{(trip host)}/==/web/landscape/profile"
; {(trip author)}
==
==
;div.text-host-breadcrumb
=urb-component "Elapsed"
=urb-timestring "{(trip date)}";
==
;div.collection-comment-content
;+ elm:(static:cram (ream data.raw.ite))
==
==
==
::
;div
=urb-component "CommentCreate"
=urb-pax "{<(flop /spur)>}"
=urb-ship "{<shp>}";
==
==
::
++ extract-date-created
|= i=item:collections
^- @da
?- -.i
%error *@da
%collection date-created.meta.col.i
%both date-created.meta.col.i
%raw (slav %da (~(got by meta.raw.i) %date-created))
==
::
::
::
++ item-to-snip
|= [nom=knot itm=item:collections]
^- manx
?- -.itm
%error
;div: Invalid collection
%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
"/~landscape/collections/{<shp>}/{(scow %p p.full-path.meta.col)}/{(spud (flop (slag 1 s.full-path.meta.col)))}"
;div
;div.collection-date: {<date-created.meta.col>}
;h2.mt-0.mb-0
;a(href lnk): {(trip name.meta.col)}
==
;div.who.text-mono.text-600: {<author.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:collections +.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')
=/ author (fall (~(get by meta.raw) %author) 'anonymous')
=/ lnk=tape
"/~landscape/collections/{<shp>}/{(scow %da col)}/{(trip nom)}"
::
;div
;div.collection-date: {(trip date)}
;h2
;+ ?~ hed.ht
;a(href lnk): {(trip title)}
;a(href lnk): *{hed.ht}
==
;div.who.text-mono.text-600: {(trip author)}
;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:collections +.elm)
=? tal.ht ?=(~ hed.ht)
(scag 5 c.elm)
=/ title (fall (~(get by meta.raw) %name) nom)
=/ lnk=tape
"/~landscape/collections/{<shp>}/{(scow %da ^col)}/{(trip nom)}"
::
;div
;div.collection-date: {<date-created.meta.col>}
;h2.mt-0.mb-0.text-500
;+ ?~ hed.ht
;a(href lnk): {(trip title)}
;a(href lnk): *{hed.ht}
==
;div.text-mono.text-small.text-300.mt-1.mb-1: {<author.meta.col>}
;div
;div.icon-label.justify-start
;div(urb-component "IconComment");
;div.ml-2
; {(trip (scot %ud ~(wyt by data.col)))}
==
==
==
==
::
++ meta-to-elem
|= itm=item:collections
^- manx
=/ mat=mart
:~ [%type "hidden"]
[%name "urb-metadata"]
==
:_ ~
:- %input
%+ weld mat
^- mart
?- -.itm
%error ~
%collection
=* met meta.col.itm
:~ [%urb-name (trip name.met)]
[%urb-author (scow %p author.met)]
[%urb-host (scow %p p.full-path.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"]
[%urb-path (spud /web/collections/(scot %da date-created.meta.col.itm))]
[%urb-show "default"]
==
%raw
=/ met ~(got by meta.raw.itm)
:~ [%urb-name (trip (met %name))]
[%urb-author (trip (met %author))]
[%urb-host (trip (met %host))]
[%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"]
[%urb-path (spud (flop /web/collections/raw))]
[%urb-show "default"]
==
%both
=/ met ~(got by meta.raw.itm)
:~ [%urb-name (trip (met %name))]
[%urb-author (trip (met %author))]
[%urb-host (trip (met %host))]
[%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"]
[%urb-path (spud (flop /web/collections/both))]
[%urb-show "default"]
==
==
--

View File

@ -0,0 +1,14 @@
::
::::
::
|= [shp=@p col=@da]
^- manx
;div.container
;div
=urb-component "TopicCreatePage"
=urb-ship "{<shp>}"
=urb-claypath "{<col>}"
=urb-content ""
;input(type "hidden", name "urb-header", value "collection-write", station "query");
==
==

File diff suppressed because one or more lines are too long

5
app/landscape/inbox.hoon Normal file
View File

@ -0,0 +1,5 @@
^- manx
;div
;div(urb-component "InboxPage");
;input(type "hidden", name "urb-metadata", urb-structure-type "header-inbox");
==

22
app/landscape/index.hoon Normal file
View File

@ -0,0 +1,22 @@
|= inner=manx
^- manx
;html
::
;head
;title: Landscape
;meta(charset "utf-8");
;meta
=name "viewport"
=content "width=device-width, initial-scale=1, shrink-to-fit=no";
;link(rel "stylesheet", href "/~landscape/css.css");
==
::
;body
;div#root
;+ inner
==
;script@"/~/channel/channel.js";
;script@"/modulo/session.js";
;script@"/~landscape/js.js";
==
==

82847
app/landscape/js/index.js Normal file

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,26 @@
|= who=@t
^- manx
;div
;input(type "hidden", name "urb-metadata", urb-structure-type "header-profile", urb-author "{(trip who)}");
;div.container
;div.row
;div.flex-col-2;
;div.flex-col-x
;div.profile-avatar
;div(urb-component "Sigil", urb-size "320", urb-ship "{(trip who)}", urb-suffix "false");
;div(urb-component "ProfileMsgBtn", urb-ship "{(trip who)}");
==
==
==
;div.row.mt-9
;div.flex-offset-2.flex-col-x
;h2.text-500: Meta
==
==
;div.row.mt-4.align-center
;div.flex-col-2;
;h3.text-500.flex-col-1.mt-0: Started:
;div.flex-col-x.text-mono: ~2018.4.12..6.45.12
==
==
==

View File

@ -0,0 +1,6 @@
^- manx
;div.chat-container
;div.chat-container-inner(urb-component "ChatPage");
;input(type "hidden", name "urb-metadata", urb-structure-type "stream-chat");
==

View File

@ -0,0 +1,6 @@
^- manx
;div
;div(urb-component "WelcomePage");
;input(type "hidden", name "urb-metadata", urb-structure-type "welcome");
==

View File

@ -59,14 +59,10 @@
++ prep
|= old=(unit *)
^- (quip move _this)
~& %prep
?~ old
:_ this
[ost.bow [%connect / [~ /] %modulo]]~
:_ this(sta *state)
:~ [ost.bow %poke /bind-subapp [our.bow %modulo] %modulo-bind %subapp]
[ost.bow %poke /bind-subapp1 [our.bow %modulo] %modulo-bind %subapp1]
==
[~ this(sta *state)]
:: alerts us that we were bound. we need this because the vane calls back.
::
++ bound
@ -110,7 +106,7 @@
=/ name=@t
=+ back-path=(flop site.request-line)
?~ back-path
'World'
!!
i.back-path
::
?: =(name 'session')

View File

@ -1,75 +0,0 @@
/+ *server
/= index
/^ octs
/; as-octs:mimes:html
/: /===/app/subapp/index /html/
/= script
/^ octs
/; as-octs:mimes:html
/: /===/app/subapp/script /js/
::
|%
:: +move: output effect
::
+$ move [bone card]
:: +card: output effect payload
::
+$ card
$% [%poke wire dock poke]
[%http-response =http-event:http]
==
+$ poke
$% [%modulo-bind app=term]
[%modulo-unbind app=term]
==
--
::
|_ [bol=bowl:gall sta=@t]
::
++ this .
::
++ poke-noun
|= asd=?(%bind %unbind)
^- (quip move _this)
:_ this
?: =(%bind asd)
[ost.bol %poke /subapp [our.bol %modulo] `poke`[%modulo-bind %subapp]]~
[ost.bol %poke /subapp [our.bol %modulo] `poke`[%modulo-unbind %subapp]]~
++ prep
|= old=(unit @t)
^- (quip move _this)
~& %prep
:- [ost.bol %poke /subapp [our.bol %modulo] [%modulo-bind %subapp]]~
?~ old
this
this(sta u.old)
::
++ poke-handle-http-request
%- (require-authorization ost.bol move this)
|= =inbound-request:http-server
^- (quip move _this)
=+ request-line=(parse-request-line url.request.inbound-request)
=/ name=@t
=+ back-path=(flop site.request-line)
?~ back-path
'World'
i.back-path
::
?: =(name 'script')
:_ this
:~ ^- move
:- ost.bol
:* %http-response
[%start [200 ['content-type' 'application/javascript']~] [~ script] %.y]
==
==
:_ this
:~ ^- move
:- ost.bol
:* %http-response
[%start [200 ['content-type' 'text/html']~] [~ index] %.y]
==
==
--

View File

@ -1,6 +0,0 @@
^- manx
;html
;body
;h1: Subapp
==
==

View File

@ -1,11 +0,0 @@
<!doctype html>
<html>
<head>
<script type="application/javascript" src="~/channel/channel.js"></script>
<script type="application/javascript" src="/~modulo/session.js"></script>
<script type="application/javascript" src="/~subapp/script.js"></script>
</head>
<body>
<p>Jimmy</p>
</body>
</html>

View File

@ -1 +0,0 @@
console.log("subapp");

View File

@ -1,75 +0,0 @@
/+ *server
/= index
/^ octs
/; as-octs:mimes:html
/: /===/app/subapp1/index /html/
/= script
/^ octs
/; as-octs:mimes:html
/: /===/app/subapp1/script /js/
::
|%
:: +move: output effect
::
+$ move [bone card]
:: +card: output effect payload
::
+$ card
$% [%poke wire dock poke]
[%http-response =http-event:http]
==
+$ poke
$% [%modulo-bind app=term]
[%modulo-unbind app=term]
==
--
::
|_ [bol=bowl:gall sta=@t]
::
++ this .
::
++ poke-noun
|= asd=?(%bind %unbind)
^- (quip move _this)
:_ this
?: =(%bind asd)
[ost.bol %poke /subapp1 [our.bol %modulo] `poke`[%modulo-bind %subapp1]]~
[ost.bol %poke /subapp1 [our.bol %modulo] `poke`[%modulo-unbind %subapp1]]~
++ prep
|= old=(unit @t)
^- (quip move _this)
~& %prep
:- [ost.bol %poke /subapp1 [our.bol %modulo] [%modulo-bind %subapp1]]~
?~ old
this
this(sta u.old)
::
++ poke-handle-http-request
%- (require-authorization ost.bol move this)
|= =inbound-request:http-server
^- (quip move _this)
=+ request-line=(parse-request-line url.request.inbound-request)
=/ name=@t
=+ back-path=(flop site.request-line)
?~ back-path
'World'
i.back-path
::
?: =(name 'script')
:_ this
:~ ^- move
:- ost.bol
:* %http-response
[%start [200 ['content-type' 'application/javascript']~] [~ script] %.y]
==
==
:_ this
:~ ^- move
:- ost.bol
:* %http-response
[%start [200 ['content-type' 'text/html']~] [~ index] %.y]
==
==
--

View File

@ -1,6 +0,0 @@
^- manx
;html
;body
;h1: Subapp1
==
==

View File

@ -1,11 +0,0 @@
<!doctype html>
<html>
<head>
<script type="application/javascript" src="~/channel/channel.js"></script>
<script type="application/javascript" src="/~modulo/session.js"></script>
<script type="application/javascript" src="/~subapp1/script.js"></script>
</head>
<body>
<p>Is Great</p>
</body>
</html>

View File

@ -1 +0,0 @@
console.log("subapp1");

View File

@ -26,4 +26,24 @@
"/~/login?redirect={(trip url.request.inbound-request)}"
[bone [%http-response %start [307 ['location' redirect]~] ~ %.y]]~
::
++ manx-to-octs
|= man=manx
^- octs
(as-octs:mimes:html (crip (en-xml:html man)))
::
++ html-response
|= oct-html=octs
^- http-event:http
[%start [200 ['content-type' 'text/html']~] [~ oct-html] %.y]
::
++ js-response
|= oct-js=octs
^- http-event:http
[%start [200 ['content-type' 'application/js']~] [~ oct-js] %.y]
::
++ css-response
|= oct-css=octs
^- http-event:http
[%start [200 ['content-type' 'text/css']~] [~ oct-css] %.y]
::
--