summaryrefslogtreecommitdiffabout
path: root/ui-summary.c
authorJason A. Donenfeld <Jason@zx2c4.com>2010-08-03 22:45:42 (UTC)
committer Lars Hjemli <hjemli@gmail.com>2010-08-20 16:57:30 (UTC)
commit379e80e3a83481d3639c5d312eeddcce57c486b2 (patch) (unidiff)
tree474ac38e3812008532d4ebd0b095ac835b5478b5 /ui-summary.c
parentaec9c245e7eaf444c7ae1851e3eda3b30748950f (diff)
downloadcgit-379e80e3a83481d3639c5d312eeddcce57c486b2.zip
cgit-379e80e3a83481d3639c5d312eeddcce57c486b2.tar.gz
cgit-379e80e3a83481d3639c5d312eeddcce57c486b2.tar.bz2
Support refspecs in about-filter.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com> Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Diffstat (limited to 'ui-summary.c') (more/less context) (ignore whitespace changes)
-rw-r--r--ui-summary.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/ui-summary.c b/ui-summary.c
index a2c018e..02f191e 100644
--- a/ui-summary.c
+++ b/ui-summary.c
@@ -1,6 +1,7 @@
1/* ui-summary.c: functions for generating repo summary page 1/* ui-summary.c: functions for generating repo summary page
2 * 2 *
3 * Copyright (C) 2006 Lars Hjemli 3 * Copyright (C) 2006 Lars Hjemli
4 * Copyright (C) 2010 Jason A. Donenfeld <Jason@zx2c4.com>
4 * 5 *
5 * Licensed under GNU General Public License v2 6 * Licensed under GNU General Public License v2
6 * (see COPYING for full license text) 7 * (see COPYING for full license text)
@@ -10,6 +11,7 @@
10#include "html.h" 11#include "html.h"
11#include "ui-log.h" 12#include "ui-log.h"
12#include "ui-refs.h" 13#include "ui-refs.h"
14#include "ui-blob.h"
13 15
14int urls = 0; 16int urls = 0;
15 17
@@ -68,24 +70,40 @@ void cgit_print_summary()
68 70
69void cgit_print_repo_readme(char *path) 71void cgit_print_repo_readme(char *path)
70{ 72{
71 char *slash, *tmp; 73 char *slash, *tmp, *colon, *ref = 0;
72 74
73 if (!ctx.repo->readme) 75 if (!ctx.repo->readme)
74 return; 76 return;
75 77
76 if (path) { 78 if (path) {
77 slash = strrchr(ctx.repo->readme, '/'); 79 slash = strrchr(ctx.repo->readme, '/');
78 if (!slash) 80 if (!slash) {
79 return; 81 slash = strchr(ctx.repo->readme, ':');
82 if (!slash)
83 return;
84 }
80 tmp = xmalloc(slash - ctx.repo->readme + 1 + strlen(path) + 1); 85 tmp = xmalloc(slash - ctx.repo->readme + 1 + strlen(path) + 1);
81 strncpy(tmp, ctx.repo->readme, slash - ctx.repo->readme + 1); 86 strncpy(tmp, ctx.repo->readme, slash - ctx.repo->readme + 1);
82 strcpy(tmp + (slash - ctx.repo->readme + 1), path); 87 strcpy(tmp + (slash - ctx.repo->readme + 1), path);
83 } else 88 } else
84 tmp = ctx.repo->readme; 89 tmp = ctx.repo->readme;
90 colon = strchr(tmp, ':');
91 if (colon && strlen(colon) > 1) {
92 *colon = '\0';
93 ref = tmp;
94 tmp = colon + 1;
95 while ((*tmp == '/' || *tmp == ':') && *tmp != '\0')
96 ++tmp;
97 if (!(*tmp))
98 return;
99 }
85 html("<div id='summary'>"); 100 html("<div id='summary'>");
86 if (ctx.repo->about_filter) 101 if (ctx.repo->about_filter)
87 cgit_open_filter(ctx.repo->about_filter); 102 cgit_open_filter(ctx.repo->about_filter);
88 html_include(tmp); 103 if (ref)
104 cgit_print_file(tmp, ref);
105 else
106 html_include(tmp);
89 if (ctx.repo->about_filter) 107 if (ctx.repo->about_filter)
90 cgit_close_filter(ctx.repo->about_filter); 108 cgit_close_filter(ctx.repo->about_filter);
91 html("</div>"); 109 html("</div>");