]> gitweb.ps.run Git - ps-cgit/blobdiff - shared.c
css: make column headings bold
[ps-cgit] / shared.c
index 54b1813a882806c67b5afe9422fdae51737cd665..65af11a05ac6433189f1da6f40a4bbf6fa96cfda 100644 (file)
--- a/shared.c
+++ b/shared.c
@@ -10,6 +10,7 @@
 
 struct repolist cgit_repolist;
 struct repoinfo *cgit_repo;
+int cgit_cmd;
 
 char *cgit_root_title   = "Git repository browser";
 char *cgit_css          = "/cgit.css";
@@ -20,6 +21,7 @@ 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;
@@ -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)
@@ -86,6 +100,7 @@ struct repoinfo *add_repo(const char *url)
        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;
@@ -94,6 +109,19 @@ struct repoinfo *add_repo(const char *url)
        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"))
@@ -134,6 +162,8 @@ void cgit_global_config_cb(const char *name, const char *value)
                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"))
@@ -162,8 +192,12 @@ void cgit_querystring_cb(const char *name, const char *value)
 {
        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")) {