author | Lars Hjemli <hjemli@gmail.com> | 2007-11-11 12:04:28 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2007-11-11 12:04:28 (UTC) |
commit | 2915483ef6c9c29ac1493e6945688bb62f7825b4 (patch) (unidiff) | |
tree | 3ee4afec27ec8cb0ad5e10008f3bd8c994747c39 /ui-shared.c | |
parent | b4649fc90597910c89c3f37a6aec9af54d9f416b (diff) | |
download | cgit-2915483ef6c9c29ac1493e6945688bb62f7825b4.zip cgit-2915483ef6c9c29ac1493e6945688bb62f7825b4.tar.gz cgit-2915483ef6c9c29ac1493e6945688bb62f7825b4.tar.bz2 |
Fix html error detected by test-suite
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
-rw-r--r-- | ui-shared.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/ui-shared.c b/ui-shared.c index 7c69f60..9ec646b 100644 --- a/ui-shared.c +++ b/ui-shared.c | |||
@@ -313,225 +313,225 @@ void cgit_print_age(time_t t, time_t max_relative, char *format) | |||
313 | { | 313 | { |
314 | time_t now, secs; | 314 | time_t now, secs; |
315 | 315 | ||
316 | time(&now); | 316 | time(&now); |
317 | secs = now - t; | 317 | secs = now - t; |
318 | 318 | ||
319 | if (secs > max_relative && max_relative >= 0) { | 319 | if (secs > max_relative && max_relative >= 0) { |
320 | cgit_print_date(t, format); | 320 | cgit_print_date(t, format); |
321 | return; | 321 | return; |
322 | } | 322 | } |
323 | 323 | ||
324 | if (secs < TM_HOUR * 2) { | 324 | if (secs < TM_HOUR * 2) { |
325 | htmlf("<span class='age-mins'>%.0f min.</span>", | 325 | htmlf("<span class='age-mins'>%.0f min.</span>", |
326 | secs * 1.0 / TM_MIN); | 326 | secs * 1.0 / TM_MIN); |
327 | return; | 327 | return; |
328 | } | 328 | } |
329 | if (secs < TM_DAY * 2) { | 329 | if (secs < TM_DAY * 2) { |
330 | htmlf("<span class='age-hours'>%.0f hours</span>", | 330 | htmlf("<span class='age-hours'>%.0f hours</span>", |
331 | secs * 1.0 / TM_HOUR); | 331 | secs * 1.0 / TM_HOUR); |
332 | return; | 332 | return; |
333 | } | 333 | } |
334 | if (secs < TM_WEEK * 2) { | 334 | if (secs < TM_WEEK * 2) { |
335 | htmlf("<span class='age-days'>%.0f days</span>", | 335 | htmlf("<span class='age-days'>%.0f days</span>", |
336 | secs * 1.0 / TM_DAY); | 336 | secs * 1.0 / TM_DAY); |
337 | return; | 337 | return; |
338 | } | 338 | } |
339 | if (secs < TM_MONTH * 2) { | 339 | if (secs < TM_MONTH * 2) { |
340 | htmlf("<span class='age-weeks'>%.0f weeks</span>", | 340 | htmlf("<span class='age-weeks'>%.0f weeks</span>", |
341 | secs * 1.0 / TM_WEEK); | 341 | secs * 1.0 / TM_WEEK); |
342 | return; | 342 | return; |
343 | } | 343 | } |
344 | if (secs < TM_YEAR * 2) { | 344 | if (secs < TM_YEAR * 2) { |
345 | htmlf("<span class='age-months'>%.0f months</span>", | 345 | htmlf("<span class='age-months'>%.0f months</span>", |
346 | secs * 1.0 / TM_MONTH); | 346 | secs * 1.0 / TM_MONTH); |
347 | return; | 347 | return; |
348 | } | 348 | } |
349 | htmlf("<span class='age-years'>%.0f years</span>", | 349 | htmlf("<span class='age-years'>%.0f years</span>", |
350 | secs * 1.0 / TM_YEAR); | 350 | secs * 1.0 / TM_YEAR); |
351 | } | 351 | } |
352 | 352 | ||
353 | void cgit_print_docstart(char *title, struct cacheitem *item) | 353 | void cgit_print_docstart(char *title, struct cacheitem *item) |
354 | { | 354 | { |
355 | html("Content-Type: text/html; charset=" PAGE_ENCODING "\n"); | 355 | html("Content-Type: text/html; charset=" PAGE_ENCODING "\n"); |
356 | htmlf("Last-Modified: %s\n", http_date(item->st.st_mtime)); | 356 | htmlf("Last-Modified: %s\n", http_date(item->st.st_mtime)); |
357 | htmlf("Expires: %s\n", http_date(item->st.st_mtime + | 357 | htmlf("Expires: %s\n", http_date(item->st.st_mtime + |
358 | ttl_seconds(item->ttl))); | 358 | ttl_seconds(item->ttl))); |
359 | html("\n"); | 359 | html("\n"); |
360 | html(cgit_doctype); | 360 | html(cgit_doctype); |
361 | html("<html>\n"); | 361 | html("<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>\n"); |
362 | html("<head>\n"); | 362 | html("<head>\n"); |
363 | html("<title>"); | 363 | html("<title>"); |
364 | html_txt(title); | 364 | html_txt(title); |
365 | html("</title>\n"); | 365 | html("</title>\n"); |
366 | htmlf("<meta name='generator' content='cgit %s'/>\n", cgit_version); | 366 | htmlf("<meta name='generator' content='cgit %s'/>\n", cgit_version); |
367 | html("<link rel='stylesheet' type='text/css' href='"); | 367 | html("<link rel='stylesheet' type='text/css' href='"); |
368 | html_attr(cgit_css); | 368 | html_attr(cgit_css); |
369 | html("'/>\n"); | 369 | html("'/>\n"); |
370 | html("</head>\n"); | 370 | html("</head>\n"); |
371 | html("<body>\n"); | 371 | html("<body>\n"); |
372 | } | 372 | } |
373 | 373 | ||
374 | void cgit_print_docend() | 374 | void cgit_print_docend() |
375 | { | 375 | { |
376 | html("</td>\n</tr>\n<table>\n</body>\n</html>\n"); | 376 | html("</td>\n</tr>\n</table>\n</body>\n</html>\n"); |
377 | } | 377 | } |
378 | 378 | ||
379 | int print_branch_option(const char *refname, const unsigned char *sha1, | 379 | int print_branch_option(const char *refname, const unsigned char *sha1, |
380 | int flags, void *cb_data) | 380 | int flags, void *cb_data) |
381 | { | 381 | { |
382 | char *name = (char *)refname; | 382 | char *name = (char *)refname; |
383 | html_option(name, name, cgit_query_head); | 383 | html_option(name, name, cgit_query_head); |
384 | return 0; | 384 | return 0; |
385 | } | 385 | } |
386 | 386 | ||
387 | int print_archive_ref(const char *refname, const unsigned char *sha1, | 387 | int print_archive_ref(const char *refname, const unsigned char *sha1, |
388 | int flags, void *cb_data) | 388 | int flags, void *cb_data) |
389 | { | 389 | { |
390 | struct tag *tag; | 390 | struct tag *tag; |
391 | struct taginfo *info; | 391 | struct taginfo *info; |
392 | struct object *obj; | 392 | struct object *obj; |
393 | char buf[256], *url; | 393 | char buf[256], *url; |
394 | unsigned char fileid[20]; | 394 | unsigned char fileid[20]; |
395 | int *header = (int *)cb_data; | 395 | int *header = (int *)cb_data; |
396 | 396 | ||
397 | if (prefixcmp(refname, "refs/archives")) | 397 | if (prefixcmp(refname, "refs/archives")) |
398 | return 0; | 398 | return 0; |
399 | strncpy(buf, refname+14, sizeof(buf)); | 399 | strncpy(buf, refname+14, sizeof(buf)); |
400 | obj = parse_object(sha1); | 400 | obj = parse_object(sha1); |
401 | if (!obj) | 401 | if (!obj) |
402 | return 1; | 402 | return 1; |
403 | if (obj->type == OBJ_TAG) { | 403 | if (obj->type == OBJ_TAG) { |
404 | tag = lookup_tag(sha1); | 404 | tag = lookup_tag(sha1); |
405 | if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag))) | 405 | if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag))) |
406 | return 0; | 406 | return 0; |
407 | hashcpy(fileid, tag->tagged->sha1); | 407 | hashcpy(fileid, tag->tagged->sha1); |
408 | } else if (obj->type != OBJ_BLOB) { | 408 | } else if (obj->type != OBJ_BLOB) { |
409 | return 0; | 409 | return 0; |
410 | } else { | 410 | } else { |
411 | hashcpy(fileid, sha1); | 411 | hashcpy(fileid, sha1); |
412 | } | 412 | } |
413 | if (!*header) { | 413 | if (!*header) { |
414 | html("<p><h1>download</h1>"); | 414 | html("<p><h1>download</h1>"); |
415 | *header = 1; | 415 | *header = 1; |
416 | } | 416 | } |
417 | url = cgit_pageurl(cgit_query_repo, "blob", | 417 | url = cgit_pageurl(cgit_query_repo, "blob", |
418 | fmt("id=%s&path=%s", sha1_to_hex(fileid), | 418 | fmt("id=%s&path=%s", sha1_to_hex(fileid), |
419 | buf)); | 419 | buf)); |
420 | html_link_open(url, NULL, "menu"); | 420 | html_link_open(url, NULL, "menu"); |
421 | html_txt(strlpart(buf, 20)); | 421 | html_txt(strlpart(buf, 20)); |
422 | html_link_close(); | 422 | html_link_close(); |
423 | return 0; | 423 | return 0; |
424 | } | 424 | } |
425 | 425 | ||
426 | void add_hidden_formfields(int incl_head, int incl_search, char *page) | 426 | void add_hidden_formfields(int incl_head, int incl_search, char *page) |
427 | { | 427 | { |
428 | char *url; | 428 | char *url; |
429 | 429 | ||
430 | if (!cgit_virtual_root) { | 430 | if (!cgit_virtual_root) { |
431 | url = fmt("%s/%s", cgit_query_repo, page); | 431 | url = fmt("%s/%s", cgit_query_repo, page); |
432 | if (cgit_query_path) | 432 | if (cgit_query_path) |
433 | url = fmt("%s/%s", url, cgit_query_path); | 433 | url = fmt("%s/%s", url, cgit_query_path); |
434 | html_hidden("url", url); | 434 | html_hidden("url", url); |
435 | } | 435 | } |
436 | 436 | ||
437 | if (incl_head && strcmp(cgit_query_head, cgit_repo->defbranch)) | 437 | if (incl_head && strcmp(cgit_query_head, cgit_repo->defbranch)) |
438 | html_hidden("h", cgit_query_head); | 438 | html_hidden("h", cgit_query_head); |
439 | 439 | ||
440 | if (cgit_query_sha1) | 440 | if (cgit_query_sha1) |
441 | html_hidden("id", cgit_query_sha1); | 441 | html_hidden("id", cgit_query_sha1); |
442 | if (cgit_query_sha2) | 442 | if (cgit_query_sha2) |
443 | html_hidden("id2", cgit_query_sha2); | 443 | html_hidden("id2", cgit_query_sha2); |
444 | 444 | ||
445 | if (incl_search) { | 445 | if (incl_search) { |
446 | if (cgit_query_grep) | 446 | if (cgit_query_grep) |
447 | html_hidden("qt", cgit_query_grep); | 447 | html_hidden("qt", cgit_query_grep); |
448 | if (cgit_query_search) | 448 | if (cgit_query_search) |
449 | html_hidden("q", cgit_query_search); | 449 | html_hidden("q", cgit_query_search); |
450 | } | 450 | } |
451 | } | 451 | } |
452 | 452 | ||
453 | void cgit_print_pageheader(char *title, int show_search) | 453 | void cgit_print_pageheader(char *title, int show_search) |
454 | { | 454 | { |
455 | static const char *default_info = "This is cgit, a fast webinterface for git repositories"; | 455 | static const char *default_info = "This is cgit, a fast webinterface for git repositories"; |
456 | int header = 0; | 456 | int header = 0; |
457 | 457 | ||
458 | html("<div id='sidebar'>\n"); | 458 | html("<div id='sidebar'>\n"); |
459 | html("<a href='"); | 459 | html("<div id='logo'><a href='"); |
460 | html_attr(cgit_rooturl()); | 460 | html_attr(cgit_rooturl()); |
461 | htmlf("'><div id='logo'><img src='%s' alt='cgit'/></div></a>\n", | 461 | htmlf("'><img src='%s' alt='cgit'/></a></div>\n", |
462 | cgit_logo); | 462 | cgit_logo); |
463 | html("<div class='infobox'>"); | 463 | html("<div class='infobox'>"); |
464 | if (cgit_query_repo) { | 464 | if (cgit_query_repo) { |
465 | html("<h1>"); | 465 | html("<h1 class='first'>"); |
466 | html_txt(strrpart(cgit_repo->name, 20)); | 466 | html_txt(strrpart(cgit_repo->name, 20)); |
467 | html("</h1>\n"); | 467 | html("</h1>\n"); |
468 | html_txt(cgit_repo->desc); | 468 | html_txt(cgit_repo->desc); |
469 | if (cgit_repo->owner) { | 469 | if (cgit_repo->owner) { |
470 | html("<p>\n<h1>owner</h1>\n"); | 470 | html("<h1>owner</h1>\n"); |
471 | html_txt(cgit_repo->owner); | 471 | html_txt(cgit_repo->owner); |
472 | } | 472 | } |
473 | html("<p>\n<h1>navigate</h1>\n"); | 473 | html("<h1>navigate</h1>\n"); |
474 | reporevlink(NULL, "summary", NULL, "menu", cgit_query_head, | 474 | reporevlink(NULL, "summary", NULL, "menu", cgit_query_head, |
475 | NULL, NULL); | 475 | NULL, NULL); |
476 | cgit_log_link("log", NULL, "menu", cgit_query_head, NULL, NULL, | 476 | cgit_log_link("log", NULL, "menu", cgit_query_head, NULL, NULL, |
477 | 0, NULL, NULL); | 477 | 0, NULL, NULL); |
478 | cgit_tree_link("tree", NULL, "menu", cgit_query_head, | 478 | cgit_tree_link("tree", NULL, "menu", cgit_query_head, |
479 | cgit_query_sha1, NULL); | 479 | cgit_query_sha1, NULL); |
480 | cgit_commit_link("commit", NULL, "menu", cgit_query_head, | 480 | cgit_commit_link("commit", NULL, "menu", cgit_query_head, |
481 | cgit_query_sha1); | 481 | cgit_query_sha1); |
482 | cgit_diff_link("diff", NULL, "menu", cgit_query_head, | 482 | cgit_diff_link("diff", NULL, "menu", cgit_query_head, |
483 | cgit_query_sha1, cgit_query_sha2, NULL); | 483 | cgit_query_sha1, cgit_query_sha2, NULL); |
484 | 484 | ||
485 | for_each_ref(print_archive_ref, &header); | 485 | for_each_ref(print_archive_ref, &header); |
486 | 486 | ||
487 | html("<p>\n<h1>branch</h1>\n"); | 487 | html("<h1>branch</h1>\n"); |
488 | html("<form method='get' action=''>\n"); | 488 | html("<form method='get' action=''>\n"); |
489 | add_hidden_formfields(0, 1, cgit_query_page); | 489 | add_hidden_formfields(0, 1, cgit_query_page); |
490 | html("<table class='grid'><tr><td id='branch-dropdown-cell'>"); | 490 | html("<table summary='branch selector' class='grid'><tr><td id='branch-dropdown-cell'>"); |
491 | html("<select name='h' onchange='this.form.submit();'>\n"); | 491 | html("<select name='h' onchange='this.form.submit();'>\n"); |
492 | for_each_branch_ref(print_branch_option, cgit_query_head); | 492 | for_each_branch_ref(print_branch_option, cgit_query_head); |
493 | html("</select>\n"); | 493 | html("</select>\n"); |
494 | html("</td><td>"); | 494 | html("</td><td>"); |
495 | html("<noscript><input type='submit' id='switch-btn' value='..'></noscript>\n"); | 495 | html("<noscript><input type='submit' id='switch-btn' value='..'/></noscript>\n"); |
496 | html("</td></tr></table>"); | 496 | html("</td></tr></table>"); |
497 | html("</form>\n"); | 497 | html("</form>\n"); |
498 | 498 | ||
499 | html("<p>\n<h1>search</h1>\n"); | 499 | html("<h1>search</h1>\n"); |
500 | html("<form method='get' action='"); | 500 | html("<form method='get' action='"); |
501 | if (cgit_virtual_root) | 501 | if (cgit_virtual_root) |
502 | html_attr(cgit_fileurl(cgit_query_repo, "log", | 502 | html_attr(cgit_fileurl(cgit_query_repo, "log", |
503 | cgit_query_path, NULL)); | 503 | cgit_query_path, NULL)); |
504 | html("'>\n"); | 504 | html("'>\n"); |
505 | add_hidden_formfields(1, 0, "log"); | 505 | add_hidden_formfields(1, 0, "log"); |
506 | html("<select name='qt'>\n"); | 506 | html("<select name='qt'>\n"); |
507 | html_option("grep", "log msg", cgit_query_grep); | 507 | html_option("grep", "log msg", cgit_query_grep); |
508 | html_option("author", "author", cgit_query_grep); | 508 | html_option("author", "author", cgit_query_grep); |
509 | html_option("committer", "committer", cgit_query_grep); | 509 | html_option("committer", "committer", cgit_query_grep); |
510 | html("</select>\n"); | 510 | html("</select>\n"); |
511 | html("<input class='txt' type='text' name='q' value='"); | 511 | html("<input class='txt' type='text' name='q' value='"); |
512 | html_attr(cgit_query_search); | 512 | html_attr(cgit_query_search); |
513 | html("'/>\n"); | 513 | html("'/>\n"); |
514 | html("</form>\n"); | 514 | html("</form>\n"); |
515 | } else { | 515 | } else { |
516 | if (!cgit_index_info || html_include(cgit_index_info)) | 516 | if (!cgit_index_info || html_include(cgit_index_info)) |
517 | html(default_info); | 517 | html(default_info); |
518 | } | 518 | } |
519 | 519 | ||
520 | html("</div>\n"); | 520 | html("</div>\n"); |
521 | 521 | ||
522 | html("</div>\n<table class='grid'><tr><td id='content'>\n"); | 522 | html("</div>\n<table summary='page content' class='grid'><tr><td id='content'>\n"); |
523 | } | 523 | } |
524 | 524 | ||
525 | 525 | ||
526 | void cgit_print_snapshot_start(const char *mimetype, const char *filename, | 526 | void cgit_print_snapshot_start(const char *mimetype, const char *filename, |
527 | struct cacheitem *item) | 527 | struct cacheitem *item) |
528 | { | 528 | { |
529 | htmlf("Content-Type: %s\n", mimetype); | 529 | htmlf("Content-Type: %s\n", mimetype); |
530 | htmlf("Content-Disposition: inline; filename=\"%s\"\n", filename); | 530 | htmlf("Content-Disposition: inline; filename=\"%s\"\n", filename); |
531 | htmlf("Last-Modified: %s\n", http_date(item->st.st_mtime)); | 531 | htmlf("Last-Modified: %s\n", http_date(item->st.st_mtime)); |
532 | htmlf("Expires: %s\n", http_date(item->st.st_mtime + | 532 | htmlf("Expires: %s\n", http_date(item->st.st_mtime + |
533 | ttl_seconds(item->ttl))); | 533 | ttl_seconds(item->ttl))); |
534 | html("\n"); | 534 | html("\n"); |
535 | } | 535 | } |
536 | 536 | ||
537 | /* vim:set sw=8: */ | 537 | /* vim:set sw=8: */ |