# Best results with "git log -p --pretty=medium --date=rfc -C --find-hopies-harder"
BEGIN {
var_blog_title = "PyroPeters Blog";
var_blog_link = "http://keks.selfip.org/blog";
var_blog_description = "A very cool blog!!!1!111!!1";
var_blog_feed = var_blog_link "/feed.rss";
var_encoding = "UTF-8";
var_maxtitlelenght = 100;
var_debug = 0;
default_title = "-no title-";
default_link = var_blog_link;
default_description = "foo";
write_header();
}
END {
item_done();
write_footer();
}
// {
if (var_debug == 1) {
print "DEBUG:",$0;
}
}
function replace_xml(text) {
gsub("&", "\\&", text);
gsub("<", "\\<", text);
gsub(">", "\\>", text);
#gsub("", "\\&;", text);
return "" text "]]>"; #TODO
}
function write_header() {
print "";
print "";
print "";
print "" var_blog_title "";
print "" var_blog_link "";
print "" var_blog_description "";
if (var_blog_feed != "") {
print "";
}
}
function write_footer() {
print ""
}
function write_item () {
print "- ";
if (item_title != "") {
print "" item_title "";
} else {
print "" default_title "";
}
if (item_guid != "") {
print "" item_guid "";
}
if (item_link != "") {
print "" item_link "";
} else {
print "" default_link "";
}
if (item_pubdate != "") {
print "" item_pubdate "";
}
if (item_description != "") {
print "" replace_xml(item_description) "";
} else {
print "" default_description "";
}
print "
";
}
function item_done () {
if (item_description != "" && diff_destpath ~ "^/entrys/") {
item_link = var_blog_link diff_destpath;
write_item();
}
item_title = "";
item_guid = "";
item_link = "";
item_description = "";
item_pubdate = "";
diff_header = "";
diff_destpath = "";
#item_ = "";
}
/^commit/ {
if (NR != 1) {
item_done();
}
item_guid = $2;
diff_mode = 0;
}
/^Date/ {
item_pubdate = substr($0, 9);
}
/^ / {
if (item_title == "") {
item_title = substr($0, 5, var_maxtitlelenght);
}
}
/^diff/ {
diff_mode = 1;
}
/^[^+\-]/ {
if (diff_mode == 1) {
diff_header = item_diffheader "\n" $0;
}
}
/^+++/ {
if (diff_mode == 1) {
if (substr($0,6) ~ "^/entrys/") {
if (diff_destpath == "") {
diff_destpath = substr($0,6);
}
} else {
diff_mode = 0;
}
}
}
/^@@/ {
if (diff_mode == 1) {
diff_mode = 2;
}
}
/^[+\- ]/ {
if (diff_mode == 2) {
item_description = item_description ORS $0;
}
}