tsimplify - mars - superminimal static website framework
 (HTM) git clone git://parazyd.org/mars.git
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 72c9cea827f5c638979a21b0961c38c767931f9d
 (DIR) parent 41246bd55794ab5c1b3f2b4159b48d12a8b7e294
 (HTM) Author: parazyd <parazyd@dyne.org>
       Date:   Wed, 15 Feb 2017 00:15:50 +0100
       
       simplify
       
       Diffstat:
         M Makefile                            |      17 ++++++++++-------
         D example/logo.svg                    |       2 --
         D example/markdown/footer.html        |      11 -----------
         D example/markdown/header.html        |      13 -------------
         D example/markdown/index.md           |       5 -----
         D example/markdown/navigation.html    |      24 ------------------------
         D example/php/footer.php              |      11 -----------
         D example/php/header.php              |      14 --------------
         D example/php/index.php               |       6 ------
         D example/php/navigation.php          |      29 -----------------------------
         D example/style.css                   |     168 -------------------------------
         M mars                                |     170 +++++++++----------------------
         M webtree                             |      54 +++++++++----------------------
       
       13 files changed, 74 insertions(+), 450 deletions(-)
       ---
 (DIR) diff --git a/Makefile b/Makefile
       t@@ -1,15 +1,18 @@
       -DESTDIR = /var/www/html
       +PREFIX = /var/www/html
        
        all:
                @./mars generate
       -push:
       +
       +push: all
                @./mars push
       +
        clean:
       -        @./mars clean -f
       +        @./mars clean
       +
        install:
       -        cp -f Makefile      ${DESTDIR}/Makefile
       -        cp -f mars          ${DESTDIR}/mars
       -        cp -f rsync-exclude ${DESTDIR}/rsync-exclude
       -        cp -f webtree       ${DESTDIR}/webtree
       +        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
        
        .PHONY: all push clean install
 (DIR) diff --git a/example/logo.svg b/example/logo.svg
       t@@ -1 +0,0 @@
       -<?xml version="1.0" standalone="no"?><svg xmlns="http://www.w3.org/2000/svg" version="1.0" width="140" height="140"><g transform="matrix(20,0,0,20,10,10)"><path d="m0 0h6v6h-6zm0 2h6m-6 2h6m-4-4v6m2-6v6" style="fill:none;stroke:#000;stroke-width:.1;"/><circle cx="3" cy="1" r=".8"/><circle cx="5" cy="3" r=".8"/><circle cx="1" cy="5" r=".8"/><circle cx="3" cy="5" r=".8"/><circle cx="5" cy="5" r=".8"/></g></svg>
       -\ No newline at end of file
 (DIR) diff --git a/example/markdown/footer.html b/example/markdown/footer.html
       t@@ -1,11 +0,0 @@
       -        </div>
       -
       -        </div>
       -
       -        <div id="footer">
       -        <span class="right">
       -                copyleft 2016 parazyd, design heavily inspired by <a href="http://suckless.org">suckless.org</a> ♥
       -        </span>
       -        </div>
       -</body>
       -</html>
 (DIR) diff --git a/example/markdown/header.html b/example/markdown/header.html
       t@@ -1,13 +0,0 @@
       -<!DOCTYPE html>
       -<html>
       -<head>
       -        <meta charset="utf-8">
       -        <meta name="description" content="Who is parazyd, software developer, designer, crypto, bitcoin, linux administrator">
       -        <title>DEFAULT_TITLE</title>
       -        <link rel="stylesheet" type="text/css" href="../style.css">
       -</head>
       -        <div id="header">
       -                <a href="/"><img alt="logo" src="../logo.svg"></a>
       -                <a id="headerLink" href="/">parazyd.cf</a> <span id="headerSubtitle">something something</span>
       -        </div>
       -
 (DIR) diff --git a/example/markdown/index.md b/example/markdown/index.md
       t@@ -1,5 +0,0 @@
       -##+TITLE This is our title
       -
       -# And this is our page content
       -
       -:)
 (DIR) diff --git a/example/markdown/navigation.html b/example/markdown/navigation.html
       t@@ -1,24 +0,0 @@
       -        <div id="menu">
       -                <span class="left">
       -                <a class="thisSite" href="https://parazyd.cf">home</a>
       -                <a href="https://moo.parazyd.cf">moo</a>
       -                <a href="https://pub.parazyd.cf">pub</a>
       -                </span>
       -        </div>
       -
       -        <div id="content">
       -        <div id="nav">
       -
       -        <ul>
       -        <li><a  href="/">main</a></li>
       -        <li><a href="https://git.parazyd.cf">code/</a></li>
       -        <li><a href="/blog/">blog/</a></li>
       -        <li><a href="/blog/musings/">&nbsp;&nbsp;&nbsp;&nbsp;musings/</a></li>
       -        <li><a href="/projects/">projects/</a></li>
       -        <li><a href="/contact.html">contact</a></li>
       -        <li><a href="https://www.dyne.org">../dyne.org</a></li>
       -        </ul>
       -
       -        </div>
       -
       -        <div id="main">
 (DIR) diff --git a/example/php/footer.php b/example/php/footer.php
       t@@ -1,11 +0,0 @@
       -        </div>
       -
       -        </div>
       -
       -        <div id="footer">
       -        <span class="right">
       -                copyleft 2016 parazyd, design heavily inspired by <a href="http://suckless.org">suckless.org</a> ♥
       -        </span>
       -        </div>
       -</body>
       -</html>
 (DIR) diff --git a/example/php/header.php b/example/php/header.php
       t@@ -1,14 +0,0 @@
       -<!DOCTYPE html>
       -<html>
       -<head>
       -        <meta charset="utf-8">
       -        <meta name="description" content="Who is parazyd, software developer, designer, crypto, bitcoin, linux administrator">
       -        <title><?php echo $title; ?> : parazyd.cf</title>
       -        <link rel="stylesheet" type="text/css" href="../style.css">
       -</head>
       -        <div id="header">
       -                <a href="/"><img alt="logo" src="../logo.svg"></a>
       -                <a id="headerLink" href="/">parazyd.cf</a> <span id="headerSubtitle">something something</span>
       -        </div>
       -
       -<?php include "navigation.php"; ?>
 (DIR) diff --git a/example/php/index.php b/example/php/index.php
       t@@ -1,6 +0,0 @@
       -<?php $title = "home"; include "header.php"; ?>
       -
       -<p> Welcome! This is an example php page that is generated into a static
       -html page when you run <code>make</code></p>
       -
       -<?php include "footer.php"; ?>
 (DIR) diff --git a/example/php/navigation.php b/example/php/navigation.php
       t@@ -1,29 +0,0 @@
       -        <div id="menu">
       -                <span class="left">
       -                <a class="thisSite" href="https://parazyd.cf">home</a>
       -                <a href="https://moo.parazyd.cf">moo</a>
       -                <a href="https://pub.parazyd.cf">pub</a>
       -                </span>
       -        </div>
       -
       -        <div id="content">
       -        <div id="nav">
       -
       -        <ul>
       -        <li><a <?php if ($title=="home")
       -        echo "class=\"thisPage\""; ?> href="/">main</a></li>
       -        <li><a href="https://git.parazyd.cf">code/</a></li>
       -        <li><a <?php if ($title=="blog")
       -        echo "class=\"thisPage\""; ?> href="/blog/">blog/</a></li>
       -        <li><a <?php if ($title=="random musings")
       -        echo "class=\"thisPage\""; ?> href="/blog/musings/">&nbsp;&nbsp;&nbsp;&nbsp;musings/</a></li>
       -        <li><a <?php if ($title=="projects")
       -        echo "class=\"thisPage\""; ?>  href="/projects/">projects/</a></li>
       -        <li><a <?php if ($title=="contact")
       -        echo "class=\"thisPage\""; ?>  href="/contact.html">contact</a></li>
       -        <li><a href="https://www.dyne.org">../dyne.org</a></li>
       -        </ul>
       -
       -        </div>
       -
       -        <div id="main">
 (DIR) diff --git a/example/style.css b/example/style.css
       t@@ -1,168 +0,0 @@
       -body {
       -        background-color: #eee;
       -        color: #222;
       -        font-family: sans-serif;
       -        -webkit-font-smoothing: antialiased;
       -        padding: 0;
       -        margin: 0;
       -}
       -
       -hr { margin: 30px 60px; }
       -
       -a, a:visited {
       -        color: #058;
       -        text-decoration: none;
       -        -webkit-transition: all 0.2s linear;
       -        -moz-transition: all 0.2s linear;
       -        -ms-transition: all 0.2s linear;
       -        -o-transition: all 0.2s linear;
       -        transition: all 0.2s linear;
       -}
       -
       -a:hover {
       -        background-color: #eee;
       -        text-decoration: none;
       -}
       -
       -#menu {
       -        clear: both;
       -        overflow: hidden;
       -        color: #069;
       -        background-color: #333;
       -        padding: 0.7ex;
       -        font-size: 94%;
       -        border-top: 1px solid #333;
       -        border-bottom: 1px solid #333;
       -}
       -
       -#menu a {
       -        padding: 0.5ex 1ex 0.5ex 1ex;
       -        color: #fff;
       -}
       -
       -#menu a:hover {
       -        background-color: #333;
       -        color: #17a;
       -}
       -
       -#menu a.thisSite {
       -        font-weight: bold;
       -}
       -
       -#header {
       -        clear: both;
       -        color: #666;
       -        font-size: 1.78em;
       -        padding: 0.7ex 0.7ex 0.7ex 0.7em;
       -}
       -
       -#header img {
       -        width: 30px;
       -}
       -
       -#headerLink {
       -        color: #666;
       -        margin-left: 5px;
       -}
       -
       -h1 {
       -        font-family: 'OfficinaBold', sans-serif;
       -        margin: 1em 1ex 0.5ex 0;
       -        font-size: 1.4em;
       -}
       -
       -h2 {
       -        font-family: 'OfficinaBold', sans-serif;
       -        margin: 1em 1ex 0.5ex 0;
       -        font-size: 1.3em;        
       -}
       -
       -h3 {
       -        font-family: 'OfficinaBold', sans-serif;
       -        margin: 1em 1ex 0.5ex 0;
       -        font-size: 1.0em;
       -}
       -
       -h4 {
       -        font-family: 'OfficinaBold', sans-serif;
       -        margin: 1em 1ex 0.5ex 0;
       -        font-size: 0.9em;
       -}
       -
       -#headerSubtitle {
       -        font-size: 0.75em;
       -        font-style: italic;
       -        margin-left: 1em;
       -}
       -
       -#content {
       -        clear: both;
       -        margin: 0;
       -        padding: 0;
       -        background-color: #fff;
       -        overflow: hidden;
       -}
       -
       -#nav {
       -        background-color: #fff;
       -        float: left;
       -        margin: 0 1px 0 0;
       -        padding: 1em 0;
       -        border-right: 1px dotted #ccc;
       -        width: 200px;
       -}
       -
       -#nav ul {
       -        margin: 0;
       -        padding: 0;
       -}
       -
       -#nav li {
       -        list-style: none;
       -        padding: 0;
       -        margin: 0;
       -}
       -
       -#nav li ul {
       -  padding-left: 0.6em !important;
       -}
       -
       -#nav li a {
       -        display: block;
       -        margin: 0;
       -        padding: 0.8ex 2em 0.8ex 1em;
       -}
       -
       -#nav li a.thisPage {
       -        color: #222; /*#333;*/
       -        font-weight: bold;
       -        /*font-style: italic;*/
       -}
       -
       -#main {
       -        margin: 0 0 0 200px;
       -        padding: 1.5em;
       -        max-width: 50em;
       -}
       -
       -#footer {
       -        clear: both;
       -        color: #666;
       -        border-top: 1px solid #ccc;
       -        font-size: 84%;
       -        padding: 1em;
       -        margin: 0 0 1.5em 0;
       -}
       -
       -.left {
       -        float: left;
       -        margin: 0;
       -        padding: 0;
       -}
       -
       -.right {
       -        float: right;
       -        margin: 0;
       -        padding: 0;
       -}
       -
 (DIR) diff --git a/mars b/mars
       t@@ -1,135 +1,61 @@
       -#!/usr/bin/env zsh
       -#
       -# Copyright (c) 2015-2016 parazyd
       -# mars is written and maintained by parazyd <parazyd@dyne.org>
       -#
       -#                      ┏┳┓┏━┓┏━┓┏━┓
       -# This file is part of ┃┃┃┣━┫┣┳┛┗━┓
       -#                      ╹ ╹╹ ╹╹┗╸┗━┛
       -#
       -# This source code is free software: you can redistribute it and/or modify
       -# it under the terms of the GNU General Public License as published by
       -# the Free Software Foundation, either version 3 of the License, or
       -# (at your option) any later version.
       -#
       -# This software is distributed in the hope that it will be useful,
       -# but WITHOUT ANY WARRANTY; without even the implied warranty of
       -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       -# GNU General Public License for more details.
       -#
       -# You should have received a copy of the GNU General Public License
       -# along with this source code. If not, see <http://www.gnu.org/licenses/>.
       +#!/bin/sh
       +# copyleft (c) parazyd 2016-2017
       +# see LICENSE file for license details
        
       -autoload colors; colors
       -setopt pushdsilent
       -source webtree
       -# {{{ helpers
       -err() { msgstr="$*" && print "${fg[red]}(*) error: $msgstr ${reset_color}"; return 1 }
       -inf() { msgstr="$*" && print "${fg[green]}(*) $msgstr ${reset_color}" }
       -wrn() { msgstr="$*" && print "${fg[yellow]}(*) warning: $msgstr ${reset_color}" }
       -msgokay() { printf "[ ${fg[green]}OK${reset_color} ]" }
       -msgnope() { printf "[${fg[red]}NOPE${reset_color}]" }
       -msgskip() { printf "[${fg[yellow]}SKIP${reset_color}]" }
       +. ./webtree
        
       -countdown() {
       -        watdo="$*"
       -        printf "\n===========================================================\n"
       -        printf "${fg[white]}  >  ${reset_color} $watdo in: ${fg[red]} 5 4 3 2 1... ${reset_color}(hit ^C to abort)" && sleep 1 && \
       -        printf "${fg[white]}  >> ${reset_color} $watdo in: ${fg[red]}   4 3 2 1... ${reset_color}(hit ^C to abort)" && sleep 1 && \
       -        printf "${fg[white]}  >>>${reset_color} $watdo in: ${fg[red]}     3 2 1..  ${reset_color}(hit ^C to abort)" && sleep 1 && \
       -        printf "${fg[white]}  >> ${reset_color} $watdo in: ${fg[red]}       2 1..  ${reset_color}(hit ^C to abort)" && sleep 1 && \
       -        printf "${fg[white]}  >  ${reset_color} $watdo in: ${fg[red]}         1.   ${reset_color}(hit ^C to abort)" && sleep 1 && \
       -        printf "${fg[green]}  >>>${reset_color} $watdo                                                            "
       -        printf "\n===========================================================\n\n"
       +die() {
       +        printf "error\n"
       +        exit 1
        }
        
       -trapctrlc() {
       -        rm -f $tmpage
       -        print "\n\n"; wrn "aborting..."; exit 2
       -}
       -trap "trapctrlc" 2
       -# }}}
       -
       -generate() {
       -        inf "generating your static html"
       +process() {
                for dir in $tree; do
       -                print "${fg[blue]}        -- /$dir --${reset_color}"
       -                pushd $dir && {
       -                        for page in *.$pageformat; do
       -                                [[ -e "$page" ]] || continue
       -                                [[ -n "${exclude[(r)$page]}" ]] && { skip-page; continue } || process-page
       -                        done && popd && continue
       -                } || { wrn "directory unusable" && popd }
       -        done
       -}
       +                printf "\t-- /$dir --\n"
       +                cd $dir || die
        
       -clean() {
       -        [[ "$1" == "-f" ]] || { countdown "cleaning" }
       -        for dir in $tree; do
       -                print "${fg[blue]}        -- /$dir --${reset_color}"
       -                pushd $dir && {
       -                        for page in *.$pageformat; do
       -                                [[ -e "$page" ]] || continue
       -                                [[ -n "${exclude[(r)$page]}" ]] || { name=${page[(ws:.:)1]} && \
       -                                printf "${fg[blue]}(*) ${reset_color}" && rm -v $name.html }
       -                        done && popd
       -                } || { wrn "directory unusable" && popd }
       -        done
       -}
       +                for page in *.md; do
       +                        if [ $(printf "%s" "$exclude" | grep "$page") ]; then
       +                                printf "[\033[1;33mSKIP\033[0m] %s\n" "$page"
       +                                continue
       +                        fi
        
       -process-page() {
       -        name=${page[(ws:.:)1]}
       -        case $pageformat in
       -                php)
       -                        php -f $page > $name.html \
       -                                && print "$(msgokay) $name.$pageformat                ->        $name.html" \
       -                                || print "$(msgnope) $name.$pageformat                ->        $name.html";;
       +                        name="$(printf "%s" "$page" | cut -d. -f1 -)"
       +                        rm -f "${name}.html"
        
       -                md|markdown)
       -                        rm -f $name.html
       -                        [[ -z $precontent ]] || {
       -                                for i in $precontent; do
       -                                        cat $i >> $name.html
       -                                done }
       +                        if [ "$1" = generate ]; then
       +                                [ -n "$precontent" ] && {
       +                                        for i in $precontent; do
       +                                                cat $i >> "${name}.html"
       +                                        done
       +                                }
        
       -                        local pagetitle=`grep '^##+TITLE ' $page | cut -c 10- -`
       -                        sed -i -e 's/<title>.*<\/title>/<title>'$pagetitle'<\/title>/' $name.html
       -                        tmpage=`mktemp` && cp $page $tmpage
       -                        sed -i -e 's/##+TITLE .*//' $tmpage
       +                                pagetitle="$(sed 1q $page) | $maintitle"
       +                                sed -e 's:<title>.*</title>:<title>'"$pagetitle"'</title>:' \
       +                                        -i ${name}.html
        
       -                        python -m markdown $tmpage >> $name.html \
       -                                && print "$(msgokay) $name.$pageformat                ->        $name.html" \
       -                                || print "$(msgnope) $name.$pageformat                ->        $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"
        
       -                        rm $tmpage
       -
       -                        [[ -z $postcontent ]] || {
       -                                for i in $postcontent; do
       -                                        cat $i >> $name.html
       -                                done }
       -
       -                        [[ `grep $name.html $name.html` ]] && {
       -                                sed -i -e 's/class="thisPage" //' $name.html
       -                                sed -i -e 's/href="\/'$name'.html"/class="thisPage" href="\/'$name'.html"/' $name.html
       -                        } || {
       -                        local dirstr=`basename $PWD`
       -                        [[ `grep '"/'$dirstr'/"' $name.html` ]] && {
       -                                sed -i -e 's/class="thisPage" //' $name.html
       -                                sed -i -e 's/href="\/'$dirstr'\/"/class="thisPage" href="\/'$dirstr'\/"/' $name.html
       -                        } || return 0 } ;;
       -                *)
       -                        err "$pageformat is unsupported";;
       -        esac
       -}
       -
       -skip-page() {
       -        [[ -z $VERBOSE ]] || {
       -                name=${page[(ws:.:)1]} && print "$(msgskip) $name.$pageformat                ->        $name.html" }
       -        return 0
       +                                [ -n "$postcontent" ] && {
       +                                        for i in $postcontent; do
       +                                                cat $i >> "${name}.html"
       +                                        done
       +                                }
       +                        fi
       +                done
       +                cd - >/dev/null
       +        done
        }
        
        push() {
       -        [[ "$1" = "-f" ]] || countdown "rsyncing"
       +        [ "$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' \
       t@@ -137,8 +63,8 @@ push() {
        }
        
        case "$1" in
       -        generate) generate;;
       -        clean) clean "$2";;
       -        push) push "$2";;
       -        *) print "usage: `basename $0` {generate|clean|push}";;
       +        generate) process generate ;;
       +        clean)    process ;;
       +        push)     push $2;;
       +        *)        printf "usage: %s {generate|clean|push [-f]}\n" "$(basename $0)" && exit 1 ;;
        esac
 (DIR) diff --git a/webtree b/webtree
       t@@ -2,50 +2,28 @@
        WEBHOST="foo.bar.org"
        WEBROOT="/var/www/public_html/"
        
       -# set the format of your pages (php or markdown)
       -#pageformat=php
       -pageformat=md
       +maintitle="my martian web"
        
       -# here add the tree of your website, ex:
       -#
       -# tree=(
       +#tree="
        #        .
        #
        #        blog
       -#        blog/musings
       -#        blog/201603
       -#
       -#        pub
       -#        pub/priv
       -#        pub/tmp
       -#        pub/tmp/screenshots
       -# )
       -# tree=(
       -#        example/php
       -# )
       +#        blog/2017
       +#        blog/2017/01
       +#"
        
       -tree=(
       -        example/markdown
       -)
       +tree="
       +        example
       +"
        
        # here add files you want excluded from being generated as .html
       -exclude=(
       -        header.php
       -        navigation.php
       -        footer.php
       -)
       -
       -# exclude=(
       -#        README.md
       -#        INSTALL.md
       -# )
       -
       -## markdown specific settings
       -[[ $pageformat == md ]] && {
       +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 before the conten
       +precontent="header.html navigation.html"
        
       -        # html that is put in order after the content
       -        postcontent=(footer.html)
       -}
       +# html that is put in order after the content
       +postcontent="footer.html"