From c028b604ef666d64a8aa9ebdfcf69675cd5d13fb Mon Sep 17 00:00:00 2001 From: Lars Hjemli Date: Wed, 22 Jun 2011 08:49:57 +0000 Subject: Grep the source, Luke This is a PoC for grepping the blobs in the current tree. Signed-off-by: Lars Hjemli --- ui-shared.c | 103 +++++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 96 insertions(+), 7 deletions(-) (limited to 'ui-shared.c') diff --git a/ui-shared.c b/ui-shared.c index 43166af..026c2cb 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -246,6 +246,61 @@ static char *repolink(const char *title, const char *class, const char *page, return fmt("%s", delim); } +static char *repolink2(const char *title, const char *class, const char *page, + const char *head, const char *path, int lineno) +{ + char *delim = "?"; + + html("url); + if (ctx.repo->url[strlen(ctx.repo->url) - 1] != '/') + html("/"); + if (page) { + html_url_path(page); + html("/"); + if (path) + html_url_path(path); + } + } else { + html(ctx.cfg.script_name); + html("?url="); + html_url_arg(ctx.repo->url); + if (ctx.repo->url[strlen(ctx.repo->url) - 1] != '/') + html("/"); + if (page) { + html_url_arg(page); + html("/"); + if (path) + html_url_arg(path); + } + delim = "&"; + } + if (head && strcmp(head, ctx.repo->defbranch)) { + html(delim); + html("h="); + html_url_arg(head); + delim = "&"; + } + if (lineno) + htmlf("#n%d", lineno); + return fmt("%s", delim); +} + static void reporevlink(const char *page, const char *name, const char *title, const char *class, const char *head, const char *rev, const char *path) @@ -263,6 +318,23 @@ static void reporevlink(const char *page, const char *name, const char *title, html(""); } +static void reporevlink2(const char *page, const char *name, const char *title, + const char *class, const char *head, const char *rev, + const char *path, int lineno) +{ + char *delim; + + delim = repolink2(title, class, page, head, path, lineno); + if (rev && ctx.qry.head != NULL && strcmp(rev, ctx.qry.head)) { + html(delim); + html("id="); + html_url_arg(rev); + } + html("'>"); + html_txt(name); + html(""); +} + void cgit_summary_link(const char *name, const char *title, const char *class, const char *head) { @@ -281,6 +353,13 @@ void cgit_tree_link(const char *name, const char *title, const char *class, reporevlink("tree", name, title, class, head, rev, path); } +void cgit_tree_link2(const char *name, const char *title, const char *class, + const char *head, const char *rev, const char *path, + int lineno) +{ + reporevlink2("tree", name, title, class, head, rev, path, lineno); +} + void cgit_plain_link(const char *name, const char *title, const char *class, const char *head, const char *rev, const char *path) { @@ -875,6 +954,9 @@ static void print_header(struct cgit_context *ctx) void cgit_print_pageheader(struct cgit_context *ctx) { + int tree; + char *page; + html("
"); if (!ctx->cfg.noheader) print_header(ctx); @@ -903,16 +985,23 @@ void cgit_print_pageheader(struct cgit_context *ctx) NULL); html(""); html("
\n"); - cgit_add_hidden_formfields(1, 0, "log"); + cgit_add_hidden_formfields(1, 0, page); html("\n"); html("