From f135569b2be3fb1816f802f9a162b3743b735d1c Mon Sep 17 00:00:00 2001 From: Lars Hjemli Date: Sat, 12 Apr 2008 15:53:31 +0200 Subject: Replace sidebar/logo This replaces the sidebar with a more 'common' header layout and also updates the logo. Not quite finished yet, though. Signed-off-by: Lars Hjemli --- ui-shared.c | 125 +++++++++++++++++++++--------------------------------------- 1 file changed, 44 insertions(+), 81 deletions(-) (limited to 'ui-shared.c') diff --git a/ui-shared.c b/ui-shared.c index aa65988..7287956 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -7,6 +7,7 @@ */ #include "cgit.h" +#include "cmd.h" #include "html.h" const char cgit_doctype[] = @@ -465,97 +466,59 @@ void add_hidden_formfields(int incl_head, int incl_search, char *page) } } +char *hc(struct cgit_cmd *cmd, const char *page) +{ + return (strcmp(cmd->name, page) ? NULL : "active"); +} + void cgit_print_pageheader(struct cgit_context *ctx) { - static const char *default_info = "This is cgit, a fast webinterface for git repositories"; - int header = 0; - char *url; + struct cgit_cmd *cmd = cgit_get_cmd(ctx); - html("\n"); - html("\n"); - - html("
\n"); + html("
\n"); + html("
"); } void cgit_print_filemode(unsigned short mode) -- cgit v1.2.3-70-g09d2 From 7c0d2d9fbd3a29d295c8067f7798507853759eae Mon Sep 17 00:00:00 2001 From: Lars Hjemli Date: Sat, 12 Apr 2008 19:59:41 +0200 Subject: Add fixed link to index page from repo header This makes it easier to get back to the index page, and also re-enables the usage of logo-link in cgitrc. Signed-off-by: Lars Hjemli --- ui-shared.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'ui-shared.c') diff --git a/ui-shared.c b/ui-shared.c index 7287956..03d147f 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -478,14 +478,20 @@ void cgit_print_pageheader(struct cgit_context *ctx) html("\n"); html("\n"); html("\n"); html("\n"); html(""); if (ctx.cfg.enable_index_links) - html(""); + html(""); html("\n"); for (i=0; i\n\n\n\n\n"); + html("
\n\n\n"); } int print_branch_option(const char *refname, const unsigned char *sha1, @@ -485,21 +485,46 @@ void cgit_print_pageheader(struct cgit_context *ctx) html("'>\n"); + html(""); if (ctx->repo) { +/* html("index / "); - html_txt(ctx->repo->name); + html("'>index : "); +*/ + reporevlink(NULL, ctx->repo->name, NULL, hc(cmd, "summary"), + ctx->qry.head, NULL, NULL); + html(" : "); + html_txt(ctx->qry.page); + html(""); + html("\n"); + add_hidden_formfields(0, 1, ctx->qry.page); + html(" "); + html(""); + html(""); } else html_txt(ctx->cfg.root_title); - html("\n"); - html(""); - if (ctx->repo) + html("\n"); + + html("repo) { + html(" colspan='2'>"); html_txt(ctx->repo->desc); - else - html_txt(ctx->cfg.index_info); + } +/* + else if (ctx->cfg.root_subtitle) + html_txt(ctx->cfg.root_subtitle); +*/ + else { + html(">"); + html_txt("a fast webinterface for the git dscm"); + } html("\n"); + + html("\n"); html("\n"); html("
\n"); @@ -518,13 +543,23 @@ void cgit_print_pageheader(struct cgit_context *ctx) ctx->qry.sha1, ctx->qry.sha2, NULL); cgit_patch_link("patch", NULL, hc(cmd, "patch"), ctx->qry.head, ctx->qry.sha1); - html(""); - html("
\n"); - add_hidden_formfields(0, 1, ctx->qry.page); - html(" "); - html(""); + html("
"); + html("\n"); + add_hidden_formfields(1, 0, "log"); + html("\n"); + html("\n"); + html("\n"); + html("\n"); } else { html(" --- ui-repolist.c | 49 +++++++++++++++++++++++++++++++++++++------------ ui-shared.c | 11 ++++++++++- 2 files changed, 47 insertions(+), 13 deletions(-) (limited to 'ui-shared.c') diff --git a/ui-repolist.c b/ui-repolist.c index 9eba222..a7de453 100644 --- a/ui-repolist.c +++ b/ui-repolist.c @@ -44,20 +44,23 @@ static void print_modtime(struct cgit_repo *repo) cgit_print_age(s.st_mtime, -1, NULL); } -void cgit_print_repolist() +int is_match(struct cgit_repo *repo) { - int i, columns = 4; - char *last_group = NULL; - - if (ctx.cfg.enable_index_links) - columns++; - - ctx.page.title = ctx.cfg.root_title; - cgit_print_http_headers(&ctx); - cgit_print_docstart(&ctx); - cgit_print_pageheader(&ctx); + if (!ctx.qry.search) + return 1; + if (repo->url && strstr(repo->url, ctx.qry.search)) + return 1; + if (repo->name && strstr(repo->name, ctx.qry.search)) + return 1; + if (repo->desc && strstr(repo->desc, ctx.qry.search)) + return 1; + if (repo->owner && strstr(repo->owner, ctx.qry.search)) + return 1; + return 0; +} - html(""); +void print_header(int columns) +{ if (ctx.cfg.index_header) { htmlf(""); html("\n"); +} +void cgit_print_repolist() +{ + int i, columns = 4, hits = 0, header = 0; + char *last_group = NULL; + + if (ctx.cfg.enable_index_links) + columns++; + + ctx.page.title = ctx.cfg.root_title; + cgit_print_http_headers(&ctx); + cgit_print_docstart(&ctx); + cgit_print_pageheader(&ctx); + + html("
", columns); @@ -72,9 +75,29 @@ void cgit_print_repolist() if (ctx.cfg.enable_index_links) html("Links
"); for (i=0; igroup != NULL) || (last_group != NULL && ctx.repo->group == NULL) || (last_group != NULL && ctx.repo->group != NULL && @@ -110,5 +133,7 @@ void cgit_print_repolist() html("\n"); } html("
"); + if (!hits) + cgit_print_error("No repositories found"); cgit_print_docend(); } diff --git a/ui-shared.c b/ui-shared.c index 782caa7..6253a90 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -555,7 +555,7 @@ void cgit_print_pageheader(struct cgit_context *ctx) html_option("author", "author", ctx->qry.grep); html_option("committer", "committer", ctx->qry.grep); html("\n"); - html("\n"); html("\n"); @@ -564,6 +564,15 @@ void cgit_print_pageheader(struct cgit_context *ctx) html("
index\n"); + html("
"); + html("
\n"); + html("\n"); + html("\n"); + html("
"); } html("
\n"); html("
"); -- cgit v1.2.3-70-g09d2 From 39912a24edf45497e668ebda25636aa6f6db0c9b Mon Sep 17 00:00:00 2001 From: Lars Hjemli Date: Sun, 13 Apr 2008 12:20:00 +0200 Subject: Remove 'patch' link from tab, add to commit view It's a bit confusing to enter the patch view from the tab, since it has no layout. And the commit view has always lacked showing the commit id. Both of these warts are fixed by this commit, which adds a new header line in the commit view which shows the commit id as a 'permalink' to the current commit and also adds a link to the patch view of the current commit. Signed-off-by: Lars Hjemli --- ui-commit.c | 6 ++++++ ui-shared.c | 2 -- ui-shared.h | 2 ++ 3 files changed, 8 insertions(+), 2 deletions(-) (limited to 'ui-shared.c') diff --git a/ui-commit.c b/ui-commit.c index c2fafd7..dd36cc0 100644 --- a/ui-commit.c +++ b/ui-commit.c @@ -175,6 +175,12 @@ void cgit_print_commit(char *hex) html(""); cgit_print_date(info->committer_date, FMT_LONGDATE); html("\n"); + html("commit"); + tmp = sha1_to_hex(commit->object.sha1); + cgit_commit_link(tmp, NULL, NULL, ctx.qry.head, tmp); + html(" ("); + cgit_patch_link("patch", NULL, NULL, NULL, tmp); + html(")\n"); html("tree"); tmp = xstrdup(hex); cgit_tree_link(sha1_to_hex(commit->tree->object.sha1), NULL, NULL, diff --git a/ui-shared.c b/ui-shared.c index 6253a90..bb08c4a 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -541,8 +541,6 @@ void cgit_print_pageheader(struct cgit_context *ctx) ctx->qry.head, ctx->qry.sha1); cgit_diff_link("diff", NULL, hc(cmd, "diff"), ctx->qry.head, ctx->qry.sha1, ctx->qry.sha2, NULL); - cgit_patch_link("patch", NULL, hc(cmd, "patch"), ctx->qry.head, - ctx->qry.sha1); html(""); html("