author | Lars Hjemli <hjemli@gmail.com> | 2007-11-16 09:28:29 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2007-11-16 09:28:29 (UTC) |
commit | e8e6721817c983770fc0fdfbb26a17900e3c34ce (patch) (unidiff) | |
tree | 86dbc8acd0171bf5ab68fb71872f78465042f680 /ui-shared.c | |
parent | 6ef637e0908ca5a14675b3513f48cd390d3757fe (diff) | |
download | cgit-e8e6721817c983770fc0fdfbb26a17900e3c34ce.zip cgit-e8e6721817c983770fc0fdfbb26a17900e3c34ce.tar.gz cgit-e8e6721817c983770fc0fdfbb26a17900e3c34ce.tar.bz2 |
Add cell-spacing in html
There are some browsers which don't support the border-spacing property
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
-rw-r--r-- | ui-shared.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/ui-shared.c b/ui-shared.c index 4c0613a..be2c75d 100644 --- a/ui-shared.c +++ b/ui-shared.c | |||
@@ -270,272 +270,272 @@ void cgit_diff_link(char *name, char *title, char *class, char *head, | |||
270 | html("'>"); | 270 | html("'>"); |
271 | html_txt(name); | 271 | html_txt(name); |
272 | html("</a>"); | 272 | html("</a>"); |
273 | } | 273 | } |
274 | 274 | ||
275 | void cgit_object_link(struct object *obj) | 275 | void cgit_object_link(struct object *obj) |
276 | { | 276 | { |
277 | char *page, *arg, *url; | 277 | char *page, *arg, *url; |
278 | 278 | ||
279 | if (obj->type == OBJ_COMMIT) { | 279 | if (obj->type == OBJ_COMMIT) { |
280 | cgit_commit_link(fmt("commit %s", sha1_to_hex(obj->sha1)), NULL, NULL, | 280 | cgit_commit_link(fmt("commit %s", sha1_to_hex(obj->sha1)), NULL, NULL, |
281 | cgit_query_head, sha1_to_hex(obj->sha1)); | 281 | cgit_query_head, sha1_to_hex(obj->sha1)); |
282 | return; | 282 | return; |
283 | } else if (obj->type == OBJ_TREE) { | 283 | } else if (obj->type == OBJ_TREE) { |
284 | page = "tree"; | 284 | page = "tree"; |
285 | arg = "id"; | 285 | arg = "id"; |
286 | } else if (obj->type == OBJ_TAG) { | 286 | } else if (obj->type == OBJ_TAG) { |
287 | page = "tag"; | 287 | page = "tag"; |
288 | arg = "id"; | 288 | arg = "id"; |
289 | } else { | 289 | } else { |
290 | page = "blob"; | 290 | page = "blob"; |
291 | arg = "id"; | 291 | arg = "id"; |
292 | } | 292 | } |
293 | 293 | ||
294 | url = cgit_pageurl(cgit_query_repo, page, | 294 | url = cgit_pageurl(cgit_query_repo, page, |
295 | fmt("%s=%s", arg, sha1_to_hex(obj->sha1))); | 295 | fmt("%s=%s", arg, sha1_to_hex(obj->sha1))); |
296 | html_link_open(url, NULL, NULL); | 296 | html_link_open(url, NULL, NULL); |
297 | htmlf("%s %s", typename(obj->type), | 297 | htmlf("%s %s", typename(obj->type), |
298 | sha1_to_hex(obj->sha1)); | 298 | sha1_to_hex(obj->sha1)); |
299 | html_link_close(); | 299 | html_link_close(); |
300 | } | 300 | } |
301 | 301 | ||
302 | void cgit_print_date(time_t secs, char *format) | 302 | void cgit_print_date(time_t secs, char *format) |
303 | { | 303 | { |
304 | char buf[64]; | 304 | char buf[64]; |
305 | struct tm *time; | 305 | struct tm *time; |
306 | 306 | ||
307 | time = gmtime(&secs); | 307 | time = gmtime(&secs); |
308 | strftime(buf, sizeof(buf)-1, format, time); | 308 | strftime(buf, sizeof(buf)-1, format, time); |
309 | html_txt(buf); | 309 | html_txt(buf); |
310 | } | 310 | } |
311 | 311 | ||
312 | void cgit_print_age(time_t t, time_t max_relative, char *format) | 312 | 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 xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>\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 | if (cgit_robots && *cgit_robots) | 367 | if (cgit_robots && *cgit_robots) |
368 | htmlf("<meta name='robots' content='%s'/>\n", cgit_robots); | 368 | htmlf("<meta name='robots' content='%s'/>\n", cgit_robots); |
369 | html("<link rel='stylesheet' type='text/css' href='"); | 369 | html("<link rel='stylesheet' type='text/css' href='"); |
370 | html_attr(cgit_css); | 370 | html_attr(cgit_css); |
371 | html("'/>\n"); | 371 | html("'/>\n"); |
372 | html("</head>\n"); | 372 | html("</head>\n"); |
373 | html("<body>\n"); | 373 | html("<body>\n"); |
374 | } | 374 | } |
375 | 375 | ||
376 | void cgit_print_docend() | 376 | void cgit_print_docend() |
377 | { | 377 | { |
378 | html("</td>\n</tr>\n</table>\n</body>\n</html>\n"); | 378 | html("</td>\n</tr>\n</table>\n</body>\n</html>\n"); |
379 | } | 379 | } |
380 | 380 | ||
381 | int print_branch_option(const char *refname, const unsigned char *sha1, | 381 | int print_branch_option(const char *refname, const unsigned char *sha1, |
382 | int flags, void *cb_data) | 382 | int flags, void *cb_data) |
383 | { | 383 | { |
384 | char *name = (char *)refname; | 384 | char *name = (char *)refname; |
385 | html_option(name, name, cgit_query_head); | 385 | html_option(name, name, cgit_query_head); |
386 | return 0; | 386 | return 0; |
387 | } | 387 | } |
388 | 388 | ||
389 | int print_archive_ref(const char *refname, const unsigned char *sha1, | 389 | int print_archive_ref(const char *refname, const unsigned char *sha1, |
390 | int flags, void *cb_data) | 390 | int flags, void *cb_data) |
391 | { | 391 | { |
392 | struct tag *tag; | 392 | struct tag *tag; |
393 | struct taginfo *info; | 393 | struct taginfo *info; |
394 | struct object *obj; | 394 | struct object *obj; |
395 | char buf[256], *url; | 395 | char buf[256], *url; |
396 | unsigned char fileid[20]; | 396 | unsigned char fileid[20]; |
397 | int *header = (int *)cb_data; | 397 | int *header = (int *)cb_data; |
398 | 398 | ||
399 | if (prefixcmp(refname, "refs/archives")) | 399 | if (prefixcmp(refname, "refs/archives")) |
400 | return 0; | 400 | return 0; |
401 | strncpy(buf, refname+14, sizeof(buf)); | 401 | strncpy(buf, refname+14, sizeof(buf)); |
402 | obj = parse_object(sha1); | 402 | obj = parse_object(sha1); |
403 | if (!obj) | 403 | if (!obj) |
404 | return 1; | 404 | return 1; |
405 | if (obj->type == OBJ_TAG) { | 405 | if (obj->type == OBJ_TAG) { |
406 | tag = lookup_tag(sha1); | 406 | tag = lookup_tag(sha1); |
407 | if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag))) | 407 | if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag))) |
408 | return 0; | 408 | return 0; |
409 | hashcpy(fileid, tag->tagged->sha1); | 409 | hashcpy(fileid, tag->tagged->sha1); |
410 | } else if (obj->type != OBJ_BLOB) { | 410 | } else if (obj->type != OBJ_BLOB) { |
411 | return 0; | 411 | return 0; |
412 | } else { | 412 | } else { |
413 | hashcpy(fileid, sha1); | 413 | hashcpy(fileid, sha1); |
414 | } | 414 | } |
415 | if (!*header) { | 415 | if (!*header) { |
416 | html("<h1>download</h1>\n"); | 416 | html("<h1>download</h1>\n"); |
417 | *header = 1; | 417 | *header = 1; |
418 | } | 418 | } |
419 | url = cgit_pageurl(cgit_query_repo, "blob", | 419 | url = cgit_pageurl(cgit_query_repo, "blob", |
420 | fmt("id=%s&path=%s", sha1_to_hex(fileid), | 420 | fmt("id=%s&path=%s", sha1_to_hex(fileid), |
421 | buf)); | 421 | buf)); |
422 | html_link_open(url, NULL, "menu"); | 422 | html_link_open(url, NULL, "menu"); |
423 | html_txt(strlpart(buf, 20)); | 423 | html_txt(strlpart(buf, 20)); |
424 | html_link_close(); | 424 | html_link_close(); |
425 | return 0; | 425 | return 0; |
426 | } | 426 | } |
427 | 427 | ||
428 | void add_hidden_formfields(int incl_head, int incl_search, char *page) | 428 | void add_hidden_formfields(int incl_head, int incl_search, char *page) |
429 | { | 429 | { |
430 | char *url; | 430 | char *url; |
431 | 431 | ||
432 | if (!cgit_virtual_root) { | 432 | if (!cgit_virtual_root) { |
433 | url = fmt("%s/%s", cgit_query_repo, page); | 433 | url = fmt("%s/%s", cgit_query_repo, page); |
434 | if (cgit_query_path) | 434 | if (cgit_query_path) |
435 | url = fmt("%s/%s", url, cgit_query_path); | 435 | url = fmt("%s/%s", url, cgit_query_path); |
436 | html_hidden("url", url); | 436 | html_hidden("url", url); |
437 | } | 437 | } |
438 | 438 | ||
439 | if (incl_head && strcmp(cgit_query_head, cgit_repo->defbranch)) | 439 | if (incl_head && strcmp(cgit_query_head, cgit_repo->defbranch)) |
440 | html_hidden("h", cgit_query_head); | 440 | html_hidden("h", cgit_query_head); |
441 | 441 | ||
442 | if (cgit_query_sha1) | 442 | if (cgit_query_sha1) |
443 | html_hidden("id", cgit_query_sha1); | 443 | html_hidden("id", cgit_query_sha1); |
444 | if (cgit_query_sha2) | 444 | if (cgit_query_sha2) |
445 | html_hidden("id2", cgit_query_sha2); | 445 | html_hidden("id2", cgit_query_sha2); |
446 | 446 | ||
447 | if (incl_search) { | 447 | if (incl_search) { |
448 | if (cgit_query_grep) | 448 | if (cgit_query_grep) |
449 | html_hidden("qt", cgit_query_grep); | 449 | html_hidden("qt", cgit_query_grep); |
450 | if (cgit_query_search) | 450 | if (cgit_query_search) |
451 | html_hidden("q", cgit_query_search); | 451 | html_hidden("q", cgit_query_search); |
452 | } | 452 | } |
453 | } | 453 | } |
454 | 454 | ||
455 | void cgit_print_pageheader(char *title, int show_search) | 455 | void cgit_print_pageheader(char *title, int show_search) |
456 | { | 456 | { |
457 | static const char *default_info = "This is cgit, a fast webinterface for git repositories"; | 457 | static const char *default_info = "This is cgit, a fast webinterface for git repositories"; |
458 | int header = 0; | 458 | int header = 0; |
459 | 459 | ||
460 | html("<table id='layout' summary=''>\n"); | 460 | html("<table id='layout' summary=''>\n"); |
461 | html("<tr><td id='sidebar'>\n"); | 461 | html("<tr><td id='sidebar'>\n"); |
462 | html("<table class='sidebar' summary=''>\n"); | 462 | html("<table class='sidebar' cellspacing='0' summary=''>\n"); |
463 | html("<tr><td class='sidebar'>\n<a href='"); | 463 | html("<tr><td class='sidebar'>\n<a href='"); |
464 | html_attr(cgit_rooturl()); | 464 | html_attr(cgit_rooturl()); |
465 | htmlf("'><img src='%s' alt='cgit'/></a>\n", | 465 | htmlf("'><img src='%s' alt='cgit'/></a>\n", |
466 | cgit_logo); | 466 | cgit_logo); |
467 | html("</td></tr>\n<tr><td class='sidebar'>\n"); | 467 | html("</td></tr>\n<tr><td class='sidebar'>\n"); |
468 | if (cgit_query_repo) { | 468 | if (cgit_query_repo) { |
469 | html("<h1 class='first'>"); | 469 | html("<h1 class='first'>"); |
470 | html_txt(strrpart(cgit_repo->name, 20)); | 470 | html_txt(strrpart(cgit_repo->name, 20)); |
471 | html("</h1>\n"); | 471 | html("</h1>\n"); |
472 | html_txt(cgit_repo->desc); | 472 | html_txt(cgit_repo->desc); |
473 | if (cgit_repo->owner) { | 473 | if (cgit_repo->owner) { |
474 | html("<h1>owner</h1>\n"); | 474 | html("<h1>owner</h1>\n"); |
475 | html_txt(cgit_repo->owner); | 475 | html_txt(cgit_repo->owner); |
476 | } | 476 | } |
477 | html("<h1>navigate</h1>\n"); | 477 | html("<h1>navigate</h1>\n"); |
478 | reporevlink(NULL, "summary", NULL, "menu", cgit_query_head, | 478 | reporevlink(NULL, "summary", NULL, "menu", cgit_query_head, |
479 | NULL, NULL); | 479 | NULL, NULL); |
480 | cgit_log_link("log", NULL, "menu", cgit_query_head, NULL, NULL, | 480 | cgit_log_link("log", NULL, "menu", cgit_query_head, NULL, NULL, |
481 | 0, NULL, NULL); | 481 | 0, NULL, NULL); |
482 | cgit_tree_link("tree", NULL, "menu", cgit_query_head, | 482 | cgit_tree_link("tree", NULL, "menu", cgit_query_head, |
483 | cgit_query_sha1, NULL); | 483 | cgit_query_sha1, NULL); |
484 | cgit_commit_link("commit", NULL, "menu", cgit_query_head, | 484 | cgit_commit_link("commit", NULL, "menu", cgit_query_head, |
485 | cgit_query_sha1); | 485 | cgit_query_sha1); |
486 | cgit_diff_link("diff", NULL, "menu", cgit_query_head, | 486 | cgit_diff_link("diff", NULL, "menu", cgit_query_head, |
487 | cgit_query_sha1, cgit_query_sha2, NULL); | 487 | cgit_query_sha1, cgit_query_sha2, NULL); |
488 | 488 | ||
489 | for_each_ref(print_archive_ref, &header); | 489 | for_each_ref(print_archive_ref, &header); |
490 | 490 | ||
491 | html("<h1>branch</h1>\n"); | 491 | html("<h1>branch</h1>\n"); |
492 | html("<form method='get' action=''>\n"); | 492 | html("<form method='get' action=''>\n"); |
493 | add_hidden_formfields(0, 1, cgit_query_page); | 493 | add_hidden_formfields(0, 1, cgit_query_page); |
494 | // html("<table summary='branch selector' class='grid'><tr><td id='branch-dropdown-cell'>"); | 494 | // html("<table summary='branch selector' class='grid'><tr><td id='branch-dropdown-cell'>"); |
495 | html("<select name='h' onchange='this.form.submit();'>\n"); | 495 | html("<select name='h' onchange='this.form.submit();'>\n"); |
496 | for_each_branch_ref(print_branch_option, cgit_query_head); | 496 | for_each_branch_ref(print_branch_option, cgit_query_head); |
497 | html("</select>\n"); | 497 | html("</select>\n"); |
498 | // html("</td><td>"); | 498 | // html("</td><td>"); |
499 | html("<noscript><input type='submit' id='switch-btn' value='switch'/></noscript>\n"); | 499 | html("<noscript><input type='submit' id='switch-btn' value='switch'/></noscript>\n"); |
500 | // html("</td></tr></table>"); | 500 | // html("</td></tr></table>"); |
501 | html("</form>\n"); | 501 | html("</form>\n"); |
502 | 502 | ||
503 | html("<h1>search</h1>\n"); | 503 | html("<h1>search</h1>\n"); |
504 | html("<form method='get' action='"); | 504 | html("<form method='get' action='"); |
505 | if (cgit_virtual_root) | 505 | if (cgit_virtual_root) |
506 | html_attr(cgit_fileurl(cgit_query_repo, "log", | 506 | html_attr(cgit_fileurl(cgit_query_repo, "log", |
507 | cgit_query_path, NULL)); | 507 | cgit_query_path, NULL)); |
508 | html("'>\n"); | 508 | html("'>\n"); |
509 | add_hidden_formfields(1, 0, "log"); | 509 | add_hidden_formfields(1, 0, "log"); |
510 | html("<select name='qt'>\n"); | 510 | html("<select name='qt'>\n"); |
511 | html_option("grep", "log msg", cgit_query_grep); | 511 | html_option("grep", "log msg", cgit_query_grep); |
512 | html_option("author", "author", cgit_query_grep); | 512 | html_option("author", "author", cgit_query_grep); |
513 | html_option("committer", "committer", cgit_query_grep); | 513 | html_option("committer", "committer", cgit_query_grep); |
514 | html("</select>\n"); | 514 | html("</select>\n"); |
515 | html("<input class='txt' type='text' name='q' value='"); | 515 | html("<input class='txt' type='text' name='q' value='"); |
516 | html_attr(cgit_query_search); | 516 | html_attr(cgit_query_search); |
517 | html("'/>\n"); | 517 | html("'/>\n"); |
518 | html("</form>\n"); | 518 | html("</form>\n"); |
519 | } else { | 519 | } else { |
520 | if (!cgit_index_info || html_include(cgit_index_info)) | 520 | if (!cgit_index_info || html_include(cgit_index_info)) |
521 | html(default_info); | 521 | html(default_info); |
522 | } | 522 | } |
523 | 523 | ||
524 | html("</td></tr></table></td>\n"); | 524 | html("</td></tr></table></td>\n"); |
525 | 525 | ||
526 | html("<td id='content'>\n"); | 526 | html("<td id='content'>\n"); |
527 | } | 527 | } |
528 | 528 | ||
529 | 529 | ||
530 | void cgit_print_snapshot_start(const char *mimetype, const char *filename, | 530 | void cgit_print_snapshot_start(const char *mimetype, const char *filename, |
531 | struct cacheitem *item) | 531 | struct cacheitem *item) |
532 | { | 532 | { |
533 | htmlf("Content-Type: %s\n", mimetype); | 533 | htmlf("Content-Type: %s\n", mimetype); |
534 | htmlf("Content-Disposition: inline; filename=\"%s\"\n", filename); | 534 | htmlf("Content-Disposition: inline; filename=\"%s\"\n", filename); |
535 | htmlf("Last-Modified: %s\n", http_date(item->st.st_mtime)); | 535 | htmlf("Last-Modified: %s\n", http_date(item->st.st_mtime)); |
536 | htmlf("Expires: %s\n", http_date(item->st.st_mtime + | 536 | htmlf("Expires: %s\n", http_date(item->st.st_mtime + |
537 | ttl_seconds(item->ttl))); | 537 | ttl_seconds(item->ttl))); |
538 | html("\n"); | 538 | html("\n"); |
539 | } | 539 | } |
540 | 540 | ||
541 | /* vim:set sw=8: */ | 541 | /* vim:set sw=8: */ |