summaryrefslogtreecommitdiffabout
authorLars Hjemli <hjemli@gmail.com>2009-08-09 09:50:34 (UTC)
committer Lars Hjemli <hjemli@gmail.com>2009-08-09 11:41:54 (UTC)
commite1782fff8a78b7f265432603351281ad2988bb40 (patch) (unidiff)
tree83a8ed623178b870f2e3f34041743ccde5bed944
parent97b3d252629a8a3b9d356c2532dec7611438e4b9 (diff)
downloadcgit-e1782fff8a78b7f265432603351281ad2988bb40.zip
cgit-e1782fff8a78b7f265432603351281ad2988bb40.tar.gz
cgit-e1782fff8a78b7f265432603351281ad2988bb40.tar.bz2
ui-summary: enable arbitrary paths below repo.readme
This change makes it possible to include any number of pages below the 'about' tab for a repository. The path is assumed to be located in the same directory as the 'repo.readme' file. Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--cmd.c2
-rw-r--r--ui-summary.c20
-rw-r--r--ui-summary.h2
3 files changed, 18 insertions, 6 deletions
diff --git a/cmd.c b/cmd.c
index cf97da7..766f903 100644
--- a/cmd.c
+++ b/cmd.c
@@ -36,13 +36,13 @@ static void atom_fn(struct cgit_context *ctx)
36 cgit_print_atom(ctx->qry.head, ctx->qry.path, 10); 36 cgit_print_atom(ctx->qry.head, ctx->qry.path, 10);
37} 37}
38 38
39static void about_fn(struct cgit_context *ctx) 39static void about_fn(struct cgit_context *ctx)
40{ 40{
41 if (ctx->repo) 41 if (ctx->repo)
42 cgit_print_repo_readme(); 42 cgit_print_repo_readme(ctx->qry.path);
43 else 43 else
44 cgit_print_site_readme(); 44 cgit_print_site_readme();
45} 45}
46 46
47static void blob_fn(struct cgit_context *ctx) 47static void blob_fn(struct cgit_context *ctx)
48{ 48{
diff --git a/ui-summary.c b/ui-summary.c
index ede4a62..f2a9b46 100644
--- a/ui-summary.c
+++ b/ui-summary.c
@@ -63,14 +63,26 @@ void cgit_print_summary()
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
73 if (!ctx.repo->readme)
74 return;
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;
72 html("<div id='summary'>"); 85 html("<div id='summary'>");
73 html_include(ctx.repo->readme); 86 html_include(tmp);
74 html("</div>"); 87 html("</div>");
75 } 88 }
76}
diff --git a/ui-summary.h b/ui-summary.h
index 3e13039..c01f560 100644
--- a/ui-summary.h
+++ b/ui-summary.h
@@ -1,7 +1,7 @@
1#ifndef UI_SUMMARY_H 1#ifndef UI_SUMMARY_H
2#define UI_SUMMARY_H 2#define UI_SUMMARY_H
3 3
4extern void cgit_print_summary(); 4extern void cgit_print_summary();
5extern void cgit_print_repo_readme(); 5extern void cgit_print_repo_readme(char *path);
6 6
7#endif /* UI_SUMMARY_H */ 7#endif /* UI_SUMMARY_H */