def render_forms(self, ctx, data): forms = [] if self.node.is_readonly(): return T.div["No upload forms: directory is read-only"] if self.dirnode_children is None: return T.div["No upload forms: directory is unreadable"] mkdir = 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.input(type="submit", value="Create"), ]] forms.append(T.div(class_="freeform-form")[mkdir]) upload = 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"), ]] forms.append(T.div(class_="freeform-form")[upload]) mount = 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"), " ", T.input(type="submit", value="Attach"), ]] forms.append(T.div(class_="freeform-form")[mount]) return forms
def rend(self, context, data): context.remember(data, iformless.IBinding) from formless import configurable as conf configurable = conf.GroupConfigurable(data.boundTo, data.typedValue.iface) context.remember(configurable, iformless.IConfigurable) bindingNames = configurable.getBindingNames(context) def generateBindings(): for name in bindingNames: bnd = configurable.getBinding(context, name) renderer = iformless.IBindingRenderer(bnd, defaultBindingRenderer) renderer.isGrouped = True renderer.needsSkin = True yield tags.invisible( data=bnd, render=renderer, key=name) return getError(context), tags.form( id=keyToXMLID(context.key), enctype="multipart/form-data", action=calculatePostURL(context, data), method="post", **{'accept-charset':'utf-8'})[ tags.fieldset[ tags.legend(_class="freeform-form-label")[data.label], tags.input(type='hidden', name='_charset_'), generateBindings(), tags.input(type="submit")]]
def calculateDefaultSkin(self, context): if self.isGrouped: frm = tags.invisible butt = "" fld = tags.invisible else: frm = tags.form( id=slot("form-id"), name=slot("form-id"), action=slot("form-action"), method="post", enctype="multipart/form-data", **{"accept-charset": "utf-8"} ) butt = slot("form-button") fld = tags.fieldset[tags.input(type="hidden", name="_charset_")] ## Provide default skin since no skin was provided for us. context.tag.clear()[ frm[ fld[ tags.legend(_class="freeform-form-label")[slot("form-label")], tags.div(_class="freeform-form-description")[slot("form-description")], tags.div(_class="freeform-form-error")[slot("form-error")], slot("form-arguments"), butt, ] ] ]
def render_upload_form(self, ctx, data): # 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:"+SPACE, T.input(type="file", name="file", class_="freeform-input-file")], T.input(type="hidden", name="t", 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. # 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"), ]] return T.div[form]
def render_check_form(self, ctx, data): node = self.original quoted_uri = urllib.quote(node.get_uri()) target = self.get_root(ctx) + "/uri/" + quoted_uri if IDirectoryNode.providedBy(node): target += "/" check = T.form(action=target, method="post", enctype="multipart/form-data")[ T.fieldset[ T.input(type="hidden", name="t", value="check"), T.input(type="hidden", name="return_to", value="."), T.legend(class_="freeform-form-label")["Check on this object"], T.div[ "Verify every bit? (EXPENSIVE):", T.input(type="checkbox", name="verify"), ], T.div["Repair any problems?: ", T.input(type="checkbox", name="repair")], T.div["Add/renew lease on all shares?: ", T.input(type="checkbox", name="add-lease")], T.div["Emit results in JSON format?: ", T.input(type="checkbox", name="output", value="JSON")], T.input(type="submit", value="Check"), ]] return ctx.tag[check]
def render_upload_form(self, ctx, data): # 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:" + SPACE, T.input(type="file", name="file", class_="freeform-input-file" )], T.input(type="hidden", name="t", 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 rend(self, context, data): context.remember(data, iformless.IBinding) from formless import configurable as conf configurable = conf.GroupConfigurable(data.boundTo, data.typedValue.iface) context.remember(configurable, iformless.IConfigurable) bindingNames = configurable.getBindingNames(context) def generateBindings(): for name in bindingNames: bnd = configurable.getBinding(context, name) renderer = iformless.IBindingRenderer(bnd, defaultBindingRenderer) renderer.isGrouped = True renderer.needsSkin = True yield tags.invisible(data=bnd, render=renderer, key=name) return getError(context), tags.form( id=keyToXMLID(context.key), enctype="multipart/form-data", action=calculatePostURL(context, data), method="post", **{'accept-charset': 'utf-8' })[tags.fieldset[tags.legend( _class="freeform-form-label")[data.label], tags.input(type='hidden', name='_charset_'), generateBindings(), tags.input(type="submit")]]
def render_forms(self, ctx, data): forms = [] if self.node.is_readonly(): return T.div["No upload forms: directory is read-only"] if self.dirnode_children is None: return T.div["No upload forms: directory is unreadable"] mkdir = 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.input(type="submit", value="Create"), ]] forms.append(T.div(class_="freeform-form")[mkdir]) upload = 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"), ]] forms.append(T.div(class_="freeform-form")[upload]) mount = 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"), " ", T.input(type="submit", value="Attach"), ]] forms.append(T.div(class_="freeform-form")[mount]) return forms
def render_deep_stats_form(self, ctx, data): ophandle = base32.b2a(os.urandom(16)) deep_stats = T.form(action=".", method="post", enctype="multipart/form-data")[ T.fieldset[ T.input(type="hidden", name="t", value="start-deep-stats"), T.legend(class_="freeform-form-label")["Run a deep-stats operation (EXPENSIVE)"], T.input(type="hidden", name="ophandle", value=ophandle), T.input(type="submit", value="Deep-Stats"), ]] return ctx.tag[deep_stats]
def render_mkdir_form(self, ctx, data): # this is a form where users can create new directories form = T.form(action="uri", method="post", enctype="multipart/form-data")[ T.fieldset[ T.legend(class_="freeform-form-label")["Create a directory"], 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"), ]] return T.div[form]
def render_view_form(self, ctx, data): # this is a form where users can download files by URI, or jump to a # named directory form = T.form( action="uri", method="get", enctype="multipart/form-data")[ T.fieldset[T.legend( class_="freeform-form-label")["View a file or directory"], "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_deep_stats_form(self, ctx, data): ophandle = base32.b2a(os.urandom(16)) deep_stats = T.form( action=".", method="post", enctype="multipart/form-data")[T.fieldset[ T.input(type="hidden", name="t", value="start-deep-stats"), T.legend(class_="freeform-form-label" )["Run a deep-stats operation (EXPENSIVE)"], T.input(type="hidden", name="ophandle", value=ophandle), T.input(type="submit", value="Deep-Stats"), ]] return ctx.tag[deep_stats]
def render_download_form(self, ctx, data): # this is a form where users can download files by URI form = T.form( action="uri", method="get", enctype="multipart/form-data")[T.fieldset[ T.legend(class_="freeform-form-label")["Download a file"], T.div["Tahoe-URI to download:" + SPACE, T.input(type="text", name="uri")], T.div["Filename to download as:" + SPACE, T.input(type="text", name="filename")], T.input(type="submit", value="Download!"), ]] return T.div[form]
def render_incident_button(self, ctx, data): # this button triggers a foolscap-logging "incident" form = T.form(action="report_incident", method="post", enctype="multipart/form-data")[ 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"), " ", T.input(type="submit", value="Report!"), ]] return T.div[form]
def render_incident_button(self, ctx, data): # this button triggers a foolscap-logging "incident" form = T.form( action="report_incident", method="post", enctype="multipart/form-data")[T.fieldset[ T.legend(class_="freeform-form-label")["Report an Incident"], T.input(type="hidden", name="t", value="report-incident"), "What went wrong?:" + SPACE, T.input(type="text", name="details"), SPACE, T.input(type="submit", value="Report!"), ]] return T.div[form]
def render_view_form(self, ctx, data): # this is a form where users can download files by URI, or jump to a # named directory form = T.form(action="uri", method="get", 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"), " ", 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 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.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!")], ]] return T.div[form]
def render_download_form(self, ctx, data): # this is a form where users can download files by URI form = T.form(action="uri", method="get", enctype="multipart/form-data")[ T.fieldset[ T.legend(class_="freeform-form-label")["Download a file"], T.div["Tahoe-URI to download: ", T.input(type="text", name="uri")], T.div["Filename to download as: ", T.input(type="text", name="filename")], T.input(type="submit", value="Download!"), ]] return T.div[form]
def render_overwrite_form(self, ctx, data): node = self.original root = self.get_root(ctx) action = "%s/uri/%s" % (root, urllib.quote(node.get_uri())) done_url = "%s/uri/%s?t=info" % (root, urllib.quote(node.get_uri())) overwrite = T.form( action=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=done_url), T.legend(class_="freeform-form-label")["Overwrite"], "Upload new contents: ", T.input(type="file", name="file"), " ", T.input(type="submit", value="Replace Contents")]] return ctx.tag[overwrite]
def render_manifest_form(self, ctx, data): ophandle = base32.b2a(os.urandom(16)) manifest = T.form( action=".", method="post", enctype="multipart/form-data")[T.fieldset[ T.input(type="hidden", name="t", value="start-manifest"), T.legend(class_="freeform-form-label" )["Run a manifest operation (EXPENSIVE)"], T.div["Output Format: ", T.select(name="output")[ T.option(value="html", selected="true")["HTML"], T.option(value="text")["text"], T.option(value="json")["JSON"], ], ], T.input(type="hidden", name="ophandle", value=ophandle), T.input(type="submit", value="Manifest"), ]] return ctx.tag[manifest]
def render_overwrite_form(self, ctx, data): node = self.original root = self.get_root(ctx) action = "%s/uri/%s" % (root, urllib.quote(node.get_uri())) done_url = "%s/uri/%s?t=info" % (root, urllib.quote(node.get_uri())) overwrite = T.form(action=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=done_url), T.legend(class_="freeform-form-label")["Overwrite"], "Upload new contents: ", T.input(type="file", name="file"), " ", T.input(type="submit", value="Replace Contents") ]] return ctx.tag[overwrite]
def render_manifest_form(self, ctx, data): ophandle = base32.b2a(os.urandom(16)) manifest = T.form(action=".", method="post", enctype="multipart/form-data")[ T.fieldset[ T.input(type="hidden", name="t", value="start-manifest"), T.legend(class_="freeform-form-label")["Run a manifest operation (EXPENSIVE)"], T.div["Output Format: ", T.select(name="output") [ T.option(value="html", selected="true")["HTML"], T.option(value="text")["text"], T.option(value="json")["JSON"], ], ], T.input(type="hidden", name="ophandle", value=ophandle), T.input(type="submit", value="Manifest"), ]] return ctx.tag[manifest]
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', checked='checked') 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, 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"), ]] return T.div[form]
def render_deep_check_form(self, ctx, data): ophandle = base32.b2a(os.urandom(16)) deep_check = T.form( action=".", method="post", enctype="multipart/form-data")[T.fieldset[ T.input(type="hidden", name="t", value="start-deep-check"), T.input(type="hidden", name="return_to", value="."), T.legend(class_="freeform-form-label" )["Run a deep-check operation (EXPENSIVE)"], T.div["Verify every bit? (EVEN MORE EXPENSIVE):", T.input(type="checkbox", name="verify"), ], T.div["Repair any problems?: ", T.input(type="checkbox", name="repair")], T.div["Add/renew lease on all shares?: ", T.input(type="checkbox", name="add-lease")], T.div["Emit results in JSON format?: ", T.input(type="checkbox", name="output", value="JSON")], T.input(type="hidden", name="ophandle", value=ophandle), T.input(type="submit", value="Deep-Check"), ]] return ctx.tag[deep_check]
def render_mkdir_form(self, ctx, data): # 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"), ]] 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') 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.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!")], ]] return T.div[form]
def calculateDefaultSkin(self, context): if self.isGrouped: frm = tags.invisible butt = '' fld = tags.invisible else: frm = tags.form(id=slot('form-id'), name=slot('form-id'), action=slot('form-action'), method="post", enctype="multipart/form-data", **{'accept-charset': 'utf-8'}) butt = slot('form-button') fld = tags.fieldset[tags.input(type='hidden', name='_charset_')] ## Provide default skin since no skin was provided for us. context.tag.clear()[frm[fld[ tags.legend(_class="freeform-form-label")[slot('form-label')], tags.div( _class="freeform-form-description")[slot('form-description')], tags.div(_class="freeform-form-error")[slot('form-error')], slot('form-arguments'), butt]]]
def render_check_form(self, ctx, data): node = self.original quoted_uri = urllib.quote(node.get_uri()) target = self.get_root(ctx) + "/uri/" + quoted_uri if IDirectoryNode.providedBy(node): target += "/" check = T.form( action=target, method="post", enctype="multipart/form-data")[T.fieldset[ T.input(type="hidden", name="t", value="check"), T.input(type="hidden", name="return_to", value="."), T.legend(class_="freeform-form-label")["Check on this object"], T.div["Verify every bit? (EXPENSIVE):", T.input(type="checkbox", name="verify"), ], T.div["Repair any problems?: ", T.input(type="checkbox", name="repair")], T.div["Add/renew lease on all shares?: ", T.input(type="checkbox", name="add-lease")], T.div["Emit results in JSON format?: ", T.input(type="checkbox", name="output", value="JSON")], T.input(type="submit", value="Check"), ]] return ctx.tag[check]
def render_deep_check_form(self, ctx, data): ophandle = base32.b2a(os.urandom(16)) deep_check = T.form(action=".", method="post", enctype="multipart/form-data")[ T.fieldset[ T.input(type="hidden", name="t", value="start-deep-check"), T.input(type="hidden", name="return_to", value="."), T.legend(class_="freeform-form-label")["Run a deep-check operation (EXPENSIVE)"], T.div[ "Verify every bit? (EVEN MORE EXPENSIVE):", T.input(type="checkbox", name="verify"), ], T.div["Repair any problems?: ", T.input(type="checkbox", name="repair")], T.div["Add/renew lease on all shares?: ", T.input(type="checkbox", name="add-lease")], T.div["Emit results in JSON format?: ", T.input(type="checkbox", name="output", value="JSON")], T.input(type="hidden", name="ophandle", value=ophandle), T.input(type="submit", value="Deep-Check"), ]] return ctx.tag[deep_check]
def render_forms(self, ctx, data): forms = [] if self.node.is_readonly(): return T.div["No upload forms: directory is read-only"] if self.dirnode_children is None: return T.div["No upload forms: directory is unreadable"] 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:"+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_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:"+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_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"), ]] forms.append(T.div(class_="freeform-form")[attach_form]) return forms
def render_forms(self, ctx, data): forms = [] if self.node.is_readonly(): return T.div["No upload forms: directory is read-only"] if self.dirnode_children is None: return T.div["No upload forms: directory is unreadable"] 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:"+SPACE, T.br, T.input(type="text", name="name"), SPACE, 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]) 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:"+SPACE, T.input(type="file", name="file", class_="freeform-input-file"), SPACE, 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.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