summaryrefslogtreecommitdiffabout
path: root/shared.c
authorLars Hjemli <hjemli@gmail.com>2007-05-23 20:46:54 (UTC)
committer Lars Hjemli <hjemli@gmail.com>2007-05-23 20:46:54 (UTC)
commitbbcdc290c6c0b8121e57dbca4bd66c9e5e729959 (patch) (unidiff)
treefb762f2153b60cc4f997095626af70baa16ce7b1 /shared.c
parent25da3f76255754c8b3f98232a5eb84f47088d0f7 (diff)
downloadcgit-bbcdc290c6c0b8121e57dbca4bd66c9e5e729959.zip
cgit-bbcdc290c6c0b8121e57dbca4bd66c9e5e729959.tar.gz
cgit-bbcdc290c6c0b8121e57dbca4bd66c9e5e729959.tar.bz2
Add repo.readme parameter
This parameter can be used to specify a repo-specific includefile, which will then be printed on the summary page for the repo. If the parametervalue is a not an absolute path, it is taken to be relative to repo.path. Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Diffstat (limited to 'shared.c') (more/less context) (ignore whitespace changes)
-rw-r--r--shared.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/shared.c b/shared.c
index ce3ca4f..e3123a8 100644
--- a/shared.c
+++ b/shared.c
@@ -94,32 +94,33 @@ struct repoinfo *add_repo(const char *url)
94 cgit_repolist.length * 94 cgit_repolist.length *
95 sizeof(struct repoinfo)); 95 sizeof(struct repoinfo));
96 } 96 }
97 97
98 ret = &cgit_repolist.repos[cgit_repolist.count-1]; 98 ret = &cgit_repolist.repos[cgit_repolist.count-1];
99 ret->url = xstrdup(url); 99 ret->url = xstrdup(url);
100 ret->name = ret->url; 100 ret->name = ret->url;
101 ret->path = NULL; 101 ret->path = NULL;
102 ret->desc = NULL; 102 ret->desc = NULL;
103 ret->owner = NULL; 103 ret->owner = NULL;
104 ret->group = cgit_repo_group; 104 ret->group = cgit_repo_group;
105 ret->defbranch = "master"; 105 ret->defbranch = "master";
106 ret->snapshots = cgit_snapshots; 106 ret->snapshots = cgit_snapshots;
107 ret->enable_log_filecount = cgit_enable_log_filecount; 107 ret->enable_log_filecount = cgit_enable_log_filecount;
108 ret->enable_log_linecount = cgit_enable_log_linecount; 108 ret->enable_log_linecount = cgit_enable_log_linecount;
109 ret->module_link = cgit_module_link; 109 ret->module_link = cgit_module_link;
110 ret->readme = NULL;
110 return ret; 111 return ret;
111} 112}
112 113
113struct repoinfo *cgit_get_repoinfo(const char *url) 114struct repoinfo *cgit_get_repoinfo(const char *url)
114{ 115{
115 int i; 116 int i;
116 struct repoinfo *repo; 117 struct repoinfo *repo;
117 118
118 for (i=0; i<cgit_repolist.count; i++) { 119 for (i=0; i<cgit_repolist.count; i++) {
119 repo = &cgit_repolist.repos[i]; 120 repo = &cgit_repolist.repos[i];
120 if (!strcmp(repo->url, url)) 121 if (!strcmp(repo->url, url))
121 return repo; 122 return repo;
122 } 123 }
123 return NULL; 124 return NULL;
124} 125}
125 126
@@ -174,33 +175,38 @@ void cgit_global_config_cb(const char *name, const char *value)
174 else if (cgit_repo && !strcmp(name, "repo.path")) 175 else if (cgit_repo && !strcmp(name, "repo.path"))
175 cgit_repo->path = xstrdup(value); 176 cgit_repo->path = xstrdup(value);
176 else if (cgit_repo && !strcmp(name, "repo.desc")) 177 else if (cgit_repo && !strcmp(name, "repo.desc"))
177 cgit_repo->desc = xstrdup(value); 178 cgit_repo->desc = xstrdup(value);
178 else if (cgit_repo && !strcmp(name, "repo.owner")) 179 else if (cgit_repo && !strcmp(name, "repo.owner"))
179 cgit_repo->owner = xstrdup(value); 180 cgit_repo->owner = xstrdup(value);
180 else if (cgit_repo && !strcmp(name, "repo.defbranch")) 181 else if (cgit_repo && !strcmp(name, "repo.defbranch"))
181 cgit_repo->defbranch = xstrdup(value); 182 cgit_repo->defbranch = xstrdup(value);
182 else if (cgit_repo && !strcmp(name, "repo.snapshots")) 183 else if (cgit_repo && !strcmp(name, "repo.snapshots"))
183 cgit_repo->snapshots = cgit_snapshots * atoi(value); 184 cgit_repo->snapshots = cgit_snapshots * atoi(value);
184 else if (cgit_repo && !strcmp(name, "repo.enable-log-filecount")) 185 else if (cgit_repo && !strcmp(name, "repo.enable-log-filecount"))
185 cgit_repo->enable_log_filecount = cgit_enable_log_filecount * atoi(value); 186 cgit_repo->enable_log_filecount = cgit_enable_log_filecount * atoi(value);
186 else if (cgit_repo && !strcmp(name, "repo.enable-log-linecount")) 187 else if (cgit_repo && !strcmp(name, "repo.enable-log-linecount"))
187 cgit_repo->enable_log_linecount = cgit_enable_log_linecount * atoi(value); 188 cgit_repo->enable_log_linecount = cgit_enable_log_linecount * atoi(value);
188 else if (cgit_repo && !strcmp(name, "repo.module-link")) 189 else if (cgit_repo && !strcmp(name, "repo.module-link"))
189 cgit_repo->module_link= xstrdup(value); 190 cgit_repo->module_link= xstrdup(value);
190 else if (!strcmp(name, "include")) 191 else if (cgit_repo && !strcmp(name, "repo.readme") && value != NULL) {
192 if (*value == '/')
193 cgit_repo->readme = xstrdup(value);
194 else
195 cgit_repo->readme = xstrdup(fmt("%s/%s", cgit_repo->path, value));
196 } else if (!strcmp(name, "include"))
191 cgit_read_config(value, cgit_global_config_cb); 197 cgit_read_config(value, cgit_global_config_cb);
192} 198}
193 199
194void cgit_querystring_cb(const char *name, const char *value) 200void cgit_querystring_cb(const char *name, const char *value)
195{ 201{
196 if (!strcmp(name,"r")) { 202 if (!strcmp(name,"r")) {
197 cgit_query_repo = xstrdup(value); 203 cgit_query_repo = xstrdup(value);
198 cgit_repo = cgit_get_repoinfo(value); 204 cgit_repo = cgit_get_repoinfo(value);
199 } else if (!strcmp(name, "p")) { 205 } else if (!strcmp(name, "p")) {
200 cgit_query_page = xstrdup(value); 206 cgit_query_page = xstrdup(value);
201 cgit_cmd = cgit_get_cmd_index(value); 207 cgit_cmd = cgit_get_cmd_index(value);
202 } else if (!strcmp(name, "url")) { 208 } else if (!strcmp(name, "url")) {
203 cgit_parse_url(value); 209 cgit_parse_url(value);
204 } else if (!strcmp(name, "q")) { 210 } else if (!strcmp(name, "q")) {
205 cgit_query_search = xstrdup(value); 211 cgit_query_search = xstrdup(value);
206 } else if (!strcmp(name, "h")) { 212 } else if (!strcmp(name, "h")) {