-rw-r--r-- | Makefile | 4 | ||||
-rw-r--r-- | cgit.c | 2 | ||||
-rw-r--r-- | cgit.h | 1 | ||||
-rw-r--r-- | shared.c | 2 | ||||
-rw-r--r-- | ui-shared.c | 4 |
5 files changed, 9 insertions, 4 deletions
@@ -1,31 +1,33 @@ CGIT_VERSION = 0.4 prefix = /var/www/htdocs/cgit SHA1_HEADER = <openssl/sha.h> CACHE_ROOT = /var/cache/cgit CGIT_CONFIG = /etc/cgitrc +CGIT_SCRIPT_NAME = cgit.cgi EXTLIBS = git/libgit.a git/xdiff/lib.a -lz -lcrypto OBJECTS = shared.o cache.o parsing.o html.o ui-shared.o ui-repolist.o \ ui-summary.o ui-log.o ui-view.o ui-tree.o ui-commit.o ui-diff.o \ ui-snapshot.o ui-blob.o CFLAGS += -Wall ifdef DEBUG CFLAGS += -g endif CFLAGS += -Igit CFLAGS += -DSHA1_HEADER='$(SHA1_HEADER)' CFLAGS += -DCGIT_VERSION='"$(CGIT_VERSION)"' CFLAGS += -DCGIT_CONFIG='"$(CGIT_CONFIG)"' +CFLAGS += -DCGIT_SCRIPT_NAME='"$(CGIT_SCRIPT_NAME)"' # # If make is run on a nongit platform, we need to get the git sources as a tarball. # But there is currently no recent enough tarball available on kernel.org, so download # a zipfile from hjemli.net instead # GITVER = $(shell git version 2>/dev/null || echo nogit) @@ -51,17 +53,17 @@ git/libgit.a: $(INITGIT) $(MAKE) -C git # # phony targets # install: all clean-cache mkdir -p $(prefix) - install cgit $(prefix)/cgit.cgi + install cgit $(prefix)/$(CGIT_SCRIPT_NAME) install cgit.css $(prefix)/cgit.css install add.png del.png $(prefix)/ clean-cgit: rm -f cgit *.o distclean-cgit: clean-cgit git clean -d -x @@ -239,16 +239,18 @@ int main(int argc, const char **argv) htmlfd = STDOUT_FILENO; item.st.st_mtime = time(NULL); cgit_repolist.length = 0; cgit_repolist.count = 0; cgit_repolist.repos = NULL; cgit_read_config(CGIT_CONFIG, cgit_global_config_cb); + if (getenv("SCRIPT_NAME")) + cgit_script_name = xstrdup(getenv("SCRIPT_NAME")); if (getenv("QUERY_STRING")) cgit_querystring = xstrdup(getenv("QUERY_STRING")); cgit_parse_args(argc, argv); cgit_parse_query(cgit_querystring, cgit_querystring_cb); if (!cgit_prepare_cache(&item)) return 0; if (cgit_nocache) { cgit_fill_cache(&item, 0); @@ -70,16 +70,17 @@ extern struct repolist cgit_repolist; extern struct repoinfo *cgit_repo; extern char *cgit_root_title; extern char *cgit_css; extern char *cgit_logo; extern char *cgit_logo_link; extern char *cgit_module_link; extern char *cgit_virtual_root; +extern char *cgit_script_name; extern char *cgit_cache_root; extern int cgit_nocache; extern int cgit_snapshots; extern int cgit_max_lock_attempts; extern int cgit_cache_root_ttl; extern int cgit_cache_repo_ttl; extern int cgit_cache_dynamic_ttl; @@ -12,17 +12,17 @@ struct repolist cgit_repolist; struct repoinfo *cgit_repo; char *cgit_root_title = "Git repository browser"; char *cgit_css = "/cgit.css"; char *cgit_logo = "/git-logo.png"; char *cgit_logo_link = "http://www.kernel.org/pub/software/scm/git/docs/"; char *cgit_module_link = "./?repo=%s&page=commit&id=%s"; char *cgit_virtual_root = NULL; - +char *cgit_script_name = CGIT_SCRIPT_NAME; char *cgit_cache_root = "/var/cache/cgit"; int cgit_nocache = 0; int cgit_snapshots = 0; int cgit_max_lock_attempts = 5; int cgit_cache_root_ttl = 5; int cgit_cache_repo_ttl = 5; int cgit_cache_dynamic_ttl = 5; diff --git a/ui-shared.c b/ui-shared.c index 6f5cf2b..b0cff7d 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -40,17 +40,17 @@ void cgit_print_error(char *msg) html("</div>\n"); } char *cgit_rooturl() { if (cgit_virtual_root) return fmt("%s/", cgit_virtual_root); else - return "./cgit.cgi"; + return cgit_script_name; } char *cgit_repourl(const char *reponame) { if (cgit_virtual_root) { return fmt("%s/%s/", cgit_virtual_root, reponame); } else { return fmt("?r=%s", reponame); @@ -66,17 +66,17 @@ char *cgit_pageurl(const char *reponame, const char *pagename, } else { return fmt("?r=%s&p=%s&%s", reponame, pagename, query); } } char *cgit_currurl() { if (!cgit_virtual_root) - return "./cgit.cgi"; + return cgit_script_name; else if (cgit_query_page) return fmt("%s/%s/%s/", cgit_virtual_root, cgit_query_repo, cgit_query_page); else if (cgit_query_repo) return fmt("%s/%s/", cgit_virtual_root, cgit_query_repo); else return fmt("%s/", cgit_virtual_root); } |