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))
def draw(self, users): #print 'Content-type: text/html\n\n' ipaddr = socket.gethostbyname(socket.gethostname()) baseref = 'http://%s:5000/' % ipaddr output = '' output += """ <form> <td><input type="text" name="pattern" value="" /></td> <td><input type="submit" value="Search" /></td> </form> """ output += html.tr("<th>" + "</th><th>".join(users[0]) + "</th>") addform = """ <form> <td><input type="text" name="role" value="WAITER" /></td> <td>Auto</td> <td><input type="text" name="fname" value="" /></td> <td><input type="text" name="lname" value="" /></td> <td><input type="text" name="login" value="" /></td> <td><input type="text" name="tel" value="+380" /></td> <td><input type="submit" value="Add" /></td> <input type="hidden" name="q" value="add"> </form> """ output += html.tr(addform) for user in users[1:]: ref = baseref + 'udel?id=%d' % user[1] user += html.a(ref, 'del'), output += html.tr("<td>" + "</td><td>".join([str(x) for x in user]) + "</td>") return html.doc(html.table(output))
def histogram_grid(post): histogram = post["analysis"]["histogram"] id = post["data"]["id"] n = len(post["analysis"]["data"]) p = 1 / 256.0 expected = n * p stddev = math.sqrt(n * p * (1 - p)) if stddev == 0: stddev = 1 rows = [] for y in range(16): row = [] for x in range(16): i = y * 16 + x value = histogram[i] offset = float(value - expected) / (stddev * 8) bright = min(max(int(offset * 128 + 127), 0), 255) bgcolor = "#%02x%02x%02x" % (bright, bright, bright) td = html.td(" " * 5, bgcolor=bgcolor, title="0x%02x: %i" % (i, value)) row.append(td) rows.append(html.tr(*row)) return expander("histogram-grid-%s" % id, html.table(*rows))
def line_to_html(left, right, content, classes): left_td = ( html.td() if left == 0 else html.td(str(left), **{"class": "h", "id": "{}L{}".format(diff.a_blob, left)}) ) right_td = ( html.td() if right == 0 else html.td(str(right), **{"class": "h", "id": "{}R{}".format(diff.b_blob, right)}) ) return html.tr(left_td, right_td, html.td(content), **{"class": classes})
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))
def draw(self, data): print 'Content-type: text/html\n\n' ipaddr = socket.gethostbyname(socket.gethostname()) baseref = 'http://%s/cgi-bin/admin.py' % ipaddr output = '' if data == "#ERROR": output += "<h3>Error: invalid login or password</h3>" loginform = """ <form> <p><input type="text" name="login" value="" /></p> <p><input type="text" name="pw" value="" /></p> <p><input type="submit" value="Login" /></p> </form> """ output += html.tr(loginform) print html.doc(html.table(output))
def get_ref(ref): commits = html.a("commits", href=html.absolute("commits", ref.name)) tree = html.a("tree", href=html.absolute("tree", ref.name)) return html.tr(html.td(ref.name), html.td(commits), html.td(tree))