Skip to content

Commit b92cbb6

Browse files
committed
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
2 parents 055e1e2 + e391859 commit b92cbb6

File tree

7 files changed

+83
-36
lines changed

7 files changed

+83
-36
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@
156156
/git-core-*/?*
157157
/gitk-git/gitk-wish
158158
/gitweb/gitweb.cgi
159+
/gitweb/gitweb.min.*
159160
/test-chmtime
160161
/test-ctype
161162
/test-date

Makefile

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,9 @@ all::
203203
# Define JSMIN to point to JavaScript minifier that functions as
204204
# a filter to have gitweb.js minified.
205205
#
206+
# Define CSSMIN to point to a CSS minifier in order to generate a minified
207+
# version of gitweb.css
208+
#
206209
# Define DEFAULT_PAGER to a sensible pager command (defaults to "less") if
207210
# you want to use something different. The value will be interpreted by the
208211
# shell at runtime when it is used.
@@ -279,9 +282,6 @@ lib = lib
279282
# DESTDIR=
280283
pathsep = :
281284

282-
# JavaScript minifier invocation that can function as filter
283-
JSMIN =
284-
285285
export prefix bindir sharedir sysconfdir
286286

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

15631563
ifdef JSMIN
1564-
OTHER_PROGRAMS += gitweb/gitweb.cgi gitweb/gitweb.min.js
1565-
gitweb/gitweb.cgi: gitweb/gitweb.perl gitweb/gitweb.min.js
1564+
GITWEB_PROGRAMS += gitweb/gitweb.min.js
1565+
GITWEB_JS = gitweb/gitweb.min.js
15661566
else
1567-
OTHER_PROGRAMS += gitweb/gitweb.cgi
1568-
gitweb/gitweb.cgi: gitweb/gitweb.perl
1567+
GITWEB_JS = gitweb/gitweb.js
15691568
endif
1569+
ifdef CSSMIN
1570+
GITWEB_PROGRAMS += gitweb/gitweb.min.css
1571+
GITWEB_CSS = gitweb/gitweb.min.css
1572+
else
1573+
GITWEB_CSS = gitweb/gitweb.css
1574+
endif
1575+
OTHER_PROGRAMS += gitweb/gitweb.cgi $(GITWEB_PROGRAMS)
1576+
gitweb/gitweb.cgi: gitweb/gitweb.perl $(GITWEB_PROGRAMS)
15701577
$(QUIET_SUBDIR0)gitweb $(QUIET_SUBDIR1) $(patsubst gitweb/%,%,$@)
15711578

15721579
ifdef JSMIN
15731580
gitweb/gitweb.min.js: gitweb/gitweb.js
15741581
$(QUIET_SUBDIR0)gitweb $(QUIET_SUBDIR1) $(patsubst gitweb/%,%,$@)
15751582
endif # JSMIN
1583+
ifdef CSSMIN
1584+
gitweb/gitweb.min.css: gitweb/gitweb.css
1585+
$(QUIET_SUBDIR0)gitweb $(QUIET_SUBDIR1) $(patsubst gitweb/%,%,$@)
1586+
endif # CSSMIN
15761587

15771588

15781589
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.
15821593
-e 's/@@NO_CURL@@/$(NO_CURL)/g' \
15831594
-e '/@@GITWEB_CGI@@/r gitweb/gitweb.cgi' \
15841595
-e '/@@GITWEB_CGI@@/d' \
1585-
-e '/@@GITWEB_CSS@@/r gitweb/gitweb.css' \
1596+
-e '/@@GITWEB_CSS@@/r $(GITWEB_CSS)' \
15861597
-e '/@@GITWEB_CSS@@/d' \
1587-
-e '/@@GITWEB_JS@@/r gitweb/gitweb.js' \
1598+
-e '/@@GITWEB_JS@@/r $(GITWEB_JS)' \
15881599
-e '/@@GITWEB_JS@@/d' \
15891600
-e 's|@@PERL@@|$(PERL_PATH_SQ)|g' \
1601+
-e 's|@@GITWEB_CSS_NAME@@|$(GITWEB_CSS)|' \
1602+
-e 's|@@GITWEB_JS_NAME@@|$(GITWEB_JS)|' \
15901603
[email protected] > $@+ && \
15911604
chmod +x $@+ && \
15921605
mv $@+ $@
@@ -2085,7 +2098,7 @@ clean:
20852098
$(RM) $(htmldocs).tar.gz $(manpages).tar.gz
20862099
$(MAKE) -C Documentation/ clean
20872100
ifndef NO_PERL
2088-
$(RM) gitweb/gitweb.cgi
2101+
$(RM) gitweb/gitweb.cgi gitweb/gitweb.min.*
20892102
$(MAKE) -C perl clean
20902103
endif
20912104
ifndef NO_PYTHON

configure.ac

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,26 @@ fi],
179179
AC_MSG_NOTICE([Will try -pthread then -lpthread to enable POSIX Threads.])
180180
])
181181

182+
# Define option to enable JavaScript minification
183+
AC_ARG_ENABLE([jsmin],
184+
[AS_HELP_STRING([--enable-jsmin=PATH],
185+
[PATH is the name of a JavaScript minifier or the absolute path to one.])],
186+
[
187+
JSMIN=$enableval;
188+
AC_MSG_NOTICE([Setting JSMIN to '$JSMIN' to enable JavaScript minifying])
189+
GIT_CONF_APPEND_LINE(JSMIN=$enableval);
190+
])
191+
192+
# Define option to enable CSS minification
193+
AC_ARG_ENABLE([cssmin],
194+
[AS_HELP_STRING([--enable-cssmin=PATH],
195+
[PATH is the name of a CSS minifier or the absolute path to one.])],
196+
[
197+
CSSMIN=$enableval;
198+
AC_MSG_NOTICE([Setting CSSMIN to '$CSSMIN' to enable CSS minifying])
199+
GIT_CONF_APPEND_LINE(CSSMIN=$enableval);
200+
])
201+
182202
## Site configuration (override autodetection)
183203
## --with-PACKAGE[=ARG] and --without-PACKAGE
184204
AC_MSG_NOTICE([CHECKS for site configuration])

git-instaweb.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,18 +391,20 @@ EOFGITWEB
391391
gitweb_css () {
392392
cat > "$1" <<\EOFGITWEB
393393
@@GITWEB_CSS@@
394+
394395
EOFGITWEB
395396
}
396397

397398
gitweb_js () {
398399
cat > "$1" <<\EOFGITWEB
399400
@@GITWEB_JS@@
401+
400402
EOFGITWEB
401403
}
402404

403405
gitweb_cgi "$GIT_DIR/gitweb/gitweb.cgi"
404-
gitweb_css "$GIT_DIR/gitweb/gitweb.css"
405-
gitweb_js "$GIT_DIR/gitweb/gitweb.js"
406+
gitweb_css "$GIT_DIR/@@GITWEB_CSS_NAME@@"
407+
gitweb_js "$GIT_DIR/@@GITWEB_JS_NAME@@"
406408

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

gitweb/INSTALL

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ GIT web Interface (gitweb) Installation
22
=======================================
33

44
First you have to generate gitweb.cgi from gitweb.perl using
5-
"make gitweb/gitweb.cgi", then copy appropriate files (gitweb.cgi,
5+
"make gitweb", then copy appropriate files (gitweb.cgi, gitweb.js,
66
gitweb.css, git-logo.png and git-favicon.png) to their destination.
77
For example if git was (or is) installed with /usr prefix, you can do
88

9-
$ make prefix=/usr gitweb/gitweb.cgi ;# as yourself
9+
$ make prefix=/usr gitweb ;# as yourself
1010
# cp gitweb/git* /var/www/cgi-bin/ ;# as root
1111

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

1616
$ make configure ;# as yourself
1717
$ ./configure --prefix=/usr ;# as yourself
18-
$ make gitweb/gitweb.cgi ;# as yourself
18+
$ make gitweb ;# as yourself
1919
# cp gitweb/git* /var/www/cgi-bin/ ;# as root
2020

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

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

3736
One of the most important is where to find the git wrapper binary. Gitweb
3837
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).
6261
a suggestion).
6362

6463
- You can control where gitweb tries to find its main CSS style file,
65-
its favicon and logo with the GITWEB_CSS, GITWEB_FAVICON and GITWEB_LOGO
66-
build configuration variables. By default gitweb tries to find them
67-
in the same directory as gitweb.cgi script.
64+
its JavaScript file, its favicon and logo with the GITWEB_CSS, GITWEB_JS
65+
GITWEB_FAVICON and GITWEB_LOGO build configuration variables. By default
66+
gitweb tries to find them in the same directory as gitweb.cgi script.
67+
68+
- You can optionally generate minified versions of gitweb.js and gitweb.css
69+
by defining the JSMIN and CSSMIN build configuration variables. By default
70+
the non-minified versions will be used. NOTE: if you enable this option,
71+
substitute gitweb.min.js and gitweb.min.css for all uses of gitweb.js and
72+
gitweb.css in the help files.
6873

6974
Build example
7075
~~~~~~~~~~~~~
@@ -74,13 +79,14 @@ Build example
7479
we want to display are under /home/local/scm, you can do
7580

7681
make GITWEB_PROJECTROOT="/home/local/scm" \
82+
GITWEB_JS="/gitweb/gitweb.js" \
7783
GITWEB_CSS="/gitweb/gitweb.css" \
7884
GITWEB_LOGO="/gitweb/git-logo.png" \
7985
GITWEB_FAVICON="/gitweb/git-favicon.png" \
8086
bindir=/usr/local/bin \
81-
gitweb/gitweb.cgi
87+
gitweb
8288

83-
cp -fv ~/git/gitweb/gitweb.{cgi,css} \
89+
cp -fv ~/git/gitweb/gitweb.{cgi,js,css} \
8490
~/git/gitweb/git-{favicon,logo}.png \
8591
/var/www/cgi-bin/gitweb/
8692

gitweb/Makefile

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ all::
66
# Define JSMIN to point to JavaScript minifier that functions as
77
# a filter to have gitweb.js minified.
88
#
9+
# Define CSSMIN to point to a CSS minifier in order to generate a minified
10+
# version of gitweb.css
11+
#
912

1013
prefix ?= $(HOME)
1114
bindir ?= $(prefix)/bin
1215
RM ?= rm -f
1316

14-
# JavaScript minifier invocation that can function as filter
15-
JSMIN ?=
16-
1717
# default configuration for gitweb
1818
GITWEB_CONFIG = gitweb_config.perl
1919
GITWEB_CONFIG_SYSTEM = /etc/gitweb.conf
@@ -29,11 +29,7 @@ GITWEB_HOMETEXT = indextext.html
2929
GITWEB_CSS = gitweb.css
3030
GITWEB_LOGO = git-logo.png
3131
GITWEB_FAVICON = git-favicon.png
32-
ifdef JSMIN
33-
GITWEB_JS = gitweb.min.js
34-
else
3532
GITWEB_JS = gitweb.js
36-
endif
3733
GITWEB_SITE_HEADER =
3834
GITWEB_SITE_FOOTER =
3935

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

8581
all:: gitweb.cgi
8682

83+
FILES = gitweb.cgi
8784
ifdef JSMIN
88-
FILES=gitweb.cgi gitweb.min.js
89-
gitweb.cgi: gitweb.perl gitweb.min.js
90-
else # !JSMIN
91-
FILES=gitweb.cgi
92-
gitweb.cgi: gitweb.perl
93-
endif # JSMIN
85+
FILES += gitweb.min.js
86+
GITWEB_JS = gitweb.min.js
87+
endif
88+
ifdef CSSMIN
89+
FILES += gitweb.min.css
90+
GITWEB_CSS = gitweb.min.css
91+
endif
92+
gitweb.cgi: gitweb.perl $(GITWEB_JS) $(GITWEB_CSS)
9493

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

125+
ifdef CSSMIN
126+
gitweb.min.css: gitweb.css
127+
$(QUIET_GEN)$(CSSMIN) <$ >$@
128+
endif
129+
126130
clean:
127131
$(RM) $(FILES)
128132

gitweb/README

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ You can specify the following configuration variables when building GIT:
8080
Points to the location where you put gitweb.css on your web server
8181
(or to be more generic, the URI of gitweb stylesheet). Relative to the
8282
base URI of gitweb. Note that you can setup multiple stylesheets from
83-
the gitweb config file. [Default: gitweb.css]
83+
the gitweb config file. [Default: gitweb.css (or gitweb.min.css if the
84+
CSSMIN variable is defined / CSS minifier is used)]
8485
* GITWEB_LOGO
8586
Points to the location where you put git-logo.png on your web server
8687
(or to be more generic URI of logo, 72x27 size, displayed in top right

0 commit comments

Comments
 (0)