소스 검색

Include project name in the title.

For now it's taken from the basename of the repository path.
Heikki Hokkanen 18 년 전
부모
커밋
d87b7a004f
1개의 변경된 파일7개의 추가작업 그리고 4개의 파일을 삭제
  1. 7
    4
      gitstats

+ 7
- 4
gitstats 파일 보기

@@ -38,6 +38,7 @@ class DataCollector:
38 38
 	# This should be the main function to extract data from the repository.
39 39
 	def collect(self, dir):
40 40
 		self.dir = dir
41
+		self.projectname = os.path.basename(os.path.abspath(dir))
41 42
 	
42 43
 	##
43 44
 	# : get a dictionary of author
@@ -344,6 +345,7 @@ def html_header(level, text):
344 345
 class HTMLReportCreator(ReportCreator):
345 346
 	def create(self, data, path):
346 347
 		ReportCreator.create(self, data, path)
348
+		self.title = data.projectname
347 349
 
348 350
 		# TODO copy the CSS if it does not exist
349 351
 		if not os.path.exists(path + '/gitstats.css'):
@@ -354,11 +356,12 @@ class HTMLReportCreator(ReportCreator):
354 356
 		format = '%Y-%m-%d %H:%m:%S'
355 357
 		self.printHeader(f)
356 358
 
357
-		f.write('<h1>GitStats</h1>')
359
+		f.write('<h1>GitStats - %s</h1>' % data.projectname)
358 360
 
359 361
 		self.printNav(f)
360 362
 
361 363
 		f.write('<dl>');
364
+		f.write('<dt>Project name</dt><dd>%s</dd>' % (data.projectname))
362 365
 		f.write('<dt>Generated</dt><dd>%s (in %d seconds)</dd>' % (datetime.datetime.now().strftime(format), time.time() - data.getStampCreated()));
363 366
 		f.write('<dt>Report Period</dt><dd>%s to %s</dd>' % (data.getFirstCommitDate().strftime(format), data.getLastCommitDate().strftime(format)))
364 367
 		f.write('<dt>Total Files</dt><dd>%s</dd>' % data.getTotalFiles())
@@ -745,18 +748,18 @@ plot 'lines_of_code.dat' using 1:2 w lines
745 748
 			if len(out) > 0:
746 749
 				print out
747 750
 
748
-	def printHeader(self, f):
751
+	def printHeader(self, f, title = ''):
749 752
 		f.write(
750 753
 """<?xml version="1.0" encoding="UTF-8"?>
751 754
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
752 755
 <html xmlns="http://www.w3.org/1999/xhtml">
753 756
 <head>
754
-	<title>GitStats</title>
757
+	<title>GitStats - %s</title>
755 758
 	<link rel="stylesheet" href="gitstats.css" type="text/css" />
756 759
 	<meta name="generator" content="GitStats" />
757 760
 </head>
758 761
 <body>
759
-""")
762
+""" % self.title)
760 763
 
761 764
 	def printNav(self, f):
762 765
 		f.write("""