diff options
Diffstat (limited to 'ui-summary.c')
| -rw-r--r-- | ui-summary.c | 65 |
1 files changed, 6 insertions, 59 deletions
diff --git a/ui-summary.c b/ui-summary.c index ba90510..39fe330 100644 --- a/ui-summary.c +++ b/ui-summary.c | |||
| @@ -120,47 +120,6 @@ static int print_tag(struct refinfo *ref) | |||
| 120 | return 0; | 120 | return 0; |
| 121 | } | 121 | } |
| 122 | 122 | ||
| 123 | static int cgit_print_archive_cb(const char *refname, const unsigned char *sha1, | ||
| 124 | int flags, void *cb_data) | ||
| 125 | { | ||
| 126 | struct tag *tag; | ||
| 127 | struct taginfo *info; | ||
| 128 | struct object *obj; | ||
| 129 | char buf[256], *url; | ||
| 130 | unsigned char fileid[20]; | ||
| 131 | |||
| 132 | if (prefixcmp(refname, "refs/archives")) | ||
| 133 | return 0; | ||
| 134 | strncpy(buf, refname+14, sizeof(buf)); | ||
| 135 | obj = parse_object(sha1); | ||
| 136 | if (!obj) | ||
| 137 | return 1; | ||
| 138 | if (obj->type == OBJ_TAG) { | ||
| 139 | tag = lookup_tag(sha1); | ||
| 140 | if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag))) | ||
| 141 | return 0; | ||
| 142 | hashcpy(fileid, tag->tagged->sha1); | ||
| 143 | } else if (obj->type != OBJ_BLOB) { | ||
| 144 | return 0; | ||
| 145 | } else { | ||
| 146 | hashcpy(fileid, sha1); | ||
| 147 | } | ||
| 148 | if (!header) { | ||
| 149 | html("<table id='downloads'>"); | ||
| 150 | html("<tr><th>Downloads</th></tr>"); | ||
| 151 | header = 1; | ||
| 152 | } | ||
| 153 | html("<tr><td>"); | ||
| 154 | url = cgit_pageurl(cgit_query_repo, "blob", | ||
| 155 | fmt("id=%s&path=%s", sha1_to_hex(fileid), | ||
| 156 | buf)); | ||
| 157 | html_link_open(url, NULL, NULL); | ||
| 158 | html_txt(buf); | ||
| 159 | html_link_close(); | ||
| 160 | html("</td></tr>"); | ||
| 161 | return 0; | ||
| 162 | } | ||
| 163 | |||
| 164 | static void print_refs_link(char *path) | 123 | static void print_refs_link(char *path) |
| 165 | { | 124 | { |
| 166 | html("<tr class='nohover'><td colspan='4'>"); | 125 | html("<tr class='nohover'><td colspan='4'>"); |
| @@ -221,28 +180,16 @@ void cgit_print_tags(int maxcount) | |||
| 221 | print_refs_link("tags"); | 180 | print_refs_link("tags"); |
| 222 | } | 181 | } |
| 223 | 182 | ||
| 224 | static void cgit_print_archives() | ||
| 225 | { | ||
| 226 | header = 0; | ||
| 227 | for_each_ref(cgit_print_archive_cb, NULL); | ||
| 228 | if (header) | ||
| 229 | html("</table>"); | ||
| 230 | } | ||
| 231 | |||
| 232 | void cgit_print_summary() | 183 | void cgit_print_summary() |
| 233 | { | 184 | { |
| 234 | html("<div id='summary'>"); | 185 | if (cgit_repo->readme) { |
| 235 | cgit_print_archives(); | 186 | html("<div id='summary'>"); |
| 236 | html("<h2>"); | ||
| 237 | html_txt(cgit_repo->name); | ||
| 238 | html(" - "); | ||
| 239 | html_txt(cgit_repo->desc); | ||
| 240 | html("</h2>"); | ||
| 241 | if (cgit_repo->readme) | ||
| 242 | html_include(cgit_repo->readme); | 187 | html_include(cgit_repo->readme); |
| 243 | html("</div>"); | 188 | html("</div>"); |
| 189 | } | ||
| 244 | if (cgit_summary_log > 0) | 190 | if (cgit_summary_log > 0) |
| 245 | cgit_print_log(cgit_query_head, 0, cgit_summary_log, NULL, NULL, NULL, 0); | 191 | cgit_print_log(cgit_query_head, 0, cgit_summary_log, NULL, |
| 192 | NULL, NULL, 0); | ||
| 246 | html("<table class='list nowrap'>"); | 193 | html("<table class='list nowrap'>"); |
| 247 | if (cgit_summary_log > 0) | 194 | if (cgit_summary_log > 0) |
| 248 | html("<tr class='nohover'><td colspan='4'> </td></tr>"); | 195 | html("<tr class='nohover'><td colspan='4'> </td></tr>"); |
