summaryrefslogtreecommitdiffabout
path: root/ui-log.c
authorLars Hjemli <hjemli@gmail.com>2006-12-15 23:19:56 (UTC)
committer Lars Hjemli <hjemli@gmail.com>2006-12-15 23:19:56 (UTC)
commit9a8f88658d51aeb86a79ac1121de13562ad2601f (patch) (unidiff)
tree8724d9477efe887e0b851b567e74554e75761cc7 /ui-log.c
parent2101e26fd68f816e77de62b93df4c32fd1110d0c (diff)
downloadcgit-9a8f88658d51aeb86a79ac1121de13562ad2601f.zip
cgit-9a8f88658d51aeb86a79ac1121de13562ad2601f.tar.gz
cgit-9a8f88658d51aeb86a79ac1121de13562ad2601f.tar.bz2
Add ui-commit.c + misc ui cleanups
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Diffstat (limited to 'ui-log.c') (more/less context) (ignore whitespace changes)
-rw-r--r--ui-log.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/ui-log.c b/ui-log.c
index 31331ef..c52af79 100644
--- a/ui-log.c
+++ b/ui-log.c
@@ -1,92 +1,87 @@
1/* ui-log.c: functions for log output 1/* ui-log.c: functions for log output
2 * 2 *
3 * Copyright (C) 2006 Lars Hjemli 3 * Copyright (C) 2006 Lars Hjemli
4 * 4 *
5 * Licensed under GNU General Public License v2 5 * Licensed under GNU General Public License v2
6 * (see COPYING for full license text) 6 * (see COPYING for full license text)
7 */ 7 */
8 8
9#include "cgit.h" 9#include "cgit.h"
10 10
11void print_commit(struct commit *commit) 11void print_commit(struct commit *commit)
12{ 12{
13 char buf[32]; 13 char buf[32];
14 struct commitinfo *info; 14 struct commitinfo *info;
15 struct tm *time; 15 struct tm *time;
16 16
17 info = cgit_parse_commit(commit); 17 info = cgit_parse_commit(commit);
18 time = gmtime(&commit->date); 18 time = gmtime(&commit->date);
19 html("<tr><td>"); 19 html("<tr><td>");
20 strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", time); 20 strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", time);
21 html_txt(buf); 21 html_txt(buf);
22 html("</td><td>"); 22 html("</td><td>");
23 char *qry = fmt("id=%s", sha1_to_hex(commit->object.sha1)); 23 char *qry = fmt("id=%s", sha1_to_hex(commit->object.sha1));
24 char *url = cgit_pageurl(cgit_query_repo, "view", qry); 24 char *url = cgit_pageurl(cgit_query_repo, "commit", qry);
25 html_link_open(url, NULL, NULL); 25 html_link_open(url, NULL, NULL);
26 html_txt(info->subject); 26 html_txt(info->subject);
27 html_link_close(); 27 html_link_close();
28 html("</td><td>"); 28 html("</td><td>");
29 html_txt(info->author); 29 html_txt(info->author);
30 html("</td><td><a href='");
31 html_attr(cgit_pageurl(cgit_query_repo, "tree",
32 fmt("id=%s",
33 sha1_to_hex(commit->tree->object.sha1))));
34 html("'>tree</a>");
35 html("</td></tr>\n"); 30 html("</td></tr>\n");
36 free(info->author); 31 free(info->author);
37 free(info->committer); 32 free(info->committer);
38 free(info->subject); 33 free(info->subject);
39 free(info); 34 free(info);
40} 35}
41 36
42 37
43void cgit_print_log(const char *tip, int ofs, int cnt) 38void cgit_print_log(const char *tip, int ofs, int cnt)
44{ 39{
45 struct rev_info rev; 40 struct rev_info rev;
46 struct commit *commit; 41 struct commit *commit;
47 const char *argv[2] = {NULL, tip}; 42 const char *argv[2] = {NULL, tip};
48 int i; 43 int i;
49 44
50 init_revisions(&rev, NULL); 45 init_revisions(&rev, NULL);
51 rev.abbrev = DEFAULT_ABBREV; 46 rev.abbrev = DEFAULT_ABBREV;
52 rev.commit_format = CMIT_FMT_DEFAULT; 47 rev.commit_format = CMIT_FMT_DEFAULT;
53 rev.verbose_header = 1; 48 rev.verbose_header = 1;
54 rev.show_root_diff = 0; 49 rev.show_root_diff = 0;
55 setup_revisions(2, argv, &rev, NULL); 50 setup_revisions(2, argv, &rev, NULL);
56 prepare_revision_walk(&rev); 51 prepare_revision_walk(&rev);
57 52
58 html("<h2>Log</h2>"); 53 html("<h2>Log</h2>");
59 html("<table class='list'>"); 54 html("<table class='list log'>");
60 html("<tr><th>Date</th><th>Message</th><th>Author</th><th>Link</th></tr>\n"); 55 html("<tr><th class='left'>Date</th><th class='left'>Message</th><th class='left'>Author</th></tr>\n");
61 56
62 if (ofs<0) 57 if (ofs<0)
63 ofs = 0; 58 ofs = 0;
64 59
65 for (i = 0; i < ofs && (commit = get_revision(&rev)) != NULL; i++) { 60 for (i = 0; i < ofs && (commit = get_revision(&rev)) != NULL; i++) {
66 free(commit->buffer); 61 free(commit->buffer);
67 commit->buffer = NULL; 62 commit->buffer = NULL;
68 free_commit_list(commit->parents); 63 free_commit_list(commit->parents);
69 commit->parents = NULL; 64 commit->parents = NULL;
70 } 65 }
71 66
72 for (i = 0; i < cnt && (commit = get_revision(&rev)) != NULL; i++) { 67 for (i = 0; i < cnt && (commit = get_revision(&rev)) != NULL; i++) {
73 print_commit(commit); 68 print_commit(commit);
74 free(commit->buffer); 69 free(commit->buffer);
75 commit->buffer = NULL; 70 commit->buffer = NULL;
76 free_commit_list(commit->parents); 71 free_commit_list(commit->parents);
77 commit->parents = NULL; 72 commit->parents = NULL;
78 } 73 }
79 html("</table>\n"); 74 html("</table>\n");
80 75
81 html("<div class='pager'>"); 76 html("<div class='pager'>");
82 if (ofs > 0) { 77 if (ofs > 0) {
83 html("&nbsp;<a href='"); 78 html("&nbsp;<a href='");
84 html(cgit_pageurl(cgit_query_repo, cgit_query_page, 79 html(cgit_pageurl(cgit_query_repo, cgit_query_page,
85 fmt("h=%s&ofs=%d", tip, ofs-cnt))); 80 fmt("h=%s&ofs=%d", tip, ofs-cnt)));
86 html("'>[prev]</a>&nbsp;"); 81 html("'>[prev]</a>&nbsp;");
87 } 82 }
88 83
89 if ((commit = get_revision(&rev)) != NULL) { 84 if ((commit = get_revision(&rev)) != NULL) {
90 html("&nbsp;<a href='"); 85 html("&nbsp;<a href='");
91 html(cgit_pageurl(cgit_query_repo, "log", 86 html(cgit_pageurl(cgit_query_repo, "log",
92 fmt("h=%s&ofs=%d", tip, ofs+cnt))); 87 fmt("h=%s&ofs=%d", tip, ofs+cnt)));