]> gitweb.ps.run Git - ps-cgit/commitdiff
Merge branch 'stable'
authorLars Hjemli <hjemli@gmail.com>
Sun, 11 Jan 2009 21:00:25 +0000 (22:00 +0100)
committerLars Hjemli <hjemli@gmail.com>
Sun, 11 Jan 2009 21:00:25 +0000 (22:00 +0100)
1  2 
cgit.c
ui-shared.c

diff --combined cgit.c
index d1cee580cd6fe064993da8bd04acdf9f3325042b,6e5215e3b08edcbc5c09b9faf22a753762d0767c..f35f6059e1531ad6408b3ec3d638be81643bed58
--- 1/cgit.c
--- 2/cgit.c
+++ b/cgit.c
@@@ -154,10 -154,6 +154,10 @@@ static void querystring_cb(const char *
                ctx.qry.name = xstrdup(value);
        } else if (!strcmp(name, "mimetype")) {
                ctx.qry.mimetype = xstrdup(value);
 +      } else if (!strcmp(name, "s")){
 +              ctx.qry.sort = xstrdup(value);
 +      } else if (!strcmp(name, "showmsg")) {
 +              ctx.qry.showmsg = atoi(value);
        }
  }
  
@@@ -293,7 -289,6 +293,6 @@@ static void process_request(void *cbdat
        cmd = cgit_get_cmd(ctx);
        if (!cmd) {
                ctx->page.title = "cgit error";
-               ctx->repo = NULL;
                cgit_print_http_headers(ctx);
                cgit_print_docstart(ctx);
                cgit_print_pageheader(ctx);
@@@ -439,29 -434,28 +438,29 @@@ int main(int argc, const char **argv
        ctx.repo = NULL;
        http_parse_querystring(ctx.qry.raw, querystring_cb);
  
 -      /* If virtual-root isn't specified in cgitrc and no url
 -       * parameter is specified on the querystring, lets pretend
 -       * that virtualroot equals SCRIPT_NAME and use PATH_INFO as
 -       * url. This allows cgit to work with virtual urls without
 -       * the need for rewriterules in the webserver (as long as
 -       * PATH_INFO is included in the cache lookup key).
 +      /* If virtual-root isn't specified in cgitrc, lets pretend
 +       * that virtual-root equals SCRIPT_NAME.
         */
 -      if (!ctx.cfg.virtual_root && !ctx.qry.url) {
 +      if (!ctx.cfg.virtual_root)
                ctx.cfg.virtual_root = ctx.cfg.script_name;
 -              path = getenv("PATH_INFO");
 -              if (path) {
 -                      if (path[0] == '/')
 -                              path++;
 -                      ctx.qry.url = xstrdup(path);
 -                      if (ctx.qry.raw) {
 -                              qry = ctx.qry.raw;
 -                              ctx.qry.raw = xstrdup(fmt("%s?%s", path, qry));
 -                              free(qry);
 -                      } else
 -                              ctx.qry.raw = ctx.qry.url;
 -                      cgit_parse_url(ctx.qry.url);
 -              }
 +
 +      /* If no url parameter is specified on the querystring, lets
 +       * use PATH_INFO as url. This allows cgit to work with virtual
 +       * urls without the need for rewriterules in the webserver (as
 +       * long as PATH_INFO is included in the cache lookup key).
 +       */
 +      path = getenv("PATH_INFO");
 +      if (!ctx.qry.url && path) {
 +              if (path[0] == '/')
 +                      path++;
 +              ctx.qry.url = xstrdup(path);
 +              if (ctx.qry.raw) {
 +                      qry = ctx.qry.raw;
 +                      ctx.qry.raw = xstrdup(fmt("%s?%s", path, qry));
 +                      free(qry);
 +              } else
 +                      ctx.qry.raw = ctx.qry.url;
 +              cgit_parse_url(ctx.qry.url);
        }
  
        ttl = calc_ttl();
diff --combined ui-shared.c
index 95dfeb443e7b41ad2bf438a93396bc90adebc38e,76cd00d3b146a8a1401f7e3be7b6fcaacc48dab3..fba1ba6dba56a4eab7381c1cbf0065a2c641fefa
@@@ -281,8 -281,7 +281,8 @@@ void cgit_plain_link(char *name, char *
  }
  
  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;
  
                html(delim);
                html("ofs=");
                htmlf("%d", ofs);
 +              delim = "&";
 +      }
 +      if (showmsg) {
 +              html(delim);
 +              html("showmsg=1");
        }
        html("'>");
        html_txt(name);
@@@ -371,14 -365,11 +371,14 @@@ void cgit_patch_link(char *name, char *
  
  void cgit_object_link(struct object *obj)
  {
 -      char *page, *rev, *name;
 +      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)
                page = "tree";
                page = "tag";
        else
                page = "blob";
 -      rev = sha1_to_hex(obj->sha1);
 -      name = fmt("%s %s", typename(obj->type), rev);
 -      reporevlink(page, name, NULL, NULL, ctx.qry.head, rev, NULL);
 +      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)
@@@ -576,8 -568,6 +576,8 @@@ void add_hidden_formfields(int incl_hea
                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)
        }
  }
  
+ const char *fallback_cmd = "repolist";
  char *hc(struct cgit_cmd *cmd, const char *page)
  {
-       return (strcmp(cmd->name, page) ? NULL : "active");
+       return (strcmp(cmd ? cmd->name : fallback_cmd, page) ? NULL : "active");
  }
  
  void cgit_print_pageheader(struct cgit_context *ctx)
  {
        struct cgit_cmd *cmd = cgit_get_cmd(ctx);
  
+       if (!cmd && ctx->repo)
+               fallback_cmd = "summary";
        html("<table id='header'>\n");
        html("<tr>\n");
        html("<td class='logo' rowspan='2'><a href='");
                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"),
@@@ -717,7 -712,8 +722,7 @@@ void cgit_print_snapshot_links(const ch
                        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/>");
        }
  }