示例#1
0
文件: webapp.py 项目: sandhawke/riftr
def select_processor(div, state, method, field_name):

    for p in plugin.registry:
        if hasattr(p, method):
            desc = []
            desc.append(p.__doc__)
            if hasattr(p, 'spec'):
                desc.append(h.span('  (See ', h.a('language specification', 
                                                href=p.spec), ")"))

            if cgi_args.getfirst(field_name) == p.id:
                button = h.input(type="radio",
                            name=field_name,
                            checked='YES',
                            value=p.id)
            else:
                button = h.input(type="radio",
                            name=field_name,
                            value=p.id)

            examples = h.span()
            if getattr(p, 'examples', []):
                examples << h.br()
                examples << "Load example input: "
                for (name, text) in p.examples:
                    examples << h.input(type="submit", name="load_example", 
                                        value=name)

            div << h.p(button, desc, examples)
示例#2
0
 def getCsvButton(self):
     '''Return a 'Download CSV' button that can be used on the page
        Uses a hidden field called 'csv'
        Uses javascript to reset the value of that field.
     '''
     from html import input, script
     reset_js = 'function(){document.form1.csv.value=0}'
     return script('setInterval(%s,''500)') % reset_js + \
            input(name='csv', type='hidden', value='0') + \
            input(name='csv_button', value='Download CSV', type='button',
                  class_='btn btn-info btn-xs',
                  onClick='document.form1.csv.value=1; submit();')
示例#3
0
文件: htmlpage.py 项目: dlink/vweb
 def getCsvButton(self, additional_classes=''):
     '''Return a 'Download CSV' button that can be used on the page
        Uses a hidden field called 'csv'
        Uses javascript to reset the value of that field.
     '''
     from html import input, script
     reset_js = 'function(){document.form1.csv.value=0}'
     return script('setInterval(%s,''500)') % reset_js + \
            input(name='csv', type='hidden', value='0') + \
            input(name='csv_button', value='Download CSV', type='button',
                  class_='btn btn-info btn-xs' + ' ' + additional_classes,
                  onClick='document.form1.csv.value=1; submit();')
示例#4
0
def get_commits(request, args):
    ref_name = "/".join(args)
    rows = []
    for commit in repo.iter_commits(ref_name, max_count=config["displayed_commits"]):
        check = html.input(type="checkbox", name=commit.hexsha)
        rows.append(html.tr(html.td(check, " ", *commit_to_html(commit))))
    create_review = html.input(value="Create Review", type="submit")
    reset = html.input(value="Reset", type="reset")
    body = html.form(
        create_review,
        reset,
        html.hr(),
        html.table(*rows, **{"class": "list"}),
        method="post",
        action=html.absolute("review", "create"),
    )
    return html_page("Commits {}".format(ref_name), html.div(body))
示例#5
0
文件: webapp.py 项目: sandhawke/riftr
def select_input(div, args):

    input_location=args.getfirst("input_location") or ""
    div << h.p('(Method 1) Web Address of Input:',h.br(),
               h.input(type="text", name="input_location",
                       size="80",
                       value=input_location))
    
    input_text=args.getvalue("input_text", "")
    div << h.p(('(Method 2) Input Text:'), h.br(),
               h.textarea(input_text,
                          cols="90", rows="10", name="input_text"))
示例#6
0
文件: webapp.py 项目: sandhawke/riftr
def main_page(state):
    global page

    startPage("Highly Experimental RIF Demonstration Page")	
    page << h.h2("Highly Experimental RIF Demonstration Page")
    page << h.p("This page currently only does translations between RIF XML and RIF PS, but the idea is to have various non-RIF languages supported as well")

    #for k in state.keys():
    #    page << h.p(`k`, '=', `state[k]`)

    form = h.form(method="GET", class_="f")	
    
    form << h.h3("Step 1: Select Input Processor") 
    select_input_processor(form, state)

    form << h.h3("Step 2: Provide Input") 
    select_input(form, state)

    form << h.h3("Step 3: (Optional) Select transform or analysis plugins") 
    select_middle(form, state)
    
    analysis_div = h.div()
    page << analysis_div

    form << h.h3("Step 4: Select Output Processor") 
    select_output_processor(form, state)

    form << h.h3("Step 5: Begin Processing") 

    form << h.br()

    output_div = h.div()
    output_done = run(output_div, state, analysis_div)
    page << form
    page << output_div

    if output_done:
        form <<  h.input(type="submit",  name="action", 
                         value="Update Output Below")
    else:
        form <<  h.input(type="submit",  name="action", 
                         value="Generate Output Below")

    #form <<  h.Raw("&nbsp;")
    #form <<  h.Raw("&nbsp;")
    #form <<  h.Raw("&nbsp;")
    #form <<  h.Raw("&nbsp;")
    #form <<  h.Raw("&nbsp;")
    #form <<  h.input(type="submit",  name="action", value="Generate Output on New Page")



    if 0:
        page << h.h3('Translates to...')

        input = input.replace("\r\n", "\n")
        action=args.getfirst("action") 
        if action:
            (notes, output) = translate(input, action)
        else:
            notes = "select a processing option"
            output = ""

        if notes:
            page << h.h4('Processor Message:')
            page << h.pre(notes, style="padding:0.5em; border: 2px solid red;")


        if output:
            page << h.pre(output, style="padding:0.5em; border: 2px solid black;")
        else:
            page << h.p("-- No Output --")

    page << h.hr()

    page << h.p("This page/software was developed by [email protected].   It's too buggy right now to use.   Please don't even bother to report bugs.")

    print page