Wed Mar 7 02:25:05 GMT 2012 Brian Warner <warner@lothar.com>
authorDaira Hopwood <daira@jacaranda.org>
Thu, 5 Sep 2013 16:57:35 +0000 (17:57 +0100)
committerDaira Hopwood <daira@jacaranda.org>
Thu, 5 Sep 2013 16:57:35 +0000 (17:57 +0100)
  * introducer web page: add CSS styling, roughly match client Welcome page

  Also add /static and the top-level /tahoe.css -type stuff to the introducer's
  web server.

src/allmydata/introducer/server.py
src/allmydata/web/introducer.xhtml
src/allmydata/web/introweb.py

index dd042a4f0fe20993f220719827fb3739a41e2ca3..10dc1a05fd1e418e8588eb2d74cb446506ffa457 100644 (file)
@@ -42,7 +42,9 @@ class IntroducerNode(node.Node):
 
         from allmydata.webish import IntroducerWebishServer
         nodeurl_path = os.path.join(self.basedir, "node.url")
-        ws = IntroducerWebishServer(self, webport, nodeurl_path)
+        staticdir = self.get_config("node", "web.static", "public_html")
+        staticdir = os.path.expanduser(staticdir)
+        ws = IntroducerWebishServer(self, webport, nodeurl_path, staticdir)
         self.add_service(ws)
 
 class IntroducerService(service.MultiService, Referenceable):
index e1a9d1819ca1e4b81e2d6b5409fbbf0aa9621665..501f78da0e05c6de087ca60fbfe7c60e22ad58f6 100644 (file)
@@ -1,65 +1,76 @@
-<html xmlns:n="http://nevow.com/ns/nevow/0.1">
-  <head>
-    <title>Tahoe-LAFS - Introducer Status</title>
-    <link href="/icon.png" rel="shortcut icon" />
-    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-  </head>
-  <body>
+<html xmlns:n="http://nevow.com/ns/nevow/0.1"><head>
+  <title>Tahoe-LAFS - Introducer Status</title>
+  <link href="/tahoe.css" rel="stylesheet" type="text/css"/>
+  <link href="/icon.png" rel="shortcut icon" />
+  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+</head><body>
 
 <h1>Welcome To The Tahoe-LAFS Introducer</h1>
 
-<h2>My Code</h2>
+<div class="section" id="this-client">
+  <h2>This Introducer</h2>
 
-<div>My nodeid: <span n:render="string" n:data="my_nodeid" /></div>
-<div>My versions: <span n:render="string" n:data="version" /></div>
-<div>Tahoe-LAFS code imported from: <span n:render="string" n:data="import_path" /></div>
-
-<br />
+  <table class="node-info table-headings-left">
+    <tr><th>My nodeid:</th> <td class="nideid mine data-chars" n:render="string" n:data="my_nodeid" /></tr>
+    <tr><th>My versions:</th> <td n:render="string" n:data="version" /></tr>
+    <tr><th>Tahoe-LAFS code imported from:</th> <td n:render="string" n:data="import_path" /></tr>
+  </table>
+</div>
 
 <div>Announcement Summary: <span n:render="announcement_summary" /></div>
 <div>Subscription Summary: <span n:render="client_summary" /></div>
 
-<h2>Service Announcements</h2>
+<br />
 
-<div>
-<table n:render="sequence" n:data="services">
+
+<div class="section">
+<h2>Service Announcements</h2>
+<table class="services table-headings-top" n:render="sequence" n:data="services">
   <tr n:pattern="header">
-    <td>PeerID / Nickname</td>
-    <td>Advertised IPs</td>
-    <td>Announced</td>
-    <td>Version</td>
-    <td>Service Name</td>
+    <th class="nickname-and-peerid">
+      <div class="service-nickname">Nickname</div>
+      <div class="nodeid data-chars">PeerID</div></th>
+    <th>Advertised IPs</th>
+    <th>Announced</th>
+    <th>Version</th>
+    <th>Service Name</th>
   </tr>
   <tr n:pattern="item" n:render="service_row">
-    <td><tt><n:slot name="peerid"/></tt></td>
-    <td><tt><n:slot name="advertised"/></tt></td>
-    <td><tt><n:slot name="announced"/></tt></td>
-    <td><tt><n:slot name="version"/></tt></td>
-    <td><tt><n:slot name="service_name"/></tt></td>
+    <td class="nickname-and-peerid">
+      <div class="nickname"><n:slot name="nickname"/></div>
+      <div class="nodeid data-chars"><n:slot name="peerid"/></div></td>
+    <td><n:slot name="advertised"/></td>
+    <td class="service-announced"><n:slot name="announced"/></td>
+    <td class="service-version"><n:slot name="version"/></td>
+    <td class="service-service-name"><n:slot name="service_name"/></td>
   </tr>
   <tr n:pattern="empty"><td>no peers!</td></tr>
 </table>
 </div>
 
-<h2>Subscribed Clients</h2>
 
 <div>
-<table n:render="sequence" n:data="subscribers">
+<h2>Subscribed Clients</h2>
+<table class="services table-headings-top" n:render="sequence" n:data="subscribers">
   <tr n:pattern="header">
-    <td>PeerID / Nickname</td>
-    <td>Advertised IPs</td>
-    <td>Connected From</td>
-    <td>Since</td>
-    <td>Version</td>
-    <td>Subscribed To</td>
+    <th class="nickname-and-peerid">
+      <div class="service-nickname">Nickname</div>
+      <div class="nodeid data-chars">PeerID</div></th>
+    <th>Advertised IPs</th>
+    <th>Connected From</th>
+    <th>Since</th>
+    <th>Version</th>
+    <th>Subscribed To</th>
   </tr>
   <tr n:pattern="item" n:render="subscriber_row">
-    <td><tt><n:slot name="peerid"/></tt></td>
-    <td><tt><n:slot name="advertised"/></tt></td>
-    <td><tt><n:slot name="connected"/></tt></td>
-    <td><tt><n:slot name="since"/></tt></td>
-    <td><tt><n:slot name="version"/></tt></td>
-    <td><tt><n:slot name="service_name"/></tt></td>
+    <td class="nickname-and-peerid">
+      <div class="nickname"><n:slot name="nickname"/></div>
+      <div class="nodeid data-chars"><n:slot name="peerid"/></div></td>
+    <td><n:slot name="advertised"/></td>
+    <td><n:slot name="connected"/></td>
+    <td class="service-since"><n:slot name="since"/></td>
+    <td class="service-version"><n:slot name="version"/></td>
+    <td class="service-service-name"><n:slot name="service_name"/></td>
   </tr>
   <tr n:pattern="empty"><td>no peers!</td></tr>
 </table>
index 28273bd7eb343b3e1dca730c71284297e17bb26b..0e25e20a043e6a047cb4af6f591c3d765d51d42e 100644 (file)
@@ -1,6 +1,8 @@
 
-import time
+import time, os
 from nevow import rend, inevow
+from nevow.static import File as nevow_File
+from nevow.util import resource_filename
 from foolscap.api import SturdyRef
 from twisted.internet import address
 import allmydata
@@ -20,6 +22,9 @@ class IntroducerRoot(rend.Page):
         self.introducer_node = introducer_node
         self.introducer_service = introducer_node.getServiceNamed("introducer")
         rend.Page.__init__(self, introducer_node)
+        static_dir = resource_filename("allmydata.web", "static")
+        for filen in os.listdir(static_dir):
+            self.putChild(filen, nevow_File(os.path.join(static_dir, filen)))
 
     def renderHTTP(self, ctx):
         t = get_arg(inevow.IRequest(ctx), "t")
@@ -104,7 +109,8 @@ class IntroducerRoot(rend.Page):
         sr = SturdyRef(furl)
         nodeid = sr.tubID
         advertised = self.show_location_hints(sr)
-        ctx.fillSlots("peerid", "%s %s" % (nodeid, nickname))
+        ctx.fillSlots("peerid", nodeid)
+        ctx.fillSlots("nickname", nickname)
         ctx.fillSlots("advertised", " ".join(advertised))
         ctx.fillSlots("connected", "?")
         TIME_FORMAT = "%H:%M:%S %d-%b-%Y"
@@ -147,7 +153,8 @@ class IntroducerRoot(rend.Page):
         sr = rref.getSturdyRef()
         # if the subscriber didn't do Tub.setLocation, nodeid will be None
         nodeid = sr.tubID or "?"
-        ctx.fillSlots("peerid", "%s %s" % (nodeid, nickname))
+        ctx.fillSlots("peerid", nodeid)
+        ctx.fillSlots("nickname", nickname)
         advertised = self.show_location_hints(sr)
         ctx.fillSlots("advertised", " ".join(advertised))
         remote_host = rref.tracker.broker.transport.getPeer()