From 8830bf4bc5b2d03027eff8a4dc6a0cb823ec3c3b Mon Sep 17 00:00:00 2001 From: Mark Rada Date: Fri, 2 Apr 2010 20:33:55 -0400 Subject: [PATCH 1/6] Gitweb: add ignore and clean rules for minified files Signed-off-by: Mark Rada Signed-off-by: Junio C Hamano --- .gitignore | 1 + Makefile | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 7b3acb766..4c2415276 100644 --- a/.gitignore +++ b/.gitignore @@ -156,6 +156,7 @@ /git-core-*/?* /gitk-git/gitk-wish /gitweb/gitweb.cgi +/gitweb/gitweb.min.* /test-chmtime /test-ctype /test-date diff --git a/Makefile b/Makefile index 8a0f5c4d5..62a029ccc 100644 --- a/Makefile +++ b/Makefile @@ -2085,7 +2085,7 @@ clean: $(RM) $(htmldocs).tar.gz $(manpages).tar.gz $(MAKE) -C Documentation/ clean ifndef NO_PERL - $(RM) gitweb/gitweb.cgi + $(RM) gitweb/gitweb.cgi gitweb/gitweb.min.* $(MAKE) -C perl clean endif ifndef NO_PYTHON From 0e6ce21361c5d8e35cd15327539eec1f627aa0e3 Mon Sep 17 00:00:00 2001 From: Mark Rada Date: Fri, 2 Apr 2010 20:35:05 -0400 Subject: [PATCH 2/6] Gitweb: add support for minifying gitweb.css The build system added support minifying gitweb.js through a JavaScript minifier, but most minifiers come with support for minifying CSS files as well, so we should use it if we can. This patch will add the same facilities to gitweb.css that gitweb.js has for minification. That does not mean that they will use the same minifier though, as it is not safe to assume that all JavaScript minifiers will also minify CSS files. This patch also adds the GITWEB_PROGRAMS variable to the Makefile to keep a list of potential gitweb dependencies separate from OTHER_PROGRAMS when we need to know just the gitweb dependencies. Though the bandwidth savings will not be as dramatic as with the JavaScript minifier, every byte saved is important. Signed-off-by: Mark Rada Signed-off-by: Junio C Hamano --- Makefile | 21 +++++++++++++++------ gitweb/INSTALL | 5 +++++ gitweb/Makefile | 28 +++++++++++++++++++++------- gitweb/README | 3 ++- 4 files changed, 43 insertions(+), 14 deletions(-) diff --git a/Makefile b/Makefile index 62a029ccc..9bebcf1c4 100644 --- a/Makefile +++ b/Makefile @@ -203,6 +203,9 @@ all:: # Define JSMIN to point to JavaScript minifier that functions as # a filter to have gitweb.js minified. # +# Define CSSMIN to point to a CSS minifier in order to generate a minified +# version of gitweb.css +# # Define DEFAULT_PAGER to a sensible pager command (defaults to "less") if # you want to use something different. The value will be interpreted by the # shell at runtime when it is used. @@ -279,8 +282,9 @@ lib = lib # DESTDIR= pathsep = : -# JavaScript minifier invocation that can function as filter +# JavaScript/CSS minifier invocation that can function as filter JSMIN = +CSSMIN = export prefix bindir sharedir sysconfdir @@ -1560,18 +1564,23 @@ gitweb: $(QUIET_SUBDIR0)gitweb $(QUIET_SUBDIR1) all ifdef JSMIN -OTHER_PROGRAMS += gitweb/gitweb.cgi gitweb/gitweb.min.js -gitweb/gitweb.cgi: gitweb/gitweb.perl gitweb/gitweb.min.js -else -OTHER_PROGRAMS += gitweb/gitweb.cgi -gitweb/gitweb.cgi: gitweb/gitweb.perl +GITWEB_PROGRAMS += gitweb/gitweb.min.js endif +ifdef CSSMIN +GITWEB_PROGRAMS += gitweb/gitweb.min.css +endif +OTHER_PROGRAMS += gitweb/gitweb.cgi $(GITWEB_PROGRAMS) +gitweb/gitweb.cgi: gitweb/gitweb.perl $(GITWEB_PROGRAMS) $(QUIET_SUBDIR0)gitweb $(QUIET_SUBDIR1) $(patsubst gitweb/%,%,$@) ifdef JSMIN gitweb/gitweb.min.js: gitweb/gitweb.js $(QUIET_SUBDIR0)gitweb $(QUIET_SUBDIR1) $(patsubst gitweb/%,%,$@) endif # JSMIN +ifdef CSSMIN +gitweb/gitweb.min.css: gitweb/gitweb.css + $(QUIET_SUBDIR0)gitweb $(QUIET_SUBDIR1) $(patsubst gitweb/%,%,$@) +endif # CSSMIN git-instaweb: git-instaweb.sh gitweb/gitweb.cgi gitweb/gitweb.css gitweb/gitweb.js diff --git a/gitweb/INSTALL b/gitweb/INSTALL index b76a0cfff..b75a90be7 100644 --- a/gitweb/INSTALL +++ b/gitweb/INSTALL @@ -66,6 +66,11 @@ file for gitweb (in gitweb/README). build configuration variables. By default gitweb tries to find them in the same directory as gitweb.cgi script. +- You can optionally generate a minified version of gitweb.css by defining + the CSSMIN build configuration variable. By default the non-minified + version of gitweb.css will be used. NOTE: if you enable this option, + substitute gitweb.min.css for all uses of gitweb.css in the help files. + Build example ~~~~~~~~~~~~~ diff --git a/gitweb/Makefile b/gitweb/Makefile index c9eb1ee66..fffe70076 100644 --- a/gitweb/Makefile +++ b/gitweb/Makefile @@ -6,13 +6,17 @@ all:: # Define JSMIN to point to JavaScript minifier that functions as # a filter to have gitweb.js minified. # +# Define CSSMIN to point to a CSS minifier in order to generate a minified +# version of gitweb.css +# prefix ?= $(HOME) bindir ?= $(prefix)/bin RM ?= rm -f -# JavaScript minifier invocation that can function as filter +# JavaScript/CSS minifier invocation that can function as filter JSMIN ?= +CSSMIN ?= # default configuration for gitweb GITWEB_CONFIG = gitweb_config.perl @@ -26,7 +30,11 @@ GITWEB_STRICT_EXPORT = GITWEB_BASE_URL = GITWEB_LIST = GITWEB_HOMETEXT = indextext.html +ifdef CSSMIN +GITWEB_CSS = gitweb.min.css +else GITWEB_CSS = gitweb.css +endif GITWEB_LOGO = git-logo.png GITWEB_FAVICON = git-favicon.png ifdef JSMIN @@ -84,13 +92,14 @@ endif all:: gitweb.cgi +FILES = gitweb.cgi ifdef JSMIN -FILES=gitweb.cgi gitweb.min.js -gitweb.cgi: gitweb.perl gitweb.min.js -else # !JSMIN -FILES=gitweb.cgi -gitweb.cgi: gitweb.perl -endif # JSMIN +FILES += gitweb.min.js +endif +ifdef CSSMIN +FILES += gitweb.min.css +endif +gitweb.cgi: gitweb.perl $(GITWEB_JS) $(GITWEB_CSS) gitweb.cgi: $(QUIET_GEN)$(RM) $@ $@+ && \ @@ -123,6 +132,11 @@ gitweb.min.js: gitweb.js $(QUIET_GEN)$(JSMIN) <$< >$@ endif # JSMIN +ifdef CSSMIN +gitweb.min.css: gitweb.css + $(QUIET_GEN)$(CSSMIN) <$ >$@ +endif + clean: $(RM) $(FILES) diff --git a/gitweb/README b/gitweb/README index ad6a04c46..71742b335 100644 --- a/gitweb/README +++ b/gitweb/README @@ -80,7 +80,8 @@ You can specify the following configuration variables when building GIT: Points to the location where you put gitweb.css on your web server (or to be more generic, the URI of gitweb stylesheet). Relative to the base URI of gitweb. Note that you can setup multiple stylesheets from - the gitweb config file. [Default: gitweb.css] + the gitweb config file. [Default: gitweb.css (or gitweb.min.css if the + CSSMIN variable is defined / CSS minifier is used)] * GITWEB_LOGO Points to the location where you put git-logo.png on your web server (or to be more generic URI of logo, 72x27 size, displayed in top right From bb4bbf75829d1a6c021e34943ff4e942f064bb55 Mon Sep 17 00:00:00 2001 From: Mark Rada Date: Fri, 2 Apr 2010 20:35:54 -0400 Subject: [PATCH 3/6] Gitweb: add autoconfigure support for minifiers This will allow users to set a JavaScript/CSS minifier when/if they run the autoconfigure script while building git. Signed-off-by: Mark Rada Signed-off-by: Junio C Hamano --- Makefile | 4 ---- configure.ac | 20 ++++++++++++++++++++ gitweb/Makefile | 14 ++------------ 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/Makefile b/Makefile index 9bebcf1c4..2c36def3e 100644 --- a/Makefile +++ b/Makefile @@ -282,10 +282,6 @@ lib = lib # DESTDIR= pathsep = : -# JavaScript/CSS minifier invocation that can function as filter -JSMIN = -CSSMIN = - export prefix bindir sharedir sysconfdir CC = gcc diff --git a/configure.ac b/configure.ac index 914ae5759..f4d7372ef 100644 --- a/configure.ac +++ b/configure.ac @@ -179,6 +179,26 @@ fi], AC_MSG_NOTICE([Will try -pthread then -lpthread to enable POSIX Threads.]) ]) +# Define option to enable JavaScript minification +AC_ARG_ENABLE([jsmin], +[AS_HELP_STRING([--enable-jsmin=PATH], + [PATH is the name of a JavaScript minifier or the absolute path to one.])], +[ + JSMIN=$enableval; + AC_MSG_NOTICE([Setting JSMIN to '$JSMIN' to enable JavaScript minifying]) + GIT_CONF_APPEND_LINE(JSMIN=$enableval); +]) + +# Define option to enable CSS minification +AC_ARG_ENABLE([cssmin], +[AS_HELP_STRING([--enable-cssmin=PATH], + [PATH is the name of a CSS minifier or the absolute path to one.])], +[ + CSSMIN=$enableval; + AC_MSG_NOTICE([Setting CSSMIN to '$CSSMIN' to enable CSS minifying]) + GIT_CONF_APPEND_LINE(CSSMIN=$enableval); +]) + ## Site configuration (override autodetection) ## --with-PACKAGE[=ARG] and --without-PACKAGE AC_MSG_NOTICE([CHECKS for site configuration]) diff --git a/gitweb/Makefile b/gitweb/Makefile index fffe70076..ffee4bd1e 100644 --- a/gitweb/Makefile +++ b/gitweb/Makefile @@ -14,10 +14,6 @@ prefix ?= $(HOME) bindir ?= $(prefix)/bin RM ?= rm -f -# JavaScript/CSS minifier invocation that can function as filter -JSMIN ?= -CSSMIN ?= - # default configuration for gitweb GITWEB_CONFIG = gitweb_config.perl GITWEB_CONFIG_SYSTEM = /etc/gitweb.conf @@ -30,18 +26,10 @@ GITWEB_STRICT_EXPORT = GITWEB_BASE_URL = GITWEB_LIST = GITWEB_HOMETEXT = indextext.html -ifdef CSSMIN -GITWEB_CSS = gitweb.min.css -else GITWEB_CSS = gitweb.css -endif GITWEB_LOGO = git-logo.png GITWEB_FAVICON = git-favicon.png -ifdef JSMIN -GITWEB_JS = gitweb.min.js -else GITWEB_JS = gitweb.js -endif GITWEB_SITE_HEADER = GITWEB_SITE_FOOTER = @@ -95,9 +83,11 @@ all:: gitweb.cgi FILES = gitweb.cgi ifdef JSMIN FILES += gitweb.min.js +GITWEB_JS = gitweb.min.js endif ifdef CSSMIN FILES += gitweb.min.css +GITWEB_CSS = gitweb.min.css endif gitweb.cgi: gitweb.perl $(GITWEB_JS) $(GITWEB_CSS) From 09b89d1a082a298a182875076c068711210bb5c2 Mon Sep 17 00:00:00 2001 From: Mark Rada Date: Fri, 2 Apr 2010 20:40:33 -0400 Subject: [PATCH 4/6] instaweb: add minification awareness This patch will cause git-instaweb to use the minified version of gitweb support files (e.g. CSS and JavaScript) if they were generated. Without minification awareness, generating the minified version of gitweb's support files will generate a broken instaweb script since the copy of gitweb.cgi will look for gitweb.min.* which will not exist. Signed-off-by: Mark Rada Signed-off-by: Junio C Hamano --- Makefile | 12 ++++++++++-- git-instaweb.sh | 6 ++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 2c36def3e..7aad43fd2 100644 --- a/Makefile +++ b/Makefile @@ -1561,9 +1561,15 @@ gitweb: ifdef JSMIN GITWEB_PROGRAMS += gitweb/gitweb.min.js +GITWEB_JS = gitweb/gitweb.min.js +else +GITWEB_JS = gitweb/gitweb.js endif ifdef CSSMIN GITWEB_PROGRAMS += gitweb/gitweb.min.css +GITWEB_CSS = gitweb/gitweb.min.css +else +GITWEB_CSS = gitweb/gitweb.css endif OTHER_PROGRAMS += gitweb/gitweb.cgi $(GITWEB_PROGRAMS) gitweb/gitweb.cgi: gitweb/gitweb.perl $(GITWEB_PROGRAMS) @@ -1586,11 +1592,13 @@ git-instaweb: git-instaweb.sh gitweb/gitweb.cgi gitweb/gitweb.css gitweb/gitweb. -e 's/@@NO_CURL@@/$(NO_CURL)/g' \ -e '/@@GITWEB_CGI@@/r gitweb/gitweb.cgi' \ -e '/@@GITWEB_CGI@@/d' \ - -e '/@@GITWEB_CSS@@/r gitweb/gitweb.css' \ + -e '/@@GITWEB_CSS@@/r $(GITWEB_CSS)' \ -e '/@@GITWEB_CSS@@/d' \ - -e '/@@GITWEB_JS@@/r gitweb/gitweb.js' \ + -e '/@@GITWEB_JS@@/r $(GITWEB_JS)' \ -e '/@@GITWEB_JS@@/d' \ -e 's|@@PERL@@|$(PERL_PATH_SQ)|g' \ + -e 's|@@GITWEB_CSS_NAME@@|$(GITWEB_CSS)|' \ + -e 's|@@GITWEB_JS_NAME@@|$(GITWEB_JS)|' \ $@.sh > $@+ && \ chmod +x $@+ && \ mv $@+ $@ diff --git a/git-instaweb.sh b/git-instaweb.sh index 6a65f255c..d4941a9ce 100755 --- a/git-instaweb.sh +++ b/git-instaweb.sh @@ -391,18 +391,20 @@ EOFGITWEB gitweb_css () { cat > "$1" <<\EOFGITWEB @@GITWEB_CSS@@ + EOFGITWEB } gitweb_js () { cat > "$1" <<\EOFGITWEB @@GITWEB_JS@@ + EOFGITWEB } gitweb_cgi "$GIT_DIR/gitweb/gitweb.cgi" -gitweb_css "$GIT_DIR/gitweb/gitweb.css" -gitweb_js "$GIT_DIR/gitweb/gitweb.js" +gitweb_css "$GIT_DIR/@@GITWEB_CSS_NAME@@" +gitweb_js "$GIT_DIR/@@GITWEB_JS_NAME@@" case "$httpd" in *lighttpd*) From a8ab675f21b6e8b003b7a8ba0a72933cf34afb68 Mon Sep 17 00:00:00 2001 From: Mark Rada Date: Fri, 2 Apr 2010 20:36:44 -0400 Subject: [PATCH 5/6] gitweb: add documentation to INSTALL regarding gitweb.js This patch updates gitweb/INSTALL to mention gitweb.js, including JavaScript minification support. Signed-off-by: Mark Rada Signed-off-by: Junio C Hamano --- gitweb/INSTALL | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/gitweb/INSTALL b/gitweb/INSTALL index b75a90be7..44ff17d62 100644 --- a/gitweb/INSTALL +++ b/gitweb/INSTALL @@ -3,8 +3,9 @@ GIT web Interface (gitweb) Installation First you have to generate gitweb.cgi from gitweb.perl using "make gitweb/gitweb.cgi", then copy appropriate files (gitweb.cgi, -gitweb.css, git-logo.png and git-favicon.png) to their destination. -For example if git was (or is) installed with /usr prefix, you can do +gitweb.js, gitweb.css, git-logo.png and git-favicon.png) to their +destination. For example if git was (or is) installed with /usr prefix, +you can do $ make prefix=/usr gitweb/gitweb.cgi ;# as yourself # cp gitweb/git* /var/www/cgi-bin/ ;# as root @@ -62,14 +63,15 @@ file for gitweb (in gitweb/README). a suggestion). - You can control where gitweb tries to find its main CSS style file, - its favicon and logo with the GITWEB_CSS, GITWEB_FAVICON and GITWEB_LOGO - build configuration variables. By default gitweb tries to find them - in the same directory as gitweb.cgi script. + its JavaScript file, its favicon and logo with the GITWEB_CSS, GITWEB_JS + GITWEB_FAVICON and GITWEB_LOGO build configuration variables. By default + gitweb tries to find them in the same directory as gitweb.cgi script. -- You can optionally generate a minified version of gitweb.css by defining - the CSSMIN build configuration variable. By default the non-minified - version of gitweb.css will be used. NOTE: if you enable this option, - substitute gitweb.min.css for all uses of gitweb.css in the help files. +- You can optionally generate minified versions of gitweb.js and gitweb.css + by defining the JSMIN and CSSMIN build configuration variables. By default + the non-minified versions will be used. NOTE: if you enable this option, + substitute gitweb.min.js and gitweb.min.css for all uses of gitweb.js and + gitweb.css in the help files. Build example ~~~~~~~~~~~~~ @@ -79,13 +81,14 @@ Build example we want to display are under /home/local/scm, you can do make GITWEB_PROJECTROOT="/home/local/scm" \ + GITWEB_JS="/gitweb/gitweb.js" \ GITWEB_CSS="/gitweb/gitweb.css" \ GITWEB_LOGO="/gitweb/git-logo.png" \ GITWEB_FAVICON="/gitweb/git-favicon.png" \ bindir=/usr/local/bin \ gitweb/gitweb.cgi - cp -fv ~/git/gitweb/gitweb.{cgi,css} \ + cp -fv ~/git/gitweb/gitweb.{cgi,js,css} \ ~/git/gitweb/git-{favicon,logo}.png \ /var/www/cgi-bin/gitweb/ From e3918594f6269b37ad7bd7e419df433b6d586428 Mon Sep 17 00:00:00 2001 From: Mark Rada Date: Fri, 2 Apr 2010 20:37:33 -0400 Subject: [PATCH 6/6] gitweb: update INSTALL to use shorter make target Gitweb can be generated by the gitweb/gitweb.cgi target or the gitweb target. Since the gitweb target is shorter, I think it would be better to have new users be instructed to use it. Signed-off-by: Mark Rada Signed-off-by: Junio C Hamano --- gitweb/INSTALL | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/gitweb/INSTALL b/gitweb/INSTALL index 44ff17d62..cbdc13647 100644 --- a/gitweb/INSTALL +++ b/gitweb/INSTALL @@ -2,12 +2,11 @@ GIT web Interface (gitweb) Installation ======================================= First you have to generate gitweb.cgi from gitweb.perl using -"make gitweb/gitweb.cgi", then copy appropriate files (gitweb.cgi, -gitweb.js, gitweb.css, git-logo.png and git-favicon.png) to their -destination. For example if git was (or is) installed with /usr prefix, -you can do +"make gitweb", then copy appropriate files (gitweb.cgi, gitweb.js, +gitweb.css, git-logo.png and git-favicon.png) to their destination. +For example if git was (or is) installed with /usr prefix, you can do - $ make prefix=/usr gitweb/gitweb.cgi ;# as yourself + $ make prefix=/usr gitweb ;# as yourself # cp gitweb/git* /var/www/cgi-bin/ ;# as root Alternatively you can use autoconf generated ./configure script to @@ -16,7 +15,7 @@ instead $ make configure ;# as yourself $ ./configure --prefix=/usr ;# as yourself - $ make gitweb/gitweb.cgi ;# as yourself + $ make gitweb ;# as yourself # cp gitweb/git* /var/www/cgi-bin/ ;# as root The above example assumes that your web server is configured to run @@ -32,8 +31,7 @@ file for gitweb (in gitweb/README). - There are many configuration variables which affect building of gitweb.cgi; see "default configuration for gitweb" section in main - (top dir) Makefile, and instructions for building gitweb/gitweb.cgi - target. + (top dir) Makefile, and instructions for building gitweb target. One of the most important is where to find the git wrapper binary. Gitweb tries to find the git wrapper at $(bindir)/git, so you have to set $bindir @@ -86,7 +84,7 @@ Build example GITWEB_LOGO="/gitweb/git-logo.png" \ GITWEB_FAVICON="/gitweb/git-favicon.png" \ bindir=/usr/local/bin \ - gitweb/gitweb.cgi + gitweb cp -fv ~/git/gitweb/gitweb.{cgi,js,css} \ ~/git/gitweb/git-{favicon,logo}.png \