Skip to content

Commit 0e6ce21

Browse files
ferrous26gitster
authored andcommitted
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 <marada@uwaterloo.ca> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 8830bf4 commit 0e6ce21

File tree

4 files changed

+43
-14
lines changed

4 files changed

+43
-14
lines changed

Makefile

Lines changed: 15 additions & 6 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,8 +282,9 @@ lib = lib
279282
# DESTDIR=
280283
pathsep = :
281284

282-
# JavaScript minifier invocation that can function as filter
285+
# JavaScript/CSS minifier invocation that can function as filter
283286
JSMIN =
287+
CSSMIN =
284288

285289
export prefix bindir sharedir sysconfdir
286290

@@ -1560,18 +1564,23 @@ gitweb:
15601564
$(QUIET_SUBDIR0)gitweb $(QUIET_SUBDIR1) all
15611565

15621566
ifdef JSMIN
1563-
OTHER_PROGRAMS += gitweb/gitweb.cgi gitweb/gitweb.min.js
1564-
gitweb/gitweb.cgi: gitweb/gitweb.perl gitweb/gitweb.min.js
1565-
else
1566-
OTHER_PROGRAMS += gitweb/gitweb.cgi
1567-
gitweb/gitweb.cgi: gitweb/gitweb.perl
1567+
GITWEB_PROGRAMS += gitweb/gitweb.min.js
15681568
endif
1569+
ifdef CSSMIN
1570+
GITWEB_PROGRAMS += gitweb/gitweb.min.css
1571+
endif
1572+
OTHER_PROGRAMS += gitweb/gitweb.cgi $(GITWEB_PROGRAMS)
1573+
gitweb/gitweb.cgi: gitweb/gitweb.perl $(GITWEB_PROGRAMS)
15691574
$(QUIET_SUBDIR0)gitweb $(QUIET_SUBDIR1) $(patsubst gitweb/%,%,$@)
15701575

15711576
ifdef JSMIN
15721577
gitweb/gitweb.min.js: gitweb/gitweb.js
15731578
$(QUIET_SUBDIR0)gitweb $(QUIET_SUBDIR1) $(patsubst gitweb/%,%,$@)
15741579
endif # JSMIN
1580+
ifdef CSSMIN
1581+
gitweb/gitweb.min.css: gitweb/gitweb.css
1582+
$(QUIET_SUBDIR0)gitweb $(QUIET_SUBDIR1) $(patsubst gitweb/%,%,$@)
1583+
endif # CSSMIN
15751584

15761585

15771586
git-instaweb: git-instaweb.sh gitweb/gitweb.cgi gitweb/gitweb.css gitweb/gitweb.js

gitweb/INSTALL

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@ file for gitweb (in gitweb/README).
6666
build configuration variables. By default gitweb tries to find them
6767
in the same directory as gitweb.cgi script.
6868

69+
- You can optionally generate a minified version of gitweb.css by defining
70+
the CSSMIN build configuration variable. By default the non-minified
71+
version of gitweb.css will be used. NOTE: if you enable this option,
72+
substitute gitweb.min.css for all uses of gitweb.css in the help files.
73+
6974
Build example
7075
~~~~~~~~~~~~~
7176

gitweb/Makefile

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,17 @@ 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
17+
# JavaScript/CSS minifier invocation that can function as filter
1518
JSMIN ?=
19+
CSSMIN ?=
1620

1721
# default configuration for gitweb
1822
GITWEB_CONFIG = gitweb_config.perl
@@ -26,7 +30,11 @@ GITWEB_STRICT_EXPORT =
2630
GITWEB_BASE_URL =
2731
GITWEB_LIST =
2832
GITWEB_HOMETEXT = indextext.html
33+
ifdef CSSMIN
34+
GITWEB_CSS = gitweb.min.css
35+
else
2936
GITWEB_CSS = gitweb.css
37+
endif
3038
GITWEB_LOGO = git-logo.png
3139
GITWEB_FAVICON = git-favicon.png
3240
ifdef JSMIN
@@ -84,13 +92,14 @@ endif
8492

8593
all:: gitweb.cgi
8694

95+
FILES = gitweb.cgi
8796
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
97+
FILES += gitweb.min.js
98+
endif
99+
ifdef CSSMIN
100+
FILES += gitweb.min.css
101+
endif
102+
gitweb.cgi: gitweb.perl $(GITWEB_JS) $(GITWEB_CSS)
94103

95104
gitweb.cgi:
96105
$(QUIET_GEN)$(RM) $@ $@+ && \
@@ -123,6 +132,11 @@ gitweb.min.js: gitweb.js
123132
$(QUIET_GEN)$(JSMIN) <$< >$@
124133
endif # JSMIN
125134

135+
ifdef CSSMIN
136+
gitweb.min.css: gitweb.css
137+
$(QUIET_GEN)$(CSSMIN) <$ >$@
138+
endif
139+
126140
clean:
127141
$(RM) $(FILES)
128142

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)