Merge branch tarcieri/redesigned-directory-page

Closes ticket:1966 (trac)
Closes tahoe-lafs/tahoe-lafs#32 (github PR)
This commit is contained in:
Brian Warner 2014-09-02 14:01:24 -07:00
commit c4da6c91a7
3 changed files with 108 additions and 69 deletions

View File

@ -50,7 +50,7 @@ unknown_rocap = u"ro.lafs://readonly_from_the_future_ro_\u263A".encode('utf-8')
unknown_immcap = u"imm.lafs://immutable_from_the_future_imm_\u263A".encode('utf-8')
FAVICON_MARKUP = '<link href="/icon.png" rel="shortcut icon" />'
DIR_HTML_TAG = '<html lang="en">'
class FakeStatsProvider:
def get_stats(self):
@ -1522,7 +1522,7 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, testutil.ReallyEqualMixi
def test_GET_DIRECTORY_html(self):
d = self.GET(self.public_url + "/foo", followRedirect=True)
def _check(html):
self.failUnlessIn('<div class="toolbar-item"><a href="../../..">Return to Welcome page</a></div>', html)
self.failUnlessIn('<li class="toolbar-item"><a href="../../..">Return to Welcome page</a></li>', html)
self._check_upload_and_mkdir_forms(html)
self.failUnlessIn("quux", html)
d.addCallback(_check)
@ -1616,7 +1616,7 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, testutil.ReallyEqualMixi
d.addCallback(lambda res: self.GET(self.public_url + "/foo/empty/"))
def _check4(res):
self.failUnlessIn("directory is empty", res)
MKDIR_BUTTON_RE=re.compile('<input type="hidden" name="t" value="mkdir" />.*<legend class="freeform-form-label">Create a new directory in this directory</legend>.*<input type="submit" value="Create" />', re.I)
MKDIR_BUTTON_RE=re.compile('<input type="hidden" name="t" value="mkdir" />.*<legend class="freeform-form-label">Create a new directory in this directory</legend>.*<input type="submit" class="btn" value="Create" />', re.I)
self.failUnless(MKDIR_BUTTON_RE.search(res), res)
d.addCallback(_check4)
@ -5590,7 +5590,7 @@ class Grid(GridTestMixin, WebErrorMixin, ShouldFailMixin, testutil.ReallyEqualMi
d.addCallback(lambda ignored: self.GET(self.fileurls["dir-0share"]))
def _check_0shares_dir_html(body):
self.failUnlessIn("<html>", body)
self.failUnlessIn(DIR_HTML_TAG, body)
# we should see the regular page, but without the child table or
# the dirops forms
body = " ".join(body.strip().split())
@ -5613,7 +5613,7 @@ class Grid(GridTestMixin, WebErrorMixin, ShouldFailMixin, testutil.ReallyEqualMi
# and some-shares like we did for immutable files (since there
# are different sorts of advice to offer in each case). For now,
# they present the same way.
self.failUnlessIn("<html>", body)
self.failUnlessIn(DIR_HTML_TAG, body)
body = " ".join(body.strip().split())
self.failUnlessIn('href="?t=info">More info on this directory',
body)
@ -5740,7 +5740,7 @@ class Grid(GridTestMixin, WebErrorMixin, ShouldFailMixin, testutil.ReallyEqualMi
d.addCallback(_stash_dir)
d.addCallback(lambda ign: self.GET(self.dir_url, followRedirect=True))
def _check_dir_html(body):
self.failUnlessIn("<html>", body)
self.failUnlessIn(DIR_HTML_TAG, body)
self.failUnlessIn("blacklisted.txt</a>", body)
d.addCallback(_check_dir_html)
d.addCallback(lambda ign: self.GET(self.url))
@ -5764,7 +5764,7 @@ class Grid(GridTestMixin, WebErrorMixin, ShouldFailMixin, testutil.ReallyEqualMi
# We should still be able to list the parent directory, in HTML...
d.addCallback(lambda ign: self.GET(self.dir_url, followRedirect=True))
def _check_dir_html2(body):
self.failUnlessIn("<html>", body)
self.failUnlessIn(DIR_HTML_TAG, body)
self.failUnlessIn("blacklisted.txt</strike>", body)
d.addCallback(_check_dir_html2)
@ -5815,7 +5815,7 @@ class Grid(GridTestMixin, WebErrorMixin, ShouldFailMixin, testutil.ReallyEqualMi
self.child_url = "uri/"+dn.get_readonly_uri()+"/child"
d.addCallback(_get_dircap)
d.addCallback(lambda ign: self.GET(self.dir_url_base, followRedirect=True))
d.addCallback(lambda body: self.failUnlessIn("<html>", body))
d.addCallback(lambda body: self.failUnlessIn(DIR_HTML_TAG, body))
d.addCallback(lambda ign: self.GET(self.dir_url_json1))
d.addCallback(lambda res: simplejson.loads(res)) # just check it decodes
d.addCallback(lambda ign: self.GET(self.dir_url_json2))

View File

@ -686,14 +686,14 @@ class DirectoryAsHTML(rend.Page):
T.input(type='hidden', name='t', value='unlink'),
T.input(type='hidden', name='name', value=name),
T.input(type='hidden', name='when_done', value="."),
T.input(type='submit', value='unlink', name="unlink"),
T.input(type='submit', _class='btn', value='unlink', name="unlink"),
]
rename = T.form(action=here, method="get")[
T.input(type='hidden', name='t', value='rename-form'),
T.input(type='hidden', name='name', value=name),
T.input(type='hidden', name='when_done', value="."),
T.input(type='submit', value='rename/relink', name="rename"),
T.input(type='submit', _class='btn', value='rename/relink', name="rename"),
]
ctx.fillSlots("unlink", unlink)
@ -815,11 +815,13 @@ class DirectoryAsHTML(rend.Page):
T.input(type="hidden", name="t", value="mkdir"),
T.input(type="hidden", name="when_done", value="."),
T.legend(class_="freeform-form-label")["Create a new directory in this directory"],
"New directory name:"+SPACE,
"New directory name:"+SPACE, T.br,
T.input(type="text", name="name"), SPACE,
T.input(type="submit", value="Create"), SPACE*2,
mkdir_sdmf, T.label(for_='mutable-directory-sdmf')[" SDMF"], SPACE,
mkdir_mdmf, T.label(for_='mutable-directory-mdmf')[" MDMF (experimental)"],
T.div(class_="form-inline")[
mkdir_sdmf, T.label(for_='mutable-directory-sdmf')[SPACE, "SDMF"], SPACE*2,
mkdir_mdmf, T.label(for_='mutable-directory-mdmf')[SPACE, "MDMF (experimental)"]
],
T.input(type="submit", class_="btn", value="Create")
]]
forms.append(T.div(class_="freeform-form")[mkdir_form])
@ -839,25 +841,27 @@ class DirectoryAsHTML(rend.Page):
T.legend(class_="freeform-form-label")["Upload a file to this directory"],
"Choose a file to upload:"+SPACE,
T.input(type="file", name="file", class_="freeform-input-file"), SPACE,
T.input(type="submit", value="Upload"), SPACE*2,
upload_chk, T.label(for_="upload-chk") [" Immutable"], SPACE,
upload_sdmf, T.label(for_="upload-sdmf")[" SDMF"], SPACE,
upload_mdmf, T.label(for_="upload-mdmf")[" MDMF (experimental)"],
T.div(class_="form-inline")[
upload_chk, T.label(for_="upload-chk") [SPACE, "Immutable"], SPACE*2,
upload_sdmf, T.label(for_="upload-sdmf")[SPACE, "SDMF"], SPACE*2,
upload_mdmf, T.label(for_="upload-mdmf")[SPACE, "MDMF (experimental)"]
],
T.input(type="submit", class_="btn", value="Upload"), SPACE*2,
]]
forms.append(T.div(class_="freeform-form")[upload_form])
attach_form = T.form(action=".", method="post",
enctype="multipart/form-data")[
T.fieldset[
T.input(type="hidden", name="t", value="uri"),
T.input(type="hidden", name="when_done", value="."),
T.legend(class_="freeform-form-label")["Add a link to a file or directory which is already in Tahoe-LAFS."],
"New child name:"+SPACE,
T.input(type="text", name="name"), SPACE*2,
"URI of new child:"+SPACE,
T.input(type="text", name="uri"), SPACE,
T.input(type="submit", value="Attach"),
]]
T.fieldset[ T.div(class_="form-inline")[
T.input(type="hidden", name="t", value="uri"),
T.input(type="hidden", name="when_done", value="."),
T.legend(class_="freeform-form-label")["Add a link to a file or directory which is already in Tahoe-LAFS."],
"New child name:"+SPACE,
T.input(type="text", name="name"), SPACE*2, T.br,
"URI of new child:"+SPACE,
T.input(type="text", name="uri"), SPACE,
T.input(type="submit", class_="btn", value="Attach"),
]]]
forms.append(T.div(class_="freeform-form")[attach_form])
return forms

View File

@ -1,50 +1,85 @@
<html xmlns:n="http://nevow.com/ns/nevow/0.1"><head>
<title n:render="title"></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 class="tahoe-directory-page">
<!DOCTYPE html>
<html lang="en" xmlns:n="http://nevow.com/ns/nevow/0.1">
<head>
<meta charset="utf-8"/>
<title n:render="title"></title>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<meta name="description" content="Tahoe-LAFS is a free and open cloud storage engine"/>
<meta name="author" content="Tahoe-LAFS"/>
<h1 n:render="header"></h1>
<!-- Le styles -->
<link href="/css/bootstrap.css" rel="stylesheet"/>
<link href="/css/bootstrap-responsive.css" rel="stylesheet"/>
<link href="/css/new-tahoe.css" rel="stylesheet"/>
<div class="toolbar">
<div class="toolbar-item" n:render="welcome" />
<div class="toolbar-item"><a href=".">Refresh</a></div>
<!-- Le fav and touch icons -->
<link rel="shortcut icon" href="/icon.png" />
</head>
<div class="toolbar-item"><a href="?t=info">More info on this directory</a></div>
<div class="toolbar-item" n:render="show_readonly" />
</div>
<body>
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container-fluid">
<a class="brand" href="/"><img src="/img/logo.png" alt="Tahoe-LAFS"/></a>
</div>
</div>
</div>
<div n:render="try_children">
<table class="tahoe-directory" n:render="sequence" n:data="children">
<tr n:pattern="header">
<th>Type</th>
<th>Filename</th>
<th>Size</th>
<th>Times</th>
<th></th>
<th></th>
<th></th>
</tr>
<tr n:pattern="item" n:render="row">
<td><n:slot name="type"/></td>
<td><n:slot name="filename"/></td>
<td align="right"><n:slot name="size"/></td>
<td><n:slot name="times"/></td>
<td><n:slot name="unlink"/></td>
<td><n:slot name="rename"/></td>
<td><n:slot name="info"/></td>
</tr>
<div class="container-fluid">
<div class="row-fluid">
<div class="span3">
<div class="well sidebar-nav">
<ul class="nav nav-list">
<li class="toolbar-item" n:render="welcome" />
<li class="toolbar-item"><a href=".">Refresh</a></li>
<li class="toolbar-item"><a href="?t=info">More info on this directory</a></li>
<li class="toolbar-item" n:render="show_readonly" />
</ul>
</div>
</div>
<div class="span9">
<h1 n:render="header"></h1>
<tr n:pattern="empty"><td colspan="9" class="empty-marker">This directory is empty.</td></tr>
<div n:render="try_children">
<table class="table table-striped tahoe-directory" n:render="sequence" n:data="children">
<tr n:pattern="header">
<th>Type</th>
<th>Filename</th>
<th>Size</th>
<th>Times</th>
<th></th>
<th></th>
<th></th>
</tr>
<tr n:pattern="item" n:render="row">
<td><n:slot name="type"/></td>
<td><n:slot name="filename"/></td>
<td align="right"><n:slot name="size"/></td>
<td><n:slot name="times"/></td>
<td><n:slot name="unlink"/></td>
<td><n:slot name="rename"/></td>
<td><n:slot name="info"/></td>
</tr>
</table>
</div>
<tr n:pattern="empty"><td colspan="9" class="empty-marker">This directory is empty.</td></tr>
<div class="tahoe-directory-footer">
<div n:render="forms"/>
</table>
</div>
<div class="results" n:render="results"/>
</div>
<div class="tahoe-directory-footer">
<div n:render="forms"/>
</body></html>
<div class="results" n:render="results"/>
</div>
</div><!--/span-->
</div><!--/row-->
<hr/>
<footer>
<p>&#169; <a href="http://tahoe-lafs.org/">Tahoe-LAFS 2013</a></p>
</footer>
</div><!--/.fluid-container-->
</body>
</html>