diff options
author | Lars Hjemli | 2009-08-09 11:50:34 +0200 |
---|---|---|
committer | Lars Hjemli | 2009-08-09 13:41:54 +0200 |
commit | e1782fff8a78b7f265432603351281ad2988bb40 (patch) | |
tree | 83a8ed623178b870f2e3f34041743ccde5bed944 /ui-summary.c | |
parent | 97b3d252629a8a3b9d356c2532dec7611438e4b9 (diff) | |
download | cgit-e1782fff8a78b7f265432603351281ad2988bb40.tar.gz cgit-e1782fff8a78b7f265432603351281ad2988bb40.tar.bz2 cgit-e1782fff8a78b7f265432603351281ad2988bb40.zip |
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 (limited to 'ui-summary.c')
-rw-r--r-- | ui-summary.c | 24 |
1 files changed, 18 insertions, 6 deletions
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 | ||
69 | void cgit_print_repo_readme() | 69 | void 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 | } |