1
0
Fork 0

Added news-fmt to replace existing system

website
Mike Gerwitz 2014-03-13 00:15:31 -04:00
parent 886b1a4f10
commit ee12a7df5e
No known key found for this signature in database
GPG Key ID: F22BB8158EE30EAB
2 changed files with 67 additions and 7 deletions

View File

@ -64,13 +64,7 @@ $(outdir)/%.html: %.html $(header) $(footer) tools/page-parse | $(outdir)
# requires git-weblog from mikegerwitz's git-supp package
news:
@[ "$$( which git-weblog )" ] \
|| ( echo "Please add git-weblog to PATH" >&2 && false )
git fetch origin refs/notes/*:refs/notes/*
git log --log-size --format="%H%n%B" master \
| grep -A1 '^log size \([5-9][0-9]\{2,\}\|[0-9]\{4,\}\)$$' \
| grep -o '^[a-z0-9]\+$$' \
| xargs git weblog -Dn $$( git tag -l ) \
tools/news-fmt < NEWS \
| cat $(header) $(header_news) - $(footer) \
| sed 's/\(<body\)/\1 class="news"/' \
> "$(outdir)/news.html"

66
tools/news-fmt 100755
View File

@ -0,0 +1,66 @@
#!/usr/bin/gawk -f
#
# Formats NEWS for display on the website
#
# Copyright (C) 2014 Mike Gerwitz
#
# 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
##
# formats for HTML output
function escprint( str )
{
# escapes
gsub( /&/, "\\&amp;", str )
gsub( /</, "\\&lt;", str )
gsub( />/, "\\&gt;", str )
# hyperlinks
print gensub( /(https?:\/\/.+)(>|\. )/, \
"<a href=\"\\1\">\\1</a>\\2", str \
)
}
/^commit / { next }
# store author
match( $0, /^Author: *([^<]+)/, author ) { next }
# store date
match( $0, /^Date: *(.+)$/, date ) { next }
# commit messages are indented by four spaces, with the subject line
# occupying the first paragraph (that is---until an empty line)
/^ / {
# begin the subject line output
printf "<h3>"
do {
escprint( $0 " " )
} while ( getline && !/^ $/ );
# close subject line
printf "</h3>"
# the rest of the commit (that is, until we find a line with
# non-whitespace in column one) is the body
printf "<pre>"
while ( getline && /^\W/ ) {
escprint( $0 )
}
printf "</pre>"
}