home · contact · privacy
Add explanatory text to HTML view, inter-link HTML and TXT versions.
[berlin-corona-table] / enhance_table.py
index a969895164f6a316123e1692d32762248533c15c..03382554e2dbfc538aca8107777ed15ee789546c 100755 (executable)
@@ -131,22 +131,27 @@ for i in range(len(sorted_dates)):
 
 # Optimized for web browser viewing.
 if output_type == 'html':
-    print('<html>')
-    print('<style>')
-    print('table, tr, th, td { border: 1px solid black; }')
-    print('.day_row:nth-child(7n+2) { background-color: yellow; }')
-    print('.district_header { writing-mode: vertical-rl; '
-          'transform: rotate(180deg); }')
-    print('</style>')
-    print('<table>')
-    print('<tr>')
-    print('<th>date</th>')
+    print("""<html>
+<style>
+table, tr, th, td { border: 1px solid black; }
+.day_row:nth-child(7n+2) { background-color: yellow; }
+.district_name { writing-mode: vertical-rl; transform: rotate(180deg); }
+</style>
+<h1>Table of Berlin's Corona infection number development by districts.
+</h1>
+<p>Updated daily at 9pm. <a href="https://plomlompom.com/repos/?p=berlin-corona-table">Source code</a>. <a href="berlin_corona.txt">Text view optimized for terminal curl</a>.</p>
+<table>
+<tr>
+<th>date</th>""")
+    sorted_dates.reverse()
+    sum_district = sorted_districts[-1]
     for district in sorted_districts:
         long_form = translate[district]
-        print('<th class="district_header">%s</th>' % long_form)
+        if sum_district == district:
+            print('<th>%s</th>' % long_form)
+        else:
+            print('<th class="district_name">%s</th>' % long_form)
     print('</tr>')
-    sorted_dates.reverse()
-    sum_district = sorted_districts[-1]
     for date in sorted_dates:
         print('<tr class="day_row">')
         print('<td>%s</td>' % date)
@@ -192,6 +197,8 @@ Abbrevations/explanations:
         intro += "%s: %s\n" % (k, translate[k])
     intro += """
 Source code: https://plomlompom.com/repos/?p=berlin-corona-table
+
+HTML view: https://plomlompom.com/berlin_corona.html
 """
     print(intro)