diff options
Diffstat (limited to '')
-rw-r--r-- | cgit.c | 82 | ||||
-rw-r--r-- | cgit.css | 148 |
2 files changed, 215 insertions, 15 deletions
diff --git a/cgit.c b/cgit.c index 6c7e811..d6146e2 100644 --- a/cgit.c +++ b/cgit.c @@ -1,6 +1,7 @@ /* cgit.c: cgi for the git scm * * Copyright (C) 2006 Lars Hjemli + * Copyright (C) 2010 Jason A. Donenfeld <Jason@zx2c4.com> * * Licensed under GNU General Public License v2 * (see COPYING for full license text) @@ -21,7 +22,7 @@ void add_mimetype(const char *name, const char *value) { struct string_list_item *item; - item = string_list_insert(xstrdup(name), &ctx.cfg.mimetypes); + item = string_list_insert(&ctx.cfg.mimetypes, xstrdup(name)); item->util = xstrdup(value); } @@ -60,6 +61,10 @@ void repo_config(struct cgit_repo *repo, const char *name, const char *value) repo->enable_log_filecount = ctx.cfg.enable_log_filecount * atoi(value); else if (!strcmp(name, "enable-log-linecount")) repo->enable_log_linecount = ctx.cfg.enable_log_linecount * atoi(value); + else if (!strcmp(name, "enable-remote-branches")) + repo->enable_remote_branches = atoi(value); + else if (!strcmp(name, "enable-subject-links")) + repo->enable_subject_links = atoi(value); else if (!strcmp(name, "max-stats")) repo->max_stats = cgit_find_stats_period(value, NULL); else if (!strcmp(name, "module-link")) @@ -67,7 +72,8 @@ void repo_config(struct cgit_repo *repo, const char *name, const char *value) else if (!strcmp(name, "section")) repo->section = xstrdup(value); else if (!strcmp(name, "readme") && value != NULL) { - if (*value == '/') + char *colon; + if (*value == '/' || ((colon = strchr(value, ':')) != NULL && colon != value && *(colon + 1) != '\0')) repo->readme = xstrdup(value); else repo->readme = xstrdup(fmt("%s/%s", repo->path, value)); @@ -131,12 +137,18 @@ void config_cb(const char *name, const char *value) ctx.cfg.snapshots = cgit_parse_snapshots_mask(value); else if (!strcmp(name, "enable-filter-overrides")) ctx.cfg.enable_filter_overrides = atoi(value); + else if (!strcmp(name, "enable-gitweb-owner")) + ctx.cfg.enable_gitweb_owner = atoi(value); else if (!strcmp(name, "enable-index-links")) ctx.cfg.enable_index_links = atoi(value); else if (!strcmp(name, "enable-log-filecount")) 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, "enable-remote-branches")) + ctx.cfg.enable_remote_branches = atoi(value); + else if (!strcmp(name, "enable-subject-links")) + ctx.cfg.enable_subject_links = atoi(value); else if (!strcmp(name, "enable-tree-linenumbers")) ctx.cfg.enable_tree_linenumbers = atoi(value); else if (!strcmp(name, "max-stats")) @@ -144,7 +156,7 @@ void config_cb(const char *name, const char *value) else if (!strcmp(name, "cache-size")) ctx.cfg.cache_size = atoi(value); else if (!strcmp(name, "cache-root")) - ctx.cfg.cache_root = xstrdup(value); + ctx.cfg.cache_root = xstrdup(expand_macros(value)); else if (!strcmp(name, "cache-root-ttl")) ctx.cfg.cache_root_ttl = atoi(value); else if (!strcmp(name, "cache-repo-ttl")) @@ -161,19 +173,28 @@ void config_cb(const char *name, const char *value) ctx.cfg.commit_filter = new_filter(value, 0); else if (!strcmp(name, "embedded")) ctx.cfg.embedded = atoi(value); + else if (!strcmp(name, "max-atom-items")) + ctx.cfg.max_atom_items = atoi(value); else if (!strcmp(name, "max-message-length")) ctx.cfg.max_msg_len = atoi(value); else if (!strcmp(name, "max-repodesc-length")) ctx.cfg.max_repodesc_len = atoi(value); + else if (!strcmp(name, "max-blob-size")) + ctx.cfg.max_blob_size = atoi(value); else if (!strcmp(name, "max-repo-count")) ctx.cfg.max_repo_count = atoi(value); else if (!strcmp(name, "max-commit-count")) ctx.cfg.max_commit_count = atoi(value); + else if (!strcmp(name, "project-list")) + ctx.cfg.project_list = xstrdup(expand_macros(value)); else if (!strcmp(name, "scan-path")) if (!ctx.cfg.nocache && ctx.cfg.cache_size) - process_cached_repolist(value); + process_cached_repolist(expand_macros(value)); + else if (ctx.cfg.project_list) + scan_projects(expand_macros(value), + ctx.cfg.project_list, repo_config); else - scan_tree(value, repo_config); + scan_tree(expand_macros(value), repo_config); else if (!strcmp(name, "source-filter")) ctx.cfg.source_filter = new_filter(value, 1); else if (!strcmp(name, "summary-log")) @@ -182,10 +203,14 @@ void config_cb(const char *name, const char *value) ctx.cfg.summary_branches = atoi(value); else if (!strcmp(name, "summary-tags")) ctx.cfg.summary_tags = atoi(value); + else if (!strcmp(name, "side-by-side-diffs")) + ctx.cfg.ssdiff = atoi(value); else if (!strcmp(name, "agefile")) ctx.cfg.agefile = xstrdup(value); else if (!strcmp(name, "renamelimit")) ctx.cfg.renamelimit = atoi(value); + else if (!strcmp(name, "remove-suffix")) + ctx.cfg.remove_suffix = atoi(value); else if (!strcmp(name, "robots")) ctx.cfg.robots = xstrdup(value); else if (!strcmp(name, "clone-prefix")) @@ -195,7 +220,7 @@ void config_cb(const char *name, const char *value) else if (!prefixcmp(name, "mimetype.")) add_mimetype(name + 9, value); else if (!strcmp(name, "include")) - parse_configfile(value, config_cb); + parse_configfile(expand_macros(value), config_cb); } static void querystring_cb(const char *name, const char *value) @@ -209,6 +234,8 @@ static void querystring_cb(const char *name, const char *value) } else if (!strcmp(name, "p")) { ctx.qry.page = xstrdup(value); } else if (!strcmp(name, "url")) { + if (*value == '/') + value++; ctx.qry.url = xstrdup(value); cgit_parse_url(value); } else if (!strcmp(name, "qt")) { @@ -238,6 +265,14 @@ static void querystring_cb(const char *name, const char *value) ctx.qry.showmsg = atoi(value); } else if (!strcmp(name, "period")) { ctx.qry.period = xstrdup(value); + } else if (!strcmp(name, "ss")) { + ctx.qry.ssdiff = atoi(value); + } else if (!strcmp(name, "all")) { + ctx.qry.show_all = atoi(value); + } else if (!strcmp(name, "context")) { + ctx.qry.context = atoi(value); + } else if (!strcmp(name, "ignorews")) { + ctx.qry.ignorews = atoi(value); } } @@ -262,15 +297,19 @@ static void prepare_context(struct cgit_context *ctx) ctx->cfg.css = "/cgit.css"; ctx->cfg.logo = "/cgit.png"; ctx->cfg.local_time = 0; + ctx->cfg.enable_gitweb_owner = 1; ctx->cfg.enable_tree_linenumbers = 1; ctx->cfg.max_repo_count = 50; ctx->cfg.max_commit_count = 50; ctx->cfg.max_lock_attempts = 5; ctx->cfg.max_msg_len = 80; ctx->cfg.max_repodesc_len = 80; + ctx->cfg.max_blob_size = 0; ctx->cfg.max_stats = 0; ctx->cfg.module_link = "./?repo=%s&page=commit&id=%s"; + ctx->cfg.project_list = NULL; ctx->cfg.renamelimit = -1; + ctx->cfg.remove_suffix = 0; ctx->cfg.robots = "index, nofollow"; ctx->cfg.root_title = "Git repository browser"; ctx->cfg.root_desc = "a fast webinterface for the git dscm"; @@ -279,6 +318,8 @@ static void prepare_context(struct cgit_context *ctx) ctx->cfg.summary_branches = 10; ctx->cfg.summary_log = 10; ctx->cfg.summary_tags = 10; + ctx->cfg.max_atom_items = 10; + ctx->cfg.ssdiff = 0; ctx->env.cgit_config = xstrdupn(getenv("CGIT_CONFIG")); ctx->env.http_host = xstrdupn(getenv("HTTP_HOST")); ctx->env.https = xstrdupn(getenv("HTTPS")); @@ -410,6 +451,12 @@ static void process_request(void *cbdata) return; } + /* If cmd->want_vpath is set, assume ctx->qry.path contains a "virtual" + * in-project path limit to be made available at ctx->qry.vpath. + * Otherwise, no path limit is in effect (ctx->qry.vpath = NULL). + */ + ctx->qry.vpath = cmd->want_vpath ? ctx->qry.path : NULL; + if (cmd->want_repo && !ctx->repo) { cgit_print_http_headers(ctx); cgit_print_docstart(ctx); @@ -541,7 +588,10 @@ static int generate_cached_repolist(const char *path, const char *cached_rc) return errno; } idx = cgit_repolist.count; - scan_tree(path, repo_config); + if (ctx.cfg.project_list) + scan_projects(path, ctx.cfg.project_list, repo_config); + else + scan_tree(path, repo_config); print_repolist(f, &cgit_repolist, idx); if (rename(locked_rc, cached_rc)) fprintf(stderr, "[cgit] Error renaming %s to %s: %s (%d)\n", @@ -555,17 +605,25 @@ static void process_cached_repolist(const char *path) struct stat st; char *cached_rc; time_t age; + unsigned long hash; - cached_rc = xstrdup(fmt("%s/rc-%8x", ctx.cfg.cache_root, - hash_str(path))); + hash = hash_str(path); + if (ctx.cfg.project_list) + hash += hash_str(ctx.cfg.project_list); + cached_rc = xstrdup(fmt("%s/rc-%8x", ctx.cfg.cache_root, hash)); if (stat(cached_rc, &st)) { /* Nothing is cached, we need to scan without forking. And * if we fail to generate a cached repolist, we need to * invoke scan_tree manually. */ - if (generate_cached_repolist(path, cached_rc)) - scan_tree(path, repo_config); + if (generate_cached_repolist(path, cached_rc)) { + if (ctx.cfg.project_list) + scan_projects(path, ctx.cfg.project_list, + repo_config); + else + scan_tree(path, repo_config); + } return; } @@ -674,7 +732,7 @@ int main(int argc, const char **argv) cgit_repolist.repos = NULL; cgit_parse_args(argc, argv); - parse_configfile(ctx.env.cgit_config, config_cb); + parse_configfile(expand_macros(ctx.env.cgit_config), config_cb); ctx.repo = NULL; http_parse_querystring(ctx.qry.raw, querystring_cb); diff --git a/cgit.css b/cgit.css index c47ebc9..0c88b65 100644 --- a/cgit.css +++ b/cgit.css @@ -64,7 +64,7 @@ table#header td.sub { } table.tabs { - /* border-bottom: solid 2px #ccc; */ + border-bottom: solid 3px #ccc; border-collapse: collapse; margin-top: 2em; margin-bottom: 0px; @@ -102,10 +102,16 @@ table.tabs td.form select { font-size: 90%; } +div.path { + margin: 0px; + padding: 5px 2em 2px 2em; + color: #000; + background-color: #eee; +} + div.content { margin: 0px; padding: 2em; - border-top: solid 3px #ccc; border-bottom: solid 3px #ccc; } @@ -158,10 +164,26 @@ table.list td.logmsg { padding: 1em 0.5em 2em 0.5em; } +table.list td.lognotes-label { + text-align:right; + vertical-align:top; +} + +table.list td.lognotes { + font-family: monospace; + white-space: pre; + padding: 0em 0.5em 2em 0.5em; +} + table.list td a { color: black; } +table.list td a.ls-dir { + font-weight: bold; + color: #00f; +} + table.list td a:hover { color: #00f; } @@ -315,6 +337,24 @@ div.commit-msg { font-family: monospace; } +div.notes-header { + font-weight: bold; + padding-top: 1.5em; +} + +div.notes { + white-space: pre; + font-family: monospace; + border: solid 1px #ee9; + background-color: #ffd; + padding: 0.3em 2em 0.3em 1em; + float: left; +} + +div.notes-footer { + clear: left; +} + div.diffstat-header { font-weight: bold; padding-top: 1.5em; @@ -520,7 +560,10 @@ a.deco { border: solid 1px #770000; } -div.commit-subject a { +div.commit-subject a.branch-deco, +div.commit-subject a.tag-deco, +div.commit-subject a.remote-deco, +div.commit-subject a.deco { margin-left: 1em; font-size: 75%; } @@ -601,3 +644,102 @@ table.hgraph div.bar { background-color: #eee; height: 1em; } + +table.ssdiff { + width: 100%; +} + +table.ssdiff td { + font-size: 75%; + font-family: monospace; + white-space: pre; + padding: 1px 4px 1px 4px; + border-left: solid 1px #aaa; + border-right: solid 1px #aaa; +} + +table.ssdiff td.add { + color: black; + background: #cfc; + min-width: 50%; +} + +table.ssdiff td.add_dark { + color: black; + background: #aca; + min-width: 50%; +} + +table.ssdiff span.add { + background: #cfc; + font-weight: bold; +} + +table.ssdiff td.del { + color: black; + background: #fcc; + min-width: 50%; +} + +table.ssdiff td.del_dark { + color: black; + background: #caa; + min-width: 50%; +} + +table.ssdiff span.del { + background: #fcc; + font-weight: bold; +} + +table.ssdiff td.changed { + color: black; + background: #ffc; + min-width: 50%; +} + +table.ssdiff td.changed_dark { + color: black; + background: #cca; + min-width: 50%; +} + +table.ssdiff td.lineno { + color: black; + background: #eee; + text-align: right; + width: 3em; + min-width: 3em; +} + +table.ssdiff td.hunk { + color: #black; + background: #ccf; + border-top: solid 1px #aaa; + border-bottom: solid 1px #aaa; +} + +table.ssdiff td.head { + border-top: solid 1px #aaa; + border-bottom: solid 1px #aaa; +} + +table.ssdiff td.head div.head { + font-weight: bold; + color: black; +} + +table.ssdiff td.foot { + border-top: solid 1px #aaa; + border-left: none; + border-right: none; + border-bottom: none; +} + +table.ssdiff td.space { + border: none; +} + +table.ssdiff td.space div { + min-height: 3em; +} \ No newline at end of file |