-rw-r--r-- | ui-shared.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/ui-shared.c b/ui-shared.c index 37c60b2..4818e70 100644 --- a/ui-shared.c +++ b/ui-shared.c | |||
@@ -229,64 +229,70 @@ static char *repolink(char *title, char *class, char *page, char *head, | |||
229 | } | 229 | } |
230 | if (head && strcmp(head, ctx.repo->defbranch)) { | 230 | if (head && strcmp(head, ctx.repo->defbranch)) { |
231 | html(delim); | 231 | html(delim); |
232 | html("h="); | 232 | html("h="); |
233 | html_attr(head); | 233 | html_attr(head); |
234 | delim = "&"; | 234 | delim = "&"; |
235 | } | 235 | } |
236 | return fmt("%s", delim); | 236 | return fmt("%s", delim); |
237 | } | 237 | } |
238 | 238 | ||
239 | static void reporevlink(char *page, char *name, char *title, char *class, | 239 | static void reporevlink(char *page, char *name, char *title, char *class, |
240 | char *head, char *rev, char *path) | 240 | char *head, char *rev, char *path) |
241 | { | 241 | { |
242 | char *delim; | 242 | char *delim; |
243 | 243 | ||
244 | delim = repolink(title, class, page, head, path); | 244 | delim = repolink(title, class, page, head, path); |
245 | if (rev && strcmp(rev, ctx.qry.head)) { | 245 | if (rev && strcmp(rev, ctx.qry.head)) { |
246 | html(delim); | 246 | html(delim); |
247 | html("id="); | 247 | html("id="); |
248 | html_attr(rev); | 248 | html_attr(rev); |
249 | } | 249 | } |
250 | html("'>"); | 250 | html("'>"); |
251 | html_txt(name); | 251 | html_txt(name); |
252 | html("</a>"); | 252 | html("</a>"); |
253 | } | 253 | } |
254 | 254 | ||
255 | void cgit_tree_link(char *name, char *title, char *class, char *head, | 255 | void cgit_tree_link(char *name, char *title, char *class, char *head, |
256 | char *rev, char *path) | 256 | char *rev, char *path) |
257 | { | 257 | { |
258 | reporevlink("tree", name, title, class, head, rev, path); | 258 | reporevlink("tree", name, title, class, head, rev, path); |
259 | } | 259 | } |
260 | 260 | ||
261 | void cgit_plain_link(char *name, char *title, char *class, char *head, | ||
262 | char *rev, char *path) | ||
263 | { | ||
264 | reporevlink("plain", name, title, class, head, rev, path); | ||
265 | } | ||
266 | |||
261 | void cgit_log_link(char *name, char *title, char *class, char *head, | 267 | void cgit_log_link(char *name, char *title, char *class, char *head, |
262 | char *rev, char *path, int ofs, char *grep, char *pattern) | 268 | char *rev, char *path, int ofs, char *grep, char *pattern) |
263 | { | 269 | { |
264 | char *delim; | 270 | char *delim; |
265 | 271 | ||
266 | delim = repolink(title, class, "log", head, path); | 272 | delim = repolink(title, class, "log", head, path); |
267 | if (rev && strcmp(rev, ctx.qry.head)) { | 273 | if (rev && strcmp(rev, ctx.qry.head)) { |
268 | html(delim); | 274 | html(delim); |
269 | html("id="); | 275 | html("id="); |
270 | html_attr(rev); | 276 | html_attr(rev); |
271 | delim = "&"; | 277 | delim = "&"; |
272 | } | 278 | } |
273 | if (grep && pattern) { | 279 | if (grep && pattern) { |
274 | html(delim); | 280 | html(delim); |
275 | html("qt="); | 281 | html("qt="); |
276 | html_attr(grep); | 282 | html_attr(grep); |
277 | delim = "&"; | 283 | delim = "&"; |
278 | html(delim); | 284 | html(delim); |
279 | html("q="); | 285 | html("q="); |
280 | html_attr(pattern); | 286 | html_attr(pattern); |
281 | } | 287 | } |
282 | if (ofs > 0) { | 288 | if (ofs > 0) { |
283 | html(delim); | 289 | html(delim); |
284 | html("ofs="); | 290 | html("ofs="); |
285 | htmlf("%d", ofs); | 291 | htmlf("%d", ofs); |
286 | } | 292 | } |
287 | html("'>"); | 293 | html("'>"); |
288 | html_txt(name); | 294 | html_txt(name); |
289 | html("</a>"); | 295 | html("</a>"); |
290 | } | 296 | } |
291 | 297 | ||
292 | void cgit_commit_link(char *name, char *title, char *class, char *head, | 298 | void cgit_commit_link(char *name, char *title, char *class, char *head, |
@@ -404,64 +410,66 @@ void cgit_print_age(time_t t, time_t max_relative, char *format) | |||
404 | } | 410 | } |
405 | if (secs < TM_DAY * 2) { | 411 | if (secs < TM_DAY * 2) { |
406 | htmlf("<span class='age-hours'>%.0f hours</span>", | 412 | htmlf("<span class='age-hours'>%.0f hours</span>", |
407 | secs * 1.0 / TM_HOUR); | 413 | secs * 1.0 / TM_HOUR); |
408 | return; | 414 | return; |
409 | } | 415 | } |
410 | if (secs < TM_WEEK * 2) { | 416 | if (secs < TM_WEEK * 2) { |
411 | htmlf("<span class='age-days'>%.0f days</span>", | 417 | htmlf("<span class='age-days'>%.0f days</span>", |
412 | secs * 1.0 / TM_DAY); | 418 | secs * 1.0 / TM_DAY); |
413 | return; | 419 | return; |
414 | } | 420 | } |
415 | if (secs < TM_MONTH * 2) { | 421 | if (secs < TM_MONTH * 2) { |
416 | htmlf("<span class='age-weeks'>%.0f weeks</span>", | 422 | htmlf("<span class='age-weeks'>%.0f weeks</span>", |
417 | secs * 1.0 / TM_WEEK); | 423 | secs * 1.0 / TM_WEEK); |
418 | return; | 424 | return; |
419 | } | 425 | } |
420 | if (secs < TM_YEAR * 2) { | 426 | if (secs < TM_YEAR * 2) { |
421 | htmlf("<span class='age-months'>%.0f months</span>", | 427 | htmlf("<span class='age-months'>%.0f months</span>", |
422 | secs * 1.0 / TM_MONTH); | 428 | secs * 1.0 / TM_MONTH); |
423 | return; | 429 | return; |
424 | } | 430 | } |
425 | htmlf("<span class='age-years'>%.0f years</span>", | 431 | htmlf("<span class='age-years'>%.0f years</span>", |
426 | secs * 1.0 / TM_YEAR); | 432 | secs * 1.0 / TM_YEAR); |
427 | } | 433 | } |
428 | 434 | ||
429 | void cgit_print_http_headers(struct cgit_context *ctx) | 435 | void cgit_print_http_headers(struct cgit_context *ctx) |
430 | { | 436 | { |
431 | if (ctx->page.mimetype && ctx->page.charset) | 437 | if (ctx->page.mimetype && ctx->page.charset) |
432 | htmlf("Content-Type: %s; charset=%s\n", ctx->page.mimetype, | 438 | htmlf("Content-Type: %s; charset=%s\n", ctx->page.mimetype, |
433 | ctx->page.charset); | 439 | ctx->page.charset); |
434 | else if (ctx->page.mimetype) | 440 | else if (ctx->page.mimetype) |
435 | htmlf("Content-Type: %s\n", ctx->page.mimetype); | 441 | htmlf("Content-Type: %s\n", ctx->page.mimetype); |
442 | if (ctx->page.size) | ||
443 | htmlf("Content-Length: %ld\n", ctx->page.size); | ||
436 | if (ctx->page.filename) | 444 | if (ctx->page.filename) |
437 | htmlf("Content-Disposition: inline; filename=\"%s\"\n", | 445 | htmlf("Content-Disposition: inline; filename=\"%s\"\n", |
438 | ctx->page.filename); | 446 | ctx->page.filename); |
439 | htmlf("Last-Modified: %s\n", http_date(ctx->page.modified)); | 447 | htmlf("Last-Modified: %s\n", http_date(ctx->page.modified)); |
440 | htmlf("Expires: %s\n", http_date(ctx->page.expires)); | 448 | htmlf("Expires: %s\n", http_date(ctx->page.expires)); |
441 | html("\n"); | 449 | html("\n"); |
442 | } | 450 | } |
443 | 451 | ||
444 | void cgit_print_docstart(struct cgit_context *ctx) | 452 | void cgit_print_docstart(struct cgit_context *ctx) |
445 | { | 453 | { |
446 | char *host = cgit_hosturl(); | 454 | char *host = cgit_hosturl(); |
447 | html(cgit_doctype); | 455 | html(cgit_doctype); |
448 | html("<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>\n"); | 456 | html("<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>\n"); |
449 | html("<head>\n"); | 457 | html("<head>\n"); |
450 | html("<title>"); | 458 | html("<title>"); |
451 | html_txt(ctx->page.title); | 459 | html_txt(ctx->page.title); |
452 | html("</title>\n"); | 460 | html("</title>\n"); |
453 | htmlf("<meta name='generator' content='cgit %s'/>\n", cgit_version); | 461 | htmlf("<meta name='generator' content='cgit %s'/>\n", cgit_version); |
454 | if (ctx->cfg.robots && *ctx->cfg.robots) | 462 | if (ctx->cfg.robots && *ctx->cfg.robots) |
455 | htmlf("<meta name='robots' content='%s'/>\n", ctx->cfg.robots); | 463 | htmlf("<meta name='robots' content='%s'/>\n", ctx->cfg.robots); |
456 | html("<link rel='stylesheet' type='text/css' href='"); | 464 | html("<link rel='stylesheet' type='text/css' href='"); |
457 | html_attr(ctx->cfg.css); | 465 | html_attr(ctx->cfg.css); |
458 | html("'/>\n"); | 466 | html("'/>\n"); |
459 | if (ctx->cfg.favicon) { | 467 | if (ctx->cfg.favicon) { |
460 | html("<link rel='shortcut icon' href='"); | 468 | html("<link rel='shortcut icon' href='"); |
461 | html_attr(ctx->cfg.favicon); | 469 | html_attr(ctx->cfg.favicon); |
462 | html("'/>\n"); | 470 | html("'/>\n"); |
463 | } | 471 | } |
464 | if (host && ctx->repo) { | 472 | if (host && ctx->repo) { |
465 | html("<link rel='alternate' title='Atom feed' href='http://"); | 473 | html("<link rel='alternate' title='Atom feed' href='http://"); |
466 | html_attr(cgit_hosturl()); | 474 | html_attr(cgit_hosturl()); |
467 | html_attr(cgit_fileurl(ctx->repo->url, "atom", ctx->qry.path, | 475 | html_attr(cgit_fileurl(ctx->repo->url, "atom", ctx->qry.path, |