feat: add importing of existing blog

This commit is contained in:
morelazers 2023-04-18 10:59:10 +02:00
parent cbe958926d
commit a5b4d5af8d
3 changed files with 50 additions and 0 deletions

View File

@ -130,6 +130,35 @@
[%pass /info %arvo %c %info %blog %& soba-md]
[%pass /info %arvo %c %info %blog %& soba-css]
==
::
%import
:: One thing this does not do is actually publish the new html files
=/ all-files ~(tap of files.act)
|-
?: (test all-files ~) `this
%. (rear all-files)
|= [=path content=*]
%= ^$
all-files (snip all-files)
this
?+ (rear path) this
%md
=+ content=(of-wain:format ((list cord) content))
?: ?=(%published (snag 0 path))
=/ file-name (oust [0 2] (snip path))
=/ file (~(gut by files) file-name [html='' md='' theme=%default])
this(files (~(put by files) file-name file(md content)))
=/ draft-name (oust [0 1] (snip path))
this(drafts (~(put by drafts) [path=draft-name md=content]))
%css
=/ theme-name (@tas (rear (oust [0 1] (snip path))))
this(themes (~(put by themes) [theme-name css=(@t (@tas content))]))
%html
=/ file-name (oust [0 2] (snip path))
=/ file (~(gut by files) file-name [html='' md='' theme=%default])
this(files (~(put by files) file-name file(html (@t (@tas content)))))
==
==
::
%save-draft `this(drafts (~(put by drafts) [path md]:act))
%delete-draft `this(drafts (~(del by drafts) path.act))

20
gen/blog/import.hoon Normal file
View File

@ -0,0 +1,20 @@
:- %say
|= [[now=@da @ our=@p ^] *]
=/ =path /(scot %p our)/blog/(scot %da now)/import
:- %blog-action
:- %import
|-
=+ .^(=arch %cy path)
:: If there is no directory below this, read the file's contents
?: (test dir.arch ~)
=/ mark
?+ (rear path) !!
%md wain
%html @t
%css @t
==
=/ content .^(mark %cx path)
:- [~ content] :: mimic fil.arch (unit item)
(~(rut by dir.arch) |=([name=@ta ~] ^$(path (snoc path name))))
:- fil.arch :: ~ or [~ u=item]
(~(rut by dir.arch) |=([name=@ta ~] ^$(path (snoc path name))))

View File

@ -3,6 +3,7 @@
$% [%publish =path html=@t md=@t theme=@tas]
[%unpublish =path]
[%export ~]
[%import files=(axal *)]
[%save-draft =path md=@t]
[%delete-draft =path]
[%save-theme theme=@tas css=@t]