from allmydata.web import filenode, directory, unlinked, status, operations
from allmydata.web import reliability, storage
from allmydata.web.common import abbreviate_size, getxmlfile, WebError, \
- get_arg, RenderMixin, boolean_of_arg
+ get_arg, RenderMixin, get_format, get_mutable_type
class URIHandler(RenderMixin, rend.Page):
# "PUT /uri?t=mkdir" to create an unlinked directory
t = get_arg(req, "t", "").strip()
if t == "":
- mutable = boolean_of_arg(get_arg(req, "mutable", "false").strip())
- if mutable:
- return unlinked.PUTUnlinkedSSK(req, self.client)
+ file_format = get_format(req, "CHK")
+ mutable_type = get_mutable_type(file_format)
+ if mutable_type is not None:
+ return unlinked.PUTUnlinkedSSK(req, self.client, mutable_type)
else:
return unlinked.PUTUnlinkedCHK(req, self.client)
if t == "mkdir":
req = IRequest(ctx)
t = get_arg(req, "t", "").strip()
if t in ("", "upload"):
- mutable = bool(get_arg(req, "mutable", "").strip())
- if mutable:
- return unlinked.POSTUnlinkedSSK(req, self.client)
+ file_format = get_format(req)
+ mutable_type = get_mutable_type(file_format)
+ if mutable_type is not None:
+ return unlinked.POSTUnlinkedSSK(req, self.client, mutable_type)
else:
return unlinked.POSTUnlinkedCHK(req, self.client)
if t == "mkdir":
</html>
''')
+SPACE = u"\u00A0"*2
+
class Root(rend.Page):
addSlash = True
self.child_named = FileHandler(client)
self.child_status = status.Status(client.get_history())
self.child_statistics = status.Statistics(client.stats_provider)
+ def f(name):
+ return nevow_File(resource_filename('allmydata.web', name))
+ self.putChild("download_status_timeline.js", f("download_status_timeline.js"))
+ self.putChild("jquery-1.6.1.min.js", f("jquery-1.6.1.min.js"))
+ self.putChild("protovis-3.3.1.min.js", f("protovis-3.3.1.min.js"))
def child_helper_status(self, ctx):
# the Helper isn't attached until after the Tub starts, so this child
def data_services(self, ctx, data):
sb = self.client.get_storage_broker()
- return sb.get_known_servers()
+ return sorted(sb.get_known_servers(), key=lambda s: s.get_serverid())
def render_service_row(self, ctx, server):
nodeid = server.get_serverid()
- ctx.fillSlots("peerid", idlib.nodeid_b2a(nodeid))
+ ctx.fillSlots("peerid", server.get_longname())
ctx.fillSlots("nickname", server.get_nickname())
rhost = server.get_remote_host()
if rhost:
enctype="multipart/form-data")[
T.fieldset[
T.legend(class_="freeform-form-label")["Download a file"],
- T.div["Tahoe-URI to download: ",
+ T.div["Tahoe-URI to download:"+SPACE,
T.input(type="text", name="uri")],
- T.div["Filename to download as: ",
+ T.div["Filename to download as:"+SPACE,
T.input(type="text", name="filename")],
T.input(type="submit", value="Download!"),
]]
enctype="multipart/form-data")[
T.fieldset[
T.legend(class_="freeform-form-label")["View a file or directory"],
- "Tahoe-URI to view: ",
- T.input(type="text", name="uri"), " ",
+ "Tahoe-URI to view:"+SPACE,
+ T.input(type="text", name="uri"), SPACE*2,
T.input(type="submit", value="View!"),
]]
return T.div[form]
def render_upload_form(self, ctx, data):
- # this is a form where users can upload unlinked files
+ # This is a form where users can upload unlinked files.
+ # Users can choose immutable, SDMF, or MDMF from a radio button.
+
+ upload_chk = T.input(type='radio', name='format',
+ value='chk', id='upload-chk',
+ checked='checked')
+ upload_sdmf = T.input(type='radio', name='format',
+ value='sdmf', id='upload-sdmf')
+ upload_mdmf = T.input(type='radio', name='format',
+ value='mdmf', id='upload-mdmf')
+
form = T.form(action="uri", method="post",
enctype="multipart/form-data")[
T.fieldset[
T.legend(class_="freeform-form-label")["Upload a file"],
- T.div["Choose a file: ",
+ T.div["Choose a file:"+SPACE,
T.input(type="file", name="file", class_="freeform-input-file")],
T.input(type="hidden", name="t", value="upload"),
- T.div[T.input(type="checkbox", name="mutable"), T.label(for_="mutable")["Create mutable file"],
- " ", T.input(type="submit", value="Upload!")],
+ T.div[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)"], SPACE*2,
+ T.input(type="submit", value="Upload!")],
]]
return T.div[form]
def render_mkdir_form(self, ctx, data):
- # this is a form where users can create new directories
+ # This is a form where users can create new directories.
+ # Users can choose SDMF or MDMF from a radio button.
+
+ mkdir_sdmf = T.input(type='radio', name='format',
+ value='sdmf', id='mkdir-sdmf',
+ checked='checked')
+ mkdir_mdmf = T.input(type='radio', name='format',
+ value='mdmf', id='mkdir-mdmf')
+
form = T.form(action="uri", method="post",
enctype="multipart/form-data")[
T.fieldset[
T.legend(class_="freeform-form-label")["Create a directory"],
+ mkdir_sdmf, T.label(for_='mkdir-sdmf')[" SDMF"], SPACE,
+ mkdir_mdmf, T.label(for_='mkdir-mdmf')[" MDMF (experimental)"], SPACE*2,
T.input(type="hidden", name="t", value="mkdir"),
T.input(type="hidden", name="redirect_to_result", value="true"),
T.input(type="submit", value="Create a directory"),
T.fieldset[
T.legend(class_="freeform-form-label")["Report an Incident"],
T.input(type="hidden", name="t", value="report-incident"),
- "What went wrong?: ",
- T.input(type="text", name="details"), " ",
+ "What went wrong?:"+SPACE,
+ T.input(type="text", name="details"), SPACE,
T.input(type="submit", value="Report!"),
]]
return T.div[form]