author | Lars Hjemli <hjemli@gmail.com> | 2007-05-23 20:46:54 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2007-05-23 20:46:54 (UTC) |
commit | bbcdc290c6c0b8121e57dbca4bd66c9e5e729959 (patch) (unidiff) | |
tree | fb762f2153b60cc4f997095626af70baa16ce7b1 /shared.c | |
parent | 25da3f76255754c8b3f98232a5eb84f47088d0f7 (diff) | |
download | cgit-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>
-rw-r--r-- | shared.c | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -78,64 +78,65 @@ int chk_positive(int result, char *msg) | |||
78 | { | 78 | { |
79 | if (result <= 0) | 79 | if (result <= 0) |
80 | die("%s: %s", msg, strerror(errno)); | 80 | die("%s: %s", msg, strerror(errno)); |
81 | return result; | 81 | return result; |
82 | } | 82 | } |
83 | 83 | ||
84 | struct repoinfo *add_repo(const char *url) | 84 | struct repoinfo *add_repo(const char *url) |
85 | { | 85 | { |
86 | struct repoinfo *ret; | 86 | struct repoinfo *ret; |
87 | 87 | ||
88 | if (++cgit_repolist.count > cgit_repolist.length) { | 88 | if (++cgit_repolist.count > cgit_repolist.length) { |
89 | if (cgit_repolist.length == 0) | 89 | if (cgit_repolist.length == 0) |
90 | cgit_repolist.length = 8; | 90 | cgit_repolist.length = 8; |
91 | else | 91 | else |
92 | cgit_repolist.length *= 2; | 92 | cgit_repolist.length *= 2; |
93 | cgit_repolist.repos = xrealloc(cgit_repolist.repos, | 93 | cgit_repolist.repos = xrealloc(cgit_repolist.repos, |
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 | ||
113 | struct repoinfo *cgit_get_repoinfo(const char *url) | 114 | struct 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 | ||
126 | void cgit_global_config_cb(const char *name, const char *value) | 127 | void cgit_global_config_cb(const char *name, const char *value) |
127 | { | 128 | { |
128 | if (!strcmp(name, "root-title")) | 129 | if (!strcmp(name, "root-title")) |
129 | cgit_root_title = xstrdup(value); | 130 | cgit_root_title = xstrdup(value); |
130 | else if (!strcmp(name, "css")) | 131 | else if (!strcmp(name, "css")) |
131 | cgit_css = xstrdup(value); | 132 | cgit_css = xstrdup(value); |
132 | else if (!strcmp(name, "logo")) | 133 | else if (!strcmp(name, "logo")) |
133 | cgit_logo = xstrdup(value); | 134 | cgit_logo = xstrdup(value); |
134 | else if (!strcmp(name, "index-header")) | 135 | else if (!strcmp(name, "index-header")) |
135 | cgit_index_header = xstrdup(value); | 136 | cgit_index_header = xstrdup(value); |
136 | else if (!strcmp(name, "logo-link")) | 137 | else if (!strcmp(name, "logo-link")) |
137 | cgit_logo_link = xstrdup(value); | 138 | cgit_logo_link = xstrdup(value); |
138 | else if (!strcmp(name, "module-link")) | 139 | else if (!strcmp(name, "module-link")) |
139 | cgit_module_link = xstrdup(value); | 140 | cgit_module_link = xstrdup(value); |
140 | else if (!strcmp(name, "virtual-root")) | 141 | else if (!strcmp(name, "virtual-root")) |
141 | cgit_virtual_root = xstrdup(value); | 142 | cgit_virtual_root = xstrdup(value); |
@@ -158,65 +159,70 @@ void cgit_global_config_cb(const char *name, const char *value) | |||
158 | else if (!strcmp(name, "cache-dynamic-ttl")) | 159 | else if (!strcmp(name, "cache-dynamic-ttl")) |
159 | cgit_cache_dynamic_ttl = atoi(value); | 160 | cgit_cache_dynamic_ttl = atoi(value); |
160 | else if (!strcmp(name, "max-message-length")) | 161 | else if (!strcmp(name, "max-message-length")) |
161 | cgit_max_msg_len = atoi(value); | 162 | cgit_max_msg_len = atoi(value); |
162 | else if (!strcmp(name, "max-repodesc-length")) | 163 | else if (!strcmp(name, "max-repodesc-length")) |
163 | cgit_max_repodesc_len = atoi(value); | 164 | cgit_max_repodesc_len = atoi(value); |
164 | else if (!strcmp(name, "max-commit-count")) | 165 | else if (!strcmp(name, "max-commit-count")) |
165 | cgit_max_commit_count = atoi(value); | 166 | cgit_max_commit_count = atoi(value); |
166 | else if (!strcmp(name, "agefile")) | 167 | else if (!strcmp(name, "agefile")) |
167 | cgit_agefile = xstrdup(value); | 168 | cgit_agefile = xstrdup(value); |
168 | else if (!strcmp(name, "repo.group")) | 169 | else if (!strcmp(name, "repo.group")) |
169 | cgit_repo_group = xstrdup(value); | 170 | cgit_repo_group = xstrdup(value); |
170 | else if (!strcmp(name, "repo.url")) | 171 | else if (!strcmp(name, "repo.url")) |
171 | cgit_repo = add_repo(value); | 172 | cgit_repo = add_repo(value); |
172 | else if (!strcmp(name, "repo.name")) | 173 | else if (!strcmp(name, "repo.name")) |
173 | cgit_repo->name = xstrdup(value); | 174 | cgit_repo->name = xstrdup(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 | ||
194 | void cgit_querystring_cb(const char *name, const char *value) | 200 | void 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")) { |
207 | cgit_query_head = xstrdup(value); | 213 | cgit_query_head = xstrdup(value); |
208 | cgit_query_has_symref = 1; | 214 | cgit_query_has_symref = 1; |
209 | } else if (!strcmp(name, "id")) { | 215 | } else if (!strcmp(name, "id")) { |
210 | cgit_query_sha1 = xstrdup(value); | 216 | cgit_query_sha1 = xstrdup(value); |
211 | cgit_query_has_sha1 = 1; | 217 | cgit_query_has_sha1 = 1; |
212 | } else if (!strcmp(name, "id2")) { | 218 | } else if (!strcmp(name, "id2")) { |
213 | cgit_query_sha2 = xstrdup(value); | 219 | cgit_query_sha2 = xstrdup(value); |
214 | cgit_query_has_sha1 = 1; | 220 | cgit_query_has_sha1 = 1; |
215 | } else if (!strcmp(name, "ofs")) { | 221 | } else if (!strcmp(name, "ofs")) { |
216 | cgit_query_ofs = atoi(value); | 222 | cgit_query_ofs = atoi(value); |
217 | } else if (!strcmp(name, "path")) { | 223 | } else if (!strcmp(name, "path")) { |
218 | cgit_query_path = xstrdup(value); | 224 | cgit_query_path = xstrdup(value); |
219 | } else if (!strcmp(name, "name")) { | 225 | } else if (!strcmp(name, "name")) { |
220 | cgit_query_name = xstrdup(value); | 226 | cgit_query_name = xstrdup(value); |
221 | } | 227 | } |
222 | } | 228 | } |