Permalink
Browse files

Redesigned Welcome page using Twitter Bootstrap CSS.

Author: Tony Arcieri <tarcieri>
Signed-off-by: David-Sarah Hopwood <david-sarah@jacaranda.org>
  • Loading branch information...
1 parent 427193d commit 709be93a29e20026e61a436dac3fa1c160e9cef2 @daira daira committed Mar 15, 2013
@@ -1,6 +1,8 @@
+
from base64 import b32encode
-import os, sys, time, simplejson
+import os, re, sys, time, simplejson
from cStringIO import StringIO
+
from twisted.trial import unittest
from twisted.internet import defer
from twisted.internet import threads # CLI tests use deferToThread
@@ -1096,26 +1098,23 @@ def _test_web(self, res):
public = "uri/" + self._root_directory_uri
d = getPage(base)
def _got_welcome(page):
- # XXX This test is oversensitive to formatting
- expected = "Connected to <span>%d</span>\n of <span>%d</span> known storage servers:" % (self.numclients, self.numclients)
- self.failUnless(expected in page,
- "I didn't see the right 'connected storage servers'"
- " message in: %s" % page
- )
- expected = "<th>My nodeid:</th> <td class=\"nodeid mine data-chars\">%s</td>" % (b32encode(self.clients[0].nodeid).lower(),)
- self.failUnless(expected in page,
- "I didn't see the right 'My nodeid' message "
- "in: %s" % page)
+ html = page.replace('\n', ' ')
+ connected_re = "Connected to <span>%d</span>[ ]*of <span>%d</span> known storage servers" % (self.numclients, self.numclients)
+ self.failUnless(re.search(connected_re, html),
+ "I didn't see the right '%s' message in:\n%s" % (connected_re, page))
+ nodeid_re = "<th>Node ID:</th>[ ]*<td>%s</td>" % (re.escape(b32encode(self.clients[0].nodeid).lower()),)
+ self.failUnless(re.search(nodeid_re, html),
+ "I didn't see the right '%s' message in:\n%s" % (nodeid_re, page))
self.failUnless("Helper: 0 active uploads" in page)
d.addCallback(_got_welcome)
d.addCallback(self.log, "done with _got_welcome")
# get the welcome page from the node that uses the helper too
d.addCallback(lambda res: getPage(self.helper_webish_url))
def _got_welcome_helper(page):
- self.failUnless("Connected to helper?: <span>yes</span>" in page,
- page)
- self.failUnless("Not running helper" in page)
+ html = page.replace('\n', ' ')
+ self.failUnless(re.search('<div class="status-indicator connected-yes"></div>[ ]*Helper', html), page)
+ self.failUnlessIn("Not running helper", page)
d.addCallback(_got_welcome_helper)
d.addCallback(lambda res: getPage(base + public))
@@ -600,14 +600,15 @@ def test_create(self):
def test_welcome(self):
d = self.GET("/")
def _check(res):
- self.failUnlessIn('Welcome to Tahoe-LAFS', res)
+ self.failUnlessIn('<title>Tahoe-LAFS - Welcome</title>', res)
self.failUnlessIn(FAVICON_MARKUP, res)
- self.failUnlessIn('href="https://tahoe-lafs.org/"', res)
- self.failUnlessIn('<a href="status/">Recent and Active Operations</a>', res)
+ 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)
res_u = res.decode('utf-8')
- self.failUnlessIn(u'<th>My nickname:</th> <td class="nickname mine">fake_nickname \u263A</td></tr>', res_u)
+ self.failUnlessIn(u'<td>fake_nickname \u263A</td>', res_u)
self.failUnlessIn(u'<div class="nickname">other_nickname \u263B</div>', res_u)
+ self.failUnlessIn(u'\u00A9 <a href="https://tahoe-lafs.org/">Tahoe-LAFS Software Foundation', res_u)
self.s.basedir = 'web/test_welcome'
fileutil.make_dirs("web/test_welcome")
@@ -624,26 +625,32 @@ def _set_no_helper(ign):
self.s.uploader.helper_furl = None
return self.GET("/")
d.addCallback(_set_no_helper)
- d.addCallback(lambda res:
- self.failUnlessIn('Connected to helper?: <span>not configured</span>', res))
+ def _check_no_helper(res):
+ html = res.replace('\n', ' ')
+ self.failUnless(re.search('<div class="status-indicator connected-not-configured"></div>[ ]*Helper', html), res)
+ d.addCallback(_check_no_helper)
# enable helper, not connected
def _set_helper_not_connected(ign):
self.s.uploader.helper_furl = "pb://someHelper"
self.s.uploader.helper_connected = False
return self.GET("/")
d.addCallback(_set_helper_not_connected)
- d.addCallback(lambda res:
- self.failUnlessIn('Connected to helper?: <span>no</span>', res))
+ def _check_helper_not_connected(res):
+ html = res.replace('\n', ' ')
+ self.failUnless(re.search('<div class="status-indicator connected-no"></div>[ ]*Helper', html), res)
+ d.addCallback(_check_helper_not_connected)
# enable helper, connected
def _set_helper_connected(ign):
self.s.uploader.helper_furl = "pb://someHelper"
self.s.uploader.helper_connected = True
return self.GET("/")
d.addCallback(_set_helper_connected)
- d.addCallback(lambda res:
- self.failUnlessIn('Connected to helper?: <span>yes</span>', res))
+ def _check_helper_connected(res):
+ html = res.replace('\n', ' ')
+ self.failUnless(re.search('<div class="status-indicator connected-yes"></div>[ ]*Helper', html), res)
+ d.addCallback(_check_helper_connected)
return d
def test_storage(self):
@@ -3186,12 +3193,13 @@ def test_welcome_page_mkdir_button(self):
d = self.GET("/")
def _after_get_welcome_page(res):
MKDIR_BUTTON_RE = re.compile(
- '<form action="([^"]*)" method="post".*?'
- '<input type="hidden" name="t" value="([^"]*)" />'
- '<input type="hidden" name="([^"]*)" value="([^"]*)" />'
- '<input type="submit" value="Create a directory" />',
- re.I)
- mo = MKDIR_BUTTON_RE.search(res)
+ '<form action="([^"]*)" method="post".*'
+ '<input type="hidden" name="t" value="([^"]*)" />[ ]*'
+ '<input type="hidden" name="([^"]*)" value="([^"]*)" />[ ]*'
+ '<input type="submit" class="btn" value="Create a directory[^"]*" />')
+ html = res.replace('\n', ' ')
+ mo = MKDIR_BUTTON_RE.search(html)
+ self.failUnless(mo, html)
formaction = mo.group(1)
formt = mo.group(2)
formaname = mo.group(3)
View
@@ -255,17 +255,20 @@ def render_service_row(self, ctx, server):
rhost_s = "%s:%d" % (rhost.host, rhost.port)
else:
rhost_s = str(rhost)
- connected = "Yes: to " + rhost_s
+ addr = rhost_s
+ connected = "yes"
since = server.get_last_connect_time()
else:
- connected = "No"
+ addr = "N/A"
+ connected = "no"
since = server.get_last_loss_time()
announced = server.get_announcement_time()
announcement = server.get_announcement()
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))
ctx.fillSlots("since", time.strftime(TIME_FORMAT,
@@ -357,10 +360,9 @@ def render_incident_button(self, ctx, data):
form = T.form(action="report_incident", method="post",
enctype="multipart/form-data")[
T.fieldset[
- T.legend(class_="freeform-form-label")["Report an Incident"],
T.input(type="hidden", name="t", value="report-incident"),
- "What went wrong?:"+SPACE,
+ "What went wrong?"+SPACE,
T.input(type="text", name="details"), SPACE,
- T.input(type="submit", value="Report!"),
+ T.input(type="submit", value=u"Report \u00BB"),
]]
return T.div[form]
Oops, something went wrong.

0 comments on commit 709be93

Please sign in to comment.