From 0c8e184e9cbf4d3a1e907de9125f6d8210c169d6 Mon Sep 17 00:00:00 2001 From: Lars Hjemli Date: Tue, 30 Oct 2007 10:47:38 +0100 Subject: [PATCH] Change the cgit layout This modifies and hopefully improves the layout of all cgit pages: * Remove the header from all pages and replace it with a sidebar; most pages have sufficient width but many needs more height. * Add a dropdown-box to switch between branches, using a one-liner javascript to reload the current page in context of the selected branch. * Include refs found below refs/archives in the sidebar, appearing as a set of menuitems below a 'download' heading. * Include the brand new cgit logo Signed-off-by: Lars Hjemli --- cgit.css | 149 +++++++++++++++++++------------------------- cgit.h | 2 + cgit.png | Bin 0 -> 3790 bytes cgitrc | 9 ++- shared.c | 31 ++++++++++ ui-shared.c | 172 ++++++++++++++++++++++++++++++++++++--------------- ui-summary.c | 65 ++----------------- 7 files changed, 231 insertions(+), 197 deletions(-) create mode 100644 cgit.png diff --git a/cgit.css b/cgit.css index 5d47099..6cf4517 100644 --- a/cgit.css +++ b/cgit.css @@ -1,15 +1,16 @@ -body { - font-family: arial, sans-serif; - font-size: 11pt; - color: black; - background: white; -} - body, table { padding: 0em; margin: 0em; } +body { + font-family: sans; + font-size: 10pt; + color: #333; + background: white; + padding-left: 4px; +} + table { border-collapse: collapse; } @@ -35,12 +36,13 @@ h4 { } a { - color: blue; + color: #600; text-decoration: none; } a:hover { - text-decoration: underline; + background-color: #ddd; + text-decoration: none; } table.list { @@ -53,7 +55,7 @@ table.list tr { } table.list tr:hover { - background: #eee; + background: #f8f8f8; } table.list tr.nohover:hover { @@ -76,98 +78,78 @@ img { border: none; } -table#layout { - width: 100%; - border-collapse: collapse; - margin: 0px; -} - -td#header, td#logo { - color: #666; - background-color: #ddd; - border-bottom: solid 1px #000; -} - -td#header { - font-size: 150%; - font-weight: bold; - padding: 0.2em 0.5em; - vertical-align: text-bottom; -} - -td#header a { - color: #666; -} - -td#header a:hover { - text-decoration: underline; +div#sidebar { + vertical-align: top; + width: 162px; + padding: 0px 0px 0px 0px; + margin: 4px; + float: left; } -td#logo { - text-align: right; - vertical-align: middle; - padding-right: 0.5em; +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#crumb, td#search { - color: #ccc; - border-top: solid 3px #555; - background-color: #666; - border-bottom: solid 1px #333; - padding: 2px 1em; +div#sidebar div.infobox { + margin: 0px 0px 0pax 0px; + padding: 0.5em; + text-align: left; + background-color: #ccc; + border-top: solid 1px #eee; + border-left: solid 1px #eee; + border-right: solid 1px #aaa; + border-bottom: solid 1px #aaa; } -td#crumb { +div#sidebar div.infobox h1 { + font-size: 11pt; font-weight: bold; + margin: 0px; } -td#crumb a { - color: #ccc; - background-color: #666; - padding: 0em 0.5em 0em 0.5em; -} - -td#crumb a:hover { - color: #666; +div#sidebar div.infobox a.menu { + display: block; background-color: #ccc; + padding: 0.1em 0.5em; text-decoration: none; } -td#search { - text-align: right; - vertical-align: middle; - padding-right: 0.5em; -} - -td#search form { - margin: 0px; - padding: 0px; +div#sidebar div.infobox a.menu:hover { + background-color: #bbb; + text-decoration: none; } -td#search select { - font-size: 9pt; +div#sidebar div.infobox select { + width: 100%; + border: solid 1px #aaa; + background-color: #bbb; + margin: 2px 0px 0px 0px; padding: 0px; - border: solid 1px #333; - color: #333; - background-color: #fff; } -td#search input { - font-size: 9pt; - padding: 0px; +div#sidebar div.infobox input.txt { + width: 100%; + border: solid 1px #aaa; + background-color: #bbb; + margin: 2px 0px 0px 0px; + padding: 0; } -td#search input.txt { - width: 8em; - border: solid 1px #333; - color: #333; - background-color: #fff; +table#grid { + margin: 0px; } -td#search input.btn { - border: solid 1px #333; - color: #333; - background-color: #ccc; +td#content { + vertical-align: top; + padding: 1em 2em 1em 1em; + border: none; } div#summary { @@ -187,10 +169,6 @@ table#downloads th { background-color: #ccc; } -td#content { - padding: 1em 0.5em; -} - div#blob { border: solid 1px black; } @@ -284,7 +262,6 @@ div.diffstat-header { table.diffstat { border-collapse: collapse; - width: 100%; border: solid 1px #aaa; background-color: #eee; } @@ -325,7 +302,7 @@ table.diffstat td.upd a { } table.diffstat td.graph { - width: 75%; + width: 500px; vertical-align: middle; } diff --git a/cgit.h b/cgit.h index b8af970..42036c3 100644 --- a/cgit.h +++ b/cgit.h @@ -181,6 +181,8 @@ extern int chk_non_negative(int result, char *msg); extern int hextoint(char c); extern char *trim_end(const char *str, char c); +extern char *strlpart(char *txt, int maxlen); +extern char *strrpart(char *txt, int maxlen); extern void cgit_add_ref(struct reflist *list, struct refinfo *ref); extern int cgit_refs_cb(const char *refname, const unsigned char *sha1, diff --git a/cgit.png b/cgit.png new file mode 100644 index 0000000000000000000000000000000000000000..ee48197a8d55abf3345d913a87c17734c1af040e GIT binary patch literal 3790 zcmeAS@N?(olHy`uVBq!ia0y~yU|7Jwz>vVf%)r2~_Gjm61_lPk;vjb?X7l5|!3+$X zC7I670h!6k3=9>w-p))95XqD}e*fJ(8HpK^Z9L90O)i|w9_KupQUV(#jd~1JSba`B z;##AiG)ctKg;6{vwrR~Gr7p(6fCCNh6uKKW>8(@J(lUR+zW&v^cb98-?y9ug^LKT< zeQ19B@>TVrybW(El+-mv%@`Cqryu)XyfK}vy~Su_asz`1gP=iU9E-Z?&2z_(3v*;I z760SCSDN+0sgLvC?YI9g-+jXOQ6XbPfm7dex1~ibbJU(h!3*@8{Oz_s=_?NM(57VHiKNprloKztPt#T*XO0JsD1vasIx# z@9pocM@+->nk0{VcR%{9B((KF{qBF6`WvrIWtW>NH+{x3>EplU@2025?Yk(wdVMj2 zq1L|i*{$yz{&F!ac~ZTsOoHK59)nfYzVwO58DHoyI{ea9pF97fuJc-*jE5>g46-K} zTo-VeH0l{Jr5zBu!KD6xZ%?B=2ctA2`;jJ<1MD*u*xxYyTp%!|p?Lwy4# zScouxTu`FHev4PsX=#9H2)n7{euw7^PG8{7;Hcv8b=Z92{sni5Mo$CTum;nF+8MmJ z56W$@-^19~82muTg8v?S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gJhL)@>8lvJ+JZa%kJ-ZB-r->pfRu16S0m4pX^?4u*(! zOYY#rhW7^L+?fX*Pq1&`EsnTo@Wa8bfm!s~r^S^EIF%W%IeQ!Adbu$kIuIx?ut6xw zsVUF;x|zsNvkeXhN;~I2m@5}u6MBDZ$KScZYTs9QDKGoErz-SC;!kb!w(oyRK0M=* z`BhLB|Mcp+lRr1x?2xy7S5@&TUCc!JxZZK+b?R?3pGoY}eD)zx`I`$@Jj3Me_a@0Q zv6(Kspz!NrPXCU6#T;GX+6kMvO4NR8oVk{|h+lYaYh0tC)FGWD`-|+i9#ksns4_e- z?(pCHCUjwo(xsp~8XOjt0WL}Bk3DT!so7S*s4kKsXkFlR(`$>R$fO55ZrykB*c{8D z=ri+yn#k8jZjv+HK5J%qCfP1d__cXNA1s-h"); - html("\n\n"); + html("\n\n\n\n\n"); +} + +int print_branch_option(const char *refname, const unsigned char *sha1, + int flags, void *cb_data) +{ + char *name = (char *)refname; + html_option(name, name, cgit_query_head); + return 0; +} + +int print_archive_ref(const char *refname, const unsigned char *sha1, + int flags, void *cb_data) +{ + struct tag *tag; + struct taginfo *info; + struct object *obj; + char buf[256], *url; + unsigned char fileid[20]; + int *header = (int *)cb_data; + + if (prefixcmp(refname, "refs/archives")) + return 0; + strncpy(buf, refname+14, sizeof(buf)); + obj = parse_object(sha1); + if (!obj) + return 1; + if (obj->type == OBJ_TAG) { + tag = lookup_tag(sha1); + if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag))) + return 0; + hashcpy(fileid, tag->tagged->sha1); + } else if (obj->type != OBJ_BLOB) { + return 0; + } else { + hashcpy(fileid, sha1); + } + if (!*header) { + html("

download

"); + *header = 1; + } + url = cgit_pageurl(cgit_query_repo, "blob", + fmt("id=%s&path=%s", sha1_to_hex(fileid), + buf)); + html_link_open(url, NULL, "menu"); + html_txt(strlpart(buf, 20)); + html_link_close(); + return 0; +} + +void add_hidden_formfields(int incl_head, int incl_search) +{ + if (!cgit_virtual_root) { + if (cgit_query_repo) + html_hidden("r", cgit_query_repo); + if (cgit_query_page) + html_hidden("p", cgit_query_page); + } + + if (incl_head && strcmp(cgit_query_head, cgit_repo->defbranch)) + html_hidden("h", cgit_query_head); + + if (cgit_query_sha1) + html_hidden("id", cgit_query_sha1); + if (cgit_query_sha2) + html_hidden("id2", cgit_query_sha2); + + if (incl_search) { + if (cgit_query_grep) + html_hidden("qt", cgit_query_grep); + if (cgit_query_search) + html_hidden("q", cgit_query_search); + } } void cgit_print_pageheader(char *title, int show_search) { - html("
"); - html(""); - html(""); - html(""); - html("
"); + html_attr(cgit_rooturl()); + htmlf("'>\n", + cgit_logo); + html("
"); if (cgit_query_repo) { - html_txt(cgit_repo->name); - html(" ("); - html_txt(cgit_query_head); - html(") :  "); - reporevlink(NULL, "summary", NULL, NULL, cgit_query_head, + html("

"); + html_txt(strrpart(cgit_repo->name, 20)); + html("

\n"); + html_txt(cgit_repo->desc); + if (cgit_repo->owner) { + html("

\n

owner

\n"); + html_txt(cgit_repo->owner); + } + html("

\n

navigate

\n"); + reporevlink(NULL, "summary", NULL, "menu", cgit_query_head, NULL, NULL); - html(" "); - cgit_log_link("log", NULL, NULL, cgit_query_head, + cgit_log_link("log", NULL, "menu", cgit_query_head, cgit_query_sha1, cgit_query_path, 0); - html(" "); - cgit_tree_link("tree", NULL, NULL, cgit_query_head, + cgit_tree_link("tree", NULL, "menu", cgit_query_head, cgit_query_sha1, NULL); - html(" "); - cgit_commit_link("commit", NULL, NULL, cgit_query_head, + cgit_commit_link("commit", NULL, "menu", cgit_query_head, cgit_query_sha1); - html(" "); - cgit_diff_link("diff", NULL, NULL, cgit_query_head, + cgit_diff_link("diff", NULL, "menu", cgit_query_head, cgit_query_sha1, cgit_query_sha2, cgit_query_path); - } else { - html_txt("Index of repositories"); - } - html("
"); + + html("\n"); + + html("\n
\n"); } + void cgit_print_snapshot_start(const char *mimetype, const char *filename, struct cacheitem *item) { diff --git a/ui-summary.c b/ui-summary.c index ba90510..39fe330 100644 --- a/ui-summary.c +++ b/ui-summary.c @@ -120,47 +120,6 @@ static int print_tag(struct refinfo *ref) return 0; } -static int cgit_print_archive_cb(const char *refname, const unsigned char *sha1, - int flags, void *cb_data) -{ - struct tag *tag; - struct taginfo *info; - struct object *obj; - char buf[256], *url; - unsigned char fileid[20]; - - if (prefixcmp(refname, "refs/archives")) - return 0; - strncpy(buf, refname+14, sizeof(buf)); - obj = parse_object(sha1); - if (!obj) - return 1; - if (obj->type == OBJ_TAG) { - tag = lookup_tag(sha1); - if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag))) - return 0; - hashcpy(fileid, tag->tagged->sha1); - } else if (obj->type != OBJ_BLOB) { - return 0; - } else { - hashcpy(fileid, sha1); - } - if (!header) { - html(""); - html(""); - header = 1; - } - html(""); - return 0; -} - static void print_refs_link(char *path) { html("
Downloads
"); - url = cgit_pageurl(cgit_query_repo, "blob", - fmt("id=%s&path=%s", sha1_to_hex(fileid), - buf)); - html_link_open(url, NULL, NULL); - html_txt(buf); - html_link_close(); - html("
"); @@ -221,28 +180,16 @@ void cgit_print_tags(int maxcount) print_refs_link("tags"); } -static void cgit_print_archives() -{ - header = 0; - for_each_ref(cgit_print_archive_cb, NULL); - if (header) - html("
"); -} - void cgit_print_summary() { - html("
"); - cgit_print_archives(); - html("

"); - html_txt(cgit_repo->name); - html(" - "); - html_txt(cgit_repo->desc); - html("

"); - if (cgit_repo->readme) + if (cgit_repo->readme) { + html("
"); html_include(cgit_repo->readme); - html("
"); + html("
"); + } if (cgit_summary_log > 0) - cgit_print_log(cgit_query_head, 0, cgit_summary_log, NULL, NULL, NULL, 0); + cgit_print_log(cgit_query_head, 0, cgit_summary_log, NULL, + NULL, NULL, 0); html(""); if (cgit_summary_log > 0) html(""); -- 2.50.1