all repos — h3rald @ 0d4130e9770d4670b461ad5372686516fde6c94c

The sources of https://h3rald.com

Added generators for articles and projects.
h3rald h3rald@h3rald.com
Sun, 15 Oct 2017 18:45:43 +0200
commit

0d4130e9770d4670b461ad5372686516fde6c94c

parent

04d3a8faaae6f5a7a6b38b78ce87c26e08eea676

2 files changed, 88 insertions(+), 0 deletions(-)

jump to
A scripts/article.min

@@ -0,0 +1,40 @@

+"" :ident +"" :title +"" :subtitle +timestamp :ts +false :valid-id + +( + (string) expect first :ident + ident "^[a-z0-9-]+$" match :valid-regexp + (. "contents" "articles") => "/" join ls =filelist + filelist (filename "(.+)\..+$" search 1 get) map ident in? not :valid-file + valid-regexp valid-file and +) :validate + + +(valid-id not) ( + "ID" ask @ident + ident validate @valid-id + (valid-id not) ("ID must not be already used and it must contain only lowercase letters, numbers, or -" warn) when +) while + +"Title" ask @title +"Subtitle" ask @subtitle + +"----- +id: $1 +title: \"$2\" +subtitle: \"$3\" +content-type: article +timestamp: $4 +----- +" (ident title subtitle ts) => % :metadata + +metadata puts +("Create article?" confirm) +( + (ident ".md") => "" join :fn + (. "contents" "articles" fn) => "/" join :path + metadata path fwrite +) when
A scripts/project.min

@@ -0,0 +1,48 @@

+"" :ident +"" :title +"" :subtitle +"" :summary +false :github +"" :release +false :valid-id + +( + (string) expect first :ident + ident "^[a-z0-9-]+$" match :valid-regexp + (. "contents") => "/" join ls =filelist + filelist (filename "(.+)\..+$" search 1 get) map ident in? not :valid-file + valid-regexp valid-file and +) :validate + + +(valid-id not) ( + "ID" ask @ident + ident validate @valid-id + (valid-id not) ("ID must not be already used and it must contain only lowercase letters, numbers, or -" warn) when +) while + +"Title" ask @title +"Subtitle" ask @subtitle +"Summary" ask @summary +"version" ask @release + +"----- +id: $1 +github: $1 +home: /$1/ +title: \"$2\" +subtitle: \"$3\" +content-type: project +active: true +version: $4 +download: \"https://github.com/h3rald/$1/releases/download/\" +----- +" (ident title subtitle release) => % :metadata + +metadata puts +("Create project?" confirm) +( + (ident ".md") => "" join :fn + (. "contents" fn) => "/" join :path + metadata path fwrite +) when