mirror of
https://github.com/tadad/blog.git
synced 2024-09-11 12:55:07 +03:00
commit
95eb09859b
172
app/blog.hoon
172
app/blog.hoon
@ -19,13 +19,13 @@
|
|||||||
drafts=(map path md=@t)
|
drafts=(map path md=@t)
|
||||||
themes=(map @tas css=@t)
|
themes=(map @tas css=@t)
|
||||||
==
|
==
|
||||||
|
+$ card $+(card card:agent:gall)
|
||||||
--
|
--
|
||||||
=| state-2
|
=| state-2
|
||||||
=* state -
|
=* state -
|
||||||
|_ =bowl:gall
|
|_ =bowl:gall
|
||||||
+* this .
|
+* this .
|
||||||
def ~(. (default-agent this %.n) bowl)
|
def ~(. (default-agent this %.n) bowl)
|
||||||
card card:agent:gall
|
|
||||||
++ on-init
|
++ on-init
|
||||||
^- (quip card _this)
|
^- (quip card _this)
|
||||||
`this(themes (~(gas by themes) [%default default-theme:blog-lib]~))
|
`this(themes (~(gas by themes) [%default default-theme:blog-lib]~))
|
||||||
@ -50,102 +50,92 @@
|
|||||||
(~(gas by *(map @tas @t)) [%default default-theme:blog-lib]~)
|
(~(gas by *(map @tas @t)) [%default default-theme:blog-lib]~)
|
||||||
==
|
==
|
||||||
::
|
::
|
||||||
%2 `this(state old)
|
%2
|
||||||
|
:_ this(state old)
|
||||||
|
%- zing
|
||||||
|
%+ turn ~(tap by files.old)
|
||||||
|
|= [=path html=@t md=@t theme=@tas]
|
||||||
|
:~ [%pass /bind %arvo %e %disconnect `path]
|
||||||
|
:* %pass /bind %arvo %e
|
||||||
|
%set-response (spat path)
|
||||||
|
~ %.n %payload
|
||||||
|
[200 ['Content-Type' 'text/html; charset=utf-8']~]
|
||||||
|
=/ tem=@t (~(gut by themes.old) theme '')
|
||||||
|
`(as-octs:mimes:^html (cat 3 html (add-style:blog-lib tem)))
|
||||||
|
==
|
||||||
|
:* %pass /bind %arvo %e
|
||||||
|
%set-response (cat 3 (spat path) '.md')
|
||||||
|
~ %.n %payload
|
||||||
|
[200 ['Content-Type' 'text/plain; charset=utf-8']~]
|
||||||
|
`(as-octs:mimes:^html md)
|
||||||
|
== ==
|
||||||
==
|
==
|
||||||
::
|
::
|
||||||
++ on-poke
|
++ on-poke
|
||||||
|= [=mark =vase]
|
|= [=mark =vase]
|
||||||
|^
|
^- (quip card _this)
|
||||||
?+ mark (on-poke:def mark vase)
|
~| "unexpected poke to {<dap.bowl>} with mark {<mark>}"
|
||||||
%handle-http-request
|
?> =(%blog-action mark)
|
||||||
(handle-http-request bowl !<([@tas inbound-request:eyre] vase))
|
=+ !<(act=action:blog vase)
|
||||||
::
|
?> =(src.bowl our.bowl)
|
||||||
%blog-action
|
?- -.act
|
||||||
(handle-action bowl !<(act=action:blog vase))
|
%publish
|
||||||
==
|
:_ this(files (~(put by files) [path html md theme]:act))
|
||||||
::
|
:~ :* %pass /bind %arvo %e
|
||||||
++ handle-http-request
|
%set-response (cat 3 (spat path.act) '.md')
|
||||||
|= [=bowl:gall rid=@tas req=inbound-request:eyre]
|
~ %.n %payload
|
||||||
^- (quip card _this)
|
[200 ['Content-Type' 'text/plain; charset=utf-8']~]
|
||||||
=/ url-len (met 3 url.request.req)
|
`(as-octs:mimes:html md.act)
|
||||||
?: =('.md' (cut 3 [(sub url-len 3) 3] url.request.req)) :: get MARKDOWN
|
|
||||||
=/ file (rash (end [3 (sub url-len 3)] url.request.req) stap)
|
|
||||||
:_ this
|
|
||||||
%^ http-response-cards:blog-lib
|
|
||||||
rid
|
|
||||||
[200 ['Content-Type' 'text/plain; charset=utf-8']~]
|
|
||||||
`(as-octs:mimes:html md:(~(got by files) file))
|
|
||||||
::
|
|
||||||
=? url.request.req =('.html' (cut 3 [(sub url-len 5) 5] url.request.req))
|
|
||||||
(end [3 (sub url-len 5)] url.request.req)
|
|
||||||
=/ file (~(got by files) (rash url.request.req stap))
|
|
||||||
=/ theme ?~(got=(~(get by themes) theme.file) '' u.got)
|
|
||||||
=/ post-with-style
|
|
||||||
(cat 3 html:file (add-style:blog-lib theme))
|
|
||||||
:_ this
|
|
||||||
%^ http-response-cards:blog-lib
|
|
||||||
rid
|
|
||||||
[200 ['Content-Type' 'text/html; charset=utf-8']~]
|
|
||||||
`(as-octs:mimes:html post-with-style)
|
|
||||||
::
|
|
||||||
++ handle-action
|
|
||||||
|= [=bowl:gall act=action:blog]
|
|
||||||
^- (quip card _this)
|
|
||||||
?> =(src.bowl our.bowl)
|
|
||||||
?- -.act
|
|
||||||
%publish
|
|
||||||
:_ this(files (~(put by files) [path html md theme]:act))
|
|
||||||
[%pass /bind %arvo %e %connect `path.act dap.bowl]~
|
|
||||||
::
|
|
||||||
%unpublish
|
|
||||||
:_ this(files (~(del by files) path.act))
|
|
||||||
[%pass /bind %arvo %e %disconnect `path.act]~
|
|
||||||
::
|
|
||||||
%export
|
|
||||||
=/ theme-export=(map path @tas)
|
|
||||||
(~(urn by files) |=([* * * theme=@tas] theme))
|
|
||||||
=/ soba-meta=soba:clay
|
|
||||||
^- soba:clay
|
|
||||||
[[%export %published %meta %noun ~] [%ins %noun !>(theme-export)]]~
|
|
||||||
=/ soba-html=soba:clay
|
|
||||||
%- zing
|
|
||||||
%+ turn ~(tap by files)
|
|
||||||
|= [=path html=@t md=@t theme=@tas]
|
|
||||||
^- soba:clay
|
|
||||||
=/ t ?~(got=(~(get by themes) theme) '' u.got)
|
|
||||||
:~ :^ [%export %published %html (snoc path %html)]
|
|
||||||
%ins %html
|
|
||||||
?: css.act
|
|
||||||
!>((cat 3 html (add-style:blog-lib t)))
|
|
||||||
!>(html)
|
|
||||||
::
|
|
||||||
:^ [%export %published %md (snoc path %md)]
|
|
||||||
%ins %md
|
|
||||||
!>([md ~])
|
|
||||||
==
|
==
|
||||||
=/ soba-md=soba:clay
|
|
||||||
%+ turn ~(tap by drafts)
|
:* %pass /bind %arvo %e
|
||||||
|= [=path md=@t]
|
%set-response (spat path.act)
|
||||||
^- (pair ^path miso:clay)
|
~ %.n %payload
|
||||||
[[%export %drafts (snoc path %md)] %ins %md !>([md ~])]
|
[200 ['Content-Type' 'text/html; charset=utf-8']~]
|
||||||
=/ soba-css=soba:clay
|
=/ tem=@t (~(gut by themes) theme.act '')
|
||||||
%+ turn ~(tap by themes)
|
`(as-octs:mimes:html (cat 3 html.act (add-style:blog-lib tem)))
|
||||||
|= [theme=@tas css=@t]
|
== ==
|
||||||
^- (pair path miso:clay)
|
::
|
||||||
[[%export %themes (snoc [theme]~ %css)] %ins %css !>(css)]
|
%unpublish
|
||||||
:_ this
|
:_ this(files (~(del by files) path.act))
|
||||||
:~ [%pass /info %arvo %c %info %blog %& soba-html]
|
:~ [%pass /bind %arvo %e %set-response `@t`(cat 3 (spat path.act) '.md') ~]
|
||||||
[%pass /info %arvo %c %info %blog %& soba-md]
|
[%pass /bind %arvo %e %set-response (spat path.act) ~]
|
||||||
[%pass /info %arvo %c %info %blog %& soba-css]
|
|
||||||
[%pass /info %arvo %c %info %blog %& soba-meta]
|
|
||||||
==
|
|
||||||
::
|
|
||||||
%save-draft `this(drafts (~(put by drafts) [path md]:act))
|
|
||||||
%delete-draft `this(drafts (~(del by drafts) path.act))
|
|
||||||
%save-theme `this(themes (~(put by themes) [theme css]:act))
|
|
||||||
%delete-theme `this(themes (~(del by themes) theme.act))
|
|
||||||
==
|
==
|
||||||
--
|
::
|
||||||
|
%export
|
||||||
|
=/ soba-html=soba:clay
|
||||||
|
%- zing
|
||||||
|
%+ turn ~(tap by files)
|
||||||
|
|= [=path html=@t md=@t theme=@tas]
|
||||||
|
^- soba:clay
|
||||||
|
=/ tem (~(gut by themes) theme '')
|
||||||
|
:~ :- [%export %published %html (snoc path %html)]
|
||||||
|
[%ins %html !>((cat 3 html (add-style:blog-lib tem)))]
|
||||||
|
::
|
||||||
|
:- [%export %published %md (snoc path %md)]
|
||||||
|
[%ins %md !>([md ~])]
|
||||||
|
==
|
||||||
|
=/ soba-md=soba:clay
|
||||||
|
%+ turn ~(tap by drafts)
|
||||||
|
|= [=path md=@t]
|
||||||
|
^- (pair ^path miso:clay)
|
||||||
|
[[%export %drafts (snoc path %md)] %ins %md !>([md ~])]
|
||||||
|
=/ soba-css=soba:clay
|
||||||
|
%+ turn ~(tap by themes)
|
||||||
|
|= [theme=@tas css=@t]
|
||||||
|
^- (pair path miso:clay)
|
||||||
|
[[%export %themes theme %css ~] %ins %css !>(css)]
|
||||||
|
:_ this
|
||||||
|
:~ [%pass /info %arvo %c %info %blog %& soba-html]
|
||||||
|
[%pass /info %arvo %c %info %blog %& soba-md]
|
||||||
|
[%pass /info %arvo %c %info %blog %& soba-css]
|
||||||
|
==
|
||||||
|
::
|
||||||
|
%save-draft `this(drafts (~(put by drafts) [path md]:act))
|
||||||
|
%delete-draft `this(drafts (~(del by drafts) path.act))
|
||||||
|
%save-theme `this(themes (~(put by themes) [theme css]:act))
|
||||||
|
%delete-theme `this(themes (~(del by themes) theme.act))
|
||||||
|
==
|
||||||
::
|
::
|
||||||
++ on-agent on-agent:def
|
++ on-agent on-agent:def
|
||||||
++ on-watch
|
++ on-watch
|
||||||
|
Loading…
Reference in New Issue
Block a user