-rw-r--r-- | cgit.c | 2 | ||||
-rw-r--r-- | cgit.css | 19 | ||||
-rw-r--r-- | cgit.h | 4 | ||||
-rw-r--r-- | shared.c | 3 | ||||
-rw-r--r-- | ui-log.c | 9 | ||||
-rw-r--r-- | ui-shared.c | 9 | ||||
-rw-r--r-- | ui-summary.c | 2 |
7 files changed, 39 insertions, 9 deletions
@@ -1,193 +1,193 @@ | |||
1 | /* cgit.c: cgi for the git scm | 1 | /* cgit.c: cgi for the git scm |
2 | * | 2 | * |
3 | * Copyright (C) 2006 Lars Hjemli | 3 | * Copyright (C) 2006 Lars Hjemli |
4 | * | 4 | * |
5 | * Licensed under GNU General Public License v2 | 5 | * Licensed under GNU General Public License v2 |
6 | * (see COPYING for full license text) | 6 | * (see COPYING for full license text) |
7 | */ | 7 | */ |
8 | 8 | ||
9 | #include "cgit.h" | 9 | #include "cgit.h" |
10 | 10 | ||
11 | static int cgit_prepare_cache(struct cacheitem *item) | 11 | static int cgit_prepare_cache(struct cacheitem *item) |
12 | { | 12 | { |
13 | if (!cgit_repo && cgit_query_repo) { | 13 | if (!cgit_repo && cgit_query_repo) { |
14 | char *title = fmt("%s - %s", cgit_root_title, "Bad request"); | 14 | char *title = fmt("%s - %s", cgit_root_title, "Bad request"); |
15 | cgit_print_docstart(title, item); | 15 | cgit_print_docstart(title, item); |
16 | cgit_print_pageheader(title, 0); | 16 | cgit_print_pageheader(title, 0); |
17 | cgit_print_error(fmt("Unknown repo: %s", cgit_query_repo)); | 17 | cgit_print_error(fmt("Unknown repo: %s", cgit_query_repo)); |
18 | cgit_print_docend(); | 18 | cgit_print_docend(); |
19 | return 0; | 19 | return 0; |
20 | } | 20 | } |
21 | 21 | ||
22 | if (!cgit_repo) { | 22 | if (!cgit_repo) { |
23 | item->name = xstrdup(fmt("%s/index.html", cgit_cache_root)); | 23 | item->name = xstrdup(fmt("%s/index.html", cgit_cache_root)); |
24 | item->ttl = cgit_cache_root_ttl; | 24 | item->ttl = cgit_cache_root_ttl; |
25 | return 1; | 25 | return 1; |
26 | } | 26 | } |
27 | 27 | ||
28 | if (!cgit_cmd) { | 28 | if (!cgit_cmd) { |
29 | item->name = xstrdup(fmt("%s/%s/index.%s.html", cgit_cache_root, | 29 | item->name = xstrdup(fmt("%s/%s/index.%s.html", cgit_cache_root, |
30 | cache_safe_filename(cgit_repo->url), | 30 | cache_safe_filename(cgit_repo->url), |
31 | cache_safe_filename(cgit_querystring))); | 31 | cache_safe_filename(cgit_querystring))); |
32 | item->ttl = cgit_cache_repo_ttl; | 32 | item->ttl = cgit_cache_repo_ttl; |
33 | } else { | 33 | } else { |
34 | item->name = xstrdup(fmt("%s/%s/%s/%s.html", cgit_cache_root, | 34 | item->name = xstrdup(fmt("%s/%s/%s/%s.html", cgit_cache_root, |
35 | cache_safe_filename(cgit_repo->url), | 35 | cache_safe_filename(cgit_repo->url), |
36 | cgit_query_page, | 36 | cgit_query_page, |
37 | cache_safe_filename(cgit_querystring))); | 37 | cache_safe_filename(cgit_querystring))); |
38 | if (cgit_query_has_symref) | 38 | if (cgit_query_has_symref) |
39 | item->ttl = cgit_cache_dynamic_ttl; | 39 | item->ttl = cgit_cache_dynamic_ttl; |
40 | else if (cgit_query_has_sha1) | 40 | else if (cgit_query_has_sha1) |
41 | item->ttl = cgit_cache_static_ttl; | 41 | item->ttl = cgit_cache_static_ttl; |
42 | else | 42 | else |
43 | item->ttl = cgit_cache_repo_ttl; | 43 | item->ttl = cgit_cache_repo_ttl; |
44 | } | 44 | } |
45 | return 1; | 45 | return 1; |
46 | } | 46 | } |
47 | 47 | ||
48 | static void cgit_print_repo_page(struct cacheitem *item) | 48 | static void cgit_print_repo_page(struct cacheitem *item) |
49 | { | 49 | { |
50 | char *title; | 50 | char *title; |
51 | int show_search; | 51 | int show_search; |
52 | 52 | ||
53 | if (!cgit_query_head) | 53 | if (!cgit_query_head) |
54 | cgit_query_head = cgit_repo->defbranch; | 54 | cgit_query_head = cgit_repo->defbranch; |
55 | 55 | ||
56 | if (chdir(cgit_repo->path)) { | 56 | if (chdir(cgit_repo->path)) { |
57 | title = fmt("%s - %s", cgit_root_title, "Bad request"); | 57 | title = fmt("%s - %s", cgit_root_title, "Bad request"); |
58 | cgit_print_docstart(title, item); | 58 | cgit_print_docstart(title, item); |
59 | cgit_print_pageheader(title, 0); | 59 | cgit_print_pageheader(title, 0); |
60 | cgit_print_error(fmt("Unable to scan repository: %s", | 60 | cgit_print_error(fmt("Unable to scan repository: %s", |
61 | strerror(errno))); | 61 | strerror(errno))); |
62 | cgit_print_docend(); | 62 | cgit_print_docend(); |
63 | return; | 63 | return; |
64 | } | 64 | } |
65 | 65 | ||
66 | title = fmt("%s - %s", cgit_repo->name, cgit_repo->desc); | 66 | title = fmt("%s - %s", cgit_repo->name, cgit_repo->desc); |
67 | show_search = 0; | 67 | show_search = 0; |
68 | setenv("GIT_DIR", cgit_repo->path, 1); | 68 | setenv("GIT_DIR", cgit_repo->path, 1); |
69 | 69 | ||
70 | if ((cgit_cmd == CMD_SNAPSHOT) && cgit_repo->snapshots) { | 70 | if ((cgit_cmd == CMD_SNAPSHOT) && cgit_repo->snapshots) { |
71 | cgit_print_snapshot(item, cgit_query_head, cgit_query_sha1, | 71 | cgit_print_snapshot(item, cgit_query_head, cgit_query_sha1, |
72 | cgit_repobasename(cgit_repo->url), | 72 | cgit_repobasename(cgit_repo->url), |
73 | cgit_query_path, | 73 | cgit_query_path, |
74 | cgit_repo->snapshots ); | 74 | cgit_repo->snapshots ); |
75 | return; | 75 | return; |
76 | } | 76 | } |
77 | 77 | ||
78 | if (cgit_cmd == CMD_BLOB) { | 78 | if (cgit_cmd == CMD_BLOB) { |
79 | cgit_print_blob(item, cgit_query_sha1, cgit_query_path); | 79 | cgit_print_blob(item, cgit_query_sha1, cgit_query_path); |
80 | return; | 80 | return; |
81 | } | 81 | } |
82 | 82 | ||
83 | show_search = (cgit_cmd == CMD_LOG); | 83 | show_search = (cgit_cmd == CMD_LOG); |
84 | cgit_print_docstart(title, item); | 84 | cgit_print_docstart(title, item); |
85 | if (!cgit_cmd) { | 85 | if (!cgit_cmd) { |
86 | cgit_print_pageheader("summary", show_search); | 86 | cgit_print_pageheader("summary", show_search); |
87 | cgit_print_summary(); | 87 | cgit_print_summary(); |
88 | cgit_print_docend(); | 88 | cgit_print_docend(); |
89 | return; | 89 | return; |
90 | } | 90 | } |
91 | 91 | ||
92 | cgit_print_pageheader(cgit_query_page, show_search); | 92 | cgit_print_pageheader(cgit_query_page, show_search); |
93 | 93 | ||
94 | switch(cgit_cmd) { | 94 | switch(cgit_cmd) { |
95 | case CMD_LOG: | 95 | case CMD_LOG: |
96 | cgit_print_log(cgit_query_sha1, cgit_query_ofs, | 96 | cgit_print_log(cgit_query_sha1, cgit_query_ofs, |
97 | cgit_max_commit_count, cgit_query_search, | 97 | cgit_max_commit_count, cgit_query_grep, cgit_query_search, |
98 | cgit_query_path, 1); | 98 | cgit_query_path, 1); |
99 | break; | 99 | break; |
100 | case CMD_TREE: | 100 | case CMD_TREE: |
101 | cgit_print_tree(cgit_query_sha1, cgit_query_path); | 101 | cgit_print_tree(cgit_query_sha1, cgit_query_path); |
102 | break; | 102 | break; |
103 | case CMD_COMMIT: | 103 | case CMD_COMMIT: |
104 | cgit_print_commit(cgit_query_sha1); | 104 | cgit_print_commit(cgit_query_sha1); |
105 | break; | 105 | break; |
106 | case CMD_REFS: | 106 | case CMD_REFS: |
107 | cgit_print_refs(); | 107 | cgit_print_refs(); |
108 | break; | 108 | break; |
109 | case CMD_TAG: | 109 | case CMD_TAG: |
110 | cgit_print_tag(cgit_query_sha1); | 110 | cgit_print_tag(cgit_query_sha1); |
111 | break; | 111 | break; |
112 | case CMD_DIFF: | 112 | case CMD_DIFF: |
113 | cgit_print_diff(cgit_query_sha1, cgit_query_sha2, cgit_query_path); | 113 | cgit_print_diff(cgit_query_sha1, cgit_query_sha2, cgit_query_path); |
114 | break; | 114 | break; |
115 | default: | 115 | default: |
116 | cgit_print_error("Invalid request"); | 116 | cgit_print_error("Invalid request"); |
117 | } | 117 | } |
118 | cgit_print_docend(); | 118 | cgit_print_docend(); |
119 | } | 119 | } |
120 | 120 | ||
121 | static void cgit_fill_cache(struct cacheitem *item, int use_cache) | 121 | static void cgit_fill_cache(struct cacheitem *item, int use_cache) |
122 | { | 122 | { |
123 | static char buf[PATH_MAX]; | 123 | static char buf[PATH_MAX]; |
124 | int stdout2; | 124 | int stdout2; |
125 | 125 | ||
126 | getcwd(buf, sizeof(buf)); | 126 | getcwd(buf, sizeof(buf)); |
127 | item->st.st_mtime = time(NULL); | 127 | item->st.st_mtime = time(NULL); |
128 | 128 | ||
129 | if (use_cache) { | 129 | if (use_cache) { |
130 | stdout2 = chk_positive(dup(STDOUT_FILENO), | 130 | stdout2 = chk_positive(dup(STDOUT_FILENO), |
131 | "Preserving STDOUT"); | 131 | "Preserving STDOUT"); |
132 | chk_zero(close(STDOUT_FILENO), "Closing STDOUT"); | 132 | chk_zero(close(STDOUT_FILENO), "Closing STDOUT"); |
133 | chk_positive(dup2(item->fd, STDOUT_FILENO), "Dup2(cachefile)"); | 133 | chk_positive(dup2(item->fd, STDOUT_FILENO), "Dup2(cachefile)"); |
134 | } | 134 | } |
135 | 135 | ||
136 | if (cgit_repo) | 136 | if (cgit_repo) |
137 | cgit_print_repo_page(item); | 137 | cgit_print_repo_page(item); |
138 | else | 138 | else |
139 | cgit_print_repolist(item); | 139 | cgit_print_repolist(item); |
140 | 140 | ||
141 | if (use_cache) { | 141 | if (use_cache) { |
142 | chk_zero(close(STDOUT_FILENO), "Close redirected STDOUT"); | 142 | chk_zero(close(STDOUT_FILENO), "Close redirected STDOUT"); |
143 | chk_positive(dup2(stdout2, STDOUT_FILENO), | 143 | chk_positive(dup2(stdout2, STDOUT_FILENO), |
144 | "Restoring original STDOUT"); | 144 | "Restoring original STDOUT"); |
145 | chk_zero(close(stdout2), "Closing temporary STDOUT"); | 145 | chk_zero(close(stdout2), "Closing temporary STDOUT"); |
146 | } | 146 | } |
147 | 147 | ||
148 | chdir(buf); | 148 | chdir(buf); |
149 | } | 149 | } |
150 | 150 | ||
151 | static void cgit_check_cache(struct cacheitem *item) | 151 | static void cgit_check_cache(struct cacheitem *item) |
152 | { | 152 | { |
153 | int i = 0; | 153 | int i = 0; |
154 | 154 | ||
155 | top: | 155 | top: |
156 | if (++i > cgit_max_lock_attempts) { | 156 | if (++i > cgit_max_lock_attempts) { |
157 | die("cgit_refresh_cache: unable to lock %s: %s", | 157 | die("cgit_refresh_cache: unable to lock %s: %s", |
158 | item->name, strerror(errno)); | 158 | item->name, strerror(errno)); |
159 | } | 159 | } |
160 | if (!cache_exist(item)) { | 160 | if (!cache_exist(item)) { |
161 | if (!cache_lock(item)) { | 161 | if (!cache_lock(item)) { |
162 | sleep(1); | 162 | sleep(1); |
163 | goto top; | 163 | goto top; |
164 | } | 164 | } |
165 | if (!cache_exist(item)) { | 165 | if (!cache_exist(item)) { |
166 | cgit_fill_cache(item, 1); | 166 | cgit_fill_cache(item, 1); |
167 | cache_unlock(item); | 167 | cache_unlock(item); |
168 | } else { | 168 | } else { |
169 | cache_cancel_lock(item); | 169 | cache_cancel_lock(item); |
170 | } | 170 | } |
171 | } else if (cache_expired(item) && cache_lock(item)) { | 171 | } else if (cache_expired(item) && cache_lock(item)) { |
172 | if (cache_expired(item)) { | 172 | if (cache_expired(item)) { |
173 | cgit_fill_cache(item, 1); | 173 | cgit_fill_cache(item, 1); |
174 | cache_unlock(item); | 174 | cache_unlock(item); |
175 | } else { | 175 | } else { |
176 | cache_cancel_lock(item); | 176 | cache_cancel_lock(item); |
177 | } | 177 | } |
178 | } | 178 | } |
179 | } | 179 | } |
180 | 180 | ||
181 | static void cgit_print_cache(struct cacheitem *item) | 181 | static void cgit_print_cache(struct cacheitem *item) |
182 | { | 182 | { |
183 | static char buf[4096]; | 183 | static char buf[4096]; |
184 | ssize_t i; | 184 | ssize_t i; |
185 | 185 | ||
186 | int fd = open(item->name, O_RDONLY); | 186 | int fd = open(item->name, O_RDONLY); |
187 | if (fd<0) | 187 | if (fd<0) |
188 | die("Unable to open cached file %s", item->name); | 188 | die("Unable to open cached file %s", item->name); |
189 | 189 | ||
190 | while((i=read(fd, buf, sizeof(buf))) > 0) | 190 | while((i=read(fd, buf, sizeof(buf))) > 0) |
191 | write(STDOUT_FILENO, buf, i); | 191 | write(STDOUT_FILENO, buf, i); |
192 | 192 | ||
193 | close(fd); | 193 | close(fd); |
@@ -51,201 +51,218 @@ table.list { | |||
51 | table.list tr { | 51 | table.list tr { |
52 | background: white; | 52 | background: white; |
53 | } | 53 | } |
54 | 54 | ||
55 | table.list tr:hover { | 55 | table.list tr:hover { |
56 | background: #eee; | 56 | background: #eee; |
57 | } | 57 | } |
58 | 58 | ||
59 | table.list tr.nohover:hover { | 59 | table.list tr.nohover:hover { |
60 | background: white; | 60 | background: white; |
61 | } | 61 | } |
62 | 62 | ||
63 | table.list th { | 63 | table.list th { |
64 | font-weight: bold; | 64 | font-weight: bold; |
65 | border-bottom: solid 1px #777; | 65 | border-bottom: solid 1px #777; |
66 | padding: 0.1em 0.5em 0.1em 0.5em; | 66 | padding: 0.1em 0.5em 0.1em 0.5em; |
67 | vertical-align: baseline; | 67 | vertical-align: baseline; |
68 | } | 68 | } |
69 | 69 | ||
70 | table.list td { | 70 | table.list td { |
71 | border: none; | 71 | border: none; |
72 | padding: 0.1em 0.5em 0.1em 0.5em; | 72 | padding: 0.1em 0.5em 0.1em 0.5em; |
73 | } | 73 | } |
74 | 74 | ||
75 | img { | 75 | img { |
76 | border: none; | 76 | border: none; |
77 | } | 77 | } |
78 | 78 | ||
79 | table#layout { | 79 | table#layout { |
80 | width: 100%; | 80 | width: 100%; |
81 | border-collapse: collapse; | 81 | border-collapse: collapse; |
82 | margin: 0px; | 82 | margin: 0px; |
83 | } | 83 | } |
84 | 84 | ||
85 | td#header, td#logo { | 85 | td#header, td#logo { |
86 | color: #666; | 86 | color: #666; |
87 | background-color: #ddd; | 87 | background-color: #ddd; |
88 | border-bottom: solid 1px #000; | 88 | border-bottom: solid 1px #000; |
89 | } | 89 | } |
90 | 90 | ||
91 | td#header { | 91 | td#header { |
92 | font-size: 150%; | 92 | font-size: 150%; |
93 | font-weight: bold; | 93 | font-weight: bold; |
94 | padding: 0.2em 0.5em; | 94 | padding: 0.2em 0.5em; |
95 | vertical-align: text-bottom; | 95 | vertical-align: text-bottom; |
96 | } | 96 | } |
97 | 97 | ||
98 | td#header a { | 98 | td#header a { |
99 | color: #666; | 99 | color: #666; |
100 | } | 100 | } |
101 | 101 | ||
102 | td#header a:hover { | 102 | td#header a:hover { |
103 | text-decoration: underline; | 103 | text-decoration: underline; |
104 | } | 104 | } |
105 | 105 | ||
106 | td#logo { | 106 | td#logo { |
107 | text-align: right; | 107 | text-align: right; |
108 | vertical-align: middle; | 108 | vertical-align: middle; |
109 | padding-right: 0.5em; | 109 | padding-right: 0.5em; |
110 | } | 110 | } |
111 | 111 | ||
112 | td#crumb, td#search { | 112 | td#crumb, td#search { |
113 | color: #ccc; | 113 | color: #ccc; |
114 | border-top: solid 3px #555; | 114 | border-top: solid 3px #555; |
115 | background-color: #666; | 115 | background-color: #666; |
116 | border-bottom: solid 1px #333; | 116 | border-bottom: solid 1px #333; |
117 | padding: 2px 1em; | 117 | padding: 2px 1em; |
118 | } | 118 | } |
119 | 119 | ||
120 | td#crumb { | 120 | td#crumb { |
121 | font-weight: bold; | 121 | font-weight: bold; |
122 | } | 122 | } |
123 | 123 | ||
124 | td#crumb a { | 124 | td#crumb a { |
125 | color: #ccc; | 125 | color: #ccc; |
126 | background-color: #666; | 126 | background-color: #666; |
127 | padding: 0em 0.5em 0em 0.5em; | 127 | padding: 0em 0.5em 0em 0.5em; |
128 | } | 128 | } |
129 | 129 | ||
130 | td#crumb a:hover { | 130 | td#crumb a:hover { |
131 | color: #666; | 131 | color: #666; |
132 | background-color: #ccc; | 132 | background-color: #ccc; |
133 | text-decoration: none; | 133 | text-decoration: none; |
134 | } | 134 | } |
135 | 135 | ||
136 | td#search { | 136 | td#search { |
137 | text-align: right; | 137 | text-align: right; |
138 | vertical-align: middle; | 138 | vertical-align: middle; |
139 | padding-right: 0.5em; | 139 | padding-right: 0.5em; |
140 | } | 140 | } |
141 | 141 | ||
142 | td#search form { | 142 | td#search form { |
143 | margin: 0px; | 143 | margin: 0px; |
144 | padding: 0px; | 144 | padding: 0px; |
145 | } | 145 | } |
146 | 146 | ||
147 | td#search select { | ||
148 | font-size: 9pt; | ||
149 | padding: 0px; | ||
150 | border: solid 1px #333; | ||
151 | color: #333; | ||
152 | background-color: #fff; | ||
153 | } | ||
154 | |||
147 | td#search input { | 155 | td#search input { |
148 | font-size: 9pt; | 156 | font-size: 9pt; |
149 | padding: 0px; | 157 | padding: 0px; |
150 | width: 10em; | 158 | } |
159 | |||
160 | td#search input.txt { | ||
161 | width: 8em; | ||
151 | border: solid 1px #333; | 162 | border: solid 1px #333; |
152 | color: #333; | 163 | color: #333; |
153 | background-color: #fff; | 164 | background-color: #fff; |
154 | } | 165 | } |
155 | 166 | ||
167 | td#search input.btn { | ||
168 | border: solid 1px #333; | ||
169 | color: #333; | ||
170 | background-color: #ccc; | ||
171 | } | ||
172 | |||
156 | div#summary { | 173 | div#summary { |
157 | vertical-align: top; | 174 | vertical-align: top; |
158 | margin-bottom: 1em; | 175 | margin-bottom: 1em; |
159 | } | 176 | } |
160 | 177 | ||
161 | table#downloads { | 178 | table#downloads { |
162 | float: right; | 179 | float: right; |
163 | border-collapse: collapse; | 180 | border-collapse: collapse; |
164 | border: solid 1px #777; | 181 | border: solid 1px #777; |
165 | margin-left: 0.5em; | 182 | margin-left: 0.5em; |
166 | margin-bottom: 0.5em; | 183 | margin-bottom: 0.5em; |
167 | } | 184 | } |
168 | 185 | ||
169 | table#downloads th { | 186 | table#downloads th { |
170 | background-color: #ccc; | 187 | background-color: #ccc; |
171 | } | 188 | } |
172 | 189 | ||
173 | td#content { | 190 | td#content { |
174 | padding: 1em 0.5em; | 191 | padding: 1em 0.5em; |
175 | } | 192 | } |
176 | 193 | ||
177 | div#blob { | 194 | div#blob { |
178 | border: solid 1px black; | 195 | border: solid 1px black; |
179 | } | 196 | } |
180 | 197 | ||
181 | div.error { | 198 | div.error { |
182 | color: red; | 199 | color: red; |
183 | font-weight: bold; | 200 | font-weight: bold; |
184 | margin: 1em 2em; | 201 | margin: 1em 2em; |
185 | } | 202 | } |
186 | 203 | ||
187 | a.ls-blob, a.ls-dir, a.ls-mod { | 204 | a.ls-blob, a.ls-dir, a.ls-mod { |
188 | font-family: monospace; | 205 | font-family: monospace; |
189 | } | 206 | } |
190 | 207 | ||
191 | td.ls-size { | 208 | td.ls-size { |
192 | text-align: right; | 209 | text-align: right; |
193 | } | 210 | } |
194 | 211 | ||
195 | td.ls-size { | 212 | td.ls-size { |
196 | font-family: monospace; | 213 | font-family: monospace; |
197 | } | 214 | } |
198 | 215 | ||
199 | td.ls-mode { | 216 | td.ls-mode { |
200 | font-family: monospace; | 217 | font-family: monospace; |
201 | } | 218 | } |
202 | 219 | ||
203 | table.blob { | 220 | table.blob { |
204 | margin-top: 0.5em; | 221 | margin-top: 0.5em; |
205 | border-top: solid 1px black; | 222 | border-top: solid 1px black; |
206 | } | 223 | } |
207 | 224 | ||
208 | table.blob td.no { | 225 | table.blob td.no { |
209 | border-right: solid 1px black; | 226 | border-right: solid 1px black; |
210 | color: black; | 227 | color: black; |
211 | background-color: #eee; | 228 | background-color: #eee; |
212 | text-align: right; | 229 | text-align: right; |
213 | } | 230 | } |
214 | 231 | ||
215 | table.blob td.no a { | 232 | table.blob td.no a { |
216 | color: black; | 233 | color: black; |
217 | } | 234 | } |
218 | 235 | ||
219 | table.blob td.no a:hover { | 236 | table.blob td.no a:hover { |
220 | color: black; | 237 | color: black; |
221 | text-decoration: none; | 238 | text-decoration: none; |
222 | } | 239 | } |
223 | 240 | ||
224 | table.blob td.txt { | 241 | table.blob td.txt { |
225 | white-space: pre; | 242 | white-space: pre; |
226 | font-family: monospace; | 243 | font-family: monospace; |
227 | padding-left: 0.5em; | 244 | padding-left: 0.5em; |
228 | } | 245 | } |
229 | 246 | ||
230 | table.nowrap td { | 247 | table.nowrap td { |
231 | white-space: nowrap; | 248 | white-space: nowrap; |
232 | } | 249 | } |
233 | 250 | ||
234 | table.commit-info { | 251 | table.commit-info { |
235 | border-collapse: collapse; | 252 | border-collapse: collapse; |
236 | margin-top: 1.5em; | 253 | margin-top: 1.5em; |
237 | } | 254 | } |
238 | 255 | ||
239 | table.commit-info th { | 256 | table.commit-info th { |
240 | text-align: left; | 257 | text-align: left; |
241 | font-weight: normal; | 258 | font-weight: normal; |
242 | padding: 0.1em 1em 0.1em 0.1em; | 259 | padding: 0.1em 1em 0.1em 0.1em; |
243 | vertical-align: top; | 260 | vertical-align: top; |
244 | } | 261 | } |
245 | 262 | ||
246 | table.commit-info td { | 263 | table.commit-info td { |
247 | font-weight: normal; | 264 | font-weight: normal; |
248 | padding: 0.1em 1em 0.1em 0.1em; | 265 | padding: 0.1em 1em 0.1em 0.1em; |
249 | } | 266 | } |
250 | 267 | ||
251 | div.commit-subject { | 268 | div.commit-subject { |
@@ -65,213 +65,215 @@ struct repoinfo { | |||
65 | char *path; | 65 | char *path; |
66 | char *desc; | 66 | char *desc; |
67 | char *owner; | 67 | char *owner; |
68 | char *defbranch; | 68 | char *defbranch; |
69 | char *group; | 69 | char *group; |
70 | char *module_link; | 70 | char *module_link; |
71 | char *readme; | 71 | char *readme; |
72 | int snapshots; | 72 | int snapshots; |
73 | int enable_log_filecount; | 73 | int enable_log_filecount; |
74 | int enable_log_linecount; | 74 | int enable_log_linecount; |
75 | }; | 75 | }; |
76 | 76 | ||
77 | struct repolist { | 77 | struct repolist { |
78 | int length; | 78 | int length; |
79 | int count; | 79 | int count; |
80 | struct repoinfo *repos; | 80 | struct repoinfo *repos; |
81 | }; | 81 | }; |
82 | 82 | ||
83 | struct commitinfo { | 83 | struct commitinfo { |
84 | struct commit *commit; | 84 | struct commit *commit; |
85 | char *author; | 85 | char *author; |
86 | char *author_email; | 86 | char *author_email; |
87 | unsigned long author_date; | 87 | unsigned long author_date; |
88 | char *committer; | 88 | char *committer; |
89 | char *committer_email; | 89 | char *committer_email; |
90 | unsigned long committer_date; | 90 | unsigned long committer_date; |
91 | char *subject; | 91 | char *subject; |
92 | char *msg; | 92 | char *msg; |
93 | }; | 93 | }; |
94 | 94 | ||
95 | struct taginfo { | 95 | struct taginfo { |
96 | char *tagger; | 96 | char *tagger; |
97 | char *tagger_email; | 97 | char *tagger_email; |
98 | int tagger_date; | 98 | int tagger_date; |
99 | char *msg; | 99 | char *msg; |
100 | }; | 100 | }; |
101 | 101 | ||
102 | struct refinfo { | 102 | struct refinfo { |
103 | const char *refname; | 103 | const char *refname; |
104 | struct object *object; | 104 | struct object *object; |
105 | union { | 105 | union { |
106 | struct taginfo *tag; | 106 | struct taginfo *tag; |
107 | struct commitinfo *commit; | 107 | struct commitinfo *commit; |
108 | }; | 108 | }; |
109 | }; | 109 | }; |
110 | 110 | ||
111 | struct reflist { | 111 | struct reflist { |
112 | struct refinfo **refs; | 112 | struct refinfo **refs; |
113 | int alloc; | 113 | int alloc; |
114 | int count; | 114 | int count; |
115 | }; | 115 | }; |
116 | 116 | ||
117 | extern const char *cgit_version; | 117 | extern const char *cgit_version; |
118 | 118 | ||
119 | extern struct repolist cgit_repolist; | 119 | extern struct repolist cgit_repolist; |
120 | extern struct repoinfo *cgit_repo; | 120 | extern struct repoinfo *cgit_repo; |
121 | extern int cgit_cmd; | 121 | extern int cgit_cmd; |
122 | 122 | ||
123 | extern char *cgit_root_title; | 123 | extern char *cgit_root_title; |
124 | extern char *cgit_css; | 124 | extern char *cgit_css; |
125 | extern char *cgit_logo; | 125 | extern char *cgit_logo; |
126 | extern char *cgit_index_header; | 126 | extern char *cgit_index_header; |
127 | extern char *cgit_logo_link; | 127 | extern char *cgit_logo_link; |
128 | extern char *cgit_module_link; | 128 | extern char *cgit_module_link; |
129 | extern char *cgit_agefile; | 129 | extern char *cgit_agefile; |
130 | extern char *cgit_virtual_root; | 130 | extern char *cgit_virtual_root; |
131 | extern char *cgit_script_name; | 131 | extern char *cgit_script_name; |
132 | extern char *cgit_cache_root; | 132 | extern char *cgit_cache_root; |
133 | extern char *cgit_repo_group; | 133 | extern char *cgit_repo_group; |
134 | 134 | ||
135 | extern int cgit_nocache; | 135 | extern int cgit_nocache; |
136 | extern int cgit_snapshots; | 136 | extern int cgit_snapshots; |
137 | extern int cgit_enable_index_links; | 137 | extern int cgit_enable_index_links; |
138 | extern int cgit_enable_log_filecount; | 138 | extern int cgit_enable_log_filecount; |
139 | extern int cgit_enable_log_linecount; | 139 | extern int cgit_enable_log_linecount; |
140 | extern int cgit_max_lock_attempts; | 140 | extern int cgit_max_lock_attempts; |
141 | extern int cgit_cache_root_ttl; | 141 | extern int cgit_cache_root_ttl; |
142 | extern int cgit_cache_repo_ttl; | 142 | extern int cgit_cache_repo_ttl; |
143 | extern int cgit_cache_dynamic_ttl; | 143 | extern int cgit_cache_dynamic_ttl; |
144 | extern int cgit_cache_static_ttl; | 144 | extern int cgit_cache_static_ttl; |
145 | extern int cgit_cache_max_create_time; | 145 | extern int cgit_cache_max_create_time; |
146 | extern int cgit_summary_log; | 146 | extern int cgit_summary_log; |
147 | extern int cgit_summary_tags; | 147 | extern int cgit_summary_tags; |
148 | extern int cgit_summary_branches; | 148 | extern int cgit_summary_branches; |
149 | 149 | ||
150 | extern int cgit_max_msg_len; | 150 | extern int cgit_max_msg_len; |
151 | extern int cgit_max_repodesc_len; | 151 | extern int cgit_max_repodesc_len; |
152 | extern int cgit_max_commit_count; | 152 | extern int cgit_max_commit_count; |
153 | 153 | ||
154 | extern int cgit_query_has_symref; | 154 | extern int cgit_query_has_symref; |
155 | extern int cgit_query_has_sha1; | 155 | extern int cgit_query_has_sha1; |
156 | 156 | ||
157 | extern char *cgit_querystring; | 157 | extern char *cgit_querystring; |
158 | extern char *cgit_query_repo; | 158 | extern char *cgit_query_repo; |
159 | extern char *cgit_query_page; | 159 | extern char *cgit_query_page; |
160 | extern char *cgit_query_search; | 160 | extern char *cgit_query_search; |
161 | extern char *cgit_query_grep; | ||
161 | extern char *cgit_query_head; | 162 | extern char *cgit_query_head; |
162 | extern char *cgit_query_sha1; | 163 | extern char *cgit_query_sha1; |
163 | extern char *cgit_query_sha2; | 164 | extern char *cgit_query_sha2; |
164 | extern char *cgit_query_path; | 165 | extern char *cgit_query_path; |
165 | extern char *cgit_query_name; | 166 | extern char *cgit_query_name; |
166 | extern int cgit_query_ofs; | 167 | extern int cgit_query_ofs; |
167 | 168 | ||
168 | extern int htmlfd; | 169 | extern int htmlfd; |
169 | 170 | ||
170 | extern int cgit_get_cmd_index(const char *cmd); | 171 | extern int cgit_get_cmd_index(const char *cmd); |
171 | extern struct repoinfo *cgit_get_repoinfo(const char *url); | 172 | extern struct repoinfo *cgit_get_repoinfo(const char *url); |
172 | extern void cgit_global_config_cb(const char *name, const char *value); | 173 | extern void cgit_global_config_cb(const char *name, const char *value); |
173 | extern void cgit_repo_config_cb(const char *name, const char *value); | 174 | extern void cgit_repo_config_cb(const char *name, const char *value); |
174 | extern void cgit_querystring_cb(const char *name, const char *value); | 175 | extern void cgit_querystring_cb(const char *name, const char *value); |
175 | 176 | ||
176 | extern int chk_zero(int result, char *msg); | 177 | extern int chk_zero(int result, char *msg); |
177 | extern int chk_positive(int result, char *msg); | 178 | extern int chk_positive(int result, char *msg); |
178 | extern int chk_non_negative(int result, char *msg); | 179 | extern int chk_non_negative(int result, char *msg); |
179 | 180 | ||
180 | extern int hextoint(char c); | 181 | extern int hextoint(char c); |
181 | extern char *trim_end(const char *str, char c); | 182 | extern char *trim_end(const char *str, char c); |
182 | 183 | ||
183 | extern void cgit_add_ref(struct reflist *list, struct refinfo *ref); | 184 | extern void cgit_add_ref(struct reflist *list, struct refinfo *ref); |
184 | extern int cgit_refs_cb(const char *refname, const unsigned char *sha1, | 185 | extern int cgit_refs_cb(const char *refname, const unsigned char *sha1, |
185 | int flags, void *cb_data); | 186 | int flags, void *cb_data); |
186 | 187 | ||
187 | extern void *cgit_free_commitinfo(struct commitinfo *info); | 188 | extern void *cgit_free_commitinfo(struct commitinfo *info); |
188 | 189 | ||
189 | extern int cgit_diff_files(const unsigned char *old_sha1, | 190 | extern int cgit_diff_files(const unsigned char *old_sha1, |
190 | const unsigned char *new_sha1, | 191 | const unsigned char *new_sha1, |
191 | linediff_fn fn); | 192 | linediff_fn fn); |
192 | 193 | ||
193 | extern void cgit_diff_tree(const unsigned char *old_sha1, | 194 | extern void cgit_diff_tree(const unsigned char *old_sha1, |
194 | const unsigned char *new_sha1, | 195 | const unsigned char *new_sha1, |
195 | filepair_fn fn, const char *prefix); | 196 | filepair_fn fn, const char *prefix); |
196 | 197 | ||
197 | extern void cgit_diff_commit(struct commit *commit, filepair_fn fn); | 198 | extern void cgit_diff_commit(struct commit *commit, filepair_fn fn); |
198 | 199 | ||
199 | extern char *fmt(const char *format,...); | 200 | extern char *fmt(const char *format,...); |
200 | 201 | ||
201 | extern void html(const char *txt); | 202 | extern void html(const char *txt); |
202 | extern void htmlf(const char *format,...); | 203 | extern void htmlf(const char *format,...); |
203 | extern void html_txt(char *txt); | 204 | extern void html_txt(char *txt); |
204 | extern void html_ntxt(int len, char *txt); | 205 | extern void html_ntxt(int len, char *txt); |
205 | extern void html_attr(char *txt); | 206 | extern void html_attr(char *txt); |
206 | extern void html_hidden(char *name, char *value); | 207 | extern void html_hidden(char *name, char *value); |
207 | extern void html_option(char *value, char *text, char *selected_value); | 208 | extern void html_option(char *value, char *text, char *selected_value); |
208 | extern void html_link_open(char *url, char *title, char *class); | 209 | extern void html_link_open(char *url, char *title, char *class); |
209 | extern void html_link_close(void); | 210 | extern void html_link_close(void); |
210 | extern void html_filemode(unsigned short mode); | 211 | extern void html_filemode(unsigned short mode); |
211 | extern int html_include(const char *filename); | 212 | extern int html_include(const char *filename); |
212 | 213 | ||
213 | extern int cgit_read_config(const char *filename, configfn fn); | 214 | extern int cgit_read_config(const char *filename, configfn fn); |
214 | extern int cgit_parse_query(char *txt, configfn fn); | 215 | extern int cgit_parse_query(char *txt, configfn fn); |
215 | extern struct commitinfo *cgit_parse_commit(struct commit *commit); | 216 | extern struct commitinfo *cgit_parse_commit(struct commit *commit); |
216 | extern struct taginfo *cgit_parse_tag(struct tag *tag); | 217 | extern struct taginfo *cgit_parse_tag(struct tag *tag); |
217 | extern void cgit_parse_url(const char *url); | 218 | extern void cgit_parse_url(const char *url); |
218 | 219 | ||
219 | extern char *cache_safe_filename(const char *unsafe); | 220 | extern char *cache_safe_filename(const char *unsafe); |
220 | extern int cache_lock(struct cacheitem *item); | 221 | extern int cache_lock(struct cacheitem *item); |
221 | extern int cache_unlock(struct cacheitem *item); | 222 | extern int cache_unlock(struct cacheitem *item); |
222 | extern int cache_cancel_lock(struct cacheitem *item); | 223 | extern int cache_cancel_lock(struct cacheitem *item); |
223 | extern int cache_exist(struct cacheitem *item); | 224 | extern int cache_exist(struct cacheitem *item); |
224 | extern int cache_expired(struct cacheitem *item); | 225 | extern int cache_expired(struct cacheitem *item); |
225 | 226 | ||
226 | extern char *cgit_repourl(const char *reponame); | 227 | extern char *cgit_repourl(const char *reponame); |
227 | extern char *cgit_fileurl(const char *reponame, const char *pagename, | 228 | extern char *cgit_fileurl(const char *reponame, const char *pagename, |
228 | const char *filename, const char *query); | 229 | const char *filename, const char *query); |
229 | extern char *cgit_pageurl(const char *reponame, const char *pagename, | 230 | extern char *cgit_pageurl(const char *reponame, const char *pagename, |
230 | const char *query); | 231 | const char *query); |
231 | 232 | ||
232 | extern const char *cgit_repobasename(const char *reponame); | 233 | extern const char *cgit_repobasename(const char *reponame); |
233 | 234 | ||
234 | extern void cgit_tree_link(char *name, char *title, char *class, char *head, | 235 | extern void cgit_tree_link(char *name, char *title, char *class, char *head, |
235 | char *rev, char *path); | 236 | char *rev, char *path); |
236 | extern void cgit_log_link(char *name, char *title, char *class, char *head, | 237 | extern void cgit_log_link(char *name, char *title, char *class, char *head, |
237 | char *rev, char *path, int ofs); | 238 | char *rev, char *path, int ofs); |
238 | extern void cgit_commit_link(char *name, char *title, char *class, char *head, | 239 | extern void cgit_commit_link(char *name, char *title, char *class, char *head, |
239 | char *rev); | 240 | char *rev); |
240 | extern void cgit_refs_link(char *name, char *title, char *class, char *head, | 241 | extern void cgit_refs_link(char *name, char *title, char *class, char *head, |
241 | char *rev, char *path); | 242 | char *rev, char *path); |
242 | extern void cgit_snapshot_link(char *name, char *title, char *class, | 243 | extern void cgit_snapshot_link(char *name, char *title, char *class, |
243 | char *head, char *rev, char *archivename); | 244 | char *head, char *rev, char *archivename); |
244 | extern void cgit_diff_link(char *name, char *title, char *class, char *head, | 245 | extern void cgit_diff_link(char *name, char *title, char *class, char *head, |
245 | char *new_rev, char *old_rev, char *path); | 246 | char *new_rev, char *old_rev, char *path); |
246 | 247 | ||
247 | extern void cgit_object_link(struct object *obj); | 248 | extern void cgit_object_link(struct object *obj); |
248 | 249 | ||
249 | extern void cgit_print_error(char *msg); | 250 | extern void cgit_print_error(char *msg); |
250 | extern void cgit_print_date(time_t secs, char *format); | 251 | extern void cgit_print_date(time_t secs, char *format); |
251 | extern void cgit_print_age(time_t t, time_t max_relative, char *format); | 252 | extern void cgit_print_age(time_t t, time_t max_relative, char *format); |
252 | extern void cgit_print_docstart(char *title, struct cacheitem *item); | 253 | extern void cgit_print_docstart(char *title, struct cacheitem *item); |
253 | extern void cgit_print_docend(); | 254 | extern void cgit_print_docend(); |
254 | extern void cgit_print_pageheader(char *title, int show_search); | 255 | extern void cgit_print_pageheader(char *title, int show_search); |
255 | extern void cgit_print_snapshot_start(const char *mimetype, | 256 | extern void cgit_print_snapshot_start(const char *mimetype, |
256 | const char *filename, | 257 | const char *filename, |
257 | struct cacheitem *item); | 258 | struct cacheitem *item); |
258 | extern void cgit_print_branches(int maxcount); | 259 | extern void cgit_print_branches(int maxcount); |
259 | extern void cgit_print_tags(int maxcount); | 260 | extern void cgit_print_tags(int maxcount); |
260 | 261 | ||
261 | extern void cgit_print_repolist(struct cacheitem *item); | 262 | extern void cgit_print_repolist(struct cacheitem *item); |
262 | extern void cgit_print_summary(); | 263 | extern void cgit_print_summary(); |
263 | extern void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *path, int pager); | 264 | extern void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, |
265 | char *pattern, char *path, int pager); | ||
264 | extern void cgit_print_blob(struct cacheitem *item, const char *hex, char *path); | 266 | extern void cgit_print_blob(struct cacheitem *item, const char *hex, char *path); |
265 | extern void cgit_print_tree(const char *rev, char *path); | 267 | extern void cgit_print_tree(const char *rev, char *path); |
266 | extern void cgit_print_commit(char *hex); | 268 | extern void cgit_print_commit(char *hex); |
267 | extern void cgit_print_refs(); | 269 | extern void cgit_print_refs(); |
268 | extern void cgit_print_tag(char *revname); | 270 | extern void cgit_print_tag(char *revname); |
269 | extern void cgit_print_diff(const char *new_hex, const char *old_hex, const char *prefix); | 271 | extern void cgit_print_diff(const char *new_hex, const char *old_hex, const char *prefix); |
270 | extern void cgit_print_snapshot(struct cacheitem *item, const char *head, | 272 | extern void cgit_print_snapshot(struct cacheitem *item, const char *head, |
271 | const char *hex, const char *prefix, | 273 | const char *hex, const char *prefix, |
272 | const char *filename, int snapshot); | 274 | const char *filename, int snapshot); |
273 | extern void cgit_print_snapshot_links(const char *repo, const char *head, | 275 | extern void cgit_print_snapshot_links(const char *repo, const char *head, |
274 | const char *hex, int snapshots); | 276 | const char *hex, int snapshots); |
275 | extern int cgit_parse_snapshots_mask(const char *str); | 277 | extern int cgit_parse_snapshots_mask(const char *str); |
276 | 278 | ||
277 | #endif /* CGIT_H */ | 279 | #endif /* CGIT_H */ |
@@ -1,330 +1,333 @@ | |||
1 | /* shared.c: global vars + some callback functions | 1 | /* shared.c: global vars + some callback functions |
2 | * | 2 | * |
3 | * Copyright (C) 2006 Lars Hjemli | 3 | * Copyright (C) 2006 Lars Hjemli |
4 | * | 4 | * |
5 | * Licensed under GNU General Public License v2 | 5 | * Licensed under GNU General Public License v2 |
6 | * (see COPYING for full license text) | 6 | * (see COPYING for full license text) |
7 | */ | 7 | */ |
8 | 8 | ||
9 | #include "cgit.h" | 9 | #include "cgit.h" |
10 | 10 | ||
11 | struct repolist cgit_repolist; | 11 | struct repolist cgit_repolist; |
12 | struct repoinfo *cgit_repo; | 12 | struct repoinfo *cgit_repo; |
13 | int cgit_cmd; | 13 | int cgit_cmd; |
14 | 14 | ||
15 | const char *cgit_version = CGIT_VERSION; | 15 | const char *cgit_version = CGIT_VERSION; |
16 | 16 | ||
17 | char *cgit_root_title = "Git repository browser"; | 17 | char *cgit_root_title = "Git repository browser"; |
18 | char *cgit_css = "/cgit.css"; | 18 | char *cgit_css = "/cgit.css"; |
19 | char *cgit_logo = "/git-logo.png"; | 19 | char *cgit_logo = "/git-logo.png"; |
20 | char *cgit_index_header = NULL; | 20 | char *cgit_index_header = NULL; |
21 | char *cgit_logo_link = "http://www.kernel.org/pub/software/scm/git/docs/"; | 21 | char *cgit_logo_link = "http://www.kernel.org/pub/software/scm/git/docs/"; |
22 | char *cgit_module_link = "./?repo=%s&page=commit&id=%s"; | 22 | char *cgit_module_link = "./?repo=%s&page=commit&id=%s"; |
23 | char *cgit_agefile = "info/web/last-modified"; | 23 | char *cgit_agefile = "info/web/last-modified"; |
24 | char *cgit_virtual_root = NULL; | 24 | char *cgit_virtual_root = NULL; |
25 | char *cgit_script_name = CGIT_SCRIPT_NAME; | 25 | char *cgit_script_name = CGIT_SCRIPT_NAME; |
26 | char *cgit_cache_root = CGIT_CACHE_ROOT; | 26 | char *cgit_cache_root = CGIT_CACHE_ROOT; |
27 | char *cgit_repo_group = NULL; | 27 | char *cgit_repo_group = NULL; |
28 | 28 | ||
29 | int cgit_nocache = 0; | 29 | int cgit_nocache = 0; |
30 | int cgit_snapshots = 0; | 30 | int cgit_snapshots = 0; |
31 | int cgit_enable_index_links = 0; | 31 | int cgit_enable_index_links = 0; |
32 | int cgit_enable_log_filecount = 0; | 32 | int cgit_enable_log_filecount = 0; |
33 | int cgit_enable_log_linecount = 0; | 33 | int cgit_enable_log_linecount = 0; |
34 | int cgit_max_lock_attempts = 5; | 34 | int cgit_max_lock_attempts = 5; |
35 | int cgit_cache_root_ttl = 5; | 35 | int cgit_cache_root_ttl = 5; |
36 | int cgit_cache_repo_ttl = 5; | 36 | int cgit_cache_repo_ttl = 5; |
37 | int cgit_cache_dynamic_ttl = 5; | 37 | int cgit_cache_dynamic_ttl = 5; |
38 | int cgit_cache_static_ttl = -1; | 38 | int cgit_cache_static_ttl = -1; |
39 | int cgit_cache_max_create_time = 5; | 39 | int cgit_cache_max_create_time = 5; |
40 | int cgit_summary_log = 0; | 40 | int cgit_summary_log = 0; |
41 | int cgit_summary_tags = 0; | 41 | int cgit_summary_tags = 0; |
42 | int cgit_summary_branches = 0; | 42 | int cgit_summary_branches = 0; |
43 | int cgit_renamelimit = -1; | 43 | int cgit_renamelimit = -1; |
44 | 44 | ||
45 | int cgit_max_msg_len = 60; | 45 | int cgit_max_msg_len = 60; |
46 | int cgit_max_repodesc_len = 60; | 46 | int cgit_max_repodesc_len = 60; |
47 | int cgit_max_commit_count = 50; | 47 | int cgit_max_commit_count = 50; |
48 | 48 | ||
49 | int cgit_query_has_symref = 0; | 49 | int cgit_query_has_symref = 0; |
50 | int cgit_query_has_sha1 = 0; | 50 | int cgit_query_has_sha1 = 0; |
51 | 51 | ||
52 | char *cgit_querystring = NULL; | 52 | char *cgit_querystring = NULL; |
53 | char *cgit_query_repo = NULL; | 53 | char *cgit_query_repo = NULL; |
54 | char *cgit_query_page = NULL; | 54 | char *cgit_query_page = NULL; |
55 | char *cgit_query_head = NULL; | 55 | char *cgit_query_head = NULL; |
56 | char *cgit_query_search = NULL; | 56 | char *cgit_query_search = NULL; |
57 | char *cgit_query_grep = NULL; | ||
57 | char *cgit_query_sha1 = NULL; | 58 | char *cgit_query_sha1 = NULL; |
58 | char *cgit_query_sha2 = NULL; | 59 | char *cgit_query_sha2 = NULL; |
59 | char *cgit_query_path = NULL; | 60 | char *cgit_query_path = NULL; |
60 | char *cgit_query_name = NULL; | 61 | char *cgit_query_name = NULL; |
61 | int cgit_query_ofs = 0; | 62 | int cgit_query_ofs = 0; |
62 | 63 | ||
63 | int htmlfd = 0; | 64 | int htmlfd = 0; |
64 | 65 | ||
65 | 66 | ||
66 | int cgit_get_cmd_index(const char *cmd) | 67 | int cgit_get_cmd_index(const char *cmd) |
67 | { | 68 | { |
68 | static char *cmds[] = {"log", "commit", "diff", "tree", "blob", | 69 | static char *cmds[] = {"log", "commit", "diff", "tree", "blob", |
69 | "snapshot", "tag", "refs", NULL}; | 70 | "snapshot", "tag", "refs", NULL}; |
70 | int i; | 71 | int i; |
71 | 72 | ||
72 | for(i = 0; cmds[i]; i++) | 73 | for(i = 0; cmds[i]; i++) |
73 | if (!strcmp(cmd, cmds[i])) | 74 | if (!strcmp(cmd, cmds[i])) |
74 | return i + 1; | 75 | return i + 1; |
75 | return 0; | 76 | return 0; |
76 | } | 77 | } |
77 | 78 | ||
78 | int chk_zero(int result, char *msg) | 79 | int chk_zero(int result, char *msg) |
79 | { | 80 | { |
80 | if (result != 0) | 81 | if (result != 0) |
81 | die("%s: %s", msg, strerror(errno)); | 82 | die("%s: %s", msg, strerror(errno)); |
82 | return result; | 83 | return result; |
83 | } | 84 | } |
84 | 85 | ||
85 | int chk_positive(int result, char *msg) | 86 | int chk_positive(int result, char *msg) |
86 | { | 87 | { |
87 | if (result <= 0) | 88 | if (result <= 0) |
88 | die("%s: %s", msg, strerror(errno)); | 89 | die("%s: %s", msg, strerror(errno)); |
89 | return result; | 90 | return result; |
90 | } | 91 | } |
91 | 92 | ||
92 | int chk_non_negative(int result, char *msg) | 93 | int chk_non_negative(int result, char *msg) |
93 | { | 94 | { |
94 | if (result < 0) | 95 | if (result < 0) |
95 | die("%s: %s",msg, strerror(errno)); | 96 | die("%s: %s",msg, strerror(errno)); |
96 | return result; | 97 | return result; |
97 | } | 98 | } |
98 | 99 | ||
99 | struct repoinfo *add_repo(const char *url) | 100 | struct repoinfo *add_repo(const char *url) |
100 | { | 101 | { |
101 | struct repoinfo *ret; | 102 | struct repoinfo *ret; |
102 | 103 | ||
103 | if (++cgit_repolist.count > cgit_repolist.length) { | 104 | if (++cgit_repolist.count > cgit_repolist.length) { |
104 | if (cgit_repolist.length == 0) | 105 | if (cgit_repolist.length == 0) |
105 | cgit_repolist.length = 8; | 106 | cgit_repolist.length = 8; |
106 | else | 107 | else |
107 | cgit_repolist.length *= 2; | 108 | cgit_repolist.length *= 2; |
108 | cgit_repolist.repos = xrealloc(cgit_repolist.repos, | 109 | cgit_repolist.repos = xrealloc(cgit_repolist.repos, |
109 | cgit_repolist.length * | 110 | cgit_repolist.length * |
110 | sizeof(struct repoinfo)); | 111 | sizeof(struct repoinfo)); |
111 | } | 112 | } |
112 | 113 | ||
113 | ret = &cgit_repolist.repos[cgit_repolist.count-1]; | 114 | ret = &cgit_repolist.repos[cgit_repolist.count-1]; |
114 | ret->url = trim_end(url, '/'); | 115 | ret->url = trim_end(url, '/'); |
115 | ret->name = ret->url; | 116 | ret->name = ret->url; |
116 | ret->path = NULL; | 117 | ret->path = NULL; |
117 | ret->desc = NULL; | 118 | ret->desc = NULL; |
118 | ret->owner = NULL; | 119 | ret->owner = NULL; |
119 | ret->group = cgit_repo_group; | 120 | ret->group = cgit_repo_group; |
120 | ret->defbranch = "master"; | 121 | ret->defbranch = "master"; |
121 | ret->snapshots = cgit_snapshots; | 122 | ret->snapshots = cgit_snapshots; |
122 | ret->enable_log_filecount = cgit_enable_log_filecount; | 123 | ret->enable_log_filecount = cgit_enable_log_filecount; |
123 | ret->enable_log_linecount = cgit_enable_log_linecount; | 124 | ret->enable_log_linecount = cgit_enable_log_linecount; |
124 | ret->module_link = cgit_module_link; | 125 | ret->module_link = cgit_module_link; |
125 | ret->readme = NULL; | 126 | ret->readme = NULL; |
126 | return ret; | 127 | return ret; |
127 | } | 128 | } |
128 | 129 | ||
129 | struct repoinfo *cgit_get_repoinfo(const char *url) | 130 | struct repoinfo *cgit_get_repoinfo(const char *url) |
130 | { | 131 | { |
131 | int i; | 132 | int i; |
132 | struct repoinfo *repo; | 133 | struct repoinfo *repo; |
133 | 134 | ||
134 | for (i=0; i<cgit_repolist.count; i++) { | 135 | for (i=0; i<cgit_repolist.count; i++) { |
135 | repo = &cgit_repolist.repos[i]; | 136 | repo = &cgit_repolist.repos[i]; |
136 | if (!strcmp(repo->url, url)) | 137 | if (!strcmp(repo->url, url)) |
137 | return repo; | 138 | return repo; |
138 | } | 139 | } |
139 | return NULL; | 140 | return NULL; |
140 | } | 141 | } |
141 | 142 | ||
142 | void cgit_global_config_cb(const char *name, const char *value) | 143 | void cgit_global_config_cb(const char *name, const char *value) |
143 | { | 144 | { |
144 | if (!strcmp(name, "root-title")) | 145 | if (!strcmp(name, "root-title")) |
145 | cgit_root_title = xstrdup(value); | 146 | cgit_root_title = xstrdup(value); |
146 | else if (!strcmp(name, "css")) | 147 | else if (!strcmp(name, "css")) |
147 | cgit_css = xstrdup(value); | 148 | cgit_css = xstrdup(value); |
148 | else if (!strcmp(name, "logo")) | 149 | else if (!strcmp(name, "logo")) |
149 | cgit_logo = xstrdup(value); | 150 | cgit_logo = xstrdup(value); |
150 | else if (!strcmp(name, "index-header")) | 151 | else if (!strcmp(name, "index-header")) |
151 | cgit_index_header = xstrdup(value); | 152 | cgit_index_header = xstrdup(value); |
152 | else if (!strcmp(name, "logo-link")) | 153 | else if (!strcmp(name, "logo-link")) |
153 | cgit_logo_link = xstrdup(value); | 154 | cgit_logo_link = xstrdup(value); |
154 | else if (!strcmp(name, "module-link")) | 155 | else if (!strcmp(name, "module-link")) |
155 | cgit_module_link = xstrdup(value); | 156 | cgit_module_link = xstrdup(value); |
156 | else if (!strcmp(name, "virtual-root")) | 157 | else if (!strcmp(name, "virtual-root")) |
157 | cgit_virtual_root = trim_end(value, '/'); | 158 | cgit_virtual_root = trim_end(value, '/'); |
158 | else if (!strcmp(name, "nocache")) | 159 | else if (!strcmp(name, "nocache")) |
159 | cgit_nocache = atoi(value); | 160 | cgit_nocache = atoi(value); |
160 | else if (!strcmp(name, "snapshots")) | 161 | else if (!strcmp(name, "snapshots")) |
161 | cgit_snapshots = cgit_parse_snapshots_mask(value); | 162 | cgit_snapshots = cgit_parse_snapshots_mask(value); |
162 | else if (!strcmp(name, "enable-index-links")) | 163 | else if (!strcmp(name, "enable-index-links")) |
163 | cgit_enable_index_links = atoi(value); | 164 | cgit_enable_index_links = atoi(value); |
164 | else if (!strcmp(name, "enable-log-filecount")) | 165 | else if (!strcmp(name, "enable-log-filecount")) |
165 | cgit_enable_log_filecount = atoi(value); | 166 | cgit_enable_log_filecount = atoi(value); |
166 | else if (!strcmp(name, "enable-log-linecount")) | 167 | else if (!strcmp(name, "enable-log-linecount")) |
167 | cgit_enable_log_linecount = atoi(value); | 168 | cgit_enable_log_linecount = atoi(value); |
168 | else if (!strcmp(name, "cache-root")) | 169 | else if (!strcmp(name, "cache-root")) |
169 | cgit_cache_root = xstrdup(value); | 170 | cgit_cache_root = xstrdup(value); |
170 | else if (!strcmp(name, "cache-root-ttl")) | 171 | else if (!strcmp(name, "cache-root-ttl")) |
171 | cgit_cache_root_ttl = atoi(value); | 172 | cgit_cache_root_ttl = atoi(value); |
172 | else if (!strcmp(name, "cache-repo-ttl")) | 173 | else if (!strcmp(name, "cache-repo-ttl")) |
173 | cgit_cache_repo_ttl = atoi(value); | 174 | cgit_cache_repo_ttl = atoi(value); |
174 | else if (!strcmp(name, "cache-static-ttl")) | 175 | else if (!strcmp(name, "cache-static-ttl")) |
175 | cgit_cache_static_ttl = atoi(value); | 176 | cgit_cache_static_ttl = atoi(value); |
176 | else if (!strcmp(name, "cache-dynamic-ttl")) | 177 | else if (!strcmp(name, "cache-dynamic-ttl")) |
177 | cgit_cache_dynamic_ttl = atoi(value); | 178 | cgit_cache_dynamic_ttl = atoi(value); |
178 | else if (!strcmp(name, "max-message-length")) | 179 | else if (!strcmp(name, "max-message-length")) |
179 | cgit_max_msg_len = atoi(value); | 180 | cgit_max_msg_len = atoi(value); |
180 | else if (!strcmp(name, "max-repodesc-length")) | 181 | else if (!strcmp(name, "max-repodesc-length")) |
181 | cgit_max_repodesc_len = atoi(value); | 182 | cgit_max_repodesc_len = atoi(value); |
182 | else if (!strcmp(name, "max-commit-count")) | 183 | else if (!strcmp(name, "max-commit-count")) |
183 | cgit_max_commit_count = atoi(value); | 184 | cgit_max_commit_count = atoi(value); |
184 | else if (!strcmp(name, "summary-log")) | 185 | else if (!strcmp(name, "summary-log")) |
185 | cgit_summary_log = atoi(value); | 186 | cgit_summary_log = atoi(value); |
186 | else if (!strcmp(name, "summary-branches")) | 187 | else if (!strcmp(name, "summary-branches")) |
187 | cgit_summary_branches = atoi(value); | 188 | cgit_summary_branches = atoi(value); |
188 | else if (!strcmp(name, "summary-tags")) | 189 | else if (!strcmp(name, "summary-tags")) |
189 | cgit_summary_tags = atoi(value); | 190 | cgit_summary_tags = atoi(value); |
190 | else if (!strcmp(name, "agefile")) | 191 | else if (!strcmp(name, "agefile")) |
191 | cgit_agefile = xstrdup(value); | 192 | cgit_agefile = xstrdup(value); |
192 | else if (!strcmp(name, "renamelimit")) | 193 | else if (!strcmp(name, "renamelimit")) |
193 | cgit_renamelimit = atoi(value); | 194 | cgit_renamelimit = atoi(value); |
194 | else if (!strcmp(name, "repo.group")) | 195 | else if (!strcmp(name, "repo.group")) |
195 | cgit_repo_group = xstrdup(value); | 196 | cgit_repo_group = xstrdup(value); |
196 | else if (!strcmp(name, "repo.url")) | 197 | else if (!strcmp(name, "repo.url")) |
197 | cgit_repo = add_repo(value); | 198 | cgit_repo = add_repo(value); |
198 | else if (!strcmp(name, "repo.name")) | 199 | else if (!strcmp(name, "repo.name")) |
199 | cgit_repo->name = xstrdup(value); | 200 | cgit_repo->name = xstrdup(value); |
200 | else if (cgit_repo && !strcmp(name, "repo.path")) | 201 | else if (cgit_repo && !strcmp(name, "repo.path")) |
201 | cgit_repo->path = trim_end(value, '/'); | 202 | cgit_repo->path = trim_end(value, '/'); |
202 | else if (cgit_repo && !strcmp(name, "repo.desc")) | 203 | else if (cgit_repo && !strcmp(name, "repo.desc")) |
203 | cgit_repo->desc = xstrdup(value); | 204 | cgit_repo->desc = xstrdup(value); |
204 | else if (cgit_repo && !strcmp(name, "repo.owner")) | 205 | else if (cgit_repo && !strcmp(name, "repo.owner")) |
205 | cgit_repo->owner = xstrdup(value); | 206 | cgit_repo->owner = xstrdup(value); |
206 | else if (cgit_repo && !strcmp(name, "repo.defbranch")) | 207 | else if (cgit_repo && !strcmp(name, "repo.defbranch")) |
207 | cgit_repo->defbranch = xstrdup(value); | 208 | cgit_repo->defbranch = xstrdup(value); |
208 | else if (cgit_repo && !strcmp(name, "repo.snapshots")) | 209 | else if (cgit_repo && !strcmp(name, "repo.snapshots")) |
209 | cgit_repo->snapshots = cgit_snapshots & cgit_parse_snapshots_mask(value); /* XXX: &? */ | 210 | cgit_repo->snapshots = cgit_snapshots & cgit_parse_snapshots_mask(value); /* XXX: &? */ |
210 | else if (cgit_repo && !strcmp(name, "repo.enable-log-filecount")) | 211 | else if (cgit_repo && !strcmp(name, "repo.enable-log-filecount")) |
211 | cgit_repo->enable_log_filecount = cgit_enable_log_filecount * atoi(value); | 212 | cgit_repo->enable_log_filecount = cgit_enable_log_filecount * atoi(value); |
212 | else if (cgit_repo && !strcmp(name, "repo.enable-log-linecount")) | 213 | else if (cgit_repo && !strcmp(name, "repo.enable-log-linecount")) |
213 | cgit_repo->enable_log_linecount = cgit_enable_log_linecount * atoi(value); | 214 | cgit_repo->enable_log_linecount = cgit_enable_log_linecount * atoi(value); |
214 | else if (cgit_repo && !strcmp(name, "repo.module-link")) | 215 | else if (cgit_repo && !strcmp(name, "repo.module-link")) |
215 | cgit_repo->module_link= xstrdup(value); | 216 | cgit_repo->module_link= xstrdup(value); |
216 | else if (cgit_repo && !strcmp(name, "repo.readme") && value != NULL) { | 217 | else if (cgit_repo && !strcmp(name, "repo.readme") && value != NULL) { |
217 | if (*value == '/') | 218 | if (*value == '/') |
218 | cgit_repo->readme = xstrdup(value); | 219 | cgit_repo->readme = xstrdup(value); |
219 | else | 220 | else |
220 | cgit_repo->readme = xstrdup(fmt("%s/%s", cgit_repo->path, value)); | 221 | cgit_repo->readme = xstrdup(fmt("%s/%s", cgit_repo->path, value)); |
221 | } else if (!strcmp(name, "include")) | 222 | } else if (!strcmp(name, "include")) |
222 | cgit_read_config(value, cgit_global_config_cb); | 223 | cgit_read_config(value, cgit_global_config_cb); |
223 | } | 224 | } |
224 | 225 | ||
225 | void cgit_querystring_cb(const char *name, const char *value) | 226 | void cgit_querystring_cb(const char *name, const char *value) |
226 | { | 227 | { |
227 | if (!strcmp(name,"r")) { | 228 | if (!strcmp(name,"r")) { |
228 | cgit_query_repo = xstrdup(value); | 229 | cgit_query_repo = xstrdup(value); |
229 | cgit_repo = cgit_get_repoinfo(value); | 230 | cgit_repo = cgit_get_repoinfo(value); |
230 | } else if (!strcmp(name, "p")) { | 231 | } else if (!strcmp(name, "p")) { |
231 | cgit_query_page = xstrdup(value); | 232 | cgit_query_page = xstrdup(value); |
232 | cgit_cmd = cgit_get_cmd_index(value); | 233 | cgit_cmd = cgit_get_cmd_index(value); |
233 | } else if (!strcmp(name, "url")) { | 234 | } else if (!strcmp(name, "url")) { |
234 | cgit_parse_url(value); | 235 | cgit_parse_url(value); |
236 | } else if (!strcmp(name, "qt")) { | ||
237 | cgit_query_grep = xstrdup(value); | ||
235 | } else if (!strcmp(name, "q")) { | 238 | } else if (!strcmp(name, "q")) { |
236 | cgit_query_search = xstrdup(value); | 239 | cgit_query_search = xstrdup(value); |
237 | } else if (!strcmp(name, "h")) { | 240 | } else if (!strcmp(name, "h")) { |
238 | cgit_query_head = xstrdup(value); | 241 | cgit_query_head = xstrdup(value); |
239 | cgit_query_has_symref = 1; | 242 | cgit_query_has_symref = 1; |
240 | } else if (!strcmp(name, "id")) { | 243 | } else if (!strcmp(name, "id")) { |
241 | cgit_query_sha1 = xstrdup(value); | 244 | cgit_query_sha1 = xstrdup(value); |
242 | cgit_query_has_sha1 = 1; | 245 | cgit_query_has_sha1 = 1; |
243 | } else if (!strcmp(name, "id2")) { | 246 | } else if (!strcmp(name, "id2")) { |
244 | cgit_query_sha2 = xstrdup(value); | 247 | cgit_query_sha2 = xstrdup(value); |
245 | cgit_query_has_sha1 = 1; | 248 | cgit_query_has_sha1 = 1; |
246 | } else if (!strcmp(name, "ofs")) { | 249 | } else if (!strcmp(name, "ofs")) { |
247 | cgit_query_ofs = atoi(value); | 250 | cgit_query_ofs = atoi(value); |
248 | } else if (!strcmp(name, "path")) { | 251 | } else if (!strcmp(name, "path")) { |
249 | cgit_query_path = trim_end(value, '/'); | 252 | cgit_query_path = trim_end(value, '/'); |
250 | } else if (!strcmp(name, "name")) { | 253 | } else if (!strcmp(name, "name")) { |
251 | cgit_query_name = xstrdup(value); | 254 | cgit_query_name = xstrdup(value); |
252 | } | 255 | } |
253 | } | 256 | } |
254 | 257 | ||
255 | void *cgit_free_commitinfo(struct commitinfo *info) | 258 | void *cgit_free_commitinfo(struct commitinfo *info) |
256 | { | 259 | { |
257 | free(info->author); | 260 | free(info->author); |
258 | free(info->author_email); | 261 | free(info->author_email); |
259 | free(info->committer); | 262 | free(info->committer); |
260 | free(info->committer_email); | 263 | free(info->committer_email); |
261 | free(info->subject); | 264 | free(info->subject); |
262 | free(info); | 265 | free(info); |
263 | return NULL; | 266 | return NULL; |
264 | } | 267 | } |
265 | 268 | ||
266 | int hextoint(char c) | 269 | int hextoint(char c) |
267 | { | 270 | { |
268 | if (c >= 'a' && c <= 'f') | 271 | if (c >= 'a' && c <= 'f') |
269 | return 10 + c - 'a'; | 272 | return 10 + c - 'a'; |
270 | else if (c >= 'A' && c <= 'F') | 273 | else if (c >= 'A' && c <= 'F') |
271 | return 10 + c - 'A'; | 274 | return 10 + c - 'A'; |
272 | else if (c >= '0' && c <= '9') | 275 | else if (c >= '0' && c <= '9') |
273 | return c - '0'; | 276 | return c - '0'; |
274 | else | 277 | else |
275 | return -1; | 278 | return -1; |
276 | } | 279 | } |
277 | 280 | ||
278 | char *trim_end(const char *str, char c) | 281 | char *trim_end(const char *str, char c) |
279 | { | 282 | { |
280 | int len; | 283 | int len; |
281 | char *s, *t; | 284 | char *s, *t; |
282 | 285 | ||
283 | if (str == NULL) | 286 | if (str == NULL) |
284 | return NULL; | 287 | return NULL; |
285 | t = (char *)str; | 288 | t = (char *)str; |
286 | len = strlen(t); | 289 | len = strlen(t); |
287 | while(len > 0 && t[len - 1] == c) | 290 | while(len > 0 && t[len - 1] == c) |
288 | len--; | 291 | len--; |
289 | 292 | ||
290 | if (len == 0) | 293 | if (len == 0) |
291 | return NULL; | 294 | return NULL; |
292 | 295 | ||
293 | c = t[len]; | 296 | c = t[len]; |
294 | t[len] = '\0'; | 297 | t[len] = '\0'; |
295 | s = xstrdup(t); | 298 | s = xstrdup(t); |
296 | t[len] = c; | 299 | t[len] = c; |
297 | return s; | 300 | return s; |
298 | } | 301 | } |
299 | 302 | ||
300 | void cgit_add_ref(struct reflist *list, struct refinfo *ref) | 303 | void cgit_add_ref(struct reflist *list, struct refinfo *ref) |
301 | { | 304 | { |
302 | size_t size; | 305 | size_t size; |
303 | 306 | ||
304 | if (list->count >= list->alloc) { | 307 | if (list->count >= list->alloc) { |
305 | list->alloc += (list->alloc ? list->alloc : 4); | 308 | list->alloc += (list->alloc ? list->alloc : 4); |
306 | size = list->alloc * sizeof(struct refinfo *); | 309 | size = list->alloc * sizeof(struct refinfo *); |
307 | list->refs = xrealloc(list->refs, size); | 310 | list->refs = xrealloc(list->refs, size); |
308 | } | 311 | } |
309 | list->refs[list->count++] = ref; | 312 | list->refs[list->count++] = ref; |
310 | } | 313 | } |
311 | 314 | ||
312 | struct refinfo *cgit_mk_refinfo(const char *refname, const unsigned char *sha1) | 315 | struct refinfo *cgit_mk_refinfo(const char *refname, const unsigned char *sha1) |
313 | { | 316 | { |
314 | struct refinfo *ref; | 317 | struct refinfo *ref; |
315 | 318 | ||
316 | ref = xmalloc(sizeof (struct refinfo)); | 319 | ref = xmalloc(sizeof (struct refinfo)); |
317 | ref->refname = xstrdup(refname); | 320 | ref->refname = xstrdup(refname); |
318 | ref->object = parse_object(sha1); | 321 | ref->object = parse_object(sha1); |
319 | switch (ref->object->type) { | 322 | switch (ref->object->type) { |
320 | case OBJ_TAG: | 323 | case OBJ_TAG: |
321 | ref->tag = cgit_parse_tag((struct tag *)ref->object); | 324 | ref->tag = cgit_parse_tag((struct tag *)ref->object); |
322 | break; | 325 | break; |
323 | case OBJ_COMMIT: | 326 | case OBJ_COMMIT: |
324 | ref->commit = cgit_parse_commit((struct commit *)ref->object); | 327 | ref->commit = cgit_parse_commit((struct commit *)ref->object); |
325 | break; | 328 | break; |
326 | } | 329 | } |
327 | return ref; | 330 | return ref; |
328 | } | 331 | } |
329 | 332 | ||
330 | int cgit_refs_cb(const char *refname, const unsigned char *sha1, int flags, | 333 | int cgit_refs_cb(const char *refname, const unsigned char *sha1, int flags, |
@@ -1,128 +1,131 @@ | |||
1 | /* ui-log.c: functions for log output | 1 | /* ui-log.c: functions for log output |
2 | * | 2 | * |
3 | * Copyright (C) 2006 Lars Hjemli | 3 | * Copyright (C) 2006 Lars Hjemli |
4 | * | 4 | * |
5 | * Licensed under GNU General Public License v2 | 5 | * Licensed under GNU General Public License v2 |
6 | * (see COPYING for full license text) | 6 | * (see COPYING for full license text) |
7 | */ | 7 | */ |
8 | 8 | ||
9 | #include "cgit.h" | 9 | #include "cgit.h" |
10 | 10 | ||
11 | int files, lines; | 11 | int files, lines; |
12 | 12 | ||
13 | void count_lines(char *line, int size) | 13 | void count_lines(char *line, int size) |
14 | { | 14 | { |
15 | if (size>0 && (line[0] == '+' || line[0] == '-')) | 15 | if (size>0 && (line[0] == '+' || line[0] == '-')) |
16 | lines++; | 16 | lines++; |
17 | } | 17 | } |
18 | 18 | ||
19 | void inspect_files(struct diff_filepair *pair) | 19 | void inspect_files(struct diff_filepair *pair) |
20 | { | 20 | { |
21 | files++; | 21 | files++; |
22 | if (cgit_repo->enable_log_linecount) | 22 | if (cgit_repo->enable_log_linecount) |
23 | cgit_diff_files(pair->one->sha1, pair->two->sha1, count_lines); | 23 | cgit_diff_files(pair->one->sha1, pair->two->sha1, count_lines); |
24 | } | 24 | } |
25 | 25 | ||
26 | void print_commit(struct commit *commit) | 26 | void print_commit(struct commit *commit) |
27 | { | 27 | { |
28 | struct commitinfo *info; | 28 | struct commitinfo *info; |
29 | 29 | ||
30 | info = cgit_parse_commit(commit); | 30 | info = cgit_parse_commit(commit); |
31 | html("<tr><td>"); | 31 | html("<tr><td>"); |
32 | cgit_print_age(commit->date, TM_WEEK * 2, FMT_SHORTDATE); | 32 | cgit_print_age(commit->date, TM_WEEK * 2, FMT_SHORTDATE); |
33 | html("</td><td>"); | 33 | html("</td><td>"); |
34 | cgit_commit_link(info->subject, NULL, NULL, cgit_query_head, | 34 | cgit_commit_link(info->subject, NULL, NULL, cgit_query_head, |
35 | sha1_to_hex(commit->object.sha1)); | 35 | sha1_to_hex(commit->object.sha1)); |
36 | if (cgit_repo->enable_log_filecount) { | 36 | if (cgit_repo->enable_log_filecount) { |
37 | files = 0; | 37 | files = 0; |
38 | lines = 0; | 38 | lines = 0; |
39 | cgit_diff_commit(commit, inspect_files); | 39 | cgit_diff_commit(commit, inspect_files); |
40 | html("</td><td class='right'>"); | 40 | html("</td><td class='right'>"); |
41 | htmlf("%d", files); | 41 | htmlf("%d", files); |
42 | if (cgit_repo->enable_log_linecount) { | 42 | if (cgit_repo->enable_log_linecount) { |
43 | html("</td><td class='right'>"); | 43 | html("</td><td class='right'>"); |
44 | htmlf("%d", lines); | 44 | htmlf("%d", lines); |
45 | } | 45 | } |
46 | } | 46 | } |
47 | html("</td><td>"); | 47 | html("</td><td>"); |
48 | html_txt(info->author); | 48 | html_txt(info->author); |
49 | html("</td></tr>\n"); | 49 | html("</td></tr>\n"); |
50 | cgit_free_commitinfo(info); | 50 | cgit_free_commitinfo(info); |
51 | } | 51 | } |
52 | 52 | ||
53 | 53 | ||
54 | void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *path, int pager) | 54 | void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern, char *path, int pager) |
55 | { | 55 | { |
56 | struct rev_info rev; | 56 | struct rev_info rev; |
57 | struct commit *commit; | 57 | struct commit *commit; |
58 | const char *argv[] = {NULL, tip, NULL, NULL, NULL}; | 58 | const char *argv[] = {NULL, tip, NULL, NULL, NULL}; |
59 | int argc = 2; | 59 | int argc = 2; |
60 | int i; | 60 | int i; |
61 | 61 | ||
62 | if (!tip) | 62 | if (!tip) |
63 | argv[1] = cgit_query_head; | 63 | argv[1] = cgit_query_head; |
64 | 64 | ||
65 | if (grep) | 65 | if (grep && pattern && (!strcmp(grep, "grep") || |
66 | argv[argc++] = fmt("--grep=%s", grep); | 66 | !strcmp(grep, "author") || |
67 | !strcmp(grep, "committer"))) | ||
68 | argv[argc++] = fmt("--%s=%s", grep, pattern); | ||
69 | |||
67 | if (path) { | 70 | if (path) { |
68 | argv[argc++] = "--"; | 71 | argv[argc++] = "--"; |
69 | argv[argc++] = path; | 72 | argv[argc++] = path; |
70 | } | 73 | } |
71 | init_revisions(&rev, NULL); | 74 | init_revisions(&rev, NULL); |
72 | rev.abbrev = DEFAULT_ABBREV; | 75 | rev.abbrev = DEFAULT_ABBREV; |
73 | rev.commit_format = CMIT_FMT_DEFAULT; | 76 | rev.commit_format = CMIT_FMT_DEFAULT; |
74 | rev.verbose_header = 1; | 77 | rev.verbose_header = 1; |
75 | rev.show_root_diff = 0; | 78 | rev.show_root_diff = 0; |
76 | setup_revisions(argc, argv, &rev, NULL); | 79 | setup_revisions(argc, argv, &rev, NULL); |
77 | if (rev.grep_filter) { | 80 | if (rev.grep_filter) { |
78 | rev.grep_filter->regflags |= REG_ICASE; | 81 | rev.grep_filter->regflags |= REG_ICASE; |
79 | compile_grep_patterns(rev.grep_filter); | 82 | compile_grep_patterns(rev.grep_filter); |
80 | } | 83 | } |
81 | prepare_revision_walk(&rev); | 84 | prepare_revision_walk(&rev); |
82 | 85 | ||
83 | html("<table class='list nowrap'>"); | 86 | html("<table class='list nowrap'>"); |
84 | html("<tr class='nohover'><th class='left'>Age</th>" | 87 | html("<tr class='nohover'><th class='left'>Age</th>" |
85 | "<th class='left'>Message</th>"); | 88 | "<th class='left'>Message</th>"); |
86 | 89 | ||
87 | if (cgit_repo->enable_log_filecount) { | 90 | if (cgit_repo->enable_log_filecount) { |
88 | html("<th class='left'>Files</th>"); | 91 | html("<th class='left'>Files</th>"); |
89 | if (cgit_repo->enable_log_linecount) | 92 | if (cgit_repo->enable_log_linecount) |
90 | html("<th class='left'>Lines</th>"); | 93 | html("<th class='left'>Lines</th>"); |
91 | } | 94 | } |
92 | html("<th class='left'>Author</th></tr>\n"); | 95 | html("<th class='left'>Author</th></tr>\n"); |
93 | 96 | ||
94 | if (ofs<0) | 97 | if (ofs<0) |
95 | ofs = 0; | 98 | ofs = 0; |
96 | 99 | ||
97 | for (i = 0; i < ofs && (commit = get_revision(&rev)) != NULL; i++) { | 100 | for (i = 0; i < ofs && (commit = get_revision(&rev)) != NULL; i++) { |
98 | free(commit->buffer); | 101 | free(commit->buffer); |
99 | commit->buffer = NULL; | 102 | commit->buffer = NULL; |
100 | free_commit_list(commit->parents); | 103 | free_commit_list(commit->parents); |
101 | commit->parents = NULL; | 104 | commit->parents = NULL; |
102 | } | 105 | } |
103 | 106 | ||
104 | for (i = 0; i < cnt && (commit = get_revision(&rev)) != NULL; i++) { | 107 | for (i = 0; i < cnt && (commit = get_revision(&rev)) != NULL; i++) { |
105 | print_commit(commit); | 108 | print_commit(commit); |
106 | free(commit->buffer); | 109 | free(commit->buffer); |
107 | commit->buffer = NULL; | 110 | commit->buffer = NULL; |
108 | free_commit_list(commit->parents); | 111 | free_commit_list(commit->parents); |
109 | commit->parents = NULL; | 112 | commit->parents = NULL; |
110 | } | 113 | } |
111 | html("</table>\n"); | 114 | html("</table>\n"); |
112 | 115 | ||
113 | if (pager) { | 116 | if (pager) { |
114 | html("<div class='pager'>"); | 117 | html("<div class='pager'>"); |
115 | if (ofs > 0) { | 118 | if (ofs > 0) { |
116 | cgit_log_link("[prev]", NULL, NULL, cgit_query_head, | 119 | cgit_log_link("[prev]", NULL, NULL, cgit_query_head, |
117 | cgit_query_sha1, cgit_query_path, | 120 | cgit_query_sha1, cgit_query_path, |
118 | ofs - cnt); | 121 | ofs - cnt); |
119 | html(" "); | 122 | html(" "); |
120 | } | 123 | } |
121 | if ((commit = get_revision(&rev)) != NULL) { | 124 | if ((commit = get_revision(&rev)) != NULL) { |
122 | cgit_log_link("[next]", NULL, NULL, cgit_query_head, | 125 | cgit_log_link("[next]", NULL, NULL, cgit_query_head, |
123 | cgit_query_sha1, cgit_query_path, | 126 | cgit_query_sha1, cgit_query_path, |
124 | ofs + cnt); | 127 | ofs + cnt); |
125 | } | 128 | } |
126 | html("</div>"); | 129 | html("</div>"); |
127 | } | 130 | } |
128 | } | 131 | } |
diff --git a/ui-shared.c b/ui-shared.c index e4bb98f..45105dc 100644 --- a/ui-shared.c +++ b/ui-shared.c | |||
@@ -324,116 +324,121 @@ void cgit_print_age(time_t t, time_t max_relative, char *format) | |||
324 | } | 324 | } |
325 | if (secs < TM_MONTH * 2) { | 325 | if (secs < TM_MONTH * 2) { |
326 | htmlf("<span class='age-weeks'>%.0f weeks</span>", | 326 | htmlf("<span class='age-weeks'>%.0f weeks</span>", |
327 | secs * 1.0 / TM_WEEK); | 327 | secs * 1.0 / TM_WEEK); |
328 | return; | 328 | return; |
329 | } | 329 | } |
330 | if (secs < TM_YEAR * 2) { | 330 | if (secs < TM_YEAR * 2) { |
331 | htmlf("<span class='age-months'>%.0f months</span>", | 331 | htmlf("<span class='age-months'>%.0f months</span>", |
332 | secs * 1.0 / TM_MONTH); | 332 | secs * 1.0 / TM_MONTH); |
333 | return; | 333 | return; |
334 | } | 334 | } |
335 | htmlf("<span class='age-years'>%.0f years</span>", | 335 | htmlf("<span class='age-years'>%.0f years</span>", |
336 | secs * 1.0 / TM_YEAR); | 336 | secs * 1.0 / TM_YEAR); |
337 | } | 337 | } |
338 | 338 | ||
339 | void cgit_print_docstart(char *title, struct cacheitem *item) | 339 | void cgit_print_docstart(char *title, struct cacheitem *item) |
340 | { | 340 | { |
341 | html("Content-Type: text/html; charset=utf-8\n"); | 341 | html("Content-Type: text/html; charset=utf-8\n"); |
342 | htmlf("Last-Modified: %s\n", http_date(item->st.st_mtime)); | 342 | htmlf("Last-Modified: %s\n", http_date(item->st.st_mtime)); |
343 | htmlf("Expires: %s\n", http_date(item->st.st_mtime + | 343 | htmlf("Expires: %s\n", http_date(item->st.st_mtime + |
344 | ttl_seconds(item->ttl))); | 344 | ttl_seconds(item->ttl))); |
345 | html("\n"); | 345 | html("\n"); |
346 | html(cgit_doctype); | 346 | html(cgit_doctype); |
347 | html("<html>\n"); | 347 | html("<html>\n"); |
348 | html("<head>\n"); | 348 | html("<head>\n"); |
349 | html("<title>"); | 349 | html("<title>"); |
350 | html_txt(title); | 350 | html_txt(title); |
351 | html("</title>\n"); | 351 | html("</title>\n"); |
352 | htmlf("<meta name='generator' content='cgit %s'/>\n", cgit_version); | 352 | htmlf("<meta name='generator' content='cgit %s'/>\n", cgit_version); |
353 | html("<link rel='stylesheet' type='text/css' href='"); | 353 | html("<link rel='stylesheet' type='text/css' href='"); |
354 | html_attr(cgit_css); | 354 | html_attr(cgit_css); |
355 | html("'/>\n"); | 355 | html("'/>\n"); |
356 | html("</head>\n"); | 356 | html("</head>\n"); |
357 | html("<body>\n"); | 357 | html("<body>\n"); |
358 | } | 358 | } |
359 | 359 | ||
360 | void cgit_print_docend() | 360 | void cgit_print_docend() |
361 | { | 361 | { |
362 | html("</td></tr></table>"); | 362 | html("</td></tr></table>"); |
363 | html("</body>\n</html>\n"); | 363 | html("</body>\n</html>\n"); |
364 | } | 364 | } |
365 | 365 | ||
366 | void cgit_print_pageheader(char *title, int show_search) | 366 | void cgit_print_pageheader(char *title, int show_search) |
367 | { | 367 | { |
368 | html("<table id='layout'>"); | 368 | html("<table id='layout'>"); |
369 | html("<tr><td id='header'><a href='"); | 369 | html("<tr><td id='header'><a href='"); |
370 | html_attr(cgit_rooturl()); | 370 | html_attr(cgit_rooturl()); |
371 | html("'>"); | 371 | html("'>"); |
372 | html_txt(cgit_root_title); | 372 | html_txt(cgit_root_title); |
373 | html("</a></td><td id='logo'>"); | 373 | html("</a></td><td id='logo'>"); |
374 | html("<a href='"); | 374 | html("<a href='"); |
375 | html_attr(cgit_logo_link); | 375 | html_attr(cgit_logo_link); |
376 | htmlf("'><img src='%s' alt='logo'/></a>", cgit_logo); | 376 | htmlf("'><img src='%s' alt='logo'/></a>", cgit_logo); |
377 | html("</td></tr>"); | 377 | html("</td></tr>"); |
378 | html("<tr><td id='crumb'>"); | 378 | html("<tr><td id='crumb'>"); |
379 | if (cgit_query_repo) { | 379 | if (cgit_query_repo) { |
380 | html_txt(cgit_repo->name); | 380 | html_txt(cgit_repo->name); |
381 | html(" ("); | 381 | html(" ("); |
382 | html_txt(cgit_query_head); | 382 | html_txt(cgit_query_head); |
383 | html(") : "); | 383 | html(") : "); |
384 | reporevlink(NULL, "summary", NULL, NULL, cgit_query_head, | 384 | reporevlink(NULL, "summary", NULL, NULL, cgit_query_head, |
385 | NULL, NULL); | 385 | NULL, NULL); |
386 | html(" "); | 386 | html(" "); |
387 | cgit_log_link("log", NULL, NULL, cgit_query_head, | 387 | cgit_log_link("log", NULL, NULL, cgit_query_head, |
388 | cgit_query_sha1, cgit_query_path, 0); | 388 | cgit_query_sha1, cgit_query_path, 0); |
389 | html(" "); | 389 | html(" "); |
390 | cgit_tree_link("tree", NULL, NULL, cgit_query_head, | 390 | cgit_tree_link("tree", NULL, NULL, cgit_query_head, |
391 | cgit_query_sha1, NULL); | 391 | cgit_query_sha1, NULL); |
392 | html(" "); | 392 | html(" "); |
393 | cgit_commit_link("commit", NULL, NULL, cgit_query_head, | 393 | cgit_commit_link("commit", NULL, NULL, cgit_query_head, |
394 | cgit_query_sha1); | 394 | cgit_query_sha1); |
395 | html(" "); | 395 | html(" "); |
396 | cgit_diff_link("diff", NULL, NULL, cgit_query_head, | 396 | cgit_diff_link("diff", NULL, NULL, cgit_query_head, |
397 | cgit_query_sha1, cgit_query_sha2, | 397 | cgit_query_sha1, cgit_query_sha2, |
398 | cgit_query_path); | 398 | cgit_query_path); |
399 | } else { | 399 | } else { |
400 | html_txt("Index of repositories"); | 400 | html_txt("Index of repositories"); |
401 | } | 401 | } |
402 | html("</td>"); | 402 | html("</td>"); |
403 | html("<td id='search'>"); | 403 | html("<td id='search'>"); |
404 | if (show_search) { | 404 | if (show_search) { |
405 | html("<form method='get' action='"); | 405 | html("<form method='get' action='"); |
406 | html_attr(cgit_currurl()); | 406 | html_attr(cgit_currurl()); |
407 | html("'>"); | 407 | html("'>"); |
408 | if (!cgit_virtual_root) { | 408 | if (!cgit_virtual_root) { |
409 | if (cgit_query_repo) | 409 | if (cgit_query_repo) |
410 | html_hidden("r", cgit_query_repo); | 410 | html_hidden("r", cgit_query_repo); |
411 | if (cgit_query_page) | 411 | if (cgit_query_page) |
412 | html_hidden("p", cgit_query_page); | 412 | html_hidden("p", cgit_query_page); |
413 | } | 413 | } |
414 | if (cgit_query_head) | 414 | if (cgit_query_head) |
415 | html_hidden("h", cgit_query_head); | 415 | html_hidden("h", cgit_query_head); |
416 | if (cgit_query_sha1) | 416 | if (cgit_query_sha1) |
417 | html_hidden("id", cgit_query_sha1); | 417 | html_hidden("id", cgit_query_sha1); |
418 | if (cgit_query_sha2) | 418 | if (cgit_query_sha2) |
419 | html_hidden("id2", cgit_query_sha2); | 419 | html_hidden("id2", cgit_query_sha2); |
420 | html("<input type='text' name='q' value='"); | 420 | html("<select name='qt'>"); |
421 | html_option("grep", "log msg", cgit_query_grep); | ||
422 | html_option("author", "author", cgit_query_grep); | ||
423 | html_option("committer", "committer", cgit_query_grep); | ||
424 | html("</select>"); | ||
425 | html("<input class='txt' type='text' name='q' value='"); | ||
421 | html_attr(cgit_query_search); | 426 | html_attr(cgit_query_search); |
422 | html("'/></form>"); | 427 | html("'/><input class='btn' type='submit' value='...'/></form>"); |
423 | } | 428 | } |
424 | html("</td></tr>"); | 429 | html("</td></tr>"); |
425 | html("<tr><td id='content' colspan='2'>"); | 430 | html("<tr><td id='content' colspan='2'>"); |
426 | } | 431 | } |
427 | 432 | ||
428 | void cgit_print_snapshot_start(const char *mimetype, const char *filename, | 433 | void cgit_print_snapshot_start(const char *mimetype, const char *filename, |
429 | struct cacheitem *item) | 434 | struct cacheitem *item) |
430 | { | 435 | { |
431 | htmlf("Content-Type: %s\n", mimetype); | 436 | htmlf("Content-Type: %s\n", mimetype); |
432 | htmlf("Content-Disposition: inline; filename=\"%s\"\n", filename); | 437 | htmlf("Content-Disposition: inline; filename=\"%s\"\n", filename); |
433 | htmlf("Last-Modified: %s\n", http_date(item->st.st_mtime)); | 438 | htmlf("Last-Modified: %s\n", http_date(item->st.st_mtime)); |
434 | htmlf("Expires: %s\n", http_date(item->st.st_mtime + | 439 | htmlf("Expires: %s\n", http_date(item->st.st_mtime + |
435 | ttl_seconds(item->ttl))); | 440 | ttl_seconds(item->ttl))); |
436 | html("\n"); | 441 | html("\n"); |
437 | } | 442 | } |
438 | 443 | ||
439 | /* vim:set sw=8: */ | 444 | /* vim:set sw=8: */ |
diff --git a/ui-summary.c b/ui-summary.c index 178e959..04a466a 100644 --- a/ui-summary.c +++ b/ui-summary.c | |||
@@ -143,105 +143,105 @@ static int cgit_print_archive_cb(const char *refname, const unsigned char *sha1, | |||
143 | html("<table id='downloads'>"); | 143 | html("<table id='downloads'>"); |
144 | html("<tr><th>Downloads</th></tr>"); | 144 | html("<tr><th>Downloads</th></tr>"); |
145 | header = 1; | 145 | header = 1; |
146 | } | 146 | } |
147 | html("<tr><td>"); | 147 | html("<tr><td>"); |
148 | url = cgit_pageurl(cgit_query_repo, "blob", | 148 | url = cgit_pageurl(cgit_query_repo, "blob", |
149 | fmt("id=%s&path=%s", sha1_to_hex(fileid), | 149 | fmt("id=%s&path=%s", sha1_to_hex(fileid), |
150 | buf)); | 150 | buf)); |
151 | html_link_open(url, NULL, NULL); | 151 | html_link_open(url, NULL, NULL); |
152 | html_txt(buf); | 152 | html_txt(buf); |
153 | html_link_close(); | 153 | html_link_close(); |
154 | html("</td></tr>"); | 154 | html("</td></tr>"); |
155 | return 0; | 155 | return 0; |
156 | } | 156 | } |
157 | 157 | ||
158 | static void print_refs_link(char *path) | 158 | static void print_refs_link(char *path) |
159 | { | 159 | { |
160 | html("<tr class='nohover'><td colspan='4'>"); | 160 | html("<tr class='nohover'><td colspan='4'>"); |
161 | cgit_refs_link("[...]", NULL, NULL, cgit_query_head, NULL, path); | 161 | cgit_refs_link("[...]", NULL, NULL, cgit_query_head, NULL, path); |
162 | html("</td></tr>"); | 162 | html("</td></tr>"); |
163 | } | 163 | } |
164 | 164 | ||
165 | void cgit_print_branches(int maxcount) | 165 | void cgit_print_branches(int maxcount) |
166 | { | 166 | { |
167 | struct reflist list; | 167 | struct reflist list; |
168 | int i; | 168 | int i; |
169 | 169 | ||
170 | html("<tr class='nohover'><th class='left'>Branch</th>" | 170 | html("<tr class='nohover'><th class='left'>Branch</th>" |
171 | "<th class='left'>Idle</th>" | 171 | "<th class='left'>Idle</th>" |
172 | "<th class='left'>Author</th>" | 172 | "<th class='left'>Author</th>" |
173 | "<th class='left'>Head commit</th></tr>\n"); | 173 | "<th class='left'>Head commit</th></tr>\n"); |
174 | 174 | ||
175 | list.refs = NULL; | 175 | list.refs = NULL; |
176 | list.alloc = list.count = 0; | 176 | list.alloc = list.count = 0; |
177 | for_each_branch_ref(cgit_refs_cb, &list); | 177 | for_each_branch_ref(cgit_refs_cb, &list); |
178 | 178 | ||
179 | if (maxcount == 0 || maxcount > list.count) | 179 | if (maxcount == 0 || maxcount > list.count) |
180 | maxcount = list.count; | 180 | maxcount = list.count; |
181 | 181 | ||
182 | if (maxcount < list.count) { | 182 | if (maxcount < list.count) { |
183 | qsort(list.refs, list.count, sizeof(*list.refs), cmp_branch_age); | 183 | qsort(list.refs, list.count, sizeof(*list.refs), cmp_branch_age); |
184 | qsort(list.refs, maxcount, sizeof(*list.refs), cmp_ref_name); | 184 | qsort(list.refs, maxcount, sizeof(*list.refs), cmp_ref_name); |
185 | } | 185 | } |
186 | 186 | ||
187 | for(i=0; i<maxcount; i++) | 187 | for(i=0; i<maxcount; i++) |
188 | print_branch(list.refs[i]); | 188 | print_branch(list.refs[i]); |
189 | 189 | ||
190 | if (maxcount < list.count) | 190 | if (maxcount < list.count) |
191 | print_refs_link("heads"); | 191 | print_refs_link("heads"); |
192 | } | 192 | } |
193 | 193 | ||
194 | void cgit_print_tags(int maxcount) | 194 | void cgit_print_tags(int maxcount) |
195 | { | 195 | { |
196 | struct reflist list; | 196 | struct reflist list; |
197 | int i; | 197 | int i; |
198 | 198 | ||
199 | header = 0; | 199 | header = 0; |
200 | list.refs = NULL; | 200 | list.refs = NULL; |
201 | list.alloc = list.count = 0; | 201 | list.alloc = list.count = 0; |
202 | for_each_tag_ref(cgit_refs_cb, &list); | 202 | for_each_tag_ref(cgit_refs_cb, &list); |
203 | if (list.count == 0) | 203 | if (list.count == 0) |
204 | return; | 204 | return; |
205 | qsort(list.refs, list.count, sizeof(*list.refs), cmp_tag_age); | 205 | qsort(list.refs, list.count, sizeof(*list.refs), cmp_tag_age); |
206 | if (!maxcount) | 206 | if (!maxcount) |
207 | maxcount = list.count; | 207 | maxcount = list.count; |
208 | else if (maxcount > list.count) | 208 | else if (maxcount > list.count) |
209 | maxcount = list.count; | 209 | maxcount = list.count; |
210 | print_tag_header(); | 210 | print_tag_header(); |
211 | for(i=0; i<maxcount; i++) | 211 | for(i=0; i<maxcount; i++) |
212 | print_tag(list.refs[i]); | 212 | print_tag(list.refs[i]); |
213 | 213 | ||
214 | if (maxcount < list.count) | 214 | if (maxcount < list.count) |
215 | print_refs_link("tags"); | 215 | print_refs_link("tags"); |
216 | } | 216 | } |
217 | 217 | ||
218 | static void cgit_print_archives() | 218 | static void cgit_print_archives() |
219 | { | 219 | { |
220 | header = 0; | 220 | header = 0; |
221 | for_each_ref(cgit_print_archive_cb, NULL); | 221 | for_each_ref(cgit_print_archive_cb, NULL); |
222 | if (header) | 222 | if (header) |
223 | html("</table>"); | 223 | html("</table>"); |
224 | } | 224 | } |
225 | 225 | ||
226 | void cgit_print_summary() | 226 | void cgit_print_summary() |
227 | { | 227 | { |
228 | html("<div id='summary'>"); | 228 | html("<div id='summary'>"); |
229 | cgit_print_archives(); | 229 | cgit_print_archives(); |
230 | html("<h2>"); | 230 | html("<h2>"); |
231 | html_txt(cgit_repo->name); | 231 | html_txt(cgit_repo->name); |
232 | html(" - "); | 232 | html(" - "); |
233 | html_txt(cgit_repo->desc); | 233 | html_txt(cgit_repo->desc); |
234 | html("</h2>"); | 234 | html("</h2>"); |
235 | if (cgit_repo->readme) | 235 | if (cgit_repo->readme) |
236 | html_include(cgit_repo->readme); | 236 | html_include(cgit_repo->readme); |
237 | html("</div>"); | 237 | html("</div>"); |
238 | if (cgit_summary_log > 0) | 238 | if (cgit_summary_log > 0) |
239 | cgit_print_log(cgit_query_head, 0, cgit_summary_log, NULL, NULL, 0); | 239 | cgit_print_log(cgit_query_head, 0, cgit_summary_log, NULL, NULL, NULL, 0); |
240 | html("<table class='list nowrap'>"); | 240 | html("<table class='list nowrap'>"); |
241 | if (cgit_summary_log > 0) | 241 | if (cgit_summary_log > 0) |
242 | html("<tr class='nohover'><td colspan='4'> </td></tr>"); | 242 | html("<tr class='nohover'><td colspan='4'> </td></tr>"); |
243 | cgit_print_branches(cgit_summary_branches); | 243 | cgit_print_branches(cgit_summary_branches); |
244 | html("<tr class='nohover'><td colspan='4'> </td></tr>"); | 244 | html("<tr class='nohover'><td colspan='4'> </td></tr>"); |
245 | cgit_print_tags(cgit_summary_tags); | 245 | cgit_print_tags(cgit_summary_tags); |
246 | html("</table>"); | 246 | html("</table>"); |
247 | } | 247 | } |