scripts/project.min
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
;Generates a new project page.
"" :ident
"" :title
"" :subtitle
"" :summary
false :github
"" :release
false :valid-id
(
(str) expect first :ident
ident "^[a-z0-9-]+$" match? :valid-regexp
(sys.pwd "contents") => "/" join sys.ls :filelist
filelist (fs.filename "(.+)\\..+$" search 1 get) map ident in? not :valid-file
valid-regexp valid-file and
) ^validate
(valid-id not) (
"ID" io.ask @ident
ident validate @valid-id
(valid-id not) ("ID must not be already used and it must contain only lowercase letters, numbers, or -" io.warn!) when
) while
"Title" io.ask @title
"Subtitle" io.ask @subtitle
"Summary" io.ask @summary
"Version" io.ask @release
"-----\nid: $1\ngithub: $1\nhome: /$1/\ntitle: \"$2\"\nsubtitle: \"$3\"\nsummary: \"$4\"\ncontent-type: project\nactive: true\nversion: $5\ndownload: \"https://github.com/h3rald/$1/releases/download/\"\n-----\n" (ident title subtitle summary release) =% :metadata
("Create project?" io.confirm)
(
(ident ".md") => "" join :fn
(sys.pwd "contents" fn) => "/" join :path
metadata path fs.write
) when
|