From 0bf3209ac695379ad0e3ebc3f52a19b226fa73ba Mon Sep 17 00:00:00 2001 From: emkael Date: Sat, 23 Feb 2019 15:51:31 +0100 Subject: External CSS + hiding everything apart from the bracket for print styles Fixes #31 --- jfr_playoff/filemanager.py | 30 ++++++++++++++++++------------ jfr_playoff/template.py | 5 +++-- playoff.css | 16 ++++++++++++++++ playoff.py | 1 + 4 files changed, 38 insertions(+), 14 deletions(-) create mode 100644 playoff.css diff --git a/jfr_playoff/filemanager.py b/jfr_playoff/filemanager.py index 515845e..990b9f2 100644 --- a/jfr_playoff/filemanager.py +++ b/jfr_playoff/filemanager.py @@ -50,23 +50,29 @@ class PlayoffFileManager(object): self.register_file(self.output_file) return self.output_file - def copy_scripts(self, script_path='sklady/playoff.js'): - script_output_path = os.path.join(self.output_path, script_path) - script_output_dir = os.path.dirname(script_output_path) - if len(script_output_dir) > 0: - if not os.path.exists(script_output_dir): + def copy_file(self, filename, path): + output_path = os.path.join(self.output_path, path) + output_dir = os.path.dirname(output_path) + if len(output_dir) > 0: + if not os.path.exists(output_dir): PlayoffLogger.get('filemanager').info( 'output directory %s does not exist, creating', - script_output_dir) - os.makedirs(script_output_dir) + output_dir) + os.makedirs(output_dir) PlayoffLogger.get('filemanager').info( - 'copying JS to %s', script_output_path) + 'copying file to %s', output_path) shutil.copy( unicode(os.path.join( - os.path.dirname(__main__.__file__), 'playoff.js')), - unicode(script_output_path)) - self.register_file(script_output_path) - return script_output_path + os.path.dirname(__main__.__file__), filename)), + unicode(output_path)) + self.register_file(output_path) + return output_path + + def copy_scripts(self, script_path='sklady/playoff.js'): + return self.copy_file('playoff.js', script_path) + + def copy_styles(self, sheet_path='css/playoff.css'): + return self.copy_file('playoff.css', sheet_path) def send_files(self): if (self.goniec is not None) and self.goniec['enabled']: diff --git a/jfr_playoff/template.py b/jfr_playoff/template.py index c6995e3..a76ebcd 100644 --- a/jfr_playoff/template.py +++ b/jfr_playoff/template.py @@ -124,7 +124,7 @@ class PlayoffTemplateStrings(object): ''' LEADERBOARD = ''' - +
@@ -178,6 +178,7 @@ class PlayoffTemplateStrings(object): %s %s + ''' @@ -189,7 +190,7 @@ class PlayoffTemplateStrings(object): %s %s -

+

%s diff --git a/playoff.css b/playoff.css new file mode 100644 index 0000000..30fd68b --- /dev/null +++ b/playoff.css @@ -0,0 +1,16 @@ +tr.winner > td { + background: #dfd; +} +tr.loser > td { + background: #fee; +} + +.team-predicted-label { + opacity: 0.3 +} + +@media print { + span#logo, p.swiss_links, table.leaderboard, table.caption_table, body>p.f { + display: none; + } +} diff --git a/playoff.py b/playoff.py index ac84c66..4e4d197 100644 --- a/playoff.py +++ b/playoff.py @@ -41,6 +41,7 @@ def main(): file_manager = PlayoffFileManager(settings) file_manager.write_content(content) file_manager.copy_scripts() + file_manager.copy_styles() file_manager.send_files() except SystemExit: interactive = False -- cgit v1.2.3
 {{FINAL_STANDINGS}}