author | Lars Hjemli <hjemli@gmail.com> | 2007-06-29 18:32:08 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2007-06-29 18:32:08 (UTC) |
commit | 16a3d2779ccd56bf7954d98da547247d8796544b (patch) (unidiff) | |
tree | 86d2ed41adc3de842c7518d614ea49ca0200e4d2 /ui-shared.c | |
parent | f69250358a74efa5d7d9c562b2cdd80fad1430f1 (diff) | |
parent | 103940fe6b0914dc42b8b033d1d328f38135ca5f (diff) | |
download | cgit-16a3d2779ccd56bf7954d98da547247d8796544b.zip cgit-16a3d2779ccd56bf7954d98da547247d8796544b.tar.gz cgit-16a3d2779ccd56bf7954d98da547247d8796544b.tar.bz2 |
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-- | ui-shared.c | 71 |
1 files changed, 55 insertions, 16 deletions
diff --git a/ui-shared.c b/ui-shared.c index 110c696..d4376ce 100644 --- a/ui-shared.c +++ b/ui-shared.c | |||
@@ -106,30 +106,34 @@ static char *repolink(char *title, char *class, char *page, char *head, | |||
106 | html(" href='"); | 106 | html(" href='"); |
107 | if (cgit_virtual_root) { | 107 | if (cgit_virtual_root) { |
108 | html_attr(cgit_virtual_root); | 108 | html_attr(cgit_virtual_root); |
109 | if (cgit_virtual_root[strlen(cgit_virtual_root) - 1] != '/') | 109 | if (cgit_virtual_root[strlen(cgit_virtual_root) - 1] != '/') |
110 | html("/"); | 110 | html("/"); |
111 | html_attr(cgit_repo->url); | 111 | html_attr(cgit_repo->url); |
112 | if (cgit_repo->url[strlen(cgit_repo->url) - 1] != '/') | 112 | if (cgit_repo->url[strlen(cgit_repo->url) - 1] != '/') |
113 | html("/"); | 113 | html("/"); |
114 | html(page); | 114 | if (page) { |
115 | html("/"); | 115 | html(page); |
116 | if (path) | 116 | html("/"); |
117 | html_attr(path); | 117 | if (path) |
118 | html_attr(path); | ||
119 | } | ||
118 | } else { | 120 | } else { |
119 | html(cgit_script_name); | 121 | html(cgit_script_name); |
120 | html("?url="); | 122 | html("?url="); |
121 | html_attr(cgit_repo->url); | 123 | html_attr(cgit_repo->url); |
122 | if (cgit_repo->url[strlen(cgit_repo->url) - 1] != '/') | 124 | if (cgit_repo->url[strlen(cgit_repo->url) - 1] != '/') |
123 | html("/"); | 125 | html("/"); |
124 | html(page); | 126 | if (page) { |
125 | html("/"); | 127 | html(page); |
126 | if (path) | 128 | html("/"); |
127 | html_attr(path); | 129 | if (path) |
130 | html_attr(path); | ||
131 | } | ||
128 | delim = "&"; | 132 | delim = "&"; |
129 | } | 133 | } |
130 | if (head && strcmp(head, cgit_repo->defbranch)) { | 134 | if (head && strcmp(head, cgit_repo->defbranch)) { |
131 | html(delim); | 135 | html(delim); |
132 | html("h="); | 136 | html("h="); |
133 | html_attr(head); | 137 | html_attr(head); |
134 | delim = "&"; | 138 | delim = "&"; |
135 | } | 139 | } |
@@ -154,19 +158,35 @@ static void reporevlink(char *page, char *name, char *title, char *class, | |||
154 | 158 | ||
155 | void cgit_tree_link(char *name, char *title, char *class, char *head, | 159 | void cgit_tree_link(char *name, char *title, char *class, char *head, |
156 | char *rev, char *path) | 160 | char *rev, char *path) |
157 | { | 161 | { |
158 | reporevlink("tree", name, title, class, head, rev, path); | 162 | reporevlink("tree", name, title, class, head, rev, path); |
159 | } | 163 | } |
160 | 164 | ||
161 | void cgit_log_link(char *name, char *title, char *class, char *head, | 165 | void cgit_log_link(char *name, char *title, char *class, char *head, |
162 | char *rev, char *path) | 166 | char *rev, char *path, int ofs) |
163 | { | 167 | { |
164 | reporevlink("log", name, title, class, head, rev, path); | 168 | char *delim; |
169 | |||
170 | delim = repolink(title, class, "log", head, path); | ||
171 | if (rev && strcmp(rev, cgit_query_head)) { | ||
172 | html(delim); | ||
173 | html("id="); | ||
174 | html_attr(rev); | ||
175 | delim = "&"; | ||
176 | } | ||
177 | if (ofs > 0) { | ||
178 | html(delim); | ||
179 | html("ofs="); | ||
180 | htmlf("%d", ofs); | ||
181 | } | ||
182 | html("'>"); | ||
183 | html_txt(name); | ||
184 | html("</a>"); | ||
165 | } | 185 | } |
166 | 186 | ||
167 | void cgit_commit_link(char *name, char *title, char *class, char *head, | 187 | void cgit_commit_link(char *name, char *title, char *class, char *head, |
168 | char *rev) | 188 | char *rev) |
169 | { | 189 | { |
170 | if (strlen(name) > cgit_max_msg_len && cgit_max_msg_len >= 15) { | 190 | if (strlen(name) > cgit_max_msg_len && cgit_max_msg_len >= 15) { |
171 | name[cgit_max_msg_len] = '\0'; | 191 | name[cgit_max_msg_len] = '\0'; |
172 | name[cgit_max_msg_len - 1] = '.'; | 192 | name[cgit_max_msg_len - 1] = '.'; |
@@ -274,29 +294,48 @@ void cgit_print_docend() | |||
274 | { | 294 | { |
275 | html("</td></tr></table>"); | 295 | html("</td></tr></table>"); |
276 | html("</body>\n</html>\n"); | 296 | html("</body>\n</html>\n"); |
277 | } | 297 | } |
278 | 298 | ||
279 | void cgit_print_pageheader(char *title, int show_search) | 299 | void cgit_print_pageheader(char *title, int show_search) |
280 | { | 300 | { |
281 | html("<table id='layout'>"); | 301 | html("<table id='layout'>"); |
282 | html("<tr><td id='header'>"); | 302 | html("<tr><td id='header'><a href='"); |
283 | html(cgit_root_title); | 303 | html_attr(cgit_rooturl()); |
284 | html("</td><td id='logo'>"); | 304 | html("'>"); |
305 | html_txt(cgit_root_title); | ||
306 | html("</a></td><td id='logo'>"); | ||
285 | html("<a href='"); | 307 | html("<a href='"); |
286 | html_attr(cgit_logo_link); | 308 | html_attr(cgit_logo_link); |
287 | htmlf("'><img src='%s' alt='logo'/></a>", cgit_logo); | 309 | htmlf("'><img src='%s' alt='logo'/></a>", cgit_logo); |
288 | html("</td></tr>"); | 310 | html("</td></tr>"); |
289 | html("<tr><td id='crumb'>"); | 311 | html("<tr><td id='crumb'>"); |
290 | htmlf("<a href='%s'>root</a>", cgit_rooturl()); | ||
291 | if (cgit_query_repo) { | 312 | if (cgit_query_repo) { |
292 | htmlf(" : <a href='%s'>", cgit_repourl(cgit_repo->url)); | ||
293 | html_txt(cgit_repo->name); | 313 | html_txt(cgit_repo->name); |
294 | htmlf("</a> : %s", title); | 314 | html(" ("); |
315 | html_txt(cgit_query_head); | ||
316 | html(") : "); | ||
317 | reporevlink(NULL, "summary", NULL, NULL, cgit_query_head, | ||
318 | NULL, NULL); | ||
319 | html(" "); | ||
320 | cgit_log_link("log", NULL, NULL, cgit_query_head, | ||
321 | cgit_query_sha1, cgit_query_path, 0); | ||
322 | html(" "); | ||
323 | cgit_tree_link("tree", NULL, NULL, cgit_query_head, | ||
324 | cgit_query_sha1, NULL); | ||
325 | html(" "); | ||
326 | cgit_commit_link("commit", NULL, NULL, cgit_query_head, | ||
327 | cgit_query_sha1); | ||
328 | html(" "); | ||
329 | cgit_diff_link("diff", NULL, NULL, cgit_query_head, | ||
330 | cgit_query_sha1, cgit_query_sha2, | ||
331 | cgit_query_path); | ||
332 | } else { | ||
333 | html_txt("Index of repositories"); | ||
295 | } | 334 | } |
296 | html("</td>"); | 335 | html("</td>"); |
297 | html("<td id='search'>"); | 336 | html("<td id='search'>"); |
298 | if (show_search) { | 337 | if (show_search) { |
299 | html("<form method='get' action='"); | 338 | html("<form method='get' action='"); |
300 | html_attr(cgit_currurl()); | 339 | html_attr(cgit_currurl()); |
301 | html("'>"); | 340 | html("'>"); |
302 | if (!cgit_virtual_root) { | 341 | if (!cgit_virtual_root) { |