summaryrefslogtreecommitdiff
path: root/template
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2017-01-06 03:04:10 +0100
committeremkael <emkael@tlen.pl>2017-01-06 03:04:10 +0100
commit7303742fef4f593c478ba4061a5a0e63ce768974 (patch)
tree44763d693fe9e71749419db3d8df040ca593c8bc /template
parentf492e49f743c6283e7f071f6118f6da5ced526e3 (diff)
Template refactoring - macros for reusable markup
Diffstat (limited to 'template')
-rw-r--r--template/macros.html65
-rw-r--r--template/segment.html16
-rw-r--r--template/table.html114
3 files changed, 81 insertions, 114 deletions
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) %}
+<tr>
+ <td class="e" colspan="{{cols}}">&nbsp;</td>
+</tr>
+{% endmacro %}
+
+{% macro previous_rounds(segments, segment_limit, prefix) %}
+<tr>
+ <td class="bdnl12" colspan="{{segment_limit+5}}">
+ {{"HEADER_PREV_ROUNDS"|translate}}
+ {% for segment in segments[0:-segment_limit] %}
+ |<a href="{{prefix}}normbutler{{segment['round']}}-{{segment['segment']}}.htm">
+ {{segment['round']}}-{{segment['segment']}}
+ </a>
+ {% endfor %}
+ |
+ </td>
+</tr>
+<tr>
+ <td class="e" colspan="{{segment_limit+5}}">&nbsp;</td>
+</tr>
+{% endmacro %}
+
+{% macro table_header(segments, segment_limit, prefix) %}
+<tr>
+ <td class="bdcc12">{{"HEADER_PLACE"|translate}}</td>
+ <td class="bdcc2">&nbsp;</td>
+ <td class="bdcc2">{{"HEADER_TEAM"|translate}}</td>
+ <td class="bdcc2">{{"HEADER_IMPBRD"|translate}}</td>
+ <td class="bdcc2">{{"HEADER_BOARDS"|translate}}</td>
+ {% for segment in segments[-segment_limit:] %}
+ <td class="bdcc2">
+ <a href="{{prefix}}normbutler{{segment['round']}}-{{segment['segment']}}.htm">
+ {{segment['round']}}-{{segment['segment']}}
+ </a>
+ </td>
+ {% endfor %}
+</tr>
+{% endmacro %}
+
+{% macro table_player(player, segment_limit) %}
+<tr>
+ <td class="bdc1">{{player['place']}}</td>
+ <td class="bd">{{player['name']}}</td>
+ <td class="bd">{{player['team']}}</td>
+ <td class="bdc">{{'%.2f' % player['sum']}}</td>
+ <td class="bdc">{{player['count']}}</td>
+ {% for result in player['results'][-segment_limit:] %}
+ {% if result != '' %}
+ <td class="bdc">{{'%+.2f' % result}}</td>
+ {% else %}
+ <td class="bdc">&nbsp;</td>
+ {% endif %}
+ {% endfor %}
+</tr>
+{% endmacro %}
+
+{% macro footer(date, time) %}
+<p class="vs"></p>
+<p class="f">
+ {{"FOOTER_ANALYSIS"|translate}}, &copy;William Bailey&#39;1999<br />
+ &nbsp;Admin&nbsp;&copy;Jan Romański&#39;2005,&nbsp;jfrteamy-ausbutler&nbsp;&copy;Michał Klichowicz&#39;2017{{"FOOTER_GENERATED"|translate}}
+ {{date}}{{"FOOTER_AT"|translate}}{{time}}{{"FOOTER_OPTIMIZED"|translate}}
+</p>
+{% 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 %}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
@@ -19,15 +20,11 @@
{{logoh}}
</td>
</tr>
- <tr>
- <td class="e" colspan="3">&nbsp;</td>
- </tr>
+ {{ separator(3) }}
<tr>
<td class="bdnt12" colspan="3">{{"BUTLER_ROUND"|translate}}{{round_no}} {{"SEGMENT"|translate}}{{segment_no}}</td>
</tr>
- <tr>
- <td class="e" colspan="3">&nbsp;</td>
- </tr>
+ {{ separator(3) }}
<tr valign="top">
<td>
<table cellspacing="0">
@@ -70,11 +67,6 @@
</td>
</tr>
</table>
- <p class="vs"></p>
- <p class="f">
- {{"FOOTER_ANALYSIS"|translate}}, &copy;William Bailey&#39;1999<br />
- &nbsp;Admin&nbsp;&copy;Jan Romański&#39;2005,&nbsp;jfrteamy-ausbutler&nbsp;&copy;Michał Klichowicz&#39;2017{{"FOOTER_GENERATED"|translate}}
- {{date}}{{"FOOTER_AT"|translate}}{{time}}{{"FOOTER_OPTIMIZED"|translate}}
- </p>
+ {{ footer(date, time) }}
</body>
</html>
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 %}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
@@ -19,9 +20,7 @@
{{logoh}}
</td>
</tr>
- <tr>
- <td class="e" colspan="{{segment_limit+5}}">&nbsp;</td>
- </tr>
+ {{ separator(segment_limit+5) }}
<tr>
<td class="bdnt12" colspan="{{segment_limit+5}}">
{{"NORMALIZED_CLASSIFICATION"|translate}}
@@ -30,59 +29,16 @@
{% endif %}
</td>
</tr>
- <tr>
- <td class="e" colspan="{{segment_limit+5}}">&nbsp;</td>
- </tr>
+ {{ separator(segment_limit+5) }}
{% if segments|length > segment_limit %}
- <tr>
- <td class="bdnl12" colspan="{{segment_limit+5}}">
- {{"HEADER_PREV_ROUNDS"|translate}}
- {% for segment in segments[0:-segment_limit] %}
- |<a href="{{prefix}}normbutler{{segment['round']}}-{{segment['segment']}}.htm">
- {{segment['round']}}-{{segment['segment']}}
- </a>
- {% endfor %}
- |
- </td>
- </tr>
- <tr>
- <td class="e" colspan="{{segment_limit+5}}">&nbsp;</td>
- </tr>
+ {{ previous_rounds(segments, segment_limit, prefix) }}
{% endif %}
- <tr>
- <td class="bdcc12">{{"HEADER_PLACE"|translate}}</td>
- <td class="bdcc2">&nbsp;</td>
- <td class="bdcc2">{{"HEADER_TEAM"|translate}}</td>
- <td class="bdcc2">{{"HEADER_IMPBRD"|translate}}</td>
- <td class="bdcc2">{{"HEADER_BOARDS"|translate}}</td>
- {% for segment in segments[-segment_limit:] %}
- <td class="bdcc2">
- <a href="{{prefix}}normbutler{{segment['round']}}-{{segment['segment']}}.htm">
- {{segment['round']}}-{{segment['segment']}}
- </a>
- </td>
- {% endfor %}
- </tr>
+ {{ table_header(segments, segment_limit, prefix) }}
{% for player in above_threshold %}
- <tr>
- <td class="bdc1">{{player['place']}}</td>
- <td class="bd">{{player['name']}}</td>
- <td class="bd">{{player['team']}}</td>
- <td class="bdc">{{'%.2f' % player['sum']}}</td>
- <td class="bdc">{{player['count']}}</td>
- {% for result in player['results'][-segment_limit:] %}
- {% if result != '' %}
- <td class="bdc">{{'%+.2f' % result}}</td>
- {% else %}
- <td class="bdc">&nbsp;</td>
- {% endif %}
- {% endfor %}
- </tr>
+ {{ table_player(player, segment_limit) }}
{% endfor %}
{% if below_threshold|length > 0 %}
- <tr>
- <td class="e" colspan="{{segment_limit+5}}">&nbsp;</td>
- </tr>
+ {{ separator(segment_limit+5) }}
<tr>
<td class="bdnt12" colspan="{{segment_limit+5}}">
{{"NORMALIZED_CLASSIFICATION"|translate}}
@@ -91,62 +47,16 @@
{% endif %}
</td>
</tr>
- <tr>
- <td class="e" colspan="{{segment_limit+5}}">&nbsp;</td>
- </tr>
+ {{ separator(segment_limit+5) }}
{% if segments|length > segment_limit %}
- <tr>
- <td class="bdnl12" colspan="{{segment_limit+5}}">
- {{"HEADER_PREV_ROUNDS"|translate}}
- {% for segment in segments[0:-segment_limit] %}
- |<a href="{{prefix}}normbutler{{segment['round']}}-{{segment['segment']}}.htm">
- {{segment['round']}}-{{segment['segment']}}
- </a>
- {% endfor %}
- |
- </td>
- </tr>
- <tr>
- <td class="e" colspan="{{segment_limit+5}}">&nbsp;</td>
- </tr>
+ {{ previous_rounds(segments, segment_limit, prefix) }}
{% endif %}
- <tr>
- <td class="bdcc12">{{"HEADER_PLACE"|translate}}</td>
- <td class="bdcc2">&nbsp;</td>
- <td class="bdcc2">{{"HEADER_TEAM"|translate}}</td>
- <td class="bdcc2">{{"HEADER_IMPBRD"|translate}}</td>
- <td class="bdcc2">{{"HEADER_BOARDS"|translate}}</td>
- {% for segment in segments[-segment_limit:] %}
- <td class="bdcc2">
- <a href="{{prefix}}normbutler{{segment['round']}}-{{segment['segment']}}.htm">
- {{segment['round']}}-{{segment['segment']}}
- </a>
- </td>
- {% endfor %}
- </tr>
+ {{ table_header(segments, segment_limit, prefix) }}
{% for player in below_threshold %}
- <tr>
- <td class="bdc1">{{player['place']}}</td>
- <td class="bd">{{player['name']}}</td>
- <td class="bd">{{player['team']}}</td>
- <td class="bdc">{{'%.2f' % player['sum']}}</td>
- <td class="bdc">{{player['count']}}</td>
- {% for result in player['results'][-segment_limit:] %}
- {% if result != '' %}
- <td class="bdc">{{'%+.2f' % result}}</td>
- {% else %}
- <td class="bdc">&nbsp;</td>
- {% endif %}
- {% endfor %}
- </tr>
+ {{ table_player(player, segment_limit) }}
{% endfor %}
{% endif %}
</table>
- <p class="vs"></p>
- <p class="f">
- {{"FOOTER_ANALYSIS"|translate}}, &copy;William Bailey&#39;1999<br />
- &nbsp;Admin&nbsp;&copy;Jan Romański&#39;2005,&nbsp;jfrteamy-ausbutler&nbsp;&copy;Michał Klichowicz&#39;2017{{"FOOTER_GENERATED"|translate}}
- {{date}}{{"FOOTER_AT"|translate}}{{time}}{{"FOOTER_OPTIMIZED"|translate}}
- </p>
+ {{ footer(date, time) }}
</body>
</html>