]> gitweb.ps.run Git - ps-cgit/commitdiff
Merge branch 'repogroups'
authorLars Hjemli <hjemli@gmail.com>
Sun, 20 May 2007 20:13:17 +0000 (22:13 +0200)
committerLars Hjemli <hjemli@gmail.com>
Sun, 20 May 2007 20:13:17 +0000 (22:13 +0200)
* repogroups:
  Adjust apperance of repogroup headers
  Don't highlight repogroup headings
  Teach cgit how to group repositories by category

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

diff --combined cgit.h
index e0879bd26d0eda774d045586e1f1e6b16a0e3aaf,8a69a1fe948f2e0c825dcc96faf50558b8aa3e4b..892723651361b622629aa4a39f42528654882d7f
--- 1/cgit.h
--- 2/cgit.h
+++ b/cgit.h
  #include <xdiff/xdiff.h>
  
  
 +/*
 + * The valid cgit repo-commands
 + */
 +#define CMD_LOG      1
 +#define CMD_COMMIT   2
 +#define CMD_DIFF     3
 +#define CMD_TREE     4
 +#define CMD_VIEW     5
 +#define CMD_BLOB     6
 +#define CMD_SNAPSHOT 7
 +
  typedef void (*configfn)(const char *name, const char *value);
  typedef void (*filepair_fn)(struct diff_filepair *pair);
  typedef void (*linediff_fn)(char *line, int len);
@@@ -47,6 -36,7 +47,7 @@@ struct repoinfo 
        char *desc;
        char *owner;
        char *defbranch;
+       char *group;
        char *module_link;
        int snapshots;
        int enable_log_filecount;
@@@ -82,17 -72,16 +83,18 @@@ extern const char cgit_version[]
  
  extern struct repolist cgit_repolist;
  extern struct repoinfo *cgit_repo;
 +extern int cgit_cmd;
  
  extern char *cgit_root_title;
  extern char *cgit_css;
  extern char *cgit_logo;
 +extern char *cgit_index_header;
  extern char *cgit_logo_link;
  extern char *cgit_module_link;
  extern char *cgit_virtual_root;
  extern char *cgit_script_name;
  extern char *cgit_cache_root;
+ extern char *cgit_repo_group;
  
  extern int cgit_nocache;
  extern int cgit_snapshots;
@@@ -125,8 -114,6 +127,8 @@@ extern int   cgit_query_ofs
  
  extern int htmlfd;
  
 +extern int cgit_get_cmd_index(const char *cmd);
 +extern struct repoinfo *cgit_get_repoinfo(const char *url);
  extern void cgit_global_config_cb(const char *name, const char *value);
  extern void cgit_repo_config_cb(const char *name, const char *value);
  extern void cgit_querystring_cb(const char *name, const char *value);
@@@ -159,13 -146,11 +161,13 @@@ extern void html_hidden(char *name, cha
  extern void html_link_open(char *url, char *title, char *class);
  extern void html_link_close(void);
  extern void html_filemode(unsigned short mode);
 +extern int html_include(const char *filename);
  
  extern int cgit_read_config(const char *filename, configfn fn);
  extern int cgit_parse_query(char *txt, configfn fn);
  extern struct commitinfo *cgit_parse_commit(struct commit *commit);
  extern struct taginfo *cgit_parse_tag(struct tag *tag);
 +extern void cgit_parse_url(const char *url);
  
  extern char *cache_safe_filename(const char *unsafe);
  extern int cache_lock(struct cacheitem *item);
diff --combined shared.c
index 45fde7fe3bc23fd8d7e9bbf6861f70395330df25,4ddba61864e63eab9f2561adfaddcc08ad5c3306..65af11a05ac6433189f1da6f40a4bbf6fa96cfda
+++ b/shared.c
  
  struct repolist cgit_repolist;
  struct repoinfo *cgit_repo;
 +int cgit_cmd;
  
  char *cgit_root_title   = "Git repository browser";
  char *cgit_css          = "/cgit.css";
  char *cgit_logo         = "/git-logo.png";
 +char *cgit_index_header = NULL;
  char *cgit_logo_link    = "http://www.kernel.org/pub/software/scm/git/docs/";
  char *cgit_module_link  = "./?repo=%s&page=commit&id=%s";
  char *cgit_virtual_root = NULL;
  char *cgit_script_name  = CGIT_SCRIPT_NAME;
  char *cgit_cache_root   = "/var/cache/cgit";
+ char *cgit_repo_group   = NULL;
  
  int cgit_nocache               =  0;
  int cgit_snapshots             =  0;
@@@ -53,18 -52,6 +54,18 @@@ int   cgit_query_ofs    = 0
  
  int htmlfd = 0;
  
 +
 +int cgit_get_cmd_index(const char *cmd)
 +{
 +      static char *cmds[] = {"log", "commit", "diff", "tree", "view", "blob", "snapshot", NULL};
 +      int i;
 +
 +      for(i = 0; cmds[i]; i++)
 +              if (!strcmp(cmd, cmds[i]))
 +                      return i + 1;
 +      return 0;
 +}
 +
  int chk_zero(int result, char *msg)
  {
        if (result != 0)
@@@ -99,6 -86,7 +100,7 @@@ struct repoinfo *add_repo(const char *u
        ret->path = NULL;
        ret->desc = NULL;
        ret->owner = NULL;
+       ret->group = cgit_repo_group;
        ret->defbranch = "master";
        ret->snapshots = cgit_snapshots;
        ret->enable_log_filecount = cgit_enable_log_filecount;
        return ret;
  }
  
 +struct repoinfo *cgit_get_repoinfo(const char *url)
 +{
 +      int i;
 +      struct repoinfo *repo;
 +
 +      for (i=0; i<cgit_repolist.count; i++) {
 +              repo = &cgit_repolist.repos[i];
 +              if (!strcmp(repo->url, url))
 +                      return repo;
 +      }
 +      return NULL;
 +}
 +
  void cgit_global_config_cb(const char *name, const char *value)
  {
        if (!strcmp(name, "root-title"))
                cgit_css = xstrdup(value);
        else if (!strcmp(name, "logo"))
                cgit_logo = xstrdup(value);
 +      else if (!strcmp(name, "index-header"))
 +              cgit_index_header = xstrdup(value);
        else if (!strcmp(name, "logo-link"))
                cgit_logo_link = xstrdup(value);
        else if (!strcmp(name, "module-link"))
                cgit_max_repodesc_len = atoi(value);
        else if (!strcmp(name, "max-commit-count"))
                cgit_max_commit_count = atoi(value);
+       else if (!strcmp(name, "repo.group"))
+               cgit_repo_group = xstrdup(value);
        else if (!strcmp(name, "repo.url"))
                cgit_repo = add_repo(value);
        else if (!strcmp(name, "repo.name"))
@@@ -188,12 -163,8 +192,12 @@@ void cgit_querystring_cb(const char *na
  {
        if (!strcmp(name,"r")) {
                cgit_query_repo = xstrdup(value);
 +              cgit_repo = cgit_get_repoinfo(value);
        } else if (!strcmp(name, "p")) {
                cgit_query_page = xstrdup(value);
 +              cgit_cmd = cgit_get_cmd_index(value);
 +      } else if (!strcmp(name, "url")) {
 +              cgit_parse_url(value);
        } else if (!strcmp(name, "q")) {
                cgit_query_search = xstrdup(value);
        } else if (!strcmp(name, "h")) {
diff --combined ui-repolist.c
index 8e367a2e34e386944bf9b2915c68945f1f886acb,872458983361fb5917b3b8b2aaea84aeb1ea5163..33e3e7fdcc45690aad81d66ebee33d31cdd84dcf
@@@ -12,16 -12,12 +12,17 @@@ void cgit_print_repolist(struct cacheit
  {
        struct repoinfo *repo;
        int i;
+       char *last_group = NULL;
  
        cgit_print_docstart(cgit_root_title, item);
        cgit_print_pageheader(cgit_root_title, 0);
  
        html("<table class='list nowrap'>");
 +      if (cgit_index_header) {
 +              html("<tr class='nohover'><td colspan='4' class='include-block'>");
 +              html_include(cgit_index_header);
 +              html("</td></tr>");
 +      }
        html("<tr class='nohover'>"
             "<th class='left'>Name</th>"
             "<th class='left'>Description</th>"
  
        for (i=0; i<cgit_repolist.count; i++) {
                repo = &cgit_repolist.repos[i];
+               if ((last_group == NULL && repo->group != NULL) ||
+                   (last_group != NULL && repo->group == NULL) ||
+                   (last_group != NULL && repo->group!= NULL &&
+                    strcmp(repo->group, last_group))) {
+                       html("<tr class='nohover'><td colspan='4' class='repogroup'>");
+                       html_txt(repo->group);
+                       html("</td></tr>");
+                       last_group = repo->group;
+               }
                html("<tr><td>");
                html_link_open(cgit_repourl(repo->url), NULL, NULL);
                html_txt(repo->name);