summaryrefslogtreecommitdiffabout
path: root/ui-shared.c
authorLars Hjemli <hjemli@gmail.com>2007-10-28 14:23:00 (UTC)
committer Lars Hjemli <hjemli@gmail.com>2007-10-28 14:23:00 (UTC)
commit68ca032dbe7379f78775fb03ef34a9ad2abc409f (patch) (unidiff)
tree2209ae312eb932bc61b41ae9c774f6cfcc3dd372 /ui-shared.c
parent6ec5f36f279a85f59db2851ab476d9acd0015770 (diff)
downloadcgit-68ca032dbe7379f78775fb03ef34a9ad2abc409f.zip
cgit-68ca032dbe7379f78775fb03ef34a9ad2abc409f.tar.gz
cgit-68ca032dbe7379f78775fb03ef34a9ad2abc409f.tar.bz2
Teach log search about --grep, --author and --committer
This makes the log searching more explicit, using a dropdown box to specify the commit field to match against. Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Diffstat (limited to 'ui-shared.c') (more/less context) (ignore whitespace changes)
-rw-r--r--ui-shared.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/ui-shared.c b/ui-shared.c
index e4bb98f..45105dc 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -292,148 +292,153 @@ void cgit_print_date(time_t secs, char *format)
292 292
293 time = gmtime(&secs); 293 time = gmtime(&secs);
294 strftime(buf, sizeof(buf)-1, format, time); 294 strftime(buf, sizeof(buf)-1, format, time);
295 html_txt(buf); 295 html_txt(buf);
296} 296}
297 297
298void cgit_print_age(time_t t, time_t max_relative, char *format) 298void cgit_print_age(time_t t, time_t max_relative, char *format)
299{ 299{
300 time_t now, secs; 300 time_t now, secs;
301 301
302 time(&now); 302 time(&now);
303 secs = now - t; 303 secs = now - t;
304 304
305 if (secs > max_relative && max_relative >= 0) { 305 if (secs > max_relative && max_relative >= 0) {
306 cgit_print_date(t, format); 306 cgit_print_date(t, format);
307 return; 307 return;
308 } 308 }
309 309
310 if (secs < TM_HOUR * 2) { 310 if (secs < TM_HOUR * 2) {
311 htmlf("<span class='age-mins'>%.0f min.</span>", 311 htmlf("<span class='age-mins'>%.0f min.</span>",
312 secs * 1.0 / TM_MIN); 312 secs * 1.0 / TM_MIN);
313 return; 313 return;
314 } 314 }
315 if (secs < TM_DAY * 2) { 315 if (secs < TM_DAY * 2) {
316 htmlf("<span class='age-hours'>%.0f hours</span>", 316 htmlf("<span class='age-hours'>%.0f hours</span>",
317 secs * 1.0 / TM_HOUR); 317 secs * 1.0 / TM_HOUR);
318 return; 318 return;
319 } 319 }
320 if (secs < TM_WEEK * 2) { 320 if (secs < TM_WEEK * 2) {
321 htmlf("<span class='age-days'>%.0f days</span>", 321 htmlf("<span class='age-days'>%.0f days</span>",
322 secs * 1.0 / TM_DAY); 322 secs * 1.0 / TM_DAY);
323 return; 323 return;
324 } 324 }
325 if (secs < TM_MONTH * 2) { 325 if (secs < TM_MONTH * 2) {
326 htmlf("<span class='age-weeks'>%.0f weeks</span>", 326 htmlf("<span class='age-weeks'>%.0f weeks</span>",
327 secs * 1.0 / TM_WEEK); 327 secs * 1.0 / TM_WEEK);
328 return; 328 return;
329 } 329 }
330 if (secs < TM_YEAR * 2) { 330 if (secs < TM_YEAR * 2) {
331 htmlf("<span class='age-months'>%.0f months</span>", 331 htmlf("<span class='age-months'>%.0f months</span>",
332 secs * 1.0 / TM_MONTH); 332 secs * 1.0 / TM_MONTH);
333 return; 333 return;
334 } 334 }
335 htmlf("<span class='age-years'>%.0f years</span>", 335 htmlf("<span class='age-years'>%.0f years</span>",
336 secs * 1.0 / TM_YEAR); 336 secs * 1.0 / TM_YEAR);
337} 337}
338 338
339void cgit_print_docstart(char *title, struct cacheitem *item) 339void cgit_print_docstart(char *title, struct cacheitem *item)
340{ 340{
341 html("Content-Type: text/html; charset=utf-8\n"); 341 html("Content-Type: text/html; charset=utf-8\n");
342 htmlf("Last-Modified: %s\n", http_date(item->st.st_mtime)); 342 htmlf("Last-Modified: %s\n", http_date(item->st.st_mtime));
343 htmlf("Expires: %s\n", http_date(item->st.st_mtime + 343 htmlf("Expires: %s\n", http_date(item->st.st_mtime +
344 ttl_seconds(item->ttl))); 344 ttl_seconds(item->ttl)));
345 html("\n"); 345 html("\n");
346 html(cgit_doctype); 346 html(cgit_doctype);
347 html("<html>\n"); 347 html("<html>\n");
348 html("<head>\n"); 348 html("<head>\n");
349 html("<title>"); 349 html("<title>");
350 html_txt(title); 350 html_txt(title);
351 html("</title>\n"); 351 html("</title>\n");
352 htmlf("<meta name='generator' content='cgit %s'/>\n", cgit_version); 352 htmlf("<meta name='generator' content='cgit %s'/>\n", cgit_version);
353 html("<link rel='stylesheet' type='text/css' href='"); 353 html("<link rel='stylesheet' type='text/css' href='");
354 html_attr(cgit_css); 354 html_attr(cgit_css);
355 html("'/>\n"); 355 html("'/>\n");
356 html("</head>\n"); 356 html("</head>\n");
357 html("<body>\n"); 357 html("<body>\n");
358} 358}
359 359
360void cgit_print_docend() 360void cgit_print_docend()
361{ 361{
362 html("</td></tr></table>"); 362 html("</td></tr></table>");
363 html("</body>\n</html>\n"); 363 html("</body>\n</html>\n");
364} 364}
365 365
366void cgit_print_pageheader(char *title, int show_search) 366void cgit_print_pageheader(char *title, int show_search)
367{ 367{
368 html("<table id='layout'>"); 368 html("<table id='layout'>");
369 html("<tr><td id='header'><a href='"); 369 html("<tr><td id='header'><a href='");
370 html_attr(cgit_rooturl()); 370 html_attr(cgit_rooturl());
371 html("'>"); 371 html("'>");
372 html_txt(cgit_root_title); 372 html_txt(cgit_root_title);
373 html("</a></td><td id='logo'>"); 373 html("</a></td><td id='logo'>");
374 html("<a href='"); 374 html("<a href='");
375 html_attr(cgit_logo_link); 375 html_attr(cgit_logo_link);
376 htmlf("'><img src='%s' alt='logo'/></a>", cgit_logo); 376 htmlf("'><img src='%s' alt='logo'/></a>", cgit_logo);
377 html("</td></tr>"); 377 html("</td></tr>");
378 html("<tr><td id='crumb'>"); 378 html("<tr><td id='crumb'>");
379 if (cgit_query_repo) { 379 if (cgit_query_repo) {
380 html_txt(cgit_repo->name); 380 html_txt(cgit_repo->name);
381 html(" ("); 381 html(" (");
382 html_txt(cgit_query_head); 382 html_txt(cgit_query_head);
383 html(") : &nbsp;"); 383 html(") : &nbsp;");
384 reporevlink(NULL, "summary", NULL, NULL, cgit_query_head, 384 reporevlink(NULL, "summary", NULL, NULL, cgit_query_head,
385 NULL, NULL); 385 NULL, NULL);
386 html(" "); 386 html(" ");
387 cgit_log_link("log", NULL, NULL, cgit_query_head, 387 cgit_log_link("log", NULL, NULL, cgit_query_head,
388 cgit_query_sha1, cgit_query_path, 0); 388 cgit_query_sha1, cgit_query_path, 0);
389 html(" "); 389 html(" ");
390 cgit_tree_link("tree", NULL, NULL, cgit_query_head, 390 cgit_tree_link("tree", NULL, NULL, cgit_query_head,
391 cgit_query_sha1, NULL); 391 cgit_query_sha1, NULL);
392 html(" "); 392 html(" ");
393 cgit_commit_link("commit", NULL, NULL, cgit_query_head, 393 cgit_commit_link("commit", NULL, NULL, cgit_query_head,
394 cgit_query_sha1); 394 cgit_query_sha1);
395 html(" "); 395 html(" ");
396 cgit_diff_link("diff", NULL, NULL, cgit_query_head, 396 cgit_diff_link("diff", NULL, NULL, cgit_query_head,
397 cgit_query_sha1, cgit_query_sha2, 397 cgit_query_sha1, cgit_query_sha2,
398 cgit_query_path); 398 cgit_query_path);
399 } else { 399 } else {
400 html_txt("Index of repositories"); 400 html_txt("Index of repositories");
401 } 401 }
402 html("</td>"); 402 html("</td>");
403 html("<td id='search'>"); 403 html("<td id='search'>");
404 if (show_search) { 404 if (show_search) {
405 html("<form method='get' action='"); 405 html("<form method='get' action='");
406 html_attr(cgit_currurl()); 406 html_attr(cgit_currurl());
407 html("'>"); 407 html("'>");
408 if (!cgit_virtual_root) { 408 if (!cgit_virtual_root) {
409 if (cgit_query_repo) 409 if (cgit_query_repo)
410 html_hidden("r", cgit_query_repo); 410 html_hidden("r", cgit_query_repo);
411 if (cgit_query_page) 411 if (cgit_query_page)
412 html_hidden("p", cgit_query_page); 412 html_hidden("p", cgit_query_page);
413 } 413 }
414 if (cgit_query_head) 414 if (cgit_query_head)
415 html_hidden("h", cgit_query_head); 415 html_hidden("h", cgit_query_head);
416 if (cgit_query_sha1) 416 if (cgit_query_sha1)
417 html_hidden("id", cgit_query_sha1); 417 html_hidden("id", cgit_query_sha1);
418 if (cgit_query_sha2) 418 if (cgit_query_sha2)
419 html_hidden("id2", cgit_query_sha2); 419 html_hidden("id2", cgit_query_sha2);
420 html("<input type='text' name='q' value='"); 420 html("<select name='qt'>");
421 html_option("grep", "log msg", cgit_query_grep);
422 html_option("author", "author", cgit_query_grep);
423 html_option("committer", "committer", cgit_query_grep);
424 html("</select>");
425 html("<input class='txt' type='text' name='q' value='");
421 html_attr(cgit_query_search); 426 html_attr(cgit_query_search);
422 html("'/></form>"); 427 html("'/><input class='btn' type='submit' value='...'/></form>");
423 } 428 }
424 html("</td></tr>"); 429 html("</td></tr>");
425 html("<tr><td id='content' colspan='2'>"); 430 html("<tr><td id='content' colspan='2'>");
426} 431}
427 432
428void cgit_print_snapshot_start(const char *mimetype, const char *filename, 433void cgit_print_snapshot_start(const char *mimetype, const char *filename,
429 struct cacheitem *item) 434 struct cacheitem *item)
430{ 435{
431 htmlf("Content-Type: %s\n", mimetype); 436 htmlf("Content-Type: %s\n", mimetype);
432 htmlf("Content-Disposition: inline; filename=\"%s\"\n", filename); 437 htmlf("Content-Disposition: inline; filename=\"%s\"\n", filename);
433 htmlf("Last-Modified: %s\n", http_date(item->st.st_mtime)); 438 htmlf("Last-Modified: %s\n", http_date(item->st.st_mtime));
434 htmlf("Expires: %s\n", http_date(item->st.st_mtime + 439 htmlf("Expires: %s\n", http_date(item->st.st_mtime +
435 ttl_seconds(item->ttl))); 440 ttl_seconds(item->ttl)));
436 html("\n"); 441 html("\n");
437} 442}
438 443
439/* vim:set sw=8: */ 444/* vim:set sw=8: */