-rw-r--r-- | ui-shared.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/ui-shared.c b/ui-shared.c index a2f636c..1fc5c09 100644 --- a/ui-shared.c +++ b/ui-shared.c | |||
@@ -193,43 +193,43 @@ static char *repolink(char *title, char *class, char *page, char *head, | |||
193 | { | 193 | { |
194 | char *delim = "?"; | 194 | char *delim = "?"; |
195 | 195 | ||
196 | html("<a"); | 196 | html("<a"); |
197 | if (title) { | 197 | if (title) { |
198 | html(" title='"); | 198 | html(" title='"); |
199 | html_attr(title); | 199 | html_attr(title); |
200 | html("'"); | 200 | html("'"); |
201 | } | 201 | } |
202 | if (class) { | 202 | if (class) { |
203 | html(" class='"); | 203 | html(" class='"); |
204 | html_attr(class); | 204 | html_attr(class); |
205 | html("'"); | 205 | html("'"); |
206 | } | 206 | } |
207 | html(" href='"); | 207 | html(" href='"); |
208 | if (ctx.cfg.virtual_root) { | 208 | if (ctx.cfg.virtual_root) { |
209 | html_attr(ctx.cfg.virtual_root); | 209 | html_url_path(ctx.cfg.virtual_root); |
210 | if (ctx.cfg.virtual_root[strlen(ctx.cfg.virtual_root) - 1] != '/') | 210 | if (ctx.cfg.virtual_root[strlen(ctx.cfg.virtual_root) - 1] != '/') |
211 | html("/"); | 211 | html("/"); |
212 | html_attr(ctx.repo->url); | 212 | html_url_path(ctx.repo->url); |
213 | if (ctx.repo->url[strlen(ctx.repo->url) - 1] != '/') | 213 | if (ctx.repo->url[strlen(ctx.repo->url) - 1] != '/') |
214 | html("/"); | 214 | html("/"); |
215 | if (page) { | 215 | if (page) { |
216 | html(page); | 216 | html_url_path(page); |
217 | html("/"); | 217 | html("/"); |
218 | if (path) | 218 | if (path) |
219 | html_attr(path); | 219 | html_url_path(path); |
220 | } | 220 | } |
221 | } else { | 221 | } else { |
222 | html(ctx.cfg.script_name); | 222 | html(ctx.cfg.script_name); |
223 | html("?url="); | 223 | html("?url="); |
224 | html_url_arg(ctx.repo->url); | 224 | html_url_arg(ctx.repo->url); |
225 | if (ctx.repo->url[strlen(ctx.repo->url) - 1] != '/') | 225 | if (ctx.repo->url[strlen(ctx.repo->url) - 1] != '/') |
226 | html("/"); | 226 | html("/"); |
227 | if (page) { | 227 | if (page) { |
228 | html_url_arg(page); | 228 | html_url_arg(page); |
229 | html("/"); | 229 | html("/"); |
230 | if (path) | 230 | if (path) |
231 | html_url_arg(path); | 231 | html_url_arg(path); |
232 | } | 232 | } |
233 | delim = "&"; | 233 | delim = "&"; |
234 | } | 234 | } |
235 | if (head && strcmp(head, ctx.repo->defbranch)) { | 235 | if (head && strcmp(head, ctx.repo->defbranch)) { |
@@ -244,32 +244,37 @@ static char *repolink(char *title, char *class, char *page, char *head, | |||
244 | static void reporevlink(char *page, char *name, char *title, char *class, | 244 | static void reporevlink(char *page, char *name, char *title, char *class, |
245 | char *head, char *rev, char *path) | 245 | char *head, char *rev, char *path) |
246 | { | 246 | { |
247 | char *delim; | 247 | char *delim; |
248 | 248 | ||
249 | delim = repolink(title, class, page, head, path); | 249 | delim = repolink(title, class, page, head, path); |
250 | if (rev && strcmp(rev, ctx.qry.head)) { | 250 | if (rev && strcmp(rev, ctx.qry.head)) { |
251 | html(delim); | 251 | html(delim); |
252 | html("id="); | 252 | html("id="); |
253 | html_url_arg(rev); | 253 | html_url_arg(rev); |
254 | } | 254 | } |
255 | html("'>"); | 255 | html("'>"); |
256 | html_txt(name); | 256 | html_txt(name); |
257 | html("</a>"); | 257 | html("</a>"); |
258 | } | 258 | } |
259 | 259 | ||
260 | void cgit_summary_link(char *name, char *title, char *class, char *head) | ||
261 | { | ||
262 | reporevlink(NULL, name, title, class, head, NULL, NULL); | ||
263 | } | ||
264 | |||
260 | void cgit_tree_link(char *name, char *title, char *class, char *head, | 265 | void cgit_tree_link(char *name, char *title, char *class, char *head, |
261 | char *rev, char *path) | 266 | char *rev, char *path) |
262 | { | 267 | { |
263 | reporevlink("tree", name, title, class, head, rev, path); | 268 | reporevlink("tree", name, title, class, head, rev, path); |
264 | } | 269 | } |
265 | 270 | ||
266 | void cgit_plain_link(char *name, char *title, char *class, char *head, | 271 | void cgit_plain_link(char *name, char *title, char *class, char *head, |
267 | char *rev, char *path) | 272 | char *rev, char *path) |
268 | { | 273 | { |
269 | reporevlink("plain", name, title, class, head, rev, path); | 274 | reporevlink("plain", name, title, class, head, rev, path); |
270 | } | 275 | } |
271 | 276 | ||
272 | void cgit_log_link(char *name, char *title, char *class, char *head, | 277 | void cgit_log_link(char *name, char *title, char *class, char *head, |
273 | char *rev, char *path, int ofs, char *grep, char *pattern) | 278 | char *rev, char *path, int ofs, char *grep, char *pattern) |
274 | { | 279 | { |
275 | char *delim; | 280 | char *delim; |
@@ -585,63 +590,62 @@ void cgit_print_pageheader(struct cgit_context *ctx) | |||
585 | 590 | ||
586 | html("<table id='header'>\n"); | 591 | html("<table id='header'>\n"); |
587 | html("<tr>\n"); | 592 | html("<tr>\n"); |
588 | html("<td class='logo' rowspan='2'><a href='"); | 593 | html("<td class='logo' rowspan='2'><a href='"); |
589 | if (ctx->cfg.logo_link) | 594 | if (ctx->cfg.logo_link) |
590 | html_attr(ctx->cfg.logo_link); | 595 | html_attr(ctx->cfg.logo_link); |
591 | else | 596 | else |
592 | html_attr(cgit_rooturl()); | 597 | html_attr(cgit_rooturl()); |
593 | html("'><img src='"); | 598 | html("'><img src='"); |
594 | html_attr(ctx->cfg.logo); | 599 | html_attr(ctx->cfg.logo); |
595 | html("' alt='cgit logo'/></a></td>\n"); | 600 | html("' alt='cgit logo'/></a></td>\n"); |
596 | 601 | ||
597 | html("<td class='main'>"); | 602 | html("<td class='main'>"); |
598 | if (ctx->repo) { | 603 | if (ctx->repo) { |
599 | cgit_index_link("index", NULL, NULL, NULL, 0); | 604 | cgit_index_link("index", NULL, NULL, NULL, 0); |
600 | html(" : "); | 605 | html(" : "); |
601 | reporevlink(NULL, ctx->repo->name, NULL, hc(cmd, "summary"), | 606 | cgit_summary_link(ctx->repo->name, ctx->repo->name, NULL, NULL); |
602 | ctx->qry.head, NULL, NULL); | ||
603 | html("</td><td class='form'>"); | 607 | html("</td><td class='form'>"); |
604 | html("<form method='get' action=''>\n"); | 608 | html("<form method='get' action=''>\n"); |
605 | add_hidden_formfields(0, 1, ctx->qry.page); | 609 | add_hidden_formfields(0, 1, ctx->qry.page); |
606 | html("<select name='h' onchange='this.form.submit();'>\n"); | 610 | html("<select name='h' onchange='this.form.submit();'>\n"); |
607 | for_each_branch_ref(print_branch_option, ctx->qry.head); | 611 | for_each_branch_ref(print_branch_option, ctx->qry.head); |
608 | html("</select> "); | 612 | html("</select> "); |
609 | html("<input type='submit' name='' value='switch'/>"); | 613 | html("<input type='submit' name='' value='switch'/>"); |
610 | html("</form>"); | 614 | html("</form>"); |
611 | } else | 615 | } else |
612 | html_txt(ctx->cfg.root_title); | 616 | html_txt(ctx->cfg.root_title); |
613 | html("</td></tr>\n"); | 617 | html("</td></tr>\n"); |
614 | 618 | ||
615 | html("<tr><td class='sub'>"); | 619 | html("<tr><td class='sub'>"); |
616 | if (ctx->repo) { | 620 | if (ctx->repo) { |
617 | html_txt(ctx->repo->desc); | 621 | html_txt(ctx->repo->desc); |
618 | html("</td><td class='sub right'>"); | 622 | html("</td><td class='sub right'>"); |
619 | html_txt(ctx->repo->owner); | 623 | html_txt(ctx->repo->owner); |
620 | } else { | 624 | } else { |
621 | if (ctx->cfg.root_desc) | 625 | if (ctx->cfg.root_desc) |
622 | html_txt(ctx->cfg.root_desc); | 626 | html_txt(ctx->cfg.root_desc); |
623 | else if (ctx->cfg.index_info) | 627 | else if (ctx->cfg.index_info) |
624 | html_include(ctx->cfg.index_info); | 628 | html_include(ctx->cfg.index_info); |
625 | } | 629 | } |
626 | html("</td></tr></table>\n"); | 630 | html("</td></tr></table>\n"); |
627 | 631 | ||
628 | html("<table class='tabs'><tr><td>\n"); | 632 | html("<table class='tabs'><tr><td>\n"); |
629 | if (ctx->repo) { | 633 | if (ctx->repo) { |
630 | reporevlink(NULL, "summary", NULL, hc(cmd, "summary"), | 634 | cgit_summary_link(ctx->repo->name, ctx->repo->name, NULL, |
631 | ctx->qry.head, NULL, NULL); | 635 | ctx->qry.head); |
632 | cgit_refs_link("refs", NULL, hc(cmd, "refs"), ctx->qry.head, | 636 | cgit_refs_link("refs", NULL, hc(cmd, "refs"), ctx->qry.head, |
633 | ctx->qry.sha1, NULL); | 637 | ctx->qry.sha1, NULL); |
634 | cgit_log_link("log", NULL, hc(cmd, "log"), ctx->qry.head, | 638 | cgit_log_link("log", NULL, hc(cmd, "log"), ctx->qry.head, |
635 | NULL, NULL, 0, NULL, NULL); | 639 | NULL, NULL, 0, NULL, NULL); |
636 | cgit_tree_link("tree", NULL, hc(cmd, "tree"), ctx->qry.head, | 640 | cgit_tree_link("tree", NULL, hc(cmd, "tree"), ctx->qry.head, |
637 | ctx->qry.sha1, NULL); | 641 | ctx->qry.sha1, NULL); |
638 | cgit_commit_link("commit", NULL, hc(cmd, "commit"), | 642 | cgit_commit_link("commit", NULL, hc(cmd, "commit"), |
639 | ctx->qry.head, ctx->qry.sha1); | 643 | ctx->qry.head, ctx->qry.sha1); |
640 | cgit_diff_link("diff", NULL, hc(cmd, "diff"), ctx->qry.head, | 644 | cgit_diff_link("diff", NULL, hc(cmd, "diff"), ctx->qry.head, |
641 | ctx->qry.sha1, ctx->qry.sha2, NULL); | 645 | ctx->qry.sha1, ctx->qry.sha2, NULL); |
642 | if (ctx->repo->readme) | 646 | if (ctx->repo->readme) |
643 | reporevlink("about", "about", NULL, | 647 | reporevlink("about", "about", NULL, |
644 | hc(cmd, "about"), ctx->qry.head, NULL, | 648 | hc(cmd, "about"), ctx->qry.head, NULL, |
645 | NULL); | 649 | NULL); |
646 | html("</td><td class='form'>"); | 650 | html("</td><td class='form'>"); |
647 | html("<form class='right' method='get' action='"); | 651 | html("<form class='right' method='get' action='"); |