2013-05-19 15:56:17 -04:00
|
|
|
#!/bin/bash
|
2013-05-25 23:00:05 -04:00
|
|
|
#
|
|
|
|
# Index template
|
|
|
|
#
|
|
|
|
# Copyright (C) 2013 Mike Gerwitz
|
|
|
|
#
|
|
|
|
# This file is part of repo2html.
|
|
|
|
#
|
|
|
|
# This program 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 program 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 program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
# #
|
2013-05-25 22:14:42 -04:00
|
|
|
|
|
|
|
output-heading()
|
|
|
|
{
|
|
|
|
# 1 = dategroup
|
|
|
|
# we assign the heading to the id for the purpose of URL hashes
|
|
|
|
echo "<h3 id="$1" class="index">$1</h3>"
|
|
|
|
|
|
|
|
# every heading is followed by at least one index line
|
|
|
|
echo '<ul class="index">'
|
|
|
|
}
|
|
|
|
|
|
|
|
output-line()
|
|
|
|
{
|
|
|
|
# 1 = day, 2 = pagefile, 3 = fmtsubject
|
|
|
|
printf '<li><span class="day">(%s)</span> <a href="%s">%s</a></li>' "$@"
|
|
|
|
}
|
|
|
|
|
|
|
|
close-heading()
|
|
|
|
{
|
|
|
|
echo '</ul>'
|
|
|
|
}
|
|
|
|
|
2013-05-19 15:56:17 -04:00
|
|
|
cat <<EOH
|
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
<head>
|
2013-05-23 19:52:07 -04:00
|
|
|
<meta charset="utf-8" />
|
2013-05-19 15:56:17 -04:00
|
|
|
<link rel="alternate" title="RSS Feed"
|
|
|
|
href="rss.xml" type="application/rss+xml" />
|
2013-05-19 17:06:53 -04:00
|
|
|
$( [ -n "$html_external_css" ] \
|
|
|
|
&& printf '<link rel="stylesheet" type="text/css" href="%s" />' \
|
|
|
|
"$html_external_css"
|
|
|
|
)
|
2013-05-27 16:54:18 -04:00
|
|
|
<title>$title${subject:+"${html_tsep:-—}$subject"}</title>
|
2013-05-19 15:56:17 -04:00
|
|
|
</head>
|
2013-05-27 16:52:15 -04:00
|
|
|
<body class="${html_body_class:-index}">
|
2013-05-19 17:07:29 -04:00
|
|
|
<header>
|
2013-05-30 21:15:58 -04:00
|
|
|
<h1 class="title"><a href="${url_root:-/}">$title</a></h1>
|
2013-05-20 06:35:29 -04:00
|
|
|
<h2 class="desc">$desc</h2>
|
2013-05-19 17:07:29 -04:00
|
|
|
</header>
|
2013-05-25 11:10:14 -04:00
|
|
|
$html_pre_index
|
2013-05-19 15:56:17 -04:00
|
|
|
EOH
|
|
|
|
|
|
|
|
# generate index and populate statistical vars
|
2013-05-26 17:31:38 -04:00
|
|
|
type do-index &>/dev/null \
|
|
|
|
&& do-index output-heading output-line close-heading \
|
|
|
|
|| {
|
|
|
|
# no do-index is defined; default to accepting input from stdin
|
|
|
|
yearrange="$( date +%Y )"
|
|
|
|
lastts="$( date +%s )"
|
2013-05-27 16:54:54 -04:00
|
|
|
|
|
|
|
[ -n "$subject" ] && printf '<h3 class="subject">%s</h3>\n' "$subject"
|
2013-05-26 17:31:38 -04:00
|
|
|
cat
|
|
|
|
}
|
2013-05-19 15:56:17 -04:00
|
|
|
|
|
|
|
cat <<EOF
|
|
|
|
<footer>
|
2013-05-19 17:07:29 -04:00
|
|
|
<div id="rss"><a href="rss.xml">RSS</a></div>
|
|
|
|
<hr />
|
|
|
|
$( [ -n "$html_footer" ] \
|
|
|
|
&& printf '<div class="pre-copyright">%s</div>' "$html_footer"
|
|
|
|
)
|
2013-05-20 06:35:15 -04:00
|
|
|
$( [ -n "$html_index_footer" ] \
|
|
|
|
&& printf '<div class="pre-copyright">%s</div>' "$html_index_footer"
|
|
|
|
)
|
2013-05-19 15:56:17 -04:00
|
|
|
<div>Copyright © $yearrange $copyright</div>
|
|
|
|
<div>Last Updated: $( ./tsdate "$lastts" '%F %H:%M:%S' )</div>
|
2013-05-26 17:38:53 -04:00
|
|
|
$( [ -n "$commit-id" ] \
|
|
|
|
&& printf '<div class="commit-id">%s</div>' "$lasthash"
|
|
|
|
)
|
2013-05-19 15:56:17 -04:00
|
|
|
</footer>
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
EOF
|