diff options
| -rw-r--r-- | Makefile | 8 | ||||
| -rw-r--r-- | cache.c | 22 | ||||
| -rw-r--r-- | cgit.c | 74 | ||||
| -rw-r--r-- | cgit.h | 17 | ||||
| m--------- | git | 0 | ||||
| -rw-r--r-- | html.c | 14 | ||||
| -rw-r--r-- | parsing.c | 44 | ||||
| -rw-r--r-- | shared.c | 33 | ||||
| -rw-r--r-- | ui-repolist.c | 5 | ||||
| -rw-r--r-- | ui-shared.c | 5 |
10 files changed, 166 insertions, 56 deletions
| @@ -31,14 +31,12 @@ CFLAGS += -DCGIT_SCRIPT_NAME='"$(CGIT_SCRIPT_NAME)"' | |||
| 31 | 31 | ||
| 32 | 32 | ||
| 33 | # | 33 | # |
| 34 | # If make is run on a nongit platform, we need to get the git sources as a tarball. | 34 | # If make is run on a nongit platform, get the git sources as a tarball. |
| 35 | # But there is currently no recent enough tarball available on kernel.org, so download | ||
| 36 | # a zipfile from hjemli.net instead | ||
| 37 | # | 35 | # |
| 38 | GITVER = $(shell git version 2>/dev/null || echo nogit) | 36 | GITVER = $(shell git version 2>/dev/null || echo nogit) |
| 39 | ifeq ($(GITVER),nogit) | 37 | ifeq ($(GITVER),nogit) |
| 40 | GITURL = http://hjemli.net/git/git/snapshot/?id=v1.5.2-rc2 | 38 | GITURL = http://www.kernel.org/pub/software/scm/git/git-1.5.2.tar.bz2 |
| 41 | INITGIT = test -e git/git.c || (curl "$(GITURL)" > tmp.zip && unzip tmp.zip) | 39 | INITGIT = test -e git/git.c || ((curl "$(GITURL)" | tar -xj) && mv git-1.5.2 git) |
| 42 | else | 40 | else |
| 43 | INITGIT = ./submodules.sh -i | 41 | INITGIT = ./submodules.sh -i |
| 44 | endif | 42 | endif |
| @@ -12,18 +12,23 @@ const int NOLOCK = -1; | |||
| 12 | 12 | ||
| 13 | char *cache_safe_filename(const char *unsafe) | 13 | char *cache_safe_filename(const char *unsafe) |
| 14 | { | 14 | { |
| 15 | static char buf[PATH_MAX]; | 15 | static char buf[4][PATH_MAX]; |
| 16 | char *s = buf; | 16 | static int bufidx; |
| 17 | char *s; | ||
| 17 | char c; | 18 | char c; |
| 18 | 19 | ||
| 20 | bufidx++; | ||
| 21 | bufidx &= 3; | ||
| 22 | s = buf[bufidx]; | ||
| 23 | |||
| 19 | while(unsafe && (c = *unsafe++) != 0) { | 24 | while(unsafe && (c = *unsafe++) != 0) { |
| 20 | if (c == '/' || c == ' ' || c == '&' || c == '|' || | 25 | if (c == '/' || c == ' ' || c == '&' || c == '|' || |
| 21 | c == '>' || c == '<' || c == '.') | 26 | c == '>' || c == '<' || c == '.') |
| 22 | c = '_'; | 27 | c = '_'; |
| 23 | *s++ = c; | 28 | *s++ = c; |
| 24 | } | 29 | } |
| 25 | *s = '\0'; | 30 | *s = '\0'; |
| 26 | return buf; | 31 | return buf[bufidx]; |
| 27 | } | 32 | } |
| 28 | 33 | ||
| 29 | int cache_exist(struct cacheitem *item) | 34 | int cache_exist(struct cacheitem *item) |
| @@ -43,15 +48,18 @@ int cache_create_dirs() | |||
| 43 | if (mkdir(path, S_IRWXU) && errno!=EEXIST) | 48 | if (mkdir(path, S_IRWXU) && errno!=EEXIST) |
| 44 | return 0; | 49 | return 0; |
| 45 | 50 | ||
| 46 | if (!cgit_query_repo) | 51 | if (!cgit_repo) |
| 47 | return 0; | 52 | return 0; |
| 48 | 53 | ||
| 49 | path = fmt("%s/%s", cgit_cache_root, cgit_query_repo); | 54 | path = fmt("%s/%s", cgit_cache_root, |
| 55 | cache_safe_filename(cgit_repo->url)); | ||
| 56 | |||
| 50 | if (mkdir(path, S_IRWXU) && errno!=EEXIST) | 57 | if (mkdir(path, S_IRWXU) && errno!=EEXIST) |
| 51 | return 0; | 58 | return 0; |
| 52 | 59 | ||
| 53 | if (cgit_query_page) { | 60 | if (cgit_query_page) { |
| 54 | path = fmt("%s/%s/%s", cgit_cache_root, cgit_query_repo, | 61 | path = fmt("%s/%s/%s", cgit_cache_root, |
| 62 | cache_safe_filename(cgit_repo->url), | ||
| 55 | cgit_query_page); | 63 | cgit_query_page); |
| 56 | if (mkdir(path, S_IRWXU) && errno!=EEXIST) | 64 | if (mkdir(path, S_IRWXU) && errno!=EEXIST) |
| 57 | return 0; | 65 | return 0; |
| @@ -11,29 +11,9 @@ | |||
| 11 | const char cgit_version[] = CGIT_VERSION; | 11 | const char cgit_version[] = CGIT_VERSION; |
| 12 | 12 | ||
| 13 | 13 | ||
| 14 | static struct repoinfo *cgit_get_repoinfo(char *url) | ||
| 15 | { | ||
| 16 | int i; | ||
| 17 | struct repoinfo *repo; | ||
| 18 | |||
| 19 | for (i=0; i<cgit_repolist.count; i++) { | ||
| 20 | repo = &cgit_repolist.repos[i]; | ||
| 21 | if (!strcmp(repo->url, url)) | ||
| 22 | return repo; | ||
| 23 | } | ||
| 24 | return NULL; | ||
| 25 | } | ||
| 26 | |||
| 27 | |||
| 28 | static int cgit_prepare_cache(struct cacheitem *item) | 14 | static int cgit_prepare_cache(struct cacheitem *item) |
| 29 | { | 15 | { |
| 30 | if (!cgit_query_repo) { | 16 | if (!cgit_repo && cgit_query_repo) { |
| 31 | item->name = xstrdup(fmt("%s/index.html", cgit_cache_root)); | ||
| 32 | item->ttl = cgit_cache_root_ttl; | ||
| 33 | return 1; | ||
| 34 | } | ||
| 35 | cgit_repo = cgit_get_repoinfo(cgit_query_repo); | ||
| 36 | if (!cgit_repo) { | ||
| 37 | char *title = fmt("%s - %s", cgit_root_title, "Bad request"); | 17 | char *title = fmt("%s - %s", cgit_root_title, "Bad request"); |
| 38 | cgit_print_docstart(title, item); | 18 | cgit_print_docstart(title, item); |
| 39 | cgit_print_pageheader(title, 0); | 19 | cgit_print_pageheader(title, 0); |
| @@ -42,13 +22,19 @@ static int cgit_prepare_cache(struct cacheitem *item) | |||
| 42 | return 0; | 22 | return 0; |
| 43 | } | 23 | } |
| 44 | 24 | ||
| 45 | if (!cgit_query_page) { | 25 | if (!cgit_repo) { |
| 26 | item->name = xstrdup(fmt("%s/index.html", cgit_cache_root)); | ||
| 27 | item->ttl = cgit_cache_root_ttl; | ||
| 28 | return 1; | ||
| 29 | } | ||
| 30 | |||
| 31 | if (!cgit_cmd) { | ||
| 46 | item->name = xstrdup(fmt("%s/%s/index.html", cgit_cache_root, | 32 | item->name = xstrdup(fmt("%s/%s/index.html", cgit_cache_root, |
| 47 | cgit_repo->url)); | 33 | cache_safe_filename(cgit_repo->url))); |
| 48 | item->ttl = cgit_cache_repo_ttl; | 34 | item->ttl = cgit_cache_repo_ttl; |
| 49 | } else { | 35 | } else { |
| 50 | item->name = xstrdup(fmt("%s/%s/%s/%s.html", cgit_cache_root, | 36 | item->name = xstrdup(fmt("%s/%s/%s/%s.html", cgit_cache_root, |
| 51 | cgit_repo->url, cgit_query_page, | 37 | cache_safe_filename(cgit_repo->url), cgit_query_page, |
| 52 | cache_safe_filename(cgit_querystring))); | 38 | cache_safe_filename(cgit_querystring))); |
| 53 | if (cgit_query_has_symref) | 39 | if (cgit_query_has_symref) |
| 54 | item->ttl = cgit_cache_dynamic_ttl; | 40 | item->ttl = cgit_cache_dynamic_ttl; |
| @@ -82,25 +68,20 @@ static void cgit_print_repo_page(struct cacheitem *item) | |||
| 82 | show_search = 0; | 68 | show_search = 0; |
| 83 | setenv("GIT_DIR", cgit_repo->path, 1); | 69 | setenv("GIT_DIR", cgit_repo->path, 1); |
| 84 | 70 | ||
| 85 | if (cgit_query_page) { | 71 | if ((cgit_cmd == CMD_SNAPSHOT) && cgit_repo->snapshots) { |
| 86 | if (cgit_repo->snapshots && !strcmp(cgit_query_page, "snapshot")) { | ||
| 87 | cgit_print_snapshot(item, cgit_query_sha1, "zip", | 72 | cgit_print_snapshot(item, cgit_query_sha1, "zip", |
| 88 | cgit_repo->url, cgit_query_name); | 73 | cgit_repo->url, cgit_query_name); |
| 89 | return; | 74 | return; |
| 90 | } | ||
| 91 | if (!strcmp(cgit_query_page, "blob")) { | ||
| 92 | cgit_print_blob(item, cgit_query_sha1, cgit_query_path); | ||
| 93 | return; | ||
| 94 | } | ||
| 95 | } | 75 | } |
| 96 | 76 | ||
| 97 | if (cgit_query_page && !strcmp(cgit_query_page, "log")) | 77 | if (cgit_cmd == CMD_BLOB) { |
| 98 | show_search = 1; | 78 | cgit_print_blob(item, cgit_query_sha1, cgit_query_path); |
| 79 | return; | ||
| 80 | } | ||
| 99 | 81 | ||
| 82 | show_search = (cgit_cmd == CMD_LOG); | ||
| 100 | cgit_print_docstart(title, item); | 83 | cgit_print_docstart(title, item); |
| 101 | 84 | if (!cgit_cmd) { | |
| 102 | |||
| 103 | if (!cgit_query_page) { | ||
| 104 | cgit_print_pageheader("summary", show_search); | 85 | cgit_print_pageheader("summary", show_search); |
| 105 | cgit_print_summary(); | 86 | cgit_print_summary(); |
| 106 | cgit_print_docend(); | 87 | cgit_print_docend(); |
| @@ -109,20 +90,26 @@ static void cgit_print_repo_page(struct cacheitem *item) | |||
| 109 | 90 | ||
| 110 | cgit_print_pageheader(cgit_query_page, show_search); | 91 | cgit_print_pageheader(cgit_query_page, show_search); |
| 111 | 92 | ||
| 112 | if (!strcmp(cgit_query_page, "log")) { | 93 | switch(cgit_cmd) { |
| 94 | case CMD_LOG: | ||
| 113 | cgit_print_log(cgit_query_head, cgit_query_ofs, | 95 | cgit_print_log(cgit_query_head, cgit_query_ofs, |
| 114 | cgit_max_commit_count, cgit_query_search, | 96 | cgit_max_commit_count, cgit_query_search, |
| 115 | cgit_query_path); | 97 | cgit_query_path); |
| 116 | } else if (!strcmp(cgit_query_page, "tree")) { | 98 | break; |
| 99 | case CMD_TREE: | ||
| 117 | cgit_print_tree(cgit_query_head, cgit_query_sha1, cgit_query_path); | 100 | cgit_print_tree(cgit_query_head, cgit_query_sha1, cgit_query_path); |
| 118 | } else if (!strcmp(cgit_query_page, "commit")) { | 101 | break; |
| 102 | case CMD_COMMIT: | ||
| 119 | cgit_print_commit(cgit_query_head); | 103 | cgit_print_commit(cgit_query_head); |
| 120 | } else if (!strcmp(cgit_query_page, "view")) { | 104 | break; |
| 105 | case CMD_VIEW: | ||
| 121 | cgit_print_view(cgit_query_sha1, cgit_query_path); | 106 | cgit_print_view(cgit_query_sha1, cgit_query_path); |
| 122 | } else if (!strcmp(cgit_query_page, "diff")) { | 107 | break; |
| 108 | case CMD_DIFF: | ||
| 123 | cgit_print_diff(cgit_query_head, cgit_query_sha1, cgit_query_sha2, | 109 | cgit_print_diff(cgit_query_head, cgit_query_sha1, cgit_query_sha2, |
| 124 | cgit_query_path); | 110 | cgit_query_path); |
| 125 | } else { | 111 | break; |
| 112 | default: | ||
| 126 | cgit_print_error("Invalid request"); | 113 | cgit_print_error("Invalid request"); |
| 127 | } | 114 | } |
| 128 | cgit_print_docend(); | 115 | cgit_print_docend(); |
| @@ -143,7 +130,7 @@ static void cgit_fill_cache(struct cacheitem *item, int use_cache) | |||
| 143 | chk_positive(dup2(item->fd, STDOUT_FILENO), "Dup2(cachefile)"); | 130 | chk_positive(dup2(item->fd, STDOUT_FILENO), "Dup2(cachefile)"); |
| 144 | } | 131 | } |
| 145 | 132 | ||
| 146 | if (cgit_query_repo) | 133 | if (cgit_repo) |
| 147 | cgit_print_repo_page(item); | 134 | cgit_print_repo_page(item); |
| 148 | else | 135 | else |
| 149 | cgit_print_repolist(item); | 136 | cgit_print_repolist(item); |
| @@ -248,6 +235,7 @@ int main(int argc, const char **argv) | |||
| 248 | cgit_repolist.repos = NULL; | 235 | cgit_repolist.repos = NULL; |
| 249 | 236 | ||
| 250 | cgit_read_config(CGIT_CONFIG, cgit_global_config_cb); | 237 | cgit_read_config(CGIT_CONFIG, cgit_global_config_cb); |
| 238 | cgit_repo = NULL; | ||
| 251 | if (getenv("SCRIPT_NAME")) | 239 | if (getenv("SCRIPT_NAME")) |
| 252 | cgit_script_name = xstrdup(getenv("SCRIPT_NAME")); | 240 | cgit_script_name = xstrdup(getenv("SCRIPT_NAME")); |
| 253 | if (getenv("QUERY_STRING")) | 241 | if (getenv("QUERY_STRING")) |
| @@ -18,6 +18,17 @@ | |||
| 18 | #include <xdiff/xdiff.h> | 18 | #include <xdiff/xdiff.h> |
| 19 | 19 | ||
| 20 | 20 | ||
| 21 | /* | ||
| 22 | * The valid cgit repo-commands | ||
| 23 | */ | ||
| 24 | #define CMD_LOG 1 | ||
| 25 | #define CMD_COMMIT 2 | ||
| 26 | #define CMD_DIFF 3 | ||
| 27 | #define CMD_TREE 4 | ||
| 28 | #define CMD_VIEW 5 | ||
| 29 | #define CMD_BLOB 6 | ||
| 30 | #define CMD_SNAPSHOT 7 | ||
| 31 | |||
| 21 | typedef void (*configfn)(const char *name, const char *value); | 32 | typedef void (*configfn)(const char *name, const char *value); |
| 22 | typedef void (*filepair_fn)(struct diff_filepair *pair); | 33 | typedef void (*filepair_fn)(struct diff_filepair *pair); |
| 23 | typedef void (*linediff_fn)(char *line, int len); | 34 | typedef void (*linediff_fn)(char *line, int len); |
| @@ -72,10 +83,12 @@ extern const char cgit_version[]; | |||
| 72 | 83 | ||
| 73 | extern struct repolist cgit_repolist; | 84 | extern struct repolist cgit_repolist; |
| 74 | extern struct repoinfo *cgit_repo; | 85 | extern struct repoinfo *cgit_repo; |
| 86 | extern int cgit_cmd; | ||
| 75 | 87 | ||
| 76 | extern char *cgit_root_title; | 88 | extern char *cgit_root_title; |
| 77 | extern char *cgit_css; | 89 | extern char *cgit_css; |
| 78 | extern char *cgit_logo; | 90 | extern char *cgit_logo; |
| 91 | extern char *cgit_index_header; | ||
| 79 | extern char *cgit_logo_link; | 92 | extern char *cgit_logo_link; |
| 80 | extern char *cgit_module_link; | 93 | extern char *cgit_module_link; |
| 81 | extern char *cgit_virtual_root; | 94 | extern char *cgit_virtual_root; |
| @@ -114,6 +127,8 @@ extern int cgit_query_ofs; | |||
| 114 | 127 | ||
| 115 | extern int htmlfd; | 128 | extern int htmlfd; |
| 116 | 129 | ||
| 130 | extern int cgit_get_cmd_index(const char *cmd); | ||
| 131 | extern struct repoinfo *cgit_get_repoinfo(const char *url); | ||
| 117 | extern void cgit_global_config_cb(const char *name, const char *value); | 132 | extern void cgit_global_config_cb(const char *name, const char *value); |
| 118 | extern void cgit_repo_config_cb(const char *name, const char *value); | 133 | extern void cgit_repo_config_cb(const char *name, const char *value); |
| 119 | extern void cgit_querystring_cb(const char *name, const char *value); | 134 | extern void cgit_querystring_cb(const char *name, const char *value); |
| @@ -146,11 +161,13 @@ extern void html_hidden(char *name, char *value); | |||
| 146 | extern void html_link_open(char *url, char *title, char *class); | 161 | extern void html_link_open(char *url, char *title, char *class); |
| 147 | extern void html_link_close(void); | 162 | extern void html_link_close(void); |
| 148 | extern void html_filemode(unsigned short mode); | 163 | extern void html_filemode(unsigned short mode); |
| 164 | extern int html_include(const char *filename); | ||
| 149 | 165 | ||
| 150 | extern int cgit_read_config(const char *filename, configfn fn); | 166 | extern int cgit_read_config(const char *filename, configfn fn); |
| 151 | extern int cgit_parse_query(char *txt, configfn fn); | 167 | extern int cgit_parse_query(char *txt, configfn fn); |
| 152 | extern struct commitinfo *cgit_parse_commit(struct commit *commit); | 168 | extern struct commitinfo *cgit_parse_commit(struct commit *commit); |
| 153 | extern struct taginfo *cgit_parse_tag(struct tag *tag); | 169 | extern struct taginfo *cgit_parse_tag(struct tag *tag); |
| 170 | extern void cgit_parse_url(const char *url); | ||
| 154 | 171 | ||
| 155 | extern char *cache_safe_filename(const char *unsafe); | 172 | extern char *cache_safe_filename(const char *unsafe); |
| 156 | extern int cache_lock(struct cacheitem *item); | 173 | extern int cache_lock(struct cacheitem *item); |
diff --git a/git b/git | |||
| Subproject 9159afbfce955db86373dab95b5f8e31fb763da | Subproject aba170cdb4874b72dd619e6f7bbc13c33295f83 | ||
| @@ -166,3 +166,17 @@ void html_filemode(unsigned short mode) | |||
| 166 | html_fileperm(mode >> 3); | 166 | html_fileperm(mode >> 3); |
| 167 | html_fileperm(mode); | 167 | html_fileperm(mode); |
| 168 | } | 168 | } |
| 169 | |||
| 170 | int html_include(const char *filename) | ||
| 171 | { | ||
| 172 | FILE *f; | ||
| 173 | char buf[4096]; | ||
| 174 | size_t len; | ||
| 175 | |||
| 176 | if (!(f = fopen(filename, "r"))) | ||
| 177 | return -1; | ||
| 178 | while((len = fread(buf, 1, 4096, f)) > 0) | ||
| 179 | write(htmlfd, buf, len); | ||
| 180 | fclose(f); | ||
| 181 | return 0; | ||
| 182 | } | ||
| @@ -132,6 +132,50 @@ int cgit_parse_query(char *txt, configfn fn) | |||
| 132 | return 0; | 132 | return 0; |
| 133 | } | 133 | } |
| 134 | 134 | ||
| 135 | /* | ||
| 136 | * url syntax: [repo ['/' cmd [ '/' path]]] | ||
| 137 | * repo: any valid repo url, may contain '/' | ||
| 138 | * cmd: log | commit | diff | tree | view | blob | snapshot | ||
| 139 | * path: any valid path, may contain '/' | ||
| 140 | * | ||
| 141 | */ | ||
| 142 | void cgit_parse_url(const char *url) | ||
| 143 | { | ||
| 144 | char *cmd, *p; | ||
| 145 | |||
| 146 | cgit_repo = NULL; | ||
| 147 | if (!url || url[0] == '\0') | ||
| 148 | return; | ||
| 149 | |||
| 150 | cgit_repo = cgit_get_repoinfo(url); | ||
| 151 | if (cgit_repo) { | ||
| 152 | cgit_query_repo = cgit_repo->url; | ||
| 153 | return; | ||
| 154 | } | ||
| 155 | |||
| 156 | cmd = strchr(url, '/'); | ||
| 157 | while (!cgit_repo && cmd) { | ||
| 158 | cmd[0] = '\0'; | ||
| 159 | cgit_repo = cgit_get_repoinfo(url); | ||
| 160 | if (cgit_repo == NULL) { | ||
| 161 | cmd[0] = '/'; | ||
| 162 | cmd = strchr(cmd + 1, '/'); | ||
| 163 | continue; | ||
| 164 | } | ||
| 165 | |||
| 166 | cgit_query_repo = cgit_repo->url; | ||
| 167 | p = strchr(cmd + 1, '/'); | ||
| 168 | if (p) { | ||
| 169 | p[0] = '\0'; | ||
| 170 | if (p[1]) | ||
| 171 | cgit_query_path = xstrdup(p + 1); | ||
| 172 | } | ||
| 173 | cgit_cmd = cgit_get_cmd_index(cmd + 1); | ||
| 174 | cgit_query_page = xstrdup(cmd + 1); | ||
| 175 | return; | ||
| 176 | } | ||
| 177 | } | ||
| 178 | |||
| 135 | char *substr(const char *head, const char *tail) | 179 | char *substr(const char *head, const char *tail) |
| 136 | { | 180 | { |
| 137 | char *buf; | 181 | char *buf; |
| @@ -10,10 +10,12 @@ | |||
| 10 | 10 | ||
| 11 | struct repolist cgit_repolist; | 11 | struct repolist cgit_repolist; |
| 12 | struct repoinfo *cgit_repo; | 12 | struct repoinfo *cgit_repo; |
| 13 | int cgit_cmd; | ||
| 13 | 14 | ||
| 14 | char *cgit_root_title = "Git repository browser"; | 15 | char *cgit_root_title = "Git repository browser"; |
| 15 | char *cgit_css = "/cgit.css"; | 16 | char *cgit_css = "/cgit.css"; |
| 16 | char *cgit_logo = "/git-logo.png"; | 17 | char *cgit_logo = "/git-logo.png"; |
| 18 | char *cgit_index_header = NULL; | ||
| 17 | char *cgit_logo_link = "http://www.kernel.org/pub/software/scm/git/docs/"; | 19 | char *cgit_logo_link = "http://www.kernel.org/pub/software/scm/git/docs/"; |
| 18 | char *cgit_module_link = "./?repo=%s&page=commit&id=%s"; | 20 | char *cgit_module_link = "./?repo=%s&page=commit&id=%s"; |
| 19 | char *cgit_virtual_root = NULL; | 21 | char *cgit_virtual_root = NULL; |
| @@ -52,6 +54,18 @@ int cgit_query_ofs = 0; | |||
| 52 | 54 | ||
| 53 | int htmlfd = 0; | 55 | int htmlfd = 0; |
| 54 | 56 | ||
| 57 | |||
| 58 | int cgit_get_cmd_index(const char *cmd) | ||
| 59 | { | ||
| 60 | static char *cmds[] = {"log", "commit", "diff", "tree", "view", "blob", "snapshot", NULL}; | ||
| 61 | int i; | ||
| 62 | |||
| 63 | for(i = 0; cmds[i]; i++) | ||
| 64 | if (!strcmp(cmd, cmds[i])) | ||
| 65 | return i + 1; | ||
| 66 | return 0; | ||
| 67 | } | ||
| 68 | |||
| 55 | int chk_zero(int result, char *msg) | 69 | int chk_zero(int result, char *msg) |
| 56 | { | 70 | { |
| 57 | if (result != 0) | 71 | if (result != 0) |
| @@ -95,6 +109,19 @@ struct repoinfo *add_repo(const char *url) | |||
| 95 | return ret; | 109 | return ret; |
| 96 | } | 110 | } |
| 97 | 111 | ||
| 112 | struct repoinfo *cgit_get_repoinfo(const char *url) | ||
| 113 | { | ||
| 114 | int i; | ||
| 115 | struct repoinfo *repo; | ||
| 116 | |||
| 117 | for (i=0; i<cgit_repolist.count; i++) { | ||
| 118 | repo = &cgit_repolist.repos[i]; | ||
| 119 | if (!strcmp(repo->url, url)) | ||
| 120 | return repo; | ||
| 121 | } | ||
| 122 | return NULL; | ||
| 123 | } | ||
| 124 | |||
| 98 | void cgit_global_config_cb(const char *name, const char *value) | 125 | void cgit_global_config_cb(const char *name, const char *value) |
| 99 | { | 126 | { |
| 100 | if (!strcmp(name, "root-title")) | 127 | if (!strcmp(name, "root-title")) |
| @@ -103,6 +130,8 @@ void cgit_global_config_cb(const char *name, const char *value) | |||
| 103 | cgit_css = xstrdup(value); | 130 | cgit_css = xstrdup(value); |
| 104 | else if (!strcmp(name, "logo")) | 131 | else if (!strcmp(name, "logo")) |
| 105 | cgit_logo = xstrdup(value); | 132 | cgit_logo = xstrdup(value); |
| 133 | else if (!strcmp(name, "index-header")) | ||
| 134 | cgit_index_header = xstrdup(value); | ||
| 106 | else if (!strcmp(name, "logo-link")) | 135 | else if (!strcmp(name, "logo-link")) |
| 107 | cgit_logo_link = xstrdup(value); | 136 | cgit_logo_link = xstrdup(value); |
| 108 | else if (!strcmp(name, "module-link")) | 137 | else if (!strcmp(name, "module-link")) |
| @@ -163,8 +192,12 @@ void cgit_querystring_cb(const char *name, const char *value) | |||
| 163 | { | 192 | { |
| 164 | if (!strcmp(name,"r")) { | 193 | if (!strcmp(name,"r")) { |
| 165 | cgit_query_repo = xstrdup(value); | 194 | cgit_query_repo = xstrdup(value); |
| 195 | cgit_repo = cgit_get_repoinfo(value); | ||
| 166 | } else if (!strcmp(name, "p")) { | 196 | } else if (!strcmp(name, "p")) { |
| 167 | cgit_query_page = xstrdup(value); | 197 | cgit_query_page = xstrdup(value); |
| 198 | cgit_cmd = cgit_get_cmd_index(value); | ||
| 199 | } else if (!strcmp(name, "url")) { | ||
| 200 | cgit_parse_url(value); | ||
| 168 | } else if (!strcmp(name, "q")) { | 201 | } else if (!strcmp(name, "q")) { |
| 169 | cgit_query_search = xstrdup(value); | 202 | cgit_query_search = xstrdup(value); |
| 170 | } else if (!strcmp(name, "h")) { | 203 | } else if (!strcmp(name, "h")) { |
diff --git a/ui-repolist.c b/ui-repolist.c index 8724589..33e3e7f 100644 --- a/ui-repolist.c +++ b/ui-repolist.c | |||
| @@ -18,6 +18,11 @@ void cgit_print_repolist(struct cacheitem *item) | |||
| 18 | cgit_print_pageheader(cgit_root_title, 0); | 18 | cgit_print_pageheader(cgit_root_title, 0); |
| 19 | 19 | ||
| 20 | html("<table class='list nowrap'>"); | 20 | html("<table class='list nowrap'>"); |
| 21 | if (cgit_index_header) { | ||
| 22 | html("<tr class='nohover'><td colspan='4' class='include-block'>"); | ||
| 23 | html_include(cgit_index_header); | ||
| 24 | html("</td></tr>"); | ||
| 25 | } | ||
| 21 | html("<tr class='nohover'>" | 26 | html("<tr class='nohover'>" |
| 22 | "<th class='left'>Name</th>" | 27 | "<th class='left'>Name</th>" |
| 23 | "<th class='left'>Description</th>" | 28 | "<th class='left'>Description</th>" |
diff --git a/ui-shared.c b/ui-shared.c index 6211056..c7fbc5e 100644 --- a/ui-shared.c +++ b/ui-shared.c | |||
| @@ -68,7 +68,10 @@ char *cgit_pageurl(const char *reponame, const char *pagename, | |||
| 68 | return fmt("%s/%s/%s/", cgit_virtual_root, reponame, | 68 | return fmt("%s/%s/%s/", cgit_virtual_root, reponame, |
| 69 | pagename); | 69 | pagename); |
| 70 | } else { | 70 | } else { |
| 71 | return fmt("?r=%s&p=%s&%s", reponame, pagename, query); | 71 | if (query) |
| 72 | return fmt("?r=%s&p=%s&%s", reponame, pagename, query); | ||
| 73 | else | ||
| 74 | return fmt("?r=%s&p=%s", reponame, pagename); | ||
| 72 | } | 75 | } |
| 73 | } | 76 | } |
| 74 | 77 | ||
