mirror of
https://github.com/tadad/blog.git
synced 2024-08-17 08:40:20 +03:00
Merge pull request #7 from morelazers/feat/import
feat: add importing of existing blog
This commit is contained in:
commit
9734e688c7
21
README.md
21
README.md
@ -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.
|
||||
|
@ -102,6 +102,11 @@
|
||||
[%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)
|
||||
@ -110,7 +115,10 @@
|
||||
=/ t ?~(got=(~(get by themes) theme) '' u.got)
|
||||
:~ :^ [%export %published %html (snoc path %html)]
|
||||
%ins %html
|
||||
!>((cat 3 html (add-style:blog-lib t)))
|
||||
?: css.act
|
||||
!>((cat 3 html (add-style:blog-lib t)))
|
||||
!>(html)
|
||||
::
|
||||
:^ [%export %published %md (snoc path %md)]
|
||||
%ins %md
|
||||
!>([md ~])
|
||||
@ -129,9 +137,10 @@
|
||||
:~ [%pass /info %arvo %c %info %blog %& soba-html]
|
||||
[%pass /info %arvo %c %info %blog %& soba-md]
|
||||
[%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))
|
||||
%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))
|
||||
|
@ -1,4 +1,5 @@
|
||||
:- %say
|
||||
|= *
|
||||
:: css is whether to append the css to exported html in <style> tags
|
||||
|= [[*] [css=? ~] ~]
|
||||
:- %blog-action
|
||||
[%export ~]
|
||||
[%export css]
|
@ -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
1
lib/strandio.hoon
Symbolic link
@ -0,0 +1 @@
|
||||
../../base-dev/lib/strandio.hoon
|
@ -1 +0,0 @@
|
||||
../../arvo/mar/noun.hoon
|
22
mar/noun.hoon
Normal file
22
mar/noun.hoon
Normal 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 !!))
|
||||
--
|
||||
--
|
@ -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
82
ted/import.hoon
Normal 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 !>(~))
|
Loading…
Reference in New Issue
Block a user