summaryrefslogtreecommitdiffabout
authorLars Hjemli <hjemli@gmail.com>2008-07-27 09:54:06 (UTC)
committer Lars Hjemli <hjemli@gmail.com>2008-07-27 09:54:06 (UTC)
commit78af25ccac7aab6baccd58e4d65bfe879a25dd54 (patch) (unidiff)
tree27eb89bc2b0d44282f41007d0bf292627bb654e1
parent50989d3b471aeecba563cfb1dfbffeeecf6c83cb (diff)
downloadcgit-78af25ccac7aab6baccd58e4d65bfe879a25dd54.zip
cgit-78af25ccac7aab6baccd58e4d65bfe879a25dd54.tar.gz
cgit-78af25ccac7aab6baccd58e4d65bfe879a25dd54.tar.bz2
ui-summary: show clone urls
If either repo.clone-url or clone-prefix is specified in cgitrc, all space-separated values in the config option is printed as a possible clone url on the repo summary page. Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--ui-summary.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/ui-summary.c b/ui-summary.c
index ad0b4a7..29e1544 100644
--- a/ui-summary.c
+++ b/ui-summary.c
@@ -8,23 +8,64 @@
8 8
9#include "cgit.h" 9#include "cgit.h"
10#include "html.h" 10#include "html.h"
11#include "ui-log.h" 11#include "ui-log.h"
12#include "ui-refs.h" 12#include "ui-refs.h"
13 13
14int urls = 0;
15
16static void print_url(char *base, char *suffix)
17{
18 if (!base || !*base)
19 return;
20 if (urls++ == 0) {
21 html("<tr class='nohover'><td colspan='4'>&nbsp;</td></tr>");
22 html("<tr><th class='left' colspan='4'>Clone</th></tr>\n");
23 }
24 if (suffix && *suffix)
25 base = fmt("%s/%s", base, suffix);
26 html("<tr><td colspan='4'><a href='");
27 html_attr(base);
28 html("'>");
29 html_txt(base);
30 html("</a></td></tr>\n");
31}
32
33static void print_urls(char *txt, char *suffix)
34{
35 char *h = txt, *t, c;
36
37 while (h && *h) {
38 while (h && *h == ' ')
39 h++;
40 t = h;
41 while (t && *t && *t != ' ')
42 t++;
43 c = *t;
44 *t = 0;
45 print_url(h, suffix);
46 *t = c;
47 h = t;
48 }
49}
50
14void cgit_print_summary() 51void cgit_print_summary()
15{ 52{
16 html("<table summary='repository info' class='list nowrap'>"); 53 html("<table summary='repository info' class='list nowrap'>");
17 cgit_print_branches(ctx.cfg.summary_branches); 54 cgit_print_branches(ctx.cfg.summary_branches);
18 html("<tr class='nohover'><td colspan='4'>&nbsp;</td></tr>"); 55 html("<tr class='nohover'><td colspan='4'>&nbsp;</td></tr>");
19 cgit_print_tags(ctx.cfg.summary_tags); 56 cgit_print_tags(ctx.cfg.summary_tags);
20 if (ctx.cfg.summary_log > 0) { 57 if (ctx.cfg.summary_log > 0) {
21 html("<tr class='nohover'><td colspan='4'>&nbsp;</td></tr>"); 58 html("<tr class='nohover'><td colspan='4'>&nbsp;</td></tr>");
22 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,
23 NULL, NULL, 0); 60 NULL, NULL, 0);
24 } 61 }
62 if (ctx.repo->clone_url)
63 print_urls(ctx.repo->clone_url, NULL);
64 else if (ctx.cfg.clone_prefix)
65 print_urls(ctx.cfg.clone_prefix, ctx.repo->url);
25 html("</table>"); 66 html("</table>");
26} 67}
27 68
28void cgit_print_repo_readme() 69void cgit_print_repo_readme()
29{ 70{
30 if (ctx.repo->readme) { 71 if (ctx.repo->readme) {