Skip to content

Commit 18d0532

Browse files
pksunkaragitster
authored andcommitted
gitweb: Move static files into seperate subdirectory
Create a new subdirectory called 'static' in gitweb/, and move all static files required by gitweb.cgi when running, which means styles, images and Javascript code. This should make gitweb more readable and easier to maintain. Update t/gitweb-lib.sh to reflect this change.The install-gitweb now also include moving of static files into 'static' subdirectory in target directory: update Makefile, gitweb's INSTALL, README and Makefile accordingly. Signed-off-by: Pavan Kumar Sunkara <pavan.sss1991@gmail.com> Mentored-by: Christian Couder <chriscool@tuxfamily.org> Mentored-by: Petr Baudis <pasky@ucw.cz> Acked-by: Jakub Narebski <jnareb@gmail.com> Acked-by: Petr Baudis <pasky@suse.cz> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent d0b16c8 commit 18d0532

File tree

9 files changed

+50
-47
lines changed

9 files changed

+50
-47
lines changed

Makefile

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1578,32 +1578,32 @@ gitweb:
15781578
$(QUIET_SUBDIR0)gitweb $(QUIET_SUBDIR1) all
15791579

15801580
ifdef JSMIN
1581-
GITWEB_PROGRAMS += gitweb/gitweb.min.js
1582-
GITWEB_JS = gitweb/gitweb.min.js
1581+
GITWEB_PROGRAMS += gitweb/static/gitweb.min.js
1582+
GITWEB_JS = gitweb/static/gitweb.min.js
15831583
else
1584-
GITWEB_JS = gitweb/gitweb.js
1584+
GITWEB_JS = gitweb/static/gitweb.js
15851585
endif
15861586
ifdef CSSMIN
1587-
GITWEB_PROGRAMS += gitweb/gitweb.min.css
1588-
GITWEB_CSS = gitweb/gitweb.min.css
1587+
GITWEB_PROGRAMS += gitweb/static/gitweb.min.css
1588+
GITWEB_CSS = gitweb/static/gitweb.min.css
15891589
else
1590-
GITWEB_CSS = gitweb/gitweb.css
1590+
GITWEB_CSS = gitweb/static/gitweb.css
15911591
endif
15921592
OTHER_PROGRAMS += gitweb/gitweb.cgi $(GITWEB_PROGRAMS)
15931593
gitweb/gitweb.cgi: gitweb/gitweb.perl $(GITWEB_PROGRAMS)
15941594
$(QUIET_SUBDIR0)gitweb $(QUIET_SUBDIR1) $(patsubst gitweb/%,%,$@)
15951595

15961596
ifdef JSMIN
1597-
gitweb/gitweb.min.js: gitweb/gitweb.js
1597+
gitweb/static/gitweb.min.js: gitweb/static/gitweb.js
15981598
$(QUIET_SUBDIR0)gitweb $(QUIET_SUBDIR1) $(patsubst gitweb/%,%,$@)
15991599
endif # JSMIN
16001600
ifdef CSSMIN
1601-
gitweb/gitweb.min.css: gitweb/gitweb.css
1601+
gitweb/static/gitweb.min.css: gitweb/static/gitweb.css
16021602
$(QUIET_SUBDIR0)gitweb $(QUIET_SUBDIR1) $(patsubst gitweb/%,%,$@)
16031603
endif # CSSMIN
16041604

16051605

1606-
git-instaweb: git-instaweb.sh gitweb/gitweb.cgi gitweb/gitweb.css gitweb/gitweb.js
1606+
git-instaweb: git-instaweb.sh gitweb/gitweb.cgi gitweb/static/gitweb.css gitweb/static/gitweb.js
16071607
$(QUIET_GEN)$(RM) $@ $@+ && \
16081608
sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
16091609
-e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \

gitweb/INSTALL

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

44
First you have to generate gitweb.cgi from gitweb.perl using
5-
"make gitweb", then copy appropriate files (gitweb.cgi, gitweb.js,
6-
gitweb.css, git-logo.png and git-favicon.png) to their destination.
7-
For example if git was (or is) installed with /usr prefix, you can do
5+
"make gitweb", then "make install-gitweb" appropriate files
6+
(gitweb.cgi, gitweb.js, gitweb.css, git-logo.png and git-favicon.png)
7+
to their destination. For example if git was (or is) installed with
8+
/usr prefix and gitwebdir is /var/www/cgi-bin, you can do
89

910
$ make prefix=/usr gitweb ;# as yourself
1011
# make gitwebdir=/var/www/cgi-bin install-gitweb ;# as root
@@ -81,16 +82,14 @@ Build example
8182
minifiers, you can do
8283

8384
make GITWEB_PROJECTROOT="/home/local/scm" \
84-
GITWEB_JS="/gitweb/gitweb.js" \
85-
GITWEB_CSS="/gitweb/gitweb.css" \
86-
GITWEB_LOGO="/gitweb/git-logo.png" \
87-
GITWEB_FAVICON="/gitweb/git-favicon.png" \
85+
GITWEB_JS="gitweb/static/gitweb.js" \
86+
GITWEB_CSS="gitweb/static/gitweb.css" \
87+
GITWEB_LOGO="gitweb/static/git-logo.png" \
88+
GITWEB_FAVICON="gitweb/static/git-favicon.png" \
8889
bindir=/usr/local/bin \
8990
gitweb
9091

91-
cp -fv gitweb/gitweb.{cgi,js,css} \
92-
gitweb/git-{favicon,logo}.png \
93-
/var/www/cgi-bin/gitweb/
92+
make gitwebdir=/var/www/cgi-bin/gitweb install-gitweb
9493

9594

9695
Gitweb config file

gitweb/Makefile

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ all::
44
# Define V=1 to have a more verbose compile.
55
#
66
# Define JSMIN to point to JavaScript minifier that functions as
7-
# a filter to have gitweb.js minified.
7+
# a filter to have static/gitweb.js minified.
88
#
99
# Define CSSMIN to point to a CSS minifier in order to generate a minified
10-
# version of gitweb.css
10+
# version of static/gitweb.css
1111
#
1212

1313
prefix ?= $(HOME)
@@ -29,10 +29,10 @@ GITWEB_STRICT_EXPORT =
2929
GITWEB_BASE_URL =
3030
GITWEB_LIST =
3131
GITWEB_HOMETEXT = indextext.html
32-
GITWEB_CSS = gitweb.css
33-
GITWEB_LOGO = git-logo.png
34-
GITWEB_FAVICON = git-favicon.png
35-
GITWEB_JS = gitweb.js
32+
GITWEB_CSS = static/gitweb.css
33+
GITWEB_LOGO = static/git-logo.png
34+
GITWEB_FAVICON = static/git-favicon.png
35+
GITWEB_JS = static/gitweb.js
3636
GITWEB_SITE_HEADER =
3737
GITWEB_SITE_FOOTER =
3838

@@ -54,6 +54,7 @@ PERL_PATH ?= /usr/bin/perl
5454
# Shell quote;
5555
bindir_SQ = $(subst ','\'',$(bindir))#'
5656
gitwebdir_SQ = $(subst ','\'',$(gitwebdir))#'
57+
gitwebstaticdir_SQ = $(subst ','\'',$(gitwebdir)/static)#'
5758
SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))#'
5859
PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))#'
5960
DESTDIR_SQ = $(subst ','\'',$(DESTDIR))#'
@@ -88,26 +89,26 @@ all:: gitweb.cgi
8889
GITWEB_PROGRAMS = gitweb.cgi
8990

9091
ifdef JSMIN
91-
GITWEB_FILES += gitweb.min.js
92-
GITWEB_JS = gitweb.min.js
93-
all:: gitweb.min.js
94-
gitweb.min.js: gitweb.js GITWEB-BUILD-OPTIONS
92+
GITWEB_FILES += static/gitweb.min.js
93+
GITWEB_JS = static/gitweb.min.js
94+
all:: static/gitweb.min.js
95+
static/gitweb.min.js: static/gitweb.js GITWEB-BUILD-OPTIONS
9596
$(QUIET_GEN)$(JSMIN) <$< >$@
9697
else
97-
GITWEB_FILES += gitweb.js
98+
GITWEB_FILES += static/gitweb.js
9899
endif
99100

100101
ifdef CSSMIN
101-
GITWEB_FILES += gitweb.min.css
102-
GITWEB_CSS = gitweb.min.css
103-
all:: gitweb.min.css
104-
gitweb.min.css: gitweb.css GITWEB-BUILD-OPTIONS
102+
GITWEB_FILES += static/gitweb.min.css
103+
GITWEB_CSS = static/gitweb.min.css
104+
all:: static/gitweb.min.css
105+
static/gitweb.min.css: static/gitweb.css GITWEB-BUILD-OPTIONS
105106
$(QUIET_GEN)$(CSSMIN) <$ >$@
106107
else
107-
GITWEB_FILES += gitweb.css
108+
GITWEB_FILES += static/gitweb.css
108109
endif
109110

110-
GITWEB_FILES += git-logo.png git-favicon.png
111+
GITWEB_FILES += static/git-logo.png static/git-favicon.png
111112

112113
GITWEB_REPLACE = \
113114
-e 's|++GIT_VERSION++|$(GIT_VERSION)|g' \
@@ -147,12 +148,13 @@ gitweb.cgi: gitweb.perl GITWEB-BUILD-OPTIONS
147148
install: all
148149
$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitwebdir_SQ)'
149150
$(INSTALL) -m 755 $(GITWEB_PROGRAMS) '$(DESTDIR_SQ)$(gitwebdir_SQ)'
150-
$(INSTALL) -m 644 $(GITWEB_FILES) '$(DESTDIR_SQ)$(gitwebdir_SQ)'
151+
$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitwebstaticdir_SQ)'
152+
$(INSTALL) -m 644 $(GITWEB_FILES) '$(DESTDIR_SQ)$(gitwebstaticdir_SQ)'
151153

152154
### Cleaning rules
153155

154156
clean:
155-
$(RM) gitweb.cgi gitweb.min.js gitweb.min.css GITWEB-BUILD-OPTIONS
157+
$(RM) gitweb.cgi static/gitweb.min.js static/gitweb.min.css GITWEB-BUILD-OPTIONS
156158

157159
.PHONY: all clean install .FORCE-GIT-VERSION-FILE FORCE
158160

gitweb/README

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,24 +80,26 @@ 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 (or gitweb.min.css if the
84-
CSSMIN variable is defined / CSS minifier is used)]
83+
the gitweb config file. [Default: static/gitweb.css (or
84+
static/gitweb.min.css if the CSSMIN variable is defined / CSS minifier
85+
is used)]
8586
* GITWEB_LOGO
8687
Points to the location where you put git-logo.png on your web server
8788
(or to be more generic URI of logo, 72x27 size, displayed in top right
8889
corner of each gitweb page, and used as logo for Atom feed). Relative
89-
to base URI of gitweb. [Default: git-logo.png]
90+
to base URI of gitweb. [Default: static/git-logo.png]
9091
* GITWEB_FAVICON
9192
Points to the location where you put git-favicon.png on your web server
9293
(or to be more generic URI of favicon, assumed to be image/png type;
9394
web browsers that support favicons (website icons) may display them
9495
in the browser's URL bar and next to site name in bookmarks). Relative
95-
to base URI of gitweb. [Default: git-favicon.png]
96+
to base URI of gitweb. [Default: static/git-favicon.png]
9697
* GITWEB_JS
9798
Points to the localtion where you put gitweb.js on your web server
9899
(or to be more generic URI of JavaScript code used by gitweb).
99-
Relative to base URI of gitweb. [Default: gitweb.js (or gitweb.min.js
100-
if JSMIN build variable is defined / JavaScript minifier is used)]
100+
Relative to base URI of gitweb. [Default: static/gitweb.js (or
101+
static/gitweb.min.js if JSMIN build variable is defined / JavaScript
102+
minifier is used)]
101103
* GITWEB_CONFIG
102104
This Perl file will be loaded using 'do' and can be used to override any
103105
of the options above as well as some other options -- see the "Runtime

t/gitweb-lib.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ our \$site_name = '[localhost]';
1919
our \$site_header = '';
2020
our \$site_footer = '';
2121
our \$home_text = 'indextext.html';
22-
our @stylesheets = ('file:///$TEST_DIRECTORY/../gitweb/gitweb.css');
23-
our \$logo = 'file:///$TEST_DIRECTORY/../gitweb/git-logo.png';
24-
our \$favicon = 'file:///$TEST_DIRECTORY/../gitweb/git-favicon.png';
22+
our @stylesheets = ('file:///$TEST_DIRECTORY/../gitweb/static/gitweb.css');
23+
our \$logo = 'file:///$TEST_DIRECTORY/../gitweb/static/git-logo.png';
24+
our \$favicon = 'file:///$TEST_DIRECTORY/../gitweb/static/git-favicon.png';
2525
our \$projects_list = '';
2626
our \$export_ok = '';
2727
our \$strict_export = '';

0 commit comments

Comments
 (0)