about summary refs log tree commit diff stats
path: root/ui-shared.c
diff options
context:
space:
mode:
Diffstat (limited to 'ui-shared.c')
-rw-r--r--ui-shared.c44
1 files changed, 37 insertions, 7 deletions
diff --git a/ui-shared.c b/ui-shared.c index acd8ab5..225a363 100644 --- a/ui-shared.c +++ b/ui-shared.c
@@ -894,6 +894,15 @@ void cgit_add_clone_urls(void (*fn)(const char *))
894 add_clone_urls(fn, ctx.cfg.clone_prefix, ctx.repo->url); 894 add_clone_urls(fn, ctx.cfg.clone_prefix, ctx.repo->url);
895} 895}
896 896
897static int print_this_commit_option(void)
898{
899 struct object_id oid;
900 if (!ctx.qry.head || get_oid(ctx.qry.head, &oid))
901 return 1;
902 html_option(oid_to_hex(&oid), "this commit", ctx.qry.head);
903 return 0;
904}
905
897static int print_branch_option(const char *refname, const struct object_id *oid, 906static int print_branch_option(const char *refname, const struct object_id *oid,
898 int flags, void *cb_data) 907 int flags, void *cb_data)
899{ 908{
@@ -995,15 +1004,18 @@ static void print_header(void)
995 if (ctx.repo) { 1004 if (ctx.repo) {
996 cgit_index_link("index", NULL, NULL, NULL, NULL, 0, 1); 1005 cgit_index_link("index", NULL, NULL, NULL, NULL, 0, 1);
997 html(" : "); 1006 html(" : ");
998 cgit_summary_link(ctx.repo->name, ctx.repo->name, NULL, NULL); 1007 cgit_summary_link(ctx.repo->name, NULL, NULL, NULL);
999 if (ctx.env.authenticated) { 1008 if (ctx.env.authenticated) {
1000 html("</td><td class='form'>"); 1009 html("</td><td class='form'>");
1001 html("<form method='get'>\n"); 1010 html("<form method='get'>\n");
1002 cgit_add_hidden_formfields(0, 1, ctx.qry.page); 1011 cgit_add_hidden_formfields(0, 1, ctx.qry.page);
1003 html("<select name='h' onchange='this.form.submit();'>\n"); 1012 html("<select name='h' onchange='this.form.submit();'>\n");
1013 print_this_commit_option();
1014 html("<optgroup label='branches'>");
1004 for_each_branch_ref(print_branch_option, ctx.qry.head); 1015 for_each_branch_ref(print_branch_option, ctx.qry.head);
1005 if (ctx.repo->enable_remote_branches) 1016 if (ctx.repo->enable_remote_branches)
1006 for_each_remote_ref(print_branch_option, ctx.qry.head); 1017 for_each_remote_ref(print_branch_option, ctx.qry.head);
1018 html("</optgroup>");
1007 html("</select> "); 1019 html("</select> ");
1008 html("<input type='submit' value='switch'/>"); 1020 html("<input type='submit' value='switch'/>");
1009 html("</form>"); 1021 html("</form>");
@@ -1016,7 +1028,13 @@ static void print_header(void)
1016 if (ctx.repo) { 1028 if (ctx.repo) {
1017 html_txt(ctx.repo->desc); 1029 html_txt(ctx.repo->desc);
1018 html("</td><td class='sub right'>"); 1030 html("</td><td class='sub right'>");
1019 html_txt(ctx.repo->owner); 1031 if (ctx.repo->owner_filter) {
1032 cgit_open_filter(ctx.repo->owner_filter);
1033 html_txt(ctx.repo->owner);
1034 cgit_close_filter(ctx.repo->owner_filter);
1035 } else {
1036 html_txt(ctx.repo->owner);
1037 }
1020 } else { 1038 } else {
1021 if (ctx.cfg.root_desc) 1039 if (ctx.cfg.root_desc)
1022 html_txt(ctx.cfg.root_desc); 1040 html_txt(ctx.cfg.root_desc);
@@ -1032,32 +1050,41 @@ void cgit_print_pageheader(void)
1032 1050
1033 html("<table class='tabs'><tr><td>\n"); 1051 html("<table class='tabs'><tr><td>\n");
1034 if (ctx.env.authenticated && ctx.repo) { 1052 if (ctx.env.authenticated && ctx.repo) {
1035 if (ctx.repo->readme.nr) 1053 if (ctx.repo->readme.nr) {
1036 reporevlink("about", "about", NULL, 1054 reporevlink("about", "about", NULL,
1037 hc("about"), ctx.qry.head, NULL, 1055 hc("about"), ctx.qry.head, NULL,
1038 NULL); 1056 NULL);
1057 html(" ");
1058 }
1039 cgit_summary_link("summary", NULL, hc("summary"), 1059 cgit_summary_link("summary", NULL, hc("summary"),
1040 ctx.qry.head); 1060 ctx.qry.head);
1061 html(" ");
1041 cgit_refs_link("refs", NULL, hc("refs"), ctx.qry.head, 1062 cgit_refs_link("refs", NULL, hc("refs"), ctx.qry.head,
1042 ctx.qry.oid, NULL); 1063 ctx.qry.oid, NULL);
1064 html(" ");
1043 cgit_log_link("log", NULL, hc("log"), ctx.qry.head, 1065 cgit_log_link("log", NULL, hc("log"), ctx.qry.head,
1044 NULL, ctx.qry.vpath, 0, NULL, NULL, 1066 NULL, ctx.qry.vpath, 0, NULL, NULL,
1045 ctx.qry.showmsg, ctx.qry.follow); 1067 ctx.qry.showmsg, ctx.qry.follow);
1068 html(" ");
1046 if (ctx.qry.page && !strcmp(ctx.qry.page, "blame")) 1069 if (ctx.qry.page && !strcmp(ctx.qry.page, "blame"))
1047 cgit_blame_link("blame", NULL, hc("blame"), ctx.qry.head, 1070 cgit_blame_link("blame", NULL, hc("blame"), ctx.qry.head,
1048 ctx.qry.oid, ctx.qry.vpath); 1071 ctx.qry.oid, ctx.qry.vpath);
1049 else 1072 else
1050 cgit_tree_link("tree", NULL, hc("tree"), ctx.qry.head, 1073 cgit_tree_link("tree", NULL, hc("tree"), ctx.qry.head,
1051 ctx.qry.oid, ctx.qry.vpath); 1074 ctx.qry.oid, ctx.qry.vpath);
1075 html(" ");
1052 cgit_commit_link("commit", NULL, hc("commit"), 1076 cgit_commit_link("commit", NULL, hc("commit"),
1053 ctx.qry.head, ctx.qry.oid, ctx.qry.vpath); 1077 ctx.qry.head, ctx.qry.oid, ctx.qry.vpath);
1078 html(" ");
1054 cgit_diff_link("diff", NULL, hc("diff"), ctx.qry.head, 1079 cgit_diff_link("diff", NULL, hc("diff"), ctx.qry.head,
1055 ctx.qry.oid, ctx.qry.oid2, ctx.qry.vpath); 1080 ctx.qry.oid, ctx.qry.oid2, ctx.qry.vpath);
1056 if (ctx.repo->max_stats) 1081 if (ctx.repo->max_stats) {
1082 html(" ");
1057 cgit_stats_link("stats", NULL, hc("stats"), 1083 cgit_stats_link("stats", NULL, hc("stats"),
1058 ctx.qry.head, ctx.qry.vpath); 1084 ctx.qry.head, ctx.qry.vpath);
1085 }
1059 if (ctx.repo->homepage) { 1086 if (ctx.repo->homepage) {
1060 html("<a href='"); 1087 html(" <a href='");
1061 html_attr(ctx.repo->homepage); 1088 html_attr(ctx.repo->homepage);
1062 html("'>homepage</a>"); 1089 html("'>homepage</a>");
1063 } 1090 }
@@ -1201,9 +1228,12 @@ void cgit_set_title_from_path(const char *path)
1201 if (!path) 1228 if (!path)
1202 return; 1229 return;
1203 1230
1204 for (last_slash = path + strlen(path); (slash = memrchr(path, '/', last_slash - path)) != NULL; last_slash = slash) { 1231 last_slash = path + strlen(path);
1232 for (slash = last_slash; slash > path; --slash) {
1233 if (*slash != '/') continue;
1205 strbuf_add(&sb, slash + 1, last_slash - slash - 1); 1234 strbuf_add(&sb, slash + 1, last_slash - slash - 1);
1206 strbuf_addstr(&sb, " \xc2\xab "); 1235 strbuf_addstr(&sb, " \xc2\xab ");
1236 last_slash = slash;
1207 } 1237 }
1208 strbuf_add(&sb, path, last_slash - path); 1238 strbuf_add(&sb, path, last_slash - path);
1209 strbuf_addf(&sb, " - %s", ctx.page.title); 1239 strbuf_addf(&sb, " - %s", ctx.page.title);