diff options
-rw-r--r-- | .gitignore | 5 | ||||
-rw-r--r-- | Makefile | 21 | ||||
-rw-r--r-- | cgit-doc.css | 3 | ||||
-rw-r--r-- | cgit.c | 8 | ||||
-rw-r--r-- | cgit.h | 4 | ||||
-rw-r--r-- | cgitrc.5.txt | 122 | ||||
-rw-r--r-- | ui-atom.c | 6 | ||||
-rw-r--r-- | ui-blob.c | 8 | ||||
-rw-r--r-- | ui-plain.c | 6 | ||||
-rw-r--r-- | ui-shared.c | 26 | ||||
-rw-r--r-- | ui-shared.h | 1 | ||||
-rw-r--r-- | ui-snapshot.c | 23 | ||||
-rw-r--r-- | ui-tree.c | 26 |
13 files changed, 177 insertions, 82 deletions
@@ -2,5 +2,10 @@ | |||
2 | cgit | 2 | cgit |
3 | cgit.conf | 3 | cgit.conf |
4 | VERSION | 4 | VERSION |
5 | cgitrc.5 | ||
6 | cgitrc.5.fo | ||
7 | cgitrc.5.html | ||
8 | cgitrc.5.pdf | ||
9 | cgitrc.5.xml | ||
5 | *.o | 10 | *.o |
6 | *.d | 11 | *.d |
@@ -1,4 +1,4 @@ | |||
1 | CGIT_VERSION = v0.8.2 | 1 | CGIT_VERSION = v0.8.2.1 |
2 | CGIT_SCRIPT_NAME = cgit.cgi | 2 | CGIT_SCRIPT_NAME = cgit.cgi |
3 | CGIT_SCRIPT_PATH = /var/www/htdocs/cgit | 3 | CGIT_SCRIPT_PATH = /var/www/htdocs/cgit |
4 | CGIT_DATA_PATH = $(CGIT_SCRIPT_PATH) | 4 | CGIT_DATA_PATH = $(CGIT_SCRIPT_PATH) |
@@ -100,7 +100,8 @@ ifdef NEEDS_LIBICONV | |||
100 | endif | 100 | endif |
101 | 101 | ||
102 | 102 | ||
103 | .PHONY: all libgit test install uninstall clean force-version get-git | 103 | .PHONY: all libgit test install uninstall clean force-version get-git \ |
104 | doc man-doc html-doc clean-doc | ||
104 | 105 | ||
105 | all: cgit | 106 | all: cgit |
106 | 107 | ||
@@ -149,8 +150,22 @@ uninstall: | |||
149 | rm -f $(CGIT_DATA_PATH)/cgit.css | 150 | rm -f $(CGIT_DATA_PATH)/cgit.css |
150 | rm -f $(CGIT_DATA_PATH)/cgit.png | 151 | rm -f $(CGIT_DATA_PATH)/cgit.png |
151 | 152 | ||
152 | clean: | 153 | doc: man-doc html-doc pdf-doc |
154 | |||
155 | man-doc: cgitrc.5.txt | ||
156 | a2x -f manpage cgitrc.5.txt | ||
157 | |||
158 | html-doc: cgitrc.5.txt | ||
159 | a2x -f xhtml --stylesheet=cgit-doc.css cgitrc.5.txt | ||
160 | |||
161 | pdf-doc: cgitrc.5.txt | ||
162 | a2x -f pdf cgitrc.5.txt | ||
163 | |||
164 | clean: clean-doc | ||
153 | rm -f cgit VERSION *.o *.d | 165 | rm -f cgit VERSION *.o *.d |
154 | 166 | ||
167 | clean-doc: | ||
168 | rm -f cgitrc.5 cgitrc.5.html cgitrc.5.pdf cgitrc.5.xml cgitrc.5.fo | ||
169 | |||
155 | get-git: | 170 | get-git: |
156 | curl $(GIT_URL) | tar -xj && rm -rf git && mv git-$(GIT_VER) git | 171 | curl $(GIT_URL) | tar -xj && rm -rf git && mv git-$(GIT_VER) git |
diff --git a/cgit-doc.css b/cgit-doc.css new file mode 100644 index 0000000..5a399b6 --- /dev/null +++ b/cgit-doc.css | |||
@@ -0,0 +1,3 @@ | |||
1 | div.variablelist dt { | ||
2 | margin-top: 1em; | ||
3 | } | ||
@@ -31,6 +31,8 @@ void config_cb(const char *name, const char *value) | |||
31 | ctx.cfg.favicon = xstrdup(value); | 31 | ctx.cfg.favicon = xstrdup(value); |
32 | else if (!strcmp(name, "footer")) | 32 | else if (!strcmp(name, "footer")) |
33 | ctx.cfg.footer = xstrdup(value); | 33 | ctx.cfg.footer = xstrdup(value); |
34 | else if (!strcmp(name, "head-include")) | ||
35 | ctx.cfg.head_include = xstrdup(value); | ||
34 | else if (!strcmp(name, "header")) | 36 | else if (!strcmp(name, "header")) |
35 | ctx.cfg.header = xstrdup(value); | 37 | ctx.cfg.header = xstrdup(value); |
36 | else if (!strcmp(name, "logo")) | 38 | else if (!strcmp(name, "logo")) |
@@ -210,6 +212,7 @@ static void prepare_context(struct cgit_context *ctx) | |||
210 | ctx->page.size = 0; | 212 | ctx->page.size = 0; |
211 | ctx->page.modified = time(NULL); | 213 | ctx->page.modified = time(NULL); |
212 | ctx->page.expires = ctx->page.modified; | 214 | ctx->page.expires = ctx->page.modified; |
215 | ctx->page.etag = NULL; | ||
213 | } | 216 | } |
214 | 217 | ||
215 | struct refmatch { | 218 | struct refmatch { |
@@ -289,6 +292,8 @@ static int prepare_repo_cmd(struct cgit_context *ctx) | |||
289 | if (get_sha1(ctx->qry.head, sha1)) { | 292 | if (get_sha1(ctx->qry.head, sha1)) { |
290 | tmp = xstrdup(ctx->qry.head); | 293 | tmp = xstrdup(ctx->qry.head); |
291 | ctx->qry.head = ctx->repo->defbranch; | 294 | ctx->qry.head = ctx->repo->defbranch; |
295 | ctx->page.status = 404; | ||
296 | ctx->page.statusmsg = "not found"; | ||
292 | cgit_print_http_headers(ctx); | 297 | cgit_print_http_headers(ctx); |
293 | cgit_print_docstart(ctx); | 298 | cgit_print_docstart(ctx); |
294 | cgit_print_pageheader(ctx); | 299 | cgit_print_pageheader(ctx); |
@@ -433,6 +438,7 @@ static int calc_ttl() | |||
433 | int main(int argc, const char **argv) | 438 | int main(int argc, const char **argv) |
434 | { | 439 | { |
435 | const char *cgit_config_env = getenv("CGIT_CONFIG"); | 440 | const char *cgit_config_env = getenv("CGIT_CONFIG"); |
441 | const char *method = getenv("REQUEST_METHOD"); | ||
436 | const char *path; | 442 | const char *path; |
437 | char *qry; | 443 | char *qry; |
438 | int err, ttl; | 444 | int err, ttl; |
@@ -479,6 +485,8 @@ int main(int argc, const char **argv) | |||
479 | 485 | ||
480 | ttl = calc_ttl(); | 486 | ttl = calc_ttl(); |
481 | ctx.page.expires += ttl*60; | 487 | ctx.page.expires += ttl*60; |
488 | if (method && !strcmp(method, "HEAD")) | ||
489 | ctx.cfg.nocache = 1; | ||
482 | if (ctx.cfg.nocache) | 490 | if (ctx.cfg.nocache) |
483 | ctx.cfg.cache_size = 0; | 491 | ctx.cfg.cache_size = 0; |
484 | err = cache_process(ctx.cfg.cache_size, ctx.cfg.cache_root, | 492 | err = cache_process(ctx.cfg.cache_size, ctx.cfg.cache_root, |
@@ -136,6 +136,7 @@ struct cgit_config { | |||
136 | char *css; | 136 | char *css; |
137 | char *favicon; | 137 | char *favicon; |
138 | char *footer; | 138 | char *footer; |
139 | char *head_include; | ||
139 | char *header; | 140 | char *header; |
140 | char *index_header; | 141 | char *index_header; |
141 | char *index_info; | 142 | char *index_info; |
@@ -182,7 +183,10 @@ struct cgit_page { | |||
182 | char *mimetype; | 183 | char *mimetype; |
183 | char *charset; | 184 | char *charset; |
184 | char *filename; | 185 | char *filename; |
186 | char *etag; | ||
185 | char *title; | 187 | char *title; |
188 | int status; | ||
189 | char *statusmsg; | ||
186 | }; | 190 | }; |
187 | 191 | ||
188 | struct cgit_context { | 192 | struct cgit_context { |
diff --git a/cgitrc.5.txt b/cgitrc.5.txt index 771bb7d..a207fe0 100644 --- a/cgitrc.5.txt +++ b/cgitrc.5.txt | |||
@@ -1,14 +1,14 @@ | |||
1 | CGITRC | 1 | CGITRC(5) |
2 | ====== | 2 | ======== |
3 | 3 | ||
4 | 4 | ||
5 | NAME | 5 | NAME |
6 | ---- | 6 | ---- |
7 | cgitrc - runtime configuration for cgit | 7 | cgitrc - runtime configuration for cgit |
8 | 8 | ||
9 | 9 | ||
10 | DESCRIPTION | 10 | SYNOPSIS |
11 | ----------- | 11 | -------- |
12 | Cgitrc contains all runtime settings for cgit, including the list of git | 12 | Cgitrc contains all runtime settings for cgit, including the list of git |
13 | repositories, formatted as a line-separated list of NAME=VALUE pairs. Blank | 13 | repositories, formatted as a line-separated list of NAME=VALUE pairs. Blank |
14 | lines, and lines starting with '#', are ignored. | 14 | lines, and lines starting with '#', are ignored. |
@@ -16,175 +16,179 @@ lines, and lines starting with '#', are ignored. | |||
16 | 16 | ||
17 | GLOBAL SETTINGS | 17 | GLOBAL SETTINGS |
18 | --------------- | 18 | --------------- |
19 | agefile | 19 | agefile:: |
20 | Specifies a path, relative to each repository path, which can be used | 20 | Specifies a path, relative to each repository path, which can be used |
21 | to specify the date and time of the youngest commit in the repository. | 21 | to specify the date and time of the youngest commit in the repository. |
22 | The first line in the file is used as input to the "parse_date" | 22 | The first line in the file is used as input to the "parse_date" |
23 | function in libgit. Recommended timestamp-format is "yyyy-mm-dd | 23 | function in libgit. Recommended timestamp-format is "yyyy-mm-dd |
24 | hh:mm:ss". Default value: "info/web/last-modified". | 24 | hh:mm:ss". Default value: "info/web/last-modified". |
25 | 25 | ||
26 | cache-root | 26 | cache-root:: |
27 | Path used to store the cgit cache entries. Default value: | 27 | Path used to store the cgit cache entries. Default value: |
28 | "/var/cache/cgit". | 28 | "/var/cache/cgit". |
29 | 29 | ||
30 | cache-dynamic-ttl | 30 | cache-dynamic-ttl:: |
31 | Number which specifies the time-to-live, in minutes, for the cached | 31 | Number which specifies the time-to-live, in minutes, for the cached |
32 | version of repository pages accessed without a fixed SHA1. Default | 32 | version of repository pages accessed without a fixed SHA1. Default |
33 | value: "5". | 33 | value: "5". |
34 | 34 | ||
35 | cache-repo-ttl | 35 | cache-repo-ttl:: |
36 | Number which specifies the time-to-live, in minutes, for the cached | 36 | Number which specifies the time-to-live, in minutes, for the cached |
37 | version of the repository summary page. Default value: "5". | 37 | version of the repository summary page. Default value: "5". |
38 | 38 | ||
39 | cache-root-ttl | 39 | cache-root-ttl:: |
40 | Number which specifies the time-to-live, in minutes, for the cached | 40 | Number which specifies the time-to-live, in minutes, for the cached |
41 | version of the repository index page. Default value: "5". | 41 | version of the repository index page. Default value: "5". |
42 | 42 | ||
43 | cache-size | 43 | cache-size:: |
44 | The maximum number of entries in the cgit cache. Default value: "0" | 44 | The maximum number of entries in the cgit cache. Default value: "0" |
45 | (i.e. caching is disabled). | 45 | (i.e. caching is disabled). |
46 | 46 | ||
47 | cache-static-ttl | 47 | cache-static-ttl:: |
48 | Number which specifies the time-to-live, in minutes, for the cached | 48 | Number which specifies the time-to-live, in minutes, for the cached |
49 | version of repository pages accessed with a fixed SHA1. Default value: | 49 | version of repository pages accessed with a fixed SHA1. Default value: |
50 | "5". | 50 | "5". |
51 | 51 | ||
52 | clone-prefix | 52 | clone-prefix:: |
53 | Space-separated list of common prefixes which, when combined with a | 53 | Space-separated list of common prefixes which, when combined with a |
54 | repository url, generates valid clone urls for the repository. This | 54 | repository url, generates valid clone urls for the repository. This |
55 | setting is only used if `repo.clone-url` is unspecified. Default value: | 55 | setting is only used if `repo.clone-url` is unspecified. Default value: |
56 | none. | 56 | none. |
57 | 57 | ||
58 | css | 58 | css:: |
59 | Url which specifies the css document to include in all cgit pages. | 59 | Url which specifies the css document to include in all cgit pages. |
60 | Default value: "/cgit.css". | 60 | Default value: "/cgit.css". |
61 | 61 | ||
62 | embedded | 62 | embedded:: |
63 | Flag which, when set to "1", will make cgit generate a html fragment | 63 | Flag which, when set to "1", will make cgit generate a html fragment |
64 | suitable for embedding in other html pages. Default value: none. See | 64 | suitable for embedding in other html pages. Default value: none. See |
65 | also: "noheader". | 65 | also: "noheader". |
66 | 66 | ||
67 | enable-index-links | 67 | enable-index-links:: |
68 | Flag which, when set to "1", will make cgit generate extra links for | 68 | Flag which, when set to "1", will make cgit generate extra links for |
69 | each repo in the repository index (specifically, to the "summary", | 69 | each repo in the repository index (specifically, to the "summary", |
70 | "commit" and "tree" pages). Default value: "0". | 70 | "commit" and "tree" pages). Default value: "0". |
71 | 71 | ||
72 | enable-log-filecount | 72 | enable-log-filecount:: |
73 | Flag which, when set to "1", will make cgit print the number of | 73 | Flag which, when set to "1", will make cgit print the number of |
74 | modified files for each commit on the repository log page. Default | 74 | modified files for each commit on the repository log page. Default |
75 | value: "0". | 75 | value: "0". |
76 | 76 | ||
77 | enable-log-linecount | 77 | enable-log-linecount:: |
78 | Flag which, when set to "1", will make cgit print the number of added | 78 | Flag which, when set to "1", will make cgit print the number of added |
79 | and removed lines for each commit on the repository log page. Default | 79 | and removed lines for each commit on the repository log page. Default |
80 | value: "0". | 80 | value: "0". |
81 | 81 | ||
82 | favicon | 82 | favicon:: |
83 | Url used as link to a shortcut icon for cgit. If specified, it is | 83 | Url used as link to a shortcut icon for cgit. If specified, it is |
84 | suggested to use the value "/favicon.ico" since certain browsers will | 84 | suggested to use the value "/favicon.ico" since certain browsers will |
85 | ignore other values. Default value: none. | 85 | ignore other values. Default value: none. |
86 | 86 | ||
87 | footer | 87 | footer:: |
88 | The content of the file specified with this option will be included | 88 | The content of the file specified with this option will be included |
89 | verbatim at the bottom of all pages (i.e. it replaces the standard | 89 | verbatim at the bottom of all pages (i.e. it replaces the standard |
90 | "generated by..." message. Default value: none. | 90 | "generated by..." message. Default value: none. |
91 | 91 | ||
92 | header | 92 | head-include:: |
93 | The content of the file specified with this option will be included | ||
94 | verbatim in the html HEAD section on all pages. Default value: none. | ||
95 | |||
96 | header:: | ||
93 | The content of the file specified with this option will be included | 97 | The content of the file specified with this option will be included |
94 | verbatim at the top of all pages. Default value: none. | 98 | verbatim at the top of all pages. Default value: none. |
95 | 99 | ||
96 | include | 100 | include:: |
97 | Name of a configfile to include before the rest of the current config- | 101 | Name of a configfile to include before the rest of the current config- |
98 | file is parsed. Default value: none. | 102 | file is parsed. Default value: none. |
99 | 103 | ||
100 | index-header | 104 | index-header:: |
101 | The content of the file specified with this option will be included | 105 | The content of the file specified with this option will be included |
102 | verbatim above the repository index. This setting is deprecated, and | 106 | verbatim above the repository index. This setting is deprecated, and |
103 | will not be supported by cgit-1.0 (use root-readme instead). Default | 107 | will not be supported by cgit-1.0 (use root-readme instead). Default |
104 | value: none. | 108 | value: none. |
105 | 109 | ||
106 | index-info | 110 | index-info:: |
107 | The content of the file specified with this option will be included | 111 | The content of the file specified with this option will be included |
108 | verbatim below the heading on the repository index page. This setting | 112 | verbatim below the heading on the repository index page. This setting |
109 | is deprecated, and will not be supported by cgit-1.0 (use root-desc | 113 | is deprecated, and will not be supported by cgit-1.0 (use root-desc |
110 | instead). Default value: none. | 114 | instead). Default value: none. |
111 | 115 | ||
112 | local-time | 116 | local-time:: |
113 | Flag which, if set to "1", makes cgit print commit and tag times in the | 117 | Flag which, if set to "1", makes cgit print commit and tag times in the |
114 | servers timezone. Default value: "0". | 118 | servers timezone. Default value: "0". |
115 | 119 | ||
116 | logo | 120 | logo:: |
117 | Url which specifies the source of an image which will be used as a logo | 121 | Url which specifies the source of an image which will be used as a logo |
118 | on all cgit pages. | 122 | on all cgit pages. |
119 | 123 | ||
120 | logo-link | 124 | logo-link:: |
121 | Url loaded when clicking on the cgit logo image. If unspecified the | 125 | Url loaded when clicking on the cgit logo image. If unspecified the |
122 | calculated url of the repository index page will be used. Default | 126 | calculated url of the repository index page will be used. Default |
123 | value: none. | 127 | value: none. |
124 | 128 | ||
125 | max-commit-count | 129 | max-commit-count:: |
126 | Specifies the number of entries to list per page in "log" view. Default | 130 | Specifies the number of entries to list per page in "log" view. Default |
127 | value: "50". | 131 | value: "50". |
128 | 132 | ||
129 | max-message-length | 133 | max-message-length:: |
130 | Specifies the maximum number of commit message characters to display in | 134 | Specifies the maximum number of commit message characters to display in |
131 | "log" view. Default value: "80". | 135 | "log" view. Default value: "80". |
132 | 136 | ||
133 | max-repo-count | 137 | max-repo-count:: |
134 | Specifies the number of entries to list per page on the repository | 138 | Specifies the number of entries to list per page on the repository |
135 | index page. Default value: "50". | 139 | index page. Default value: "50". |
136 | 140 | ||
137 | max-repodesc-length | 141 | max-repodesc-length:: |
138 | Specifies the maximum number of repo description characters to display | 142 | Specifies the maximum number of repo description characters to display |
139 | on the repository index page. Default value: "80". | 143 | on the repository index page. Default value: "80". |
140 | 144 | ||
141 | max-stats | 145 | max-stats:: |
142 | Set the default maximum statistics period. Valid values are "week", | 146 | Set the default maximum statistics period. Valid values are "week", |
143 | "month", "quarter" and "year". If unspecified, statistics are | 147 | "month", "quarter" and "year". If unspecified, statistics are |
144 | disabled. Default value: none. See also: "repo.max-stats". | 148 | disabled. Default value: none. See also: "repo.max-stats". |
145 | 149 | ||
146 | module-link | 150 | module-link:: |
147 | Text which will be used as the formatstring for a hyperlink when a | 151 | Text which will be used as the formatstring for a hyperlink when a |
148 | submodule is printed in a directory listing. The arguments for the | 152 | submodule is printed in a directory listing. The arguments for the |
149 | formatstring are the path and SHA1 of the submodule commit. Default | 153 | formatstring are the path and SHA1 of the submodule commit. Default |
150 | value: "./?repo=%s&page=commit&id=%s" | 154 | value: "./?repo=%s&page=commit&id=%s" |
151 | 155 | ||
152 | nocache | 156 | nocache:: |
153 | If set to the value "1" caching will be disabled. This settings is | < |