72 lines
1.8 KiB
Awk
Executable File
72 lines
1.8 KiB
Awk
Executable File
#!/usr/bin/gawk -f
|
|
#
|
|
# Formats NEWS for display on the website
|
|
#
|
|
# Copyright (C) 2014 Free Software Foundation, Inc.
|
|
#
|
|
# 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( /&/, "\\&", str )
|
|
gsub( /</, "\\<", str )
|
|
gsub( />/, "\\>", str )
|
|
|
|
# hyperlinks
|
|
print gensub( /(https?:\/\/.+)(>|\. )/, \
|
|
"<a href=\"\\1\">\\1</a>\\2", str \
|
|
)
|
|
}
|
|
|
|
|
|
/^commit / { next }
|
|
|
|
# store author
|
|
match( $0, /^Author: *([^<]+)/, a ) { author = a[1]; next }
|
|
|
|
# store date
|
|
match( $0, /^Date: *[^ ]+ ([^ ]+ [^ ]+ [^ ]+)/, a ) { date = a[1]; 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 class=\"git-commit\">"
|
|
|
|
do {
|
|
escprint( $0 " " )
|
|
} while ( getline && !/^ $/ );
|
|
|
|
# close subject line
|
|
printf "</h3>"
|
|
|
|
# author
|
|
printf "<div class=\"git-commit-author\">%s</div>", author
|
|
# date
|
|
printf "<div class=\"git-commit-date\">%s</div>", date
|
|
|
|
# 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>"
|
|
}
|
|
|