]> gitweb.ps.run Git - ps-cgit/blobdiff - ui-shared.c
Add support for 'section-from-path' option
[ps-cgit] / ui-shared.c
index d5c4c10e76c4d9188629242d1aa9b1e7a5ebb4b2..ae29615a32d04ac8c3e933815e61b64543fdecee 100644 (file)
@@ -319,7 +319,8 @@ void cgit_log_link(const char *name, const char *title, const char *class,
 }
 
 void cgit_commit_link(char *name, const char *title, const char *class,
-                     const char *head, const char *rev, int toggle_ssdiff)
+                     const char *head, const char *rev, const char *path,
+                     int toggle_ssdiff)
 {
        if (strlen(name) > ctx.cfg.max_msg_len && ctx.cfg.max_msg_len >= 15) {
                name[ctx.cfg.max_msg_len] = '\0';
@@ -330,7 +331,7 @@ void cgit_commit_link(char *name, const char *title, const char *class,
 
        char *delim;
 
-       delim = repolink(title, class, "commit", head, NULL);
+       delim = repolink(title, class, "commit", head, path);
        if (rev && strcmp(rev, ctx.qry.head)) {
                html(delim);
                html("id=");
@@ -340,6 +341,18 @@ void cgit_commit_link(char *name, const char *title, const char *class,
        if ((ctx.qry.ssdiff && !toggle_ssdiff) || (!ctx.qry.ssdiff && toggle_ssdiff)) {
                html(delim);
                html("ss=1");
+               delim = "&";
+       }
+       if (ctx.qry.context > 0 && ctx.qry.context != 3) {
+               html(delim);
+               html("context=");
+               htmlf("%d", ctx.qry.context);
+               delim = "&";
+       }
+       if (ctx.qry.ignorews) {
+               html(delim);
+               html("ignorews=1");
+               delim = "&";
        }
        html("'>");
        html_txt(name);
@@ -381,6 +394,18 @@ void cgit_diff_link(const char *name, const char *title, const char *class,
        if ((ctx.qry.ssdiff && !toggle_ssdiff) || (!ctx.qry.ssdiff && toggle_ssdiff)) {
                html(delim);
                html("ss=1");
+               delim = "&";
+       }
+       if (ctx.qry.context > 0 && ctx.qry.context != 3) {
+               html(delim);
+               html("context=");
+               htmlf("%d", ctx.qry.context);
+               delim = "&";
+       }
+       if (ctx.qry.ignorews) {
+               html(delim);
+               html("ignorews=1");
+               delim = "&";
        }
        html("'>");
        html_txt(name);
@@ -466,7 +491,7 @@ void cgit_object_link(struct object *obj)
        shortrev[10] = '\0';
        if (obj->type == OBJ_COMMIT) {
                 cgit_commit_link(fmt("commit %s...", shortrev), NULL, NULL,
-                                ctx.qry.head, fullrev, 0);
+                                ctx.qry.head, fullrev, NULL, 0);
                return;
        } else if (obj->type == OBJ_TREE)
                page = "tree";
@@ -789,16 +814,17 @@ void cgit_print_pageheader(struct cgit_context *ctx)
                cgit_refs_link("refs", NULL, hc(ctx, "refs"), ctx->qry.head,
                               ctx->qry.sha1, NULL);
                cgit_log_link("log", NULL, hc(ctx, "log"), ctx->qry.head,
-                             NULL, NULL, 0, NULL, NULL, ctx->qry.showmsg);
+                             NULL, ctx->qry.vpath, 0, NULL, NULL,
+                             ctx->qry.showmsg);
                cgit_tree_link("tree", NULL, hc(ctx, "tree"), ctx->qry.head,
-                              ctx->qry.sha1, NULL);
+                              ctx->qry.sha1, ctx->qry.vpath);
                cgit_commit_link("commit", NULL, hc(ctx, "commit"),
-                                ctx->qry.head, ctx->qry.sha1, 0);
+                                ctx->qry.head, ctx->qry.sha1, ctx->qry.vpath, 0);
                cgit_diff_link("diff", NULL, hc(ctx, "diff"), ctx->qry.head,
-                              ctx->qry.sha1, ctx->qry.sha2, NULL, 0);
+                              ctx->qry.sha1, ctx->qry.sha2, ctx->qry.vpath, 0);
                if (ctx->repo->max_stats)
                        cgit_stats_link("stats", NULL, hc(ctx, "stats"),
-                                       ctx->qry.head, NULL);
+                                       ctx->qry.head, ctx->qry.vpath);
                if (ctx->repo->readme)
                        reporevlink("about", "about", NULL,
                                    hc(ctx, "about"), ctx->qry.head, NULL,
@@ -814,6 +840,7 @@ void cgit_print_pageheader(struct cgit_context *ctx)
                html_option("grep", "log msg", ctx->qry.grep);
                html_option("author", "author", ctx->qry.grep);
                html_option("committer", "committer", ctx->qry.grep);
+               html_option("range", "range", ctx->qry.grep);
                html("</select>\n");
                html("<input class='txt' type='text' size='10' name='q' value='");
                html_attr(ctx->qry.search);