~darklands/teal

81e0e48c8a36a7b73d5dbd0523527a622e27903e — Ben O'Neill 2 years ago
First commit
11 files changed, 318 insertions(+), 0 deletions(-)

A LICENSE
A Makefile
A README.md
A config.mk
A example/index.md
A example/otherpage.md
A style.css.def
A teal
A teal.1
A teal.conf.5
A teal.conf.def
A  => LICENSE +21 -0
@@ 1,21 @@
MIT License

Copyright (c) 2019 Ben O'Neill <benjaminmoneill@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

A  => Makefile +41 -0
@@ 1,41 @@
.POSIX:

include config.mk

all: example

teal.conf:
	cp -f teal.conf.def teal.conf

style.css:
	cp -f style.css.def style.css

clean:
	rm -rf teal.conf style.css out teal-$(VERSION).tar.gz

dist:
	mkdir -p teal-$(VERSION)
	cp -rf teal teal.conf.def teal.1 teal.conf.5 style.css.def Makefile \
		config.mk LICENSE example README.md teal-$(VERSION)
	tar -cf teal-$(VERSION).tar teal-$(VERSION)
	gzip teal-$(VERSION).tar
	rm -rf teal-$(VERSION)

example: teal.conf style.css
	./teal

install:
	mkdir -p $(DESTDIR)/$(PREFIX)/bin
	cp -f teal $(DESTDIR)$(PREFIX)/bin/teal
	chmod 755 $(DESTDIR)$(PREFIX)/bin/teal
	mkdir -p $(DESTDIR)/$(PREFIX)/share/man/man1
	cp -f teal.1 $(DESTDIR)/$(PREFIX)/share/man/man1
	mkdir -p $(DESTDIR)/$(PREFIX)/share/man/man5
	cp -f teal.conf.5 $(DESTDIR)/$(PREFIX)/share/man/man5

uninstall:
	rm -f $(DESTDIR)/$(PREFIX)/bin/teal
	rm -f $(DESTDIR)/$(PREFIX)/share/man/man1/teal.1
	rm -f $(DESTDIR)/$(PREFIX)/share/man/man7/teal_conf.7

.PHONY: all clean dist example install uninstall

A  => README.md +13 -0
@@ 1,13 @@
# teal

a simple static website generator.

## Installation

1. Edit `config.mk` to your liking
1. Run `make install`

## Usage

Put a `style.css` file and a `teal.conf` file in the current working directory,
set the variables in the configuration file, then run `teal`.

A  => config.mk +4 -0
@@ 1,4 @@
VERSION = 0.1

# paths
PREFIX = /usr/local

A  => example/index.md +3 -0
@@ 1,3 @@
# Hello world!

This is my site.

A  => example/otherpage.md +3 -0
@@ 1,3 @@
# Another Page

This is a seperate page!

A  => style.css.def +105 -0
@@ 1,105 @@
/* based on the style.css from https://github.com/jroimartin/sw */

body {
	color: #000;
	font-family: sans-serif;
	font-size: 100%;
	margin: 0;
	padding: 0;
}

/* Header */
#header { 
	background-color: #dc322f;
	border: 0;
	position: fixed;
	top: 0px;
	height: 8%;
	width: 100%;
}
#header a {
	border: 0;
	color: #000;
	text-decoration: none;
}
#header h1 {
	font-size: 1.6em;
	font-weight: bold;
	margin: 0 0 0 0.5em;
	padding: 0.5em;
}
#header h3 {
	font-size: 0.6em;
	font-weight: normal;
	margin-left: 1em;
}

/* Side */
#side-bar {
	width: 100%;
	top: 8%;
	position: fixed;
	clear: both;
	border: 0;
	margin: 0;
	padding: 0;
	background-color: #268bd2;
}

#side-bar ul {
	margin: 0;
	padding: 0.3em;
	list-style-type: none;
	list-style-image: none;
	border: 0;
}

#side-bar li { display: inline; line-height: 1.6em; white-space: nowrap; }

#side-bar ul li a {
	margin: 0;
	padding: 0.1em 1ex 0.1em 1ex;
	color: #000;
	background-color: transparent;
	text-decoration: none;
	font-size: 1em;
	border: 0;
}

#side-bar ul li a:hover { color: #000; text-decoration: none; }

/* Main */
#main {
	max-width: 70em;
	padding: 8em 2em 10em 2em;
	color: #000;
}

#main a { color: #000; text-decoration: bold; }
#main a:hover { text-decoration: underline; }
#main h1, h2, h3, h4, h5 { color: #000; }
#main ul { list-style-type: square; }

/* Footer */
#footer {
	background-color: #859900;
	color: #000;
	padding: 2em;
	font-size: 91%;
	height: 2%;
	width: 100%;
	bottom: 0px;
	text-align: left;
	position: fixed;
}

#footer .left { text-align: left; float: left; clear: left; }
#footer a { color: #111; text-decoration: none; }
#footer a:hover { text-decoration: underline; }

abbr, acronym { border-bottom: 1px dotted #333; cursor: help; }
blockquote { border-left: 1px solid #333; font-style: italic; padding: 1em; }
hr { border-width: 0 0 0.1em 0; border-color: #666; }

code, pre { font-size: 1.1em }
pre { margin-left: 2em; }

A  => teal +87 -0
@@ 1,87 @@
#!/bin/sh

teal_compile() { \
	cat >> $2 << EOF
<body>
<div id="main">
EOF
	$MDC $1 >> $2
cat >> $2 << EOF
</div>
</body>
EOF

	echo "MDC $1 >> $2"
}

teal_head() { \
	name=$(echo $1 | sed 's/.html//' | awk -F"/" '{OFS="/"; print $NF}')
	cat > $1 << EOF
<head>
<title>$name - $TITLE</title>
<style>
$(cat style.css)
</style>
</head>
EOF
	echo "HTMLINFO $1"
}

teal_sidebar() { \
cat >> $1 << EOF
<div id="side-bar">
<ul>
EOF
	for f in $(find $SRC | grep .md); do
		cat >> $1 << EOF
<li><a href="$(echo $f | sed "s,$SRC/,," | sed 's/.md/.html/')">$(echo $f | sed "s,$SRC/,," | sed 's/.md//')</li>
EOF
	done
cat >> $1 << EOF
</ul>
</div>
EOF
}

teal_header() { \
	cat >> $1 << EOF
<div id="header">
<h1>$TITLE</h1>
</div>
EOF
}

teal_footer() { \
	cat >> $1 << EOF
<div id="footer">
<p>$FOOTER</p>
</div>
EOF
}

teal_loop() { \
	# copy all necessary files from source dir to target dir
	mkdir -p $TARGET
	cp -rf $SRC/* $TARGET

	# remove the source files
	for f in $(find $TARGET | grep .md); do
		rm -f $f
	done

	for f in $(find $SRC | grep .md); do
		out="$TARGET/$(echo $f | sed 's/.md/.html/' | sed "s,$SRC/,,")"
		teal_head $out
		teal_header $out
		teal_compile $f $out
		teal_footer $out
		teal_sidebar $out
	done
}


[ ! -f "teal.conf" ] && echo "no teal.conf found! must abort." && exit 1
[ ! -f "style.css" ] && echo "no style.css found! must abort." && exit 1

. ./teal.conf
teal_loop

A  => teal.1 +11 -0
@@ 1,11 @@
.TH DICTIONARY 1
.Os
.SH NAME
teal \- a simple static website generator
.SH SYNOPSIS
.B teal
.SH DESCRIPTION
teal uses the style.css and teal.conf files in the current working directory to
compile Markdown source to HTML with minimal formatting.
.SH SEE ALSO
teal.conf(5), smu(1), pandoc(1)

A  => teal.conf.5 +25 -0
@@ 1,25 @@
.TH TEAL.CONF 5 teal
.SH NAME
teal.conf \- static site configuration for teal
.SH DESCRIPTION
This is read as a shell script in the current working directory. It must have certain variables defined.
.SH VARIABLES
.TP
.B MDC
the Markdown compiler
.TP
.B SRC
the Markdown source directory
.TP
.B TARGET
the HTML output directory
.TP
.B TITLE
the website title
.TP
.B FOOTER
the website footer
.SH SEE ALSO
.BR teal (1),
.BR smu (1),
.BR pandoc (1)

A  => teal.conf.def +5 -0
@@ 1,5 @@
MDC=smu
SRC=example
TARGET=out
TITLE="My Site"
FOOTER="powered by <a href="https://github.com/swegbun/teal">teal</a>"