tbasic markdown support - mars - superminimal static website framework
HTML git clone git://parazyd.org/mars.git
DIR Log
DIR Files
DIR Refs
DIR README
DIR LICENSE
---
DIR commit 3c639a245699fac69c99f9c16561152365d979f5
DIR parent 5900dd1ac5628de2ddf2bc5ef1bbf1c5a94586f7
HTML Author: parazyd <parazyd@dyne.org>
Date: Thu, 23 Jun 2016 12:00:59 +0200
basic markdown support
Diffstat:
M README.md | 11 ++++++++---
M mars.sh | 46 ++++++++++++++++----------------
M webtree | 4 ++++
3 files changed, 35 insertions(+), 26 deletions(-)
---
DIR diff --git a/README.md b/README.md
t@@ -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:
t@@ -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.
DIR diff --git a/mars.sh b/mars.sh
t@@ -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
}
DIR diff --git a/webtree b/webtree
t@@ -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=(