]> git.cameronkatri.com Git - cgit.git/commitdiff
Merge branch 'lh/menu'
authorLars Hjemli <hjemli@gmail.com>
Fri, 29 Jun 2007 18:32:08 +0000 (20:32 +0200)
committerLars Hjemli <hjemli@gmail.com>
Fri, 29 Jun 2007 18:32:08 +0000 (20:32 +0200)
* lh/menu:
  Add ofs argument to cgit_log_link and use it in ui-log.c
  Add trim_end() and use it to remove trailing slashes from repo paths
  Do not include current path in the "tree" menu link
  Add setting to enable/disable extra links on index page
  Change S/L/T to summary/log/tree
  Change "files" to "tree"
  Include querystring as part of cached filename for repo summary page
  Add more menuitems on repo pages

1  2 
cgit.c
cgit.h
shared.c
ui-shared.c

diff --combined cgit.c
index 11dff767e7c9f57cbbb1772829dacbcf3b0b322e,b943fe5769ce56644d5b5ac54c43da0d15be8e7d..d9a03c2773e88ca0a65eadc97183e0197e0524ba
--- 1/cgit.c
--- 2/cgit.c
+++ b/cgit.c
@@@ -8,6 -8,9 +8,6 @@@
  
  #include "cgit.h"
  
 -const char cgit_version[] = CGIT_VERSION;
 -
 -
  static int cgit_prepare_cache(struct cacheitem *item)
  {
        if (!cgit_repo && cgit_query_repo) {
        }
  
        if (!cgit_cmd) {
-               item->name = xstrdup(fmt("%s/%s/index.html", cgit_cache_root,
-                          cache_safe_filename(cgit_repo->url)));
+               item->name = xstrdup(fmt("%s/%s/index.%s.html", cgit_cache_root,
+                                        cache_safe_filename(cgit_repo->url),
+                                        cache_safe_filename(cgit_querystring)));
                item->ttl = cgit_cache_repo_ttl;
        } else {
                item->name = xstrdup(fmt("%s/%s/%s/%s.html", cgit_cache_root,
-                          cache_safe_filename(cgit_repo->url), cgit_query_page,
-                          cache_safe_filename(cgit_querystring)));
+                                        cache_safe_filename(cgit_repo->url),
+                                        cgit_query_page,
+                                        cache_safe_filename(cgit_querystring)));
                if (cgit_query_has_symref)
                        item->ttl = cgit_cache_dynamic_ttl;
                else if (cgit_query_has_sha1)
diff --combined cgit.h
index 95583620d966cee311dfd620fc481b1763856894,a59a3706f35c64a4cd5b412ab93703ba0963f29a..2ff5340d9d755a17fbc428f15083cc01f52caa5b
--- 1/cgit.h
--- 2/cgit.h
+++ b/cgit.h
@@@ -98,7 -98,7 +98,7 @@@ struct taginfo 
        char *msg;
  };
  
 -extern const char cgit_version[];
 +extern const char *cgit_version;
  
  extern struct repolist cgit_repolist;
  extern struct repoinfo *cgit_repo;
@@@ -118,6 -118,7 +118,7 @@@ extern char *cgit_repo_group
  
  extern int cgit_nocache;
  extern int cgit_snapshots;
+ extern int cgit_enable_index_links;
  extern int cgit_enable_log_filecount;
  extern int cgit_enable_log_linecount;
  extern int cgit_max_lock_attempts;
@@@ -158,6 -159,7 +159,7 @@@ extern int chk_zero(int result, char *m
  extern int chk_positive(int result, char *msg);
  
  extern int hextoint(char c);
+ extern char *trim_end(const char *str, char c);
  
  extern void *cgit_free_commitinfo(struct commitinfo *info);
  
@@@ -204,7 -206,7 +206,7 @@@ extern char *cgit_pageurl(const char *r
  extern void cgit_tree_link(char *name, char *title, char *class, char *head,
                           char *rev, char *path);
  extern void cgit_log_link(char *name, char *title, char *class, char *head,
-                         char *rev, char *path);
+                         char *rev, char *path, int ofs);
  extern void cgit_commit_link(char *name, char *title, char *class, char *head,
                             char *rev);
  extern void cgit_diff_link(char *name, char *title, char *class, char *head,
diff --combined shared.c
index f7f43b2e8e083d4c7ba5c15fc8b5d4e36e8d2819,45db735ed39f1a7ba20dce0618f11eecfb08ddc2..1a5b866e86630df4964961086edbb0ea1ec0d48e
+++ b/shared.c
@@@ -12,8 -12,6 +12,8 @@@ struct repolist cgit_repolist
  struct repoinfo *cgit_repo;
  int cgit_cmd;
  
 +const char *cgit_version = CGIT_VERSION;
 +
  char *cgit_root_title   = "Git repository browser";
  char *cgit_css          = "/cgit.css";
  char *cgit_logo         = "/git-logo.png";
@@@ -28,6 -26,7 +28,7 @@@ char *cgit_repo_group   = NULL
  
  int cgit_nocache               =  0;
  int cgit_snapshots             =  0;
+ int cgit_enable_index_links    =  0;
  int cgit_enable_log_filecount  =  0;
  int cgit_enable_log_linecount  =  0;
  int cgit_max_lock_attempts     =  5;
@@@ -148,6 -147,8 +149,8 @@@ void cgit_global_config_cb(const char *
                cgit_nocache = atoi(value);
        else if (!strcmp(name, "snapshots"))
                cgit_snapshots = atoi(value);
+       else if (!strcmp(name, "enable-index-links"))
+               cgit_enable_index_links = atoi(value);
        else if (!strcmp(name, "enable-log-filecount"))
                cgit_enable_log_filecount = atoi(value);
        else if (!strcmp(name, "enable-log-linecount"))
@@@ -227,7 -228,7 +230,7 @@@ void cgit_querystring_cb(const char *na
        } else if (!strcmp(name, "ofs")) {
                cgit_query_ofs = atoi(value);
        } else if (!strcmp(name, "path")) {
-               cgit_query_path = xstrdup(value);
+               cgit_query_path = trim_end(value, '/');
        } else if (!strcmp(name, "name")) {
                cgit_query_name = xstrdup(value);
        }
@@@ -256,6 -257,28 +259,28 @@@ int hextoint(char c
                return -1;
  }
  
+ char *trim_end(const char *str, char c)
+ {
+       int len;
+       char *s, *t;
+       if (str == NULL)
+               return NULL;
+       t = (char *)str;
+       len = strlen(t);
+       while(len > 0 && t[len - 1] == c)
+               len--;
+       if (len == 0)
+               return NULL;
+       c = t[len];
+       t[len] = '\0';
+       s = xstrdup(t);
+       t[len] = c;
+       return s;
+ }
  void cgit_diff_tree_cb(struct diff_queue_struct *q,
                       struct diff_options *options, void *data)
  {
diff --combined ui-shared.c
index 110c6966877d05967c21093a32845f35efd9f9ca,bfcc2ac5a880cf5a27ac8d0c227cea562b1956a9..d4376cef5823f403ccd30707abc985ef76c2e6fb
@@@ -111,20 -111,24 +111,24 @@@ static char *repolink(char *title, cha
                html_attr(cgit_repo->url);
                if (cgit_repo->url[strlen(cgit_repo->url) - 1] != '/')
                        html("/");
-               html(page);
-               html("/");
-               if (path)
-                       html_attr(path);
+               if (page) {
+                       html(page);
+                       html("/");
+                       if (path)
+                               html_attr(path);
+               }
        } else {
                html(cgit_script_name);
                html("?url=");
                html_attr(cgit_repo->url);
                if (cgit_repo->url[strlen(cgit_repo->url) - 1] != '/')
                        html("/");
-               html(page);
-               html("/");
-               if (path)
-                       html_attr(path);
+               if (page) {
+                       html(page);
+                       html("/");
+                       if (path)
+                               html_attr(path);
+               }
                delim = "&amp;";
        }
        if (head && strcmp(head, cgit_repo->defbranch)) {
@@@ -159,9 -163,25 +163,25 @@@ void cgit_tree_link(char *name, char *t
  }
  
  void cgit_log_link(char *name, char *title, char *class, char *head,
-                  char *rev, char *path)
+                  char *rev, char *path, int ofs)
  {
-       reporevlink("log", name, title, class, head, rev, path);
+       char *delim;
+       delim = repolink(title, class, "log", head, path);
+       if (rev && strcmp(rev, cgit_query_head)) {
+               html(delim);
+               html("id=");
+               html_attr(rev);
+               delim = "&";
+       }
+       if (ofs > 0) {
+               html(delim);
+               html("ofs=");
+               htmlf("%d", ofs);
+       }
+       html("'>");
+       html_txt(name);
+       html("</a>");
  }
  
  void cgit_commit_link(char *name, char *title, char *class, char *head,
@@@ -262,7 -282,7 +282,7 @@@ void cgit_print_docstart(char *title, s
        html("<title>");
        html_txt(title);
        html("</title>\n");
 -      htmlf("<meta name='generator' content='cgit v%s'/>\n", cgit_version);
 +      htmlf("<meta name='generator' content='cgit %s'/>\n", cgit_version);
        html("<link rel='stylesheet' type='text/css' href='");
        html_attr(cgit_css);
        html("'/>\n");
@@@ -279,19 -299,38 +299,38 @@@ void cgit_print_docend(
  void cgit_print_pageheader(char *title, int show_search)
  {
        html("<table id='layout'>");
-       html("<tr><td id='header'>");
-       html(cgit_root_title);
-       html("</td><td id='logo'>");
+       html("<tr><td id='header'><a href='");
+       html_attr(cgit_rooturl());
+       html("'>");
+       html_txt(cgit_root_title);
+       html("</a></td><td id='logo'>");
        html("<a href='");
        html_attr(cgit_logo_link);
        htmlf("'><img src='%s' alt='logo'/></a>", cgit_logo);
        html("</td></tr>");
        html("<tr><td id='crumb'>");
-       htmlf("<a href='%s'>root</a>", cgit_rooturl());
        if (cgit_query_repo) {
-               htmlf(" : <a href='%s'>", cgit_repourl(cgit_repo->url));
                html_txt(cgit_repo->name);
-               htmlf("</a> : %s", title);
+               html(" (");
+               html_txt(cgit_query_head);
+               html(") : &nbsp;");
+               reporevlink(NULL, "summary", NULL, NULL, cgit_query_head,
+                           NULL, NULL);
+               html(" ");
+               cgit_log_link("log", NULL, NULL, cgit_query_head,
+                             cgit_query_sha1, cgit_query_path, 0);
+               html(" ");
+               cgit_tree_link("tree", NULL, NULL, cgit_query_head,
+                              cgit_query_sha1, NULL);
+               html(" ");
+               cgit_commit_link("commit", NULL, NULL, cgit_query_head,
+                             cgit_query_sha1);
+               html(" ");
+               cgit_diff_link("diff", NULL, NULL, cgit_query_head,
+                              cgit_query_sha1, cgit_query_sha2,
+                              cgit_query_path);
+       } else {
+               html_txt("Index of repositories");
        }
        html("</td>");
        html("<td id='search'>");