author | Lars Hjemli <hjemli@gmail.com> | 2009-02-01 18:17:52 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2009-02-01 18:17:52 (UTC) |
commit | 0b3c746ba80738dbe0885a21406409390936537c (patch) (unidiff) | |
tree | 405a9f959feafab650f53e17561a1d3a85cb8097 | |
parent | d6174b7aab476c2b6a86e59d98cf978d603045f4 (diff) | |
parent | b115955d71c50cd2d0065c45f3df6b02fa4730bd (diff) | |
download | cgit-0b3c746ba80738dbe0885a21406409390936537c.zip cgit-0b3c746ba80738dbe0885a21406409390936537c.tar.gz cgit-0b3c746ba80738dbe0885a21406409390936537c.tar.bz2 |
Merge branch 'lh/header'
-rw-r--r-- | cgit.c | 2 | ||||
-rw-r--r-- | cgit.h | 1 | ||||
-rw-r--r-- | cgitrc.5.txt | 4 | ||||
-rw-r--r-- | ui-shared.c | 2 |
4 files changed, 9 insertions, 0 deletions
@@ -1,81 +1,83 @@ | |||
1 | /* cgit.c: cgi for the git scm | 1 | /* cgit.c: cgi for the git scm |
2 | * | 2 | * |
3 | * Copyright (C) 2006 Lars Hjemli | 3 | * Copyright (C) 2006 Lars Hjemli |
4 | * | 4 | * |
5 | * Licensed under GNU General Public License v2 | 5 | * Licensed under GNU General Public License v2 |
6 | * (see COPYING for full license text) | 6 | * (see COPYING for full license text) |
7 | */ | 7 | */ |
8 | 8 | ||
9 | #include "cgit.h" | 9 | #include "cgit.h" |
10 | #include "cache.h" | 10 | #include "cache.h" |
11 | #include "cmd.h" | 11 | #include "cmd.h" |
12 | #include "configfile.h" | 12 | #include "configfile.h" |
13 | #include "html.h" | 13 | #include "html.h" |
14 | #include "ui-shared.h" | 14 | #include "ui-shared.h" |
15 | #include "ui-stats.h" | 15 | #include "ui-stats.h" |
16 | #include "scan-tree.h" | 16 | #include "scan-tree.h" |
17 | 17 | ||
18 | const char *cgit_version = CGIT_VERSION; | 18 | const char *cgit_version = CGIT_VERSION; |
19 | 19 | ||
20 | void config_cb(const char *name, const char *value) | 20 | void config_cb(const char *name, const char *value) |
21 | { | 21 | { |
22 | if (!strcmp(name, "root-title")) | 22 | if (!strcmp(name, "root-title")) |
23 | ctx.cfg.root_title = xstrdup(value); | 23 | ctx.cfg.root_title = xstrdup(value); |
24 | else if (!strcmp(name, "root-desc")) | 24 | else if (!strcmp(name, "root-desc")) |
25 | ctx.cfg.root_desc = xstrdup(value); | 25 | ctx.cfg.root_desc = xstrdup(value); |
26 | else if (!strcmp(name, "root-readme")) | 26 | else if (!strcmp(name, "root-readme")) |
27 | ctx.cfg.root_readme = xstrdup(value); | 27 | ctx.cfg.root_readme = xstrdup(value); |
28 | else if (!strcmp(name, "css")) | 28 | else if (!strcmp(name, "css")) |
29 | ctx.cfg.css = xstrdup(value); | 29 | ctx.cfg.css = xstrdup(value); |
30 | else if (!strcmp(name, "favicon")) | 30 | else if (!strcmp(name, "favicon")) |
31 | ctx.cfg.favicon = xstrdup(value); | 31 | ctx.cfg.favicon = xstrdup(value); |
32 | else if (!strcmp(name, "footer")) | 32 | else if (!strcmp(name, "footer")) |
33 | ctx.cfg.footer = xstrdup(value); | 33 | ctx.cfg.footer = xstrdup(value); |
34 | else if (!strcmp(name, "header")) | ||
35 | ctx.cfg.header = xstrdup(value); | ||
34 | else if (!strcmp(name, "logo")) | 36 | else if (!strcmp(name, "logo")) |
35 | ctx.cfg.logo = xstrdup(value); | 37 | ctx.cfg.logo = xstrdup(value); |
36 | else if (!strcmp(name, "index-header")) | 38 | else if (!strcmp(name, "index-header")) |
37 | ctx.cfg.index_header = xstrdup(value); | 39 | ctx.cfg.index_header = xstrdup(value); |
38 | else if (!strcmp(name, "index-info")) | 40 | else if (!strcmp(name, "index-info")) |
39 | ctx.cfg.index_info = xstrdup(value); | 41 | ctx.cfg.index_info = xstrdup(value); |
40 | else if (!strcmp(name, "logo-link")) | 42 | else if (!strcmp(name, "logo-link")) |
41 | ctx.cfg.logo_link = xstrdup(value); | 43 | ctx.cfg.logo_link = xstrdup(value); |
42 | else if (!strcmp(name, "module-link")) | 44 | else if (!strcmp(name, "module-link")) |
43 | ctx.cfg.module_link = xstrdup(value); | 45 | ctx.cfg.module_link = xstrdup(value); |
44 | else if (!strcmp(name, "virtual-root")) { | 46 | else if (!strcmp(name, "virtual-root")) { |
45 | ctx.cfg.virtual_root = trim_end(value, '/'); | 47 | ctx.cfg.virtual_root = trim_end(value, '/'); |
46 | if (!ctx.cfg.virtual_root && (!strcmp(value, "/"))) | 48 | if (!ctx.cfg.virtual_root && (!strcmp(value, "/"))) |
47 | ctx.cfg.virtual_root = ""; | 49 | ctx.cfg.virtual_root = ""; |
48 | } else if (!strcmp(name, "nocache")) | 50 | } else if (!strcmp(name, "nocache")) |
49 | ctx.cfg.nocache = atoi(value); | 51 | ctx.cfg.nocache = atoi(value); |
50 | else if (!strcmp(name, "snapshots")) | 52 | else if (!strcmp(name, "snapshots")) |
51 | ctx.cfg.snapshots = cgit_parse_snapshots_mask(value); | 53 | ctx.cfg.snapshots = cgit_parse_snapshots_mask(value); |
52 | else if (!strcmp(name, "enable-index-links")) | 54 | else if (!strcmp(name, "enable-index-links")) |
53 | ctx.cfg.enable_index_links = atoi(value); | 55 | ctx.cfg.enable_index_links = atoi(value); |
54 | else if (!strcmp(name, "enable-log-filecount")) | 56 | else if (!strcmp(name, "enable-log-filecount")) |
55 | ctx.cfg.enable_log_filecount = atoi(value); | 57 | ctx.cfg.enable_log_filecount = atoi(value); |
56 | else if (!strcmp(name, "enable-log-linecount")) | 58 | else if (!strcmp(name, "enable-log-linecount")) |
57 | ctx.cfg.enable_log_linecount = atoi(value); | 59 | ctx.cfg.enable_log_linecount = atoi(value); |
58 | else if (!strcmp(name, "max-stats")) | 60 | else if (!strcmp(name, "max-stats")) |
59 | ctx.cfg.max_stats = cgit_find_stats_period(value, NULL); | 61 | ctx.cfg.max_stats = cgit_find_stats_period(value, NULL); |
60 | else if (!strcmp(name, "cache-size")) | 62 | else if (!strcmp(name, "cache-size")) |
61 | ctx.cfg.cache_size = atoi(value); | 63 | ctx.cfg.cache_size = atoi(value); |
62 | else if (!strcmp(name, "cache-root")) | 64 | else if (!strcmp(name, "cache-root")) |
63 | ctx.cfg.cache_root = xstrdup(value); | 65 | ctx.cfg.cache_root = xstrdup(value); |
64 | else if (!strcmp(name, "cache-root-ttl")) | 66 | else if (!strcmp(name, "cache-root-ttl")) |
65 | ctx.cfg.cache_root_ttl = atoi(value); | 67 | ctx.cfg.cache_root_ttl = atoi(value); |
66 | else if (!strcmp(name, "cache-repo-ttl")) | 68 | else if (!strcmp(name, "cache-repo-ttl")) |
67 | ctx.cfg.cache_repo_ttl = atoi(value); | 69 | ctx.cfg.cache_repo_ttl = atoi(value); |
68 | else if (!strcmp(name, "cache-static-ttl")) | 70 | else if (!strcmp(name, "cache-static-ttl")) |
69 | ctx.cfg.cache_static_ttl = atoi(value); | 71 | ctx.cfg.cache_static_ttl = atoi(value); |
70 | else if (!strcmp(name, "cache-dynamic-ttl")) | 72 | else if (!strcmp(name, "cache-dynamic-ttl")) |
71 | ctx.cfg.cache_dynamic_ttl = atoi(value); | 73 | ctx.cfg.cache_dynamic_ttl = atoi(value); |
72 | else if (!strcmp(name, "max-message-length")) | 74 | else if (!strcmp(name, "max-message-length")) |
73 | ctx.cfg.max_msg_len = atoi(value); | 75 | ctx.cfg.max_msg_len = atoi(value); |
74 | else if (!strcmp(name, "max-repodesc-length")) | 76 | else if (!strcmp(name, "max-repodesc-length")) |
75 | ctx.cfg.max_repodesc_len = atoi(value); | 77 | ctx.cfg.max_repodesc_len = atoi(value); |
76 | else if (!strcmp(name, "max-repo-count")) | 78 | else if (!strcmp(name, "max-repo-count")) |
77 | ctx.cfg.max_repo_count = atoi(value); | 79 | ctx.cfg.max_repo_count = atoi(value); |
78 | else if (!strcmp(name, "max-commit-count")) | 80 | else if (!strcmp(name, "max-commit-count")) |
79 | ctx.cfg.max_commit_count = atoi(value); | 81 | ctx.cfg.max_commit_count = atoi(value); |
80 | else if (!strcmp(name, "summary-log")) | 82 | else if (!strcmp(name, "summary-log")) |
81 | ctx.cfg.summary_log = atoi(value); | 83 | ctx.cfg.summary_log = atoi(value); |
@@ -90,96 +90,97 @@ struct taginfo { | |||
90 | unsigned long tagger_date; | 90 | unsigned long tagger_date; |
91 | char *msg; | 91 | char *msg; |
92 | }; | 92 | }; |
93 | 93 | ||
94 | struct refinfo { | 94 | struct refinfo { |
95 | const char *refname; | 95 | const char *refname; |
96 | struct object *object; | 96 | struct object *object; |
97 | union { | 97 | union { |
98 | struct taginfo *tag; | 98 | struct taginfo *tag; |
99 | struct commitinfo *commit; | 99 | struct commitinfo *commit; |
100 | }; | 100 | }; |
101 | }; | 101 | }; |
102 | 102 | ||
103 | struct reflist { | 103 | struct reflist { |
104 | struct refinfo **refs; | 104 | struct refinfo **refs; |
105 | int alloc; | 105 | int alloc; |
106 | int count; | 106 | int count; |
107 | }; | 107 | }; |
108 | 108 | ||
109 | struct cgit_query { | 109 | struct cgit_query { |
110 | int has_symref; | 110 | int has_symref; |
111 | int has_sha1; | 111 | int has_sha1; |
112 | char *raw; | 112 | char *raw; |
113 | char *repo; | 113 | char *repo; |
114 | char *page; | 114 | char *page; |
115 | char *search; | 115 | char *search; |
116 | char *grep; | 116 | char *grep; |
117 | char *head; | 117 | char *head; |
118 | char *sha1; | 118 | char *sha1; |
119 | char *sha2; | 119 | char *sha2; |
120 | char *path; | 120 | char *path; |
121 | char *name; | 121 | char *name; |
122 | char *mimetype; | 122 | char *mimetype; |
123 | char *url; | 123 | char *url; |
124 | char *period; | 124 | char *period; |
125 | int ofs; | 125 | int ofs; |
126 | int nohead; | 126 | int nohead; |
127 | char *sort; | 127 | char *sort; |
128 | int showmsg; | 128 | int showmsg; |
129 | }; | 129 | }; |
130 | 130 | ||
131 | struct cgit_config { | 131 | struct cgit_config { |
132 | char *agefile; | 132 | char *agefile; |
133 | char *cache_root; | 133 | char *cache_root; |
134 | char *clone_prefix; | 134 | char *clone_prefix; |
135 | char *css; | 135 | char *css; |
136 | char *favicon; | 136 | char *favicon; |
137 | char *footer; | 137 | char *footer; |
138 | char *header; | ||
138 | char *index_header; | 139 | char *index_header; |
139 | char *index_info; | 140 | char *index_info; |
140 | char *logo; | 141 | char *logo; |
141 | char *logo_link; | 142 | char *logo_link; |
142 | char *module_link; | 143 | char *module_link; |
143 | char *repo_group; | 144 | char *repo_group; |
144 | char *robots; | 145 | char *robots; |
145 | char *root_title; | 146 | char *root_title; |
146 | char *root_desc; | 147 | char *root_desc; |
147 | char *root_readme; | 148 | char *root_readme; |
148 | char *script_name; | 149 | char *script_name; |
149 | char *virtual_root; | 150 | char *virtual_root; |
150 | int cache_size; | 151 | int cache_size; |
151 | int cache_dynamic_ttl; | 152 | int cache_dynamic_ttl; |
152 | int cache_max_create_time; | 153 | int cache_max_create_time; |
153 | int cache_repo_ttl; | 154 | int cache_repo_ttl; |
154 | int cache_root_ttl; | 155 | int cache_root_ttl; |
155 | int cache_static_ttl; | 156 | int cache_static_ttl; |
156 | int enable_index_links; | 157 | int enable_index_links; |
157 | int enable_log_filecount; | 158 | int enable_log_filecount; |
158 | int enable_log_linecount; | 159 | int enable_log_linecount; |
159 | int local_time; | 160 | int local_time; |
160 | int max_repo_count; | 161 | int max_repo_count; |
161 | int max_commit_count; | 162 | int max_commit_count; |
162 | int max_lock_attempts; | 163 | int max_lock_attempts; |
163 | int max_msg_len; | 164 | int max_msg_len; |
164 | int max_repodesc_len; | 165 | int max_repodesc_len; |
165 | int max_stats; | 166 | int max_stats; |
166 | int nocache; | 167 | int nocache; |
167 | int renamelimit; | 168 | int renamelimit; |
168 | int snapshots; | 169 | int snapshots; |
169 | int summary_branches; | 170 | int summary_branches; |
170 | int summary_log; | 171 | int summary_log; |
171 | int summary_tags; | 172 | int summary_tags; |
172 | }; | 173 | }; |
173 | 174 | ||
174 | struct cgit_page { | 175 | struct cgit_page { |
175 | time_t modified; | 176 | time_t modified; |
176 | time_t expires; | 177 | time_t expires; |
177 | size_t size; | 178 | size_t size; |
178 | char *mimetype; | 179 | char *mimetype; |
179 | char *charset; | 180 | char *charset; |
180 | char *filename; | 181 | char *filename; |
181 | char *title; | 182 | char *title; |
182 | }; | 183 | }; |
183 | 184 | ||
184 | struct cgit_context { | 185 | struct cgit_context { |
185 | struct cgit_query qry; | 186 | struct cgit_query qry; |
diff --git a/cgitrc.5.txt b/cgitrc.5.txt index 09f56a6..fd299ae 100644 --- a/cgitrc.5.txt +++ b/cgitrc.5.txt | |||
@@ -39,96 +39,100 @@ cache-repo-ttl | |||
39 | cache-root-ttl | 39 | cache-root-ttl |
40 | Number which specifies the time-to-live, in minutes, for the cached | 40 | Number which specifies the time-to-live, in minutes, for the cached |
41 | version of the repository index page. Default value: "5". | 41 | version of the repository index page. Default value: "5". |
42 | 42 | ||
43 | cache-size | 43 | cache-size |
44 | The maximum number of entries in the cgit cache. Default value: "0" | 44 | The maximum number of entries in the cgit cache. Default value: "0" |
45 | (i.e. caching is disabled). | 45 | (i.e. caching is disabled). |
46 | 46 | ||
47 | cache-static-ttl | 47 | cache-static-ttl |
48 | Number which specifies the time-to-live, in minutes, for the cached | 48 | Number which specifies the time-to-live, in minutes, for the cached |
49 | version of repository pages accessed with a fixed SHA1. Default value: | 49 | version of repository pages accessed with a fixed SHA1. Default value: |
50 | "5". | 50 | "5". |
51 | 51 | ||
52 | clone-prefix | 52 | clone-prefix |
53 | Space-separated list of common prefixes which, when combined with a | 53 | Space-separated list of common prefixes which, when combined with a |
54 | repository url, generates valid clone urls for the repository. This | 54 | repository url, generates valid clone urls for the repository. This |
55 | setting is only used if `repo.clone-url` is unspecified. Default value: | 55 | setting is only used if `repo.clone-url` is unspecified. Default value: |
56 | none. | 56 | none. |
57 | 57 | ||
58 | css | 58 | css |
59 | Url which specifies the css document to include in all cgit pages. | 59 | Url which specifies the css document to include in all cgit pages. |
60 | Default value: "/cgit.css". | 60 | Default value: "/cgit.css". |
61 | 61 | ||
62 | enable-index-links | 62 | enable-index-links |
63 | Flag which, when set to "1", will make cgit generate extra links for | 63 | Flag which, when set to "1", will make cgit generate extra links for |
64 | each repo in the repository index (specifically, to the "summary", | 64 | each repo in the repository index (specifically, to the "summary", |
65 | "commit" and "tree" pages). Default value: "0". | 65 | "commit" and "tree" pages). Default value: "0". |
66 | 66 | ||
67 | enable-log-filecount | 67 | enable-log-filecount |
68 | Flag which, when set to "1", will make cgit print the number of | 68 | Flag which, when set to "1", will make cgit print the number of |
69 | modified files for each commit on the repository log page. Default | 69 | modified files for each commit on the repository log page. Default |
70 | value: "0". | 70 | value: "0". |
71 | 71 | ||
72 | enable-log-linecount | 72 | enable-log-linecount |
73 | Flag which, when set to "1", will make cgit print the number of added | 73 | Flag which, when set to "1", will make cgit print the number of added |
74 | and removed lines for each commit on the repository log page. Default | 74 | and removed lines for each commit on the repository log page. Default |
75 | value: "0". | 75 | value: "0". |
76 | 76 | ||
77 | favicon | 77 | favicon |
78 | Url used as link to a shortcut icon for cgit. If specified, it is | 78 | Url used as link to a shortcut icon for cgit. If specified, it is |
79 | suggested to use the value "/favicon.ico" since certain browsers will | 79 | suggested to use the value "/favicon.ico" since certain browsers will |
80 | ignore other values. Default value: none. | 80 | ignore other values. Default value: none. |
81 | 81 | ||
82 | footer | 82 | footer |
83 | The content of the file specified with this option will be included | 83 | The content of the file specified with this option will be included |
84 | verbatim at the bottom of all pages (i.e. it replaces the standard | 84 | verbatim at the bottom of all pages (i.e. it replaces the standard |
85 | "generated by..." message. Default value: none. | 85 | "generated by..." message. Default value: none. |
86 | 86 | ||
87 | header | ||
88 | The content of the file specified with this option will be included | ||
89 | verbatim at the top of all pages. Default value: none. | ||
90 | |||
87 | include | 91 | include |
88 | Name of a configfile to include before the rest of the current config- | 92 | Name of a configfile to include before the rest of the current config- |
89 | file is parsed. Default value: none. | 93 | file is parsed. Default value: none. |
90 | 94 | ||
91 | index-header | 95 | index-header |
92 | The content of the file specified with this option will be included | 96 | The content of the file specified with this option will be included |
93 | verbatim above the repository index. This setting is deprecated, and | 97 | verbatim above the repository index. This setting is deprecated, and |
94 | will not be supported by cgit-1.0 (use root-readme instead). Default | 98 | will not be supported by cgit-1.0 (use root-readme instead). Default |
95 | value: none. | 99 | value: none. |
96 | 100 | ||
97 | index-info | 101 | index-info |
98 | The content of the file specified with this option will be included | 102 | The content of the file specified with this option will be included |
99 | verbatim below the heading on the repository index page. This setting | 103 | verbatim below the heading on the repository index page. This setting |
100 | is deprecated, and will not be supported by cgit-1.0 (use root-desc | 104 | is deprecated, and will not be supported by cgit-1.0 (use root-desc |
101 | instead). Default value: none. | 105 | instead). Default value: none. |
102 | 106 | ||
103 | local-time | 107 | local-time |
104 | Flag which, if set to "1", makes cgit print commit and tag times in the | 108 | Flag which, if set to "1", makes cgit print commit and tag times in the |
105 | servers timezone. Default value: "0". | 109 | servers timezone. Default value: "0". |
106 | 110 | ||
107 | logo | 111 | logo |
108 | Url which specifies the source of an image which will be used as a logo | 112 | Url which specifies the source of an image which will be used as a logo |
109 | on all cgit pages. | 113 | on all cgit pages. |
110 | 114 | ||
111 | logo-link | 115 | logo-link |
112 | Url loaded when clicking on the cgit logo image. If unspecified the | 116 | Url loaded when clicking on the cgit logo image. If unspecified the |
113 | calculated url of the repository index page will be used. Default | 117 | calculated url of the repository index page will be used. Default |
114 | value: none. | 118 | value: none. |
115 | 119 | ||
116 | max-commit-count | 120 | max-commit-count |
117 | Specifies the number of entries to list per page in "log" view. Default | 121 | Specifies the number of entries to list per page in "log" view. Default |
118 | value: "50". | 122 | value: "50". |
119 | 123 | ||
120 | max-message-length | 124 | max-message-length |
121 | Specifies the maximum number of commit message characters to display in | 125 | Specifies the maximum number of commit message characters to display in |
122 | "log" view. Default value: "80". | 126 | "log" view. Default value: "80". |
123 | 127 | ||
124 | max-repo-count | 128 | max-repo-count |
125 | Specifies the number of entries to list per page on therepository | 129 | Specifies the number of entries to list per page on therepository |
126 | index page. Default value: "50". | 130 | index page. Default value: "50". |
127 | 131 | ||
128 | max-repodesc-length | 132 | max-repodesc-length |
129 | Specifies the maximum number of repo description characters to display | 133 | Specifies the maximum number of repo description characters to display |
130 | on the repository index page. Default value: "80". | 134 | on the repository index page. Default value: "80". |
131 | 135 | ||
132 | max-stats | 136 | max-stats |
133 | Set the default maximum statistics period. Valid values are "week", | 137 | Set the default maximum statistics period. Valid values are "week", |
134 | "month", "quarter" and "year". If unspecified, statistics are | 138 | "month", "quarter" and "year". If unspecified, statistics are |
diff --git a/ui-shared.c b/ui-shared.c index 4f28512..de77bbf 100644 --- a/ui-shared.c +++ b/ui-shared.c | |||
@@ -455,96 +455,98 @@ void cgit_print_age(time_t t, time_t max_relative, char *format) | |||
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.mimetype && ctx->page.charset) | 459 | if (ctx->page.mimetype && ctx->page.charset) |
460 | htmlf("Content-Type: %s; charset=%s\n", ctx->page.mimetype, | 460 | htmlf("Content-Type: %s; charset=%s\n", ctx->page.mimetype, |
461 | ctx->page.charset); | 461 | ctx->page.charset); |
462 | else if (ctx->page.mimetype) | 462 | else if (ctx->page.mimetype) |
463 | htmlf("Content-Type: %s\n", ctx->page.mimetype); | 463 | htmlf("Content-Type: %s\n", ctx->page.mimetype); |
464 | if (ctx->page.size) | 464 | if (ctx->page.size) |
465 | htmlf("Content-Length: %ld\n", ctx->page.size); | 465 | htmlf("Content-Length: %ld\n", ctx->page.size); |
466 | if (ctx->page.filename) | 466 | if (ctx->page.filename) |
467 | htmlf("Content-Disposition: inline; filename=\"%s\"\n", | 467 | htmlf("Content-Disposition: inline; filename=\"%s\"\n", |
468 | ctx->page.filename); | 468 | ctx->page.filename); |
469 | htmlf("Last-Modified: %s\n", http_date(ctx->page.modified)); | 469 | htmlf("Last-Modified: %s\n", http_date(ctx->page.modified)); |
470 | htmlf("Expires: %s\n", http_date(ctx->page.expires)); | 470 | htmlf("Expires: %s\n", http_date(ctx->page.expires)); |
471 | html("\n"); | 471 | html("\n"); |
472 | } | 472 | } |
473 | 473 | ||
474 | void cgit_print_docstart(struct cgit_context *ctx) | 474 | void cgit_print_docstart(struct cgit_context *ctx) |
475 | { | 475 | { |
476 | char *host = cgit_hosturl(); | 476 | char *host = cgit_hosturl(); |
477 | html(cgit_doctype); | 477 | html(cgit_doctype); |
478 | html("<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>\n"); | 478 | html("<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>\n"); |
479 | html("<head>\n"); | 479 | html("<head>\n"); |
480 | html("<title>"); | 480 | html("<title>"); |
481 | html_txt(ctx->page.title); | 481 | html_txt(ctx->page.title); |
482 | html("</title>\n"); | 482 | html("</title>\n"); |
483 | htmlf("<meta name='generator' content='cgit %s'/>\n", cgit_version); | 483 | htmlf("<meta name='generator' content='cgit %s'/>\n", cgit_version); |
484 | if (ctx->cfg.robots && *ctx->cfg.robots) | 484 | if (ctx->cfg.robots && *ctx->cfg.robots) |
485 | htmlf("<meta name='robots' content='%s'/>\n", ctx->cfg.robots); | 485 | htmlf("<meta name='robots' content='%s'/>\n", ctx->cfg.robots); |
486 | html("<link rel='stylesheet' type='text/css' href='"); | 486 | html("<link rel='stylesheet' type='text/css' href='"); |
487 | html_attr(ctx->cfg.css); | 487 | html_attr(ctx->cfg.css); |
488 | html("'/>\n"); | 488 | html("'/>\n"); |
489 | if (ctx->cfg.favicon) { | 489 | if (ctx->cfg.favicon) { |
490 | html("<link rel='shortcut icon' href='"); | 490 | html("<link rel='shortcut icon' href='"); |
491 | html_attr(ctx->cfg.favicon); | 491 | html_attr(ctx->cfg.favicon); |
492 | html("'/>\n"); | 492 | html("'/>\n"); |
493 | } | 493 | } |
494 | if (host && ctx->repo) { | 494 | if (host && ctx->repo) { |
495 | html("<link rel='alternate' title='Atom feed' href='http://"); | 495 | html("<link rel='alternate' title='Atom feed' href='http://"); |
496 | html_attr(cgit_hosturl()); | 496 | html_attr(cgit_hosturl()); |
497 | html_attr(cgit_fileurl(ctx->repo->url, "atom", ctx->qry.path, | 497 | html_attr(cgit_fileurl(ctx->repo->url, "atom", ctx->qry.path, |
498 | fmt("h=%s", ctx->qry.head))); | 498 | fmt("h=%s", ctx->qry.head))); |
499 | html("' type='application/atom+xml'/>"); | 499 | html("' type='application/atom+xml'/>"); |
500 | } | 500 | } |
501 | html("</head>\n"); | 501 | html("</head>\n"); |
502 | html("<body>\n"); | 502 | html("<body>\n"); |
503 | if (ctx->cfg.header) | ||
504 | html_include(ctx->cfg.header); | ||
503 | } | 505 | } |
504 | 506 | ||
505 | void cgit_print_docend() | 507 | void cgit_print_docend() |
506 | { | 508 | { |
507 | html("</div>"); | 509 | html("</div>"); |
508 | if (ctx.cfg.footer) | 510 | if (ctx.cfg.footer) |
509 | html_include(ctx.cfg.footer); | 511 | html_include(ctx.cfg.footer); |
510 | else { | 512 | else { |
511 | htmlf("<div class='footer'>generated by cgit %s at ", | 513 | htmlf("<div class='footer'>generated by cgit %s at ", |
512 | cgit_version); | 514 | cgit_version); |
513 | cgit_print_date(time(NULL), FMT_LONGDATE, ctx.cfg.local_time); | 515 | cgit_print_date(time(NULL), FMT_LONGDATE, ctx.cfg.local_time); |
514 | html("</div>\n"); | 516 | html("</div>\n"); |
515 | } | 517 | } |
516 | html("</body>\n</html>\n"); | 518 | html("</body>\n</html>\n"); |
517 | } | 519 | } |
518 | 520 | ||
519 | int print_branch_option(const char *refname, const unsigned char *sha1, | 521 | int print_branch_option(const char *refname, const unsigned char *sha1, |
520 | int flags, void *cb_data) | 522 | int flags, void *cb_data) |
521 | { | 523 | { |
522 | char *name = (char *)refname; | 524 | char *name = (char *)refname; |
523 | html_option(name, name, ctx.qry.head); | 525 | html_option(name, name, ctx.qry.head); |
524 | return 0; | 526 | return 0; |
525 | } | 527 | } |
526 | 528 | ||
527 | int print_archive_ref(const char *refname, const unsigned char *sha1, | 529 | int print_archive_ref(const char *refname, const unsigned char *sha1, |
528 | int flags, void *cb_data) | 530 | int flags, void *cb_data) |
529 | { | 531 | { |
530 | struct tag *tag; | 532 | struct tag *tag; |
531 | struct taginfo *info; | 533 | struct taginfo *info; |
532 | struct object *obj; | 534 | struct object *obj; |
533 | char buf[256], *url; | 535 | char buf[256], *url; |
534 | unsigned char fileid[20]; | 536 | unsigned char fileid[20]; |
535 | int *header = (int *)cb_data; | 537 | int *header = (int *)cb_data; |
536 | 538 | ||
537 | if (prefixcmp(refname, "refs/archives")) | 539 | if (prefixcmp(refname, "refs/archives")) |
538 | return 0; | 540 | return 0; |
539 | strncpy(buf, refname+14, sizeof(buf)); | 541 | strncpy(buf, refname+14, sizeof(buf)); |
540 | obj = parse_object(sha1); | 542 | obj = parse_object(sha1); |
541 | if (!obj) | 543 | if (!obj) |
542 | return 1; | 544 | return 1; |
543 | if (obj->type == OBJ_TAG) { | 545 | if (obj->type == OBJ_TAG) { |
544 | tag = lookup_tag(sha1); | 546 | tag = lookup_tag(sha1); |
545 | if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag))) | 547 | if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag))) |
546 | return 0; | 548 | return 0; |
547 | hashcpy(fileid, tag->tagged->sha1); | 549 | hashcpy(fileid, tag->tagged->sha1); |
548 | } else if (obj->type != OBJ_BLOB) { | 550 | } else if (obj->type != OBJ_BLOB) { |
549 | return 0; | 551 | return 0; |
550 | } else { | 552 | } else { |