Permalink
Browse files

[46] Implemented title and github option for HTML conversion

Additionally cleaned up and adjusted README

Signed-off-by: DoesntMatter <jaed1@gmx.net>
  • Loading branch information...
DoesntMatter committed Jan 23, 2012
1 parent 18e9047 commit 7c5e34c10647b9bb0dfcc036d36d1bc57092cf9f
Showing with 41 additions and 7 deletions.
  1. +3 −4 README
  2. +24 −1 libs/HTML.pm
  3. +14 −2 scripts/gitlog_to_html.pl
View
7 README
@@ -61,15 +61,14 @@ Options:
Usage:
./gitlog_to_html.pl --repo /path/to/repository
Options:
Gitlog to HTML - Converts the output of `git log` to a HTML file
Copyright (C) 2012, by: Dennis Christ <jaed1@gmx.net>
Options:
--repo REPO Path to your Git repository
--count COUNT Count of commits that shoud be parsed
Default: All commits
--outfile FILE Name and path of generated SQL file
Default: $PWD/log.html
--title TITLE Title of your HTML page
Default: "Title of the HTML Page"
--github Links your commits to github
--prompt Prompt for input and do not use options
--help Show this output
View
@@ -24,6 +24,14 @@ use strict;
no warnings 'uninitialized'; # We can use uninitialized variables without any problem here
package HTML;
#
# Variables
#
our %html = (
title => 'Title of the HTML Page',
);
#
# Subroutines
#
@@ -39,6 +47,9 @@ Options:
Default: All commits
--outfile FILE Name and path of generated SQL file
Default: \$PWD/log.html
--title TITLE Title of your HTML page
Default: "Title of the HTML Page"
--github Links your commits to github
--prompt Prompt for input and do not use options
--help Show this output
HELP
@@ -49,7 +60,13 @@ HELP
sub CreateHTML {
my $gitlog = shift || return undef;
my $file = shift || return undef;
my $html = shift || return undef;
my $github = shift;
my @items = Parser::SplitCommits($gitlog, "\n&gt;");
my $weblink = "https://github.com";
my $commit;
open(FILE, ">$file");
print FILE "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
@@ -58,7 +75,7 @@ sub CreateHTML {
\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">
<html xmlns=\"http://www.w3.org/1999/xhtml\">
<head>
<title></title>
<title>$html{'title'}</title>
</head>
<body>";
close(FILE);
@@ -73,6 +90,12 @@ sub CreateHTML {
# $items[$i][5] Subject
# $items[$i][6] Body
if ($github) {
$commit = join("/", $github, "commit", $items[$i][1]);
$items[$i][1] = "<a href=\"$commit\">$items[$i][1]</a>";
$items[$i][3] = "<a href=\"$weblink/$items[$i][3]\">$items[$i][3]</a>";
}
print FILE "<h3>$items[$i][5]</h3>
<p>$items[$i][3] &lt;$items[$i][4]&gt; committed $items[$i][1]</p>
<p>$items[$i][2]</p>
View
@@ -39,12 +39,13 @@
# Get options
#
GetOptions (
\%options,
"repo=s",
"count=i",
"outfile=s",
"title=s",
"github",
"prompt",
"help|?",
);
@@ -65,6 +66,12 @@
else {
HTML::ShowHelp();
}
if (Generic::HasValue($options{'title'})) {
$HTML::html{'title'} = $options{'title'};
}
if ($options{'github'}) {
$giturl = Generic::GetGithubUrl($options{'repo'});
}
}
else {
$options{'repo'} = Generic::GetInput("Please enter repository path: ", 1);
@@ -73,6 +80,11 @@
}
$options{'count'} = Generic::GetInput("Please enter count of commits: ");
$options{'outfile'} = Generic::GetInput("Please enter outfile path: ");
$HTML::html{'title'} = Generic::GetInput("Please enter HTML title: ");
$options{'github'} = Generic::GetInput("Please confirm github usage (0|1): ");
if ($options{'github'}) {
$giturl = Generic::GetGithubUrl($options{'repo'});
}
}
#
@@ -85,6 +97,6 @@
exit;
}
HTML::CreateHTML(HTML::Entities::encode($gitlog), $options{'outfile'});
HTML::CreateHTML(HTML::Entities::encode($gitlog), $options{'outfile'}, \%HTML::html, $giturl);
exit;

0 comments on commit 7c5e34c

Please sign in to comment.