]> git.cameronkatri.com Git - cgit.git/blobdiff - ui-shared.c
Untie logic for SCRIPT_NAME and PATH_INFO
[cgit.git] / ui-shared.c
index ee3f6fefef3578391e7ba354f007884bf6baec04..95dfeb443e7b41ad2bf438a93396bc90adebc38e 100644 (file)
@@ -262,6 +262,12 @@ void cgit_summary_link(char *name, char *title, char *class, char *head)
        reporevlink(NULL, name, title, class, head, NULL, NULL);
 }
 
+void cgit_tag_link(char *name, char *title, char *class, char *head,
+                  char *rev)
+{
+       reporevlink("tag", name, title, class, head, rev, NULL);
+}
+
 void cgit_tree_link(char *name, char *title, char *class, char *head,
                    char *rev, char *path)
 {
@@ -275,7 +281,8 @@ void cgit_plain_link(char *name, char *title, char *class, char *head,
 }
 
 void cgit_log_link(char *name, char *title, char *class, char *head,
-                  char *rev, char *path, int ofs, char *grep, char *pattern)
+                  char *rev, char *path, int ofs, char *grep, char *pattern,
+                  int showmsg)
 {
        char *delim;
 
@@ -299,6 +306,11 @@ void cgit_log_link(char *name, char *title, char *class, char *head,
                html(delim);
                html("ofs=");
                htmlf("%d", ofs);
+               delim = "&";
+       }
+       if (showmsg) {
+               html(delim);
+               html("showmsg=1");
        }
        html("'>");
        html_txt(name);
@@ -359,29 +371,23 @@ void cgit_patch_link(char *name, char *title, char *class, char *head,
 
 void cgit_object_link(struct object *obj)
 {
-       char *page, *arg, *url;
+       char *page, *shortrev, *fullrev, *name;
 
+       fullrev = sha1_to_hex(obj->sha1);
+       shortrev = xstrdup(fullrev);
+       shortrev[10] = '\0';
        if (obj->type == OBJ_COMMIT) {
-                cgit_commit_link(fmt("commit %s", sha1_to_hex(obj->sha1)), NULL, NULL,
-                                ctx.qry.head, sha1_to_hex(obj->sha1));
+                cgit_commit_link(fmt("commit %s...", shortrev), NULL, NULL,
+                                ctx.qry.head, fullrev);
                return;
-       } else if (obj->type == OBJ_TREE) {
+       } else if (obj->type == OBJ_TREE)
                page = "tree";
-               arg = "id";
-       } else if (obj->type == OBJ_TAG) {
+       else if (obj->type == OBJ_TAG)
                page = "tag";
-               arg = "id";
-       } else {
+       else
                page = "blob";
-               arg = "id";
-       }
-
-       url = cgit_pageurl(ctx.qry.repo, page,
-                          fmt("%s=%s", arg, sha1_to_hex(obj->sha1)));
-       html_link_open(url, NULL, NULL);
-       htmlf("%s %s", typename(obj->type),
-             sha1_to_hex(obj->sha1));
-       html_link_close();
+       name = fmt("%s %s...", typename(obj->type), shortrev);
+       reporevlink(page, name, NULL, NULL, ctx.qry.head, fullrev, NULL);
 }
 
 void cgit_print_date(time_t secs, char *format, int local_time)
@@ -496,9 +502,9 @@ void cgit_print_docend()
        if (ctx.cfg.footer)
                html_include(ctx.cfg.footer);
        else {
-               html("<div class='footer'>generated ");
+               htmlf("<div class='footer'>generated  by cgit %s at ",
+                       cgit_version);
                cgit_print_date(time(NULL), FMT_LONGDATE, ctx.cfg.local_time);
-               htmlf(" by cgit %s", cgit_version);
                html("</div>\n");
        }
        html("</body>\n</html>\n");
@@ -570,6 +576,8 @@ void add_hidden_formfields(int incl_head, int incl_search, char *page)
                html_hidden("id", ctx.qry.sha1);
        if (ctx.qry.sha2)
                html_hidden("id2", ctx.qry.sha2);
+       if (ctx.qry.showmsg)
+               html_hidden("showmsg", "1");
 
        if (incl_search) {
                if (ctx.qry.grep)
@@ -603,8 +611,7 @@ void cgit_print_pageheader(struct cgit_context *ctx)
        if (ctx->repo) {
                cgit_index_link("index", NULL, NULL, NULL, 0);
                html(" : ");
-               reporevlink(NULL, ctx->repo->name, NULL, hc(cmd, "summary"),
-                           ctx->qry.head, NULL, NULL);
+               cgit_summary_link(ctx->repo->name, ctx->repo->name, NULL, NULL);
                html("</td><td class='form'>");
                html("<form method='get' action=''>\n");
                add_hidden_formfields(0, 1, ctx->qry.page);
@@ -632,12 +639,12 @@ void cgit_print_pageheader(struct cgit_context *ctx)
 
        html("<table class='tabs'><tr><td>\n");
        if (ctx->repo) {
-               reporevlink(NULL, "summary", NULL, hc(cmd, "summary"),
-                           ctx->qry.head, NULL, NULL);
+               cgit_summary_link("summary", NULL, hc(cmd, "summary"),
+                                 ctx->qry.head);
                cgit_refs_link("refs", NULL, hc(cmd, "refs"), ctx->qry.head,
                               ctx->qry.sha1, NULL);
                cgit_log_link("log", NULL, hc(cmd, "log"), ctx->qry.head,
-                             NULL, NULL, 0, NULL, NULL);
+                             NULL, NULL, 0, NULL, NULL, ctx->qry.showmsg);
                cgit_tree_link("tree", NULL, hc(cmd, "tree"), ctx->qry.head,
                               ctx->qry.sha1, NULL);
                cgit_commit_link("commit", NULL, hc(cmd, "commit"),
@@ -651,8 +658,8 @@ void cgit_print_pageheader(struct cgit_context *ctx)
                html("</td><td class='form'>");
                html("<form class='right' method='get' action='");
                if (ctx->cfg.virtual_root)
-                       html_attr(cgit_fileurl(ctx->qry.repo, "log",
-                                              ctx->qry.path, NULL));
+                       html_url_path(cgit_fileurl(ctx->qry.repo, "log",
+                                                  ctx->qry.path, NULL));
                html("'>\n");
                add_hidden_formfields(1, 0, "log");
                html("<select name='qt'>\n");
@@ -710,8 +717,7 @@ void cgit_print_snapshot_links(const char *repo, const char *head,
                        continue;
                filename = fmt("%s-%s%s", cgit_repobasename(repo), hex,
                               f->suffix);
-               cgit_snapshot_link(filename, NULL, NULL, (char *)head,
-                                  (char *)hex, filename);
+               cgit_snapshot_link(filename, NULL, NULL, NULL, NULL, filename);
                html("<br/>");
        }
 }