From e1fd6ae6f6f05f70006b5d3eeff8056ea64c2015 Mon Sep 17 00:00:00 2001
From: Thor77 <xXThor77Xx@gmail.com>
Date: Wed, 22 Apr 2015 16:32:28 +0200
Subject: [PATCH] Add configurable html-title

---
 README.md     | 2 ++
 template.html | 1 +
 tsstats.py    | 5 +++--
 3 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md
index 50761bb..56bd54d 100644
--- a/README.md
+++ b/README.md
@@ -11,12 +11,14 @@ Run `tsstats.py` and point your web-server to the generated .html-file, now you
 ###Sections
 `[General]`
 ### Keys
+- title `HTMl-Title`
 - logfile `Path to TS3Server-logfile`
 - outputfile `Path to the location, where the generator will put the generated .html-file`
 
 ## Example
 ```
 [General]
+title = TeamspeakStats
 logfile = /usr/local/bin/teamspeak-server/logs/ts3server_2015-03-02__14_01_43.110983_1.log
 outputfile = /var/www/html/stats.html
 ```
diff --git a/template.html b/template.html
index 3bc550c..7459f86 100644
--- a/template.html
+++ b/template.html
@@ -7,6 +7,7 @@
         text-align: center;
         }
     </style>
+    <title>{{ title }}</title>
   </head>
   <body>
     {# Onlinetime #}
diff --git a/tsstats.py b/tsstats.py
index 3a1e885..4bb61c4 100755
--- a/tsstats.py
+++ b/tsstats.py
@@ -18,10 +18,11 @@ path += '/'
 # parse config
 config = configparser.ConfigParser()
 config.read(path + 'config.ini')
-if 'General' not in config or not ('logfile' in config['General'] and 'outputfile' in config['General']):
+if 'General' not in config or not ('title' in config['General'] and 'logfile' in config['General'] and 'outputfile' in config['General']):
     print('Invalid configuration!')
     import sys
     sys.exit()
+title = config['General']['title']
 log_path = config['General']['logfile']
 output_path = config['General']['outputfile']
 
@@ -153,7 +154,7 @@ def render_template():
         onlinetime_desc[idx] = (clid, nick, onlinetime_str, clients[clid]['connected'])
 
     with open(output_path, 'w+') as f:
-        f.write(template.render(onlinetime=onlinetime_desc, kicks=desc('kicks'), pkicks=desc('pkicks'), bans=desc('bans'), seconds='{}.{}'.format(generation_delta.seconds, generation_delta.microseconds), date=generation_end.strftime('%d.%m.%Y um %H:%M')))
+        f.write(template.render(title=title, onlinetime=onlinetime_desc, kicks=desc('kicks'), pkicks=desc('pkicks'), bans=desc('bans'), seconds='{}.{}'.format(generation_delta.seconds, generation_delta.microseconds), date=generation_end.strftime('%d.%m.%Y um %H:%M')))
 
 if len(clients) < 1:
     print('Not enough data!')