From: david-sarah Date: Sun, 2 Oct 2011 03:45:03 +0000 (-0700) Subject: Change the file upload forms on directory and welcome pages to use a 3-way radio... X-Git-Url: https://git.rkrishnan.org/pf/content/en/footer/legal.html?a=commitdiff_plain;h=978fd838568d06d1e8b2caf588809258d371a17e;p=tahoe-lafs%2Ftahoe-lafs.git 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 --- diff --git a/src/allmydata/web/directory.py b/src/allmydata/web/directory.py index b04cbe75..c1ecec6c 100644 --- a/src/allmydata/web/directory.py +++ b/src/allmydata/web/directory.py @@ -574,6 +574,8 @@ def abbreviated_dirnode(dirnode): u = from_string_dirnode(dirnode.get_uri()) return u.abbrev_si() +SPACE = u"\u00A0"*2 + class DirectoryAsHTML(rend.Page): # The remainder of this class is to render the directory into # human+browser -oriented HTML. @@ -796,7 +798,7 @@ class DirectoryAsHTML(rend.Page): 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): forms = [] @@ -805,79 +807,62 @@ class DirectoryAsHTML(rend.Page): if self.dirnode_children is None: return T.div["No upload forms: directory is unreadable"] - mdmf_directory_input = T.input(type='radio', name='mutable-type', - id='mutable-directory-mdmf', - value='mdmf') - sdmf_directory_input = T.input(type='radio', name='mutable-type', - id='mutable-directory-sdmf', - value='sdmf', checked='checked') - mkdir = T.form(action=".", method="post", - enctype="multipart/form-data")[ + 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') + + mkdir_form = T.form(action=".", method="post", + enctype="multipart/form-data")[ T.fieldset[ 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: ", - T.input(type="text", name="name"), " ", - T.label(for_='mutable-directory-sdmf')["SDMF"], - sdmf_directory_input, - T.label(for_='mutable-directory-mdmf')["MDMF"], - mdmf_directory_input, - T.input(type="submit", value="Create"), + "New directory name:"+SPACE, + 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)"], ]] - forms.append(T.div(class_="freeform-form")[mkdir]) - - # Build input elements for mutable file type. We do this outside - # of the list so we can check the appropriate format, based on - # 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') - else: - mdmf_input = T.input(type='radio', name='mutable-type', - id='mutable-type-mdmf', value='mdmf') - - if self.default_mutable_format == SDMF_VERSION: - 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")[ + forms.append(T.div(class_="freeform-form")[mkdir_form]) + + 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') + + upload_form = T.form(action=".", method="post", + enctype="multipart/form-data")[ T.fieldset[ T.input(type="hidden", name="t", value="upload"), T.input(type="hidden", name="when_done", value="."), T.legend(class_="freeform-form-label")["Upload a file to this directory"], - "Choose a file to upload: ", - T.input(type="file", name="file", class_="freeform-input-file"), - " ", - T.input(type="submit", value="Upload"), - " Mutable?:", - T.input(type="checkbox", name="mutable"), - sdmf_input, T.label(for_="mutable-type-sdmf")["SDMF"], - mdmf_input, - T.label(for_="mutable-type-mdmf")["MDMF (experimental)"], + "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)"], ]] - forms.append(T.div(class_="freeform-form")[upload]) + forms.append(T.div(class_="freeform-form")[upload_form]) - mount = T.form(action=".", method="post", - enctype="multipart/form-data")[ + 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: ", - T.input(type="text", name="name"), " ", - "URI of new child: ", - T.input(type="text", name="uri"), " ", + "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"), ]] - forms.append(T.div(class_="freeform-form")[mount]) + forms.append(T.div(class_="freeform-form")[attach_form]) return forms def render_results(self, ctx, data): diff --git a/src/allmydata/web/root.py b/src/allmydata/web/root.py index 00495d89..b669d50e 100644 --- a/src/allmydata/web/root.py +++ b/src/allmydata/web/root.py @@ -12,7 +12,7 @@ import allmydata # to display import path from allmydata import get_package_versions_string from allmydata import provisioning 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 reliability, storage from allmydata.web.common import abbreviate_size, getxmlfile, WebError, \ @@ -150,6 +150,8 @@ class NoReliability(rend.Page): ''') +SPACE = u"\u00A0"*2 + class Root(rend.Page): addSlash = True @@ -309,9 +311,9 @@ class Root(rend.Page): 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!"), ]] @@ -324,68 +326,54 @@ class Root(rend.Page): 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 - # - # 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: - sdmf_input = T.input(type='radio', name='mutable-type', - value='sdmf', id='mutable-type-sdmf', - checked='checked') - else: - sdmf_input = T.input(type='radio', name='mutable-type', - value='sdmf', id='mutable-type-sdmf') + # 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"], - sdmf_input, T.label(for_="mutable-type-sdmf")["SDMF"], - mdmf_input, - T.label(for_='mutable-type-mdmf')['MDMF (experimental)'], - " ", 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 - mdmf_input = T.input(type='radio', name='mutable-type', - value='mdmf', id='mutable-directory-mdmf') - sdmf_input = T.input(type='radio', name='mutable-type', - value='sdmf', id='mutable-directory-sdmf', + # 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"], - T.label(for_='mutable-directory-sdmf')["SDMF"], - sdmf_input, - T.label(for_='mutable-directory-mdmf')["MDMF"], - mdmf_input, + 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"), @@ -399,8 +387,8 @@ class Root(rend.Page): 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]