author | Lars Hjemli <hjemli@gmail.com> | 2007-06-18 07:42:10 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2007-06-18 08:38:40 (UTC) |
commit | f69250358a74efa5d7d9c562b2cdd80fad1430f1 (patch) (unidiff) | |
tree | 19c0ddab227d1c27a49046e559618cd067169591 /ui-shared.c | |
parent | 4a0be586662843382ecfa53af34a13b291312bc0 (diff) | |
download | cgit-f69250358a74efa5d7d9c562b2cdd80fad1430f1.zip cgit-f69250358a74efa5d7d9c562b2cdd80fad1430f1.tar.gz cgit-f69250358a74efa5d7d9c562b2cdd80fad1430f1.tar.bz2 |
Add version info from git-describe
A new script, gen-version.sh, is now invoked from 'make version' to generate
the file VERSION. This file contains a version identifier generated by
git-describe and is included in the Makefile.
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
-rw-r--r-- | ui-shared.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/ui-shared.c b/ui-shared.c index 15d8254..110c696 100644 --- a/ui-shared.c +++ b/ui-shared.c | |||
@@ -137,195 +137,195 @@ static char *repolink(char *title, char *class, char *page, char *head, | |||
137 | } | 137 | } |
138 | 138 | ||
139 | static void reporevlink(char *page, char *name, char *title, char *class, | 139 | static void reporevlink(char *page, char *name, char *title, char *class, |
140 | char *head, char *rev, char *path) | 140 | char *head, char *rev, char *path) |
141 | { | 141 | { |
142 | char *delim; | 142 | char *delim; |
143 | 143 | ||
144 | delim = repolink(title, class, page, head, path); | 144 | delim = repolink(title, class, page, head, path); |
145 | if (rev && strcmp(rev, cgit_query_head)) { | 145 | if (rev && strcmp(rev, cgit_query_head)) { |
146 | html(delim); | 146 | html(delim); |
147 | html("id="); | 147 | html("id="); |
148 | html_attr(rev); | 148 | html_attr(rev); |
149 | } | 149 | } |
150 | html("'>"); | 150 | html("'>"); |
151 | html_txt(name); | 151 | html_txt(name); |
152 | html("</a>"); | 152 | html("</a>"); |
153 | } | 153 | } |
154 | 154 | ||
155 | void cgit_tree_link(char *name, char *title, char *class, char *head, | 155 | void cgit_tree_link(char *name, char *title, char *class, char *head, |
156 | char *rev, char *path) | 156 | char *rev, char *path) |
157 | { | 157 | { |
158 | reporevlink("tree", name, title, class, head, rev, path); | 158 | reporevlink("tree", name, title, class, head, rev, path); |
159 | } | 159 | } |
160 | 160 | ||
161 | void cgit_log_link(char *name, char *title, char *class, char *head, | 161 | void cgit_log_link(char *name, char *title, char *class, char *head, |
162 | char *rev, char *path) | 162 | char *rev, char *path) |
163 | { | 163 | { |
164 | reporevlink("log", name, title, class, head, rev, path); | 164 | reporevlink("log", name, title, class, head, rev, path); |
165 | } | 165 | } |
166 | 166 | ||
167 | void cgit_commit_link(char *name, char *title, char *class, char *head, | 167 | void cgit_commit_link(char *name, char *title, char *class, char *head, |
168 | char *rev) | 168 | char *rev) |
169 | { | 169 | { |
170 | if (strlen(name) > cgit_max_msg_len && cgit_max_msg_len >= 15) { | 170 | if (strlen(name) > cgit_max_msg_len && cgit_max_msg_len >= 15) { |
171 | name[cgit_max_msg_len] = '\0'; | 171 | name[cgit_max_msg_len] = '\0'; |
172 | name[cgit_max_msg_len - 1] = '.'; | 172 | name[cgit_max_msg_len - 1] = '.'; |
173 | name[cgit_max_msg_len - 2] = '.'; | 173 | name[cgit_max_msg_len - 2] = '.'; |
174 | name[cgit_max_msg_len - 3] = '.'; | 174 | name[cgit_max_msg_len - 3] = '.'; |
175 | } | 175 | } |
176 | reporevlink("commit", name, title, class, head, rev, NULL); | 176 | reporevlink("commit", name, title, class, head, rev, NULL); |
177 | } | 177 | } |
178 | 178 | ||
179 | void cgit_diff_link(char *name, char *title, char *class, char *head, | 179 | void cgit_diff_link(char *name, char *title, char *class, char *head, |
180 | char *new_rev, char *old_rev, char *path) | 180 | char *new_rev, char *old_rev, char *path) |
181 | { | 181 | { |
182 | char *delim; | 182 | char *delim; |
183 | 183 | ||
184 | delim = repolink(title, class, "diff", head, path); | 184 | delim = repolink(title, class, "diff", head, path); |
185 | if (new_rev && strcmp(new_rev, cgit_query_head)) { | 185 | if (new_rev && strcmp(new_rev, cgit_query_head)) { |
186 | html(delim); | 186 | html(delim); |
187 | html("id="); | 187 | html("id="); |
188 | html_attr(new_rev); | 188 | html_attr(new_rev); |
189 | delim = "&"; | 189 | delim = "&"; |
190 | } | 190 | } |
191 | if (old_rev) { | 191 | if (old_rev) { |
192 | html(delim); | 192 | html(delim); |
193 | html("id2="); | 193 | html("id2="); |
194 | html_attr(old_rev); | 194 | html_attr(old_rev); |
195 | } | 195 | } |
196 | html("'>"); | 196 | html("'>"); |
197 | html_txt(name); | 197 | html_txt(name); |
198 | html("</a>"); | 198 | html("</a>"); |
199 | } | 199 | } |
200 | 200 | ||
201 | void cgit_print_date(time_t secs, char *format) | 201 | void cgit_print_date(time_t secs, char *format) |
202 | { | 202 | { |
203 | char buf[64]; | 203 | char buf[64]; |
204 | struct tm *time; | 204 | struct tm *time; |
205 | 205 | ||
206 | time = gmtime(&secs); | 206 | time = gmtime(&secs); |
207 | strftime(buf, sizeof(buf)-1, format, time); | 207 | strftime(buf, sizeof(buf)-1, format, time); |
208 | html_txt(buf); | 208 | html_txt(buf); |
209 | } | 209 | } |
210 | 210 | ||
211 | void cgit_print_age(time_t t, time_t max_relative, char *format) | 211 | void cgit_print_age(time_t t, time_t max_relative, char *format) |
212 | { | 212 | { |
213 | time_t now, secs; | 213 | time_t now, secs; |
214 | 214 | ||
215 | time(&now); | 215 | time(&now); |
216 | secs = now - t; | 216 | secs = now - t; |
217 | 217 | ||
218 | if (secs > max_relative && max_relative >= 0) { | 218 | if (secs > max_relative && max_relative >= 0) { |
219 | cgit_print_date(t, format); | 219 | cgit_print_date(t, format); |
220 | return; | 220 | return; |
221 | } | 221 | } |
222 | 222 | ||
223 | if (secs < TM_HOUR * 2) { | 223 | if (secs < TM_HOUR * 2) { |
224 | htmlf("<span class='age-mins'>%.0f min.</span>", | 224 | htmlf("<span class='age-mins'>%.0f min.</span>", |
225 | secs * 1.0 / TM_MIN); | 225 | secs * 1.0 / TM_MIN); |
226 | return; | 226 | return; |
227 | } | 227 | } |
228 | if (secs < TM_DAY * 2) { | 228 | if (secs < TM_DAY * 2) { |
229 | htmlf("<span class='age-hours'>%.0f hours</span>", | 229 | htmlf("<span class='age-hours'>%.0f hours</span>", |
230 | secs * 1.0 / TM_HOUR); | 230 | secs * 1.0 / TM_HOUR); |
231 | return; | 231 | return; |
232 | } | 232 | } |
233 | if (secs < TM_WEEK * 2) { | 233 | if (secs < TM_WEEK * 2) { |
234 | htmlf("<span class='age-days'>%.0f days</span>", | 234 | htmlf("<span class='age-days'>%.0f days</span>", |
235 | secs * 1.0 / TM_DAY); | 235 | secs * 1.0 / TM_DAY); |
236 | return; | 236 | return; |
237 | } | 237 | } |
238 | if (secs < TM_MONTH * 2) { | 238 | if (secs < TM_MONTH * 2) { |
239 | htmlf("<span class='age-weeks'>%.0f weeks</span>", | 239 | htmlf("<span class='age-weeks'>%.0f weeks</span>", |
240 | secs * 1.0 / TM_WEEK); | 240 | secs * 1.0 / TM_WEEK); |
241 | return; | 241 | return; |
242 | } | 242 | } |
243 | if (secs < TM_YEAR * 2) { | 243 | if (secs < TM_YEAR * 2) { |
244 | htmlf("<span class='age-months'>%.0f months</span>", | 244 | htmlf("<span class='age-months'>%.0f months</span>", |
245 | secs * 1.0 / TM_MONTH); | 245 | secs * 1.0 / TM_MONTH); |
246 | return; | 246 | return; |
247 | } | 247 | } |
248 | htmlf("<span class='age-years'>%.0f years</span>", | 248 | htmlf("<span class='age-years'>%.0f years</span>", |
249 | secs * 1.0 / TM_YEAR); | 249 | secs * 1.0 / TM_YEAR); |
250 | } | 250 | } |
251 | 251 | ||
252 | void cgit_print_docstart(char *title, struct cacheitem *item) | 252 | void cgit_print_docstart(char *title, struct cacheitem *item) |
253 | { | 253 | { |
254 | html("Content-Type: text/html; charset=utf-8\n"); | 254 | html("Content-Type: text/html; charset=utf-8\n"); |
255 | htmlf("Last-Modified: %s\n", http_date(item->st.st_mtime)); | 255 | htmlf("Last-Modified: %s\n", http_date(item->st.st_mtime)); |
256 | htmlf("Expires: %s\n", http_date(item->st.st_mtime + | 256 | htmlf("Expires: %s\n", http_date(item->st.st_mtime + |
257 | ttl_seconds(item->ttl))); | 257 | ttl_seconds(item->ttl))); |
258 | html("\n"); | 258 | html("\n"); |
259 | html(cgit_doctype); | 259 | html(cgit_doctype); |
260 | html("<html>\n"); | 260 | html("<html>\n"); |
261 | html("<head>\n"); | 261 | html("<head>\n"); |
262 | html("<title>"); | 262 | html("<title>"); |
263 | html_txt(title); | 263 | html_txt(title); |
264 | html("</title>\n"); | 264 | html("</title>\n"); |
265 | htmlf("<meta name='generator' content='cgit v%s'/>\n", cgit_version); | 265 | htmlf("<meta name='generator' content='cgit %s'/>\n", cgit_version); |
266 | html("<link rel='stylesheet' type='text/css' href='"); | 266 | html("<link rel='stylesheet' type='text/css' href='"); |
267 | html_attr(cgit_css); | 267 | html_attr(cgit_css); |
268 | html("'/>\n"); | 268 | html("'/>\n"); |
269 | html("</head>\n"); | 269 | html("</head>\n"); |
270 | html("<body>\n"); | 270 | html("<body>\n"); |
271 | } | 271 | } |
272 | 272 | ||
273 | void cgit_print_docend() | 273 | void cgit_print_docend() |
274 | { | 274 | { |
275 | html("</td></tr></table>"); | 275 | html("</td></tr></table>"); |
276 | html("</body>\n</html>\n"); | 276 | html("</body>\n</html>\n"); |
277 | } | 277 | } |
278 | 278 | ||
279 | void cgit_print_pageheader(char *title, int show_search) | 279 | void cgit_print_pageheader(char *title, int show_search) |
280 | { | 280 | { |
281 | html("<table id='layout'>"); | 281 | html("<table id='layout'>"); |
282 | html("<tr><td id='header'>"); | 282 | html("<tr><td id='header'>"); |
283 | html(cgit_root_title); | 283 | html(cgit_root_title); |
284 | html("</td><td id='logo'>"); | 284 | html("</td><td id='logo'>"); |
285 | html("<a href='"); | 285 | html("<a href='"); |
286 | html_attr(cgit_logo_link); | 286 | html_attr(cgit_logo_link); |
287 | htmlf("'><img src='%s' alt='logo'/></a>", cgit_logo); | 287 | htmlf("'><img src='%s' alt='logo'/></a>", cgit_logo); |
288 | html("</td></tr>"); | 288 | html("</td></tr>"); |
289 | html("<tr><td id='crumb'>"); | 289 | html("<tr><td id='crumb'>"); |
290 | htmlf("<a href='%s'>root</a>", cgit_rooturl()); | 290 | htmlf("<a href='%s'>root</a>", cgit_rooturl()); |
291 | if (cgit_query_repo) { | 291 | if (cgit_query_repo) { |
292 | htmlf(" : <a href='%s'>", cgit_repourl(cgit_repo->url)); | 292 | htmlf(" : <a href='%s'>", cgit_repourl(cgit_repo->url)); |
293 | html_txt(cgit_repo->name); | 293 | html_txt(cgit_repo->name); |
294 | htmlf("</a> : %s", title); | 294 | htmlf("</a> : %s", title); |
295 | } | 295 | } |
296 | html("</td>"); | 296 | html("</td>"); |
297 | html("<td id='search'>"); | 297 | html("<td id='search'>"); |
298 | if (show_search) { | 298 | if (show_search) { |
299 | html("<form method='get' action='"); | 299 | html("<form method='get' action='"); |
300 | html_attr(cgit_currurl()); | 300 | html_attr(cgit_currurl()); |
301 | html("'>"); | 301 | html("'>"); |
302 | if (!cgit_virtual_root) { | 302 | if (!cgit_virtual_root) { |
303 | if (cgit_query_repo) | 303 | if (cgit_query_repo) |
304 | html_hidden("r", cgit_query_repo); | 304 | html_hidden("r", cgit_query_repo); |
305 | if (cgit_query_page) | 305 | if (cgit_query_page) |
306 | html_hidden("p", cgit_query_page); | 306 | html_hidden("p", cgit_query_page); |
307 | } | 307 | } |
308 | if (cgit_query_head) | 308 | if (cgit_query_head) |
309 | html_hidden("h", cgit_query_head); | 309 | html_hidden("h", cgit_query_head); |
310 | if (cgit_query_sha1) | 310 | if (cgit_query_sha1) |
311 | html_hidden("id", cgit_query_sha1); | 311 | html_hidden("id", cgit_query_sha1); |
312 | if (cgit_query_sha2) | 312 | if (cgit_query_sha2) |
313 | html_hidden("id2", cgit_query_sha2); | 313 | html_hidden("id2", cgit_query_sha2); |
314 | html("<input type='text' name='q' value='"); | 314 | html("<input type='text' name='q' value='"); |
315 | html_attr(cgit_query_search); | 315 | html_attr(cgit_query_search); |
316 | html("'/></form>"); | 316 | html("'/></form>"); |
317 | } | 317 | } |
318 | html("</td></tr>"); | 318 | html("</td></tr>"); |
319 | html("<tr><td id='content' colspan='2'>"); | 319 | html("<tr><td id='content' colspan='2'>"); |
320 | } | 320 | } |
321 | 321 | ||
322 | void cgit_print_snapshot_start(const char *mimetype, const char *filename, | 322 | void cgit_print_snapshot_start(const char *mimetype, const char *filename, |
323 | struct cacheitem *item) | 323 | struct cacheitem *item) |
324 | { | 324 | { |
325 | htmlf("Content-Type: %s\n", mimetype); | 325 | htmlf("Content-Type: %s\n", mimetype); |
326 | htmlf("Content-Disposition: inline; filename=\"%s\"\n", filename); | 326 | htmlf("Content-Disposition: inline; filename=\"%s\"\n", filename); |
327 | htmlf("Last-Modified: %s\n", http_date(item->st.st_mtime)); | 327 | htmlf("Last-Modified: %s\n", http_date(item->st.st_mtime)); |
328 | htmlf("Expires: %s\n", http_date(item->st.st_mtime + | 328 | htmlf("Expires: %s\n", http_date(item->st.st_mtime + |
329 | ttl_seconds(item->ttl))); | 329 | ttl_seconds(item->ttl))); |
330 | html("\n"); | 330 | html("\n"); |
331 | } | 331 | } |