summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--cache.c10
-rw-r--r--cgit.c33
-rw-r--r--cgit.h72
-rw-r--r--shared.c138
-rw-r--r--ui-repolist.c18
-rw-r--r--ui-shared.c60
-rw-r--r--ui-summary.c10
7 files changed, 166 insertions, 175 deletions
diff --git a/cache.c b/cache.c
index b162952..2ed0d6f 100644
--- a/cache.c
+++ b/cache.c
@@ -46,3 +46,3 @@ int cache_create_dirs()
46 46
47 path = fmt("%s", cgit_cache_root); 47 path = fmt("%s", ctx.cfg.cache_root);
48 if (mkdir(path, S_IRWXU) && errno!=EEXIST) 48 if (mkdir(path, S_IRWXU) && errno!=EEXIST)
@@ -53,3 +53,3 @@ int cache_create_dirs()
53 53
54 path = fmt("%s/%s", cgit_cache_root, 54 path = fmt("%s/%s", ctx.cfg.cache_root,
55 cache_safe_filename(cgit_repo->url)); 55 cache_safe_filename(cgit_repo->url));
@@ -60,3 +60,3 @@ int cache_create_dirs()
60 if (ctx.qry.page) { 60 if (ctx.qry.page) {
61 path = fmt("%s/%s/%s", cgit_cache_root, 61 path = fmt("%s/%s/%s", ctx.cfg.cache_root,
62 cache_safe_filename(cgit_repo->url), 62 cache_safe_filename(cgit_repo->url),
@@ -76,3 +76,3 @@ int cache_refill_overdue(const char *lockfile)
76 else 76 else
77 return (time(NULL) - st.st_mtime > cgit_cache_max_create_time); 77 return (time(NULL) - st.st_mtime > ctx.cfg.cache_max_create_time);
78} 78}
@@ -85,3 +85,3 @@ int cache_lock(struct cacheitem *item)
85 top: 85 top:
86 if (++i > cgit_max_lock_attempts) 86 if (++i > ctx.cfg.max_lock_attempts)
87 die("cache_lock: unable to lock %s: %s", 87 die("cache_lock: unable to lock %s: %s",
diff --git a/cgit.c b/cgit.c
index 8a30c3c..f0907a1 100644
--- a/cgit.c
+++ b/cgit.c
@@ -13,3 +13,3 @@ static int cgit_prepare_cache(struct cacheitem *item)
13 if (!cgit_repo && ctx.qry.repo) { 13 if (!cgit_repo && ctx.qry.repo) {
14 char *title = fmt("%s - %s", cgit_root_title, "Bad request"); 14 char *title = fmt("%s - %s", ctx.cfg.root_title, "Bad request");
15 cgit_print_docstart(title, item); 15 cgit_print_docstart(title, item);
@@ -22,4 +22,4 @@ static int cgit_prepare_cache(struct cacheitem *item)
22 if (!cgit_repo) { 22 if (!cgit_repo) {
23 item->name = xstrdup(fmt("%s/index.html", cgit_cache_root)); 23 item->name = xstrdup(fmt("%s/index.html", ctx.cfg.cache_root));
24 item->ttl = cgit_cache_root_ttl; 24 item->ttl = ctx.cfg.cache_root_ttl;
25 return 1; 25 return 1;
@@ -28,8 +28,8 @@ static int cgit_prepare_cache(struct cacheitem *item)
28 if (!cgit_cmd) { 28 if (!cgit_cmd) {
29 item->name = xstrdup(fmt("%s/%s/index.%s.html", cgit_cache_root, 29 item->name = xstrdup(fmt("%s/%s/index.%s.html", ctx.cfg.cache_root,
30 cache_safe_filename(cgit_repo->url), 30 cache_safe_filename(cgit_repo->url),
31 cache_safe_filename(ctx.qry.raw))); 31 cache_safe_filename(ctx.qry.raw)));
32 item->ttl = cgit_cache_repo_ttl; 32 item->ttl = ctx.cfg.cache_repo_ttl;
33 } else { 33 } else {
34 item->name = xstrdup(fmt("%s/%s/%s/%s.html", cgit_cache_root, 34 item->name = xstrdup(fmt("%s/%s/%s/%s.html", ctx.cfg.cache_root,
35 cache_safe_filename(cgit_repo->url), 35 cache_safe_filename(cgit_repo->url),
@@ -38,7 +38,7 @@ static int cgit_prepare_cache(struct cacheitem *item)
38 if (ctx.qry.has_symref) 38 if (ctx.qry.has_symref)
39 item->ttl = cgit_cache_dynamic_ttl; 39 item->ttl = ctx.cfg.cache_dynamic_ttl;
40 else if (ctx.qry.has_sha1) 40 else if (ctx.qry.has_sha1)
41 item->ttl = cgit_cache_static_ttl; 41 item->ttl = ctx.cfg.cache_static_ttl;
42 else 42 else
43 item->ttl = cgit_cache_repo_ttl; 43 item->ttl = ctx.cfg.cache_repo_ttl;
44 } 44 }
@@ -87,3 +87,3 @@ static void cgit_print_repo_page(struct cacheitem *item)
87 if (chdir(cgit_repo->path)) { 87 if (chdir(cgit_repo->path)) {
88 title = fmt("%s - %s", cgit_root_title, "Bad request"); 88 title = fmt("%s - %s", ctx.cfg.root_title, "Bad request");
89 cgit_print_docstart(title, item); 89 cgit_print_docstart(title, item);
@@ -155,3 +155,3 @@ static void cgit_print_repo_page(struct cacheitem *item)
155 cgit_print_log(ctx.qry.sha1, ctx.qry.ofs, 155 cgit_print_log(ctx.qry.sha1, ctx.qry.ofs,
156 cgit_max_commit_count, ctx.qry.grep, ctx.qry.search, 156 ctx.cfg.max_commit_count, ctx.qry.grep, ctx.qry.search,
157 ctx.qry.path, 1); 157 ctx.qry.path, 1);
@@ -214,3 +214,3 @@ static void cgit_check_cache(struct cacheitem *item)
214 top: 214 top:
215 if (++i > cgit_max_lock_attempts) { 215 if (++i > ctx.cfg.max_lock_attempts) {
216 die("cgit_refresh_cache: unable to lock %s: %s", 216 die("cgit_refresh_cache: unable to lock %s: %s",
@@ -260,6 +260,6 @@ static void cgit_parse_args(int argc, const char **argv)
260 if (!strncmp(argv[i], "--cache=", 8)) { 260 if (!strncmp(argv[i], "--cache=", 8)) {
261 cgit_cache_root = xstrdup(argv[i]+8); 261 ctx.cfg.cache_root = xstrdup(argv[i]+8);
262 } 262 }
263 if (!strcmp(argv[i], "--nocache")) { 263 if (!strcmp(argv[i], "--nocache")) {
264 cgit_nocache = 1; 264 ctx.cfg.nocache = 1;
265 } 265 }
@@ -293,2 +293,3 @@ int main(int argc, const char **argv)
293 293
294 cgit_prepare_context(&ctx);
294 htmlfd = STDOUT_FILENO; 295 htmlfd = STDOUT_FILENO;
@@ -303,3 +304,3 @@ int main(int argc, const char **argv)
303 if (getenv("SCRIPT_NAME")) 304 if (getenv("SCRIPT_NAME"))
304 cgit_script_name = xstrdup(getenv("SCRIPT_NAME")); 305 ctx.cfg.script_name = xstrdup(getenv("SCRIPT_NAME"));
305 if (getenv("QUERY_STRING")) 306 if (getenv("QUERY_STRING"))
@@ -310,3 +311,3 @@ int main(int argc, const char **argv)
310 return 0; 311 return 0;
311 if (cgit_nocache) { 312 if (ctx.cfg.nocache) {
312 cgit_fill_cache(&item, 0); 313 cgit_fill_cache(&item, 0);
diff --git a/cgit.h b/cgit.h
index 4576efb..0338ebd 100644
--- a/cgit.h
+++ b/cgit.h
@@ -141,4 +141,40 @@ struct cgit_query {
141 141
142struct cgit_config {
143 char *agefile;
144 char *cache_root;
145 char *clone_prefix;
146 char *css;
147 char *index_header;
148 char *index_info;
149 char *logo;
150 char *logo_link;
151 char *module_link;
152 char *repo_group;
153 char *robots;
154 char *root_title;
155 char *script_name;
156 char *virtual_root;
157 int cache_dynamic_ttl;
158 int cache_max_create_time;
159 int cache_repo_ttl;
160 int cache_root_ttl;
161 int cache_static_ttl;
162 int enable_index_links;
163 int enable_log_filecount;
164 int enable_log_linecount;
165 int max_commit_count;
166 int max_lock_attempts;
167 int max_msg_len;
168 int max_repodesc_len;
169 int nocache;
170 int renamelimit;
171 int snapshots;
172 int summary_branches;
173 int summary_log;
174 int summary_tags;
175};
176
142struct cgit_context { 177struct cgit_context {
143 struct cgit_query qry; 178 struct cgit_query qry;
179 struct cgit_config cfg;
144}; 180};
@@ -152,39 +188,5 @@ extern int cgit_cmd;
152 188
153extern char *cgit_root_title;
154extern char *cgit_css;
155extern char *cgit_logo;
156extern char *cgit_index_header;
157extern char *cgit_index_info;
158extern char *cgit_logo_link;
159extern char *cgit_module_link;
160extern char *cgit_agefile;
161extern char *cgit_virtual_root;
162extern char *cgit_script_name;
163extern char *cgit_cache_root;
164extern char *cgit_repo_group;
165extern char *cgit_robots;
166extern char *cgit_clone_prefix;
167
168extern int cgit_nocache;
169extern int cgit_snapshots;
170extern int cgit_enable_index_links;
171extern int cgit_enable_log_filecount;
172extern int cgit_enable_log_linecount;
173extern int cgit_max_lock_attempts;
174extern int cgit_cache_root_ttl;
175extern int cgit_cache_repo_ttl;
176extern int cgit_cache_dynamic_ttl;
177extern int cgit_cache_static_ttl;
178extern int cgit_cache_max_create_time;
179extern int cgit_summary_log;
180extern int cgit_summary_tags;
181extern int cgit_summary_branches;
182
183extern int cgit_max_msg_len;
184extern int cgit_max_repodesc_len;
185extern int cgit_max_commit_count;
186
187
188extern int htmlfd; 189extern int htmlfd;
189 190
191extern void cgit_prepare_context(struct cgit_context *ctx);
190extern int cgit_get_cmd_index(const char *cmd); 192extern int cgit_get_cmd_index(const char *cmd);
diff --git a/shared.c b/shared.c
index 6c1a762..8dd2b00 100644
--- a/shared.c
+++ b/shared.c
@@ -17,39 +17,27 @@ const char *cgit_version = CGIT_VERSION;
17 17
18char *cgit_root_title = "Git repository browser";
19char *cgit_css = "/cgit.css";
20char *cgit_logo = "/git-logo.png";
21char *cgit_index_header = NULL;
22char *cgit_index_info = NULL;
23char *cgit_logo_link = "http://www.kernel.org/pub/software/scm/git/docs/";
24char *cgit_module_link = "./?repo=%s&page=commit&id=%s";
25char *cgit_agefile = "info/web/last-modified";
26char *cgit_virtual_root = NULL;
27char *cgit_script_name = CGIT_SCRIPT_NAME;
28char *cgit_cache_root = CGIT_CACHE_ROOT;
29char *cgit_repo_group = NULL;
30char *cgit_robots = "index, nofollow";
31char *cgit_clone_prefix = NULL;
32
33int cgit_nocache = 0;
34int cgit_snapshots = 0;
35int cgit_enable_index_links = 0;
36int cgit_enable_log_filecount = 0;
37int cgit_enable_log_linecount = 0;
38int cgit_max_lock_attempts = 5;
39int cgit_cache_root_ttl = 5;
40int cgit_cache_repo_ttl = 5;
41int cgit_cache_dynamic_ttl = 5;
42int cgit_cache_static_ttl = -1;
43int cgit_cache_max_create_time = 5;
44int cgit_summary_log = 0;
45int cgit_summary_tags = 0;
46int cgit_summary_branches = 0;
47int cgit_renamelimit = -1;
48
49int cgit_max_msg_len = 60;
50int cgit_max_repodesc_len = 60;
51int cgit_max_commit_count = 50;
52
53int htmlfd = 0; 18int htmlfd = 0;
54 19
20void cgit_prepare_context(struct cgit_context *ctx)
21{
22 memset(ctx, 0, sizeof(ctx));
23 ctx->cfg.agefile = "info/web/last-modified";
24 ctx->cfg.cache_dynamic_ttl = 5;
25 ctx->cfg.cache_max_create_time = 5;
26 ctx->cfg.cache_repo_ttl = 5;
27 ctx->cfg.cache_root = CGIT_CACHE_ROOT;
28 ctx->cfg.cache_root_ttl = 5;
29 ctx->cfg.cache_static_ttl = -1;
30 ctx->cfg.css = "/cgit.css";
31 ctx->cfg.logo = "/git-logo.png";
32 ctx->cfg.max_commit_count = 50;
33 ctx->cfg.max_lock_attempts = 5;
34 ctx->cfg.max_msg_len = 60;
35 ctx->cfg.max_repodesc_len = 60;
36 ctx->cfg.module_link = "./?repo=%s&page=commit&id=%s";
37 ctx->cfg.renamelimit = -1;
38 ctx->cfg.robots = "index, nofollow";
39 ctx->cfg.root_title = "Git repository browser";
40 ctx->cfg.script_name = CGIT_SCRIPT_NAME;
41}
42
55int cgit_get_cmd_index(const char *cmd) 43int cgit_get_cmd_index(const char *cmd)
@@ -107,8 +95,8 @@ struct repoinfo *add_repo(const char *url)
107 ret->owner = NULL; 95 ret->owner = NULL;
108 ret->group = cgit_repo_group; 96 ret->group = ctx.cfg.repo_group;
109 ret->defbranch = "master"; 97 ret->defbranch = "master";
110 ret->snapshots = cgit_snapshots; 98 ret->snapshots = ctx.cfg.snapshots;
111 ret->enable_log_filecount = cgit_enable_log_filecount; 99 ret->enable_log_filecount = ctx.cfg.enable_log_filecount;
112 ret->enable_log_linecount = cgit_enable_log_linecount; 100 ret->enable_log_linecount = ctx.cfg.enable_log_linecount;
113 ret->module_link = cgit_module_link; 101 ret->module_link = ctx.cfg.module_link;
114 ret->readme = NULL; 102 ret->readme = NULL;
@@ -133,61 +121,61 @@ void cgit_global_config_cb(const char *name, const char *value)
133 if (!strcmp(name, "root-title")) 121 if (!strcmp(name, "root-title"))
134 cgit_root_title = xstrdup(value); 122 ctx.cfg.root_title = xstrdup(value);
135 else if (!strcmp(name, "css")) 123 else if (!strcmp(name, "css"))
136 cgit_css = xstrdup(value); 124 ctx.cfg.css = xstrdup(value);
137 else if (!strcmp(name, "logo")) 125 else if (!strcmp(name, "logo"))
138 cgit_logo = xstrdup(value); 126 ctx.cfg.logo = xstrdup(value);
139 else if (!strcmp(name, "index-header")) 127 else if (!strcmp(name, "index-header"))
140 cgit_index_header = xstrdup(value); 128 ctx.cfg.index_header = xstrdup(value);
141 else if (!strcmp(name, "index-info")) 129 else if (!strcmp(name, "index-info"))
142 cgit_index_info = xstrdup(value); 130 ctx.cfg.index_info = xstrdup(value);
143 else if (!strcmp(name, "logo-link")) 131 else if (!strcmp(name, "logo-link"))
144 cgit_logo_link = xstrdup(value); 132 ctx.cfg.logo_link = xstrdup(value);
145 else if (!strcmp(name, "module-link")) 133 else if (!strcmp(name, "module-link"))
146 cgit_module_link = xstrdup(value); 134 ctx.cfg.module_link = xstrdup(value);
147 else if (!strcmp(name, "virtual-root")) { 135 else if (!strcmp(name, "virtual-root")) {
148 cgit_virtual_root = trim_end(value, '/'); 136 ctx.cfg.virtual_root = trim_end(value, '/');
149 if (!cgit_virtual_root && (!strcmp(value, "/"))) 137 if (!ctx.cfg.virtual_root && (!strcmp(value, "/")))
150 cgit_virtual_root = ""; 138 ctx.cfg.virtual_root = "";
151 } else if (!strcmp(name, "nocache")) 139 } else if (!strcmp(name, "nocache"))
152 cgit_nocache = atoi(value); 140 ctx.cfg.nocache = atoi(value);
153 else if (!strcmp(name, "snapshots")) 141 else if (!strcmp(name, "snapshots"))
154 cgit_snapshots = cgit_parse_snapshots_mask(value); 142 ctx.cfg.snapshots = cgit_parse_snapshots_mask(value);
155 else if (!strcmp(name, "enable-index-links")) 143 else if (!strcmp(name, "enable-index-links"))
156 cgit_enable_index_links = atoi(value); 144 ctx.cfg.enable_index_links = atoi(value);
157 else if (!strcmp(name, "enable-log-filecount")) 145 else if (!strcmp(name, "enable-log-filecount"))
158 cgit_enable_log_filecount = atoi(value); 146 ctx.cfg.enable_log_filecount = atoi(value);
159 else if (!strcmp(name, "enable-log-linecount")) 147 else if (!strcmp(name, "enable-log-linecount"))
160 cgit_enable_log_linecount = atoi(value); 148 ctx.cfg.enable_log_linecount = atoi(value);
161 else if (!strcmp(name, "cache-root")) 149 else if (!strcmp(name, "cache-root"))
162 cgit_cache_root = xstrdup(value); 150 ctx.cfg.cache_root = xstrdup(value);
163 else if (!strcmp(name, "cache-root-ttl")) 151 else if (!strcmp(name, "cache-root-ttl"))
164 cgit_cache_root_ttl = atoi(value); 152 ctx.cfg.cache_root_ttl = atoi(value);
165 else if (!strcmp(name, "cache-repo-ttl")) 153 else if (!strcmp(name, "cache-repo-ttl"))
166 cgit_cache_repo_ttl = atoi(value); 154 ctx.cfg.cache_repo_ttl = atoi(value);
167 else if (!strcmp(name, "cache-static-ttl")) 155 else if (!strcmp(name, "cache-static-ttl"))
168 cgit_cache_static_ttl = atoi(value); 156 ctx.cfg.cache_static_ttl = atoi(value);
169 else if (!strcmp(name, "cache-dynamic-ttl")) 157 else if (!strcmp(name, "cache-dynamic-ttl"))
170 cgit_cache_dynamic_ttl = atoi(value); 158 ctx.cfg.cache_dynamic_ttl = atoi(value);
171 else if (!strcmp(name, "max-message-length")) 159 else if (!strcmp(name, "max-message-length"))
172 cgit_max_msg_len = atoi(value); 160 ctx.cfg.max_msg_len = atoi(value);
173 else if (!strcmp(name, "max-repodesc-length")) 161 else if (!strcmp(name, "max-repodesc-length"))
174 cgit_max_repodesc_len = atoi(value); 162 ctx.cfg.max_repodesc_len = atoi(value);
175 else if (!strcmp(name, "max-commit-count")) 163 else if (!strcmp(name, "max-commit-count"))
176 cgit_max_commit_count = atoi(value); 164 ctx.cfg.max_commit_count = atoi(value);
177 else if (!strcmp(name, "summary-log")) 165 else if (!strcmp(name, "summary-log"))
178 cgit_summary_log = atoi(value); 166 ctx.cfg.summary_log = atoi(value);
179 else if (!strcmp(name, "summary-branches")) 167 else if (!strcmp(name, "summary-branches"))
180 cgit_summary_branches = atoi(value); 168 ctx.cfg.summary_branches = atoi(value);
181 else if (!strcmp(name, "summary-tags")) 169 else if (!strcmp(name, "summary-tags"))
182 cgit_summary_tags = atoi(value); 170 ctx.cfg.summary_tags = atoi(value);
183 else if (!strcmp(name, "agefile")) 171 else if (!strcmp(name, "agefile"))
184 cgit_agefile = xstrdup(value); 172 ctx.cfg.agefile = xstrdup(value);
185 else if (!strcmp(name, "renamelimit")) 173 else if (!strcmp(name, "renamelimit"))
186 cgit_renamelimit = atoi(value); 174 ctx.cfg.renamelimit = atoi(value);
187 else if (!strcmp(name, "robots")) 175 else if (!strcmp(name, "robots"))
188 cgit_robots = xstrdup(value); 176 ctx.cfg.robots = xstrdup(value);
189 else if (!strcmp(name, "clone-prefix")) 177 else if (!strcmp(name, "clone-prefix"))
190 cgit_clone_prefix = xstrdup(value); 178 ctx.cfg.clone_prefix = xstrdup(value);
191 else if (!strcmp(name, "repo.group")) 179 else if (!strcmp(name, "repo.group"))
192 cgit_repo_group = xstrdup(value); 180 ctx.cfg.repo_group = xstrdup(value);
193 else if (!strcmp(name, "repo.url")) 181 else if (!strcmp(name, "repo.url"))
@@ -207,7 +195,7 @@ void cgit_global_config_cb(const char *name, const char *value)
207 else if (cgit_repo && !strcmp(name, "repo.snapshots")) 195 else if (cgit_repo && !strcmp(name, "repo.snapshots"))
208 cgit_repo->snapshots = cgit_snapshots & cgit_parse_snapshots_mask(value); /* XXX: &? */ 196 cgit_repo->snapshots = ctx.cfg.snapshots & cgit_parse_snapshots_mask(value); /* XXX: &? */
209 else if (cgit_repo && !strcmp(name, "repo.enable-log-filecount")) 197 else if (cgit_repo && !strcmp(name, "repo.enable-log-filecount"))
210 cgit_repo->enable_log_filecount = cgit_enable_log_filecount * atoi(value); 198 cgit_repo->enable_log_filecount = ctx.cfg.enable_log_filecount * atoi(value);
211 else if (cgit_repo && !strcmp(name, "repo.enable-log-linecount")) 199 else if (cgit_repo && !strcmp(name, "repo.enable-log-linecount"))
212 cgit_repo->enable_log_linecount = cgit_enable_log_linecount * atoi(value); 200 cgit_repo->enable_log_linecount = ctx.cfg.enable_log_linecount * atoi(value);
213 else if (cgit_repo && !strcmp(name, "repo.module-link")) 201 else if (cgit_repo && !strcmp(name, "repo.module-link"))
@@ -478,3 +466,3 @@ void cgit_diff_tree(const unsigned char *old_sha1,
478 opt.detect_rename = 1; 466 opt.detect_rename = 1;
479 opt.rename_limit = cgit_renamelimit; 467 opt.rename_limit = ctx.cfg.renamelimit;
480 DIFF_OPT_SET(&opt, RECURSIVE); 468 DIFF_OPT_SET(&opt, RECURSIVE);
diff --git a/ui-repolist.c b/ui-repolist.c
index 3e97ca9..a6cc2cc 100644
--- a/ui-repolist.c
+++ b/ui-repolist.c
@@ -32,3 +32,3 @@ static void print_modtime(struct repoinfo *repo)
32 32
33 path = fmt("%s/%s", repo->path, cgit_agefile); 33 path = fmt("%s/%s", repo->path, ctx.cfg.agefile);
34 if (stat(path, &s) == 0) { 34 if (stat(path, &s) == 0) {
@@ -49,13 +49,13 @@ void cgit_print_repolist(struct cacheitem *item)
49 49
50 if (cgit_enable_index_links) 50 if (ctx.cfg.enable_index_links)
51 columns++; 51 columns++;
52 52
53 cgit_print_docstart(cgit_root_title, item); 53 cgit_print_docstart(ctx.cfg.root_title, item);
54 cgit_print_pageheader(cgit_root_title, 0); 54 cgit_print_pageheader(ctx.cfg.root_title, 0);
55 55
56 html("<table summary='repository list' class='list nowrap'>"); 56 html("<table summary='repository list' class='list nowrap'>");
57 if (cgit_index_header) { 57 if (ctx.cfg.index_header) {
58 htmlf("<tr class='nohover'><td colspan='%d' class='include-block'>", 58 htmlf("<tr class='nohover'><td colspan='%d' class='include-block'>",
59 columns); 59 columns);
60 html_include(cgit_index_header); 60 html_include(ctx.cfg.index_header);
61 html("</td></tr>"); 61 html("</td></tr>");
@@ -67,3 +67,3 @@ void cgit_print_repolist(struct cacheitem *item)
67 "<th class='left'>Idle</th>"); 67 "<th class='left'>Idle</th>");
68 if (cgit_enable_index_links) 68 if (ctx.cfg.enable_index_links)
69 html("<th>Links</th>"); 69 html("<th>Links</th>");
@@ -89,3 +89,3 @@ void cgit_print_repolist(struct cacheitem *item)
89 html("</td><td>"); 89 html("</td><td>");
90 html_ntxt(cgit_max_repodesc_len, cgit_repo->desc); 90 html_ntxt(ctx.cfg.max_repodesc_len, cgit_repo->desc);
91 html("</td><td>"); 91 html("</td><td>");
@@ -95,3 +95,3 @@ void cgit_print_repolist(struct cacheitem *item)
95 html("</td>"); 95 html("</td>");
96 if (cgit_enable_index_links) { 96 if (ctx.cfg.enable_index_links) {
97 html("<td>"); 97 html("<td>");
diff --git a/ui-shared.c b/ui-shared.c
index 6a41fb0..b96237d 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -44,6 +44,6 @@ char *cgit_rooturl()
44{ 44{
45 if (cgit_virtual_root) 45 if (ctx.cfg.virtual_root)
46 return fmt("%s/", cgit_virtual_root); 46 return fmt("%s/", ctx.cfg.virtual_root);
47 else 47 else
48 return cgit_script_name; 48 return ctx.cfg.script_name;
49} 49}
@@ -52,4 +52,4 @@ char *cgit_repourl(const char *reponame)
52{ 52{
53 if (cgit_virtual_root) { 53 if (ctx.cfg.virtual_root) {
54 return fmt("%s/%s/", cgit_virtual_root, reponame); 54 return fmt("%s/%s/", ctx.cfg.virtual_root, reponame);
55 } else { 55 } else {
@@ -65,4 +65,4 @@ char *cgit_fileurl(const char *reponame, const char *pagename,
65 65
66 if (cgit_virtual_root) { 66 if (ctx.cfg.virtual_root) {
67 tmp = fmt("%s/%s/%s/%s", cgit_virtual_root, reponame, 67 tmp = fmt("%s/%s/%s/%s", ctx.cfg.virtual_root, reponame,
68 pagename, (filename ? filename:"")); 68 pagename, (filename ? filename:""));
@@ -112,10 +112,10 @@ char *cgit_currurl()
112{ 112{
113 if (!cgit_virtual_root) 113 if (!ctx.cfg.virtual_root)
114 return cgit_script_name; 114 return ctx.cfg.script_name;
115 else if (ctx.qry.page) 115 else if (ctx.qry.page)
116 return fmt("%s/%s/%s/", cgit_virtual_root, ctx.qry.repo, ctx.qry.page); 116 return fmt("%s/%s/%s/", ctx.cfg.virtual_root, ctx.qry.repo, ctx.qry.page);
117 else if (ctx.qry.repo) 117 else if (ctx.qry.repo)
118 return fmt("%s/%s/", cgit_virtual_root, ctx.qry.repo); 118 return fmt("%s/%s/", ctx.cfg.virtual_root, ctx.qry.repo);
119 else 119 else
120 return fmt("%s/", cgit_virtual_root); 120 return fmt("%s/", ctx.cfg.virtual_root);
121} 121}
@@ -139,5 +139,5 @@ static char *repolink(char *title, char *class, char *page, char *head,
139 html(" href='"); 139 html(" href='");
140 if (cgit_virtual_root) { 140 if (ctx.cfg.virtual_root) {
141 html_attr(cgit_virtual_root); 141 html_attr(ctx.cfg.virtual_root);
142 if (cgit_virtual_root[strlen(cgit_virtual_root) - 1] != '/') 142 if (ctx.cfg.virtual_root[strlen(ctx.cfg.virtual_root) - 1] != '/')
143 html("/"); 143 html("/");
@@ -153,3 +153,3 @@ static char *repolink(char *title, char *class, char *page, char *head,
153 } else { 153 } else {
154 html(cgit_script_name); 154 html(ctx.cfg.script_name);
155 html("?url="); 155 html("?url=");
@@ -231,7 +231,7 @@ void cgit_commit_link(char *name, char *title, char *class, char *head,
231{ 231{
232 if (strlen(name) > cgit_max_msg_len && cgit_max_msg_len >= 15) { 232 if (strlen(name) > ctx.cfg.max_msg_len && ctx.cfg.max_msg_len >= 15) {
233 name[cgit_max_msg_len] = '\0'; 233 name[ctx.cfg.max_msg_len] = '\0';
234 name[cgit_max_msg_len - 1] = '.'; 234 name[ctx.cfg.max_msg_len - 1] = '.';
235 name[cgit_max_msg_len - 2] = '.'; 235 name[ctx.cfg.max_msg_len - 2] = '.';
236 name[cgit_max_msg_len - 3] = '.'; 236 name[ctx.cfg.max_msg_len - 3] = '.';
237 } 237 }
@@ -376,6 +376,6 @@ void cgit_print_docstart(char *title, struct cacheitem *item)
376 htmlf("<meta name='generator' content='cgit %s'/>\n", cgit_version); 376 htmlf("<meta name='generator' content='cgit %s'/>\n", cgit_version);
377 if (cgit_robots && *cgit_robots) 377 if (ctx.cfg.robots && *ctx.cfg.robots)
378 htmlf("<meta name='robots' content='%s'/>\n", cgit_robots); 378 htmlf("<meta name='robots' content='%s'/>\n", ctx.cfg.robots);
379 html("<link rel='stylesheet' type='text/css' href='"); 379 html("<link rel='stylesheet' type='text/css' href='");
380 html_attr(cgit_css); 380 html_attr(ctx.cfg.css);
381 html("'/>\n"); 381 html("'/>\n");
@@ -441,3 +441,3 @@ void add_hidden_formfields(int incl_head, int incl_search, char *page)
441 441
442 if (!cgit_virtual_root) { 442 if (!ctx.cfg.virtual_root) {
443 url = fmt("%s/%s", ctx.qry.repo, page); 443 url = fmt("%s/%s", ctx.qry.repo, page);
@@ -476,3 +476,3 @@ void cgit_print_pageheader(char *title, int show_search)
476 htmlf("'><img src='%s' alt='cgit'/></a>\n", 476 htmlf("'><img src='%s' alt='cgit'/></a>\n",
477 cgit_logo); 477 ctx.cfg.logo);
478 html("</td></tr>\n<tr><td class='sidebar'>\n"); 478 html("</td></tr>\n<tr><td class='sidebar'>\n");
@@ -503,3 +503,3 @@ void cgit_print_pageheader(char *title, int show_search)
503 503
504 if (cgit_repo->clone_url || cgit_clone_prefix) { 504 if (cgit_repo->clone_url || ctx.cfg.clone_prefix) {
505 html("<h1>clone</h1>\n"); 505 html("<h1>clone</h1>\n");
@@ -508,3 +508,3 @@ void cgit_print_pageheader(char *title, int show_search)
508 else 508 else
509 url = fmt("%s%s", cgit_clone_prefix, 509 url = fmt("%s%s", ctx.cfg.clone_prefix,
510 cgit_repo->url); 510 cgit_repo->url);
@@ -533,3 +533,3 @@ void cgit_print_pageheader(char *title, int show_search)
533 html("<form method='get' action='"); 533 html("<form method='get' action='");
534 if (cgit_virtual_root) 534 if (ctx.cfg.virtual_root)
535 html_attr(cgit_fileurl(ctx.qry.repo, "log", 535 html_attr(cgit_fileurl(ctx.qry.repo, "log",
@@ -548,3 +548,3 @@ void cgit_print_pageheader(char *title, int show_search)
548 } else { 548 } else {
549 if (!cgit_index_info || html_include(cgit_index_info)) 549 if (!ctx.cfg.index_info || html_include(ctx.cfg.index_info))
550 html(default_info); 550 html(default_info);
diff --git a/ui-summary.c b/ui-summary.c
index bbd4464..0a44994 100644
--- a/ui-summary.c
+++ b/ui-summary.c
@@ -189,11 +189,11 @@ void cgit_print_summary()
189 } 189 }
190 if (cgit_summary_log > 0) 190 if (ctx.cfg.summary_log > 0)
191 cgit_print_log(ctx.qry.head, 0, cgit_summary_log, NULL, 191 cgit_print_log(ctx.qry.head, 0, ctx.cfg.summary_log, NULL,
192 NULL, NULL, 0); 192 NULL, NULL, 0);
193 html("<table summary='repository info' class='list nowrap'>"); 193 html("<table summary='repository info' class='list nowrap'>");
194 if (cgit_summary_log > 0) 194 if (ctx.cfg.summary_log > 0)
195 html("<tr class='nohover'><td colspan='4'>&nbsp;</td></tr>"); 195 html("<tr class='nohover'><td colspan='4'>&nbsp;</td></tr>");
196 cgit_print_branches(cgit_summary_branches); 196 cgit_print_branches(ctx.cfg.summary_branches);
197 html("<tr class='nohover'><td colspan='4'>&nbsp;</td></tr>"); 197 html("<tr class='nohover'><td colspan='4'>&nbsp;</td></tr>");
198 cgit_print_tags(cgit_summary_tags); 198 cgit_print_tags(ctx.cfg.summary_tags);
199 html("</table>"); 199 html("</table>");