working out zod phases
This commit is contained in:
parent
7448411442
commit
f7affcaca7
114
README.md
114
README.md
@ -1,20 +1,31 @@
|
|||||||
# zodiac
|
# zodiac - a static site generator
|
||||||
|
|
||||||
|
ZODIAC is a static website generator powered by sh and awk. The core features of zodiac are:
|
||||||
|
|
||||||
|
* utliization of existing tools (i.e. awk, sh, find, etc.)
|
||||||
|
* built-in support for markdown
|
||||||
|
* a simple, easy to use templating system
|
||||||
|
* supports custom helpers written in awk
|
||||||
|
* multiple layouts
|
||||||
|
* partials
|
||||||
|
* configuration, meta, helpers, etc. can be added as you need them
|
||||||
|
* support any markup format via external tools
|
||||||
|
|
||||||
## SYNOPSIS
|
## SYNOPSIS
|
||||||
|
|
||||||
ZODIAC is a static website generator powered by sh and awk.
|
zod projectdir targetdir
|
||||||
|
|
||||||
## INSTALL
|
## INSTALL
|
||||||
|
|
||||||
git clone git://github.com/nuex/zodiac.git
|
git clone git://github.com/nuex/zodiac.git
|
||||||
|
|
||||||
Edit the config.mk file to customize the install paths
|
Edit the config.mk file to customize the install paths. `/usr/local` is the default install prefix.
|
||||||
|
|
||||||
sudo make install
|
Run the following (as root if necessary):
|
||||||
|
|
||||||
## USAGE
|
make install
|
||||||
|
|
||||||
zod projectdir targetdir
|
## DESCRIPTION
|
||||||
|
|
||||||
A typical Zodiac project will look something like this:
|
A typical Zodiac project will look something like this:
|
||||||
|
|
||||||
@ -33,6 +44,17 @@ A typical Zodiac project will look something like this:
|
|||||||
stylesheets/
|
stylesheets/
|
||||||
style.css
|
style.css
|
||||||
|
|
||||||
|
And it's output could look like this:
|
||||||
|
|
||||||
|
site/
|
||||||
|
index.html
|
||||||
|
projects/
|
||||||
|
project-1.html
|
||||||
|
project-2.html
|
||||||
|
cv.html
|
||||||
|
stylesheets/
|
||||||
|
style.css
|
||||||
|
|
||||||
### Meta
|
### Meta
|
||||||
|
|
||||||
`.meta` files contain a key / value pair per line. A key and its value must be separated by a ": ". A metafile looks like this:
|
`.meta` files contain a key / value pair per line. A key and its value must be separated by a ": ". A metafile looks like this:
|
||||||
@ -90,25 +112,83 @@ The `helpers.awk` file is an awk script that can make custom data available to y
|
|||||||
|
|
||||||
# your custom functions
|
# your custom functions
|
||||||
function page_title( title) {
|
function page_title( title) {
|
||||||
if (data["title"]) {
|
if ("title" in data) {
|
||||||
title = data["title"] " - "
|
return data["title"] "-" data["site_title"]
|
||||||
|
} else {
|
||||||
|
return data["site_title"]
|
||||||
}
|
}
|
||||||
title = title data["site_title"]
|
|
||||||
return title
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Just be sure to set the data array in the load_helpers() function at the top of the script to make your custom data available to the template.
|
Just be sure to set the data array in the `load_helpers()` function at the top of the script to make your custom data available to the template.
|
||||||
|
|
||||||
## FUTURE
|
### Config
|
||||||
|
|
||||||
- multiple filters support
|
For more control over the parsing and conversion process, a `.zod/config` file can be created within your project directory. Here is a sample config:
|
||||||
- multiple layout support
|
|
||||||
- mustache support
|
[parse]
|
||||||
- partials/snippets
|
htm
|
||||||
|
html
|
||||||
|
|
||||||
|
[parse_convert]
|
||||||
|
md smu
|
||||||
|
txt asciidoc -s -
|
||||||
|
|
||||||
|
[convert]
|
||||||
|
coffee coffee -s > {}.js
|
||||||
|
|
||||||
|
[ignore]
|
||||||
|
Makefile
|
||||||
|
|
||||||
|
Here we're only parsing (not converting to a different format) files matching `*.htm` and `*.html`.
|
||||||
|
|
||||||
|
Files matching `*.md` are going to be parsed and converted using the `smu` markdown parsing program.
|
||||||
|
|
||||||
|
Files matching `*.txt` are going to be parsed and converted using `asciidoc`.
|
||||||
|
|
||||||
|
Files matching `*.coffee` are going to be converted to JavaScript before being copied into the target directory. The `{}` notation will be expanded to the path and filename of the coffeescript file, but without the `.coffee` extension.
|
||||||
|
|
||||||
|
Files matching `Makefile` will be ignored and not copied.
|
||||||
|
|
||||||
|
Conversion programs must accept a UNIX-style pipe and send converted data to stdout.
|
||||||
|
|
||||||
|
### Per-page Templates and Partials
|
||||||
|
|
||||||
|
Multiple templates and partials are also supported.
|
||||||
|
|
||||||
|
For example; a `blog.md` page:
|
||||||
|
|
||||||
|
title: my blog
|
||||||
|
layout: blog
|
||||||
|
|
||||||
|
A `sidebar.partial`:
|
||||||
|
|
||||||
|
<div id="sidebar">
|
||||||
|
<ul>
|
||||||
|
<li><a href="/blog/some-article.html">Some Article</a></li>
|
||||||
|
<li><a href="/blog/another-one.html">Another One</a></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
And `blog.layout`:
|
||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Blog Page</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="main">
|
||||||
|
{{{yield}}}
|
||||||
|
</div>
|
||||||
|
{{>sidebar}}
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
||||||
|
`{{>sidebar}}` will be replaced with the parsed contents of `sidebar.partial`.
|
||||||
|
|
||||||
## CREDITS
|
## CREDITS
|
||||||
|
|
||||||
zsw: for the introduction to parameter expansion and other shell scripting techniques
|
* zsw: for the introduction to parameter expansion and other shell scripting techniques
|
||||||
|
|
||||||
## LICENSE
|
## LICENSE
|
||||||
|
|
||||||
|
@ -1,59 +1,32 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
# render a zodiac page
|
# render a zodiac page
|
||||||
|
# zod_render zodlibdir projdir targetdir md_builtin [files]
|
||||||
|
|
||||||
zod_lib="$1"
|
zod_lib="$1"
|
||||||
proj="$2"
|
proj="$2"
|
||||||
target="$3"
|
target="$3"
|
||||||
f="$4"
|
md_builtin="$4"
|
||||||
|
f="$5"
|
||||||
|
|
||||||
md_builtin="awk -f $zod_lib/markdown.awk"
|
# source zod sh functions
|
||||||
|
. $zod_lib/zod_functions
|
||||||
[ -f "$proj/helpers.awk" ] && helper_opts="$proj/helpers.awk"
|
|
||||||
[ -f "$proj/filters.config" ] && filter_opts="$proj/filters.config"
|
|
||||||
[ -f "$proj/global.meta" ] && global_meta_opts="$proj/global.meta"
|
|
||||||
[ -f "$proj/main.layout" ] && layout_opts="$proj/main.layout"
|
|
||||||
|
|
||||||
# Find the target directory if one must be created
|
|
||||||
subdir=${f%/*}
|
|
||||||
subdir=${subdir#$proj}
|
|
||||||
if [ "$subdir" ]; then
|
|
||||||
destination="$target$subdir"
|
|
||||||
mkdir -p "$destination"
|
|
||||||
else
|
|
||||||
# There is no directory to create in target,
|
|
||||||
# i.e. file is in the root of the project
|
|
||||||
destination="$target"
|
|
||||||
fi
|
|
||||||
|
|
||||||
ext=${f##*.}
|
ext=${f##*.}
|
||||||
|
meta=${f%.$ext}.meta
|
||||||
|
|
||||||
# Add filter support provided by the filters.config file
|
set -- -f "$zod_lib/render.awk"
|
||||||
[ "$filter_opts" ] && supported="$supported $(zod_supported_extensions "$zod_lib" "$filter_opts")"
|
[ -f "$proj/helpers.awk" ] && set -- "$@" -f "$proj/helpers.awk"
|
||||||
|
set -- "$@" -v markdown_filter_cmd="$md_builtin"
|
||||||
|
[ -f "$proj/global.meta" ] && set -- "$@" $proj/global.meta
|
||||||
|
[ -f "$meta" ] && set -- "$@" $meta
|
||||||
|
set -- "$@" "$f"
|
||||||
|
|
||||||
for supported_ext in "$supported"; do
|
find "$proj" -type f -name "*.partial" -o -name "*.layout"
|
||||||
[ $ext == "$supported_ext" ] && { is_supported=true; break }
|
while read -r part; do
|
||||||
|
set -- "$@" "$part"
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ "$is_supported" ]; then
|
page=${f##*/}
|
||||||
|
page=${page%.$ext}.html
|
||||||
meta=${f%.$ext}.meta
|
__zod_destination "$proj" "$target" "$f"
|
||||||
[ -f "$meta" ] && page_meta_opts="$meta"
|
awk "$@" > "$destination/$page"
|
||||||
|
|
||||||
set -- -f "$zod_lib/render.awk"
|
|
||||||
[ "$helper_opts" ] && set -- "$@" -f "$helper_opts"
|
|
||||||
set -- "$@" -v markdown_filter_cmd="$md_builtin" \
|
|
||||||
"$filter_opts" \
|
|
||||||
"$global_meta_opts" \
|
|
||||||
"$page_meta_opts" \
|
|
||||||
"$f" \
|
|
||||||
"$layout_opts"
|
|
||||||
|
|
||||||
page=${f##*/}
|
|
||||||
page=${page%.$ext}.html
|
|
||||||
|
|
||||||
awk "$@" > "$destination/$page"
|
|
||||||
|
|
||||||
else
|
|
||||||
cp "$f" "$destination" # Copying a non-template file
|
|
||||||
fi
|
|
||||||
|
0
bin/zod_supported_extensions
Normal file → Executable file
0
bin/zod_supported_extensions
Normal file → Executable file
@ -1,2 +1,3 @@
|
|||||||
PREFIX = /usr/local
|
PREFIX = /usr/local
|
||||||
AWKLIB = ${PREFIX}/lib/zodiac
|
#AWKLIB = ${PREFIX}/lib/zodiac
|
||||||
|
AWKLIB = /home/nuex/_dev/zodiac/lib
|
||||||
|
@ -5,9 +5,9 @@ function load_helpers() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function page_title( title) {
|
function page_title( title) {
|
||||||
if (data["title"]) {
|
if ("title" in data) {
|
||||||
title = data["title"] " - "
|
return data["title"] " - " data["site_title"]
|
||||||
|
} else {
|
||||||
|
return data["site_title"]
|
||||||
}
|
}
|
||||||
title = title data["site_title"]
|
|
||||||
return title
|
|
||||||
}
|
}
|
||||||
|
@ -6,14 +6,10 @@
|
|||||||
<title>{{page_title}}</title>
|
<title>{{page_title}}</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<header>
|
{{>header}}
|
||||||
<h1><a href="/">{{site_title}}</a></h1>
|
|
||||||
</header>
|
|
||||||
<article>
|
<article>
|
||||||
{{{yield}}}
|
{{{yield}}}
|
||||||
</article>
|
</article>
|
||||||
<footer>
|
{{>footer}}
|
||||||
<p>powered by static files</p>
|
|
||||||
</footer>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
Loading…
Reference in New Issue
Block a user