summaryrefslogtreecommitdiffabout
path: root/ui-shared.c
authorLars Hjemli <hjemli@gmail.com>2007-05-14 22:48:31 (UTC)
committer Lars Hjemli <hjemli@gmail.com>2007-05-14 22:48:31 (UTC)
commitea2831f1c826d92c0158474c2d07837ec2f9fd6c (patch) (unidiff)
treee8d6a89bf0f50835f9c86dd642e7906e1d050df7 /ui-shared.c
parent6fb7d09fea94b3dd6932469283358cb24f1e7e29 (diff)
downloadcgit-ea2831f1c826d92c0158474c2d07837ec2f9fd6c.zip
cgit-ea2831f1c826d92c0158474c2d07837ec2f9fd6c.tar.gz
cgit-ea2831f1c826d92c0158474c2d07837ec2f9fd6c.tar.bz2
Don't hardcode urls when SCRIPT_NAME is available
Also, let the makefile define the name of the installed cgi and use that definition as a default value for cgit_script_name variable. Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Diffstat (limited to 'ui-shared.c') (more/less context) (show whitespace changes)
-rw-r--r--ui-shared.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/ui-shared.c b/ui-shared.c
index 6f5cf2b..b0cff7d 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -24,75 +24,75 @@ static char *http_date(time_t t)
24 tm->tm_mday, month[tm->tm_mon], 1900+tm->tm_year, 24 tm->tm_mday, month[tm->tm_mon], 1900+tm->tm_year,
25 tm->tm_hour, tm->tm_min, tm->tm_sec); 25 tm->tm_hour, tm->tm_min, tm->tm_sec);
26} 26}
27 27
28static long ttl_seconds(long ttl) 28static long ttl_seconds(long 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 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.cgi"; 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_pageurl(const char *reponame, const char *pagename,
61 const char *query) 61 const char *query)
62{ 62{
63 if (cgit_virtual_root) { 63 if (cgit_virtual_root) {
64 return fmt("%s/%s/%s/?%s", cgit_virtual_root, reponame, 64 return fmt("%s/%s/%s/?%s", cgit_virtual_root, reponame,
65 pagename, query); 65 pagename, query);
66 } else { 66 } else {
67 return fmt("?r=%s&p=%s&%s", reponame, pagename, query); 67 return fmt("?r=%s&p=%s&%s", reponame, pagename, query);
68 } 68 }
69} 69}
70 70
71char *cgit_currurl() 71char *cgit_currurl()
72{ 72{
73 if (!cgit_virtual_root) 73 if (!cgit_virtual_root)
74 return "./cgit.cgi"; 74 return cgit_script_name;
75 else if (cgit_query_page) 75 else if (cgit_query_page)
76 return fmt("%s/%s/%s/", cgit_virtual_root, cgit_query_repo, cgit_query_page); 76 return fmt("%s/%s/%s/", cgit_virtual_root, cgit_query_repo, cgit_query_page);
77 else if (cgit_query_repo) 77 else if (cgit_query_repo)
78 return fmt("%s/%s/", cgit_virtual_root, cgit_query_repo); 78 return fmt("%s/%s/", cgit_virtual_root, cgit_query_repo);
79 else 79 else
80 return fmt("%s/", cgit_virtual_root); 80 return fmt("%s/", cgit_virtual_root);
81} 81}
82 82
83 83
84void cgit_print_date(unsigned long secs) 84void cgit_print_date(unsigned long secs)
85{ 85{
86 char buf[32]; 86 char buf[32];
87 struct tm *time; 87 struct tm *time;
88 88
89 time = gmtime(&secs); 89 time = gmtime(&secs);
90 strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", time); 90 strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", time);
91 html_txt(buf); 91 html_txt(buf);
92} 92}
93 93
94void cgit_print_docstart(char *title, struct cacheitem *item) 94void cgit_print_docstart(char *title, struct cacheitem *item)
95{ 95{
96 html("Content-Type: text/html; charset=utf-8\n"); 96 html("Content-Type: text/html; charset=utf-8\n");
97 htmlf("Last-Modified: %s\n", http_date(item->st.st_mtime)); 97 htmlf("Last-Modified: %s\n", http_date(item->st.st_mtime));
98 htmlf("Expires: %s\n", http_date(item->st.st_mtime + 98 htmlf("Expires: %s\n", http_date(item->st.st_mtime +