mars

superminimal static website framework
git clone git://parazyd.org/mars.git
Log | Files | Refs | README | LICENSE

commit 3c639a245699fac69c99f9c16561152365d979f5
parent 5900dd1ac5628de2ddf2bc5ef1bbf1c5a94586f7
Author: parazyd <parazyd@dyne.org>
Date:   Thu, 23 Jun 2016 12:00:59 +0200

basic markdown support

Diffstat:
MREADME.md | 11++++++++---
Mmars.sh | 46+++++++++++++++++++++++-----------------------
Mwebtree | 4++++
3 files changed, 35 insertions(+), 26 deletions(-)

diff --git a/README.md b/README.md @@ -4,8 +4,9 @@ superminimal static website framework ## intro mars is imagined as a helper to generate static html pages out of your php -scripts. you are supposed to drop the files in this repository in the root of -the website where you manage your php scripts and use the provided makefile. +scripts or markdown pages. you are supposed to drop the files in this +repository in the root of the website where you manage your php/markdown and +use the provided makefile. for ease of use, the makefile provides an install target: @@ -13,12 +14,16 @@ for ease of use, the makefile provides an install target: ; DESTDIR=/path/to/your/webroot make install ``` +mars for markdown depends on `python-markdown`, and for php, well - `php`... + ## configuration edit the `webtree` file to reflect the directory tree of your website. the file is commented with an example. also configure your webhost and the path to your webroot so rsync can know where to go. -the `exclude` array is an array of (php) files you don't want to be processed. +the `pageformat` variable tells mars to either use php or markdown + +the `exclude` array is an array of (php/md) files you don't want to be processed. the `rsync-exclude` file contains the list of things for rsync to ignore. diff --git a/mars.sh b/mars.sh @@ -24,53 +24,53 @@ generate() { print "${fg[green]}(*) generating your static pages${reset_color}" for dir in $tree; do pushd $dir - - pages=($(ls *.php)) - + pages=($(ls *.$pageformat)) print "${fg[blue]} -- /$dir --${reset_color}" for page in $pages; do - if [[ -n "${exclude[(r)$page]}" ]]; then - skip-page - else - process-page - fi - done - - popd + [[ -n "${exclude[(r)$page]}" ]] && { skip-page; continue } || process-page + done && popd done } process-page() { name=${page[(ws:.:)1]} - php -f $page > $name.html \ - && print "[ ${fg[green]}OK${reset_color} ] $name.php -> $name.html" \ - || print "[${fg[red]}NOPE${reset_color}] $name.php -> $name.html " + + case $pageformat in + php) + php -f $page > $name.html \ + && print "[ ${fg[green]}OK${reset_color} ] $name.$pageformat -> $name.html" \ + || print "[${fg[red]}NOPE${reset_color}] $name.$pageformat -> $name.html" + ;; + + md) + python -m markdown $page > $name.html \ + && print "[ ${fg[green]}OK${reset_color} ] $name.$pageformat -> $name.html" \ + || print "[${fg[red]}NOPE${reset_color}] $name.$pageformat -> $name.html" + ;; + *) + print "${fg[red]}(*) error: $pageformat page format is not supported${reset_color}";; + esac } skip-page() { name=${page[(ws:.:)1]} - print "[${fg[yellow]}SKIP${reset_color}] $name.php -> $name.html" + print "[${fg[yellow]}SKIP${reset_color}] $name.$pageformat -> $name.html" } clean() { print "${fg[green]}(*) cleaning...${reset_color}" for dir in $tree; do pushd $dir - - pages=($(ls *.php)) - + pages=($(ls *.$pageformat)) print "${fg[blue]} -- /$dir --${reset_color}" for page in $pages; do [[ -n "${exclude[(r)$page]}" ]] || { name=${page[(ws:.:)1]} - printf "(*) " - rm -v $name.html + printf "(*) " && rm -v $name.html } - done - - popd + done && popd done } diff --git a/webtree b/webtree @@ -2,6 +2,10 @@ WEBHOST="foo.bar.org" WEBROOT="/var/www/public_html/" +# Set the format of your pages (php or markdown) +pageformat=php +# pageformat=md + # Here add the tree of your website, ex: # # tree=(