]> gitweb.ps.run Git - ps-cgit/blobdiff - ui-shared.c
refactor get_mimetype_from_file() to get_mimetype_for_filename()
[ps-cgit] / ui-shared.c
index 19cd52178cc22320ecb92ac6ffab8e90fb493ed3..89c48979586edaa7dc6d7df1aa133f288638b70e 100644 (file)
@@ -627,17 +627,8 @@ void cgit_print_date(time_t secs, const char *format, int local_time)
 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("<span class='%s' title='", class);
-       html_attr(buf);
+       html_attr(fmt_date(t, FMT_LONGDATE, ctx.cfg.local_time));
        htmlf("'>%.0f %s</span>", value, suffix);
 }
 
@@ -653,7 +644,11 @@ void cgit_print_age(time_t t, time_t max_relative, const char *format)
                secs = 0;
 
        if (secs > max_relative && max_relative >= 0) {
+               html("<span title='");
+               html_attr(fmt_date(t, FMT_LONGDATE, ctx.cfg.local_time));
+               html("'>");
                cgit_print_date(t, format, ctx.cfg.local_time);
+               html("</span>");
                return;
        }
 
@@ -793,6 +788,33 @@ void cgit_print_docend(void)
        html("</body>\n</html>\n");
 }
 
+void cgit_print_error_page(int code, const char *msg, const char *fmt, ...)
+{
+       va_list ap;
+       ctx.page.expires = ctx.cfg.cache_dynamic_ttl;
+       ctx.page.status = code;
+       ctx.page.statusmsg = msg;
+       cgit_print_http_headers();
+       cgit_print_docstart();
+       cgit_print_pageheader();
+       va_start(ap, fmt);
+       cgit_vprint_error(fmt, ap);
+       va_end(ap);
+       cgit_print_docend();
+}
+
+void cgit_print_layout_start(void)
+{
+       cgit_print_http_headers();
+       cgit_print_docstart();
+       cgit_print_pageheader();
+}
+
+void cgit_print_layout_end(void)
+{
+       cgit_print_docend();
+}
+
 static void add_clone_urls(void (*fn)(const char *), char *txt, char *suffix)
 {
        struct strbuf **url_list = strbuf_split_str(txt, ' ', 0);