From e27423e4a946477bbe80869fd5485825d9a515bf Mon Sep 17 00:00:00 2001 From: Brian Warner <warner@lothar.com> Date: Tue, 6 Mar 2012 18:25:05 -0800 Subject: [PATCH] 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 | 4 +- src/allmydata/web/introducer.xhtml | 91 +++++++++++++++++------------- src/allmydata/web/introweb.py | 13 ++++- 3 files changed, 64 insertions(+), 44 deletions(-) diff --git a/src/allmydata/introducer/server.py b/src/allmydata/introducer/server.py index dd042a4f..10dc1a05 100644 --- a/src/allmydata/introducer/server.py +++ b/src/allmydata/introducer/server.py @@ -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): diff --git a/src/allmydata/web/introducer.xhtml b/src/allmydata/web/introducer.xhtml index e1a9d181..501f78da 100644 --- a/src/allmydata/web/introducer.xhtml +++ b/src/allmydata/web/introducer.xhtml @@ -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> diff --git a/src/allmydata/web/introweb.py b/src/allmydata/web/introweb.py index 28273bd7..0e25e20a 100644 --- a/src/allmydata/web/introweb.py +++ b/src/allmydata/web/introweb.py @@ -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() -- 2.45.2