mirror of
https://github.com/worpet-bildet/blog.git
synced 2024-10-05 20:27:08 +03:00
initial
This commit is contained in:
commit
497675ba2e
119
app/blog.hoon
Normal file
119
app/blog.hoon
Normal file
@ -0,0 +1,119 @@
|
||||
/- blog
|
||||
/+ dbug, default-agent, blog-lib=blog
|
||||
::
|
||||
%- agent:dbug
|
||||
^- agent:gall
|
||||
=> |%
|
||||
+$ versioned-state $%(state-0)
|
||||
+$ state-0 a=@
|
||||
--
|
||||
=| state-0
|
||||
=* state -
|
||||
=<
|
||||
|_ bowl=bowl:gall
|
||||
+* this .
|
||||
def ~(. (default-agent this %.n) bowl)
|
||||
hc ~(. +> bowl)
|
||||
card card:agent:gall
|
||||
++ on-init
|
||||
:_ this
|
||||
:: TODO this should go through docket later...
|
||||
[%pass /bind %arvo %e %connect `/blog dap.bowl]~
|
||||
++ on-save on-save:def
|
||||
++ on-load on-load:def
|
||||
++ on-poke
|
||||
|= [=mark =vase]
|
||||
?+ mark (on-poke:def mark vase)
|
||||
%handle-http-request
|
||||
=+ !<([rid=@tas req=inbound-request:eyre] vase)
|
||||
:: if it's /edit then enforce authentication, otherwise just serve the blog
|
||||
:_ this
|
||||
%^ make-http-response:hc
|
||||
[/http-response/[rid]]~
|
||||
[200 ~]
|
||||
(as-octs:mimes:html '<h1>hello world</h1>')
|
||||
::
|
||||
%blog-action
|
||||
=+ !<(act=action:blog vase)
|
||||
?- -.act
|
||||
%blog-bind
|
||||
:_ this
|
||||
[%pass /bind %arvo %e %connect `path.act dap.bowl]~
|
||||
::
|
||||
%blog-unbind
|
||||
:_ this
|
||||
[%pass /bind %arvo %e %disconnect `path.act]~
|
||||
::
|
||||
%save-file
|
||||
~& > text.act
|
||||
~& > file.act
|
||||
:: /=blog=/blogs/...
|
||||
=* file
|
||||
%+ weld
|
||||
/(scot %p our.bowl)/blog/(scot %da now.bowl)/blogs
|
||||
file.act
|
||||
=* nor `nori:clay`[%& [file %ins %html !>(text.act)]~]
|
||||
[%pass / %arvo %c %info %blog nor]~^this
|
||||
::
|
||||
%delete-file
|
||||
=* nor `nori:clay`[%& [file.act %del ~]~]
|
||||
[%pass / %arvo %c %info %blog nor]~^this
|
||||
==
|
||||
==
|
||||
++ on-agent on-agent:def
|
||||
++ on-watch
|
||||
|= =path
|
||||
^- (quip card _this)
|
||||
?>(?=([%http-response *] path) `this)
|
||||
++ on-peek
|
||||
|= =path
|
||||
^- (unit (unit cage))
|
||||
?+ path ~
|
||||
::
|
||||
:: [%x %existing-bindings ~]
|
||||
:: =* pax /(scot %p our.bowl)/bindings/(scot %da now.bowl)
|
||||
:: :^ ~ ~ %bindings !>
|
||||
:: .^((list [binding:eyre duct action:eyre]) %e pax)
|
||||
::
|
||||
[%x %blog ^]
|
||||
:^ ~ ~ %html
|
||||
!> ^- cord
|
||||
%- of-wain:format
|
||||
.^ wain
|
||||
%cx
|
||||
%+ weld
|
||||
/(scot %p our.bowl)/blog/(scot %da now.bowl)/blog
|
||||
t.t.path
|
||||
==
|
||||
::
|
||||
==
|
||||
::
|
||||
++ on-arvo
|
||||
|= [=wire =sign-arvo]
|
||||
^- (quip card _this)
|
||||
?+ wire (on-arvo:def wire sign-arvo)
|
||||
[%bind ~]
|
||||
?> ?=(%eyre -.sign-arvo)
|
||||
?> ?=(%bound +<.sign-arvo)
|
||||
?- accepted.sign-arvo
|
||||
%| ~&(>>> "%blog: {<path.binding.sign-arvo>} failed bind" `this)
|
||||
%& ~&("%blog: {<path.binding.sign-arvo>} successful bind" `this)
|
||||
==
|
||||
==
|
||||
::
|
||||
++ on-leave on-leave:def
|
||||
++ on-fail on-fail:def
|
||||
--
|
||||
::
|
||||
|_ =bowl:gall
|
||||
++ make-http-response
|
||||
|= $: paths=(list path)
|
||||
header=response-header:http
|
||||
data=octs
|
||||
==
|
||||
^- (list card:agent:gall)
|
||||
:~ [%give %fact paths [%http-response-header !>(header)]]
|
||||
[%give %fact paths [%http-response-data !>(`data)]]
|
||||
[%give %kick paths ~]
|
||||
==
|
||||
--
|
11
lib/blog.hoon
Normal file
11
lib/blog.hoon
Normal file
@ -0,0 +1,11 @@
|
||||
|%
|
||||
++ template
|
||||
|= $: paths=(list path)
|
||||
header=response-header:http
|
||||
data=octs
|
||||
==
|
||||
:~ [%give %fact paths %http-resposne-header !>(header)]
|
||||
[%give %fact paths %http-response-data !>(`data)]
|
||||
[%give %kick paths ~]
|
||||
==
|
||||
--
|
25
mar/blog/action.hoon
Normal file
25
mar/blog/action.hoon
Normal file
@ -0,0 +1,25 @@
|
||||
/- blog
|
||||
::
|
||||
|_ =action:blog
|
||||
++ grab
|
||||
|%
|
||||
++ noun action:blog
|
||||
++ json
|
||||
|= jon=^json
|
||||
=, dejs:format
|
||||
^- action:pyro
|
||||
%- of
|
||||
:~ [%blog-bind pa]
|
||||
[%blog-unbind pa]
|
||||
[%save-file (ot ~[file+pa text+so])]
|
||||
[%delete-file pa]
|
||||
==
|
||||
--
|
||||
::
|
||||
++ grow
|
||||
|%
|
||||
++ noun action
|
||||
--
|
||||
::
|
||||
++ grad %noun
|
||||
--
|
8
sur/blog.hoon
Normal file
8
sur/blog.hoon
Normal file
@ -0,0 +1,8 @@
|
||||
|%
|
||||
+$ action
|
||||
$% [%blog-bind =path]
|
||||
[%blog-unbind =path]
|
||||
[%save-file file=path text=@t]
|
||||
[%delete-file file=path]
|
||||
==
|
||||
--
|
1
sys.kelvin
Normal file
1
sys.kelvin
Normal file
@ -0,0 +1 @@
|
||||
[%zuse 415]
|
Loading…
Reference in New Issue
Block a user