diff options
Diffstat (limited to 'cgit.c')
| -rw-r--r-- | cgit.c | 50 | 
1 files changed, 29 insertions, 21 deletions
| @@ -12,6 +12,7 @@  #include "configfile.h"  #include "html.h"  #include "ui-shared.h" +#include "ui-stats.h"  #include "scan-tree.h"  const char *cgit_version = CGIT_VERSION; @@ -54,6 +55,8 @@ void config_cb(const char *name, const char *value)  		ctx.cfg.enable_log_filecount = atoi(value);  	else if (!strcmp(name, "enable-log-linecount"))  		ctx.cfg.enable_log_linecount = atoi(value); +	else if (!strcmp(name, "max-stats")) +		ctx.cfg.max_stats = cgit_find_stats_period(value, NULL);  	else if (!strcmp(name, "cache-size"))  		ctx.cfg.cache_size = atoi(value);  	else if (!strcmp(name, "cache-root")) @@ -112,6 +115,8 @@ void config_cb(const char *name, const char *value)  		ctx.repo->enable_log_filecount = ctx.cfg.enable_log_filecount * atoi(value);  	else if (ctx.repo && !strcmp(name, "repo.enable-log-linecount"))  		ctx.repo->enable_log_linecount = ctx.cfg.enable_log_linecount * atoi(value); +	else if (ctx.repo && !strcmp(name, "repo.max-stats")) +		ctx.repo->max_stats = cgit_find_stats_period(value, NULL);  	else if (ctx.repo && !strcmp(name, "repo.module-link"))  		ctx.repo->module_link= xstrdup(value);  	else if (ctx.repo && !strcmp(name, "repo.readme") && value != NULL) { @@ -158,6 +163,8 @@ static void querystring_cb(const char *name, const char *value)  		ctx.qry.sort = xstrdup(value);  	} else if (!strcmp(name, "showmsg")) {  		ctx.qry.showmsg = atoi(value); +	} else if (!strcmp(name, "period")) { +		ctx.qry.period = xstrdup(value);  	}  } @@ -181,6 +188,7 @@ static void prepare_context(struct cgit_context *ctx)  	ctx->cfg.max_lock_attempts = 5;  	ctx->cfg.max_msg_len = 80;  	ctx->cfg.max_repodesc_len = 80; +	ctx->cfg.max_stats = 0;  	ctx->cfg.module_link = "./?repo=%s&page=commit&id=%s";  	ctx->cfg.renamelimit = -1;  	ctx->cfg.robots = "index, nofollow"; @@ -293,7 +301,6 @@ static void process_request(void *cbdata)  	cmd = cgit_get_cmd(ctx);  	if (!cmd) {  		ctx->page.title = "cgit error"; -		ctx->repo = NULL;  		cgit_print_http_headers(ctx);  		cgit_print_docstart(ctx);  		cgit_print_pageheader(ctx); @@ -439,28 +446,29 @@ int main(int argc, const char **argv)  	ctx.repo = NULL;  	http_parse_querystring(ctx.qry.raw, querystring_cb); -	/* If virtual-root isn't specified in cgitrc and no url -	 * parameter is specified on the querystring, lets pretend -	 * that virtualroot equals SCRIPT_NAME and use PATH_INFO as -	 * url. This allows cgit to work with virtual urls without -	 * the need for rewriterules in the webserver (as long as -	 * PATH_INFO is included in the cache lookup key). +	/* If virtual-root isn't specified in cgitrc, lets pretend +	 * that virtual-root equals SCRIPT_NAME.  	 */ -	if (!ctx.cfg.virtual_root && !ctx.qry.url) { +	if (!ctx.cfg.virtual_root)  		ctx.cfg.virtual_root = ctx.cfg.script_name; -		path = getenv("PATH_INFO"); -		if (path) { -			if (path[0] == '/') -				path++; -			ctx.qry.url = xstrdup(path); -			if (ctx.qry.raw) { -				qry = ctx.qry.raw; -				ctx.qry.raw = xstrdup(fmt("%s?%s", path, qry)); -				free(qry); -			} else -				ctx.qry.raw = ctx.qry.url; -			cgit_parse_url(ctx.qry.url); -		} + +	/* If no url parameter is specified on the querystring, lets +	 * use PATH_INFO as url. This allows cgit to work with virtual +	 * urls without the need for rewriterules in the webserver (as +	 * long as PATH_INFO is included in the cache lookup key). +	 */ +	path = getenv("PATH_INFO"); +	if (!ctx.qry.url && path) { +		if (path[0] == '/') +			path++; +		ctx.qry.url = xstrdup(path); +		if (ctx.qry.raw) { +			qry = ctx.qry.raw; +			ctx.qry.raw = xstrdup(fmt("%s?%s", path, qry)); +			free(qry); +		} else +			ctx.qry.raw = ctx.qry.url; +		cgit_parse_url(ctx.qry.url);  	}  	ttl = calc_ttl(); | 
