summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--cgit.c2
-rw-r--r--ui-shared.c9
-rw-r--r--ui-tag.c24
3 files changed, 27 insertions, 8 deletions
diff --git a/cgit.c b/cgit.c
index bd37788..a17f40d 100644
--- a/cgit.c
+++ b/cgit.c
@@ -200,24 +200,26 @@ void config_cb(const char *name, const char *value)
200 200
201static void querystring_cb(const char *name, const char *value) 201static void querystring_cb(const char *name, const char *value)
202{ 202{
203 if (!value) 203 if (!value)
204 value = ""; 204 value = "";
205 205
206 if (!strcmp(name,"r")) { 206 if (!strcmp(name,"r")) {
207 ctx.qry.repo = xstrdup(value); 207 ctx.qry.repo = xstrdup(value);
208 ctx.repo = cgit_get_repoinfo(value); 208 ctx.repo = cgit_get_repoinfo(value);
209 } else if (!strcmp(name, "p")) { 209 } else if (!strcmp(name, "p")) {
210 ctx.qry.page = xstrdup(value); 210 ctx.qry.page = xstrdup(value);
211 } else if (!strcmp(name, "url")) { 211 } else if (!strcmp(name, "url")) {
212 if (*value == '/')
213 value++;
212 ctx.qry.url = xstrdup(value); 214 ctx.qry.url = xstrdup(value);
213 cgit_parse_url(value); 215 cgit_parse_url(value);
214 } else if (!strcmp(name, "qt")) { 216 } else if (!strcmp(name, "qt")) {
215 ctx.qry.grep = xstrdup(value); 217 ctx.qry.grep = xstrdup(value);
216 } else if (!strcmp(name, "q")) { 218 } else if (!strcmp(name, "q")) {
217 ctx.qry.search = xstrdup(value); 219 ctx.qry.search = xstrdup(value);
218 } else if (!strcmp(name, "h")) { 220 } else if (!strcmp(name, "h")) {
219 ctx.qry.head = xstrdup(value); 221 ctx.qry.head = xstrdup(value);
220 ctx.qry.has_symref = 1; 222 ctx.qry.has_symref = 1;
221 } else if (!strcmp(name, "id")) { 223 } else if (!strcmp(name, "id")) {
222 ctx.qry.sha1 = xstrdup(value); 224 ctx.qry.sha1 = xstrdup(value);
223 ctx.qry.has_sha1 = 1; 225 ctx.qry.has_sha1 = 1;
diff --git a/ui-shared.c b/ui-shared.c
index 4049a2b..3a9e67b 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -751,23 +751,28 @@ void cgit_print_filemode(unsigned short mode)
751 html("m"); 751 html("m");
752 else 752 else
753 html("-"); 753 html("-");
754 html_fileperm(mode >> 6); 754 html_fileperm(mode >> 6);
755 html_fileperm(mode >> 3); 755 html_fileperm(mode >> 3);
756 html_fileperm(mode); 756 html_fileperm(mode);
757} 757}
758 758
759void cgit_print_snapshot_links(const char *repo, const char *head, 759void cgit_print_snapshot_links(const char *repo, const char *head,
760 const char *hex, int snapshots) 760 const char *hex, int snapshots)
761{ 761{
762 const struct cgit_snapshot_format* f; 762 const struct cgit_snapshot_format* f;
763 char *prefix;
763 char *filename; 764 char *filename;
765 unsigned char sha1[20];
764 766
767 if (get_sha1(fmt("refs/tags/%s", hex), sha1) == 0 &&
768 (hex[0] == 'v' || hex[0] == 'V') && isdigit(hex[1]))
769 hex++;
770 prefix = xstrdup(fmt("%s-%s", cgit_repobasename(repo), hex));
765 for (f = cgit_snapshot_formats; f->suffix; f++) { 771 for (f = cgit_snapshot_formats; f->suffix; f++) {
766 if (!(snapshots & f->bit)) 772 if (!(snapshots & f->bit))
767 continue; 773 continue;
768 filename = fmt("%s-%s%s", cgit_repobasename(repo), hex, 774 filename = fmt("%s%s", prefix, f->suffix);
769 f->suffix);
770 cgit_snapshot_link(filename, NULL, NULL, NULL, NULL, filename); 775 cgit_snapshot_link(filename, NULL, NULL, NULL, NULL, filename);
771 html("<br/>"); 776 html("<br/>");
772 } 777 }
773} 778}
diff --git a/ui-tag.c b/ui-tag.c
index c2d72af..39e4cb8 100644
--- a/ui-tag.c
+++ b/ui-tag.c
@@ -21,24 +21,32 @@ static void print_tag_content(char *buf)
21 p = strchr(buf, '\n'); 21 p = strchr(buf, '\n');
22 if (p) 22 if (p)
23 *p = '\0'; 23 *p = '\0';
24 html_txt(buf); 24 html_txt(buf);
25 html("</div>"); 25 html("</div>");
26 if (p) { 26 if (p) {
27 html("<div class='commit-msg'>"); 27 html("<div class='commit-msg'>");
28 html_txt(++p); 28 html_txt(++p);
29 html("</div>"); 29 html("</div>");
30 } 30 }
31} 31}
32 32
33void print_download_links(char *revname)
34{
35 html("<tr><th>download</th><td class='sha1'>");
36 cgit_print_snapshot_links(ctx.qry.repo, ctx.qry.head,
37 revname, ctx.repo->snapshots);
38 html("</td></tr>");
39}
40
33void cgit_print_tag(char *revname) 41void cgit_print_tag(char *revname)
34{ 42{
35 unsigned char sha1[20]; 43 unsigned char sha1[20];
36 struct object *obj; 44 struct object *obj;
37 struct tag *tag; 45 struct tag *tag;
38 struct taginfo *info; 46 struct taginfo *info;
39 47
40 if (!revname) 48 if (!revname)
41 revname = ctx.qry.head; 49 revname = ctx.qry.head;
42 50
43 if (get_sha1(fmt("refs/tags/%s", revname), sha1)) { 51 if (get_sha1(fmt("refs/tags/%s", revname), sha1)) {
44 cgit_print_error(fmt("Bad tag reference: %s", revname)); 52 cgit_print_error(fmt("Bad tag reference: %s", revname));
@@ -47,46 +55,50 @@ void cgit_print_tag(char *revname)
47 obj = parse_object(sha1); 55 obj = parse_object(sha1);
48 if (!obj) { 56 if (!obj) {
49 cgit_print_error(fmt("Bad object id: %s", sha1_to_hex(sha1))); 57 cgit_print_error(fmt("Bad object id: %s", sha1_to_hex(sha1)));
50 return; 58 return;
51 } 59 }
52 if (obj->type == OBJ_TAG) { 60 if (obj->type == OBJ_TAG) {
53 tag = lookup_tag(sha1); 61 tag = lookup_tag(sha1);
54 if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag))) { 62 if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag))) {
55 cgit_print_error(fmt("Bad tag object: %s", revname)); 63 cgit_print_error(fmt("Bad tag object: %s", revname));
56 return; 64 return;
57 } 65 }
58 html("<table class='commit-info'>\n"); 66 html("<table class='commit-info'>\n");
59 htmlf("<tr><td>Tag name</td><td>"); 67 htmlf("<tr><td>tag name</td><td>");
60 html_txt(revname); 68 html_txt(revname);
61 htmlf(" (%s)</td></tr>\n", sha1_to_hex(sha1)); 69 htmlf(" (%s)</td></tr>\n", sha1_to_hex(sha1));
62 if (info->tagger_date > 0) { 70 if (info->tagger_date > 0) {
63 html("<tr><td>Tag date</td><td>"); 71 html("<tr><td>tag date</td><td>");
64 cgit_print_date(info->tagger_date, FMT_LONGDATE, ctx.cfg.local_time); 72 cgit_print_date(info->tagger_date, FMT_LONGDATE, ctx.cfg.local_time);
65 html("</td></tr>\n"); 73 html("</td></tr>\n");
66 } 74 }
67 if (info->tagger) { 75 if (info->tagger) {
68 html("<tr><td>Tagged by</td><td>"); 76 html("<tr><td>tagged by</td><td>");
69 html_txt(info->tagger); 77 html_txt(info->tagger);
70 if (info->tagger_email && !ctx.cfg.noplainemail) { 78 if (info->tagger_email && !ctx.cfg.noplainemail) {
71 html(" "); 79 html(" ");
72 html_txt(info->tagger_email); 80 html_txt(info->tagger_email);
73 } 81 }
74 html("</td></tr>\n"); 82 html("</td></tr>\n");
75 } 83 }
76 html("<tr><td>Tagged object</td><td>"); 84 html("<tr><td>tagged object</td><td class='sha1'>");
77 cgit_object_link(tag->tagged); 85 cgit_object_link(tag->tagged);
78 html("</td></tr>\n"); 86 html("</td></tr>\n");
87 if (ctx.repo->snapshots)
88 print_download_links(revname);
79 html("</table>\n"); 89 html("</table>\n");
80 print_tag_content(info->msg); 90 print_tag_content(info->msg);
81 } else { 91 } else {
82 html("<table class='commit-info'>\n"); 92 html("<table class='commit-info'>\n");
83 htmlf("<tr><td>Tag name</td><td>"); 93 htmlf("<tr><td>tag name</td><td>");
84 html_txt(revname); 94 html_txt(revname);
85 html("</td></tr>\n"); 95 html("</td></tr>\n");
86 html("<tr><td>Tagged object</td><td>"); 96 html("<tr><td>Tagged object</td><td class='sha1'>");
87 cgit_object_link(obj); 97 cgit_object_link(obj);
88 html("</td></tr>\n"); 98 html("</td></tr>\n");
99 if (ctx.repo->snapshots)
100 print_download_links(revname);
89 html("</table>\n"); 101 html("</table>\n");
90 } 102 }
91 return; 103 return;
92} 104}