diff options
author | Lars Hjemli <hjemli@gmail.com> | 2007-06-30 03:32:08 (JST) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2007-06-30 03:32:08 (JST) |
commit | 16a3d2779ccd56bf7954d98da547247d8796544b (patch) | |
tree | 86d2ed41adc3de842c7518d614ea49ca0200e4d2 | |
parent | f69250358a74efa5d7d9c562b2cdd80fad1430f1 (diff) | |
parent | 103940fe6b0914dc42b8b033d1d328f38135ca5f (diff) | |
download | cgit-16a3d2779ccd56bf7954d98da547247d8796544b.zip cgit-16a3d2779ccd56bf7954d98da547247d8796544b.tar.gz |
Merge branch 'lh/menu'
* lh/menu:
Add ofs argument to cgit_log_link and use it in ui-log.c
Add trim_end() and use it to remove trailing slashes from repo paths
Do not include current path in the "tree" menu link
Add setting to enable/disable extra links on index page
Change S/L/T to summary/log/tree
Change "files" to "tree"
Include querystring as part of cached filename for repo summary page
Add more menuitems on repo pages
-rw-r--r-- | cgit.c | 10 | ||||
-rw-r--r-- | cgit.css | 23 | ||||
-rw-r--r-- | cgit.h | 4 | ||||
-rw-r--r-- | cgitrc | 4 | ||||
-rw-r--r-- | parsing.c | 2 | ||||
-rw-r--r-- | shared.c | 27 | ||||
-rw-r--r-- | ui-log.c | 16 | ||||
-rw-r--r-- | ui-repolist.c | 35 | ||||
-rw-r--r-- | ui-shared.c | 71 | ||||
-rw-r--r-- | ui-summary.c | 2 | ||||
-rw-r--r-- | ui-tree.c | 4 |
11 files changed, 145 insertions, 53 deletions
@@ -26,13 +26,15 @@ static int cgit_prepare_cache(struct cacheitem *item) | |||
26 | } | 26 | } |
27 | 27 | ||
28 | if (!cgit_cmd) { | 28 | if (!cgit_cmd) { |
29 | item->name = xstrdup(fmt("%s/%s/index.html", cgit_cache_root, | 29 | item->name = xstrdup(fmt("%s/%s/index.%s.html", cgit_cache_root, |
30 | cache_safe_filename(cgit_repo->url))); | 30 | cache_safe_filename(cgit_repo->url), |
31 | cache_safe_filename(cgit_querystring))); | ||
31 | item->ttl = cgit_cache_repo_ttl; | 32 | item->ttl = cgit_cache_repo_ttl; |
32 | } else { | 33 | } else { |
33 | item->name = xstrdup(fmt("%s/%s/%s/%s.html", cgit_cache_root, | 34 | item->name = xstrdup(fmt("%s/%s/%s/%s.html", cgit_cache_root, |
34 | cache_safe_filename(cgit_repo->url), cgit_query_page, | 35 | cache_safe_filename(cgit_repo->url), |
35 | cache_safe_filename(cgit_querystring))); | 36 | cgit_query_page, |
37 | cache_safe_filename(cgit_querystring))); | ||
36 | if (cgit_query_has_symref) | 38 | if (cgit_query_has_symref) |
37 | item->ttl = cgit_cache_dynamic_ttl; | 39 | item->ttl = cgit_cache_dynamic_ttl; |
38 | else if (cgit_query_has_sha1) | 40 | else if (cgit_query_has_sha1) |
@@ -95,6 +95,14 @@ td#header { | |||
95 | vertical-align: text-bottom; | 95 | vertical-align: text-bottom; |
96 | } | 96 | } |
97 | 97 | ||
98 | td#header a { | ||
99 | color: #666; | ||
100 | } | ||
101 | |||
102 | td#header a:hoved { | ||
103 | text-decoration: underline; | ||
104 | } | ||
105 | |||
98 | td#logo { | 106 | td#logo { |
99 | text-align: right; | 107 | text-align: right; |
100 | vertical-align: middle; | 108 | vertical-align: middle; |
@@ -116,11 +124,13 @@ td#crumb { | |||
116 | td#crumb a { | 124 | td#crumb a { |
117 | color: #ccc; | 125 | color: #ccc; |
118 | background-color: #666; | 126 | background-color: #666; |
127 | padding: 0em 0.5em 0em 0.5em; | ||
119 | } | 128 | } |
120 | 129 | ||
121 | td#crumb a:hover { | 130 | td#crumb a:hover { |
122 | color: #eee; | 131 | color: #666; |
123 | background-color: #666; | 132 | background-color: #ccc; |
133 | text-decoration: none; | ||
124 | } | 134 | } |
125 | 135 | ||
126 | td#search { | 136 | td#search { |
@@ -361,16 +371,17 @@ table.list td.repogroup { | |||
361 | 371 | ||
362 | a.button { | 372 | a.button { |
363 | font-size: 80%; | 373 | font-size: 80%; |
364 | color: #333; | 374 | color: #aaa; |
365 | background-color: #ccc; | 375 | background-color: #eee; |
366 | border: solid 1px #999; | 376 | border: solid 1px #aaa; |
367 | padding: 0em 0.5em; | 377 | padding: 0em 0.5em; |
368 | margin: 0.1em 0.25em; | 378 | margin: 0.1em 0.25em; |
369 | } | 379 | } |
370 | 380 | ||
371 | a.button:hover { | 381 | a.button:hover { |
372 | text-decoration: none; | 382 | text-decoration: none; |
373 | background-color: #eee; | 383 | color: #333; |
384 | background-color: #ccc; | ||
374 | } | 385 | } |
375 | 386 | ||
376 | a.primary { | 387 | a.primary { |
@@ -118,6 +118,7 @@ extern char *cgit_repo_group; | |||
118 | 118 | ||
119 | extern int cgit_nocache; | 119 | extern int cgit_nocache; |
120 | extern int cgit_snapshots; | 120 | extern int cgit_snapshots; |
121 | extern int cgit_enable_index_links; | ||
121 | extern int cgit_enable_log_filecount; | 122 | extern int cgit_enable_log_filecount; |
122 | extern int cgit_enable_log_linecount; | 123 | extern int cgit_enable_log_linecount; |
123 | extern int cgit_max_lock_attempts; | 124 | extern int cgit_max_lock_attempts; |
@@ -158,6 +159,7 @@ extern int chk_zero(int result, char *msg); | |||
158 | extern int chk_positive(int result, char *msg); | 159 | extern int chk_positive(int result, char *msg); |
159 | 160 | ||
160 | extern int hextoint(char c); | 161 | extern int hextoint(char c); |
162 | extern char *trim_end(const char *str, char c); | ||
161 | 163 | ||
162 | extern void *cgit_free_commitinfo(struct commitinfo *info); | 164 | extern void *cgit_free_commitinfo(struct commitinfo *info); |
163 | 165 | ||
@@ -204,7 +206,7 @@ extern char *cgit_pageurl(const char *reponame, const char *pagename, | |||
204 | extern void cgit_tree_link(char *name, char *title, char *class, char *head, | 206 | extern void cgit_tree_link(char *name, char *title, char *class, char *head, |
205 | char *rev, char *path); | 207 | char *rev, char *path); |
206 | extern void cgit_log_link(char *name, char *title, char *class, char *head, | 208 | extern void cgit_log_link(char *name, char *title, char *class, char *head, |
207 | char *rev, char *path); | 209 | char *rev, char *path, int ofs); |
208 | extern void cgit_commit_link(char *name, char *title, char *class, char *head, | 210 | extern void cgit_commit_link(char *name, char *title, char *class, char *head, |
209 | char *rev); | 211 | char *rev); |
210 | extern void cgit_diff_link(char *name, char *title, char *class, char *head, | 212 | extern void cgit_diff_link(char *name, char *title, char *class, char *head, |
@@ -12,6 +12,10 @@ | |||
12 | #snapshots=0 | 12 | #snapshots=0 |
13 | 13 | ||
14 | 14 | ||
15 | ## Enable/disable extra links to summary/log/tree per repo on index page | ||
16 | #enable-index-links=0 | ||
17 | |||
18 | |||
15 | ## Enable/disable display of 'number of files changed' in log view | 19 | ## Enable/disable display of 'number of files changed' in log view |
16 | #enable-log-filecount=0 | 20 | #enable-log-filecount=0 |
17 | 21 | ||
@@ -168,7 +168,7 @@ void cgit_parse_url(const char *url) | |||
168 | if (p) { | 168 | if (p) { |
169 | p[0] = '\0'; | 169 | p[0] = '\0'; |
170 | if (p[1]) | 170 | if (p[1]) |
171 | cgit_query_path = xstrdup(p + 1); | 171 | cgit_query_path = trim_end(p + 1, '/'); |
172 | } | 172 | } |
173 | cgit_cmd = cgit_get_cmd_index(cmd + 1); | 173 | cgit_cmd = cgit_get_cmd_index(cmd + 1); |
174 | cgit_query_page = xstrdup(cmd + 1); | 174 | cgit_query_page = xstrdup(cmd + 1); |
@@ -28,6 +28,7 @@ char *cgit_repo_group = NULL; | |||
28 | 28 | ||
29 | int cgit_nocache = 0; | 29 | int cgit_nocache = 0; |
30 | int cgit_snapshots = 0; | 30 | int cgit_snapshots = 0; |
31 | int cgit_enable_index_links = 0; | ||
31 | int cgit_enable_log_filecount = 0; | 32 | int cgit_enable_log_filecount = 0; |
32 | int cgit_enable_log_linecount = 0; | 33 | int cgit_enable_log_linecount = 0; |
33 | int cgit_max_lock_attempts = 5; | 34 | int cgit_max_lock_attempts = 5; |
@@ -148,6 +149,8 @@ void cgit_global_config_cb(const char *name, const char *value) | |||
148 | cgit_nocache = atoi(value); | 149 | cgit_nocache = atoi(value); |
149 | else if (!strcmp(name, "snapshots")) | 150 | else if (!strcmp(name, "snapshots")) |
150 | cgit_snapshots = atoi(value); | 151 | cgit_snapshots = atoi(value); |
152 | else if (!strcmp(name, "enable-index-links")) | ||
153 | cgit_enable_index_links = atoi(value); | ||
151 | else if (!strcmp(name, "enable-log-filecount")) | 154 | else if (!strcmp(name, "enable-log-filecount")) |
152 | cgit_enable_log_filecount = atoi(value); | 155 | cgit_enable_log_filecount = atoi(value); |
153 | else if (!strcmp(name, "enable-log-linecount")) | 156 | else if (!strcmp(name, "enable-log-linecount")) |
@@ -227,7 +230,7 @@ void cgit_querystring_cb(const char *name, const char *value) | |||
227 | } else if (!strcmp(name, "ofs")) { | 230 | } else if (!strcmp(name, "ofs")) { |
228 | cgit_query_ofs = atoi(value); | 231 | cgit_query_ofs = atoi(value); |
229 | } else if (!strcmp(name, "path")) { | 232 | } else if (!strcmp(name, "path")) { |
230 | cgit_query_path = xstrdup(value); | 233 | cgit_query_path = trim_end(value, '/'); |
231 | } else if (!strcmp(name, "name")) { | 234 | } else if (!strcmp(name, "name")) { |
232 | cgit_query_name = xstrdup(value); | 235 | cgit_query_name = xstrdup(value); |
233 | } | 236 | } |
@@ -256,6 +259,28 @@ int hextoint(char c) | |||
256 | return -1; | 259 | return -1; |
257 | } | 260 | } |
258 | 261 | ||
262 | char *trim_end(const char *str, char c) | ||
263 | { | ||
264 | int len; | ||
265 | char *s, *t; | ||
266 | |||
267 | if (str == NULL) | ||
268 | return NULL; | ||
269 | t = (char *)str; | ||
270 | len = strlen(t); | ||
271 | while(len > 0 && t[len - 1] == c) | ||
272 | len--; | ||
273 | |||
274 | if (len == 0) | ||
275 | return NULL; | ||
276 | |||
277 | c = t[len]; | ||
278 | t[len] = '\0'; | ||
279 | s = xstrdup(t); | ||
280 | t[len] = c; | ||
281 | return s; | ||
282 | } | ||
283 | |||
259 | void cgit_diff_tree_cb(struct diff_queue_struct *q, | 284 | void cgit_diff_tree_cb(struct diff_queue_struct *q, |
260 | struct diff_options *options, void *data) | 285 | struct diff_options *options, void *data) |
261 | { | 286 | { |
@@ -113,17 +113,15 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *path, i | |||
113 | if (pager) { | 113 | if (pager) { |
114 | html("<div class='pager'>"); | 114 | html("<div class='pager'>"); |
115 | if (ofs > 0) { | 115 | if (ofs > 0) { |
116 | html(" <a href='"); | 116 | cgit_log_link("[prev]", NULL, NULL, cgit_query_head, |
117 | html(cgit_pageurl(cgit_query_repo, cgit_query_page, | 117 | cgit_query_sha1, cgit_query_path, |
118 | fmt("h=%s&ofs=%d", tip, ofs-cnt))); | 118 | ofs - cnt); |
119 | html("'>[prev]</a> "); | 119 | html(" "); |
120 | } | 120 | } |
121 | |||
122 | if ((commit = get_revision(&rev)) != NULL) { | 121 | if ((commit = get_revision(&rev)) != NULL) { |
123 | html(" <a href='"); | 122 | cgit_log_link("[next]", NULL, NULL, cgit_query_head, |
124 | html(cgit_pageurl(cgit_query_repo, "log", | 123 | cgit_query_sha1, cgit_query_path, |
125 | fmt("h=%s&ofs=%d", tip, ofs+cnt))); | 124 | ofs + cnt); |
126 | html("'>[next]</a> "); | ||
127 | } | 125 | } |
128 | html("</div>"); | 126 | html("</div>"); |
129 | } | 127 | } |
diff --git a/ui-repolist.c b/ui-repolist.c index 2018dab..4c86543 100644 --- a/ui-repolist.c +++ b/ui-repolist.c | |||
@@ -44,15 +44,19 @@ static void print_modtime(struct repoinfo *repo) | |||
44 | 44 | ||
45 | void cgit_print_repolist(struct cacheitem *item) | 45 | void cgit_print_repolist(struct cacheitem *item) |
46 | { | 46 | { |
47 | int i; | 47 | int i, columns = 4; |
48 | char *last_group = NULL; | 48 | char *last_group = NULL; |
49 | 49 | ||
50 | if (cgit_enable_index_links) | ||
51 | columns++; | ||
52 | |||
50 | cgit_print_docstart(cgit_root_title, item); | 53 | cgit_print_docstart(cgit_root_title, item); |
51 | cgit_print_pageheader(cgit_root_title, 0); | 54 | cgit_print_pageheader(cgit_root_title, 0); |
52 | 55 | ||
53 | html("<table class='list nowrap'>"); | 56 | html("<table class='list nowrap'>"); |
54 | if (cgit_index_header) { | 57 | if (cgit_index_header) { |
55 | html("<tr class='nohover'><td colspan='5' class='include-block'>"); | 58 | htmlf("<tr class='nohover'><td colspan='%d' class='include-block'>", |
59 | columns); | ||
56 | html_include(cgit_index_header); | 60 | html_include(cgit_index_header); |
57 | html("</td></tr>"); | 61 | html("</td></tr>"); |
58 | } | 62 | } |
@@ -60,8 +64,10 @@ void cgit_print_repolist(struct cacheitem *item) | |||
60 | "<th class='left'>Name</th>" | 64 | "<th class='left'>Name</th>" |
61 | "<th class='left'>Description</th>" | 65 | "<th class='left'>Description</th>" |
62 | "<th class='left'>Owner</th>" | 66 | "<th class='left'>Owner</th>" |
63 | "<th class='left'>Idle</th>" | 67 | "<th class='left'>Idle</th>"); |
64 | "<th>Links</th></tr>\n"); | 68 | if (cgit_enable_index_links) |
69 | html("<th>Links</th>"); | ||
70 | html("</tr>\n"); | ||
65 | 71 | ||
66 | for (i=0; i<cgit_repolist.count; i++) { | 72 | for (i=0; i<cgit_repolist.count; i++) { |
67 | cgit_repo = &cgit_repolist.repos[i]; | 73 | cgit_repo = &cgit_repolist.repos[i]; |
@@ -69,7 +75,8 @@ void cgit_print_repolist(struct cacheitem *item) | |||
69 | (last_group != NULL && cgit_repo->group == NULL) || | 75 | (last_group != NULL && cgit_repo->group == NULL) || |
70 | (last_group != NULL && cgit_repo->group != NULL && | 76 | (last_group != NULL && cgit_repo->group != NULL && |
71 | strcmp(cgit_repo->group, last_group))) { | 77 | strcmp(cgit_repo->group, last_group))) { |
72 | html("<tr class='nohover'><td colspan='4' class='repogroup'>"); | 78 | htmlf("<tr class='nohover'><td colspan='%d' class='repogroup'>", |
79 | columns); | ||
73 | html_txt(cgit_repo->group); | 80 | html_txt(cgit_repo->group); |
74 | html("</td></tr>"); | 81 | html("</td></tr>"); |
75 | last_group = cgit_repo->group; | 82 | last_group = cgit_repo->group; |
@@ -85,13 +92,17 @@ void cgit_print_repolist(struct cacheitem *item) | |||
85 | html_txt(cgit_repo->owner); | 92 | html_txt(cgit_repo->owner); |
86 | html("</td><td>"); | 93 | html("</td><td>"); |
87 | print_modtime(cgit_repo); | 94 | print_modtime(cgit_repo); |
88 | html("</td><td>"); | 95 | html("</td>"); |
89 | html_link_open(cgit_repourl(cgit_repo->url), | 96 | if (cgit_enable_index_links) { |
90 | "Summary", "button"); | 97 | html("<td>"); |
91 | html("S</a>"); | 98 | html_link_open(cgit_repourl(cgit_repo->url), |
92 | cgit_log_link("L", "Log", "button", NULL, NULL, NULL); | 99 | NULL, "button"); |
93 | cgit_tree_link("F", "Files", "button", NULL, NULL, NULL); |