Beispiel #1
1
def get_tree(request, args):
    ref_name = args[0]
    path = args[1:]
    ref = repo.refs[ref_name]
    rows = []
    tree = ref.commit.tree
    for p in path:
        tree = tree[p]
    if isinstance(tree, git.Blob):
        body = html.pre(tree.data_stream.read())
    else:
        rows.append(html.tr(html.th("Name"), html.th("Size"), html.th("Type")))
        if len(args) > 1:
            rows.append(
                html.tr(html.td(html.a("..", href="/" + "/".join(["tree"] + args[:1]))), html.td(), html.td("[DIR]"))
            )
        for d in tree.trees:
            link = html.td(html.a(d.name + "/", href="/" + "/".join(["tree"] + args + [d.name])))
            rows.append(html.tr(link, html.td(), html.td("[DIR]")))
        for blob in tree.blobs:
            link = html.td(html.a(blob.name, href="/" + "/".join(["tree"] + args + [blob.name])))
            size = html.td(bytes_to_human(blob.size))
            rows.append(html.tr(link, size, html.td(blob.mime_type)))
        body = html.table(*rows, **{"class": "list"})
    return html_page("Tree {} /{}".format(ref_name, "/".join(path)), html.div(body))
Beispiel #2
0
def hex_dump(post):
	"""Print hex dump of post."""
	id = post["data"]["id"]
	text = post["analysis"]["hexdump"]
	# Format text so that it is (usually?) four groups wide.
	# This makes it 256 bits per line.
	plaintext = html.pre(html.escape(text))
	return expander("hexdump-%s" % id, plaintext)
Beispiel #3
0
def hex_dump(post):
    """Print hex dump of post."""
    id = post["data"]["id"]
    text = post["analysis"]["hexdump"]
    # Format text so that it is (usually?) four groups wide.
    # This makes it 256 bits per line.
    plaintext = html.pre(html.escape(text))
    return expander("hexdump-%s" % id, plaintext)
Beispiel #4
0
def create_index(posts):
    """ Create the overview index.html file. """
    log_compile("creating index page")
    o = ""
    for p in posts:
        o += html.block(
            "".join([
                html.h(2, html.post_link(p)),
                html.hex_dump(p["text"]),
                html.pre(
                    "-rw-r--r-- 1 rwos rwos "
                    +str(len(p["text"]))+" "
                    +html.date(p["meta"]["datetime"])+" "
                    +p["meta"]["url_heading"][0:20]),
                html.pre(str(len(p["comments"]))+" comment(s)")]))
    # TODO: pagination, with configurable limit
    write_out("index.html", html.render_front(o))
    log_compile("done")
Beispiel #5
0
def show_overview():
    """ Show an overview over the blog. """
    posts = psblog.get_all_posts()
    comments_num = 0
    for p in posts:
        comments_num += len(p["comments"])
    o = [html.h(2, "Overview"),
         html.p(html.a("?page=list", str(len(posts))+" Posts")),
         html.p(html.a("#TODO", str(comments_num)+" Comments")),
         html.p(html.a("?page=add_new", "Add New Post")),
         html.p(html.a("?page=compile", "Re-Compile"))]
    o = html.block("".join(o))
    o += html.block(html.p("last compile log:"+html.pre(
            psblog.readfile(config.log_dir+"compile.log"))))
    log_ls = psblog.readfile(config.log_dir+"psblog.log").splitlines()
    log_ls.reverse()
    o += html.block(html.p("blog log:"+html.pre("\n".join(log_ls))))
    print(html.render_admin(o))
Beispiel #6
0
def create_stats(p, start):
    """ Create a small compilation statistic page. """
    write_out("stats.html", html.render_front(
        html.block("".join([
            html.h(2, "Statistics"),
            html.pre("".join([
                "last compile on ",
                dt.datetime.now().strftime("%A, %x %T"),
                "\n\nnumber of posts: ",
                str(len(p)),
                "\nrendering took ",
                str(time.clock()-start),
                " seconds"]))])), "statistics"))
Beispiel #7
0
def run(outdiv, args, middiv):

    return

    state = State()
    state.plugins = []
    for id in [ args.getfirst("input_processor"),
                args.getfirst("output_processor"),
                ] + args.getlist("plugin") :
        cls = plugin.plugin_by_id(id)
        p = plugin.instantiate_with_state(cls, state)
        state.plugins.append(p)

    # uhhhh, this is kind of nonsense....

    
    # get other state out of args...
    #    they're named (pluginid_optionname):   xml_out_indent=
    

    try:
        (iproc,) = plugin.get_plugins(["input"], state)
    except ValueError:
        outdiv << h.p('No input processor selected.')
        return False

    input_text = input_text=args.getvalue("input_text", "")
    input_text = input_text.replace("\r\n", "\n")
    try:
        doc = iproc.parse(input_text)
    except error.SyntaxError, e:
        err = ""
        err += e.message + "\n"
        err += e.illustrate_position()
        outdiv << h.pre("Error\n"+err,
                      style="padding: 1em; border:2px solid red;")
        return False
Beispiel #8
0
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
Beispiel #9
0
        err = ""
        err += e.message + "\n"
        err += e.illustrate_position()
        outdiv << h.pre("Error\n"+err,
                      style="padding: 1em; border:2px solid red;")
        return False


    for p in plugin.get_plugins(["transform","analysis"], state):
        if isinstance(p, plugin.TransformPlugin):
            doc = p.transform(doc)
        elif isinstance(p, plugin.AnalysisPlugin):
            report = p.analyze(doc)
            d = h.div()
            d << h.p("Report from %s plugin:" % p.id)
            d << h.pre(report, style="padding:1em; border:1px solid black;")
            middiv << d
        else:
            raise RuntimeError


    try:
        (oproc,) = plugin.get_plugins(["output"], state)
    except ValueError:
        outdiv << h.p('No output processor selected.')
        return False

    buffer = StringIO()
    oproc.serialize(doc, buffer)
    outdiv << h.pre(buffer.getvalue(), style="padding:1em; border:1px solid black;")
    return True