Ejemplo n.º 1
0
    def __init__(self, subtitle=''):
        self.doc = dominate.document(self.site_name)
        self.subtitle = subtitle if subtitle else self.__class__.__name__
        self.on_ready_scriptage = []

        with self.doc.head:
            for css in self.cssfiles.split():
                self._link_css(css)
            for scripturl in self.scripturls:
                tags.script(crossorigin="anonymous", src=scripturl)
            self.script_list = tags.script().children

        with self.doc.body.add(tags.div(cls="container")):
            self.header = tags.div(id="header")
            with self.header.add(tags.h2()):
                tags.a(self.site_name, href='/', id="site_name")
                tags.h3(self.subtitle, id="subtitle")
                with tags.ul(id="status", style=self.status_style):
                    for msg in flask.get_flashed_messages():
                        tags.li(msg)
            self.content = tags.div(id="content")
            self.footer = tags.div(id="footer")
            with self.footer:
                tags.a("Latest", href=url_for("list_latest"))
                tags.a("Back to the Front", href="/")
                tags.a("Catalog",
                       href=url_for("show_catalog_page"),
                       onclick="shift_edit(event, this)")
                tags.a("Register", href=url_for('loginbp.new_user'))
                tags.label("")
                if flask_login.current_user.is_authenticated:
                    tags.a(f"Log out", href=url_for('loginbp.logout'))
                else:
                    tags.a(f"Login", href=url_for('loginbp.login'))
Ejemplo n.º 2
0
def page():
    doc = document()
    with doc.head:
        link_("https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css")
        link_("https://extra-uru1z3cxu.now.sh/css/extra.css")
        link_("https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.8.2/css/all.css")
        script_("https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js")
        script_("http://intercoolerjs.org/release/intercooler-1.2.2.js")

    with doc.body:
        with dom.div(cls=CENTER_FRAME) as CenterFrame:
            with dom.form(FORM_ATTR):
                with dom.div(cls=LABEL_CARD):
                    dom.label('Write down your mark here',
                              cls="text-white text-xl")
                    dom.input(
                        cls=LABEL_INPUT, type='text', placeholder='your watermark text here', name='mk-text')
                with dom.div(cls=IMG_CARD):
                    with dom.div(cls=IMG_FORM):
                        dom.i(cls=UPLOAD_ICON,
                              onclick='''$('#fileupload').click()''')
                        dom.p("Find File", id="file", cls="text-gray-500 mt-4")
                        dom.input(cls="hidden", type="file", name='bg-img', id="fileupload",
                                  onchange='''$('#file').text(this.value.split("\\\\").pop(-1))''')
                        dom.button('Upload', cls=BUTTON, type='submit')

            with dom.div(cls=RESULT_CONTAINER, id="there") as ResultContainer:
                dom.span(id="here")
    return doc.render()
Ejemplo n.º 3
0
def _text_input(name,
                value,
                bool_attrs=None,
                attrs=None,
                label=None,
                invalid_div=None,
                type_='text',
                internal_label=True):
    '''
	The 'name' string is expected to be a lowercase alphanumeric
	"variable name" without spaces.  Use underscores ('_') to
	separate words for a mult-word name.  `label` will be calculated as
	name.replace('_', ' ').title() unless `label` exists.
	Set `type_` to 'password' for a password input field.
	'''
    if not label:
        label = name.replace('_', ' ').title()
    attrs = _combine_attrs(attrs, bool_attrs)

    i = t.input_(name=name, id=name, type=type_, **attrs)
    if value:
        i['value'] = value
    if internal_label:
        i['placeholder'] = label
        result = t.label(i)
    else:
        result = t.label(label + ':', i)
    if invalid_div:
        result += invalid_div
    return result
def get_alg_filter_buttons_div(r, tab_names):
    alg_filter_buttons_div = div(cls="container")

    alg_input_tag = input(id="ground_truth_CB", cls="badgebox")
    alg_input_tag.attributes['type'] = "checkbox"
    alg_span_tag = span("✓", cls="badge", id="ground_truth_CB_Span")

    alg_filter_button = label("Ground Truth",
                              cls="btn",
                              id="ground_truth_CB_Label")
    alg_filter_button.appendChild(alg_input_tag)
    alg_filter_button.appendChild(alg_span_tag)
    alg_filter_buttons_div.appendChild(alg_filter_button)

    for count in range(len(tab_names)):
        alg_input_tag = input(id=tab_names[count] + "_CB", cls="badgebox")
        alg_input_tag.attributes['type'] = "checkbox"
        alg_span_tag = span("✓", cls="badge", id=tab_names[count] + "_CB_Span")

        alg_filter_button = label(tab_names[count],
                                  cls="btn",
                                  id=tab_names[count] + "_CB_Label")
        alg_filter_button.appendChild(alg_input_tag)
        alg_filter_button.appendChild(alg_span_tag)

        alg_filter_buttons_div.appendChild(alg_filter_button)
    return alg_filter_buttons_div.render()
Ejemplo n.º 5
0
    def upload_form(self):
        with tags.form(
            id=self.config['upload_name'],
            onsubmit=self.config['onsubmit'],
            enctype='multipart/form-data',
            method=self.config['upload_method'],
            action=self.config['upload_route'],
            cls='card p-3 bg-light'):

            tags.h5('Upload an image', cls='card-title')

            with tags.div(cls='form-group row'):
                with tags.div(cls='col-12'):
                    # This requires JavaScript to show the filename.
                    # https://github.com/Johann-S/bs-custom-file-input
                    #
                    # 'style' is necessary to avoid overlapping in Safari and
                    # Chrome on iOS:
                    # https://github.com/twbs/bootstrap/issues/26933
                    with tags.div(cls='custom-file', style='overflow: hidden;'):
                        tags.input(
                            type='file', cls='custom-file-input p-1 rounded',
                            id=self.config['upload_name'], name=self.config['upload_name'])
                        tags.label(
                            'Choose file', fr=self.config['upload_name'],
                            cls='custom-file-label bg-light')

            with tags.div(cls='form-group row'):
                with tags.div(cls='col-3'):
                    with tags.button(type='submit', cls='btn btn-primary'):
                        util.text('Submit')
def _text_input(name,
                value,
                bool_attrs=None,
                attrs=None,
                label=None,
                error_message=None,
                type_='text',
                internal_label=True):
    '''
	`name_value` is a 2-tuple (usually, *Form.nv('my-field-name') will be convenient)
	The 'name' string (first in the 2-tuple) is expected to be a
	lowercase alphanumeric "variable name" without spaces.  Use underscores ('_') to
	separate words for a mult-word name.  `label` will be calculated as
	name.replace('_', ' ').title() unless `label` exists.
	Set `type_` to 'password' for a password input field.
	'''
    if not label:
        label = name.replace('_', ' ').title()
    attrs = _combine_attrs(attrs, bool_attrs)

    i = t.input_(name=name, type=type_, **attrs)
    if value:
        i['value'] = value
    if internal_label:
        i['placeholder'] = label
        result = t.label(i)
    else:
        result = t.label(label + ':', i)
    if error_message:
        result += _error(error_message)
    return result
Ejemplo n.º 7
0
 def html(self):
     if self.label is None:
         return super().html()
     else:
         d = div()
         with d:
             label(self.label, _for=self.id)
             super().html()
         return d
Ejemplo n.º 8
0
def page():
    doc = document()
    with doc as root:
        with doc.body:
            with dom.form(action='/file',method='post',enctype='multipart/form-data'):
                dom.label('上传原图')
                dom.input(type='file',name='bg_image')
                dom.label('上传水印图')
                dom.input(type='file',name='mk_image')
                dom.button('提交',type='submit')
    return root.render() 
Ejemplo n.º 9
0
 def __init__(self, series, **kwargs):
     super().__init__(f"Normalize the video names in {series.name}")
     with self.content:
         if series.normalizable_vids:
             tags.label("The following video titles can be normalized:")
             self.addTable(VideoTable(series.normalizable_vids))
             example = series.normalizable_vids[0].name
             tags.pre(f'For example, "{example}" would become ' +
                      f'"{series.normalized_name(example)}"',
                      style="text-align: left;")
         else:
             tags.p("Nothing to normalize in this series...")
             self.submit_tag['disabled'] = True
Ejemplo n.º 10
0
 def __init__(self, series, **kwargs):
     super().__init__(f"Redate the {series.name} series")
     with self.content:
         with tags.div(style="text-align: left;"):
             tags.label("Apply the start date")
             tags.input(name='start_date',
                        type='date',
                        value=f"{datetime.date.today().isoformat()}")
             tags.label("to all selected videos, increasing the date by ")
             tags.input(type="number",
                        id="date_inc",
                        name="date_inc",
                        step="1",
                        min="1",
                        max="3",
                        value="3")
             tags.label("days for every ")
             tags.input(type="number",
                        id="vid_set",
                        name="vid_set",
                        step="1",
                        min="1",
                        max="3",
                        value="2")
             tags.label("videos.")
             self.addTable(VideoTable(series.videos))
Ejemplo n.º 11
0
 def __init__(self, target_in=""):    
     super().__init__(f"Login to access {target_in}")
     self.target = target_in
     self.username = "******"
     self._passcheck = passcheck and passcheck.handles(self.target)
     if self._passcheck:
         with self.content:
             #tags.label("Username:"******"username") 
             tags.label("Password:"******"password", name="password", type="password") 
     else:
         with self.content:
             tags.p("This resource requires google oauthentication. " +
                    "Click the login button below to proceed to " +
                    "google authorization page. ")
Ejemplo n.º 12
0
    def visit_BooleanField(self, node):
        wrap = self._wrapper(node, classes=['form-check'])

        wrap.add(tags.input(type='checkbox', cls='form-check-input', id=node.id))
        wrap.add(tags.label(node.label.text, _for=node.id, cls='form-check-label'))

        return wrap
Ejemplo n.º 13
0
def page():
    doc = document()
    with doc.head:
        link_("https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css")
        link_("https://extra-uru1z3cxu.now.sh/css/extra.css")
        link_(
            "https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.8.2/css/all.css"
        )
        dom.script(
            src=
            'https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js'
        )

    with doc.body:
        with dom.div(cls=CENTER_FRAME) as CenterFrame:
            with dom.form(action='/file',
                          method='post',
                          enctype='multipart/form-data'):
                with dom.div(cls=LABEL_CARD):
                    dom.label('Write down your mark here',
                              cls="text-white text-xl")
                    dom.input(cls=LABEL_INPUT,
                              type='text',
                              placeholder='your watermark text here',
                              name='mk-text')
                with dom.div(cls=IMG_CARD):
                    with dom.div(cls=IMG_FORM):
                        dom.i(cls=UPLOAD_ICON,
                              onclick='''$('#fileupload').click()''')
                        dom.p("Find File", id="file", cls="text-gray-500 mt-4")
                        dom.input(
                            cls="hidden",
                            type="file",
                            name='bg-img',
                            id="fileupload",
                            onchange=
                            '''$('#file').text(this.value.split("\\\\").pop(-1))'''
                        )
                        dom.button('Upload', cls=BUTTON, type='submit')

            with dom.div(cls=RESULT_CONTAINER) as ResultContainer:
                for _ in range(4):
                    with dom.div(cls=RESULT_ITEM) as ResultItem:
                        dom.p("filename.jpg", cls="text-xl text-gray-400")
                        dom.i(cls="fas fa-download text-xl text-gray-400")

    return doc.render()
Ejemplo n.º 14
0
    def visit_BooleanField(self, node):
        wrap = self._get_wrap(node, classes='form-check')

        label = wrap.add(tags.label(_for=node.id, _class='form-check-label'))
        label.add(tags.input(type='checkbox', _class='form-check-input'))
        label.add(node.label.text)

        return wrap
Ejemplo n.º 15
0
    def _wrapped_input(self, node,
                       type='text',
                       classes=['form-control'], **kwargs):
        wrap = self._get_wrap(node)
        wrap.add(tags.label(node.label.text, _for=node.id))
        wrap.add(tags.input(type=type, _class=' '.join(classes), **kwargs))

        return wrap
Ejemplo n.º 16
0
    def visit_BooleanField(self, node):
        wrap = self._get_wrap(node, classes='checkbox')

        label = wrap.add(tags.label(_for=node.id))
        label.add(tags.input(type='checkbox'))
        label.add(node.label.text)

        return wrap
Ejemplo n.º 17
0
    def _wrapped_input(self, node,
                       type='text',
                       classes=['form-control'], **kwargs):
        wrap = self._get_wrap(node)
        wrap.add(tags.label(node.label.text, _for=node.id))
        wrap.add(tags.input(type=type, _class=' '.join(classes), **kwargs))

        return wrap
Ejemplo n.º 18
0
    def visit_Field(self, node):
        # FIXME: add error class

        wrap = self._get_wrap(node)

        # add the label
        wrap.add(tags.label(node.label.text, _for=node.id))
        wrap.add(raw(node()))

        if node.description:
            wrap.add(tags.p(node.description, _class='form-text text-muted'))

        return wrap
Ejemplo n.º 19
0
    def visit_Field(self, node):
        # FIXME: add error class

        wrap = self._get_wrap(node)

        # add the label
        wrap.add(tags.label(node.label.text, _for=node.id))
        wrap.add(raw(node()))

        if node.description:
            wrap.add(tags.p(node.description, _class='help-block'))

        return wrap
Ejemplo n.º 20
0
 def __init__(self, catalog, **kwargs):
     super().__init__("Import a series to the Catalog")
     # Form list from the unlisted series of the catalog
     # That is a list of vimeo folders that are not
     # present as a VideoSeries object in mongodb
     us = list(catalog.unlisted_series())
     # get the names associated with the vimeo folders
     usn = [x['name'] for x in us]
     # Stringify the unlisted series dictionary data because both name and
     # data elements of the SelectField choice list
     us = [str(x) for x in us]
     with self.content:
         tags.attr(style=g30c70)
         tags.label("Choose from existing vimeo folders: ")
         with tags.select(name="serselect", type='text'):
             for opt, name in zip(usn, us):
                 tags.option(opt, value=name)
         tags.label("First recorded:")
         tags.input(_class="post_date",
                    type="date",
                    name="postdate",
                    value=f"{datetime.date.today().isoformat()}")
Ejemplo n.º 21
0
    def visit_BooleanField(self, node):
        wrap = self._wrapper(node, classes=['form-check'])

        wrap.add(
            tags.input(type='checkbox', cls='form-check-input', id=node.id))
        wrap.add(
            tags.label(node.label.text, _for=node.id, cls='form-check-label'))

        if node.description:
            wrap.add(
                tags.small(node.description, _class='form-text text-muted'))

        return wrap
Ejemplo n.º 22
0
    def step2(self, **kwargs):
        if kwargs.get('kanton', None) is None:
            raise cherrypy.HTTPRedirect('/step1')

        content = html.div()

        row = content.add(html.div(cls='form-group row_vertical_offset'))

        row.add(
            html.div(html.label('Login suisseID', cls='pull-right'),
                     cls='col-sm-4 control-label'))

        cell = row.add(html.div(cls='col-sm-8'))
        cell.add(
            html.img(
                src='/images/suisse-id.png',
                style=
                'margin-bottom: 10px; margin-left: -8px; border-radius: 4px;'))

        content.add(NewUserForm().html(action='/create'))
        return self.template.render(content=content)
Ejemplo n.º 23
0
 def slider(self,):
    
     range = input(value=self.value, type="range", min="0", max="100",  cls="field-value", id="input" + str(self.id))
     lab = label(str(self.value), id=str(self.id), style="margin-left:5px;")
     return range, lab 
Ejemplo n.º 24
0
 def gen_label(toggle, cls, *contents):
     if toggle:
         return tags.label(*contents, cls=cls, **{"for": toggle})
     return tags.span(*contents, cls=cls)
Ejemplo n.º 25
0
 def _get_delete_key_value_modal_forms(self):
     form_action = "/hsapi/_internal/{0}/{1}/delete-file-keyvalue-metadata/"
     form_action = form_action.format(self.logical_file.__class__.__name__,
                                      self.logical_file.id)
     counter = 0
     root_div = div(id="delete-keyvalue-filetype-modals")
     with root_div:
         for k, v in self.extra_metadata.iteritems():
             counter += 1
             modal_div = div(
                 cls="modal fade",
                 id="delete-keyvalue-filetype-modal-{}".format(counter),
                 tabindex="-1",
                 role="dialog",
                 aria_labelledby="delete-key-value-metadata",
                 aria_hidden="true")
             with modal_div:
                 with div(cls="modal-dialog", role="document"):
                     with div(cls="modal-content"):
                         form_id = "delete-keyvalue-filetype-metadata-{}".format(
                             counter)
                         with form(action=form_action,
                                   id=form_id,
                                   method="post",
                                   enctype="multipart/form-data"):
                             div("{% csrf_token %}")
                             with div(cls="modal-header"):
                                 button("x",
                                        type="button",
                                        cls="close",
                                        data_dismiss="modal",
                                        aria_hidden="true")
                                 h4("Confirm to Delete Key/Value Metadata",
                                    cls="modal-title",
                                    id="delete-key-value-metadata")
                             with div(cls="modal-body"):
                                 with div(cls="form-group"):
                                     with div(cls="control-group"):
                                         label(
                                             "Key",
                                             cls=
                                             "control-label requiredField",
                                             fr="file_extra_meta_name")
                                         with div(cls="controls"):
                                             input(
                                                 cls=
                                                 "form-control input-sm textinput "
                                                 "textInput",
                                                 value=k,
                                                 id="file_extra_meta_key",
                                                 maxlength="100",
                                                 name="key",
                                                 type="text",
                                                 readonly="readonly")
                                     with div(cls="control-group"):
                                         label(
                                             "Value",
                                             cls=
                                             "control-label requiredField",
                                             fr="file_extra_meta_value")
                                         with div(cls="controls"):
                                             textarea(
                                                 v,
                                                 cls=
                                                 "form-control input-sm textarea",
                                                 cols="40",
                                                 rows="10",
                                                 id="file_extra_meta_value",
                                                 style="resize: vertical;",
                                                 name="value",
                                                 type="text",
                                                 readonly="readonly")
                             with div(cls="modal-footer"):
                                 button("Cancel",
                                        type="button",
                                        cls="btn btn-default",
                                        data_dismiss="modal")
                                 button("Delete",
                                        type="button",
                                        cls="btn btn-danger",
                                        id="btn-delete-key-value"
                                        )  # TODO: TESTING
     return root_div
Ejemplo n.º 26
0
def dominate_register_page():
    """
    第二頁:註冊頁面,對應到  @app.route('/jump')  及其函數   registerpage_run
    目標:利用dominate寫出registerpage的html並在templates資料夾中存成index2.html

    分為三個區塊
    doc = dominate.document()
    with doc.head   (包含css的style;meta確保中文可以運行在utf-8下)
    with doc.body   (包含 a form with 7 legends: name/ password/ student_id/
                    telephone_number/ school_bike_license/ bike_lock_number/ picture uploading and a button submit)

    最後寫入文件中(在templates資料夾中存成index2.html)
    """
    doc = dominate.document(title="registerpage")

    with doc.head:
        tags.meta(name='charset', content="utf-8")
        tags.style("""\
            body {
                background-color: #F9F8F1;
                color: #2C232A;
                font-family: sans-serif;
                font-size: 14;
                text-align: center;
            }
            
             section{
                width: 800px;
                height: 800px;
                position: absolute;
                top: 15%;
                left: 15%;
                overflow: auto;
                text-align: center;
            }

            label{
                cursor: pointer;
                display: inline-block;
                padding: 3px 6px;
                text-align: center;
                width: 500px;
                vertical-align: top;
            }

            input{
                font-size: inherit;
            }

        """)

    with doc.body:
        with tags.div(clas='headline', style='font-size: 20;'):
            tags.h1('Register Page')
        with tags.section():
            with tags.form(method='POST', action="/jump", enctype="multipart/form-data"):
                with tags.legend():
                    tags.label('請輸入姓名(中文)')
                    tags.input(type='text', name='name', size=20)
                with tags.legend():
                    tags.label('請輸入密碼')
                    tags.input(type='text', name='password', size=20)
                with tags.legend():
                    tags.label('請輸入學號(1個大寫英文字母+8個數字)')
                    tags.input(type='text', name='student_id', size=20)
                with tags.legend():
                    tags.label('請輸入電話(請輸入10位數字)')
                    tags.input(type='text', name='telephone_number', size=20)
                with tags.legend():
                    tags.label('是否有台大車證(Y/N)')
                    tags.input(type='text', name='school_bike_license', size=20)
                with tags.legend():
                    tags.label('腳踏車的密碼(選填、請輸入數字)')
                    tags.input(type='text', name='bike_lock_number', size=20)
                with tags.legend():
                    tags.label('上傳圖片')
                    tags.input(type='file', name='photo', size=20)
                with tags.div(cls='button', style="margin:0 auto; width:250px;"):
                    tags.input(type='submit', value='click me', style="width:120px; background-color:pink;")

    fn = 'templates/index2.html'
    with open(file=fn, mode='w', encoding='utf-8') as f:
        f.write(doc.render())
Ejemplo n.º 27
0
    def __init__(self, series, cnt=1, **kwargs):
        super().__init__(f"Add upto {cnt} new videos to \"{series.name}\"")

        with self.content:
            tags.input(id="accessToken",
                       type="hidden",
                       value=f"{os.getenv('VIMEO_TOKEN')}")
            with tags.div(id="upbox", **{"data-maxcnt": "2"}):
                with tags.div(_class="upunit", style=g30c70):
                    tags.label("Video Name:")
                    tags.input(_class="vidname",
                               type="text",
                               value=series.next_vid_name)
                    tags.label("Video Author:")
                    tags.input(_class="vid_author",
                               type="text",
                               name="vid_author",
                               value="Pastor")
                    tags.label("Video File:")
                    tags.input(
                        _class="fileselect",
                        type="file",
                    )
                    tags.label("Video Date:")
                    tags.input(_class="post_date",
                               type="date",
                               name="postdates",
                               value=f"{datetime.date.today().isoformat()}")
                    tags.label("Upload Progress:")
                    tags.div(_class="progress")
                    tags.label("Status:")
                    tags.div(_class="status")
                    tags.input(_class="vidid", name="vidids", type="hidden")
            tags.button(" + ", cls="add_field", style="display: inline-block;")
            tags.button(" - ", cls="del_field", style="display: inline-block;")
Ejemplo n.º 28
0
def dominate_enter_page():
    """
    第三頁:確認資訊頁面,對應到  @app.route('/jump')  及其函數   registerpage_run [if request.method == 'POST']
    目標:利用dominate寫出 enter_page 的 html並在 templates 資料夾中存成 index3.html

    分為三個區塊
    doc = dominate.document()
    with doc.head   (包含css的style;meta確保中文可以運行在utf-8下)
    with doc.body   (包含 6 information: name/ password/ student_id/
                    telephone_number/ school_bike_license/ bike_lock_number and a button confirm)

    最後寫入文件中(在templates資料夾中存成index3.html)
    """
    doc = dominate.document(title="entered")

    with doc.head:
        tags.meta(name='charset', content="utf-8")
        tags.style("""\
            body {
                background-color: #F9F8F1;
                color: #2C232A;
                font-family: sans-serif;
                font-size: 14;
                text-align: center;
            }
        """)

    with doc.body:
        tags.h1('welcome' + str(name_list_temp[0]))
        tags.h2('please confirm your information')
        with tags.section(cls='information check'):
            with tags.div(cls='name', style="text-align: center"):
                tags.label('your name is  ' + str(name_list_temp[0]))
            with tags.div(cls='password', style="text-align: center"):
                tags.label('your password is  ' + str(password_temp[0]))
            with tags.div(cls='student_id', style="text-align: center"):
                tags.label('your student id is  ' + str(student_id_temp[0]))
            with tags.div(cls='telephone', style="text-align: center"):
                tags.label('your telephone number is  ' + str(telephone_number_temp[0]))
            with tags.div(cls='license', style="text-align: center"):
                tags.label('the status of your bike_lice  ' + str(school_bike_license_temp[0]))
            with tags.div(cls='lock_number', style="text-align: center"):
                tags.label('your bike lock number is  ' + str(bike_lock_number_temp[0]))
            with tags.div(cls='button', style="margin:0 auto; width:250px;"):
                tags.input(type='button', value='confirm', style="width:120px; background-color:pink;",
                           onclick="location.href='http://127.0.0.1:5000/entered'")

    fn = 'templates/index3.html'
    with open(file=fn, mode='w', encoding='utf-8') as f:
        f.write(doc.render())
    print(f)
Ejemplo n.º 29
0
 def __init__(self, catalog, **kwargs):
     super().__init__("Add a new series")
     with self.content:
         tags.attr(style=g30c70)
         tags.label("Series Name:")
         tags.input(name='name')
Ejemplo n.º 30
0
 def __init__(self, series, **kwargs):
     super().__init__(f"Rename the {series.name} series")
     with self.content:
         tags.attr(style=g50c50)
         tags.label("New series name:")
         tags.input(name="new_series_name", type='text')
Ejemplo n.º 31
0
            # <em>(ii)</em> a target identity.
            # Based on whether we have seen (or not) the identity shown in the video at train time, we consider two scenarios:
            # <em>seen</em> and  <em>unseen</em>.
            # For each test video sample we synthesize audio in all target voices encountered at train time&mdash;you can select the desired target identity using the drop-down menu beneath each video.
            # We show a randomly selected sample for each subject.</p>""")

            tags.h3("Seen scenario")

            p = tags.p(
                "In this scenario the input videos at test time have identities also encountered at train time (14 identities), "
            )
            p += "but neither the video samples nor the word sequence were seen during training. "
            p += "Due to space limitations, we were not able to present quantitative results for this setting in our paper."

            with tags.div(cls="form-group form-inline"):
                tags.label("Method:")
                with tags.select(cls="form-control ml-2 method",
                                 **{"data-scenario": "seen"}):
                    tags.option("speaker identity (SI)",
                                selected=True,
                                data_name="ours-speaker-identity-dispel")
                    tags.option("speaker embedding (SE)",
                                data_name="ours-speaker-embedding-dispel")

            data2 = load_results_2(
                filelist="multi-speaker-tiny-test",
                method="ours-speaker-embedding-dispel",
            )

            data2 = load_results_2(
                filelist="multi-speaker-tiny-test",
Ejemplo n.º 32
0
 def _get_edit_key_value_modal_forms(self):
     # TODO: See if can use one modal dialog to edit any pair of key/value
     form_action = "/hsapi/_internal/{0}/{1}/update-file-keyvalue-metadata/"
     form_action = form_action.format(self.logical_file.__class__.__name__,
                                      self.logical_file.id)
     counter = 0
     root_div = div(id="edit-keyvalue-filetype-modals")
     with root_div:
         for k, v in self.extra_metadata.iteritems():
             counter += 1
             modal_div = div(
                 cls="modal fade",
                 id="edit-keyvalue-filetype-modal-{}".format(counter),
                 tabindex="-1",
                 role="dialog",
                 aria_labelledby="edit-key-value-metadata",
                 aria_hidden="true")
             with modal_div:
                 with div(cls="modal-dialog", role="document"):
                     with div(cls="modal-content"):
                         form_id = "edit-keyvalue-filetype-metadata-{}".format(
                             counter)
                         with form(action=form_action,
                                   id=form_id,
                                   data_counter="{}".format(counter),
                                   method="post",
                                   enctype="multipart/form-data"):
                             div("{% csrf_token %}")
                             with div(cls="modal-header"):
                                 button("x",
                                        type="button",
                                        cls="close",
                                        data_dismiss="modal",
                                        aria_hidden="true")
                                 h4("Update Key/Value Metadata",
                                    cls="modal-title",
                                    id="edit-key-value-metadata")
                             with div(cls="modal-body"):
                                 with div(cls="form-group"):
                                     with div(cls="control-group"):
                                         label(
                                             "Key(Original)",
                                             cls=
                                             "control-label requiredField",
                                             fr=
                                             "file_extra_meta_key_original")
                                         with div(cls="controls"):
                                             input(
                                                 value=k,
                                                 readonly="readonly",
                                                 cls=
                                                 "form-control input-sm textinput "
                                                 "textInput",
                                                 id=
                                                 "file_extra_meta_key_original",
                                                 maxlength="100",
                                                 name="key_original",
                                                 type="text")
                                     with div(cls="control-group"):
                                         label(
                                             "Key",
                                             cls=
                                             "control-label requiredField",
                                             fr="file_extra_meta_key")
                                         with div(cls="controls"):
                                             input(
                                                 value=k,
                                                 cls=
                                                 "form-control input-sm textinput "
                                                 "textInput",
                                                 id="file_extra_meta_key",
                                                 maxlength="100",
                                                 name="key",
                                                 type="text")
                                     with div(cls="control-group"):
                                         label(
                                             "Value",
                                             cls=
                                             "control-label requiredField",
                                             fr="file_extra_meta_value")
                                         with div(cls="controls"):
                                             textarea(
                                                 v,
                                                 cls=
                                                 "form-control input-sm textarea",
                                                 cols="40",
                                                 rows="10",
                                                 id="file_extra_meta_value",
                                                 name="value",
                                                 type="text")
                             with div(cls="modal-footer"):
                                 button("Cancel",
                                        type="button",
                                        cls="btn btn-default",
                                        data_dismiss="modal")
                                 button("OK",
                                        id="btn-confirm-edit-key-value",
                                        type="button",
                                        cls="btn btn-primary")
         return root_div
Ejemplo n.º 33
0
 def _get_add_key_value_modal_form(self):
     form_action = "/hsapi/_internal/{0}/{1}/update-file-keyvalue-metadata/"
     form_action = form_action.format(self.logical_file.__class__.__name__,
                                      self.logical_file.id)
     modal_div = div(cls="modal fade",
                     id="add-keyvalue-filetype-modal",
                     tabindex="-1",
                     role="dialog",
                     aria_labelledby="add-key-value-metadata",
                     aria_hidden="true")
     with modal_div:
         with div(cls="modal-dialog", role="document"):
             with div(cls="modal-content"):
                 with form(action=form_action,
                           id="add-keyvalue-filetype-metadata",
                           method="post",
                           enctype="multipart/form-data"):
                     div("{% csrf_token %}")
                     with div(cls="modal-header"):
                         button("x",
                                type="button",
                                cls="close",
                                data_dismiss="modal",
                                aria_hidden="true")
                         h4("Add Key/Value Metadata",
                            cls="modal-title",
                            id="add-key-value-metadata")
                     with div(cls="modal-body"):
                         with div(cls="form-group"):
                             with div(cls="control-group"):
                                 label("Key",
                                       cls="control-label requiredField",
                                       fr="file_extra_meta_name")
                                 with div(cls="controls"):
                                     input(
                                         cls=
                                         "form-control input-sm textinput textInput",
                                         id="file_extra_meta_name",
                                         maxlength="100",
                                         name="name",
                                         type="text")
                             with div(cls="control-group"):
                                 label("Value",
                                       cls="control-label requiredField",
                                       fr="file_extra_meta_value")
                                 with div(cls="controls"):
                                     textarea(
                                         cls=
                                         "form-control input-sm textarea",
                                         cols="40",
                                         rows="10",
                                         id="file_extra_meta_value",
                                         style="resize: vertical;",
                                         name="value",
                                         type="text")
                     with div(cls="modal-footer"):
                         button("Cancel",
                                type="button",
                                cls="btn btn-default",
                                data_dismiss="modal")
                         button(
                             "OK",
                             type="button",
                             cls="btn btn-primary",
                             id="btn-confirm-add-metadata")  # TODO: TESTING
     return modal_div
Ejemplo n.º 34
0
def _add_option(d, id, label):
    with d:
        with t.div(cls='quiz_answer_option'):
            t.input(type='radio', id=id, name='choice', value=id)
            t.label(label, fr=id, cls='answer_option_label')