commit a2b0104c621e7172554cc3e78844d562a6470549 Author: Tom Ritter tom@ritter.vg Date: Wed Jul 6 11:57:39 2016 -0500
Add placeholders for graphs while they are generating, link from the main index page, and reduce the size of the vote data in the csv file --- graphs.py | 35 +++++++++++++++++++++++++++++------ website.py | 15 ++++++++++----- write_website.py | 2 +- 3 files changed, 40 insertions(+), 12 deletions(-)
diff --git a/graphs.py b/graphs.py index ac07c97..4ceb6d3 100755 --- a/graphs.py +++ b/graphs.py @@ -21,7 +21,7 @@ class GraphWriter(WebsiteWriter): self.site = open(filename, 'w') self._write_page_header() self._write_valid_after_time() - self._write_number_of_relays_voted_about() + self._write_number_of_relays_voted_about(False) self._write_number_of_relays_voted_about_graphs() self._write_bandwidth_scanner_status(False) self._write_bandwidth_scanner_graphs() @@ -61,7 +61,7 @@ class GraphWriter(WebsiteWriter): + " }\n" + " .graphbox {\n" + " text-align: center;\n" - #+ " display: none;\n" + + " display: none;\n" + " }\n" + " .faravahar {\n" + " fill: none;\n" @@ -144,10 +144,8 @@ class GraphWriter(WebsiteWriter): + " <span class="maatuska" style="margin-left:5px"> </span> Maatuska\n" + " <span class="longclaw" style="margin-left:5px"> </span> Longclaw\n" + " <span class="tor26" style="margin-left:5px"> </span> tor26\n" - + " <span class="urras" style="margin-left:5px"> </span> urras\n" + " <span class="dizum" style="margin-left:5px"> </span> dizum\n" + " <span class="dannenberg" style="margin-left:5px"> </span> dannenberg\n" - + " <span class="turtles" style="margin-left:5px"> </span> turtles\n" + " </div>\n" + " </td>\n" + " </tr>\n") @@ -165,7 +163,14 @@ class GraphWriter(WebsiteWriter): + " <colgroup>\n" + " <col width="160">\n" + " <col width="640">\n" - + " </colgroup>\n") + + " </colgroup>\n" + + " <tr class="graphplaceholder">\n" + + " <td>\n" + + " <div style="text-align:center">\n" + + " Generating Graph... (requires SVG and Javascript support)\n" + + " </div>\n" + + " </td>\n" + + " </tr>\n") self._write_number_of_relays_voted_about_graphs_spot("voted_total_1") self._write_number_of_relays_voted_about_graphs_spot("voted_total_2") self._write_number_of_relays_voted_about_graphs_spot("voted_total_3") @@ -207,7 +212,14 @@ class GraphWriter(WebsiteWriter): + " <colgroup>\n" + " <col width="160">\n" + " <col width="640">\n" - + " </colgroup>\n") + + " </colgroup>\n" + + " <tr class="graphplaceholder">\n" + + " <td>\n" + + " <div style="text-align:center">\n" + + " Generating Graph... (requires SVG and Javascript support)\n" + + " </div>\n" + + " </td>\n" + + " </tr>\n") self._write_bandwidth_scanner_graphs_spot("bwauth_measured_1") self._write_bandwidth_scanner_graphs_spot("bwauth_measured_2") self._write_bandwidth_scanner_graphs_spot("bwauth_measured_3") @@ -398,6 +410,17 @@ class GraphWriter(WebsiteWriter): .attr("class", "graph-title") .text(graph.title); } + + var toShow = document.getElementsByClassName('graphbox'); + for(i=0; i<toShow.length; i++) { + console.log(toShow[i]); + toShow[i].style.display = 'block'; + } + var toHide = document.getElementsByClassName('graphplaceholder'); + for(i=0; i<toHide.length; i++) { + console.log(toHide[i]); + toHide[i].style.display = 'none'; + } });
</script>""" diff --git a/website.py b/website.py index 569c8a1..574ede9 100755 --- a/website.py +++ b/website.py @@ -27,7 +27,7 @@ class WebsiteWriter: self._write_valid_after_time() self._write_signatures() self._write_known_flags() - self._write_number_of_relays_voted_about() + self._write_number_of_relays_voted_about(True) self._write_consensus_methods() self._write_recommended_versions() self._write_consensus_parameters() @@ -228,7 +228,7 @@ class WebsiteWriter: + "</table>\n")
#----------------------------------------------------------------------------------------- - def _write_number_of_relays_voted_about(self): + def _write_number_of_relays_voted_about(self, linkToGraph): """ Write the number of relays voted about. """ @@ -236,9 +236,14 @@ class WebsiteWriter: + " <!-- ================================================================= -->" + "<a name="numberofrelays">\n" + "<h3><a href="#numberofrelays" class="anchor">" - + "Number of relays voted about</a></h3>\n" - + "<br>\n" - + "<table border="0" cellpadding="4" cellspacing="0" summary="">\n" + + "Number of relays voted about</a></h3>\n") + if linkToGraph: + self.site.write("<p>\n" + + " You can also view <a href="graphs.html">historical voting graphs</a>.\n" + + "</p>\n") + else: + self.site.write("<br />\n") + self.site.write("<table border="0" cellpadding="4" cellspacing="0" summary="">\n" + " <colgroup>\n" + " <col width="160">\n" + " <col width="320">\n" diff --git a/write_website.py b/write_website.py index 25781b0..87863d6 100755 --- a/write_website.py +++ b/write_website.py @@ -95,7 +95,7 @@ def main(): dbc.commit()
# Write out the updated csv file for the graphs - vote_data = dbc.execute("SELECT * from vote_data ORDER BY date DESC LIMIT 17520") + vote_data = dbc.execute("SELECT * from vote_data ORDER BY date DESC LIMIT 2160") f = open(os.path.join(os.path.dirname(__file__), 'out', 'vote-stats.csv'), 'w') f.write("date") for d in get_dirauths_in_tables():