X-Git-Url: https://gitweb.ps.run/ps-cgit/blobdiff_plain/b88fb016d0209f7041ac7d3b4d2c077318407a4d..931fc6d1e4986a4566647dda16af09bf69a28b89:/ui-shared.c?ds=sidebyside
diff --git a/ui-shared.c b/ui-shared.c
index cc1ab8b..782caa7 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -7,6 +7,8 @@
*/
#include "cgit.h"
+#include "cmd.h"
+#include "html.h"
const char cgit_doctype[] =
"tm_hour, tm->tm_min, tm->tm_sec);
}
-static long ttl_seconds(long ttl)
-{
- if (ttl<0)
- return 60 * 60 * 24 * 365;
- else
- return ttl * 60;
-}
-
void cgit_print_error(char *msg)
{
html("
");
@@ -360,24 +354,34 @@ void cgit_print_age(time_t t, time_t max_relative, char *format)
secs * 1.0 / TM_YEAR);
}
-void cgit_print_docstart(char *title, struct cacheitem *item)
+void cgit_print_http_headers(struct cgit_context *ctx)
{
- html("Content-Type: text/html; charset=" PAGE_ENCODING "\n");
- htmlf("Last-Modified: %s\n", http_date(item->st.st_mtime));
- htmlf("Expires: %s\n", http_date(item->st.st_mtime +
- ttl_seconds(item->ttl)));
+ if (ctx->page.mimetype && ctx->page.charset)
+ htmlf("Content-Type: %s; charset=%s\n", ctx->page.mimetype,
+ ctx->page.charset);
+ else if (ctx->page.mimetype)
+ htmlf("Content-Type: %s\n", ctx->page.mimetype);
+ if (ctx->page.filename)
+ htmlf("Content-Disposition: inline; filename=\"%s\"\n",
+ ctx->page.filename);
+ htmlf("Last-Modified: %s\n", http_date(ctx->page.modified));
+ htmlf("Expires: %s\n", http_date(ctx->page.expires));
html("\n");
+}
+
+void cgit_print_docstart(struct cgit_context *ctx)
+{
html(cgit_doctype);
html("\n");
html("\n");
html("
");
- html_txt(title);
+ html_txt(ctx->page.title);
html("\n");
htmlf("\n", cgit_version);
- if (ctx.cfg.robots && *ctx.cfg.robots)
- htmlf("\n", ctx.cfg.robots);
+ if (ctx->cfg.robots && *ctx->cfg.robots)
+ htmlf("\n", ctx->cfg.robots);
html("\n");
html("\n");
html("\n");
@@ -385,7 +389,7 @@ void cgit_print_docstart(char *title, struct cacheitem *item)
void cgit_print_docend()
{
- html("\n\n\n\n\n");
+ html("\n