-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
@@ -34,17 +34,17 @@ static void HEAD_fn(struct cgit_context *ctx) | |||
34 | static void atom_fn(struct cgit_context *ctx) | 34 | static void atom_fn(struct cgit_context *ctx) |
35 | { | 35 | { |
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 | ||
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 | } |
46 | 46 | ||
47 | static void blob_fn(struct cgit_context *ctx) | 47 | static void blob_fn(struct cgit_context *ctx) |
48 | { | 48 | { |
49 | cgit_print_blob(ctx->qry.sha1, ctx->qry.path, ctx->qry.head); | 49 | cgit_print_blob(ctx->qry.sha1, ctx->qry.path, ctx->qry.head); |
50 | } | 50 | } |
diff --git a/ui-summary.c b/ui-summary.c index ede4a62..f2a9b46 100644 --- a/ui-summary.c +++ b/ui-summary.c | |||
@@ -61,16 +61,28 @@ void cgit_print_summary() | |||
61 | } | 61 | } |
62 | if (ctx.repo->clone_url) | 62 | if (ctx.repo->clone_url) |
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 | ||
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 | |||
@@ -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 | ||
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 */ |