Browse Source

Merge branch 'mr/gitweb-jsmin'

* mr/gitweb-jsmin:
  gitweb: update INSTALL to use shorter make target
  gitweb: add documentation to INSTALL regarding gitweb.js
  instaweb: add minification awareness
  Gitweb: add autoconfigure support for minifiers
  Gitweb: add support for minifying gitweb.css
  Gitweb: add ignore and clean rules for minified files
maint
Junio C Hamano 15 years ago
parent
commit
b92cbb62de
  1. 1
      .gitignore
  2. 33
      Makefile
  3. 20
      configure.ac
  4. 6
      git-instaweb.sh
  5. 26
      gitweb/INSTALL
  6. 30
      gitweb/Makefile
  7. 3
      gitweb/README

1
.gitignore vendored

@ -156,6 +156,7 @@
/git-core-*/?* /git-core-*/?*
/gitk-git/gitk-wish /gitk-git/gitk-wish
/gitweb/gitweb.cgi /gitweb/gitweb.cgi
/gitweb/gitweb.min.*
/test-chmtime /test-chmtime
/test-ctype /test-ctype
/test-date /test-date

33
Makefile

@ -203,6 +203,9 @@ all::
# Define JSMIN to point to JavaScript minifier that functions as # Define JSMIN to point to JavaScript minifier that functions as
# a filter to have gitweb.js minified. # 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 # 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 # you want to use something different. The value will be interpreted by the
# shell at runtime when it is used. # shell at runtime when it is used.
@ -279,9 +282,6 @@ lib = lib
# DESTDIR= # DESTDIR=
pathsep = : pathsep = :


# JavaScript minifier invocation that can function as filter
JSMIN =

export prefix bindir sharedir sysconfdir export prefix bindir sharedir sysconfdir


CC = gcc CC = gcc
@ -1561,18 +1561,29 @@ gitweb:
$(QUIET_SUBDIR0)gitweb $(QUIET_SUBDIR1) all $(QUIET_SUBDIR0)gitweb $(QUIET_SUBDIR1) all


ifdef JSMIN ifdef JSMIN
OTHER_PROGRAMS += gitweb/gitweb.cgi gitweb/gitweb.min.js GITWEB_PROGRAMS += gitweb/gitweb.min.js
gitweb/gitweb.cgi: gitweb/gitweb.perl gitweb/gitweb.min.js GITWEB_JS = gitweb/gitweb.min.js
else else
OTHER_PROGRAMS += gitweb/gitweb.cgi GITWEB_JS = gitweb/gitweb.js
gitweb/gitweb.cgi: gitweb/gitweb.perl
endif 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)
$(QUIET_SUBDIR0)gitweb $(QUIET_SUBDIR1) $(patsubst gitweb/%,%,$@) $(QUIET_SUBDIR0)gitweb $(QUIET_SUBDIR1) $(patsubst gitweb/%,%,$@)


ifdef JSMIN ifdef JSMIN
gitweb/gitweb.min.js: gitweb/gitweb.js gitweb/gitweb.min.js: gitweb/gitweb.js
$(QUIET_SUBDIR0)gitweb $(QUIET_SUBDIR1) $(patsubst gitweb/%,%,$@) $(QUIET_SUBDIR0)gitweb $(QUIET_SUBDIR1) $(patsubst gitweb/%,%,$@)
endif # JSMIN 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 git-instaweb: git-instaweb.sh gitweb/gitweb.cgi gitweb/gitweb.css gitweb/gitweb.js
@ -1582,11 +1593,13 @@ git-instaweb: git-instaweb.sh gitweb/gitweb.cgi gitweb/gitweb.css gitweb/gitweb.
-e 's/@@NO_CURL@@/$(NO_CURL)/g' \ -e 's/@@NO_CURL@@/$(NO_CURL)/g' \
-e '/@@GITWEB_CGI@@/r gitweb/gitweb.cgi' \ -e '/@@GITWEB_CGI@@/r gitweb/gitweb.cgi' \
-e '/@@GITWEB_CGI@@/d' \ -e '/@@GITWEB_CGI@@/d' \
-e '/@@GITWEB_CSS@@/r gitweb/gitweb.css' \ -e '/@@GITWEB_CSS@@/r $(GITWEB_CSS)' \
-e '/@@GITWEB_CSS@@/d' \ -e '/@@GITWEB_CSS@@/d' \
-e '/@@GITWEB_JS@@/r gitweb/gitweb.js' \ -e '/@@GITWEB_JS@@/r $(GITWEB_JS)' \
-e '/@@GITWEB_JS@@/d' \ -e '/@@GITWEB_JS@@/d' \
-e 's|@@PERL@@|$(PERL_PATH_SQ)|g' \ -e 's|@@PERL@@|$(PERL_PATH_SQ)|g' \
-e 's|@@GITWEB_CSS_NAME@@|$(GITWEB_CSS)|' \
-e 's|@@GITWEB_JS_NAME@@|$(GITWEB_JS)|' \
$@.sh > $@+ && \ $@.sh > $@+ && \
chmod +x $@+ && \ chmod +x $@+ && \
mv $@+ $@ mv $@+ $@
@ -2085,7 +2098,7 @@ clean:
$(RM) $(htmldocs).tar.gz $(manpages).tar.gz $(RM) $(htmldocs).tar.gz $(manpages).tar.gz
$(MAKE) -C Documentation/ clean $(MAKE) -C Documentation/ clean
ifndef NO_PERL ifndef NO_PERL
$(RM) gitweb/gitweb.cgi $(RM) gitweb/gitweb.cgi gitweb/gitweb.min.*
$(MAKE) -C perl clean $(MAKE) -C perl clean
endif endif
ifndef NO_PYTHON ifndef NO_PYTHON

20
configure.ac

@ -179,6 +179,26 @@ fi],
AC_MSG_NOTICE([Will try -pthread then -lpthread to enable POSIX Threads.]) 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) ## Site configuration (override autodetection)
## --with-PACKAGE[=ARG] and --without-PACKAGE ## --with-PACKAGE[=ARG] and --without-PACKAGE
AC_MSG_NOTICE([CHECKS for site configuration]) AC_MSG_NOTICE([CHECKS for site configuration])

6
git-instaweb.sh

@ -391,18 +391,20 @@ EOFGITWEB
gitweb_css () { gitweb_css () {
cat > "$1" <<\EOFGITWEB cat > "$1" <<\EOFGITWEB
@@GITWEB_CSS@@ @@GITWEB_CSS@@

EOFGITWEB EOFGITWEB
} }


gitweb_js () { gitweb_js () {
cat > "$1" <<\EOFGITWEB cat > "$1" <<\EOFGITWEB
@@GITWEB_JS@@ @@GITWEB_JS@@

EOFGITWEB EOFGITWEB
} }


gitweb_cgi "$GIT_DIR/gitweb/gitweb.cgi" gitweb_cgi "$GIT_DIR/gitweb/gitweb.cgi"
gitweb_css "$GIT_DIR/gitweb/gitweb.css" gitweb_css "$GIT_DIR/@@GITWEB_CSS_NAME@@"
gitweb_js "$GIT_DIR/gitweb/gitweb.js" gitweb_js "$GIT_DIR/@@GITWEB_JS_NAME@@"


case "$httpd" in case "$httpd" in
*lighttpd*) *lighttpd*)

26
gitweb/INSTALL

@ -2,11 +2,11 @@ GIT web Interface (gitweb) Installation
======================================= =======================================


First you have to generate gitweb.cgi from gitweb.perl using First you have to generate gitweb.cgi from gitweb.perl using
"make gitweb/gitweb.cgi", then copy appropriate files (gitweb.cgi, "make gitweb", then copy appropriate files (gitweb.cgi, gitweb.js,
gitweb.css, git-logo.png and git-favicon.png) to their destination. 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 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 # cp gitweb/git* /var/www/cgi-bin/ ;# as root


Alternatively you can use autoconf generated ./configure script to Alternatively you can use autoconf generated ./configure script to
@ -15,7 +15,7 @@ instead


$ make configure ;# as yourself $ make configure ;# as yourself
$ ./configure --prefix=/usr ;# 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 # cp gitweb/git* /var/www/cgi-bin/ ;# as root


The above example assumes that your web server is configured to run The above example assumes that your web server is configured to run
@ -31,8 +31,7 @@ file for gitweb (in gitweb/README).


- There are many configuration variables which affect building of - There are many configuration variables which affect building of
gitweb.cgi; see "default configuration for gitweb" section in main gitweb.cgi; see "default configuration for gitweb" section in main
(top dir) Makefile, and instructions for building gitweb/gitweb.cgi (top dir) Makefile, and instructions for building gitweb target.
target.


One of the most important is where to find the git wrapper binary. Gitweb 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 tries to find the git wrapper at $(bindir)/git, so you have to set $bindir
@ -62,9 +61,15 @@ file for gitweb (in gitweb/README).
a suggestion). a suggestion).


- You can control where gitweb tries to find its main CSS style file, - 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 its JavaScript file, its favicon and logo with the GITWEB_CSS, GITWEB_JS
build configuration variables. By default gitweb tries to find them GITWEB_FAVICON and GITWEB_LOGO build configuration variables. By default
in the same directory as gitweb.cgi script. gitweb tries to find them in the same directory as gitweb.cgi script.

- 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 Build example
~~~~~~~~~~~~~ ~~~~~~~~~~~~~
@ -74,13 +79,14 @@ Build example
we want to display are under /home/local/scm, you can do we want to display are under /home/local/scm, you can do


make GITWEB_PROJECTROOT="/home/local/scm" \ make GITWEB_PROJECTROOT="/home/local/scm" \
GITWEB_JS="/gitweb/gitweb.js" \
GITWEB_CSS="/gitweb/gitweb.css" \ GITWEB_CSS="/gitweb/gitweb.css" \
GITWEB_LOGO="/gitweb/git-logo.png" \ GITWEB_LOGO="/gitweb/git-logo.png" \
GITWEB_FAVICON="/gitweb/git-favicon.png" \ GITWEB_FAVICON="/gitweb/git-favicon.png" \
bindir=/usr/local/bin \ bindir=/usr/local/bin \
gitweb/gitweb.cgi gitweb


cp -fv ~/git/gitweb/gitweb.{cgi,css} \ cp -fv ~/git/gitweb/gitweb.{cgi,js,css} \
~/git/gitweb/git-{favicon,logo}.png \ ~/git/gitweb/git-{favicon,logo}.png \
/var/www/cgi-bin/gitweb/ /var/www/cgi-bin/gitweb/



30
gitweb/Makefile

@ -6,14 +6,14 @@ all::
# Define JSMIN to point to JavaScript minifier that functions as # Define JSMIN to point to JavaScript minifier that functions as
# a filter to have gitweb.js minified. # 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) prefix ?= $(HOME)
bindir ?= $(prefix)/bin bindir ?= $(prefix)/bin
RM ?= rm -f RM ?= rm -f


# JavaScript minifier invocation that can function as filter
JSMIN ?=

# default configuration for gitweb # default configuration for gitweb
GITWEB_CONFIG = gitweb_config.perl GITWEB_CONFIG = gitweb_config.perl
GITWEB_CONFIG_SYSTEM = /etc/gitweb.conf GITWEB_CONFIG_SYSTEM = /etc/gitweb.conf
@ -29,11 +29,7 @@ GITWEB_HOMETEXT = indextext.html
GITWEB_CSS = gitweb.css GITWEB_CSS = gitweb.css
GITWEB_LOGO = git-logo.png GITWEB_LOGO = git-logo.png
GITWEB_FAVICON = git-favicon.png GITWEB_FAVICON = git-favicon.png
ifdef JSMIN
GITWEB_JS = gitweb.min.js
else
GITWEB_JS = gitweb.js GITWEB_JS = gitweb.js
endif
GITWEB_SITE_HEADER = GITWEB_SITE_HEADER =
GITWEB_SITE_FOOTER = GITWEB_SITE_FOOTER =


@ -84,13 +80,16 @@ endif


all:: gitweb.cgi all:: gitweb.cgi


FILES = gitweb.cgi
ifdef JSMIN ifdef JSMIN
FILES=gitweb.cgi gitweb.min.js FILES += gitweb.min.js
gitweb.cgi: gitweb.perl gitweb.min.js GITWEB_JS = gitweb.min.js
else # !JSMIN endif
FILES=gitweb.cgi ifdef CSSMIN
gitweb.cgi: gitweb.perl FILES += gitweb.min.css
endif # JSMIN GITWEB_CSS = gitweb.min.css
endif
gitweb.cgi: gitweb.perl $(GITWEB_JS) $(GITWEB_CSS)


gitweb.cgi: gitweb.cgi:
$(QUIET_GEN)$(RM) $@ $@+ && \ $(QUIET_GEN)$(RM) $@ $@+ && \
@ -123,6 +122,11 @@ gitweb.min.js: gitweb.js
$(QUIET_GEN)$(JSMIN) <$< >$@ $(QUIET_GEN)$(JSMIN) <$< >$@
endif # JSMIN endif # JSMIN


ifdef CSSMIN
gitweb.min.css: gitweb.css
$(QUIET_GEN)$(CSSMIN) <$ >$@
endif

clean: clean:
$(RM) $(FILES) $(RM) $(FILES)



3
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 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 (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 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 * GITWEB_LOGO
Points to the location where you put git-logo.png on your web server 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 (or to be more generic URI of logo, 72x27 size, displayed in top right

Loading…
Cancel
Save