mars

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

commit 2f7f5cc3448bfa473e7aa5585e55ca67a2792d2b
parent 7ad7477ffca692abbd654d231bb55149c2ff4bbc
Author: parazyd <parazyd@dyne.org>
Date:   Thu,  8 Feb 2018 00:44:59 +0100

Remove more bloat.

Diffstat:
MLICENSE | 2++
MMakefile | 34++++++++++++++++++++++------------
MREADME.md | 73++-----------------------------------------------------------------------
Aconfig.mk | 13+++++++++++++
Aexample.html.md | 6++++++
Afooter.html | 12++++++++++++
Aheader.html | 8++++++++
Dmars | 65-----------------------------------------------------------------
Anav.html | 10++++++++++
Mrsync-exclude | 16+++++++++-------
Astatic/style.css | 64++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Dwebtree | 29-----------------------------
12 files changed, 148 insertions(+), 184 deletions(-)

diff --git a/LICENSE b/LICENSE @@ -1,3 +1,5 @@ +Copyright (c) 2016-2018 Ivan J. <parazyd@dyne.org> + GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 diff --git a/Makefile b/Makefile @@ -1,18 +1,28 @@ -PREFIX = /var/www/html +# mars - superminimal static website framework +# See LICENSE file for copyright and license details +include config.mk -all: - @./mars generate +all: $(PAGES) $(TEXPAGES) + +%: %.md + @echo " * generating $@" + @cat header.html nav.html | \ + sed "s/{{{DEFAULT_TITLE}}}/$(shell sed 1q $^) | $(WEBTITLE)/" > $@ + @$(MARKDOWN) $^ >> $@ + @cat footer.html >> $@ -push: all - @./mars push + +%: %.tex + @echo " * generating $@" + @texi2pdf -c -q $^ -o $@ clean: - @./mars clean + rm -f $(PAGES) $(TEXPAGES) -install: - cp -f Makefile ${DESTDIR}${PREFIX}/Makefile - cp -f mars ${DESTDIR}${PREFIX}/mars - cp -f rsync-exclude ${DESTDIR}${PREFIX}/rsync-exclude - cp -f webtree ${DESTDIR}${PREFIX}/webtree +push: all + @echo " * pushing to $(WEBHOST):$(WEBROOT)" + @rsync -P -e "ssh" -avul --delete --stats \ + --exclude-from "rsync-exclude" \ + . $(WEBHOST):$(WEBROOT) -.PHONY: all push clean install +.PHONY: all clean push diff --git a/README.md b/README.md @@ -1,75 +1,6 @@ mars ----- -superminimal static website framework - -## intro -mars is imagined as a helper to generate static html pages out of your php -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 (just edit the Makefile -and specify the correct DESTDIR - the path to your web root): - -``` -; make install -``` - -mars is scripted in zsh, 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 `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. - -`precontent` and `postcontent` is (usually) html code in files that will be -concatenated in order - before and after our markdown content (respectively) - -the `rsync-exclude` file contains the list of things for rsync to ignore. - -sidenote: rsync goes over ssh by default, but is easily configurable +==== -## usage -after you've configured your `webtree`, you are ready to generate the website. -there are only two steps: - -``` -; make # will process your webtree and generate html -; make push # will rsync the goods to your webserver -``` - -an optional third step will delete the html files from the webtree - -``` -; make clean -``` - -## example/ explained -the `example` directory shows you ways to use mars with php and markdown - -### php -`index.php` is the only thing that is being generated as `index.html` - -mars will process it, and as it's in php, `footer`, `header` and `navigation` -are included from `index.php` and get included in the final page. this makes it -very easy to manage your content, as the only part you actually have to worry -about in `index.php` is the content (text). - -### markdown -`index.md` is the page that is being generated for our static `index.html` - -a custom parseable option is the page title which can be seen in the first line -of `index.md` - -the "syntax" to declare your page's title is +superminimal static website framework -``` -##+TITLE this is my page's title -``` -this line will not end up in your final html. diff --git a/config.mk b/config.mk @@ -0,0 +1,13 @@ +MARKDOWN = smu +#MARKDOWN = python -m markdown + +WEBTITLE = mars + +WEBHOST = mars.com +WEBROOT = public_html/mars + +MDS = $(shell find . -type f -name '*.html.md' -print) +PAGES = $(MDS:.md=) + +TEXS = $(shell find . -type f -name '*.pdf.tex' -print) +TEXPAGES = $(TEXS:.tex=) diff --git a/example.html.md b/example.html.md @@ -0,0 +1,6 @@ +mars example +============ + +This is an example of a mars page. + +This git repository is also an example of removing bloat. diff --git a/footer.html b/footer.html @@ -0,0 +1,12 @@ + + </div> + </div> + + <div id="footer"> + <hr> + <span class="right"> + powered by mars + </span> + </div> +</body> +</html> diff --git a/header.html b/header.html @@ -0,0 +1,8 @@ +<!DOCTYPE html> +<html lang="en"> +<head> + <meta charset="utf-8"> + <title>{{{DEFAULT_TITLE}}}</title> + <link rel="stylesheet" type="text/css" href="static/style.css"> +</head> +<body> diff --git a/mars b/mars @@ -1,65 +0,0 @@ -#!/bin/sh -# copyleft (c) parazyd 2016-2017 -# see LICENSE file for license details - -. ./webtree - -process() { - for dir in $tree; do - printf "\t-- /$dir --\n" - cd $dir || exit 1 - - for page in *.md; do - if [ $(printf "%s" "$exclude" | grep "$page") ]; then - printf "[\033[1;33mSKIP\033[0m] %s\n" "$page" - continue - fi - - name="$(printf "%s" "$page" | cut -d. -f1 -)" - rm -f "${name}.html" - - if [ "$1" = generate ]; then - [ -n "$precontent" ] && { - for i in $precontent; do - cat $i >> "${name}.html" - done - } - - pagetitle="$(sed 1q $page) | $maintitle" - sed -e 's:<title>.*</title>:<title>'"$pagetitle"'</title>:' \ - -i ${name}.html - - python -m markdown "$page" >> "${name}.html" \ - && printf "[ \033[1;32mOK\033[0m ] %s.md\t\t->\t%s.html\n" "$name" "$name" \ - || printf "[\033[1;31mNOPE\033[0m] %s.md\t\t->\t%s.html\n" "$name" "$name" - - [ -n "$postcontent" ] && { - for i in $postcontent; do - cat $i >> "${name}.html" - done - } - fi - done - cd - >/dev/null - done -} - -push() { - [ "$1" = -f ] || { - printf "(*) do you want to rsync?\n" - printf "(enter to accept, ^C to quit)" - read dummy - } - - rsync -P -e 'ssh' -avul --delete --stats \ - --size-only \ - --exclude-from 'rsync-exclude' \ - . $WEBHOST:$WEBROOT -} - -case "$1" in - generate) process generate ;; - clean) process ;; - push) push $2;; - *) printf "usage: %s {generate|clean|push [-f]}\n" "$(basename $0)" && exit 1 ;; -esac diff --git a/nav.html b/nav.html @@ -0,0 +1,10 @@ + <table> + <tr> + <td><a href="/">home</a></td> + <td><a href="http://parazyd.cf/git/mars/">mars</a></td> + </tr> + </table> + + <div id="content"> + + <div id="main"> diff --git a/rsync-exclude b/rsync-exclude @@ -1,10 +1,12 @@ -rsync-exclude -*.php .git/* -Makefile .gitignore -*.swp -mars.sh -webtree +rsync-exclude README.md -LICENSE +Makefile +config.mk +header.html +nav.html +footer.html +*.swp +*.php +*.js diff --git a/static/style.css b/static/style.css @@ -0,0 +1,64 @@ +body { + background-color: #f4f5e7; + margin: 0 15% 0 15%; + font-size: 12pt; + font-family: sans-serif, monospace; +} + +pre code { + font-family: monospace; + font-size: 95%; + line-height: 140%; + white-space: pre; + white-space: pre-wrap; + white-space: -moz-pre-wrap; + white-space: -o-pre-wrap; +} + +code { + background: #faf8f0; +} + +#content { + margin: 0 10% 0 10%; +} + +#content code { + display: block; + padding: 0.5em 1em; + border: 1px solid #bebab0; +} + +#footer { + text-align: right; + font-size: 7pt; +} + +#menu td { + margin: 0; + padding: 0; + overflow: hidden; + background-color: #393f4c; +} + +#menu td a { + display: block; + color: #eee; + text-align: center; + padding: 14px 16px; + text-decoration: none; +} + +#menu td a:hover { + background-color: #222; +} + +a, a:visited, a:active { + text-decoration: none; + color: #fa1027; +} + +a:hover { + text-decoration: underline; + color: #fa1027; +} diff --git a/webtree b/webtree @@ -1,29 +0,0 @@ -# here configure your webserver and webroot path for rsync -WEBHOST="foo.bar.org" -WEBROOT="/var/www/public_html/" - -maintitle="my martian web" - -#tree=" -# . -# -# blog -# blog/2017 -# blog/2017/01 -#" - -tree=" - example -" - -# here add files you want excluded from being generated as .html -exclude=" - README.md - INSTALL.md -" - -# html that is put in order before the conten -precontent="header.html navigation.html" - -# html that is put in order after the content -postcontent="footer.html"