diff options
| author | 2009-08-09 18:50:34 (JST) | |
|---|---|---|
| committer | 2009-08-09 20:41:54 (JST) | |
| commit | e1782fff8a78b7f265432603351281ad2988bb40 (patch) | |
| tree | 83a8ed623178b870f2e3f34041743ccde5bed944 | |
| parent | 97b3d252629a8a3b9d356c2532dec7611438e4b9 (diff) | |
| download | cgit-e1782fff8a78b7f265432603351281ad2988bb40.zip cgit-e1782fff8a78b7f265432603351281ad2988bb40.tar.gz | |
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>
| -rw-r--r-- | cmd.c | 2 | ||||
| -rw-r--r-- | ui-summary.c | 24 | ||||
| -rw-r--r-- | ui-summary.h | 2 |
3 files changed, 20 insertions, 8 deletions
| @@ -39,7 +39,7 @@ static void atom_fn(struct cgit_context *ctx) | |||
| 39 | static void about_fn(struct cgit_context *ctx) | 39 | static 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 | ||
| 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 | } |
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 | ||
| 4 | extern void cgit_print_summary(); | 4 | extern void cgit_print_summary(); |
| 5 | extern void cgit_print_repo_readme(); | 5 | extern void cgit_print_repo_readme(char *path); |
| 6 | 6 | ||
| 7 | #endif /* UI_SUMMARY_H */ | 7 | #endif /* UI_SUMMARY_H */ |
