-rw-r--r-- | cgit.c | 2 | ||||
-rw-r--r-- | cgit.h | 2 | ||||
-rw-r--r-- | ui-shared.c | 2 |
3 files changed, 6 insertions, 0 deletions
@@ -224,128 +224,130 @@ int find_current_ref(const char *refname, const unsigned char *sha1, | |||
224 | info->match = 1; | 224 | info->match = 1; |
225 | if (!info->first_ref) | 225 | if (!info->first_ref) |
226 | info->first_ref = xstrdup(refname); | 226 | info->first_ref = xstrdup(refname); |
227 | return info->match; | 227 | return info->match; |
228 | } | 228 | } |
229 | 229 | ||
230 | char *find_default_branch(struct cgit_repo *repo) | 230 | char *find_default_branch(struct cgit_repo *repo) |
231 | { | 231 | { |
232 | struct refmatch info; | 232 | struct refmatch info; |
233 | char *ref; | 233 | char *ref; |
234 | 234 | ||
235 | info.req_ref = repo->defbranch; | 235 | info.req_ref = repo->defbranch; |
236 | info.first_ref = NULL; | 236 | info.first_ref = NULL; |
237 | info.match = 0; | 237 | info.match = 0; |
238 | for_each_branch_ref(find_current_ref, &info); | 238 | for_each_branch_ref(find_current_ref, &info); |
239 | if (info.match) | 239 | if (info.match) |
240 | ref = info.req_ref; | 240 | ref = info.req_ref; |
241 | else | 241 | else |
242 | ref = info.first_ref; | 242 | ref = info.first_ref; |
243 | if (ref) | 243 | if (ref) |
244 | ref = xstrdup(ref); | 244 | ref = xstrdup(ref); |
245 | return ref; | 245 | return ref; |
246 | } | 246 | } |
247 | 247 | ||
248 | static int prepare_repo_cmd(struct cgit_context *ctx) | 248 | static int prepare_repo_cmd(struct cgit_context *ctx) |
249 | { | 249 | { |
250 | char *tmp; | 250 | char *tmp; |
251 | unsigned char sha1[20]; | 251 | unsigned char sha1[20]; |
252 | int nongit = 0; | 252 | int nongit = 0; |
253 | 253 | ||
254 | setenv("GIT_DIR", ctx->repo->path, 1); | 254 | setenv("GIT_DIR", ctx->repo->path, 1); |
255 | setup_git_directory_gently(&nongit); | 255 | setup_git_directory_gently(&nongit); |
256 | if (nongit) { | 256 | if (nongit) { |
257 | ctx->page.title = fmt("%s - %s", ctx->cfg.root_title, | 257 | ctx->page.title = fmt("%s - %s", ctx->cfg.root_title, |
258 | "config error"); | 258 | "config error"); |
259 | tmp = fmt("Not a git repository: '%s'", ctx->repo->path); | 259 | tmp = fmt("Not a git repository: '%s'", ctx->repo->path); |
260 | ctx->repo = NULL; | 260 | ctx->repo = NULL; |
261 | cgit_print_http_headers(ctx); | 261 | cgit_print_http_headers(ctx); |
262 | cgit_print_docstart(ctx); | 262 | cgit_print_docstart(ctx); |
263 | cgit_print_pageheader(ctx); | 263 | cgit_print_pageheader(ctx); |
264 | cgit_print_error(tmp); | 264 | cgit_print_error(tmp); |
265 | cgit_print_docend(); | 265 | cgit_print_docend(); |
266 | return 1; | 266 | return 1; |
267 | } | 267 | } |
268 | ctx->page.title = fmt("%s - %s", ctx->repo->name, ctx->repo->desc); | 268 | ctx->page.title = fmt("%s - %s", ctx->repo->name, ctx->repo->desc); |
269 | 269 | ||
270 | if (!ctx->qry.head) { | 270 | if (!ctx->qry.head) { |
271 | ctx->qry.nohead = 1; | 271 | ctx->qry.nohead = 1; |
272 | ctx->qry.head = find_default_branch(ctx->repo); | 272 | ctx->qry.head = find_default_branch(ctx->repo); |
273 | ctx->repo->defbranch = ctx->qry.head; | 273 | ctx->repo->defbranch = ctx->qry.head; |
274 | } | 274 | } |
275 | 275 | ||
276 | if (!ctx->qry.head) { | 276 | if (!ctx->qry.head) { |
277 | cgit_print_http_headers(ctx); | 277 | cgit_print_http_headers(ctx); |
278 | cgit_print_docstart(ctx); | 278 | cgit_print_docstart(ctx); |
279 | cgit_print_pageheader(ctx); | 279 | cgit_print_pageheader(ctx); |
280 | cgit_print_error("Repository seems to be empty"); | 280 | cgit_print_error("Repository seems to be empty"); |
281 | cgit_print_docend(); | 281 | cgit_print_docend(); |
282 | return 1; | 282 | return 1; |
283 | } | 283 | } |
284 | 284 | ||
285 | if (get_sha1(ctx->qry.head, sha1)) { | 285 | if (get_sha1(ctx->qry.head, sha1)) { |
286 | tmp = xstrdup(ctx->qry.head); | 286 | tmp = xstrdup(ctx->qry.head); |
287 | ctx->qry.head = ctx->repo->defbranch; | 287 | ctx->qry.head = ctx->repo->defbranch; |
288 | ctx->page.status = 404; | ||
289 | ctx->page.statusmsg = "not found"; | ||
288 | cgit_print_http_headers(ctx); | 290 | cgit_print_http_headers(ctx); |
289 | cgit_print_docstart(ctx); | 291 | cgit_print_docstart(ctx); |
290 | cgit_print_pageheader(ctx); | 292 | cgit_print_pageheader(ctx); |
291 | cgit_print_error(fmt("Invalid branch: %s", tmp)); | 293 | cgit_print_error(fmt("Invalid branch: %s", tmp)); |
292 | cgit_print_docend(); | 294 | cgit_print_docend(); |
293 | return 1; | 295 | return 1; |
294 | } | 296 | } |
295 | return 0; | 297 | return 0; |
296 | } | 298 | } |
297 | 299 | ||
298 | static void process_request(void *cbdata) | 300 | static void process_request(void *cbdata) |
299 | { | 301 | { |
300 | struct cgit_context *ctx = cbdata; | 302 | struct cgit_context *ctx = cbdata; |
301 | struct cgit_cmd *cmd; | 303 | struct cgit_cmd *cmd; |
302 | 304 | ||
303 | cmd = cgit_get_cmd(ctx); | 305 | cmd = cgit_get_cmd(ctx); |
304 | if (!cmd) { | 306 | if (!cmd) { |
305 | ctx->page.title = "cgit error"; | 307 | ctx->page.title = "cgit error"; |
306 | cgit_print_http_headers(ctx); | 308 | cgit_print_http_headers(ctx); |
307 | cgit_print_docstart(ctx); | 309 | cgit_print_docstart(ctx); |
308 | cgit_print_pageheader(ctx); | 310 | cgit_print_pageheader(ctx); |
309 | cgit_print_error("Invalid request"); | 311 | cgit_print_error("Invalid request"); |
310 | cgit_print_docend(); | 312 | cgit_print_docend(); |
311 | return; | 313 | return; |
312 | } | 314 | } |
313 | 315 | ||
314 | if (cmd->want_repo && !ctx->repo) { | 316 | if (cmd->want_repo && !ctx->repo) { |
315 | cgit_print_http_headers(ctx); | 317 | cgit_print_http_headers(ctx); |
316 | cgit_print_docstart(ctx); | 318 | cgit_print_docstart(ctx); |
317 | cgit_print_pageheader(ctx); | 319 | cgit_print_pageheader(ctx); |
318 | cgit_print_error(fmt("No repository selected")); | 320 | cgit_print_error(fmt("No repository selected")); |
319 | cgit_print_docend(); | 321 | cgit_print_docend(); |
320 | return; | 322 | return; |
321 | } | 323 | } |
322 | 324 | ||
323 | if (ctx->repo && prepare_repo_cmd(ctx)) | 325 | if (ctx->repo && prepare_repo_cmd(ctx)) |
324 | return; | 326 | return; |
325 | 327 | ||
326 | if (cmd->want_layout) { | 328 | if (cmd->want_layout) { |
327 | cgit_print_http_headers(ctx); | 329 | cgit_print_http_headers(ctx); |
328 | cgit_print_docstart(ctx); | 330 | cgit_print_docstart(ctx); |
329 | cgit_print_pageheader(ctx); | 331 | cgit_print_pageheader(ctx); |
330 | } | 332 | } |
331 | 333 | ||
332 | cmd->fn(ctx); | 334 | cmd->fn(ctx); |
333 | 335 | ||
334 | if (cmd->want_layout) | 336 | if (cmd->want_layout) |
335 | cgit_print_docend(); | 337 | cgit_print_docend(); |
336 | } | 338 | } |
337 | 339 | ||
338 | int cmp_repos(const void *a, const void *b) | 340 | int cmp_repos(const void *a, const void *b) |
339 | { | 341 | { |
340 | const struct cgit_repo *ra = a, *rb = b; | 342 | const struct cgit_repo *ra = a, *rb = b; |
341 | return strcmp(ra->url, rb->url); | 343 | return strcmp(ra->url, rb->url); |
342 | } | 344 | } |
343 | 345 | ||
344 | void print_repo(struct cgit_repo *repo) | 346 | void print_repo(struct cgit_repo *repo) |
345 | { | 347 | { |
346 | printf("repo.url=%s\n", repo->url); | 348 | printf("repo.url=%s\n", repo->url); |
347 | printf("repo.name=%s\n", repo->name); | 349 | printf("repo.name=%s\n", repo->name); |
348 | printf("repo.path=%s\n", repo->path); | 350 | printf("repo.path=%s\n", repo->path); |
349 | if (repo->owner) | 351 | if (repo->owner) |
350 | printf("repo.owner=%s\n", repo->owner); | 352 | printf("repo.owner=%s\n", repo->owner); |
351 | if (repo->desc) | 353 | if (repo->desc) |
@@ -120,127 +120,129 @@ struct cgit_query { | |||
120 | char *sha2; | 120 | char *sha2; |
121 | char *path; | 121 | char *path; |
122 | char *name; | 122 | char *name; |
123 | char *mimetype; | 123 | char *mimetype; |
124 | char *url; | 124 | char *url; |
125 | char *period; | 125 | char *period; |
126 | int ofs; | 126 | int ofs; |
127 | int nohead; | 127 | int nohead; |
128 | char *sort; | 128 | char *sort; |
129 | int showmsg; | 129 | int showmsg; |
130 | }; | 130 | }; |
131 | 131 | ||
132 | struct cgit_config { | 132 | struct cgit_config { |
133 | char *agefile; | 133 | char *agefile; |
134 | char *cache_root; | 134 | char *cache_root; |
135 | char *clone_prefix; | 135 | char *clone_prefix; |
136 | char *css; | 136 | char *css; |
137 | char *favicon; | 137 | char *favicon; |
138 | char *footer; | 138 | char *footer; |
139 | char *header; | 139 | char *header; |
140 | char *index_header; | 140 | char *index_header; |
141 | char *index_info; | 141 | char *index_info; |
142 | char *logo; | 142 | char *logo; |
143 | char *logo_link; | 143 | char *logo_link; |
144 | char *module_link; | 144 | char *module_link; |
145 | char *repo_group; | 145 | char *repo_group; |
146 | char *robots; | 146 | char *robots; |
147 | char *root_title; | 147 | char *root_title; |
148 | char *root_desc; | 148 | char *root_desc; |
149 | char *root_readme; | 149 | char *root_readme; |
150 | char *script_name; | 150 | char *script_name; |
151 | char *virtual_root; | 151 | char *virtual_root; |
152 | int cache_size; | 152 | int cache_size; |
153 | int cache_dynamic_ttl; | 153 | int cache_dynamic_ttl; |
154 | int cache_max_create_time; | 154 | int cache_max_create_time; |
155 | int cache_repo_ttl; | 155 | int cache_repo_ttl; |
156 | int cache_root_ttl; | 156 | int cache_root_ttl; |
157 | int cache_static_ttl; | 157 | int cache_static_ttl; |
158 | int enable_index_links; | 158 | int enable_index_links; |
159 | int enable_log_filecount; | 159 | int enable_log_filecount; |
160 | int enable_log_linecount; | 160 | int enable_log_linecount; |
161 | int local_time; | 161 | int local_time; |
162 | int max_repo_count; | 162 | int max_repo_count; |
163 | int max_commit_count; | 163 | int max_commit_count; |
164 | int max_lock_attempts; | 164 | int max_lock_attempts; |
165 | int max_msg_len; | 165 | int max_msg_len; |
166 | int max_repodesc_len; | 166 | int max_repodesc_len; |
167 | int max_stats; | 167 | int max_stats; |
168 | int nocache; | 168 | int nocache; |
169 | int renamelimit; | 169 | int renamelimit; |
170 | int snapshots; | 170 | int snapshots; |
171 | int summary_branches; | 171 | int summary_branches; |
172 | int summary_log; | 172 | int summary_log; |
173 | int summary_tags; | 173 | int summary_tags; |
174 | }; | 174 | }; |
175 | 175 | ||
176 | struct cgit_page { | 176 | struct cgit_page { |
177 | time_t modified; | 177 | time_t modified; |
178 | time_t expires; | 178 | time_t expires; |
179 | size_t size; | 179 | size_t size; |
180 | char *mimetype; | 180 | char *mimetype; |
181 | char *charset; | 181 | char *charset; |
182 | char *filename; | 182 | char *filename; |
183 | char *title; | 183 | char *title; |
184 | int status; | ||
185 | char *statusmsg; | ||
184 | }; | 186 | }; |
185 | 187 | ||
186 | struct cgit_context { | 188 | struct cgit_context { |
187 | struct cgit_query qry; | 189 | struct cgit_query qry; |
188 | struct cgit_config cfg; | 190 | struct cgit_config cfg; |
189 | struct cgit_repo *repo; | 191 | struct cgit_repo *repo; |
190 | struct cgit_page page; | 192 | struct cgit_page page; |
191 | }; | 193 | }; |
192 | 194 | ||
193 | struct cgit_snapshot_format { | 195 | struct cgit_snapshot_format { |
194 | const char *suffix; | 196 | const char *suffix; |
195 | const char *mimetype; | 197 | const char *mimetype; |
196 | write_archive_fn_t write_func; | 198 | write_archive_fn_t write_func; |
197 | int bit; | 199 | int bit; |
198 | }; | 200 | }; |
199 | 201 | ||
200 | extern const char *cgit_version; | 202 | extern const char *cgit_version; |
201 | 203 | ||
202 | extern struct cgit_repolist cgit_repolist; | 204 | extern struct cgit_repolist cgit_repolist; |
203 | extern struct cgit_context ctx; | 205 | extern struct cgit_context ctx; |
204 | extern const struct cgit_snapshot_format cgit_snapshot_formats[]; | 206 | extern const struct cgit_snapshot_format cgit_snapshot_formats[]; |
205 | 207 | ||
206 | extern struct cgit_repo *cgit_add_repo(const char *url); | 208 | extern struct cgit_repo *cgit_add_repo(const char *url); |
207 | extern struct cgit_repo *cgit_get_repoinfo(const char *url); | 209 | extern struct cgit_repo *cgit_get_repoinfo(const char *url); |
208 | extern void cgit_repo_config_cb(const char *name, const char *value); | 210 | extern void cgit_repo_config_cb(const char *name, const char *value); |
209 | 211 | ||
210 | extern int chk_zero(int result, char *msg); | 212 | extern int chk_zero(int result, char *msg); |
211 | extern int chk_positive(int result, char *msg); | 213 | extern int chk_positive(int result, char *msg); |
212 | extern int chk_non_negative(int result, char *msg); | 214 | extern int chk_non_negative(int result, char *msg); |
213 | 215 | ||
214 | extern char *trim_end(const char *str, char c); | 216 | extern char *trim_end(const char *str, char c); |
215 | extern char *strlpart(char *txt, int maxlen); | 217 | extern char *strlpart(char *txt, int maxlen); |
216 | extern char *strrpart(char *txt, int maxlen); | 218 | extern char *strrpart(char *txt, int maxlen); |
217 | 219 | ||
218 | extern void cgit_add_ref(struct reflist *list, struct refinfo *ref); | 220 | extern void cgit_add_ref(struct reflist *list, struct refinfo *ref); |
219 | extern int cgit_refs_cb(const char *refname, const unsigned char *sha1, | 221 | extern int cgit_refs_cb(const char *refname, const unsigned char *sha1, |
220 | int flags, void *cb_data); | 222 | int flags, void *cb_data); |
221 | 223 | ||
222 | extern void *cgit_free_commitinfo(struct commitinfo *info); | 224 | extern void *cgit_free_commitinfo(struct commitinfo *info); |
223 | 225 | ||
224 | extern int cgit_diff_files(const unsigned char *old_sha1, | 226 | extern int cgit_diff_files(const unsigned char *old_sha1, |
225 | const unsigned char *new_sha1, | 227 | const unsigned char *new_sha1, |
226 | unsigned long *old_size, unsigned long *new_size, | 228 | unsigned long *old_size, unsigned long *new_size, |
227 | int *binary, linediff_fn fn); | 229 | int *binary, linediff_fn fn); |
228 | 230 | ||
229 | extern void cgit_diff_tree(const unsigned char *old_sha1, | 231 | extern void cgit_diff_tree(const unsigned char *old_sha1, |
230 | const unsigned char *new_sha1, | 232 | const unsigned char *new_sha1, |
231 | filepair_fn fn, const char *prefix); | 233 | filepair_fn fn, const char *prefix); |
232 | 234 | ||
233 | extern void cgit_diff_commit(struct commit *commit, filepair_fn fn); | 235 | extern void cgit_diff_commit(struct commit *commit, filepair_fn fn); |
234 | 236 | ||
235 | extern char *fmt(const char *format,...); | 237 | extern char *fmt(const char *format,...); |
236 | 238 | ||
237 | extern struct commitinfo *cgit_parse_commit(struct commit *commit); | 239 | extern struct commitinfo *cgit_parse_commit(struct commit *commit); |
238 | extern struct taginfo *cgit_parse_tag(struct tag *tag); | 240 | extern struct taginfo *cgit_parse_tag(struct tag *tag); |
239 | extern void cgit_parse_url(const char *url); | 241 | extern void cgit_parse_url(const char *url); |
240 | 242 | ||
241 | extern const char *cgit_repobasename(const char *reponame); | 243 | extern const char *cgit_repobasename(const char *reponame); |
242 | 244 | ||
243 | extern int cgit_parse_snapshots_mask(const char *str); | 245 | extern int cgit_parse_snapshots_mask(const char *str); |
244 | 246 | ||
245 | 247 | ||
246 | #endif /* CGIT_H */ | 248 | #endif /* CGIT_H */ |
diff --git a/ui-shared.c b/ui-shared.c index de77bbf..2630f23 100644 --- a/ui-shared.c +++ b/ui-shared.c | |||
@@ -395,128 +395,130 @@ void cgit_object_link(struct object *obj) | |||
395 | name = fmt("%s %s...", typename(obj->type), shortrev); | 395 | name = fmt("%s %s...", typename(obj->type), shortrev); |
396 | reporevlink(page, name, NULL, NULL, ctx.qry.head, fullrev, NULL); | 396 | reporevlink(page, name, NULL, NULL, ctx.qry.head, fullrev, NULL); |
397 | } | 397 | } |
398 | 398 | ||
399 | void cgit_print_date(time_t secs, char *format, int local_time) | 399 | void cgit_print_date(time_t secs, char *format, int local_time) |
400 | { | 400 | { |
401 | char buf[64]; | 401 | char buf[64]; |
402 | struct tm *time; | 402 | struct tm *time; |
403 | 403 | ||
404 | if (!secs) | 404 | if (!secs) |
405 | return; | 405 | return; |
406 | if(local_time) | 406 | if(local_time) |
407 | time = localtime(&secs); | 407 | time = localtime(&secs); |
408 | else | 408 | else |
409 | time = gmtime(&secs); | 409 | time = gmtime(&secs); |
410 | strftime(buf, sizeof(buf)-1, format, time); | 410 | strftime(buf, sizeof(buf)-1, format, time); |
411 | html_txt(buf); | 411 | html_txt(buf); |
412 | } | 412 | } |
413 | 413 | ||
414 | void cgit_print_age(time_t t, time_t max_relative, char *format) | 414 | void cgit_print_age(time_t t, time_t max_relative, char *format) |
415 | { | 415 | { |
416 | time_t now, secs; | 416 | time_t now, secs; |
417 | 417 | ||
418 | if (!t) | 418 | if (!t) |
419 | return; | 419 | return; |
420 | time(&now); | 420 | time(&now); |
421 | secs = now - t; | 421 | secs = now - t; |
422 | 422 | ||
423 | if (secs > max_relative && max_relative >= 0) { | 423 | if (secs > max_relative && max_relative >= 0) { |
424 | cgit_print_date(t, format, ctx.cfg.local_time); | 424 | cgit_print_date(t, format, ctx.cfg.local_time); |
425 | return; | 425 | return; |
426 | } | 426 | } |
427 | 427 | ||
428 | if (secs < TM_HOUR * 2) { | 428 | if (secs < TM_HOUR * 2) { |
429 | htmlf("<span class='age-mins'>%.0f min.</span>", | 429 | htmlf("<span class='age-mins'>%.0f min.</span>", |
430 | secs * 1.0 / TM_MIN); | 430 | secs * 1.0 / TM_MIN); |
431 | return; | 431 | return; |
432 | } | 432 | } |
433 | if (secs < TM_DAY * 2) { | 433 | if (secs < TM_DAY * 2) { |
434 | htmlf("<span class='age-hours'>%.0f hours</span>", | 434 | htmlf("<span class='age-hours'>%.0f hours</span>", |
435 | secs * 1.0 / TM_HOUR); | 435 | secs * 1.0 / TM_HOUR); |
436 | return; | 436 | return; |
437 | } | 437 | } |
438 | if (secs < TM_WEEK * 2) { | 438 | if (secs < TM_WEEK * 2) { |
439 | htmlf("<span class='age-days'>%.0f days</span>", | 439 | htmlf("<span class='age-days'>%.0f days</span>", |
440 | secs * 1.0 / TM_DAY); | 440 | secs * 1.0 / TM_DAY); |
441 | return; | 441 | return; |
442 | } | 442 | } |
443 | if (secs < TM_MONTH * 2) { | 443 | if (secs < TM_MONTH * 2) { |
444 | htmlf("<span class='age-weeks'>%.0f weeks</span>", | 444 | htmlf("<span class='age-weeks'>%.0f weeks</span>", |
445 | secs * 1.0 / TM_WEEK); | 445 | secs * 1.0 / TM_WEEK); |
446 | return; | 446 | return; |
447 | } | 447 | } |
448 | if (secs < TM_YEAR * 2) { | 448 | if (secs < TM_YEAR * 2) { |
449 | htmlf("<span class='age-months'>%.0f months</span>", | 449 | htmlf("<span class='age-months'>%.0f months</span>", |
450 | secs * 1.0 / TM_MONTH); | 450 | secs * 1.0 / TM_MONTH); |
451 | return; | 451 | return; |
452 | } | 452 | } |
453 | htmlf("<span class='age-years'>%.0f years</span>", | 453 | htmlf("<span class='age-years'>%.0f years</span>", |
454 | secs * 1.0 / TM_YEAR); | 454 | secs * 1.0 / TM_YEAR); |
455 | } | 455 | } |
456 | 456 | ||
457 | void cgit_print_http_headers(struct cgit_context *ctx) | 457 | void cgit_print_http_headers(struct cgit_context *ctx) |
458 | { | 458 | { |
459 | if (ctx->page.status) | ||
460 | htmlf("Status: %d %s\n", ctx->page.status, ctx->page.statusmsg); | ||
459 | if (ctx->page.mimetype && ctx->page.charset) | 461 | if (ctx->page.mimetype && ctx->page.charset) |
460 | htmlf("Content-Type: %s; charset=%s\n", ctx->page.mimetype, | 462 | htmlf("Content-Type: %s; charset=%s\n", ctx->page.mimetype, |
461 | ctx->page.charset); | 463 | ctx->page.charset); |
462 | else if (ctx->page.mimetype) | 464 | else if (ctx->page.mimetype) |
463 | htmlf("Content-Type: %s\n", ctx->page.mimetype); | 465 | htmlf("Content-Type: %s\n", ctx->page.mimetype); |
464 | if (ctx->page.size) | 466 | if (ctx->page.size) |
465 | htmlf("Content-Length: %ld\n", ctx->page.size); | 467 | htmlf("Content-Length: %ld\n", ctx->page.size); |
466 | if (ctx->page.filename) | 468 | if (ctx->page.filename) |
467 | htmlf("Content-Disposition: inline; filename=\"%s\"\n", | 469 | htmlf("Content-Disposition: inline; filename=\"%s\"\n", |
468 | ctx->page.filename); | 470 | ctx->page.filename); |
469 | htmlf("Last-Modified: %s\n", http_date(ctx->page.modified)); | 471 | htmlf("Last-Modified: %s\n", http_date(ctx->page.modified)); |
470 | htmlf("Expires: %s\n", http_date(ctx->page.expires)); | 472 | htmlf("Expires: %s\n", http_date(ctx->page.expires)); |
471 | html("\n"); | 473 | html("\n"); |
472 | } | 474 | } |
473 | 475 | ||
474 | void cgit_print_docstart(struct cgit_context *ctx) | 476 | void cgit_print_docstart(struct cgit_context *ctx) |
475 | { | 477 | { |
476 | char *host = cgit_hosturl(); | 478 | char *host = cgit_hosturl(); |
477 | html(cgit_doctype); | 479 | html(cgit_doctype); |
478 | html("<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>\n"); | 480 | html("<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>\n"); |
479 | html("<head>\n"); | 481 | html("<head>\n"); |
480 | html("<title>"); | 482 | html("<title>"); |
481 | html_txt(ctx->page.title); | 483 | html_txt(ctx->page.title); |
482 | html("</title>\n"); | 484 | html("</title>\n"); |
483 | htmlf("<meta name='generator' content='cgit %s'/>\n", cgit_version); | 485 | htmlf("<meta name='generator' content='cgit %s'/>\n", cgit_version); |
484 | if (ctx->cfg.robots && *ctx->cfg.robots) | 486 | if (ctx->cfg.robots && *ctx->cfg.robots) |
485 | htmlf("<meta name='robots' content='%s'/>\n", ctx->cfg.robots); | 487 | htmlf("<meta name='robots' content='%s'/>\n", ctx->cfg.robots); |
486 | html("<link rel='stylesheet' type='text/css' href='"); | 488 | html("<link rel='stylesheet' type='text/css' href='"); |
487 | html_attr(ctx->cfg.css); | 489 | html_attr(ctx->cfg.css); |
488 | html("'/>\n"); | 490 | html("'/>\n"); |
489 | if (ctx->cfg.favicon) { | 491 | if (ctx->cfg.favicon) { |
490 | html("<link rel='shortcut icon' href='"); | 492 | html("<link rel='shortcut icon' href='"); |
491 | html_attr(ctx->cfg.favicon); | 493 | html_attr(ctx->cfg.favicon); |
492 | html("'/>\n"); | 494 | html("'/>\n"); |
493 | } | 495 | } |
494 | if (host && ctx->repo) { | 496 | if (host && ctx->repo) { |
495 | html("<link rel='alternate' title='Atom feed' href='http://"); | 497 | html("<link rel='alternate' title='Atom feed' href='http://"); |
496 | html_attr(cgit_hosturl()); | 498 | html_attr(cgit_hosturl()); |
497 | html_attr(cgit_fileurl(ctx->repo->url, "atom", ctx->qry.path, | 499 | html_attr(cgit_fileurl(ctx->repo->url, "atom", ctx->qry.path, |
498 | fmt("h=%s", ctx->qry.head))); | 500 | fmt("h=%s", ctx->qry.head))); |
499 | html("' type='application/atom+xml'/>"); | 501 | html("' type='application/atom+xml'/>"); |
500 | } | 502 | } |
501 | html("</head>\n"); | 503 | html("</head>\n"); |
502 | html("<body>\n"); | 504 | html("<body>\n"); |
503 | if (ctx->cfg.header) | 505 | if (ctx->cfg.header) |
504 | html_include(ctx->cfg.header); | 506 | html_include(ctx->cfg.header); |
505 | } | 507 | } |
506 | 508 | ||
507 | void cgit_print_docend() | 509 | void cgit_print_docend() |
508 | { | 510 | { |
509 | html("</div>"); | 511 | html("</div>"); |
510 | if (ctx.cfg.footer) | 512 | if (ctx.cfg.footer) |
511 | html_include(ctx.cfg.footer); | 513 | html_include(ctx.cfg.footer); |
512 | else { | 514 | else { |
513 | htmlf("<div class='footer'>generated by cgit %s at ", | 515 | htmlf("<div class='footer'>generated by cgit %s at ", |
514 | cgit_version); | 516 | cgit_version); |
515 | cgit_print_date(time(NULL), FMT_LONGDATE, ctx.cfg.local_time); | 517 | cgit_print_date(time(NULL), FMT_LONGDATE, ctx.cfg.local_time); |
516 | html("</div>\n"); | 518 | html("</div>\n"); |
517 | } | 519 | } |
518 | html("</body>\n</html>\n"); | 520 | html("</body>\n</html>\n"); |
519 | } | 521 | } |
520 | 522 | ||
521 | int print_branch_option(const char *refname, const unsigned char *sha1, | 523 | int print_branch_option(const char *refname, const unsigned char *sha1, |
522 | int flags, void *cb_data) | 524 | int flags, void *cb_data) |