From 7303742fef4f593c478ba4061a5a0e63ce768974 Mon Sep 17 00:00:00 2001 From: emkael Date: Fri, 6 Jan 2017 03:04:10 +0100 Subject: Template refactoring - macros for reusable markup --- template/macros.html | 65 ++++++++++++++++++++++++++++ template/segment.html | 16 ++----- template/table.html | 114 ++++++-------------------------------------------- 3 files changed, 81 insertions(+), 114 deletions(-) create mode 100644 template/macros.html (limited to 'template') diff --git a/template/macros.html b/template/macros.html new file mode 100644 index 0000000..84ae27c --- /dev/null +++ b/template/macros.html @@ -0,0 +1,65 @@ +{% macro separator(cols) %} + +   + +{% endmacro %} + +{% macro previous_rounds(segments, segment_limit, prefix) %} + + + {{"HEADER_PREV_ROUNDS"|translate}} + {% for segment in segments[0:-segment_limit] %} + | + {{segment['round']}}-{{segment['segment']}} + + {% endfor %} + | + + + +   + +{% endmacro %} + +{% macro table_header(segments, segment_limit, prefix) %} + + {{"HEADER_PLACE"|translate}} +   + {{"HEADER_TEAM"|translate}} + {{"HEADER_IMPBRD"|translate}} + {{"HEADER_BOARDS"|translate}} + {% for segment in segments[-segment_limit:] %} + + + {{segment['round']}}-{{segment['segment']}} + + + {% endfor %} + +{% endmacro %} + +{% macro table_player(player, segment_limit) %} + + {{player['place']}} + {{player['name']}} + {{player['team']}} + {{'%.2f' % player['sum']}} + {{player['count']}} + {% for result in player['results'][-segment_limit:] %} + {% if result != '' %} + {{'%+.2f' % result}} + {% else %} +   + {% endif %} + {% endfor %} + +{% endmacro %} + +{% macro footer(date, time) %} +

+

+ {{"FOOTER_ANALYSIS"|translate}}, ©William Bailey'1999
+  Admin ©Jan Romański'2005, jfrteamy-ausbutler ©Michał Klichowicz'2017{{"FOOTER_GENERATED"|translate}} + {{date}}{{"FOOTER_AT"|translate}}{{time}}{{"FOOTER_OPTIMIZED"|translate}} +

+{% endmacro %} diff --git a/template/segment.html b/template/segment.html index 6d8e038..a481dcf 100644 --- a/template/segment.html +++ b/template/segment.html @@ -1,3 +1,4 @@ +{% from 'macros.html' import separator, footer %} @@ -19,15 +20,11 @@ {{logoh}} - -   - + {{ separator(3) }} {{"BUTLER_ROUND"|translate}}{{round_no}} {{"SEGMENT"|translate}}{{segment_no}} - -   - + {{ separator(3) }} @@ -70,11 +67,6 @@
-

-

- {{"FOOTER_ANALYSIS"|translate}}, ©William Bailey'1999
-  Admin ©Jan Romański'2005, jfrteamy-ausbutler ©Michał Klichowicz'2017{{"FOOTER_GENERATED"|translate}} - {{date}}{{"FOOTER_AT"|translate}}{{time}}{{"FOOTER_OPTIMIZED"|translate}} -

+ {{ footer(date, time) }} diff --git a/template/table.html b/template/table.html index e5cd462..06e5479 100644 --- a/template/table.html +++ b/template/table.html @@ -1,3 +1,4 @@ +{% from 'macros.html' import separator, previous_rounds, table_header, table_player, footer %} @@ -19,9 +20,7 @@ {{logoh}} - -   - + {{ separator(segment_limit+5) }} {{"NORMALIZED_CLASSIFICATION"|translate}} @@ -30,59 +29,16 @@ {% endif %} - -   - + {{ separator(segment_limit+5) }} {% if segments|length > segment_limit %} - - - {{"HEADER_PREV_ROUNDS"|translate}} - {% for segment in segments[0:-segment_limit] %} - | - {{segment['round']}}-{{segment['segment']}} - - {% endfor %} - | - - - -   - + {{ previous_rounds(segments, segment_limit, prefix) }} {% endif %} - - {{"HEADER_PLACE"|translate}} -   - {{"HEADER_TEAM"|translate}} - {{"HEADER_IMPBRD"|translate}} - {{"HEADER_BOARDS"|translate}} - {% for segment in segments[-segment_limit:] %} - - - {{segment['round']}}-{{segment['segment']}} - - - {% endfor %} - + {{ table_header(segments, segment_limit, prefix) }} {% for player in above_threshold %} - - {{player['place']}} - {{player['name']}} - {{player['team']}} - {{'%.2f' % player['sum']}} - {{player['count']}} - {% for result in player['results'][-segment_limit:] %} - {% if result != '' %} - {{'%+.2f' % result}} - {% else %} -   - {% endif %} - {% endfor %} - + {{ table_player(player, segment_limit) }} {% endfor %} {% if below_threshold|length > 0 %} - -   - + {{ separator(segment_limit+5) }} {{"NORMALIZED_CLASSIFICATION"|translate}} @@ -91,62 +47,16 @@ {% endif %} - -   - + {{ separator(segment_limit+5) }} {% if segments|length > segment_limit %} - - - {{"HEADER_PREV_ROUNDS"|translate}} - {% for segment in segments[0:-segment_limit] %} - | - {{segment['round']}}-{{segment['segment']}} - - {% endfor %} - | - - - -   - + {{ previous_rounds(segments, segment_limit, prefix) }} {% endif %} - - {{"HEADER_PLACE"|translate}} -   - {{"HEADER_TEAM"|translate}} - {{"HEADER_IMPBRD"|translate}} - {{"HEADER_BOARDS"|translate}} - {% for segment in segments[-segment_limit:] %} - - - {{segment['round']}}-{{segment['segment']}} - - - {% endfor %} - + {{ table_header(segments, segment_limit, prefix) }} {% for player in below_threshold %} - - {{player['place']}} - {{player['name']}} - {{player['team']}} - {{'%.2f' % player['sum']}} - {{player['count']}} - {% for result in player['results'][-segment_limit:] %} - {% if result != '' %} - {{'%+.2f' % result}} - {% else %} -   - {% endif %} - {% endfor %} - + {{ table_player(player, segment_limit) }} {% endfor %} {% endif %} -

-

- {{"FOOTER_ANALYSIS"|translate}}, ©William Bailey'1999
-  Admin ©Jan Romański'2005, jfrteamy-ausbutler ©Michał Klichowicz'2017{{"FOOTER_GENERATED"|translate}} - {{date}}{{"FOOTER_AT"|translate}}{{time}}{{"FOOTER_OPTIMIZED"|translate}} -

+ {{ footer(date, time) }} -- cgit v1.2.3