]> gitweb.ps.run Git - ps-cgit/commitdiff
Merge branch 'wip'
authorJason A. Donenfeld <Jason@zx2c4.com>
Wed, 20 Mar 2013 19:21:25 +0000 (20:21 +0100)
committerJason A. Donenfeld <Jason@zx2c4.com>
Wed, 20 Mar 2013 19:21:25 +0000 (20:21 +0100)
1  2 
ui-shared.c

diff --combined ui-shared.c
index 80f4aee1e9aa213b2323855f8cb77a35598015c3,d3e64882109a2d0ef2408ca55aeebf4d0d1922d8..968933fe5e7dc1f7e2673aefe88df80fded519e6
@@@ -121,18 -121,6 +121,6 @@@ const char *cgit_repobasename(const cha
        return rvbuf;
  }
  
- char *cgit_currurl()
- {
-       if (!ctx.cfg.virtual_root)
-               return ctx.cfg.script_name;
-       else if (ctx.qry.page)
-               return fmt("%s/%s/%s/", ctx.cfg.virtual_root, ctx.qry.repo, ctx.qry.page);
-       else if (ctx.qry.repo)
-               return fmt("%s/%s/", ctx.cfg.virtual_root, ctx.qry.repo);
-       else
-               return fmt("%s/", ctx.cfg.virtual_root);
- }
  static void site_url(const char *page, const char *search, const char *sort, int ofs)
  {
        char *delim = "?";
@@@ -433,63 -421,62 +421,63 @@@ void cgit_stats_link(const char *name, 
        reporevlink("stats", name, title, class, head, NULL, path);
  }
  
- void cgit_self_link(char *name, const char *title, const char *class,
-                   struct cgit_context *ctx)
static void cgit_self_link(char *name, const char *title, const char *class,
+                          struct cgit_context *ctx)
  {
        if (!strcmp(ctx->qry.page, "repolist"))
 -              return cgit_index_link(name, title, class, ctx->qry.search, ctx->qry.sort,
 -                                     ctx->qry.ofs);
 +              cgit_index_link(name, title, class, ctx->qry.search, ctx->qry.sort,
 +                              ctx->qry.ofs);
        else if (!strcmp(ctx->qry.page, "summary"))
 -              return cgit_summary_link(name, title, class, ctx->qry.head);
 +              cgit_summary_link(name, title, class, ctx->qry.head);
        else if (!strcmp(ctx->qry.page, "tag"))
 -              return cgit_tag_link(name, title, class, ctx->qry.head,
 -                                   ctx->qry.has_sha1 ? ctx->qry.sha1 : NULL);
 +              cgit_tag_link(name, title, class, ctx->qry.head,
 +                            ctx->qry.has_sha1 ? ctx->qry.sha1 : NULL);
        else if (!strcmp(ctx->qry.page, "tree"))
 -              return cgit_tree_link(name, title, class, ctx->qry.head,
 -                                    ctx->qry.has_sha1 ? ctx->qry.sha1 : NULL,
 -                                    ctx->qry.path);
 +              cgit_tree_link(name, title, class, ctx->qry.head,
 +                             ctx->qry.has_sha1 ? ctx->qry.sha1 : NULL,
 +                             ctx->qry.path);
        else if (!strcmp(ctx->qry.page, "plain"))
 -              return cgit_plain_link(name, title, class, ctx->qry.head,
 -                                    ctx->qry.has_sha1 ? ctx->qry.sha1 : NULL,
 -                                    ctx->qry.path);
 +              cgit_plain_link(name, title, class, ctx->qry.head,
 +                              ctx->qry.has_sha1 ? ctx->qry.sha1 : NULL,
 +                              ctx->qry.path);
        else if (!strcmp(ctx->qry.page, "log"))
 -              return cgit_log_link(name, title, class, ctx->qry.head,
 -                                    ctx->qry.has_sha1 ? ctx->qry.sha1 : NULL,
 -                                    ctx->qry.path, ctx->qry.ofs,
 -                                    ctx->qry.grep, ctx->qry.search,
 -                                    ctx->qry.showmsg);
 +              cgit_log_link(name, title, class, ctx->qry.head,
 +                            ctx->qry.has_sha1 ? ctx->qry.sha1 : NULL,
 +                            ctx->qry.path, ctx->qry.ofs,
 +                            ctx->qry.grep, ctx->qry.search,
 +                            ctx->qry.showmsg);
        else if (!strcmp(ctx->qry.page, "commit"))
 -              return cgit_commit_link(name, title, class, ctx->qry.head,
 -                                    ctx->qry.has_sha1 ? ctx->qry.sha1 : NULL,
 -                                    ctx->qry.path, 0);
 +              cgit_commit_link(name, title, class, ctx->qry.head,
 +                               ctx->qry.has_sha1 ? ctx->qry.sha1 : NULL,
 +                               ctx->qry.path, 0);
        else if (!strcmp(ctx->qry.page, "patch"))
 -              return cgit_patch_link(name, title, class, ctx->qry.head,
 -                                    ctx->qry.has_sha1 ? ctx->qry.sha1 : NULL,
 -                                    ctx->qry.path);
 +              cgit_patch_link(name, title, class, ctx->qry.head,
 +                              ctx->qry.has_sha1 ? ctx->qry.sha1 : NULL,
 +                              ctx->qry.path);
        else if (!strcmp(ctx->qry.page, "refs"))
 -              return cgit_refs_link(name, title, class, ctx->qry.head,
 -                                    ctx->qry.has_sha1 ? ctx->qry.sha1 : NULL,
 -                                    ctx->qry.path);
 +              cgit_refs_link(name, title, class, ctx->qry.head,
 +                             ctx->qry.has_sha1 ? ctx->qry.sha1 : NULL,
 +                             ctx->qry.path);
        else if (!strcmp(ctx->qry.page, "snapshot"))
 -              return cgit_snapshot_link(name, title, class, ctx->qry.head,
 -                                    ctx->qry.has_sha1 ? ctx->qry.sha1 : NULL,
 -                                    ctx->qry.path);
 +              cgit_snapshot_link(name, title, class, ctx->qry.head,
 +                                 ctx->qry.has_sha1 ? ctx->qry.sha1 : NULL,
 +                                 ctx->qry.path);
        else if (!strcmp(ctx->qry.page, "diff"))
 -              return cgit_diff_link(name, title, class, ctx->qry.head,
 -                                    ctx->qry.sha1, ctx->qry.sha2,
 -                                    ctx->qry.path, 0);
 +              cgit_diff_link(name, title, class, ctx->qry.head,
 +                             ctx->qry.sha1, ctx->qry.sha2,
 +                             ctx->qry.path, 0);
        else if (!strcmp(ctx->qry.page, "stats"))
 -              return cgit_stats_link(name, title, class, ctx->qry.head,
 -                                    ctx->qry.path);
 -
 -      /* Don't known how to make link for this page */
 -      repolink(title, class, ctx->qry.page, ctx->qry.head, ctx->qry.path);
 -      html("><!-- cgit_self_link() doesn't know how to make link for page '");
 -      html_txt(ctx->qry.page);
 -      html("' -->");
 -      html_txt(name);
 -      html("</a>");
 +              cgit_stats_link(name, title, class, ctx->qry.head,
 +                              ctx->qry.path);
 +      else {
 +              /* Don't known how to make link for this page */
 +              repolink(title, class, ctx->qry.page, ctx->qry.head, ctx->qry.path);
 +              html("><!-- cgit_self_link() doesn't know how to make link for page '");
 +              html_txt(ctx->qry.page);
 +              html("' -->");
 +              html_txt(name);
 +              html("</a>");
 +      }
  }
  
  void cgit_object_link(struct object *obj)
        reporevlink(page, name, NULL, NULL, ctx.qry.head, fullrev, NULL);
  }
  
- struct string_list_item *lookup_path(struct string_list *list,
-                                    const char *path)
+ static struct string_list_item *lookup_path(struct string_list *list,
+                                           const char *path)
  {
        struct string_list_item *item;
  
@@@ -717,53 -704,14 +705,14 @@@ void cgit_print_docend(
        html("</body>\n</html>\n");
  }
  
- int print_branch_option(const char *refname, const unsigned char *sha1,
-                       int flags, void *cb_data)
static int print_branch_option(const char *refname, const unsigned char *sha1,
+                              int flags, void *cb_data)
  {
        char *name = (char *)refname;
        html_option(name, name, ctx.qry.head);
        return 0;
  }
  
- int print_archive_ref(const char *refname, const unsigned char *sha1,
-                      int flags, void *cb_data)
- {
-       struct tag *tag;
-       struct taginfo *info;
-       struct object *obj;
-       char buf[256], *url;
-       unsigned char fileid[20];
-       int *header = (int *)cb_data;
-       if (prefixcmp(refname, "refs/archives"))
-               return 0;
-       strncpy(buf, refname + 14, sizeof(buf));
-       obj = parse_object(sha1);
-       if (!obj)
-               return 1;
-       if (obj->type == OBJ_TAG) {
-               tag = lookup_tag(sha1);
-               if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag)))
-                       return 0;
-               hashcpy(fileid, tag->tagged->sha1);
-       } else if (obj->type != OBJ_BLOB) {
-               return 0;
-       } else {
-               hashcpy(fileid, sha1);
-       }
-       if (!*header) {
-               html("<h1>download</h1>\n");
-               *header = 1;
-       }
-       url = cgit_pageurl(ctx.qry.repo, "blob",
-                          fmt("id=%s&amp;path=%s", sha1_to_hex(fileid),
-                              buf));
-       html_link_open(url, NULL, "menu");
-       html_txt(strlpart(buf, 20));
-       html_link_close();
-       return 0;
- }
  void cgit_add_hidden_formfields(int incl_head, int incl_search,
                                const char *page)
  {
@@@ -983,4 -931,5 +932,5 @@@ void cgit_print_snapshot_links(const ch
                cgit_snapshot_link(filename, NULL, NULL, NULL, NULL, filename);
                html("<br/>");
        }
+       free(prefix);
  }