summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--cgit.h2
-rw-r--r--ui-shared.c6
-rw-r--r--ui-summary.c13
3 files changed, 21 insertions, 0 deletions
diff --git a/cgit.h b/cgit.h
index d9a15f4..f8f0316 100644
--- a/cgit.h
+++ b/cgit.h
@@ -191,84 +191,86 @@ extern int cgit_diff_files(const unsigned char *old_sha1,
191 linediff_fn fn); 191 linediff_fn fn);
192 192
193extern void cgit_diff_tree(const unsigned char *old_sha1, 193extern void cgit_diff_tree(const unsigned char *old_sha1,
194 const unsigned char *new_sha1, 194 const unsigned char *new_sha1,
195 filepair_fn fn, const char *prefix); 195 filepair_fn fn, const char *prefix);
196 196
197extern void cgit_diff_commit(struct commit *commit, filepair_fn fn); 197extern void cgit_diff_commit(struct commit *commit, filepair_fn fn);
198 198
199extern char *fmt(const char *format,...); 199extern char *fmt(const char *format,...);
200 200
201extern void html(const char *txt); 201extern void html(const char *txt);
202extern void htmlf(const char *format,...); 202extern void htmlf(const char *format,...);
203extern void html_txt(char *txt); 203extern void html_txt(char *txt);
204extern void html_ntxt(int len, char *txt); 204extern void html_ntxt(int len, char *txt);
205extern void html_attr(char *txt); 205extern void html_attr(char *txt);
206extern void html_hidden(char *name, char *value); 206extern void html_hidden(char *name, char *value);
207extern void html_link_open(char *url, char *title, char *class); 207extern void html_link_open(char *url, char *title, char *class);
208extern void html_link_close(void); 208extern void html_link_close(void);
209extern void html_filemode(unsigned short mode); 209extern void html_filemode(unsigned short mode);
210extern int html_include(const char *filename); 210extern int html_include(const char *filename);
211 211
212extern int cgit_read_config(const char *filename, configfn fn); 212extern int cgit_read_config(const char *filename, configfn fn);
213extern int cgit_parse_query(char *txt, configfn fn); 213extern int cgit_parse_query(char *txt, configfn fn);
214extern struct commitinfo *cgit_parse_commit(struct commit *commit); 214extern struct commitinfo *cgit_parse_commit(struct commit *commit);
215extern struct taginfo *cgit_parse_tag(struct tag *tag); 215extern struct taginfo *cgit_parse_tag(struct tag *tag);
216extern void cgit_parse_url(const char *url); 216extern void cgit_parse_url(const char *url);
217 217
218extern char *cache_safe_filename(const char *unsafe); 218extern char *cache_safe_filename(const char *unsafe);
219extern int cache_lock(struct cacheitem *item); 219extern int cache_lock(struct cacheitem *item);
220extern int cache_unlock(struct cacheitem *item); 220extern int cache_unlock(struct cacheitem *item);
221extern int cache_cancel_lock(struct cacheitem *item); 221extern int cache_cancel_lock(struct cacheitem *item);
222extern int cache_exist(struct cacheitem *item); 222extern int cache_exist(struct cacheitem *item);
223extern int cache_expired(struct cacheitem *item); 223extern int cache_expired(struct cacheitem *item);
224 224
225extern char *cgit_repourl(const char *reponame); 225extern char *cgit_repourl(const char *reponame);
226extern char *cgit_fileurl(const char *reponame, const char *pagename, 226extern char *cgit_fileurl(const char *reponame, const char *pagename,
227 const char *filename, const char *query); 227 const char *filename, const char *query);
228extern char *cgit_pageurl(const char *reponame, const char *pagename, 228extern char *cgit_pageurl(const char *reponame, const char *pagename,
229 const char *query); 229 const char *query);
230 230
231extern const char *cgit_repobasename(const char *reponame); 231extern const char *cgit_repobasename(const char *reponame);
232 232
233extern void cgit_tree_link(char *name, char *title, char *class, char *head, 233extern void cgit_tree_link(char *name, char *title, char *class, char *head,
234 char *rev, char *path); 234 char *rev, char *path);
235extern void cgit_log_link(char *name, char *title, char *class, char *head, 235extern void cgit_log_link(char *name, char *title, char *class, char *head,
236 char *rev, char *path, int ofs); 236 char *rev, char *path, int ofs);
237extern void cgit_commit_link(char *name, char *title, char *class, char *head, 237extern void cgit_commit_link(char *name, char *title, char *class, char *head,
238 char *rev); 238 char *rev);
239extern void cgit_refs_link(char *name, char *title, char *class, char *head,
240 char *rev, char *path);
239extern void cgit_snapshot_link(char *name, char *title, char *class, 241extern void cgit_snapshot_link(char *name, char *title, char *class,
240 char *head, char *rev, char *archivename); 242 char *head, char *rev, char *archivename);
241extern void cgit_diff_link(char *name, char *title, char *class, char *head, 243extern void cgit_diff_link(char *name, char *title, char *class, char *head,
242 char *new_rev, char *old_rev, char *path); 244 char *new_rev, char *old_rev, char *path);
243 245
244extern void cgit_object_link(struct object *obj); 246extern void cgit_object_link(struct object *obj);
245 247
246extern void cgit_print_error(char *msg); 248extern void cgit_print_error(char *msg);
247extern void cgit_print_date(time_t secs, char *format); 249extern void cgit_print_date(time_t secs, char *format);
248extern void cgit_print_age(time_t t, time_t max_relative, char *format); 250extern void cgit_print_age(time_t t, time_t max_relative, char *format);
249extern void cgit_print_docstart(char *title, struct cacheitem *item); 251extern void cgit_print_docstart(char *title, struct cacheitem *item);
250extern void cgit_print_docend(); 252extern void cgit_print_docend();
251extern void cgit_print_pageheader(char *title, int show_search); 253extern void cgit_print_pageheader(char *title, int show_search);
252extern void cgit_print_snapshot_start(const char *mimetype, 254extern void cgit_print_snapshot_start(const char *mimetype,
253 const char *filename, 255 const char *filename,
254 struct cacheitem *item); 256 struct cacheitem *item);
255extern void cgit_print_branches(int maxcount); 257extern void cgit_print_branches(int maxcount);
256extern void cgit_print_tags(int maxcount); 258extern void cgit_print_tags(int maxcount);
257 259
258extern void cgit_print_repolist(struct cacheitem *item); 260extern void cgit_print_repolist(struct cacheitem *item);
259extern void cgit_print_summary(); 261extern void cgit_print_summary();
260extern void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *path, int pager); 262extern void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *path, int pager);
261extern void cgit_print_blob(struct cacheitem *item, const char *hex, char *path); 263extern void cgit_print_blob(struct cacheitem *item, const char *hex, char *path);
262extern void cgit_print_tree(const char *rev, char *path); 264extern void cgit_print_tree(const char *rev, char *path);
263extern void cgit_print_commit(char *hex); 265extern void cgit_print_commit(char *hex);
264extern void cgit_print_refs(); 266extern void cgit_print_refs();
265extern void cgit_print_tag(char *revname); 267extern void cgit_print_tag(char *revname);
266extern void cgit_print_diff(const char *new_hex, const char *old_hex, const char *prefix); 268extern void cgit_print_diff(const char *new_hex, const char *old_hex, const char *prefix);
267extern void cgit_print_snapshot(struct cacheitem *item, const char *head, 269extern void cgit_print_snapshot(struct cacheitem *item, const char *head,
268 const char *hex, const char *prefix, 270 const char *hex, const char *prefix,
269 const char *filename, int snapshot); 271 const char *filename, int snapshot);
270extern void cgit_print_snapshot_links(const char *repo, const char *head, 272extern void cgit_print_snapshot_links(const char *repo, const char *head,
271 const char *hex, int snapshots); 273 const char *hex, int snapshots);
272extern int cgit_parse_snapshots_mask(const char *str); 274extern int cgit_parse_snapshots_mask(const char *str);
273 275
274#endif /* CGIT_H */ 276#endif /* CGIT_H */
diff --git a/ui-shared.c b/ui-shared.c
index 5c5bcf3..e4bb98f 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -182,96 +182,102 @@ static void reporevlink(char *page, char *name, char *title, char *class,
182 html("id="); 182 html("id=");
183 html_attr(rev); 183 html_attr(rev);
184 } 184 }
185 html("'>"); 185 html("'>");
186 html_txt(name); 186 html_txt(name);
187 html("</a>"); 187 html("</a>");
188} 188}
189 189
190void cgit_tree_link(char *name, char *title, char *class, char *head, 190void cgit_tree_link(char *name, char *title, char *class, char *head,
191 char *rev, char *path) 191 char *rev, char *path)
192{ 192{
193 reporevlink("tree", name, title, class, head, rev, path); 193 reporevlink("tree", name, title, class, head, rev, path);
194} 194}
195 195
196void cgit_log_link(char *name, char *title, char *class, char *head, 196void cgit_log_link(char *name, char *title, char *class, char *head,
197 char *rev, char *path, int ofs) 197 char *rev, char *path, int ofs)
198{ 198{
199 char *delim; 199 char *delim;
200 200
201 delim = repolink(title, class, "log", head, path); 201 delim = repolink(title, class, "log", head, path);
202 if (rev && strcmp(rev, cgit_query_head)) { 202 if (rev && strcmp(rev, cgit_query_head)) {
203 html(delim); 203 html(delim);
204 html("id="); 204 html("id=");
205 html_attr(rev); 205 html_attr(rev);
206 delim = "&"; 206 delim = "&";
207 } 207 }
208 if (ofs > 0) { 208 if (ofs > 0) {
209 html(delim); 209 html(delim);
210 html("ofs="); 210 html("ofs=");
211 htmlf("%d", ofs); 211 htmlf("%d", ofs);
212 } 212 }
213 html("'>"); 213 html("'>");
214 html_txt(name); 214 html_txt(name);
215 html("</a>"); 215 html("</a>");
216} 216}
217 217
218void cgit_commit_link(char *name, char *title, char *class, char *head, 218void cgit_commit_link(char *name, char *title, char *class, char *head,
219 char *rev) 219 char *rev)
220{ 220{
221 if (strlen(name) > cgit_max_msg_len && cgit_max_msg_len >= 15) { 221 if (strlen(name) > cgit_max_msg_len && cgit_max_msg_len >= 15) {
222 name[cgit_max_msg_len] = '\0'; 222 name[cgit_max_msg_len] = '\0';
223 name[cgit_max_msg_len - 1] = '.'; 223 name[cgit_max_msg_len - 1] = '.';
224 name[cgit_max_msg_len - 2] = '.'; 224 name[cgit_max_msg_len - 2] = '.';
225 name[cgit_max_msg_len - 3] = '.'; 225 name[cgit_max_msg_len - 3] = '.';
226 } 226 }
227 reporevlink("commit", name, title, class, head, rev, NULL); 227 reporevlink("commit", name, title, class, head, rev, NULL);
228} 228}
229 229
230void cgit_refs_link(char *name, char *title, char *class, char *head,
231 char *rev, char *path)
232{
233 reporevlink("refs", name, title, class, head, rev, path);
234}
235
230void cgit_snapshot_link(char *name, char *title, char *class, char *head, 236void cgit_snapshot_link(char *name, char *title, char *class, char *head,
231 char *rev, char *archivename) 237 char *rev, char *archivename)
232{ 238{
233 reporevlink("snapshot", name, title, class, head, rev, archivename); 239 reporevlink("snapshot", name, title, class, head, rev, archivename);
234} 240}
235 241
236void cgit_diff_link(char *name, char *title, char *class, char *head, 242void cgit_diff_link(char *name, char *title, char *class, char *head,
237 char *new_rev, char *old_rev, char *path) 243 char *new_rev, char *old_rev, char *path)
238{ 244{
239 char *delim; 245 char *delim;
240 246
241 delim = repolink(title, class, "diff", head, path); 247 delim = repolink(title, class, "diff", head, path);
242 if (new_rev && strcmp(new_rev, cgit_query_head)) { 248 if (new_rev && strcmp(new_rev, cgit_query_head)) {
243 html(delim); 249 html(delim);
244 html("id="); 250 html("id=");
245 html_attr(new_rev); 251 html_attr(new_rev);
246 delim = "&amp;"; 252 delim = "&amp;";
247 } 253 }
248 if (old_rev) { 254 if (old_rev) {
249 html(delim); 255 html(delim);
250 html("id2="); 256 html("id2=");
251 html_attr(old_rev); 257 html_attr(old_rev);
252 } 258 }
253 html("'>"); 259 html("'>");
254 html_txt(name); 260 html_txt(name);
255 html("</a>"); 261 html("</a>");
256} 262}
257 263
258void cgit_object_link(struct object *obj) 264void cgit_object_link(struct object *obj)
259{ 265{
260 char *page, *arg, *url; 266 char *page, *arg, *url;
261 267
262 if (obj->type == OBJ_COMMIT) { 268 if (obj->type == OBJ_COMMIT) {
263 cgit_commit_link(fmt("commit %s", sha1_to_hex(obj->sha1)), NULL, NULL, 269 cgit_commit_link(fmt("commit %s", sha1_to_hex(obj->sha1)), NULL, NULL,
264 cgit_query_head, sha1_to_hex(obj->sha1)); 270 cgit_query_head, sha1_to_hex(obj->sha1));
265 return; 271 return;
266 } else if (obj->type == OBJ_TREE) { 272 } else if (obj->type == OBJ_TREE) {
267 page = "tree"; 273 page = "tree";
268 arg = "id"; 274 arg = "id";
269 } else { 275 } else {
270 page = "blob"; 276 page = "blob";
271 arg = "id"; 277 arg = "id";
272 } 278 }
273 279
274 url = cgit_pageurl(cgit_query_repo, page, 280 url = cgit_pageurl(cgit_query_repo, page,
275 fmt("%s=%s", arg, sha1_to_hex(obj->sha1))); 281 fmt("%s=%s", arg, sha1_to_hex(obj->sha1)));
276 html_link_open(url, NULL, NULL); 282 html_link_open(url, NULL, NULL);
277 htmlf("%s %s", typename(obj->type), 283 htmlf("%s %s", typename(obj->type),
diff --git a/ui-summary.c b/ui-summary.c
index 97f1b57..016fea2 100644
--- a/ui-summary.c
+++ b/ui-summary.c
@@ -121,125 +121,138 @@ static int print_tag(struct refinfo *ref)
121 html("</td><td colspan='2'/><td>"); 121 html("</td><td colspan='2'/><td>");
122 cgit_object_link(ref->object); 122 cgit_object_link(ref->object);
123 html("</td></tr>\n"); 123 html("</td></tr>\n");
124 } 124 }
125 return 0; 125 return 0;
126} 126}
127 127
128static int cgit_print_archive_cb(const char *refname, const unsigned char *sha1, 128static int cgit_print_archive_cb(const char *refname, const unsigned char *sha1,
129 int flags, void *cb_data) 129 int flags, void *cb_data)
130{ 130{
131 struct tag *tag; 131 struct tag *tag;
132 struct taginfo *info; 132 struct taginfo *info;
133 struct object *obj; 133 struct object *obj;
134 char buf[256], *url; 134 char buf[256], *url;
135 unsigned char fileid[20]; 135 unsigned char fileid[20];
136 136
137 if (prefixcmp(refname, "refs/archives")) 137 if (prefixcmp(refname, "refs/archives"))
138 return 0; 138 return 0;
139 strncpy(buf, refname+14, sizeof(buf)); 139 strncpy(buf, refname+14, sizeof(buf));
140 obj = parse_object(sha1); 140 obj = parse_object(sha1);
141 if (!obj) 141 if (!obj)
142 return 1; 142 return 1;
143 if (obj->type == OBJ_TAG) { 143 if (obj->type == OBJ_TAG) {
144 tag = lookup_tag(sha1); 144 tag = lookup_tag(sha1);
145 if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag))) 145 if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag)))
146 return 0; 146 return 0;
147 hashcpy(fileid, tag->tagged->sha1); 147 hashcpy(fileid, tag->tagged->sha1);
148 } else if (obj->type != OBJ_BLOB) { 148 } else if (obj->type != OBJ_BLOB) {
149 return 0; 149 return 0;
150 } else { 150 } else {
151 hashcpy(fileid, sha1); 151 hashcpy(fileid, sha1);
152 } 152 }
153 if (!header) { 153 if (!header) {
154 html("<table id='downloads'>"); 154 html("<table id='downloads'>");
155 html("<tr><th>Downloads</th></tr>"); 155 html("<tr><th>Downloads</th></tr>");
156 header = 1; 156 header = 1;
157 } 157 }
158 html("<tr><td>"); 158 html("<tr><td>");
159 url = cgit_pageurl(cgit_query_repo, "blob", 159 url = cgit_pageurl(cgit_query_repo, "blob",
160 fmt("id=%s&amp;path=%s", sha1_to_hex(fileid), 160 fmt("id=%s&amp;path=%s", sha1_to_hex(fileid),
161 buf)); 161 buf));
162 html_link_open(url, NULL, NULL); 162 html_link_open(url, NULL, NULL);
163 html_txt(buf); 163 html_txt(buf);
164 html_link_close(); 164 html_link_close();
165 html("</td></tr>"); 165 html("</td></tr>");
166 return 0; 166 return 0;
167} 167}
168 168
169static void print_refs_link(char *path)
170{
171 html("<tr class='nohover'><td colspan='4'>");
172 cgit_refs_link("[...]", NULL, NULL, cgit_query_head, NULL, path);
173 html("</td></tr>");
174}
175
169void cgit_print_branches(int maxcount) 176void cgit_print_branches(int maxcount)
170{ 177{
171 struct reflist list; 178 struct reflist list;
172 int i; 179 int i;
173 180
174 html("<tr class='nohover'><th class='left'>Branch</th>" 181 html("<tr class='nohover'><th class='left'>Branch</th>"
175 "<th class='left'>Idle</th>" 182 "<th class='left'>Idle</th>"
176 "<th class='left'>Author</th>" 183 "<th class='left'>Author</th>"
177 "<th class='left'>Head commit</th></tr>\n"); 184 "<th class='left'>Head commit</th></tr>\n");
178 185
179 list.refs = NULL; 186 list.refs = NULL;
180 list.alloc = list.count = 0; 187 list.alloc = list.count = 0;
181 for_each_branch_ref(cgit_refs_cb, &list); 188 for_each_branch_ref(cgit_refs_cb, &list);
182 189
183 if (maxcount == 0 || maxcount > list.count) 190 if (maxcount == 0 || maxcount > list.count)
184 maxcount = list.count; 191 maxcount = list.count;
185 192
186 if (maxcount < list.count) { 193 if (maxcount < list.count) {
187 qsort(list.refs, list.count, sizeof(*list.refs), cmp_branch_age); 194 qsort(list.refs, list.count, sizeof(*list.refs), cmp_branch_age);
188 qsort(list.refs, maxcount, sizeof(*list.refs), cmp_ref_name); 195 qsort(list.refs, maxcount, sizeof(*list.refs), cmp_ref_name);
189 } 196 }
190 197
191 for(i=0; i<maxcount; i++) 198 for(i=0; i<maxcount; i++)
192 cgit_print_branch(list.refs[i]); 199 cgit_print_branch(list.refs[i]);
200
201 if (maxcount < list.count)
202 print_refs_link("heads");
193} 203}
194 204
195void cgit_print_tags(int maxcount) 205void cgit_print_tags(int maxcount)
196{ 206{
197 struct reflist list; 207 struct reflist list;
198 int i; 208 int i;
199 209
200 header = 0; 210 header = 0;
201 list.refs = NULL; 211 list.refs = NULL;
202 list.alloc = list.count = 0; 212 list.alloc = list.count = 0;
203 for_each_tag_ref(cgit_refs_cb, &list); 213 for_each_tag_ref(cgit_refs_cb, &list);
204 if (list.count == 0) 214 if (list.count == 0)
205 return; 215 return;
206 qsort(list.refs, list.count, sizeof(*list.refs), cmp_tag_age); 216 qsort(list.refs, list.count, sizeof(*list.refs), cmp_tag_age);
207 if (!maxcount) 217 if (!maxcount)
208 maxcount = list.count; 218 maxcount = list.count;
209 else if (maxcount > list.count) 219 else if (maxcount > list.count)
210 maxcount = list.count; 220 maxcount = list.count;
211 print_tag_header(); 221 print_tag_header();
212 for(i=0; i<maxcount; i++) 222 for(i=0; i<maxcount; i++)
213 print_tag(list.refs[i]); 223 print_tag(list.refs[i]);
224
225 if (maxcount < list.count)
226 print_refs_link("tags");
214} 227}
215 228
216static void cgit_print_archives() 229static void cgit_print_archives()
217{ 230{
218 header = 0; 231 header = 0;
219 for_each_ref(cgit_print_archive_cb, NULL); 232 for_each_ref(cgit_print_archive_cb, NULL);
220 if (header) 233 if (header)
221 html("</table>"); 234 html("</table>");
222} 235}
223 236
224void cgit_print_summary() 237void cgit_print_summary()
225{ 238{
226 html("<div id='summary'>"); 239 html("<div id='summary'>");
227 cgit_print_archives(); 240 cgit_print_archives();
228 html("<h2>"); 241 html("<h2>");
229 html_txt(cgit_repo->name); 242 html_txt(cgit_repo->name);
230 html(" - "); 243 html(" - ");
231 html_txt(cgit_repo->desc); 244 html_txt(cgit_repo->desc);
232 html("</h2>"); 245 html("</h2>");
233 if (cgit_repo->readme) 246 if (cgit_repo->readme)
234 html_include(cgit_repo->readme); 247 html_include(cgit_repo->readme);
235 html("</div>"); 248 html("</div>");
236 if (cgit_summary_log > 0) 249 if (cgit_summary_log > 0)
237 cgit_print_log(cgit_query_head, 0, cgit_summary_log, NULL, NULL, 0); 250 cgit_print_log(cgit_query_head, 0, cgit_summary_log, NULL, NULL, 0);
238 html("<table class='list nowrap'>"); 251 html("<table class='list nowrap'>");
239 if (cgit_summary_log > 0) 252 if (cgit_summary_log > 0)
240 html("<tr class='nohover'><td colspan='4'>&nbsp;</td></tr>"); 253 html("<tr class='nohover'><td colspan='4'>&nbsp;</td></tr>");
241 cgit_print_branches(cgit_summary_branches); 254 cgit_print_branches(cgit_summary_branches);
242 html("<tr class='nohover'><td colspan='4'>&nbsp;</td></tr>"); 255 html("<tr class='nohover'><td colspan='4'>&nbsp;</td></tr>");
243 cgit_print_tags(cgit_summary_tags); 256 cgit_print_tags(cgit_summary_tags);
244 html("</table>"); 257 html("</table>");
245} 258}