-rw-r--r-- | ui-shared.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/ui-shared.c b/ui-shared.c index 5192800..2f771da 100644 --- a/ui-shared.c +++ b/ui-shared.c | |||
@@ -303,128 +303,130 @@ 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) | ||
368 | htmlf("<meta name='robots' content='%s'/>\n", cgit_robots); | ||
367 | html("<link rel='stylesheet' type='text/css' href='"); | 369 | html("<link rel='stylesheet' type='text/css' href='"); |
368 | html_attr(cgit_css); | 370 | html_attr(cgit_css); |
369 | html("'/>\n"); | 371 | html("'/>\n"); |
370 | html("</head>\n"); | 372 | html("</head>\n"); |
371 | html("<body>\n"); | 373 | html("<body>\n"); |
372 | } | 374 | } |
373 | 375 | ||
374 | void cgit_print_docend() | 376 | void cgit_print_docend() |
375 | { | 377 | { |
376 | html("</td>\n</tr>\n</table>\n</body>\n</html>\n"); | 378 | html("</td>\n</tr>\n</table>\n</body>\n</html>\n"); |
377 | } | 379 | } |
378 | 380 | ||
379 | int print_branch_option(const char *refname, const unsigned char *sha1, | 381 | int print_branch_option(const char *refname, const unsigned char *sha1, |
380 | int flags, void *cb_data) | 382 | int flags, void *cb_data) |
381 | { | 383 | { |
382 | char *name = (char *)refname; | 384 | char *name = (char *)refname; |
383 | html_option(name, name, cgit_query_head); | 385 | html_option(name, name, cgit_query_head); |
384 | return 0; | 386 | return 0; |
385 | } | 387 | } |
386 | 388 | ||
387 | int print_archive_ref(const char *refname, const unsigned char *sha1, | 389 | int print_archive_ref(const char *refname, const unsigned char *sha1, |
388 | int flags, void *cb_data) | 390 | int flags, void *cb_data) |
389 | { | 391 | { |
390 | struct tag *tag; | 392 | struct tag *tag; |
391 | struct taginfo *info; | 393 | struct taginfo *info; |
392 | struct object *obj; | 394 | struct object *obj; |
393 | char buf[256], *url; | 395 | char buf[256], *url; |
394 | unsigned char fileid[20]; | 396 | unsigned char fileid[20]; |
395 | int *header = (int *)cb_data; | 397 | int *header = (int *)cb_data; |
396 | 398 | ||
397 | if (prefixcmp(refname, "refs/archives")) | 399 | if (prefixcmp(refname, "refs/archives")) |
398 | return 0; | 400 | return 0; |
399 | strncpy(buf, refname+14, sizeof(buf)); | 401 | strncpy(buf, refname+14, sizeof(buf)); |
400 | obj = parse_object(sha1); | 402 | obj = parse_object(sha1); |
401 | if (!obj) | 403 | if (!obj) |
402 | return 1; | 404 | return 1; |
403 | if (obj->type == OBJ_TAG) { | 405 | if (obj->type == OBJ_TAG) { |
404 | tag = lookup_tag(sha1); | 406 | tag = lookup_tag(sha1); |
405 | if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag))) | 407 | if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag))) |
406 | return 0; | 408 | return 0; |
407 | hashcpy(fileid, tag->tagged->sha1); | 409 | hashcpy(fileid, tag->tagged->sha1); |
408 | } else if (obj->type != OBJ_BLOB) { | 410 | } else if (obj->type != OBJ_BLOB) { |
409 | return 0; | 411 | return 0; |
410 | } else { | 412 | } else { |
411 | hashcpy(fileid, sha1); | 413 | hashcpy(fileid, sha1); |
412 | } | 414 | } |
413 | if (!*header) { | 415 | if (!*header) { |
414 | html("<h1>download</h1>\n"); | 416 | html("<h1>download</h1>\n"); |
415 | *header = 1; | 417 | *header = 1; |
416 | } | 418 | } |
417 | url = cgit_pageurl(cgit_query_repo, "blob", | 419 | url = cgit_pageurl(cgit_query_repo, "blob", |
418 | fmt("id=%s&path=%s", sha1_to_hex(fileid), | 420 | fmt("id=%s&path=%s", sha1_to_hex(fileid), |
419 | buf)); | 421 | buf)); |
420 | html_link_open(url, NULL, "menu"); | 422 | html_link_open(url, NULL, "menu"); |
421 | html_txt(strlpart(buf, 20)); | 423 | html_txt(strlpart(buf, 20)); |
422 | html_link_close(); | 424 | html_link_close(); |
423 | return 0; | 425 | return 0; |
424 | } | 426 | } |
425 | 427 | ||
426 | 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) |
427 | { | 429 | { |
428 | char *url; | 430 | char *url; |
429 | 431 | ||
430 | if (!cgit_virtual_root) { | 432 | if (!cgit_virtual_root) { |