author | Lars Hjemli <hjemli@gmail.com> | 2007-05-14 22:48:31 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2007-05-14 22:48:31 (UTC) |
commit | ea2831f1c826d92c0158474c2d07837ec2f9fd6c (patch) (side-by-side diff) | |
tree | e8d6a89bf0f50835f9c86dd642e7906e1d050df7 | |
parent | 6fb7d09fea94b3dd6932469283358cb24f1e7e29 (diff) | |
download | cgit-ea2831f1c826d92c0158474c2d07837ec2f9fd6c.zip cgit-ea2831f1c826d92c0158474c2d07837ec2f9fd6c.tar.gz cgit-ea2831f1c826d92c0158474c2d07837ec2f9fd6c.tar.bz2 |
Don't hardcode urls when SCRIPT_NAME is available
Also, let the makefile define the name of the installed cgi and
use that definition as a default value for cgit_script_name variable.
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
-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,39 +1,41 @@ 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) ifeq ($(GITVER),nogit) GITURL = http://hjemli.net/git/git/snapshot/?id=v1.5.2-rc2 INITGIT = test -e git/git.c || (curl "$(GITURL)" > tmp.zip && unzip tmp.zip) else INITGIT = ./submodules.sh -i endif @@ -43,33 +45,33 @@ endif all: cgit cgit: cgit.c cgit.h $(OBJECTS) $(CC) $(CFLAGS) cgit.c -o cgit $(OBJECTS) $(EXTLIBS) $(OBJECTS): cgit.h git/libgit.a 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 clean-sub: $(MAKE) -C git clean distclean-sub: clean-sub $(shell cd git && git clean -d -x) clean-cache: @@ -231,30 +231,32 @@ static void cgit_parse_args(int argc, const char **argv) cgit_query_ofs = atoi(argv[i]+6); } } } int main(int argc, const char **argv) { struct cacheitem item; 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); } else { cgit_check_cache(&item); cgit_print_cache(&item); } return 0; } @@ -62,32 +62,33 @@ struct taginfo { char *tagger_email; int tagger_date; char *msg; }; extern const char cgit_version[]; 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; extern int cgit_cache_static_ttl; extern int cgit_cache_max_create_time; extern int cgit_max_msg_len; extern int cgit_max_commit_count; extern char *cgit_repo_name; extern char *cgit_repo_desc; @@ -4,33 +4,33 @@ * * Licensed under GNU General Public License v2 * (see COPYING for full license text) */ #include "cgit.h" 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; int cgit_cache_static_ttl = -1; int cgit_cache_max_create_time = 5; int cgit_max_msg_len = 60; int cgit_max_commit_count = 50; char *cgit_repo_name = NULL; char *cgit_repo_desc = NULL; diff --git a/ui-shared.c b/ui-shared.c index 6f5cf2b..b0cff7d 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -32,59 +32,59 @@ static long ttl_seconds(long ttl) else return ttl * 60; } void cgit_print_error(char *msg) { html("<div class='error'>"); html_txt(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); } } char *cgit_pageurl(const char *reponame, const char *pagename, const char *query) { if (cgit_virtual_root) { return fmt("%s/%s/%s/?%s", cgit_virtual_root, reponame, pagename, query); } 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); } void cgit_print_date(unsigned long secs) { char buf[32]; struct tm *time; time = gmtime(&secs); strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", time); |