Merge branch 'master' into cache

This commit is contained in:
tadad 2023-05-16 12:48:49 -05:00 committed by GitHub
commit a03817b66d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 129 additions and 9 deletions

View File

@ -14,11 +14,26 @@
Install %blog with
```
|install ~hanrut-sillet-dachus-tiprel blog
|install ~hanrut-sillet-dachus-tiprel %blog
```
## Export
If you want to move your blog to another Urbit, run `:blog|export %.y`. If you want to serve your blog from a normal server, run `:blog|export %.n`. The file format for each of these cases is slightly different.
You can export your %blog with `:blog|export` in the dojo. This will create a folder inside your blog desk called `/export`.
To see it, ensure you have mounted the blog desk with `|mount %blog`, and it will appear in unix.
To see it, ensure you have mounted the blog desk with `|mount %blog`.
## Import
After an export (or if you have files from elsewhere), you can import files into %blog. First make sure they have the same structure as an export, it should look something like this in your desk:
```
/blog
/import
/published
/md
/html
/drafts
/themes
```
Then run `-blog!import` in the dojo.

View File

@ -147,7 +147,7 @@
++ on-peek
|= =path
^- (unit (unit cage))
?+ path (on-peek:def path)
?+ path ~& "unexpected scry into {<dap.bowl>} on path {<path>}" ~
::
[%x %md ^] ``blog+!>(+<:(~(got by files) t.t.path)) :: TODO bad practice
[%x %html ^] ``blog+!>(-:(~(got by files) t.t.path))

View File

@ -1,4 +1,5 @@
:- %say
|= *
:: css is whether to append the css to exported html in <style> tags
|= [[*] [css=? ~] ~]
:- %blog-action
[%export ~]
[%export css]

View File

@ -25,7 +25,7 @@
++ add-style
|= css=@t
^- @t
(cat 3 (cat 3 '<style>' css) '<style/>')
(cat 3 (cat 3 '<style>' css) '</style>')
::
++ http-response-cards
|= [id=@tas hed=response-header:http data=(unit octs)]

1
lib/strandio.hoon Symbolic link
View File

@ -0,0 +1 @@
../../base-dev/lib/strandio.hoon

View File

@ -1 +0,0 @@
../../arvo/mar/noun.hoon

22
mar/noun.hoon Normal file
View File

@ -0,0 +1,22 @@
::
:::: /hoon/noun/mar
::
/? 310
!:
|_ non=*
++ grab |%
++ noun *
++ mime |=([p=mite q=octs] (cue q.q))
--
++ grow |%
++ mime [/application/octet-stream (as-octs:mimes:html (jam non))]
--
++ grad
|%
++ form %noun
++ diff |=(* +<)
++ pact |=(* +<)
++ join |=([* *] *(unit *))
++ mash |=([[ship desk *] [ship desk *]] `*`~|(%noun-mash !!))
--
--

View File

@ -2,7 +2,7 @@
+$ action
$% [%publish =path html=@t md=@t theme=@tas]
[%unpublish =path]
[%export ~]
[%export css=?]
[%save-draft =path md=@t]
[%delete-draft =path]
[%save-theme theme=@tas css=@t]

82
ted/import.hoon Normal file
View File

@ -0,0 +1,82 @@
/- spider, blog
/+ *strandio
=, strand=strand:spider
=, strand-fail=strand-fail:libstrand:spider
^- thread:spider
|= arg=vase
=/ m (strand ,vase)
^- form:m
;< our=@p bind:m get-our
;< now=@da bind:m get-time
=/ files-path=path /(scot %p our)/blog/(scot %da now)/import
=/ files=(axal *)
|-
=+ .^(=arch %cy files-path)
?: (test dir.arch ~)
=/ mark
?+ (rear files-path) !!
%md wain
%html @t
%css @t
%noun noun
==
:- [~ .^(mark %cx files-path)]
(~(urn by dir.arch) |=([name=@ta ~] ^$(files-path (snoc files-path name))))
:- fil.arch
(~(urn by dir.arch) |=([name=@ta ~] ^$(files-path (snoc files-path name))))
::
=| $= imp
$: pub=(map path [html=@t md=@t theme=@tas])
dra=(map path md=@t)
thm=(map @tas css=@t)
==
=. imp
=/ all-files ~(tap of files)
|-
?~ all-files imp
%. i.all-files
|= [=path content=*]
%= ^$
all-files t.all-files
imp
?+ (rear path) imp
%md
=+ content=(of-wain:format ((list cord) content))
?: ?=(%published (snag 0 path))
=/ file-name (oust [0 2] (snip path))
=/ file (~(gut by pub.imp) file-name [html='' md='' theme=%default])
imp(pub (~(put by pub.imp) file-name file(md content)))
=/ draft-name (oust [0 1] (snip path))
=/ draft (~(gut by dra.imp) draft-name [md=''])
imp(dra (~(put by dra.imp) draft-name draft(md content)))
::
%css
=/ theme-name (@tas (rear (oust [0 1] (snip path))))
=/ theme (~(gut by thm.imp) theme-name [css=''])
imp(thm (~(put by thm.imp) theme-name theme(css (@t (@tas content)))))
::
%html
=/ file-name (oust [0 2] (snip path))
=/ file (~(gut by pub.imp) file-name [html='' md='' theme=%default])
imp(pub (~(put by pub.imp) file-name file(html (@t (@tas content)))))
==
==
=/ thm-map ;; (map path @tas)
.^(noun %cx /(scot %p our)/blog/(scot %da now)/import/published/meta/noun)
=/ act |=(=vase [%pass /poke %agent [our %blog] %poke %blog-action vase])
;< ~ bind:m
%- send-raw-cards
%- zing
:~ %+ turn ~(tap by pub.imp)
|= [=path html=@t md=@t theme=@tas]
(act !>([%publish path html md (~(gut by thm-map) path %default)]))
::
%+ turn ~(tap by dra.imp)
|= [=path md=@t]
(act !>([%save-draft path md]))
::
%+ turn ~(tap by thm.imp)
|= [theme=@tas css=@t]
(act !>([%save-theme theme css]))
==
(pure:m !>(~))