summaryrefslogtreecommitdiffabout
path: root/ui-shared.c
Unidiff
Diffstat (limited to 'ui-shared.c') (more/less context) (ignore whitespace changes)
-rw-r--r--ui-shared.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/ui-shared.c b/ui-shared.c
index e795043..cb8a8df 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -26,32 +26,53 @@ static char *http_date(time_t t)
26} 26}
27 27
28static int ttl_seconds(int ttl) 28static int ttl_seconds(int ttl)
29{ 29{
30 if (ttl<0) 30 if (ttl<0)
31 return 60 * 60 * 24 * 365; 31 return 60 * 60 * 24 * 365;
32 else 32 else
33 return ttl * 60; 33 return ttl * 60;
34} 34}
35 35
36void cgit_print_error(char *msg) 36void cgit_print_error(char *msg)
37{ 37{
38 html("<div class='error'>"); 38 html("<div class='error'>");
39 html_txt(msg); 39 html_txt(msg);
40 html("</div>\n"); 40 html("</div>\n");
41} 41}
42
43char *cgit_repourl(const char *reponame)
44{
45 if (cgit_virtual_root) {
46 return fmt("%s/%s/", cgit_virtual_root, reponame);
47 } else {
48 return fmt("?r=%s", reponame);
49 }
50}
51
52char *cgit_pageurl(const char *reponame, const char *pagename,
53 const char *query)
54{
55 if (cgit_virtual_root) {
56 return fmt("%s/%s/%s/?%s", cgit_virtual_root, reponame,
57 pagename, query);
58 } else {
59 return fmt("?r=%s&p=%s&%s", reponame, pagename, query);
60 }
61}
62
42void cgit_print_docstart(char *title, struct cacheitem *item) 63void cgit_print_docstart(char *title, struct cacheitem *item)
43{ 64{
44 html("Content-Type: text/html; charset=utf-8\n"); 65 html("Content-Type: text/html; charset=utf-8\n");
45 htmlf("Last-Modified: %s\n", http_date(item->st.st_mtime)); 66 htmlf("Last-Modified: %s\n", http_date(item->st.st_mtime));
46 htmlf("Expires: %s\n", http_date(item->st.st_mtime + 67 htmlf("Expires: %s\n", http_date(item->st.st_mtime +
47 ttl_seconds(item->ttl))); 68 ttl_seconds(item->ttl)));
48 html("\n"); 69 html("\n");
49 html(cgit_doctype); 70 html(cgit_doctype);
50 html("<html>\n"); 71 html("<html>\n");
51 html("<head>\n"); 72 html("<head>\n");
52 html("<title>"); 73 html("<title>");
53 html_txt(title); 74 html_txt(title);
54 html("</title>\n"); 75 html("</title>\n");
55 htmlf("<meta name='generator' content='cgit v%s'/>\n", cgit_version); 76 htmlf("<meta name='generator' content='cgit v%s'/>\n", cgit_version);
56 html("<link rel='stylesheet' type='text/css' href='"); 77 html("<link rel='stylesheet' type='text/css' href='");
57 html_attr(cgit_css); 78 html_attr(cgit_css);