From ee12a7df5e9888f554a3427e45f95ff9eddd3095 Mon Sep 17 00:00:00 2001 From: Mike Gerwitz Date: Thu, 13 Mar 2014 00:15:31 -0400 Subject: [PATCH] Added news-fmt to replace existing system --- Makefile | 8 +----- tools/news-fmt | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+), 7 deletions(-) create mode 100755 tools/news-fmt diff --git a/Makefile b/Makefile index 2e4615c..22c81a1 100644 --- a/Makefile +++ b/Makefile @@ -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/\( "$(outdir)/news.html" diff --git a/tools/news-fmt b/tools/news-fmt new file mode 100755 index 0000000..5062e52 --- /dev/null +++ b/tools/news-fmt @@ -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 . +## + + +# formats for HTML output +function escprint( str ) +{ + # escapes + gsub( /&/, "\\&", str ) + gsub( //, "\\>", str ) + + # hyperlinks + print gensub( /(https?:\/\/.+)(>|\. )/, \ + "\\1\\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 "

" + + do { + escprint( $0 " " ) + } while ( getline && !/^ $/ ); + + # close subject line + printf "

" + + # the rest of the commit (that is, until we find a line with + # non-whitespace in column one) is the body + printf "
"
+  while ( getline && /^\W/ ) {
+    escprint( $0 )
+  }
+  printf "
" +} +