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) (ignore whitespace changes)
-rw-r--r--cmd.c2
-rw-r--r--ui-summary.c24
-rw-r--r--ui-summary.h2
3 files changed, 20 insertions, 8 deletions
diff --git a/cmd.c b/cmd.c
index cf97da7..766f903 100644
--- a/cmd.c
+++ b/cmd.c
@@ -39,7 +39,7 @@ static void atom_fn(struct cgit_context *ctx)
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}
diff --git a/ui-summary.c b/ui-summary.c
index ede4a62..f2a9b46 100644
--- a/ui-summary.c
+++ b/ui-summary.c
@@ -66,11 +66,23 @@ void cgit_print_summary()
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 html_include(tmp);
87 html("</div>");
76} 88}
diff --git a/ui-summary.h b/ui-summary.h
index 3e13039..c01f560 100644
--- a/ui-summary.h
+++ b/ui-summary.h
@@ -2,6 +2,6 @@
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 */