| @@ -246,6 +246,61 @@ static char *repolink(const char *title, const char *class, const char *page, · 245 unmodified lines |
| 246 | return fmt("%s", delim); | 246 | return fmt("%s", delim); |
| 247 | } | 247 | } |
| 248 | | 248 | |
| | 249 | static char *repolink2(const char *title, const char *class, const char *page, |
| | 250 | const char *head, const char *path, int lineno) |
| | 251 | { |
| | 252 | char *delim = "?"; |
| | 253 | |
| | 254 | html("<a"); |
| | 255 | if (title) { |
| | 256 | html(" title='"); |
| | 257 | html_attr(title); |
| | 258 | html("'"); |
| | 259 | } |
| | 260 | if (class) { |
| | 261 | html(" class='"); |
| | 262 | html_attr(class); |
| | 263 | html("'"); |
| | 264 | } |
| | 265 | html(" href='"); |
| | 266 | if (ctx.cfg.virtual_root) { |
| | 267 | html_url_path(ctx.cfg.virtual_root); |
| | 268 | if (ctx.cfg.virtual_root[strlen(ctx.cfg.virtual_root) - 1] != '/') |
| | 269 | html("/"); |
| | 270 | html_url_path(ctx.repo->url); |
| | 271 | if (ctx.repo->url[strlen(ctx.repo->url) - 1] != '/') |
| | 272 | html("/"); |
| | 273 | if (page) { |
| | 274 | html_url_path(page); |
| | 275 | html("/"); |
| | 276 | if (path) |
| | 277 | html_url_path(path); |
| | 278 | } |
| | 279 | } else { |
| | 280 | html(ctx.cfg.script_name); |
| | 281 | html("?url="); |
| | 282 | html_url_arg(ctx.repo->url); |
| | 283 | if (ctx.repo->url[strlen(ctx.repo->url) - 1] != '/') |
| | 284 | html("/"); |
| | 285 | if (page) { |
| | 286 | html_url_arg(page); |
| | 287 | html("/"); |
| | 288 | if (path) |
| | 289 | html_url_arg(path); |
| | 290 | } |
| | 291 | delim = "&"; |
| | 292 | } |
| | 293 | if (head && strcmp(head, ctx.repo->defbranch)) { |
| | 294 | html(delim); |
| | 295 | html("h="); |
| | 296 | html_url_arg(head); |
| | 297 | delim = "&"; |
| | 298 | } |
| | 299 | if (lineno) |
| | 300 | htmlf("#n%d", lineno); |
| | 301 | return fmt("%s", delim); |
| | 302 | } |
| | 303 | |
| 249 | static void reporevlink(const char *page, const char *name, const char *title, | 304 | static void reporevlink(const char *page, const char *name, const char *title, |
| 250 | const char *class, const char *head, const char *rev, | 305 | const char *class, const char *head, const char *rev, |
| 251 | const char *path) | 306 | const char *path) |
| @@ -263,6 +318,23 @@ static void reporevlink(const char *page, const char *name, const char *title, · 11 unmodified lines |
| 263 | html("</a>"); | 318 | html("</a>"); |
| 264 | } | 319 | } |
| 265 | | 320 | |
| | 321 | static void reporevlink2(const char *page, const char *name, const char *title, |
| | 322 | const char *class, const char *head, const char *rev, |
| | 323 | const char *path, int lineno) |
| | 324 | { |
| | 325 | char *delim; |
| | 326 | |
| | 327 | delim = repolink2(title, class, page, head, path, lineno); |
| | 328 | if (rev && ctx.qry.head != NULL && strcmp(rev, ctx.qry.head)) { |
| | 329 | html(delim); |
| | 330 | html("id="); |
| | 331 | html_url_arg(rev); |
| | 332 | } |
| | 333 | html("'>"); |
| | 334 | html_txt(name); |
| | 335 | html("</a>"); |
| | 336 | } |
| | 337 | |
| 266 | void cgit_summary_link(const char *name, const char *title, const char *class, | 338 | void cgit_summary_link(const char *name, const char *title, const char *class, |
| 267 | const char *head) | 339 | const char *head) |
| 268 | { | 340 | { |
| @@ -281,6 +353,13 @@ void cgit_tree_link(const char *name, const char *title, const char *class, · 12 unmodified lines |
| 281 | reporevlink("tree", name, title, class, head, rev, path); | 353 | reporevlink("tree", name, title, class, head, rev, path); |
| 282 | } | 354 | } |
| 283 | | 355 | |
| | 356 | void cgit_tree_link2(const char *name, const char *title, const char *class, |
| | 357 | const char *head, const char *rev, const char *path, |
| | 358 | int lineno) |
| | 359 | { |
| | 360 | reporevlink2("tree", name, title, class, head, rev, path, lineno); |
| | 361 | } |
| | 362 | |
| 284 | void cgit_plain_link(const char *name, const char *title, const char *class, | 363 | void cgit_plain_link(const char *name, const char *title, const char *class, |
| 285 | const char *head, const char *rev, const char *path) | 364 | const char *head, const char *rev, const char *path) |
| 286 | { | 365 | { |
| @@ -875,6 +954,9 @@ static void print_header(struct cgit_context *ctx) · 588 unmodified lines |
| 875 | | 954 | |
| 876 | void cgit_print_pageheader(struct cgit_context *ctx) | 955 | void cgit_print_pageheader(struct cgit_context *ctx) |
| 877 | { | 956 | { |
| | 957 | int tree; |
| | 958 | char *page; |
| | 959 | |
| 878 | html("<div id='cgit'>"); | 960 | html("<div id='cgit'>"); |
| 879 | if (!ctx->cfg.noheader) | 961 | if (!ctx->cfg.noheader) |
| 880 | print_header(ctx); | 962 | print_header(ctx); |
| @@ -903,16 +985,23 @@ void cgit_print_pageheader(struct cgit_context *ctx) · 22 unmodified lines |
| 903 | NULL); | 985 | NULL); |
| 904 | html("</td><td class='form'>"); | 986 | html("</td><td class='form'>"); |
| 905 | html("<form class='right' method='get' action='"); | 987 | html("<form class='right' method='get' action='"); |
| 906 | if (ctx->cfg.virtual_root) | 988 | if (ctx->cfg.virtual_root) { |
| 907 | html_url_path(cgit_fileurl(ctx->qry.repo, "log", | 989 | tree = !strcmp(ctx->qry.page, "tree"); |
| | 990 | page = tree ? "tree" : "log"; |
| | 991 | html_url_path(cgit_fileurl(ctx->qry.repo, page, |
| 908 | ctx->qry.vpath, NULL)); | 992 | ctx->qry.vpath, NULL)); |
| | 993 | } |
| 909 | html("'>\n"); | 994 | html("'>\n"); |
| 910 | cgit_add_hidden_formfields(1, 0, "log"); | 995 | cgit_add_hidden_formfields(1, 0, page); |
| 911 | html("<select name='qt'>\n"); | 996 | html("<select name='qt'>\n"); |
| 912 | html_option("grep", "log msg", ctx->qry.grep); | 997 | if (tree) { |
| 913 | html_option("author", "author", ctx->qry.grep); | 998 | html_option("grep", "source", ctx->qry.grep); |
| 914 | html_option("committer", "committer", ctx->qry.grep); | 999 | } else { |
| 915 | html_option("range", "range", ctx->qry.grep); | 1000 | html_option("grep", "log msg", ctx->qry.grep); |
| | 1001 | html_option("author", "author", ctx->qry.grep); |
| | 1002 | html_option("committer", "committer", ctx->qry.grep); |
| | 1003 | html_option("range", "range", ctx->qry.grep); |
| | 1004 | } |
| 916 | html("</select>\n"); | 1005 | html("</select>\n"); |
| 917 | html("<input class='txt' type='text' size='10' name='q' value='"); | 1006 | html("<input class='txt' type='text' size='10' name='q' value='"); |
| 918 | html_attr(ctx->qry.search); | 1007 | html_attr(ctx->qry.search); |