X-Git-Url: https://gitweb.ps.run/ps-cgit/blobdiff_plain/bbfa006e6eb93d56842c1d90bbba1c5484afb855..caed6cb:/ui-shared.c
diff --git a/ui-shared.c b/ui-shared.c
index 4e317d0..bd74f42 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -587,6 +587,23 @@ void cgit_print_date(time_t secs, const char *format, int local_time)
html_txt(buf);
}
+static void print_rel_date(time_t t, double value,
+ const char *class, const char *suffix)
+{
+ char buf[64];
+ struct tm *time;
+
+ if (ctx.cfg.local_time)
+ time = localtime(&t);
+ else
+ time = gmtime(&t);
+ strftime(buf, sizeof(buf) - 1, FMT_LONGDATE, time);
+
+ htmlf("%.0f %s", value, suffix);
+}
+
void cgit_print_age(time_t t, time_t max_relative, const char *format)
{
time_t now, secs;
@@ -604,32 +621,26 @@ void cgit_print_age(time_t t, time_t max_relative, const char *format)
}
if (secs < TM_HOUR * 2) {
- htmlf("%.0f min.",
- secs * 1.0 / TM_MIN);
+ print_rel_date(t, secs * 1.0 / TM_MIN, "age-mins", "min.");
return;
}
if (secs < TM_DAY * 2) {
- htmlf("%.0f hours",
- secs * 1.0 / TM_HOUR);
+ print_rel_date(t, secs * 1.0 / TM_HOUR, "age-hours", "hours");
return;
}
if (secs < TM_WEEK * 2) {
- htmlf("%.0f days",
- secs * 1.0 / TM_DAY);
+ print_rel_date(t, secs * 1.0 / TM_DAY, "age-days", "days");
return;
}
if (secs < TM_MONTH * 2) {
- htmlf("%.0f weeks",
- secs * 1.0 / TM_WEEK);
+ print_rel_date(t, secs * 1.0 / TM_WEEK, "age-weeks", "weeks");
return;
}
if (secs < TM_YEAR * 2) {
- htmlf("%.0f months",
- secs * 1.0 / TM_MONTH);
+ print_rel_date(t, secs * 1.0 / TM_MONTH, "age-months", "months");
return;
}
- htmlf("%.0f years",
- secs * 1.0 / TM_YEAR);
+ print_rel_date(t, secs * 1.0 / TM_YEAR, "age-years", "years");
}
void cgit_print_http_headers(void)
@@ -660,6 +671,15 @@ void cgit_print_http_headers(void)
exit(0);
}
+static void print_rel_vcs_link(const char *url)
+{
+ html("\n");
+}
+
void cgit_print_docstart(void)
{
if (ctx.cfg.embedded) {
@@ -698,6 +718,8 @@ void cgit_print_docstart(void)
html("' type='application/atom+xml'/>\n");
strbuf_release(&sb);
}
+ if (ctx.repo)
+ cgit_add_clone_urls(print_rel_vcs_link);
if (ctx.cfg.head_include)
html_include(ctx.cfg.head_include);
html("\n");