From: Lars Hjemli Date: Sun, 20 May 2007 20:13:17 +0000 (+0200) Subject: Merge branch 'repogroups' X-Git-Url: https://gitweb.ps.run/ps-cgit/commitdiff_plain/271ac5a7e6b5b67f54fdd16e8542aa282f1c7140?hp=-c Merge branch 'repogroups' * repogroups: Adjust apperance of repogroup headers Don't highlight repogroup headings Teach cgit how to group repositories by category --- 271ac5a7e6b5b67f54fdd16e8542aa282f1c7140 diff --combined cgit.h index e0879bd,8a69a1f..8927236 --- a/cgit.h +++ b/cgit.h @@@ -18,17 -18,6 +18,17 @@@ #include +/* + * 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 45fde7f,4ddba61..65af11a --- a/shared.c +++ b/shared.c @@@ -10,17 -10,16 +10,18 @@@ 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; @@@ -107,19 -95,6 +109,19 @@@ return ret; } +struct repoinfo *cgit_get_repoinfo(const char *url) +{ + int i; + struct repoinfo *repo; + + for (i=0; iurl, url)) + return repo; + } + return NULL; +} + void cgit_global_config_cb(const char *name, const char *value) { if (!strcmp(name, "root-title")) @@@ -128,8 -103,6 +130,8 @@@ 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")) @@@ -160,6 -133,8 +162,8 @@@ 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 8e367a2,8724589..33e3e7f --- a/ui-repolist.c +++ b/ui-repolist.c @@@ -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(""); + if (cgit_index_header) { + html(""); + } html("" "" "" @@@ -30,6 -26,15 +31,15 @@@ for (i=0; igroup != NULL) || + (last_group != NULL && repo->group == NULL) || + (last_group != NULL && repo->group!= NULL && + strcmp(repo->group, last_group))) { + html(""); + last_group = repo->group; + } html("
"); + html_include(cgit_index_header); + html("
NameDescription
"); + html_txt(repo->group); + html("
"); html_link_open(cgit_repourl(repo->url), NULL, NULL); html_txt(repo->name);