author | Lars Hjemli <hjemli@gmail.com> | 2007-02-17 12:46:18 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2007-02-20 23:24:36 (UTC) |
commit | 66cacd053ba900c8eb3b7962027370c84a97f990 (patch) (unidiff) | |
tree | 9ccd8202204bf556a186ba1520a6c767756855bf /ui-shared.c | |
parent | ac70cb4795c90db02917db63d169b0fadfe9fb99 (diff) | |
download | cgit-66cacd053ba900c8eb3b7962027370c84a97f990.zip cgit-66cacd053ba900c8eb3b7962027370c84a97f990.tar.gz cgit-66cacd053ba900c8eb3b7962027370c84a97f990.tar.bz2 |
Layout update
-rw-r--r-- | ui-shared.c | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/ui-shared.c b/ui-shared.c index 172499c..bca50aa 100644 --- a/ui-shared.c +++ b/ui-shared.c | |||
@@ -19,48 +19,56 @@ static char *http_date(time_t t) | |||
19 | static char month[][4] = | 19 | static char month[][4] = |
20 | {"Jan", "Feb", "Mar", "Apr", "May", "Jun", | 20 | {"Jan", "Feb", "Mar", "Apr", "May", "Jun", |
21 | "Jul", "Aug", "Sep", "Oct", "Now", "Dec"}; | 21 | "Jul", "Aug", "Sep", "Oct", "Now", "Dec"}; |
22 | struct tm *tm = gmtime(&t); | 22 | struct tm *tm = gmtime(&t); |
23 | return fmt("%s, %02d %s %04d %02d:%02d:%02d GMT", day[tm->tm_wday], | 23 | return fmt("%s, %02d %s %04d %02d:%02d:%02d GMT", day[tm->tm_wday], |
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 | ||
28 | static long ttl_seconds(long ttl) | 28 | static 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 | ||
36 | void cgit_print_error(char *msg) | 36 | void 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 | ||
43 | char *cgit_rooturl() | ||
44 | { | ||
45 | if (cgit_virtual_root) | ||
46 | return fmt("%s/", cgit_virtual_root); | ||
47 | else | ||
48 | return "./cgit.cgi"; | ||
49 | } | ||
50 | |||
43 | char *cgit_repourl(const char *reponame) | 51 | char *cgit_repourl(const char *reponame) |
44 | { | 52 | { |
45 | if (cgit_virtual_root) { | 53 | if (cgit_virtual_root) { |
46 | return fmt("%s/%s/", cgit_virtual_root, reponame); | 54 | return fmt("%s/%s/", cgit_virtual_root, reponame); |
47 | } else { | 55 | } else { |
48 | return fmt("?r=%s", reponame); | 56 | return fmt("?r=%s", reponame); |
49 | } | 57 | } |
50 | } | 58 | } |
51 | 59 | ||
52 | char *cgit_pageurl(const char *reponame, const char *pagename, | 60 | char *cgit_pageurl(const char *reponame, const char *pagename, |
53 | const char *query) | 61 | const char *query) |
54 | { | 62 | { |
55 | if (cgit_virtual_root) { | 63 | if (cgit_virtual_root) { |
56 | return fmt("%s/%s/%s/?%s", cgit_virtual_root, reponame, | 64 | return fmt("%s/%s/%s/?%s", cgit_virtual_root, reponame, |
57 | pagename, query); | 65 | pagename, query); |
58 | } else { | 66 | } else { |
59 | return fmt("?r=%s&p=%s&%s", reponame, pagename, query); | 67 | return fmt("?r=%s&p=%s&%s", reponame, pagename, query); |
60 | } | 68 | } |
61 | } | 69 | } |
62 | 70 | ||
63 | char *cgit_currurl() | 71 | char *cgit_currurl() |
64 | { | 72 | { |
65 | if (!cgit_virtual_root) | 73 | if (!cgit_virtual_root) |
66 | return "./cgit.cgi"; | 74 | return "./cgit.cgi"; |
@@ -92,66 +100,75 @@ void cgit_print_docstart(char *title, struct cacheitem *item) | |||
92 | ttl_seconds(item->ttl))); | 100 | ttl_seconds(item->ttl))); |
93 | html("\n"); | 101 | html("\n"); |
94 | html(cgit_doctype); | 102 | html(cgit_doctype); |
95 | html("<html>\n"); | 103 | html("<html>\n"); |
96 | html("<head>\n"); | 104 | html("<head>\n"); |
97 | html("<title>"); | 105 | html("<title>"); |
98 | html_txt(title); | 106 | html_txt(title); |
99 | html("</title>\n"); | 107 | html("</title>\n"); |
100 | htmlf("<meta name='generator' content='cgit v%s'/>\n", cgit_version); | 108 | htmlf("<meta name='generator' content='cgit v%s'/>\n", cgit_version); |
101 | html("<link rel='stylesheet' type='text/css' href='"); | 109 | html("<link rel='stylesheet' type='text/css' href='"); |
102 | html_attr(cgit_css); | 110 | html_attr(cgit_css); |
103 | html("'/>\n"); | 111 | html("'/>\n"); |
104 | html("</head>\n"); | 112 | html("</head>\n"); |
105 | html("<body>\n"); | 113 | html("<body>\n"); |
106 | } | 114 | } |
107 | 115 | ||
108 | void cgit_print_docend() | 116 | void cgit_print_docend() |
109 | { | 117 | { |
110 | html("</td></tr></table>"); | 118 | html("</td></tr></table>"); |
111 | html("</body>\n</html>\n"); | 119 | html("</body>\n</html>\n"); |
112 | } | 120 | } |
113 | 121 | ||
114 | void cgit_print_pageheader(char *title, int show_search) | 122 | void cgit_print_pageheader(char *title, int show_search) |
115 | { | 123 | { |
116 | html("<table id='layout'><tr><td id='header'>"); | 124 | html("<table id='layout'>"); |
117 | htmlf("<a href='%s'>", cgit_logo_link); | 125 | html("<tr><td id='header'>"); |
118 | htmlf("<img id='logo' src='%s'/>\n", cgit_logo); | 126 | html(cgit_root_title); |
119 | htmlf("</a>"); | 127 | html("</td><td id='logo'>"); |
128 | html("<a href='"); | ||
129 | html_attr(cgit_logo_link); | ||
130 | htmlf("'><img src='%s'/></a>", cgit_logo); | ||
131 | html("</td></tr>"); | ||
132 | html("<tr><td id='crumb'>"); | ||
133 | htmlf("<a href='%s'>root</a>", cgit_rooturl()); | ||
134 | if (cgit_query_repo) { | ||
135 | htmlf(" : <a href='%s'>", cgit_repourl(cgit_repo->url)); | ||
136 | html_txt(cgit_repo->name); | ||
137 | htmlf("</a> : %s", title); | ||
138 | } | ||
139 | html("</td>"); | ||
140 | html("<td id='search'>"); | ||
120 | if (show_search) { | 141 | if (show_search) { |
121 | html("<form method='get' href='"); | 142 | html("<form method='get' href='"); |
122 | html_attr(cgit_currurl()); | 143 | html_attr(cgit_currurl()); |
123 | html("'>"); | 144 | html("'>"); |
124 | if (!cgit_virtual_root) { | 145 | if (!cgit_virtual_root) { |
125 | if (cgit_query_repo) | 146 | if (cgit_query_repo) |
126 | html_hidden("r", cgit_query_repo); | 147 | html_hidden("r", cgit_query_repo); |
127 | if (cgit_query_page) | 148 | if (cgit_query_page) |
128 | html_hidden("p", cgit_query_page); | 149 | html_hidden("p", cgit_query_page); |
129 | } | 150 | } |
130 | if (cgit_query_head) | 151 | if (cgit_query_head) |
131 | html_hidden("h", cgit_query_head); | 152 | html_hidden("h", cgit_query_head); |
132 | if (cgit_query_sha1) | 153 | if (cgit_query_sha1) |
133 | html_hidden("id", cgit_query_sha1); | 154 | html_hidden("id", cgit_query_sha1); |
134 | if (cgit_query_sha2) | 155 | if (cgit_query_sha2) |
135 | html_hidden("id2", cgit_query_sha2); | 156 | html_hidden("id2", cgit_query_sha2); |
136 | html("<input type='text' name='q' value='"); | 157 | html("<input type='text' name='q' value='"); |
137 | html_attr(cgit_query_search); | 158 | html_attr(cgit_query_search); |
138 | html("'/></form>"); | 159 | html("'/></form>"); |
139 | } | 160 | } |
140 | if (cgit_query_repo) | 161 | html("</td></tr>"); |
141 | htmlf("<a href='%s'>", cgit_repourl(cgit_query_repo)); | 162 | html("<tr><td id='content' colspan='2'>"); |
142 | html_txt(title); | ||
143 | if (cgit_query_repo) | ||
144 | html("</a>"); | ||
145 | html("</td></tr><tr><td id='content'>"); | ||
146 | } | 163 | } |
147 | 164 | ||
148 | void cgit_print_snapshot_start(const char *mimetype, const char *filename, | 165 | void cgit_print_snapshot_start(const char *mimetype, const char *filename, |
149 | struct cacheitem *item) | 166 | struct cacheitem *item) |
150 | { | 167 | { |
151 | htmlf("Content-Type: %s\n", mimetype); | 168 | htmlf("Content-Type: %s\n", mimetype); |
152 | htmlf("Content-Disposition: inline; filename=\"%s\"\n", filename); | 169 | htmlf("Content-Disposition: inline; filename=\"%s\"\n", filename); |
153 | htmlf("Last-Modified: %s\n", http_date(item->st.st_mtime)); | 170 | htmlf("Last-Modified: %s\n", http_date(item->st.st_mtime)); |
154 | htmlf("Expires: %s\n", http_date(item->st.st_mtime + | 171 | htmlf("Expires: %s\n", http_date(item->st.st_mtime + |
155 | ttl_seconds(item->ttl))); | 172 | ttl_seconds(item->ttl))); |
156 | html("\n"); | 173 | html("\n"); |
157 | } | 174 | } |