]> Lady’s Gitweb - Gitweb/commitdiff
Gitweb: add support for minifying gitweb.css
authorMark Rada <redacted>
Sat, 3 Apr 2010 00:35:05 +0000 (20:35 -0400)
committerLady <redacted>
Mon, 6 Apr 2026 04:50:39 +0000 (00:50 -0400)
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 <redacted>
Signed-off-by: Junio C Hamano <redacted>
INSTALL
Makefile
README

diff --git a/INSTALL b/INSTALL
index 813cd4d3270ec05f30efc0ba7048c862b85b95b2c36bfc2ba355352533d1dc8d..b5e70aa37791088fe681dea900932a8e5bed9a5a932f1767db99db8335dde0d9 100644 (file)
--- a/INSTALL
+++ b/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
 ~~~~~~~~~~~~~
 
index d0a0e60ae00fe108393523715ebaaf6a157130f956fcd0227d316599949e274f..444895a2f26f8bc630b7695e029c53adaef53f5dedd3187a393798dd764dff5a 100644 (file)
--- a/Makefile
+++ b/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/README b/README
index 7d7b568730ca4b6f106a20895db745962ff8b9fb99ae780704f639c587d40b08..db5101ce43bf39136800645f80899f4df963abccd57f9473a8fc81d2a28bf895 100644 (file)
--- a/README
+++ b/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
This page took 0.199035 seconds and 4 git commands to generate.