commit d03cdfba164134af17cfd71a361b798866e604d3 Author: Iain R. Learmonth <i...@fsfe.org> Date: Mon Oct 9 03:10:32 2017 +0100
Adds an alert when a new relay to link to lifecycle blog post (Closes: #23767) --- js/models/relay.js | 17 +++++++++++++++++ templates/details/router.html | 5 ++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/js/models/relay.js b/js/models/relay.js index 62b8d21..2f7b80d 100644 --- a/js/models/relay.js +++ b/js/models/relay.js @@ -125,6 +125,21 @@ define([ return output }, + is_new: function(utctime) { + var hr_magic = [10]; + var t = utctime.split(" "); + var utcd = t[0].split("-"); + var utct = t[1].split(":"); + var d = new Date(utcd[0], utcd[1]-1, utcd[2], utct[0], utct[1], utct[2]); + var now = new Date(); + now = new Date(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate(), now.getUTCHours(), now.getUTCMinutes(), now.getUTCSeconds()); + var diff = now-d; + var secs = Math.round(diff/1000); + var mins = Math.floor(secs/60); + var hours = Math.floor(mins/60); + var days = Math.floor(hours/24); + return days < 15; + }, lookup: function(options) { var success = options.success; var error = options.error; @@ -171,6 +186,8 @@ define([ relay.country = relay.country ? relay.country.toLowerCase() : null; relay.countryname = relay.country ? CountryCodes[relay.country] : null; relay.first_seen = relay.first_seen ? relay.first_seen : null; + relay.age = relay.first_seen ? model.parsedate(relay.first_seen).hrfull : null; + relay.new_relay = relay.first_seen ? model.is_new(relay.first_seen) : null; relay.uptime = relay.last_restarted ? model.parsedate(relay.last_restarted) : null; relay.uptime_hr = relay.last_restarted ? relay.uptime.hr : null; relay.uptime_hrfull = relay.last_restarted ? relay.uptime.hrfull : null; diff --git a/templates/details/router.html b/templates/details/router.html index 3cab9b2..591b6cc 100644 --- a/templates/details/router.html +++ b/templates/details/router.html @@ -10,6 +10,9 @@ <div class="page-header"> <h2>General <small>Overall information on the Tor relay</small></h2> </div> +<% if (relay.get('new_relay') === true) {%> +<div class="alert alert-info">This relay appears to be less than 2 weeks old. <a href="https://blog.torproject.org/lifecycle-new-relay">This blog post</a> explains the lifecycle of a new relay, and why it will not be immediately fully used to capacity.</div> +<% } %> <% if (relay.get('recommended_version') === false) { %> <div class="alert alert-danger">This relay is running an outdated Tor version and should be updated to a recent release of Tor that may contain important fixes.</div> <% } %> @@ -133,7 +136,7 @@ <dd><%= relay.get('as_name') ? _.escape(relay.get('as_name')) : "unknown" %></dd> <dt><span class="tip" title="The first time that this relay was seen online.">First Seen</span></dt> - <dd><%= relay.get('first_seen') %></dd> + <dd><%= relay.get('first_seen') %> (<%= relay.get('age') %>)</dd> <dt><span class="tip" title="Date and time when the relay was last (re-)started.">Last Restarted</span></dt> <dd><%= relay.get('last_restarted') %></dd> _______________________________________________ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits