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 --- cgit.css | 147 ++++++++++++++++++++++-------------------------------------- cgit.png | Bin 5406 -> 1840 bytes ui-shared.c | 125 ++++++++++++++++++--------------------------------- 3 files changed, 97 insertions(+), 175 deletions(-) diff --git a/cgit.css b/cgit.css index 17c2712..67cf48e 100644 --- a/cgit.css +++ b/cgit.css @@ -11,41 +11,67 @@ body { padding: 4px; } +a { + color: blue; + text-decoration: none; +} + +a:hover { + text-decoration: underline; +} + table { border-collapse: collapse; } -h2 { - font-size: 120%; - font-weight: bold; - margin-top: 0em; - margin-bottom: 0.25em; +table#header { + width: 100%; + margin-bottom: 1em; } -h3 { - margin-top: 0em; - font-size: 100%; - font-weight: normal; +table#header td.logo { + width: 96px; } -h4 { - margin-top: 1.5em; - margin-bottom: 0.1em; - font-size: 100%; - font-weight: bold; +table#header td.main { + font-size: 200%; } -a { - color: #600; - text-decoration: none; +table#header td.sub { + color: #777; + border-top: solid 1px #ccc; } -a:hover { - background-color: #ddd; - text-decoration: none; +table.tabs { + border-bottom: solid 2px #ccc; + border-collapse: collapse; + margin-top: 2em; + margin-bottom: 1em; + width: 100%; +} + +table.tabs td { + padding: 0px 0.5em; +} + +table.tabs td a { + padding: 2px 1em; + color: #007; +} + +table.tabs td a.active { + color: #000; + background-color: #ccc; } +div.content { + margin: 0px; + padding: 1em; +} + + table.list { + width: 100%; border: none; border-collapse: collapse; } @@ -55,7 +81,7 @@ table.list tr { } table.list tr:hover { - background: #f8f8f8; + background: #eee; } table.list tr.nohover:hover { @@ -63,8 +89,8 @@ table.list tr.nohover:hover { } table.list th { - font-weight: bold; - border-bottom: solid 1px #777; + font-weight: normal; + border-bottom: solid 1px #ccc; padding: 0.1em 0.5em 0.1em 0.5em; vertical-align: baseline; } @@ -74,79 +100,12 @@ table.list td { padding: 0.1em 0.5em 0.1em 0.5em; } -img { - border: none; +table.list td a { + color: black; } -table#layout { - border-collapse: collapse; +img { border: none; - margin: 0px; -} - -td#sidebar { - vertical-align: top; - width: 162px; - padding: 0px 0px 0px 0px; - margin: 0px; -} - -td#sidebar table { - border-collapse: separate; - border-spacing: 0px; - margin: 0px; - padding: 0px; - background-color: #ccc; -} - -td#sidebar table.sidebar td.sidebar { - padding: 4px; - border-top: solid 1px #eee; - border-left: solid 1px #eee; - border-right: solid 1px #aaa; - border-bottom: solid 1px #aaa; -} - -div#logo { - margin: 0px; - padding: 4px 0px 4px 0px; - text-align: center; - background-color: #ccc; - border-top: solid 1px #eee; - border-left: solid 1px #eee; - border-right: solid 1px #aaa; - border-bottom: solid 1px #aaa; -} - -td#sidebar h1 { - font-size: 10pt; - font-weight: bold; - margin: 8px 0px 0px 0px; -} - -td#sidebar h1.first { - margin-top: 0px; -} - -td#sidebar a.menu { - display: block; - background-color: #ccc; - padding: 0.1em 0.5em; - text-decoration: none; -} - -td#sidebar a.menu:hover { - background-color: #bbb; - text-decoration: none; -} - -td#sidebar select { - width: 100%; - margin: 2px 0px 0px 0px; -} - -td#sidebar form { - text-align: right; } input#switch-btn { @@ -357,7 +316,7 @@ table.diff td { table.diff td div.head { font-weight: bold; margin-top: 1em; - background-color: #eee; + color: black; } table.diff td div.hunk { diff --git a/cgit.png b/cgit.png index 22f7e95..d7f70bc 100644 Binary files a/cgit.png and b/cgit.png differ 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 From 89aa3c0d0a4c6d9885272602005975b763ea1604 Mon Sep 17 00:00:00 2001 From: Lars Hjemli Date: Sat, 12 Apr 2008 15:53:53 +0200 Subject: Include diff in commit view Signed-off-by: Lars Hjemli --- ui-commit.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ui-commit.c b/ui-commit.c index 8019e36..c2fafd7 100644 --- a/ui-commit.c +++ b/ui-commit.c @@ -9,6 +9,7 @@ #include "cgit.h" #include "html.h" #include "ui-shared.h" +#include "ui-diff.h" static int files, slots; static int total_adds, total_rems, max_changes; @@ -218,10 +219,11 @@ void cgit_print_commit(char *hex) print_fileinfo(&items[i]); html(""); html("
"); - htmlf("%d files changed, %d insertions, %d deletions (", + htmlf("%d files changed, %d insertions, %d deletions", files, total_adds, total_rems); - cgit_diff_link("show diff", NULL, NULL, ctx.qry.head, hex, - NULL, NULL); + cgit_print_diff(ctx.qry.sha1, + sha1_to_hex(commit->parents->item->object.sha1), + NULL); html(")
"); } cgit_free_commitinfo(info); -- cgit 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(-) 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(-) 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 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(-) 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("
url && strstr(repo->url, ctx.qry.search)) + if (repo->url && strcasestr(repo->url, ctx.qry.search)) return 1; - if (repo->name && strstr(repo->name, ctx.qry.search)) + if (repo->name && strcasestr(repo->name, ctx.qry.search)) return 1; - if (repo->desc && strstr(repo->desc, ctx.qry.search)) + if (repo->desc && strcasestr(repo->desc, ctx.qry.search)) return 1; - if (repo->owner && strstr(repo->owner, ctx.qry.search)) + if (repo->owner && strcasestr(repo->owner, ctx.qry.search)) return 1; return 0; } -- cgit