mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-22 06:17:50 +00:00
Change the file upload forms on directory and welcome pages to use a 3-way radio button to select immutable, SDMF, or MDMF. Add '(experimental)' to the label for creating an MDMF directory. Also improve the spacing of form elements. refs #1547
This commit is contained in:
parent
ac780a4148
commit
978fd83856
@ -574,6 +574,8 @@ def abbreviated_dirnode(dirnode):
|
|||||||
u = from_string_dirnode(dirnode.get_uri())
|
u = from_string_dirnode(dirnode.get_uri())
|
||||||
return u.abbrev_si()
|
return u.abbrev_si()
|
||||||
|
|
||||||
|
SPACE = u"\u00A0"*2
|
||||||
|
|
||||||
class DirectoryAsHTML(rend.Page):
|
class DirectoryAsHTML(rend.Page):
|
||||||
# The remainder of this class is to render the directory into
|
# The remainder of this class is to render the directory into
|
||||||
# human+browser -oriented HTML.
|
# human+browser -oriented HTML.
|
||||||
@ -796,7 +798,7 @@ class DirectoryAsHTML(rend.Page):
|
|||||||
|
|
||||||
return ctx.tag
|
return ctx.tag
|
||||||
|
|
||||||
# XXX: Duplicated from root.py.
|
# XXX: similar to render_upload_form and render_mkdir_form in root.py.
|
||||||
def render_forms(self, ctx, data):
|
def render_forms(self, ctx, data):
|
||||||
forms = []
|
forms = []
|
||||||
|
|
||||||
@ -805,79 +807,62 @@ class DirectoryAsHTML(rend.Page):
|
|||||||
if self.dirnode_children is None:
|
if self.dirnode_children is None:
|
||||||
return T.div["No upload forms: directory is unreadable"]
|
return T.div["No upload forms: directory is unreadable"]
|
||||||
|
|
||||||
mdmf_directory_input = T.input(type='radio', name='mutable-type',
|
mkdir_sdmf = T.input(type='radio', name='format',
|
||||||
id='mutable-directory-mdmf',
|
value='sdmf', id='mkdir-sdmf',
|
||||||
value='mdmf')
|
checked='checked')
|
||||||
sdmf_directory_input = T.input(type='radio', name='mutable-type',
|
mkdir_mdmf = T.input(type='radio', name='format',
|
||||||
id='mutable-directory-sdmf',
|
value='mdmf', id='mkdir-mdmf')
|
||||||
value='sdmf', checked='checked')
|
|
||||||
mkdir = T.form(action=".", method="post",
|
mkdir_form = T.form(action=".", method="post",
|
||||||
enctype="multipart/form-data")[
|
enctype="multipart/form-data")[
|
||||||
T.fieldset[
|
T.fieldset[
|
||||||
T.input(type="hidden", name="t", value="mkdir"),
|
T.input(type="hidden", name="t", value="mkdir"),
|
||||||
T.input(type="hidden", name="when_done", value="."),
|
T.input(type="hidden", name="when_done", value="."),
|
||||||
T.legend(class_="freeform-form-label")["Create a new directory in this directory"],
|
T.legend(class_="freeform-form-label")["Create a new directory in this directory"],
|
||||||
"New directory name: ",
|
"New directory name:"+SPACE,
|
||||||
T.input(type="text", name="name"), " ",
|
T.input(type="text", name="name"), SPACE,
|
||||||
T.label(for_='mutable-directory-sdmf')["SDMF"],
|
T.input(type="submit", value="Create"), SPACE*2,
|
||||||
sdmf_directory_input,
|
mkdir_sdmf, T.label(for_='mutable-directory-sdmf')[" SDMF"], SPACE,
|
||||||
T.label(for_='mutable-directory-mdmf')["MDMF"],
|
mkdir_mdmf, T.label(for_='mutable-directory-mdmf')[" MDMF (experimental)"],
|
||||||
mdmf_directory_input,
|
|
||||||
T.input(type="submit", value="Create"),
|
|
||||||
]]
|
]]
|
||||||
forms.append(T.div(class_="freeform-form")[mkdir])
|
forms.append(T.div(class_="freeform-form")[mkdir_form])
|
||||||
|
|
||||||
# Build input elements for mutable file type. We do this outside
|
upload_chk = T.input(type='radio', name='format',
|
||||||
# of the list so we can check the appropriate format, based on
|
value='chk', id='upload-chk',
|
||||||
# the default configured in the client (which reflects the
|
|
||||||
# default configured in tahoe.cfg)
|
|
||||||
if self.default_mutable_format == MDMF_VERSION:
|
|
||||||
mdmf_input = T.input(type='radio', name='mutable-type',
|
|
||||||
id='mutable-type-mdmf', value='mdmf',
|
|
||||||
checked='checked')
|
checked='checked')
|
||||||
else:
|
upload_sdmf = T.input(type='radio', name='format',
|
||||||
mdmf_input = T.input(type='radio', name='mutable-type',
|
value='sdmf', id='upload-sdmf')
|
||||||
id='mutable-type-mdmf', value='mdmf')
|
upload_mdmf = T.input(type='radio', name='format',
|
||||||
|
value='mdmf', id='upload-mdmf')
|
||||||
|
|
||||||
if self.default_mutable_format == SDMF_VERSION:
|
upload_form = T.form(action=".", method="post",
|
||||||
sdmf_input = T.input(type='radio', name='mutable-type',
|
|
||||||
id='mutable-type-sdmf', value='sdmf',
|
|
||||||
checked="checked")
|
|
||||||
else:
|
|
||||||
sdmf_input = T.input(type='radio', name='mutable-type',
|
|
||||||
id='mutable-type-sdmf', value='sdmf')
|
|
||||||
|
|
||||||
upload = T.form(action=".", method="post",
|
|
||||||
enctype="multipart/form-data")[
|
enctype="multipart/form-data")[
|
||||||
T.fieldset[
|
T.fieldset[
|
||||||
T.input(type="hidden", name="t", value="upload"),
|
T.input(type="hidden", name="t", value="upload"),
|
||||||
T.input(type="hidden", name="when_done", value="."),
|
T.input(type="hidden", name="when_done", value="."),
|
||||||
T.legend(class_="freeform-form-label")["Upload a file to this directory"],
|
T.legend(class_="freeform-form-label")["Upload a file to this directory"],
|
||||||
"Choose a file to upload: ",
|
"Choose a file to upload:"+SPACE,
|
||||||
T.input(type="file", name="file", class_="freeform-input-file"),
|
T.input(type="file", name="file", class_="freeform-input-file"), SPACE,
|
||||||
" ",
|
T.input(type="submit", value="Upload"), SPACE*2,
|
||||||
T.input(type="submit", value="Upload"),
|
upload_chk, T.label(for_="upload-chk") [" Immutable"], SPACE,
|
||||||
" Mutable?:",
|
upload_sdmf, T.label(for_="upload-sdmf")[" SDMF"], SPACE,
|
||||||
T.input(type="checkbox", name="mutable"),
|
upload_mdmf, T.label(for_="upload-mdmf")[" MDMF (experimental)"],
|
||||||
sdmf_input, T.label(for_="mutable-type-sdmf")["SDMF"],
|
|
||||||
mdmf_input,
|
|
||||||
T.label(for_="mutable-type-mdmf")["MDMF (experimental)"],
|
|
||||||
]]
|
]]
|
||||||
forms.append(T.div(class_="freeform-form")[upload])
|
forms.append(T.div(class_="freeform-form")[upload_form])
|
||||||
|
|
||||||
mount = T.form(action=".", method="post",
|
attach_form = T.form(action=".", method="post",
|
||||||
enctype="multipart/form-data")[
|
enctype="multipart/form-data")[
|
||||||
T.fieldset[
|
T.fieldset[
|
||||||
T.input(type="hidden", name="t", value="uri"),
|
T.input(type="hidden", name="t", value="uri"),
|
||||||
T.input(type="hidden", name="when_done", value="."),
|
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."],
|
T.legend(class_="freeform-form-label")["Add a link to a file or directory which is already in Tahoe-LAFS."],
|
||||||
"New child name: ",
|
"New child name:"+SPACE,
|
||||||
T.input(type="text", name="name"), " ",
|
T.input(type="text", name="name"), SPACE*2,
|
||||||
"URI of new child: ",
|
"URI of new child:"+SPACE,
|
||||||
T.input(type="text", name="uri"), " ",
|
T.input(type="text", name="uri"), SPACE,
|
||||||
T.input(type="submit", value="Attach"),
|
T.input(type="submit", value="Attach"),
|
||||||
]]
|
]]
|
||||||
forms.append(T.div(class_="freeform-form")[mount])
|
forms.append(T.div(class_="freeform-form")[attach_form])
|
||||||
return forms
|
return forms
|
||||||
|
|
||||||
def render_results(self, ctx, data):
|
def render_results(self, ctx, data):
|
||||||
|
@ -12,7 +12,7 @@ import allmydata # to display import path
|
|||||||
from allmydata import get_package_versions_string
|
from allmydata import get_package_versions_string
|
||||||
from allmydata import provisioning
|
from allmydata import provisioning
|
||||||
from allmydata.util import idlib, log
|
from allmydata.util import idlib, log
|
||||||
from allmydata.interfaces import IFileNode, MDMF_VERSION, SDMF_VERSION
|
from allmydata.interfaces import IFileNode
|
||||||
from allmydata.web import filenode, directory, unlinked, status, operations
|
from allmydata.web import filenode, directory, unlinked, status, operations
|
||||||
from allmydata.web import reliability, storage
|
from allmydata.web import reliability, storage
|
||||||
from allmydata.web.common import abbreviate_size, getxmlfile, WebError, \
|
from allmydata.web.common import abbreviate_size, getxmlfile, WebError, \
|
||||||
@ -150,6 +150,8 @@ class NoReliability(rend.Page):
|
|||||||
</html>
|
</html>
|
||||||
''')
|
''')
|
||||||
|
|
||||||
|
SPACE = u"\u00A0"*2
|
||||||
|
|
||||||
class Root(rend.Page):
|
class Root(rend.Page):
|
||||||
|
|
||||||
addSlash = True
|
addSlash = True
|
||||||
@ -309,9 +311,9 @@ class Root(rend.Page):
|
|||||||
enctype="multipart/form-data")[
|
enctype="multipart/form-data")[
|
||||||
T.fieldset[
|
T.fieldset[
|
||||||
T.legend(class_="freeform-form-label")["Download a file"],
|
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.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="text", name="filename")],
|
||||||
T.input(type="submit", value="Download!"),
|
T.input(type="submit", value="Download!"),
|
||||||
]]
|
]]
|
||||||
@ -324,68 +326,54 @@ class Root(rend.Page):
|
|||||||
enctype="multipart/form-data")[
|
enctype="multipart/form-data")[
|
||||||
T.fieldset[
|
T.fieldset[
|
||||||
T.legend(class_="freeform-form-label")["View a file or directory"],
|
T.legend(class_="freeform-form-label")["View a file or directory"],
|
||||||
"Tahoe-URI to view: ",
|
"Tahoe-URI to view:"+SPACE,
|
||||||
T.input(type="text", name="uri"), " ",
|
T.input(type="text", name="uri"), SPACE*2,
|
||||||
T.input(type="submit", value="View!"),
|
T.input(type="submit", value="View!"),
|
||||||
]]
|
]]
|
||||||
return T.div[form]
|
return T.div[form]
|
||||||
|
|
||||||
def render_upload_form(self, ctx, data):
|
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.
|
||||||
# for mutable files, users can choose the format by selecting
|
|
||||||
# MDMF or SDMF from a radio button. They can also configure a
|
|
||||||
# default format in tahoe.cfg, which they rightly expect us to
|
|
||||||
# obey. we convey to them that we are obeying their choice by
|
|
||||||
# ensuring that the one that they've chosen is selected in the
|
|
||||||
# interface.
|
|
||||||
if self.client.mutable_file_default == MDMF_VERSION:
|
|
||||||
mdmf_input = T.input(type='radio', name='mutable-type',
|
|
||||||
value='mdmf', id='mutable-type-mdmf',
|
|
||||||
checked='checked')
|
|
||||||
else:
|
|
||||||
mdmf_input = T.input(type='radio', name='mutable-type',
|
|
||||||
value='mdmf', id='mutable-type-mdmf')
|
|
||||||
|
|
||||||
if self.client.mutable_file_default == SDMF_VERSION:
|
upload_chk = T.input(type='radio', name='format',
|
||||||
sdmf_input = T.input(type='radio', name='mutable-type',
|
value='chk', id='upload-chk',
|
||||||
value='sdmf', id='mutable-type-sdmf',
|
|
||||||
checked='checked')
|
checked='checked')
|
||||||
else:
|
upload_sdmf = T.input(type='radio', name='format',
|
||||||
sdmf_input = T.input(type='radio', name='mutable-type',
|
value='sdmf', id='upload-sdmf')
|
||||||
value='sdmf', id='mutable-type-sdmf')
|
upload_mdmf = T.input(type='radio', name='format',
|
||||||
|
value='mdmf', id='upload-mdmf')
|
||||||
|
|
||||||
form = T.form(action="uri", method="post",
|
form = T.form(action="uri", method="post",
|
||||||
enctype="multipart/form-data")[
|
enctype="multipart/form-data")[
|
||||||
T.fieldset[
|
T.fieldset[
|
||||||
T.legend(class_="freeform-form-label")["Upload a file"],
|
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="file", name="file", class_="freeform-input-file")],
|
||||||
T.input(type="hidden", name="t", value="upload"),
|
T.input(type="hidden", name="t", value="upload"),
|
||||||
T.div[T.input(type="checkbox", name="mutable"), T.label(for_="mutable")["Create mutable file"],
|
T.div[upload_chk, T.label(for_="upload-chk") [" Immutable"], SPACE,
|
||||||
sdmf_input, T.label(for_="mutable-type-sdmf")["SDMF"],
|
upload_sdmf, T.label(for_="upload-sdmf")[" SDMF"], SPACE,
|
||||||
mdmf_input,
|
upload_mdmf, T.label(for_="upload-mdmf")[" MDMF (experimental)"], SPACE*2,
|
||||||
T.label(for_='mutable-type-mdmf')['MDMF (experimental)'],
|
T.input(type="submit", value="Upload!")],
|
||||||
" ", T.input(type="submit", value="Upload!")],
|
|
||||||
]]
|
]]
|
||||||
return T.div[form]
|
return T.div[form]
|
||||||
|
|
||||||
def render_mkdir_form(self, ctx, data):
|
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.
|
||||||
mdmf_input = T.input(type='radio', name='mutable-type',
|
# Users can choose SDMF or MDMF from a radio button.
|
||||||
value='mdmf', id='mutable-directory-mdmf')
|
|
||||||
sdmf_input = T.input(type='radio', name='mutable-type',
|
mkdir_sdmf = T.input(type='radio', name='format',
|
||||||
value='sdmf', id='mutable-directory-sdmf',
|
value='sdmf', id='mkdir-sdmf',
|
||||||
checked='checked')
|
checked='checked')
|
||||||
|
mkdir_mdmf = T.input(type='radio', name='format',
|
||||||
|
value='mdmf', id='mkdir-mdmf')
|
||||||
|
|
||||||
form = T.form(action="uri", method="post",
|
form = T.form(action="uri", method="post",
|
||||||
enctype="multipart/form-data")[
|
enctype="multipart/form-data")[
|
||||||
T.fieldset[
|
T.fieldset[
|
||||||
T.legend(class_="freeform-form-label")["Create a directory"],
|
T.legend(class_="freeform-form-label")["Create a directory"],
|
||||||
T.label(for_='mutable-directory-sdmf')["SDMF"],
|
mkdir_sdmf, T.label(for_='mkdir-sdmf')[" SDMF"], SPACE,
|
||||||
sdmf_input,
|
mkdir_mdmf, T.label(for_='mkdir-mdmf')[" MDMF (experimental)"], SPACE*2,
|
||||||
T.label(for_='mutable-directory-mdmf')["MDMF"],
|
|
||||||
mdmf_input,
|
|
||||||
T.input(type="hidden", name="t", value="mkdir"),
|
T.input(type="hidden", name="t", value="mkdir"),
|
||||||
T.input(type="hidden", name="redirect_to_result", value="true"),
|
T.input(type="hidden", name="redirect_to_result", value="true"),
|
||||||
T.input(type="submit", value="Create a directory"),
|
T.input(type="submit", value="Create a directory"),
|
||||||
@ -399,8 +387,8 @@ class Root(rend.Page):
|
|||||||
T.fieldset[
|
T.fieldset[
|
||||||
T.legend(class_="freeform-form-label")["Report an Incident"],
|
T.legend(class_="freeform-form-label")["Report an Incident"],
|
||||||
T.input(type="hidden", name="t", value="report-incident"),
|
T.input(type="hidden", name="t", value="report-incident"),
|
||||||
"What went wrong?: ",
|
"What went wrong?:"+SPACE,
|
||||||
T.input(type="text", name="details"), " ",
|
T.input(type="text", name="details"), SPACE,
|
||||||
T.input(type="submit", value="Report!"),
|
T.input(type="submit", value="Report!"),
|
||||||
]]
|
]]
|
||||||
return T.div[form]
|
return T.div[form]
|
||||||
|
Loading…
Reference in New Issue
Block a user