summaryrefslogtreecommitdiffabout
path: root/ui-shared.c
Unidiff
Diffstat (limited to 'ui-shared.c') (more/less context) (ignore whitespace changes)
-rw-r--r--ui-shared.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/ui-shared.c b/ui-shared.c
index d4376ce..1c1415e 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -36,66 +36,73 @@ static long ttl_seconds(long ttl)
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 42
43char *cgit_rooturl() 43char *cgit_rooturl()
44{ 44{
45 if (cgit_virtual_root) 45 if (cgit_virtual_root)
46 return fmt("%s/", cgit_virtual_root); 46 return fmt("%s/", cgit_virtual_root);
47 else 47 else
48 return cgit_script_name; 48 return cgit_script_name;
49} 49}
50 50
51char *cgit_repourl(const char *reponame) 51char *cgit_repourl(const char *reponame)
52{ 52{
53 if (cgit_virtual_root) { 53 if (cgit_virtual_root) {
54 return fmt("%s/%s/", cgit_virtual_root, reponame); 54 return fmt("%s/%s/", cgit_virtual_root, reponame);
55 } else { 55 } else {
56 return fmt("?r=%s", reponame); 56 return fmt("?r=%s", reponame);
57 } 57 }
58} 58}
59 59
60char *cgit_pageurl(const char *reponame, const char *pagename, 60char *cgit_fileurl(const char *reponame, const char *pagename,
61 const char *query) 61 const char *filename, const char *query)
62{ 62{
63 if (cgit_virtual_root) { 63 if (cgit_virtual_root) {
64 if (query) 64 if (query)
65 return fmt("%s/%s/%s/?%s", cgit_virtual_root, reponame, 65 return fmt("%s/%s/%s/%s?%s", cgit_virtual_root, reponame,
66 pagename, query); 66 pagename, filename?filename:"", query);
67 else 67 else
68 return fmt("%s/%s/%s/", cgit_virtual_root, reponame, 68 return fmt("%s/%s/%s/", cgit_virtual_root, reponame,
69 pagename); 69 pagename);
70 } else { 70 } else {
71 if (query) 71 if (query)
72 return fmt("?r=%s&amp;p=%s&amp;%s", reponame, pagename, query); 72 return fmt("?r=%s&amp;p=%s&amp;%s", reponame, pagename, query);
73 else 73 else
74 return fmt("?r=%s&amp;p=%s", reponame, pagename); 74 return fmt("?r=%s&amp;p=%s", reponame, pagename);
75 } 75 }
76} 76}
77 77
78char *cgit_pageurl(const char *reponame, const char *pagename,
79 const char *query)
80{
81 return cgit_fileurl(reponame,pagename,0,query);
82}
83
84
78char *cgit_currurl() 85char *cgit_currurl()
79{ 86{
80 if (!cgit_virtual_root) 87 if (!cgit_virtual_root)
81 return cgit_script_name; 88 return cgit_script_name;
82 else if (cgit_query_page) 89 else if (cgit_query_page)
83 return fmt("%s/%s/%s/", cgit_virtual_root, cgit_query_repo, cgit_query_page); 90 return fmt("%s/%s/%s/", cgit_virtual_root, cgit_query_repo, cgit_query_page);
84 else if (cgit_query_repo) 91 else if (cgit_query_repo)
85 return fmt("%s/%s/", cgit_virtual_root, cgit_query_repo); 92 return fmt("%s/%s/", cgit_virtual_root, cgit_query_repo);
86 else 93 else
87 return fmt("%s/", cgit_virtual_root); 94 return fmt("%s/", cgit_virtual_root);
88} 95}
89 96
90static char *repolink(char *title, char *class, char *page, char *head, 97static char *repolink(char *title, char *class, char *page, char *head,
91 char *path) 98 char *path)
92{ 99{
93 char *delim = "?"; 100 char *delim = "?";
94 101
95 html("<a"); 102 html("<a");
96 if (title) { 103 if (title) {
97 html(" title='"); 104 html(" title='");
98 html_attr(title); 105 html_attr(title);
99 html("'"); 106 html("'");
100 } 107 }
101 if (class) { 108 if (class) {
@@ -347,24 +354,26 @@ void cgit_print_pageheader(char *title, int show_search)
347 if (cgit_query_head) 354 if (cgit_query_head)
348 html_hidden("h", cgit_query_head); 355 html_hidden("h", cgit_query_head);
349 if (cgit_query_sha1) 356 if (cgit_query_sha1)
350 html_hidden("id", cgit_query_sha1); 357 html_hidden("id", cgit_query_sha1);
351 if (cgit_query_sha2) 358 if (cgit_query_sha2)
352 html_hidden("id2", cgit_query_sha2); 359 html_hidden("id2", cgit_query_sha2);
353 html("<input type='text' name='q' value='"); 360 html("<input type='text' name='q' value='");
354 html_attr(cgit_query_search); 361 html_attr(cgit_query_search);
355 html("'/></form>"); 362 html("'/></form>");
356 } 363 }
357 html("</td></tr>"); 364 html("</td></tr>");
358 html("<tr><td id='content' colspan='2'>"); 365 html("<tr><td id='content' colspan='2'>");
359} 366}
360 367
361void cgit_print_snapshot_start(const char *mimetype, const char *filename, 368void cgit_print_snapshot_start(const char *mimetype, const char *filename,
362 struct cacheitem *item) 369 struct cacheitem *item)
363{ 370{
364 htmlf("Content-Type: %s\n", mimetype); 371 htmlf("Content-Type: %s\n", mimetype);
365 htmlf("Content-Disposition: inline; filename=\"%s\"\n", filename); 372 htmlf("Content-Disposition: inline; filename=\"%s\"\n", filename);
366 htmlf("Last-Modified: %s\n", http_date(item->st.st_mtime)); 373 htmlf("Last-Modified: %s\n", http_date(item->st.st_mtime));
367 htmlf("Expires: %s\n", http_date(item->st.st_mtime + 374 htmlf("Expires: %s\n", http_date(item->st.st_mtime +
368 ttl_seconds(item->ttl))); 375 ttl_seconds(item->ttl)));
369 html("\n"); 376 html("\n");
370} 377}
378
379/* vim:set sw=8: */