summaryrefslogtreecommitdiffabout
path: root/ui-summary.c
Unidiff
Diffstat (limited to 'ui-summary.c') (more/less context) (ignore whitespace changes)
-rw-r--r--ui-summary.c28
1 files changed, 22 insertions, 6 deletions
diff --git a/ui-summary.c b/ui-summary.c
index ede4a62..a2c018e 100644
--- a/ui-summary.c
+++ b/ui-summary.c
@@ -21,56 +21,72 @@ static void print_url(char *base, char *suffix)
21 html("<tr class='nohover'><td colspan='4'>&nbsp;</td></tr>"); 21 html("<tr class='nohover'><td colspan='4'>&nbsp;</td></tr>");
22 html("<tr><th class='left' colspan='4'>Clone</th></tr>\n"); 22 html("<tr><th class='left' colspan='4'>Clone</th></tr>\n");
23 } 23 }
24 if (suffix && *suffix) 24 if (suffix && *suffix)
25 base = fmt("%s/%s", base, suffix); 25 base = fmt("%s/%s", base, suffix);
26 html("<tr><td colspan='4'><a href='"); 26 html("<tr><td colspan='4'><a href='");
27 html_url_path(base); 27 html_url_path(base);
28 html("'>"); 28 html("'>");
29 html_txt(base); 29 html_txt(base);
30 html("</a></td></tr>\n"); 30 html("</a></td></tr>\n");
31} 31}
32 32
33static void print_urls(char *txt, char *suffix) 33static void print_urls(char *txt, char *suffix)
34{ 34{
35 char *h = txt, *t, c; 35 char *h = txt, *t, c;
36 36
37 while (h && *h) { 37 while (h && *h) {
38 while (h && *h == ' ') 38 while (h && *h == ' ')
39 h++; 39 h++;
40 t = h; 40 t = h;
41 while (t && *t && *t != ' ') 41 while (t && *t && *t != ' ')
42 t++; 42 t++;
43 c = *t; 43 c = *t;
44 *t = 0; 44 *t = 0;
45 print_url(h, suffix); 45 print_url(h, suffix);
46 *t = c; 46 *t = c;
47 h = t; 47 h = t;
48 } 48 }
49} 49}
50 50
51void cgit_print_summary() 51void cgit_print_summary()
52{ 52{
53 html("<table summary='repository info' class='list nowrap'>"); 53 html("<table summary='repository info' class='list nowrap'>");
54 cgit_print_branches(ctx.cfg.summary_branches); 54 cgit_print_branches(ctx.cfg.summary_branches);
55 html("<tr class='nohover'><td colspan='4'>&nbsp;</td></tr>"); 55 html("<tr class='nohover'><td colspan='4'>&nbsp;</td></tr>");
56 cgit_print_tags(ctx.cfg.summary_tags); 56 cgit_print_tags(ctx.cfg.summary_tags);
57 if (ctx.cfg.summary_log > 0) { 57 if (ctx.cfg.summary_log > 0) {
58 html("<tr class='nohover'><td colspan='4'>&nbsp;</td></tr>"); 58 html("<tr class='nohover'><td colspan='4'>&nbsp;</td></tr>");
59 cgit_print_log(ctx.qry.head, 0, ctx.cfg.summary_log, NULL, 59 cgit_print_log(ctx.qry.head, 0, ctx.cfg.summary_log, NULL,
60 NULL, NULL, 0); 60 NULL, NULL, 0);
61 } 61 }
62 if (ctx.repo->clone_url) 62 if (ctx.repo->clone_url)
63 print_urls(ctx.repo->clone_url, NULL); 63 print_urls(ctx.repo->clone_url, NULL);
64 else if (ctx.cfg.clone_prefix) 64 else if (ctx.cfg.clone_prefix)
65 print_urls(ctx.cfg.clone_prefix, ctx.repo->url); 65 print_urls(ctx.cfg.clone_prefix, ctx.repo->url);
66 html("</table>"); 66 html("</table>");
67} 67}
68 68
69void cgit_print_repo_readme() 69void cgit_print_repo_readme(char *path)
70{ 70{
71 if (ctx.repo->readme) { 71 char *slash, *tmp;
72 html("<div id='summary'>"); 72
73 html_include(ctx.repo->readme); 73 if (!ctx.repo->readme)
74 html("</div>"); 74 return;
75 } 75
76 if (path) {
77 slash = strrchr(ctx.repo->readme, '/');
78 if (!slash)
79 return;
80 tmp = xmalloc(slash - ctx.repo->readme + 1 + strlen(path) + 1);
81 strncpy(tmp, ctx.repo->readme, slash - ctx.repo->readme + 1);
82 strcpy(tmp + (slash - ctx.repo->readme + 1), path);
83 } else
84 tmp = ctx.repo->readme;
85 html("<div id='summary'>");
86 if (ctx.repo->about_filter)
87 cgit_open_filter(ctx.repo->about_filter);
88 html_include(tmp);
89 if (ctx.repo->about_filter)
90 cgit_close_filter(ctx.repo->about_filter);
91 html("</div>");
76} 92}