From 9da6a926b774dfd009c0735833cc436457db3b76 Mon Sep 17 00:00:00 2001 From: Heikki Hokkanen Date: Thu, 16 Aug 2007 15:56:06 +0300 Subject: [PATCH] Output fragment (#) links for all headers. Headers are now created using html_header() function. --- doc/TODO.txt | 1 - gitstats | 31 +++++++++++++++++++------------ gitstats.css | 12 ++++++++++++ 3 files changed, 31 insertions(+), 13 deletions(-) diff --git a/doc/TODO.txt b/doc/TODO.txt index 9ab6a92..04cb2c5 100644 --- a/doc/TODO.txt +++ b/doc/TODO.txt @@ -1,5 +1,4 @@ [] -- BUG git repo broken again - Files - (T) File count by date diff --git a/gitstats b/gitstats index 7c4d27e..b2bbc21 100755 --- a/gitstats +++ b/gitstats @@ -233,6 +233,7 @@ class GitDataCollector(DataCollector): self.extensions[ext]['files'] += 1 try: + # FIXME filenames with spaces or special characters are broken self.extensions[ext]['lines'] += int(getoutput('wc -l < %s' % line, quiet = True)) except: print 'Warning: Could not count lines for file "%s"' % line @@ -296,6 +297,13 @@ class ReportCreator: self.data = data self.path = path +def html_linkify(text): + return text.lower().replace(' ', '_') + +def html_header(level, text): + name = html_linkify(text) + return '\n%s\n\n' % (level, name, name, text, level) + class HTMLReportCreator(ReportCreator): def create(self, data, path): ReportCreator.create(self, data, path) @@ -337,7 +345,7 @@ class HTMLReportCreator(ReportCreator): f.write('

Last 12 months

') # Hour of Day - f.write('\n

Hour of Day

\n\n') + f.write(html_header(2, 'Hour of Day')) hour_of_day = data.getActivityByHourOfDay() f.write('') for i in range(1, 25): @@ -370,7 +378,7 @@ class HTMLReportCreator(ReportCreator): fg.close() # Day of Week - f.write('\n

Day of Week

\n\n') + f.write(html_header(2, 'Day of Week')) day_of_week = data.getActivityByDayOfWeek() f.write('
Hour
') f.write('') @@ -389,7 +397,7 @@ class HTMLReportCreator(ReportCreator): fp.close() # Hour of Week - f.write('\n

Hour of Week

\n\n') + f.write(html_header(2, 'Hour of Week')) f.write('
DayTotal (%)
') f.write('') @@ -413,7 +421,7 @@ class HTMLReportCreator(ReportCreator): f.write('
Weekday
') # Month of Year - f.write('\n

Month of Year

\n\n') + f.write(html_header(2, 'Month of Year')) f.write('
') f.write('') fp = open (path + '/month_of_year.dat', 'w') @@ -428,7 +436,7 @@ class HTMLReportCreator(ReportCreator): f.write('Month of Year') # Commits by year/month - f.write('

Commits by year/month

') + f.write(html_header(2, 'Commits by year/month')) f.write('
MonthCommits (%)
') for yymm in reversed(sorted(data.commits_by_month.keys())): f.write('' % (yymm, data.commits_by_month[yymm])) @@ -440,7 +448,7 @@ class HTMLReportCreator(ReportCreator): fg.close() # Commits by year - f.write('

Commits by year

') + f.write(html_header(2, 'Commits by Year')) f.write('
MonthCommits
%s%d
') for yy in reversed(sorted(data.commits_by_year.keys())): f.write('' % (yy, data.commits_by_year[yy], (100.0 * data.commits_by_year[yy]) / data.getTotalCommits())) @@ -463,7 +471,7 @@ class HTMLReportCreator(ReportCreator): self.printNav(f) # Authors :: List of authors - f.write('\n

List of authors

\n\n') + f.write(html_header(2, 'List of Authors')) f.write('
YearCommits (% of all)
%s%d (%.2f%%)
') f.write('') @@ -473,7 +481,7 @@ class HTMLReportCreator(ReportCreator): f.write('
AuthorCommits (%)First commitLast commitAge
') # Authors :: Author of Month - f.write('\n

Author of Month

\n\n') + f.write(html_header(2, 'Author of Month')) f.write('') f.write('') for yymm in reversed(sorted(data.author_of_month.keys())): @@ -485,7 +493,7 @@ class HTMLReportCreator(ReportCreator): f.write('
MonthAuthorCommits (%)
') - f.write('\n

Author of Year

\n\n') + f.write(html_header(2, 'Author of Year')) f.write('') for yy in reversed(sorted(data.author_of_year.keys())): authordict = data.author_of_year[yy] @@ -512,7 +520,7 @@ class HTMLReportCreator(ReportCreator): f.write('\n') # Files :: File count by date - f.write('

File count by date

') + f.write(html_header(2, 'File count by date')) fg = open(path + '/files_by_date.dat', 'w') for stamp in sorted(data.files_by_stamp.keys()): @@ -524,7 +532,7 @@ class HTMLReportCreator(ReportCreator): #f.write('

Average file size by date

') # Files :: Extensions - f.write('\n

Extensions

\n\n') + f.write(html_header(2, 'Extensions')) f.write('
YearAuthorCommits (%)
') for ext in sorted(data.extensions.keys()): files = data.extensions[ext]['files'] @@ -734,4 +742,3 @@ print 'Generating report...' report = HTMLReportCreator() report.create(data, outputpath) - diff --git a/gitstats.css b/gitstats.css index 9defda1..be96694 100644 --- a/gitstats.css +++ b/gitstats.css @@ -83,3 +83,15 @@ img { clear: both; font-size: 90%; } + +h1 a, h2 a { + color: black; + text-decoration: none; +} + +h1:hover a:after, +h2:hover a:after { + content: 'ΒΆ'; + color: #555; +} + -- 2.11.4.GIT
ExtensionFiles (%)Lines (%)Lines/file