]> gitweb.ps.run Git - ps-cgit/blobdiff - ui-shared.c
tabs: do not use target=_blank
[ps-cgit] / ui-shared.c
index eaa45fb402f21aefcff21afe53e2bacae1ec0534..3b2dc06ceef471ecfc1d8bae23589884a681c5bb 100644 (file)
@@ -607,31 +607,10 @@ void cgit_submodule_link(const char *class, char *path, const char *rev)
                path[len - 1] = tail;
 }
 
-static const char *fmt_date(time_t secs, const char *format, int local_time)
-{
-       static char buf[64];
-       struct tm *time;
-
-       if (!secs)
-               return "";
-       if (local_time)
-               time = localtime(&secs);
-       else
-               time = gmtime(&secs);
-       strftime(buf, sizeof(buf)-1, format, time);
-       return buf;
-}
-
-void cgit_print_date(time_t secs, const char *format, int local_time)
-{
-       html_txt(fmt_date(secs, format, local_time));
-}
-
-const struct date_mode *cgit_date_mode(const char *format)
+const struct date_mode *cgit_date_mode(enum date_mode_type type)
 {
        static struct date_mode mode;
-       mode.type = DATE_STRFTIME;
-       mode.strftime_fmt = format;
+       mode.type = type;
        mode.local = ctx.cfg.local_time;
        return &mode;
 }
@@ -640,7 +619,7 @@ static void print_rel_date(time_t t, int tz, double value,
        const char *class, const char *suffix)
 {
        htmlf("<span class='%s' title='", class);
-       html_attr(show_date(t, tz, cgit_date_mode(FMT_LONGDATE)));
+       html_attr(show_date(t, tz, cgit_date_mode(DATE_ISO8601)));
        htmlf("'>%.0f %s</span>", value, suffix);
 }
 
@@ -657,9 +636,9 @@ void cgit_print_age(time_t t, int tz, time_t max_relative)
 
        if (secs > max_relative && max_relative >= 0) {
                html("<span title='");
-               html_attr(show_date(t, tz, cgit_date_mode(FMT_LONGDATE)));
+               html_attr(show_date(t, tz, cgit_date_mode(DATE_ISO8601)));
                html("'>");
-               html_txt(show_date(t, tz, cgit_date_mode(FMT_SHORTDATE)));
+               html_txt(show_date(t, tz, cgit_date_mode(DATE_SHORT)));
                html("</span>");
                return;
        }
@@ -801,7 +780,7 @@ void cgit_print_docend(void)
        else {
                htmlf("<div class='footer'>generated by <a href='http://git.zx2c4.com/cgit/about/'>cgit %s</a> at ",
                        cgit_version);
-               html_txt(show_date(time(NULL), 0, cgit_date_mode(FMT_LONGDATE)));
+               html_txt(show_date(time(NULL), 0, cgit_date_mode(DATE_ISO8601)));
                html("</div>\n");
        }
        html("</div> <!-- id=cgit -->\n");
@@ -1018,6 +997,11 @@ void cgit_print_pageheader(void)
                if (ctx.repo->max_stats)
                        cgit_stats_link("stats", NULL, hc("stats"),
                                        ctx.qry.head, ctx.qry.vpath);
+               if (ctx.repo->homepage) {
+                       html("<a href='");
+                       html_attr(ctx.repo->homepage);
+                       html("'>homepage</a>");
+               }
                html("</td><td class='form'>");
                html("<form class='right' method='get' action='");
                if (ctx.cfg.virtual_root) {