author | Lars Hjemli <hjemli@gmail.com> | 2008-04-14 20:13:38 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2008-04-14 20:13:38 (UTC) |
commit | 5764fe95469f65fdee285467f0f87d188fc1a780 (patch) (unidiff) | |
tree | 0dc9e9545bd8b43fbf1a571f3ef239ff3aea771c | |
parent | 35d19bbb641aa56a21fb2c238994716c272e154f (diff) | |
download | cgit-5764fe95469f65fdee285467f0f87d188fc1a780.zip cgit-5764fe95469f65fdee285467f0f87d188fc1a780.tar.gz cgit-5764fe95469f65fdee285467f0f87d188fc1a780.tar.bz2 |
Make branches, tags and log play better together in the summary view
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
-rw-r--r-- | ui-log.c | 42 | ||||
-rw-r--r-- | ui-refs.c | 25 | ||||
-rw-r--r-- | ui-summary.c | 10 |
3 files changed, 43 insertions, 34 deletions
@@ -38,38 +38,39 @@ void print_commit(struct commit *commit) | |||
38 | info = cgit_parse_commit(commit); | 38 | info = cgit_parse_commit(commit); |
39 | html("<tr><td>"); | 39 | html("<tr><td>"); |
40 | cgit_print_age(commit->date, TM_WEEK * 2, FMT_SHORTDATE); | 40 | cgit_print_age(commit->date, TM_WEEK * 2, FMT_SHORTDATE); |
41 | html("</td><td>"); | 41 | html("</td><td>"); |
42 | cgit_commit_link(info->subject, NULL, NULL, ctx.qry.head, | 42 | cgit_commit_link(info->subject, NULL, NULL, ctx.qry.head, |
43 | sha1_to_hex(commit->object.sha1)); | 43 | sha1_to_hex(commit->object.sha1)); |
44 | html("</td><td>"); | ||
45 | html_txt(info->author); | ||
44 | if (ctx.repo->enable_log_filecount) { | 46 | if (ctx.repo->enable_log_filecount) { |
45 | files = 0; | 47 | files = 0; |
46 | add_lines = 0; | 48 | add_lines = 0; |
47 | rem_lines = 0; | 49 | rem_lines = 0; |
48 | cgit_diff_commit(commit, inspect_files); | 50 | cgit_diff_commit(commit, inspect_files); |
49 | html("</td><td class='right'>"); | 51 | html("</td><td>"); |
50 | htmlf("%d", files); | 52 | htmlf("%d", files); |
51 | if (ctx.repo->enable_log_linecount) { | 53 | if (ctx.repo->enable_log_linecount) { |
52 | html("</td><td class='right'>"); | 54 | html("</td><td>"); |
53 | htmlf("-%d/+%d", rem_lines, add_lines); | 55 | htmlf("-%d/+%d", rem_lines, add_lines); |
54 | } | 56 | } |
55 | } | 57 | } |
56 | html("</td><td>"); | ||
57 | html_txt(info->author); | ||
58 | html("</td></tr>\n"); | 58 | html("</td></tr>\n"); |
59 | cgit_free_commitinfo(info); | 59 | cgit_free_commitinfo(info); |
60 | } | 60 | } |
61 | 61 | ||
62 | 62 | ||
63 | void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern, char *path, int pager) | 63 | void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern, |
64 | char *path, int pager) | ||
64 | { | 65 | { |
65 | struct rev_info rev; | 66 | struct rev_info rev; |
66 | struct commit *commit; | 67 | struct commit *commit; |
67 | const char *argv[] = {NULL, tip, NULL, NULL, NULL}; | 68 | const char *argv[] = {NULL, tip, NULL, NULL, NULL}; |
68 | int argc = 2; | 69 | int argc = 2; |
69 | int i; | 70 | int i, columns = 3; |
70 | 71 | ||
71 | if (!tip) | 72 | if (!tip) |
72 | argv[1] = ctx.qry.head; | 73 | argv[1] = ctx.qry.head; |
73 | 74 | ||
74 | if (grep && pattern && (!strcmp(grep, "grep") || | 75 | if (grep && pattern && (!strcmp(grep, "grep") || |
75 | !strcmp(grep, "author") || | 76 | !strcmp(grep, "author") || |
@@ -89,22 +90,27 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern | |||
89 | if (rev.grep_filter) { | 90 | if (rev.grep_filter) { |
90 | rev.grep_filter->regflags |= REG_ICASE; | 91 | rev.grep_filter->regflags |= REG_ICASE; |
91 | compile_grep_patterns(rev.grep_filter); | 92 | compile_grep_patterns(rev.grep_filter); |
92 | } | 93 | } |
93 | prepare_revision_walk(&rev); | 94 | prepare_revision_walk(&rev); |
94 | 95 | ||
95 | html("<table summary='log' class='list nowrap'>"); | 96 | if (pager) |
96 | html("<tr class='nohover'><th class='left'>Age</th>" | 97 | html("<table class='list nowrap'>"); |
97 | "<th class='left'>Message</th>"); | ||
98 | 98 | ||
99 | html("<tr class='nohover'><th class='left'>Age</th>" | ||
100 | "<th class='left'>Commit message</th>" | ||
101 | "<th class='left'>Author</th>"); | ||
99 | if (ctx.repo->enable_log_filecount) { | 102 | if (ctx.repo->enable_log_filecount) { |
100 | html("<th class='right'>Files</th>"); | 103 | html("<th class='left'>Files</th>"); |
101 | if (ctx.repo->enable_log_linecount) | 104 | columns++; |
102 | html("<th class='right'>Lines</th>"); | 105 | if (ctx.repo->enable_log_linecount) { |
106 | html("<th class='left'>Lines</th>"); | ||
107 | columns++; | ||
108 | } | ||
103 | } | 109 | } |
104 | html("<th class='left'>Author</th></tr>\n"); | 110 | html("</tr>\n"); |
105 | 111 | ||
106 | if (ofs<0) | 112 | if (ofs<0) |
107 | ofs = 0; | 113 | ofs = 0; |
108 | 114 | ||
109 | for (i = 0; i < ofs && (commit = get_revision(&rev)) != NULL; i++) { | 115 | for (i = 0; i < ofs && (commit = get_revision(&rev)) != NULL; i++) { |
110 | free(commit->buffer); | 116 | free(commit->buffer); |
@@ -117,16 +123,15 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern | |||
117 | print_commit(commit); | 123 | print_commit(commit); |
118 | free(commit->buffer); | 124 | free(commit->buffer); |
119 | commit->buffer = NULL; | 125 | commit->buffer = NULL; |
120 | free_commit_list(commit->parents); | 126 | free_commit_list(commit->parents); |
121 | commit->parents = NULL; | 127 | commit->parents = NULL; |
122 | } | 128 | } |
123 | html("</table>\n"); | ||
124 | |||
125 | if (pager) { | 129 | if (pager) { |
126 | html("<div class='pager'>"); | 130 | htmlf("</table><div class='pager'>", |
131 | columns); | ||
127 | if (ofs > 0) { | 132 | if (ofs > 0) { |
128 | cgit_log_link("[prev]", NULL, NULL, ctx.qry.head, | 133 | cgit_log_link("[prev]", NULL, NULL, ctx.qry.head, |
129 | ctx.qry.sha1, ctx.qry.path, | 134 | ctx.qry.sha1, ctx.qry.path, |
130 | ofs - cnt, ctx.qry.grep, | 135 | ofs - cnt, ctx.qry.grep, |
131 | ctx.qry.search); | 136 | ctx.qry.search); |
132 | html(" "); | 137 | html(" "); |
@@ -135,8 +140,13 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern | |||
135 | cgit_log_link("[next]", NULL, NULL, ctx.qry.head, | 140 | cgit_log_link("[next]", NULL, NULL, ctx.qry.head, |
136 | ctx.qry.sha1, ctx.qry.path, | 141 | ctx.qry.sha1, ctx.qry.path, |
137 | ofs + cnt, ctx.qry.grep, | 142 | ofs + cnt, ctx.qry.grep, |
138 | ctx.qry.search); | 143 | ctx.qry.search); |
139 | } | 144 | } |
140 | html("</div>"); | 145 | html("</div>"); |
146 | } else if ((commit = get_revision(&rev)) != NULL) { | ||
147 | html("<tr class='nohover'><td colspan='3'>"); | ||
148 | cgit_log_link("[...]", NULL, NULL, ctx.qry.head, NULL, NULL, 0, | ||
149 | NULL, NULL); | ||
150 | html("</td></tr>\n"); | ||
141 | } | 151 | } |
142 | } | 152 | } |
@@ -59,31 +59,31 @@ static int print_branch(struct refinfo *ref) | |||
59 | return 1; | 59 | return 1; |
60 | html("<tr><td>"); | 60 | html("<tr><td>"); |
61 | cgit_log_link(name, NULL, NULL, name, NULL, NULL, 0, NULL, NULL); | 61 | cgit_log_link(name, NULL, NULL, name, NULL, NULL, 0, NULL, NULL); |
62 | html("</td><td>"); | 62 | html("</td><td>"); |
63 | 63 | ||
64 | if (ref->object->type == OBJ_COMMIT) { | 64 | if (ref->object->type == OBJ_COMMIT) { |
65 | cgit_print_age(info->commit->date, -1, NULL); | 65 | cgit_commit_link(info->subject, NULL, NULL, name, NULL); |
66 | html("</td><td>"); | 66 | html("</td><td>"); |
67 | html_txt(info->author); | 67 | html_txt(info->author); |
68 | html("</td><td>"); | 68 | html("</td><td colspan='2'>"); |
69 | cgit_commit_link(info->subject, NULL, NULL, name, NULL); | 69 | cgit_print_age(info->commit->date, -1, NULL); |
70 | } else { | 70 | } else { |
71 | html("</td><td></td><td>"); | 71 | html("</td><td></td><td>"); |
72 | cgit_object_link(ref->object); | 72 | cgit_object_link(ref->object); |
73 | } | 73 | } |
74 | html("</td></tr>\n"); | 74 | html("</td></tr>\n"); |
75 | return 0; | 75 | return 0; |
76 | } | 76 | } |
77 | 77 | ||
78 | static void print_tag_header() | 78 | static void print_tag_header() |
79 | { | 79 | { |
80 | html("<tr class='nohover'><th class='left'>Tag</th>" | 80 | html("<tr class='nohover'><th class='left'>Tag</th>" |
81 | "<th class='left'>Age</th>" | 81 | "<th class='left'>Reference</th>" |
82 | "<th class='left'>Author</th>" | 82 | "<th class='left'>Author</th>" |
83 | "<th class='left'>Reference</th></tr>\n"); | 83 | "<th class='left' colspan='2'>Age</th></tr>\n"); |
84 | header = 1; | 84 | header = 1; |
85 | } | 85 | } |
86 | 86 | ||
87 | static int print_tag(struct refinfo *ref) | 87 | static int print_tag(struct refinfo *ref) |
88 | { | 88 | { |
89 | struct tag *tag; | 89 | struct tag *tag; |
@@ -99,26 +99,26 @@ static int print_tag(struct refinfo *ref) | |||
99 | url = cgit_pageurl(ctx.qry.repo, "tag", | 99 | url = cgit_pageurl(ctx.qry.repo, "tag", |
100 | fmt("id=%s", name)); | 100 | fmt("id=%s", name)); |
101 | html_link_open(url, NULL, NULL); | 101 | html_link_open(url, NULL, NULL); |
102 | html_txt(name); | 102 | html_txt(name); |
103 | html_link_close(); | 103 | html_link_close(); |
104 | html("</td><td>"); | 104 | html("</td><td>"); |
105 | if (info->tagger_date > 0) | 105 | cgit_object_link(tag->tagged); |
106 | cgit_print_age(info->tagger_date, -1, NULL); | ||
107 | html("</td><td>"); | 106 | html("</td><td>"); |
108 | if (info->tagger) | 107 | if (info->tagger) |
109 | html(info->tagger); | 108 | html(info->tagger); |
110 | html("</td><td>"); | 109 | html("</td><td colspan='2'>"); |
111 | cgit_object_link(tag->tagged); | 110 | if (info->tagger_date > 0) |
111 | cgit_print_age(info->tagger_date, -1, NULL); | ||
112 | html("</td></tr>\n"); | 112 | html("</td></tr>\n"); |
113 | } else { | 113 | } else { |
114 | if (!header) | 114 | if (!header) |
115 | print_tag_header(); | 115 | print_tag_header(); |
116 | html("<tr><td>"); | 116 | html("<tr><td>"); |
117 | html_txt(name); | 117 | html_txt(name); |
118 | html("</td><td colspan='2'/><td>"); | 118 | html("</td><td>"); |
119 | cgit_object_link(ref->object); | 119 | cgit_object_link(ref->object); |
120 | html("</td></tr>\n"); | 120 | html("</td></tr>\n"); |
121 | } | 121 | } |
122 | return 0; | 122 | return 0; |
123 | } | 123 | } |
124 | 124 | ||
@@ -132,15 +132,15 @@ static void print_refs_link(char *path) | |||
132 | void cgit_print_branches(int maxcount) | 132 | void cgit_print_branches(int maxcount) |
133 | { | 133 | { |
134 | struct reflist list; | 134 | struct reflist list; |
135 | int i; | 135 | int i; |
136 | 136 | ||
137 | html("<tr class='nohover'><th class='left'>Branch</th>" | 137 | html("<tr class='nohover'><th class='left'>Branch</th>" |
138 | "<th class='left'>Idle</th>" | 138 | "<th class='left'>Commit message</th>" |
139 | "<th class='left'>Author</th>" | 139 | "<th class='left'>Author</th>" |
140 | "<th class='left'>Head commit</th></tr>\n"); | 140 | "<th class='left' colspan='2'>Age</th></tr>\n"); |
141 | 141 | ||
142 | list.refs = NULL; | 142 | list.refs = NULL; |
143 | list.alloc = list.count = 0; | 143 | list.alloc = list.count = 0; |
144 | for_each_branch_ref(cgit_refs_cb, &list); | 144 | for_each_branch_ref(cgit_refs_cb, &list); |
145 | 145 | ||
146 | if (maxcount == 0 || maxcount > list.count) | 146 | if (maxcount == 0 || maxcount > list.count) |
@@ -193,9 +193,8 @@ void cgit_print_refs() | |||
193 | cgit_print_tags(0); | 193 | cgit_print_tags(0); |
194 | else { | 194 | else { |
195 | cgit_print_branches(0); | 195 | cgit_print_branches(0); |
196 | html("<tr class='nohover'><td colspan='4'> </td></tr>"); | 196 | html("<tr class='nohover'><td colspan='4'> </td></tr>"); |
197 | cgit_print_tags(0); | 197 | cgit_print_tags(0); |
198 | } | 198 | } |
199 | |||
200 | html("</table>"); | 199 | html("</table>"); |
201 | } | 200 | } |
diff --git a/ui-summary.c b/ui-summary.c index 0b66b52..318148a 100644 --- a/ui-summary.c +++ b/ui-summary.c | |||
@@ -15,17 +15,17 @@ void cgit_print_summary() | |||
15 | { | 15 | { |
16 | if (ctx.repo->readme) { | 16 | if (ctx.repo->readme) { |
17 | html("<div id='summary'>"); | 17 | html("<div id='summary'>"); |
18 | html_include(ctx.repo->readme); | 18 | html_include(ctx.repo->readme); |
19 | html("</div>"); | 19 | html("</div>"); |
20 | } | 20 | } |
21 | if (ctx.cfg.summary_log > 0) | ||
22 | cgit_print_log(ctx.qry.head, 0, ctx.cfg.summary_log, NULL, | ||
23 | NULL, NULL, 0); | ||
24 | html("<table summary='repository info' class='list nowrap'>"); | 21 | html("<table summary='repository info' class='list nowrap'>"); |
25 | if (ctx.cfg.summary_log > 0) | ||
26 | html("<tr class='nohover'><td colspan='4'> </td></tr>"); | ||
27 | cgit_print_branches(ctx.cfg.summary_branches); | 22 | cgit_print_branches(ctx.cfg.summary_branches); |
28 | html("<tr class='nohover'><td colspan='4'> </td></tr>"); | 23 | html("<tr class='nohover'><td colspan='4'> </td></tr>"); |
29 | cgit_print_tags(ctx.cfg.summary_tags); | 24 | cgit_print_tags(ctx.cfg.summary_tags); |
25 | if (ctx.cfg.summary_log > 0) { | ||
26 | html("<tr class='nohover'><td colspan='4'> </td></tr>"); | ||
27 | cgit_print_log(ctx.qry.head, 0, ctx.cfg.summary_log, NULL, | ||
28 | NULL, NULL, 0); | ||
29 | } | ||
30 | html("</table>"); | 30 | html("</table>"); |
31 | } | 31 | } |