Exemple #1
0
    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]
Exemple #2
0
    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]
Exemple #3
0
    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]
Exemple #4
0
class NodeLocationSubElement2(LiveElement):
    docFactory = loaders.stan(
        tags.div(render=tags.directive('liveElement'))[
            tags.label(_class='bar', _for="username"),
            tags.input(_class='bar', id='username')])

    def getDynamicWidget(self):
        """
        Return a widget dynamically for us to have more fun with.
        """
        e = NodeLocationSubElement1()
        e.setFragmentParent(self)
        return e

    expose(getDynamicWidget)

    def getNodeInsertedHelper(self):
        """
        Return a dynamically instantiated NodeInsertedHelper to play with.
        """
        e = NodeInsertedHelper()
        e.setFragmentParent(self)
        return e

    expose(getNodeInsertedHelper)
Exemple #5
0
    def test_athenaIdRewriting(self):
        """
        Test that IDs are correctly rewritten in id, for, and headers
        attributes.
        """
        tag = [tags.label(_for='foo'),
               tags.input(id='foo'),
               tags.th(headers=''),
               tags.th(headers='foo'),
               tags.td(headers='foo bar'),
               tags.td(headers='foo bar baz')]
        element = athena.LiveElement(docFactory=loaders.stan(tag))
        page = athena.LivePage(docFactory=loaders.stan(element))
        element.setFragmentParent(page)

        def _verifyRendering(result):
            self.assertIn('<input id="athenaid:%s-foo"' % (element._athenaID,), result)
            self.assertIn('<label for="athenaid:%s-foo"' % (element._athenaID,), result)
            self.assertIn('<th headers=""', result)
            self.assertIn('<th headers="athenaid:%s-foo"' % (
                element._athenaID,), result)
            self.assertIn('<td headers="athenaid:%s-foo athenaid:%s-bar"' % (
                element._athenaID, element._athenaID), result)
            self.assertIn('<td headers="athenaid:%s-foo athenaid:%s-bar athenaid:%s-baz"' % (
                element._athenaID, element._athenaID, element._athenaID), result)

        return renderLivePage(page).addCallback(_verifyRendering)
Exemple #6
0
 def renderOption(ctx, itemKey, itemLabel, num, selected):
     cssid = render_cssid(key, num)
     tag = T.input(name=key, type='radio', id=cssid, value=itemKey)
     if selected:
         tag = tag(checked='checked')
     if disabled:
         tag = tag(disabled='disabled')
     return tag, ' ', T.label(for_=cssid)[itemLabel], T.br
Exemple #7
0
 def renderOption(ctx, itemKey, itemLabel, num, selected):
     cssid = render_cssid(key, num)
     tag = T.input(name=key, type='radio', id=cssid, value=itemKey)
     if selected:
         tag = tag(checked='checked')
     if disabled:
         tag = tag(disabled='disabled')
     return tag, ' ', T.label(for_=cssid)[itemLabel], T.br
 def _radios():
     for choice in data.rtype.choices:
         yield T.label(for_=choice)[choice]
         yield T.input(type='radio', name='model-radio-%s' % hash(self),
                 value=choice, class_='model-radio')[
                 athena.handler(event='onclick', handler='changed')
                       ]
         yield T.br
Exemple #9
0
 def renderImmutable(self, ctx, key, args, errors):
     values = ('', '')
     return [
         T.input(type='password', name=key, id=render_cssid(key), value=values[0], class_='readonly', readonly='readonly'),
         T.br,
         T.label(for_=render_cssid(key, 'confirm'))[' Confirm '],
         T.input(type='password', name=key, id=render_cssid(key, 'confirm'),
                 value=values[1], class_='readonly', readonly='readonly')
     ]
Exemple #10
0
class MultiFieldFragment(rend.Fragment):
    """A fragment for rendering MultiFields.
	"""
    docFactory = loaders.stan(
        T.div(class_=T.slot("class"), render=T.directive("multifield"))[
            T.label(for_=T.slot('id'))[T.slot('label')],
            T.div(class_="multiinputs",
                  id=T.slot('id'),
                  render=T.directive("childFields")),
            T.div(class_='description')[T.slot('description')],
            T.slot('message')])

    def __init__(self, multiField):
        rend.Fragment.__init__(self)
        self.multiField = multiField

    def render_childFields(self, ctx, data):
        formData = iformal.IFormData(ctx)
        formErrors = iformal.IFormErrors(ctx, None)

        for field in self.multiField.items:
            widget = field.makeWidget()
            if field.type.immutable:
                render = widget.renderImmutable
            else:
                render = widget.render
            cssClass = " ".join(s for s in (field.cssClass, "inmulti") if s)
            ctx.tag[T.span(class_=cssClass)[render(
                ctx, field.key, formData, formErrors)(class_=cssClass,
                                                      title=field.description
                                                      or "")]]
        return ctx.tag

    def _getMessageElement(self, ctx):
        errors = []
        formErrors = iformal.IFormErrors(ctx, None)
        if formErrors is not None:
            for field in self.multiField.items:
                err = formErrors.getFieldError(field.key)
                if err is not None:
                    errors.append(err.message)
        if errors:
            return T.div(class_='message')["; ".join(errors)]
        else:
            return ''

    def render_multifield(self, ctx, data):
        ctx.tag.fillSlots('description', self.multiField.description or "")
        ctx.tag.fillSlots('label', self.multiField.label or "")
        ctx.tag.fillSlots('id', "multigroup-" + self.multiField.key)
        errMsg = self._getMessageElement(ctx)
        ctx.tag.fillSlots('message', errMsg)
        if errMsg:
            ctx.tag.fillSlots('class', 'field error')
        else:
            ctx.tag.fillSlots('class', 'field')
        return ctx.tag
Exemple #11
0
 def renderImmutable(self, ctx, key, args, errors):
     values = ('', '')
     return [
         T.input(type='password', name=key, id=render_cssid(key), value=values[0], class_='readonly', readonly='readonly'),
         T.br,
         T.label(for_=render_cssid(key, 'confirm'))[' Confirm '],
         T.input(type='password', name=key, id=render_cssid(key, 'confirm'),
                 value=values[1], class_='readonly', readonly='readonly')
     ]
Exemple #12
0
 def form(self, ctx, data):
     return t.div(_class="quick", id="replform_%s" % data.get('pid'))[
         t.form(action="./freeform_post!!quick_reply", method="post")[
             t.h3["Quote & Reply ",
                  self.onclick
             ],
             t.fieldset[
                 t.label(_for="title_")["Title"],
                 self.title,
                 t.label(_for="content_")["Message",
                     t.span[" (Markdown formatting rules are supported)"]
                 ],
                 self.body                    
             ],
             t.fieldset[
                 t.input(type="submit", name="Post Reply", value="Post Reply")
             ]   
         ]
     ]
Exemple #13
0
 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]
Exemple #14
0
 def document(self):
     return stan(T.html[T.head[T.invisible(
         render=T.directive('head'))], T.body[T.form(
             action=url.root.child(guard.LOGIN_AVATAR),
             method="post",
             id="loginForm"
         )[T.table(
             style="text-align: center"
         )[T.tr[T.td[T.label(_for="username")["Username:"******"text", id="username", name="username")]],
           T.tr[
               T.td[T.label(_for="password")["Password:"******"password", id="password", name="password"
                            )]],
           T.tr[T.td(colspan="2", style="text-align:left")[
               T.label(_for="rememberMe")["Remember Me"],
               T.input(type="checkbox", id="rememberMe", name="rememberMe"
                       )]],
           T.tr[T.td(colspan="2", style="text-align: center"
                     )[T.input(type="submit", value="Login")]]]]]])
Exemple #15
0
 def render(self, ctx, key, args, errors):
     if errors and not errors.getFieldError(key):
         values = args.get(key)
     else:
         values = ('', '')
     return [
         T.input(type='password', name=key, id=render_cssid(key), value=values[0]),
         T.br,
         T.label(for_=render_cssid(key, 'confirm'))[' Confirm '],
         T.input(type='password', name=key, id=render_cssid(key, 'confirm'), value=values[1]),
         ]
Exemple #16
0
 def render(self, ctx, key, args, errors):
     if errors and not errors.getFieldError(key):
         values = args.get(key)
     else:
         values = ('', '')
     return [
         T.input(type='password', name=key, id=render_cssid(key), value=values[0]),
         T.br,
         T.label(for_=render_cssid(key, 'confirm'))[' Confirm '],
         T.input(type='password', name=key, id=render_cssid(key, 'confirm'), value=values[1]),
         ]
Exemple #17
0
    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]
Exemple #18
0
    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]
Exemple #19
0
 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]
Exemple #20
0
 def renderer(ctx, options):
     # loops through checkbox options and renders
     for n,item in enumerate(options):
         optValue = converter.fromType(iformal.IKey(item).key())
         optLabel = iformal.ILabel(item).label()
         optid = render_cssid(key, n)
         checkbox = T.input(type='checkbox', name=key, value=optValue,
                 id=optid)
         if optValue in values:
             checkbox = checkbox(checked='checked')
         if disabled:
             checkbox = checkbox(class_='disabled', disabled='disabled')
         yield checkbox, T.label(for_=optid)[optLabel], T.br()
Exemple #21
0
class NodeLocationSubElement1(LiveElement):
    docFactory = loaders.stan(
        tags.div(render=tags.directive('liveElement'))[
            tags.invisible(render=tags.directive('bar')),
            tags.label(_class='foo', _for="username"),
            tags.input(_class='foo', id='username')])

    def bar(self, req, tag):
        e = NodeLocationSubElement2()
        e.setFragmentParent(self)
        return e

    renderer(bar)
Exemple #22
0
 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]
Exemple #23
0
	def data_login_form(self, ctx, data):
		if(self.user):
			result = tags.p()[
				"You have been successfully logged in as %s" % self.user.username
			]
		else:
			result = tags.form(method="POST")[[
				tags.p()['Enter your OpenID identifier to login:'],
				tags.label(_for="openid-field")["id:"],
				tags.input(type="text", size="60", name="identity"),
				tags.input(type="submit", name="submit", value="login"),
			]]
		return result
Exemple #24
0
 def renderer(ctx, options):
     # loops through checkbox options and renders
     for n,item in enumerate(options):
         optValue = iformal.IKey(item).key()
         optLabel = iformal.ILabel(item).label()
         optValue = converter.fromType(optValue)
         optid = render_cssid(key, n)
         checkbox = T.input(type='checkbox', name=key, value=optValue,
                 id=optid)
         if optValue in values:
             checkbox = checkbox(checked='checked')
         if disabled:
             checkbox = checkbox(class_='disabled', disabled='disabled')
         yield checkbox, T.label(for_=optid)[optLabel], T.br()
Exemple #25
0
    def render_option(self, ctx, opt):
        optType = type(opt)

        special = {Options.OptionGroup : self.render_optionGroup}
        if optType in special:
            return special[optType]

        bodyRenderer = {
            Options.ChoiceOption: self.render_choiceOption,
            Options.StringOption: self.render_stringOption,
            Options.BooleanOption: self.render_booleanOption,
            Options.NumberOption: self.render_numberOption,
            Options.PasswordOption: self.render_passwordOption
        }.get(optType, "Option type unknown: %s" % (optType, ))

        name = opt.getName()
        desc = opt.getDescription()
        return T.div[T.label(name=name)[T.strong[name], " ", desc], T.div[bodyRenderer]]
Exemple #26
0
        context.fillSlots("form-description", "")

        try:
            content_pattern = context.tag.patternGenerator("binding")
        except NodeNotFound:
            content_pattern = freeformDefaultContentPattern

        context.fillSlots("form-arguments", content_pattern(data=data, render=typedRenderer, key=data.name))

        context.fillSlots("form-button", subm)

        return context.tag


freeformDefaultContentPattern = tags.invisible[
    tags.label(_class="freeform-label", _for=slot("id"))[slot("label")],
    tags.span(_class="freeform-input")[slot("input")],
    tags.div(_class="freeform-error")[slot("error")],
    tags.div(_class="freeform-description")[tags.label(_for=slot("id"))[slot("description")]],
].freeze()


class MethodBindingRenderer(BaseBindingRenderer):
    def rend(self, context, data):
        if data.getAttribute("invisible"):
            return ""

        context.remember(data, iformless.IBinding)

        if self.needsSkin or not context.tag.children:
            self.calculateDefaultSkin(context)
Exemple #27
0
class FieldFragment(rend.Fragment):
    implements(inevow.IRenderer)

    docFactory = loaders.stan(
        T.div(id=T.slot('fieldId'),
              _class=T.slot('class'),
              render=T.directive('field'))[
                  T.label(_class='label', _for=T.slot('id'))[T.slot('label')],
                  T.div(_class='inputs')[T.slot('inputs')],
                  T.slot('description'),
                  T.slot('message'), ])

    hiddenDocFactory = loaders.stan(
        T.invisible(render=T.directive('field'))[T.slot('inputs')])

    def __init__(self, field):
        self.field = field
        # Nasty hack to work out if this is a hidden field. Keep the widget
        # for later anyway.
        self.widget = field.makeWidget()
        if getattr(self.widget, 'inputType', None) == 'hidden':
            self.docFactory = self.hiddenDocFactory

    def render_field(self, ctx, data):

        # The field we're rendering
        field = self.field

        # Get stuff from the context
        formData = iformal.IFormData(ctx)
        formErrors = iformal.IFormErrors(ctx, None)

        # Find any error
        if formErrors is None:
            error = None
        else:
            error = formErrors.getFieldError(field.key)

        # Build the error message
        if error is None:
            message = ''
        else:
            message = T.div(class_='message')[error.message]

        # Create the widget (it's created in __init__ as a hack)
        widget = self.widget

        # Build the list of CSS classes
        classes = [
            'field',
            field.type.__class__.__name__.lower(),
            widget.__class__.__name__.lower(),
        ]
        if field.type.required:
            classes.append('required')
        if field.cssClass:
            classes.append(field.cssClass)
        if error:
            classes.append('error')

        # Create the widget and decide the method that should be called
        if field.type.immutable:
            render = widget.renderImmutable
        else:
            render = widget.render

        # Fill the slots
        tag = ctx.tag
        tag.fillSlots('id', util.render_cssid(field.key))
        tag.fillSlots('fieldId', [util.render_cssid(field.key), '-field'])
        tag.fillSlots('class', ' '.join(classes))
        tag.fillSlots('label', field.label)
        tag.fillSlots('inputs', render(ctx, field.key, formData, formErrors))
        tag.fillSlots('message', message)
        tag.fillSlots('description',
                      T.div(class_='description')[field.description or ''])

        return ctx.tag
    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
Exemple #29
0
        try:
            content_pattern = context.tag.patternGenerator('binding')
        except NodeNotFound:
            content_pattern = freeformDefaultContentPattern

        context.fillSlots(
            'form-arguments',
            content_pattern(data=data, render=typedRenderer, key=data.name))

        context.fillSlots('form-button', subm)

        return context.tag


freeformDefaultContentPattern = tags.invisible[
    tags.label(_class="freeform-label", _for=slot('id'))[slot('label')],
    tags.span(_class="freeform-input")[slot('input')],
    tags.div(_class="freeform-error")[slot('error')],
    tags.div(_class="freeform-description")[tags.label(
        _for=slot('id'))[slot('description')]]].freeze()


class MethodBindingRenderer(BaseBindingRenderer):
    def rend(self, context, data):
        if data.getAttribute('invisible'):
            return ''

        context.remember(data, iformless.IBinding)

        if self.needsSkin or not context.tag.children:
            self.calculateDefaultSkin(context)
Exemple #30
0
    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
Exemple #31
0
            content_pattern = context.tag.patternGenerator( 'binding' )
        except NodeNotFound:
            content_pattern = freeformDefaultContentPattern

        context.fillSlots(
            'form-arguments',
            content_pattern(
                data=data, render=typedRenderer, key=data.name))

        context.fillSlots('form-button', subm)

        return context.tag


freeformDefaultContentPattern = tags.invisible[
    tags.label(_class="freeform-label", _for=slot('id'))[ slot('label') ],
    tags.span(_class="freeform-input")[ slot('input') ],
    tags.div(_class="freeform-error")[ slot('error') ],
    tags.div(_class="freeform-description")[tags.label(_for=slot('id'))[ slot('description') ]]].freeze()


class MethodBindingRenderer(BaseBindingRenderer):
    def rend(self, context, data):
        if data.getAttribute('invisible'):
            return ''

        context.remember(data, iformless.IBinding)

        if self.needsSkin or not context.tag.children:
            self.calculateDefaultSkin(context)
Exemple #32
0
class WizardConfiguration(rend.Page):
    __implements__ = IWizardConfiguration, rend.Page.__implements__

    def child_add_config(self, ctx):
        return ConfigurationWizard(self.original)

    def child_advanced(self, ctx):
        return PreferencesPage(self.original)

    child_images = static.File(os.path.join(os.path.dirname(__file__), 'images'))
    child_css = webform.defaultCSS

    def getCurrentConfig(self):
        if os.path.exists(currentConfigFilename):
            return open(currentConfigFilename).read().strip()
        return ''
    def setCurrentConfig(self, new):
        open(currentConfigFilename, 'w').write(new)
        rcname = os.path.expanduser('~/.shtoomrc')
        open(rcname, 'w').write(open(os.path.expanduser('~/.shtoomrc.d/%s' % new)).read())
        self.original.setValue('created_by_wizard', '')
        ## reload app options
        self.original.loadOptsFile()
        print "OPTS LOADED", open(rcname).read()
    currentConfiguration = property(getCurrentConfig, setCurrentConfig)

    def render_currentConfiguration(self, ctx, data):
        eml = self.original.getValue('email_address')
        if eml:
            ctx.fillSlots('current',
                ctx.onePattern('current'
                ).fillSlots('email', eml
                ).fillSlots('host', self.original.getValue('register_uri')))
        else:
            ctx.fillSlots('current', '')
        return ctx.tag

    docFactory = loaders.stan(T.html[
    T.head[
        T.title["Shtoom Configuration"],
        stylesheet],
    T.body[
        T.h1[
            T.span(_class="mode-switch")[
                T.a(href="/")[T.span(_class="tab-selected")["Basic"]],
                T.a(href="/advanced/")[T.span(_class="tab")["Advanced"]]],
                "Shtoom Configuration"],
        webform.renderForms(bindingNames=['currentConfiguration'])[
            T.form(pattern='freeform-form',
            action=T.slot('form-action'),
            enctype="multipart/form-data",
            method="POST",
            id=T.slot('form-id'))[
                T.slot('form-arguments'),
                T.span(pattern="binding")[
                    T.strong[T.slot('label')],
                    T.slot('input'),
                    webform.ChoiceRenderer.default_select.clone()(
                        style="margin-left: 15px", pattern="selector", onchange='submit();')]]],
        T.div(render=render_currentConfiguration)[
            T.slot('current')[
                T.table(pattern="current")[
                    T.tr[
                        T.th["Account"], T.th["Host"]],
                    T.tr[
                        T.td[T.slot('email')], T.td[T.slot('host')]]]]],
        T.h1["Add a Configuration"],
        T.form(action="add_config")[
            T.p[
                T.input(type="radio", name="config_type", id="divmod_radio", value="divmod"),
                T.label(_for="divmod_radio", onclick=labelClick)["Divmod account"]],
            T.p[
                T.input(type="radio", name="config_type", id="fwd_radio", value="fwd"),
                T.label(_for="fwd_radio", onclick=labelClick)["Free world dialup account"]],
            T.input(type="submit", name="configure", value="Create configuration")]]])