From ec191bfca6e1cd3d31b4f206c56304caa69c82cf Mon Sep 17 00:00:00 2001
From: Daira Hopwood <david-sarah@jacaranda.org>
Date: Sun, 19 May 2013 23:27:23 +0100
Subject: [PATCH] WUI: add time page was rendered to client and introducer
 welcome pages. closes #1972

Author: Leif Ryge <leif@synthesize.us>
Signed-off-by: Daira Hopwood <david-sarah@jacaranda.org>
---
 src/allmydata/test/test_web.py     | 4 ++++
 src/allmydata/web/common.py        | 3 +++
 src/allmydata/web/introducer.xhtml | 2 ++
 src/allmydata/web/introweb.py      | 5 ++++-
 src/allmydata/web/root.py          | 5 +++--
 src/allmydata/web/welcome.xhtml    | 1 +
 6 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/src/allmydata/test/test_web.py b/src/allmydata/test/test_web.py
index 9db671c6..ba76b8c6 100644
--- a/src/allmydata/test/test_web.py
+++ b/src/allmydata/test/test_web.py
@@ -612,6 +612,8 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, testutil.ReallyEqualMixi
             self.failUnlessIn('<a href="status">Recent and Active Operations</a>', res)
             self.failUnlessIn('<a href="statistics">Operational Statistics</a>', res)
             self.failUnlessIn('<input type="hidden" name="t" value="report-incident" />', res)
+            self.failUnlessIn('Page rendered at', res)
+            self.failUnlessIn('Tahoe-LAFS code imported from:', res)
             res_u = res.decode('utf-8')
             self.failUnlessIn(u'<td>fake_nickname \u263A</td>', res_u)
             self.failUnlessIn(u'<div class="nickname">other_nickname \u263B</div>', res_u)
@@ -4421,6 +4423,8 @@ class IntroducerWeb(unittest.TestCase):
         def _check(res):
             self.failUnlessIn('Welcome to the Tahoe-LAFS Introducer', res)
             self.failUnlessIn(FAVICON_MARKUP, res)
+            self.failUnlessIn('Page rendered at', res)
+            self.failUnlessIn('Tahoe-LAFS code imported from:', res)
         d.addCallback(_check)
         return d
 
diff --git a/src/allmydata/web/common.py b/src/allmydata/web/common.py
index c3b94d2a..be6df366 100644
--- a/src/allmydata/web/common.py
+++ b/src/allmydata/web/common.py
@@ -16,6 +16,9 @@ from allmydata.util import abbreviate
 from allmydata.util.encodingutil import to_str, quote_output
 
 
+TIME_FORMAT = "%H:%M:%S %d-%b-%Y"
+
+
 class IOpHandleTable(Interface):
     pass
 
diff --git a/src/allmydata/web/introducer.xhtml b/src/allmydata/web/introducer.xhtml
index 9be4388f..e89e88c3 100644
--- a/src/allmydata/web/introducer.xhtml
+++ b/src/allmydata/web/introducer.xhtml
@@ -76,5 +76,7 @@
 </table>
 </div>
 
+<p class="minutia">Page rendered at <span n:render="data" n:data="rendered_at" /></p>
+
   </body>
 </html>
diff --git a/src/allmydata/web/introweb.py b/src/allmydata/web/introweb.py
index 843fd0e0..cc8b2ce1 100644
--- a/src/allmydata/web/introweb.py
+++ b/src/allmydata/web/introweb.py
@@ -7,7 +7,8 @@ import allmydata
 import simplejson
 from allmydata import get_package_versions_string
 from allmydata.util import idlib
-from allmydata.web.common import getxmlfile, get_arg
+from allmydata.web.common import getxmlfile, get_arg, TIME_FORMAT
+
 
 class IntroducerRoot(rend.Page):
 
@@ -67,6 +68,8 @@ class IntroducerRoot(rend.Page):
         return simplejson.dumps(res, indent=1) + "\n"
 
     # FIXME: This code is duplicated in root.py and introweb.py.
+    def data_rendered_at(self, ctx, data):
+        return time.strftime(TIME_FORMAT, time.localtime())
     def data_version(self, ctx, data):
         return get_package_versions_string()
     def data_import_path(self, ctx, data):
diff --git a/src/allmydata/web/root.py b/src/allmydata/web/root.py
index 03ff87f0..9495d3df 100644
--- a/src/allmydata/web/root.py
+++ b/src/allmydata/web/root.py
@@ -14,7 +14,7 @@ from allmydata.interfaces import IFileNode
 from allmydata.web import filenode, directory, unlinked, status, operations
 from allmydata.web import storage
 from allmydata.web.common import abbreviate_size, getxmlfile, WebError, \
-     get_arg, RenderMixin, get_format, get_mutable_type
+     get_arg, RenderMixin, get_format, get_mutable_type, TIME_FORMAT
 
 
 class URIHandler(RenderMixin, rend.Page):
@@ -164,6 +164,8 @@ class Root(rend.Page):
     #child_server # let's reserve this for storage-server-over-HTTP
 
     # FIXME: This code is duplicated in root.py and introweb.py.
+    def data_rendered_at(self, ctx, data):
+        return time.strftime(TIME_FORMAT, time.localtime())
     def data_version(self, ctx, data):
         return get_package_versions_string()
     def data_import_path(self, ctx, data):
@@ -287,7 +289,6 @@ class Root(rend.Page):
         version = announcement["my-version"]
         service_name = announcement["service-name"]
 
-        TIME_FORMAT = "%H:%M:%S %d-%b-%Y"
         ctx.fillSlots("address", addr)
         ctx.fillSlots("connected", connected)
         ctx.fillSlots("connected-bool", bool(rhost))
diff --git a/src/allmydata/web/welcome.xhtml b/src/allmydata/web/welcome.xhtml
index 0b796b22..1cb99d8b 100644
--- a/src/allmydata/web/welcome.xhtml
+++ b/src/allmydata/web/welcome.xhtml
@@ -195,6 +195,7 @@
 
       <footer>
         <p>&#169; <a href="https://tahoe-lafs.org/">Tahoe-LAFS Software Foundation 2013</a></p>
+        <p class="minutia">Page rendered at <span n:render="data" n:data="rendered_at" /></p>
         <p class="minutia" n:render="string" n:data="version"></p>
         <p class="minutia">Tahoe-LAFS code imported from: <span n:render="data" n:data="import_path" /></p>
       </footer>
-- 
2.45.2