More or less the same , but XD
This commit is contained in:
commit
1432dbfeb7
|
@ -0,0 +1,4 @@
|
|||
bin
|
||||
output/*.xml
|
||||
output/*.html
|
||||
output/urllist.txt
|
|
@ -0,0 +1,15 @@
|
|||
ISC License
|
||||
|
||||
Copyright (c) 2011-2016 Hiltjo Posthuma <hiltjo@codemadness.org>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
@ -0,0 +1,62 @@
|
|||
static site scripts
|
||||
===================
|
||||
|
||||
|
||||
Description
|
||||
-----
|
||||
|
||||
This is a fork of the [original project](http://git.codemadness.org/static-site-scripts/log.html) enabling XHTML 1.1 support made by Nova.
|
||||
|
||||
Default values were left blank on this variant.
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
sh generate.sh
|
||||
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
- Small and simple to understand (I hope).
|
||||
- Small amount of dependencies, requires a POSIX shell and basic Linux/Unix
|
||||
utilities[1][2].
|
||||
- Markdown supported by default[0], easily extendable to add your
|
||||
\<favorite markup language\>.
|
||||
- RSS and Atom output support.
|
||||
- Sitemap support (sitemap.xml and urllist.txt).
|
||||
|
||||
|
||||
Pages
|
||||
-----
|
||||
|
||||
Pages are defined as shellscripts containing the metadata, for example
|
||||
the file pages/html-example.sh.
|
||||
The content filename is the basename of the shellscript with the type of
|
||||
markup file appended to it (.html or .md), for example the file
|
||||
pages/html-example.html.
|
||||
|
||||
Markdown is supported. By default "smu"[0] is set as a Markdown processor,
|
||||
to change this set $markdown to your favorite Markdown-to-HTML converter in
|
||||
the file generate.sh.
|
||||
|
||||
|
||||
Dependencies
|
||||
------------
|
||||
|
||||
cat, cut, date, mkdir, printf, read, sed, sh (POSIX), test, tr
|
||||
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
ISC, see LICENSE file.
|
||||
|
||||
|
||||
References
|
||||
----------
|
||||
|
||||
[0] smu - markdown processor: https://github.com/Gottox/smu
|
||||
[1] sbase - http://git.suckless.org/sbase/
|
||||
ubase - http://git.suckless.org/ubase/
|
||||
[2] busybox - http://www.busybox.net/
|
|
@ -0,0 +1,301 @@
|
|||
#!/bin/sh
|
||||
# site title (part of ${pagetitle} probably).
|
||||
sitetitle=""
|
||||
# site language.
|
||||
sitelang="en"
|
||||
# main site domain.
|
||||
sitedomain=""
|
||||
# relative site url, can be "/blog" or something.
|
||||
siteurlrel=""
|
||||
# full site url.
|
||||
siteurlfull="${sitedomain}${siteurlrel}"
|
||||
# site keywords (global default), don't use too many.
|
||||
sitekeywords=""
|
||||
# site description (global default).
|
||||
sitedescription=""
|
||||
# site mail used for contact "mail link".
|
||||
sitemail=""
|
||||
# site author (global).
|
||||
siteauthor=""
|
||||
# site last updated (default use date when script was run).
|
||||
siteupdated=$(date "+%Y-%m-%dT%H:%M:%SZ")
|
||||
# site owner's projects url (can be github or anything)
|
||||
siteprojects=""
|
||||
# directories containing content and metadata.
|
||||
# NOTE: it's recommended to use absolute paths here, use "." for current directory.
|
||||
pagesdir="pages"
|
||||
# Output dir.
|
||||
outputdir="output"
|
||||
# Markdown processor: default: is "smu".
|
||||
markdown="smu"
|
||||
|
||||
#gnudate(fmt,date)
|
||||
gnudate() {
|
||||
date "+$1" -d "$2"
|
||||
}
|
||||
|
||||
#bsddate(fmt,date)
|
||||
bsddate() {
|
||||
date -j "+$1" "$(printf '%s' "$2" | tr -Cd '[:digit:]')"
|
||||
}
|
||||
|
||||
# added for compatibility with GNU and BSD date.
|
||||
alias formatdate='gnudate'
|
||||
if ! gnudate '%Y' '2015-01-01 00:00' 2>/dev/null; then
|
||||
alias formatdate='bsddate'
|
||||
fi
|
||||
|
||||
#makeid(title), format "Some title" to "some-title".
|
||||
makeid() {
|
||||
printf '%s\n' "$1" | tr '[:upper:]' '[:lower:]' | \
|
||||
sed -e 's@[^[:alnum:]]\{1,\}@-@g' -e 's@-*$@@g' -e 's@^-*@@g'
|
||||
}
|
||||
|
||||
# initial values for page variables, use some site vars as global defaults.
|
||||
pagereset() {
|
||||
id=""
|
||||
title=""
|
||||
url=""
|
||||
description="${sitedescription}"
|
||||
keywords="${sitekeywords}"
|
||||
author="${siteauthor}"
|
||||
content=""
|
||||
tags=""
|
||||
categories=""
|
||||
timecreated=""
|
||||
datecreated=""
|
||||
timeupdated=""
|
||||
dateupdated=""
|
||||
}
|
||||
|
||||
pageread() {
|
||||
meta="$1"
|
||||
. "${meta}" # source page metadata.
|
||||
basename=$(basename "${meta}" ".sh")
|
||||
datecreated=$(printf '%s' "${timecreated}" | cut -b 1-10)
|
||||
dateupdated=$(printf '%s' "${timeupdated}" | cut -b 1-10)
|
||||
|
||||
# if ${id} is empty and title is set: create id based on title.
|
||||
if test -z "${id}" && test -n "${title}"; then
|
||||
id=$(makeid "${title}")
|
||||
fi
|
||||
if test -z "${id}"; then
|
||||
printf 'Warning: $id or $title not set in "%s", skipping...\n' "${meta}" >&2
|
||||
return 1
|
||||
fi
|
||||
if test -z "${url}"; then
|
||||
url="${id}.html"
|
||||
fi
|
||||
outfile="${id}.html"
|
||||
urlfull="${siteurlfull}/${outfile}"
|
||||
filename=""
|
||||
# ${content} not set; try data from filetypes.
|
||||
if test -z "${content}"; then
|
||||
if test -f "${pagesdir}/${basename}.html"; then
|
||||
filename="${pagesdir}/${basename}.html"
|
||||
content=$(cat "${filename}")
|
||||
elif test -f "${pagesdir}/${basename}.md"; then
|
||||
filename="${pagesdir}/${basename}.md"
|
||||
content=$("${markdown}" "${filename}")
|
||||
fi
|
||||
fi
|
||||
created="<strong>Created on:</strong> ${datecreated}<br/>"
|
||||
if test "${datecreated}" != "${dateupdated}"; then
|
||||
created="${created}<strong>Last update on:</strong> ${dateupdated}<br/>"
|
||||
fi
|
||||
}
|
||||
|
||||
pageheader() {
|
||||
# prefix page title with site title, make sure its neatly formatted.
|
||||
if test -z "${title}"; then
|
||||
pagetitle="${sitetitle}"
|
||||
else
|
||||
pagetitle="${title} - ${sitetitle}"
|
||||
fi
|
||||
cat <<!__EOF__
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3.org/MarkUp/SCHEMA/xhtml11.xsd" dir="ltr" xml:lang="${sitelang}" lang="${sitelang}">
|
||||
<head>
|
||||
<title>${pagetitle}</title>
|
||||
<link rel="stylesheet" href="style.css" type="text/css" media="screen" />
|
||||
<link rel="stylesheet" href="print.css" type="text/css" media="print" />
|
||||
<link rel="alternate" type="application/rss+xml" title="${sitetitle} RSS Feed" href="rss.xml" />
|
||||
<link rel="alternate" type="application/atom+xml" title="${sitetitle} Atom Feed" href="atom.xml" />
|
||||
<link rel="icon" type="image/png" href="/favicon.png" />
|
||||
<meta http-equiv="Content-Type" content="application/xhtml+xml;charset=utf-8" />
|
||||
<meta http-equiv="Content-Language" content="${sitelang}" />
|
||||
<meta content="width=device-width" name="viewport" />
|
||||
<meta content="${keywords}" name="keywords" />
|
||||
<meta content="${description}" name="description" />
|
||||
<meta content="${author}" name="author" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="menuwrap">
|
||||
<div id="menu">
|
||||
<span id="links">
|
||||
<a href="index.html" title="Blog">Blog</a> |
|
||||
<a href="${siteprojects}" title="Some of my projects">Projects</a>
|
||||
</span>
|
||||
<span id="links-contact">
|
||||
<span class="hidden"> | </span>
|
||||
<a href="rss.xml" title="RSS feed">RSS</a> |
|
||||
<a href="atom.xml" title="Atom feed">Atom</a> |
|
||||
<a href="mailto:${sitemail}" title="Mail me">Mail</a>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<hr class="hidden" />
|
||||
<div id="mainwrap">
|
||||
<div id="main">
|
||||
!__EOF__
|
||||
}
|
||||
|
||||
pagecontent() {
|
||||
pageheader
|
||||
cat <<!__EOF__
|
||||
<h1><a href="">${title}</a></h1>
|
||||
<em>${created}</em>
|
||||
${content}
|
||||
!__EOF__
|
||||
pagefooter
|
||||
}
|
||||
|
||||
pagefooter() {
|
||||
cat <<!__EOF__
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
!__EOF__
|
||||
}
|
||||
|
||||
if ! test -d "${pagesdir}"; then
|
||||
printf 'Error: pages directory "%s" not found.\n' "${pagesdir}" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# process single page as argument (handy for testing a single page).
|
||||
if test -n "$1"; then
|
||||
pagereset
|
||||
pageread "$1" || exit 1
|
||||
pagecontent
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# try to make output dir.
|
||||
mkdir -p "${outputdir}"
|
||||
|
||||
# truncate urllist.txt (sitemap).
|
||||
> "${outputdir}/urllist.txt"
|
||||
# content for RSS, Atom sitemap and index, this is appended as a string.
|
||||
contentindex=""
|
||||
contentrss=""
|
||||
contentatom=""
|
||||
contentsitemap=""
|
||||
while read -r meta; do
|
||||
pagereset
|
||||
pageread "${meta}" || continue
|
||||
pagecontent > "${outputdir}/${outfile}"
|
||||
|
||||
# index / posts item: append.
|
||||
contentindex="${contentindex}$(cat <<!__EOF__
|
||||
<tr><td>${dateupdated}</td>
|
||||
<td><a href="${url}" title="${description}">${title}</a></td></tr>
|
||||
!__EOF__
|
||||
)"
|
||||
|
||||
# RSS item: append.
|
||||
# NOTE: GMT timezone is hard-coded because %z is not consistent,
|
||||
# change accordingly.
|
||||
contentrsspubdate=$(formatdate "%a, %d %b %Y %H:%M:%S GMT" "${timeupdated}")
|
||||
contentrss="${contentrss}$(
|
||||
cat <<!__EOF__
|
||||
<item>
|
||||
<title>${title}</title>
|
||||
<link>${urlfull}</link>
|
||||
<pubDate>${contentrsspubdate}</pubDate>
|
||||
<author>${author}</author>
|
||||
<guid isPermaLink="false">${urlfull}</guid>
|
||||
<description><![CDATA[${description}]]></description>
|
||||
</item>
|
||||
!__EOF__
|
||||
)"
|
||||
|
||||
# Atom item: append.
|
||||
contentatomupdated=$(formatdate "%Y-%m-%dT%H:%M:%SZ" "${timeupdated}")
|
||||
contentatompublished=$(formatdate "%Y-%m-%dT%H:%M:%SZ" "${timecreated}")
|
||||
contentatom="${contentatom}$(
|
||||
cat <<!__EOF__
|
||||
<entry>
|
||||
<title type="html"><![CDATA[${title}]]></title>
|
||||
<link rel="alternate" type="text/html" href="${urlfull}" />
|
||||
<id>${urlfull}</id>
|
||||
<updated>${contentatomupdated}</updated>
|
||||
<published>${contentatompublished}</published>
|
||||
<author>
|
||||
<name>${author}</name>
|
||||
<uri>${siteurlfull}</uri>
|
||||
</author>
|
||||
<summary type="html"><![CDATA[${description}]]></summary>
|
||||
</entry>
|
||||
!__EOF__
|
||||
)"
|
||||
|
||||
# sitemap: sitemap.xml, append item.
|
||||
contentsitemap="${contentsitemap}<url><loc>${urlfull}</loc></url>"
|
||||
|
||||
# sitemap: urllist.txt, append item, write directly to file, because
|
||||
# this is just a plain-text list.
|
||||
printf '%s\n' "${urlfull}" >> "${outputdir}/urllist.txt"
|
||||
done <<!FILELIST
|
||||
$(find "${pagesdir}" -type f -name "*.sh" | sort -rn)
|
||||
!FILELIST
|
||||
# process pages (reverse numeric order).
|
||||
# NOTE: above heredoc is used to make sure content* variables are known
|
||||
# in the scope after the while loop (subshell / pipes prevents this in a
|
||||
# standard manner).
|
||||
|
||||
# index HTML page (index.html).
|
||||
pagereset
|
||||
title="Posts"
|
||||
(pageheader
|
||||
cat <<!__EOF__
|
||||
<h1>${title}</h1>
|
||||
<table>
|
||||
${contentindex}
|
||||
</table>
|
||||
!__EOF__
|
||||
pagefooter) > "${outputdir}/index.html"
|
||||
|
||||
# RSS feed (rss.xml).
|
||||
cat <<!__EOF__ > "${outputdir}/rss.xml"
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<rss version="2.0">
|
||||
<channel>
|
||||
<title>${sitetitle}</title>
|
||||
<link>${siteurlfull}</link>
|
||||
<description>${sitedescription}</description>
|
||||
<language>${sitelang}</language>
|
||||
${contentrss}
|
||||
</channel>
|
||||
</rss>
|
||||
!__EOF__
|
||||
|
||||
# Atom feed (atom.xml).
|
||||
cat <<!__EOF__ > "${outputdir}/atom.xml"
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="${sitelang}">
|
||||
<title type="text">${sitetitle}</title>
|
||||
<subtitle type="text">${sitedescription}</subtitle>
|
||||
<updated>${siteupdated}</updated>
|
||||
<link rel="alternate" type="text/html" href="${siteurlfull}" />
|
||||
<id>${siteurlfull}/atom.xml</id>
|
||||
<link rel="self" type="application/atom+xml" href="${siteurlfull}/atom.xml" />
|
||||
${contentatom}
|
||||
</feed>
|
||||
!__EOF__
|
||||
|
||||
# sitemap (sitemap.xml).
|
||||
cat <<!__EOF__ > "${outputdir}/sitemap.xml"
|
||||
<?xml version="1.0" encoding="UTF-8"?><urlset>${contentsitemap}</urlset>
|
||||
!__EOF__
|
|
@ -0,0 +1,22 @@
|
|||
table {
|
||||
border: 0;
|
||||
}
|
||||
h1, h1 a, h1 a:visited,
|
||||
h2, h2 a, h2 a:visited,
|
||||
h3, h3 a, h3 a:visited,
|
||||
h1 a:hover, h2 a:hover, h3 a:hover {
|
||||
color: inherit;
|
||||
text-decoration: none;
|
||||
}
|
||||
table tr td {
|
||||
padding: 2px 10px 2px 0px;
|
||||
}
|
||||
pre {
|
||||
border: 1px dashed #777;
|
||||
padding: 5px;
|
||||
overflow-x: auto;
|
||||
}
|
||||
#menuwrap,
|
||||
.hidden {
|
||||
display: none;
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
body {
|
||||
font-family: sans-serif, monospace;
|
||||
text-align: center;
|
||||
overflow-y: scroll;
|
||||
color: #333;
|
||||
background-color: #fff;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
table {
|
||||
border: 0;
|
||||
}
|
||||
hr {
|
||||
height: 1px;
|
||||
color: #ccc;
|
||||
background-color: #ccc;
|
||||
border: 0;
|
||||
}
|
||||
h1 {
|
||||
font-size: 140%;
|
||||
}
|
||||
h2 {
|
||||
font-size: 120%;
|
||||
}
|
||||
h3 {
|
||||
font-size: 100%;
|
||||
}
|
||||
h1, h1 a, h1 a:visited,
|
||||
h2, h2 a, h2 a:visited,
|
||||
h3, h3 a, h3 a:visited,
|
||||
h1 a:hover, h2 a:hover, h3 a:hover {
|
||||
color: inherit;
|
||||
text-decoration: none;
|
||||
}
|
||||
table tr td {
|
||||
padding: 2px 10px 2px 0px;
|
||||
}
|
||||
pre {
|
||||
border: 1px dashed #777;
|
||||
background-color: #eee;
|
||||
padding: 5px;
|
||||
overflow-x: auto;
|
||||
}
|
||||
#menuwrap {
|
||||
background-color: #eee;
|
||||
padding: 1ex;
|
||||
border-bottom: 1px solid #ccc;
|
||||
}
|
||||
#main {
|
||||
padding: 1ex;
|
||||
}
|
||||
#menu,
|
||||
#main {
|
||||
margin: 0px auto;
|
||||
text-align: left;
|
||||
max-width: 80ex;
|
||||
}
|
||||
#menu a {
|
||||
font-weight: bold;
|
||||
vertical-align: middle;
|
||||
}
|
||||
#links-contact {
|
||||
float: right;
|
||||
}
|
||||
.hidden {
|
||||
display: none;
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
<p>This is an example page :)</p>
|
|
@ -0,0 +1,13 @@
|
|||
#!/bin/sh
|
||||
title="HTML example"
|
||||
description="description here"
|
||||
timecreated="2013-01-01 00:00"
|
||||
timeupdated="2013-01-01 00:00"
|
||||
#id="html-example"
|
||||
#url="${id}.html"
|
||||
#tags="tags, comma, separated"
|
||||
#keywords="keywords, comma, separated"
|
||||
#categories="Category name"
|
||||
#timestamp="2013-01-01"
|
||||
#author="author"
|
||||
#content="custom stuff"
|
|
@ -0,0 +1,61 @@
|
|||
simple tests
|
||||
------------
|
||||
|
||||
first paragraph.
|
||||
testing surround: _emph_ then **strong** and `code`.
|
||||
|
||||
`\`escaped backticks\``.
|
||||
|
||||
`x = *y * 6;`
|
||||
|
||||
horizontal rule:
|
||||
|
||||
- - -
|
||||
|
||||
|
||||
blocks and entities
|
||||
-------------------
|
||||
|
||||
preformatted block:
|
||||
.'''' .'.'. | |
|
||||
'''. | ' | | |
|
||||
'''' ' ' ""
|
||||
|
||||
quoted text:
|
||||
> When in doubt,
|
||||
> use brute force.
|
||||
|
||||
list:
|
||||
* Make each program do one thing well.
|
||||
* Expect the output of every program to become the input to another,
|
||||
as yet unknown, program.
|
||||
* Design and build software, even operating systems, to be tried early,
|
||||
ideally within weeks.
|
||||
* Use tools in preference to unskilled help to lighten a programming task.
|
||||
|
||||
list in list:
|
||||
* a
|
||||
* b
|
||||
1. c
|
||||
2. d
|
||||
* e
|
||||
* f
|
||||
|
||||
entity: &, <, >
|
||||
|
||||
code:
|
||||
int powerof2(unsigned int n) {
|
||||
return !((n - 1) & n) && n > 0;
|
||||
}
|
||||
|
||||
links
|
||||
-----
|
||||
|
||||
[suckless](http://suckless.org)
|
||||
|
||||
inline html
|
||||
-----------
|
||||
|
||||
<center>
|
||||
ABC
|
||||
</center>
|
|
@ -0,0 +1,14 @@
|
|||
#!/bin/sh
|
||||
title="Markdown example"
|
||||
description="description here"
|
||||
timecreated="2013-01-01 00:00"
|
||||
timeupdated="2013-01-01 00:00"
|
||||
author="Bob"
|
||||
#id="markdown-example"
|
||||
#url="${id}.html"
|
||||
#tags="tags, comma, separated"
|
||||
#keywords="keywords, comma, separated"
|
||||
#categories="Category name"
|
||||
#timestamp="2013-01-02"
|
||||
#author="author"
|
||||
#content="custom stuff"
|
Loading…
Reference in New Issue