-rw-r--r-- | cgit.css | 14 | ||||
-rw-r--r-- | cgit.h | 1 | ||||
-rw-r--r-- | cgitrc | 1 | ||||
-rw-r--r-- | shared.c | 8 | ||||
-rw-r--r-- | ui-summary.c | 14 |
5 files changed, 23 insertions, 15 deletions
@@ -79,144 +79,142 @@ table#layout { | |||
79 | width: 100%; | 79 | width: 100%; |
80 | border-collapse: collapse; | 80 | border-collapse: collapse; |
81 | margin: 0px; | 81 | margin: 0px; |
82 | } | 82 | } |
83 | 83 | ||
84 | td#header, td#logo { | 84 | td#header, td#logo { |
85 | color: #666; | 85 | color: #666; |
86 | background-color: #ddd; | 86 | background-color: #ddd; |
87 | border-bottom: solid 1px #000; | 87 | border-bottom: solid 1px #000; |
88 | } | 88 | } |
89 | 89 | ||
90 | td#header { | 90 | td#header { |
91 | font-size: 150%; | 91 | font-size: 150%; |
92 | font-weight: bold; | 92 | font-weight: bold; |
93 | padding: 0.2em 0.5em; | 93 | padding: 0.2em 0.5em; |
94 | vertical-align: text-bottom; | 94 | vertical-align: text-bottom; |
95 | } | 95 | } |
96 | 96 | ||
97 | td#logo { | 97 | td#logo { |
98 | text-align: right; | 98 | text-align: right; |
99 | vertical-align: middle; | 99 | vertical-align: middle; |
100 | padding-right: 0.5em; | 100 | padding-right: 0.5em; |
101 | } | 101 | } |
102 | 102 | ||
103 | td#crumb, td#search { | 103 | td#crumb, td#search { |
104 | color: #ccc; | 104 | color: #ccc; |
105 | border-top: solid 3px #555; | 105 | border-top: solid 3px #555; |
106 | background-color: #666; | 106 | background-color: #666; |
107 | border-bottom: solid 1px #333; | 107 | border-bottom: solid 1px #333; |
108 | padding: 2px 1em; | 108 | padding: 2px 1em; |
109 | } | 109 | } |
110 | 110 | ||
111 | td#crumb { | 111 | td#crumb { |
112 | font-weight: bold; | 112 | font-weight: bold; |
113 | } | 113 | } |
114 | 114 | ||
115 | td#crumb a { | 115 | td#crumb a { |
116 | color: #ccc; | 116 | color: #ccc; |
117 | } | 117 | } |
118 | 118 | ||
119 | td#crumb a:hover { | 119 | td#crumb a:hover { |
120 | color: #eee; | 120 | color: #eee; |
121 | } | 121 | } |
122 | 122 | ||
123 | td#search { | 123 | td#search { |
124 | text-align: right; | 124 | text-align: right; |
125 | vertical-align: center; | 125 | vertical-align: center; |
126 | padding-right: 0.5em; | 126 | padding-right: 0.5em; |
127 | } | 127 | } |
128 | 128 | ||
129 | td#search form { | 129 | td#search form { |
130 | margin: 0px; | 130 | margin: 0px; |
131 | padding: 0px; | 131 | padding: 0px; |
132 | } | 132 | } |
133 | 133 | ||
134 | td#search input { | 134 | td#search input { |
135 | font-size: 9pt; | 135 | font-size: 9pt; |
136 | padding: 0px; | 136 | padding: 0px; |
137 | width: 10em; | 137 | width: 10em; |
138 | border: solid 1px #333; | 138 | border: solid 1px #333; |
139 | color: #333; | 139 | color: #333; |
140 | background-color: #fff; | 140 | background-color: #fff; |
141 | } | 141 | } |
142 | 142 | ||
143 | td#summary { | 143 | div#summary { |
144 | vertical-align: top; | 144 | vertical-align: top; |
145 | padding-bottom: 1em; | 145 | margin-bottom: 1em; |
146 | } | 146 | } |
147 | 147 | ||
148 | td#archivelist { | 148 | table#downloads { |
149 | padding-bottom: 1em; | ||
150 | } | ||
151 | |||
152 | td#archivelist table { | ||
153 | float: right; | 149 | float: right; |
154 | border-collapse: collapse; | 150 | border-collapse: collapse; |
155 | border: solid 1px #777; | 151 | border: solid 1px #777; |
152 | margin-left: 0.5em; | ||
153 | margin-bottom: 0.5em; | ||
156 | } | 154 | } |
157 | 155 | ||
158 | td#archivelist table th { | 156 | table#downloads th { |
159 | background-color: #ccc; | 157 | background-color: #ccc; |
160 | } | 158 | } |
161 | 159 | ||
162 | td#content { | 160 | td#content { |
163 | padding: 1em 0.5em; | 161 | padding: 1em 0.5em; |
164 | } | 162 | } |
165 | 163 | ||
166 | div#blob { | 164 | div#blob { |
167 | border: solid 1px black; | 165 | border: solid 1px black; |
168 | } | 166 | } |
169 | 167 | ||
170 | div.error { | 168 | div.error { |
171 | color: red; | 169 | color: red; |
172 | font-weight: bold; | 170 | font-weight: bold; |
173 | margin: 1em 2em; | 171 | margin: 1em 2em; |
174 | } | 172 | } |
175 | 173 | ||
176 | td.ls-blob, td.ls-dir, td.ls-mod { | 174 | td.ls-blob, td.ls-dir, td.ls-mod { |
177 | font-family: monospace; | 175 | font-family: monospace; |
178 | } | 176 | } |
179 | 177 | ||
180 | div.ls-dir a { | 178 | div.ls-dir a { |
181 | font-weight: bold; | 179 | font-weight: bold; |
182 | } | 180 | } |
183 | 181 | ||
184 | th.filesize, td.filesize { | 182 | th.filesize, td.filesize { |
185 | text-align: right; | 183 | text-align: right; |
186 | } | 184 | } |
187 | 185 | ||
188 | td.filesize { | 186 | td.filesize { |
189 | font-family: monospace; | 187 | font-family: monospace; |
190 | } | 188 | } |
191 | 189 | ||
192 | td.links { | 190 | td.links { |
193 | font-size: 80%; | 191 | font-size: 80%; |
194 | padding-left: 2em; | 192 | padding-left: 2em; |
195 | } | 193 | } |
196 | 194 | ||
197 | td.filemode { | 195 | td.filemode { |
198 | font-family: monospace; | 196 | font-family: monospace; |
199 | } | 197 | } |
200 | 198 | ||
201 | td.blob { | 199 | td.blob { |
202 | white-space: pre; | 200 | white-space: pre; |
203 | font-family: monospace; | 201 | font-family: monospace; |
204 | background-color: white; | 202 | background-color: white; |
205 | } | 203 | } |
206 | 204 | ||
207 | table.nowrap td { | 205 | table.nowrap td { |
208 | white-space: nowrap; | 206 | white-space: nowrap; |
209 | } | 207 | } |
210 | 208 | ||
211 | table.commit-info { | 209 | table.commit-info { |
212 | border-collapse: collapse; | 210 | border-collapse: collapse; |
213 | margin-top: 1.5em; | 211 | margin-top: 1.5em; |
214 | } | 212 | } |
215 | 213 | ||
216 | table.commit-info th { | 214 | table.commit-info th { |
217 | text-align: left; | 215 | text-align: left; |
218 | font-weight: normal; | 216 | font-weight: normal; |
219 | padding: 0.1em 1em 0.1em 0.1em; | 217 | padding: 0.1em 1em 0.1em 0.1em; |
220 | } | 218 | } |
221 | 219 | ||
222 | table.commit-info td { | 220 | table.commit-info td { |
@@ -7,128 +7,129 @@ | |||
7 | #include <grep.h> | 7 | #include <grep.h> |
8 | #include <object.h> | 8 | #include <object.h> |
9 | #include <tree.h> | 9 | #include <tree.h> |
10 | #include <commit.h> | 10 | #include <commit.h> |
11 | #include <tag.h> | 11 | #include <tag.h> |
12 | #include <diff.h> | 12 | #include <diff.h> |
13 | #include <diffcore.h> | 13 | #include <diffcore.h> |
14 | #include <refs.h> | 14 | #include <refs.h> |
15 | #include <revision.h> | 15 | #include <revision.h> |
16 | #include <log-tree.h> | 16 | #include <log-tree.h> |
17 | #include <archive.h> | 17 | #include <archive.h> |
18 | #include <xdiff/xdiff.h> | 18 | #include <xdiff/xdiff.h> |
19 | 19 | ||
20 | 20 | ||
21 | /* | 21 | /* |
22 | * The valid cgit repo-commands | 22 | * The valid cgit repo-commands |
23 | */ | 23 | */ |
24 | #define CMD_LOG 1 | 24 | #define CMD_LOG 1 |
25 | #define CMD_COMMIT 2 | 25 | #define CMD_COMMIT 2 |
26 | #define CMD_DIFF 3 | 26 | #define CMD_DIFF 3 |
27 | #define CMD_TREE 4 | 27 | #define CMD_TREE 4 |
28 | #define CMD_VIEW 5 | 28 | #define CMD_VIEW 5 |
29 | #define CMD_BLOB 6 | 29 | #define CMD_BLOB 6 |
30 | #define CMD_SNAPSHOT 7 | 30 | #define CMD_SNAPSHOT 7 |
31 | 31 | ||
32 | 32 | ||
33 | /* | 33 | /* |
34 | * Dateformats used on misc. pages | 34 | * Dateformats used on misc. pages |
35 | */ | 35 | */ |
36 | #define FMT_LONGDATE "%Y-%m-%d %H:%M:%S" | 36 | #define FMT_LONGDATE "%Y-%m-%d %H:%M:%S" |
37 | #define FMT_SHORTDATE "%Y-%m-%d" | 37 | #define FMT_SHORTDATE "%Y-%m-%d" |
38 | 38 | ||
39 | 39 | ||
40 | /* | 40 | /* |
41 | * Limits used for relative dates | 41 | * Limits used for relative dates |
42 | */ | 42 | */ |
43 | #define TM_MIN 60 | 43 | #define TM_MIN 60 |
44 | #define TM_HOUR (TM_MIN * 60) | 44 | #define TM_HOUR (TM_MIN * 60) |
45 | #define TM_DAY (TM_HOUR * 24) | 45 | #define TM_DAY (TM_HOUR * 24) |
46 | #define TM_WEEK (TM_DAY * 7) | 46 | #define TM_WEEK (TM_DAY * 7) |
47 | #define TM_YEAR (TM_DAY * 365) | 47 | #define TM_YEAR (TM_DAY * 365) |
48 | #define TM_MONTH (TM_YEAR / 12.0) | 48 | #define TM_MONTH (TM_YEAR / 12.0) |
49 | 49 | ||
50 | 50 | ||
51 | typedef void (*configfn)(const char *name, const char *value); | 51 | typedef void (*configfn)(const char *name, const char *value); |
52 | typedef void (*filepair_fn)(struct diff_filepair *pair); | 52 | typedef void (*filepair_fn)(struct diff_filepair *pair); |
53 | typedef void (*linediff_fn)(char *line, int len); | 53 | typedef void (*linediff_fn)(char *line, int len); |
54 | 54 | ||
55 | struct cacheitem { | 55 | struct cacheitem { |
56 | char *name; | 56 | char *name; |
57 | struct stat st; | 57 | struct stat st; |
58 | int ttl; | 58 | int ttl; |
59 | int fd; | 59 | int fd; |
60 | }; | 60 | }; |
61 | 61 | ||
62 | struct repoinfo { | 62 | struct repoinfo { |
63 | char *url; | 63 | char *url; |
64 | char *name; | 64 | char *name; |
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 | int snapshots; | 72 | int snapshots; |
72 | int enable_log_filecount; | 73 | int enable_log_filecount; |
73 | int enable_log_linecount; | 74 | int enable_log_linecount; |
74 | }; | 75 | }; |
75 | 76 | ||
76 | struct repolist { | 77 | struct repolist { |
77 | int length; | 78 | int length; |
78 | int count; | 79 | int count; |
79 | struct repoinfo *repos; | 80 | struct repoinfo *repos; |
80 | }; | 81 | }; |
81 | 82 | ||
82 | struct commitinfo { | 83 | struct commitinfo { |
83 | struct commit *commit; | 84 | struct commit *commit; |
84 | char *author; | 85 | char *author; |
85 | char *author_email; | 86 | char *author_email; |
86 | unsigned long author_date; | 87 | unsigned long author_date; |
87 | char *committer; | 88 | char *committer; |
88 | char *committer_email; | 89 | char *committer_email; |
89 | unsigned long committer_date; | 90 | unsigned long committer_date; |
90 | char *subject; | 91 | char *subject; |
91 | char *msg; | 92 | char *msg; |
92 | }; | 93 | }; |
93 | 94 | ||
94 | struct taginfo { | 95 | struct taginfo { |
95 | char *tagger; | 96 | char *tagger; |
96 | char *tagger_email; | 97 | char *tagger_email; |
97 | int tagger_date; | 98 | int tagger_date; |
98 | char *msg; | 99 | char *msg; |
99 | }; | 100 | }; |
100 | 101 | ||
101 | extern const char cgit_version[]; | 102 | extern const char cgit_version[]; |
102 | 103 | ||
103 | extern struct repolist cgit_repolist; | 104 | extern struct repolist cgit_repolist; |
104 | extern struct repoinfo *cgit_repo; | 105 | extern struct repoinfo *cgit_repo; |
105 | extern int cgit_cmd; | 106 | extern int cgit_cmd; |
106 | 107 | ||
107 | extern char *cgit_root_title; | 108 | extern char *cgit_root_title; |
108 | extern char *cgit_css; | 109 | extern char *cgit_css; |
109 | extern char *cgit_logo; | 110 | extern char *cgit_logo; |
110 | extern char *cgit_index_header; | 111 | extern char *cgit_index_header; |
111 | extern char *cgit_logo_link; | 112 | extern char *cgit_logo_link; |
112 | extern char *cgit_module_link; | 113 | extern char *cgit_module_link; |
113 | extern char *cgit_agefile; | 114 | extern char *cgit_agefile; |
114 | extern char *cgit_virtual_root; | 115 | extern char *cgit_virtual_root; |
115 | extern char *cgit_script_name; | 116 | extern char *cgit_script_name; |
116 | extern char *cgit_cache_root; | 117 | extern char *cgit_cache_root; |
117 | extern char *cgit_repo_group; | 118 | extern char *cgit_repo_group; |
118 | 119 | ||
119 | extern int cgit_nocache; | 120 | extern int cgit_nocache; |
120 | extern int cgit_snapshots; | 121 | extern int cgit_snapshots; |
121 | extern int cgit_enable_log_filecount; | 122 | extern int cgit_enable_log_filecount; |
122 | extern int cgit_enable_log_linecount; | 123 | extern int cgit_enable_log_linecount; |
123 | extern int cgit_max_lock_attempts; | 124 | extern int cgit_max_lock_attempts; |
124 | extern int cgit_cache_root_ttl; | 125 | extern int cgit_cache_root_ttl; |
125 | extern int cgit_cache_repo_ttl; | 126 | extern int cgit_cache_repo_ttl; |
126 | extern int cgit_cache_dynamic_ttl; | 127 | extern int cgit_cache_dynamic_ttl; |
127 | extern int cgit_cache_static_ttl; | 128 | extern int cgit_cache_static_ttl; |
128 | extern int cgit_cache_max_create_time; | 129 | extern int cgit_cache_max_create_time; |
129 | 130 | ||
130 | extern int cgit_max_msg_len; | 131 | extern int cgit_max_msg_len; |
131 | extern int cgit_max_repodesc_len; | 132 | extern int cgit_max_repodesc_len; |
132 | extern int cgit_max_commit_count; | 133 | extern int cgit_max_commit_count; |
133 | 134 | ||
134 | extern int cgit_query_has_symref; | 135 | extern int cgit_query_has_symref; |
@@ -47,64 +47,65 @@ | |||
47 | #css=/cgit/cgit.css | 47 | #css=/cgit/cgit.css |
48 | 48 | ||
49 | 49 | ||
50 | ## Link to logo file | 50 | ## Link to logo file |
51 | #logo=/cgit/git-logo.png | 51 | #logo=/cgit/git-logo.png |
52 | 52 | ||
53 | 53 | ||
54 | ## Url loaded when clicking the logo | 54 | ## Url loaded when clicking the logo |
55 | #logo-link=http://www.kernel.org/pub/software/scm/git/docs/ | 55 | #logo-link=http://www.kernel.org/pub/software/scm/git/docs/ |
56 | 56 | ||
57 | 57 | ||
58 | ## Url loaded when clicking a submodule link | 58 | ## Url loaded when clicking a submodule link |
59 | #module-link=./?repo=%s&page=commit&id=%s | 59 | #module-link=./?repo=%s&page=commit&id=%s |
60 | 60 | ||
61 | 61 | ||
62 | ## Number of chars shown of repo description (in repolist view) | 62 | ## Number of chars shown of repo description (in repolist view) |
63 | #max-repodesc-length=60 | 63 | #max-repodesc-length=60 |
64 | 64 | ||
65 | 65 | ||
66 | ## Number of chars shown of commit subject message (in log view) | 66 | ## Number of chars shown of commit subject message (in log view) |
67 | #max-message-length=60 | 67 | #max-message-length=60 |
68 | 68 | ||
69 | 69 | ||
70 | ## Number of commits per page in log view | 70 | ## Number of commits per page in log view |
71 | #max-commit-count=50 | 71 | #max-commit-count=50 |
72 | 72 | ||
73 | 73 | ||
74 | ## Root of cached output | 74 | ## Root of cached output |
75 | #cache-root=/var/cache/cgit | 75 | #cache-root=/var/cache/cgit |
76 | 76 | ||
77 | 77 | ||
78 | ## Include another config-file | 78 | ## Include another config-file |
79 | #include=/var/cgit/repolist | 79 | #include=/var/cgit/repolist |
80 | 80 | ||
81 | ## | 81 | ## |
82 | ## Time-To-Live settings: specifies how long (in minutes) different pages | 82 | ## Time-To-Live settings: specifies how long (in minutes) different pages |
83 | ## should be cached (0 for instant expiration, -1 for immortal pages) | 83 | ## should be cached (0 for instant expiration, -1 for immortal pages) |
84 | ## | 84 | ## |
85 | 85 | ||
86 | ## ttl for root page | 86 | ## ttl for root page |
87 | #cache-root-ttl=5 | 87 | #cache-root-ttl=5 |
88 | 88 | ||
89 | ## ttl for repo summary page | 89 | ## ttl for repo summary page |
90 | #cache-repo-ttl=5 | 90 | #cache-repo-ttl=5 |
91 | 91 | ||
92 | ## ttl for other dynamic pages | 92 | ## ttl for other dynamic pages |
93 | #cache-dynamic-ttl=5 | 93 | #cache-dynamic-ttl=5 |
94 | 94 | ||
95 | ## ttl for static pages (addressed by SHA-1) | 95 | ## ttl for static pages (addressed by SHA-1) |
96 | #cache-static-ttl=-1 | 96 | #cache-static-ttl=-1 |
97 | 97 | ||
98 | 98 | ||
99 | 99 | ||
100 | ## Example repository entry. Required values are repo.url and repo.path (each | 100 | ## Example repository entry. Required values are repo.url and repo.path (each |
101 | ## repository section must start with repo.url). | 101 | ## repository section must start with repo.url). |
102 | #repo.url=cgit | 102 | #repo.url=cgit |
103 | #repo.name=cgit | 103 | #repo.name=cgit |
104 | #repo.desc=the caching cgi for git | 104 | #repo.desc=the caching cgi for git |
105 | #repo.path=/pub/git/cgit | 105 | #repo.path=/pub/git/cgit |
106 | #repo.owner=Lars Hjemli | 106 | #repo.owner=Lars Hjemli |
107 | #repo.snapshots=1 # override a sitewide snapshot-setting | 107 | #repo.snapshots=1 # override a sitewide snapshot-setting |
108 | #repo.enable-log-filecount=0 # override the default filecount setting | 108 | #repo.enable-log-filecount=0 # override the default filecount setting |
109 | #repo.enable-log-linecount=0 # override the default linecount setting | 109 | #repo.enable-log-linecount=0 # override the default linecount setting |
110 | #repo.module-link=/git/%s/commit/?id=%s # override the standard module-link | 110 | #repo.module-link=/git/%s/commit/?id=%s # override the standard module-link |
111 | #repo.readme=info/web/readme # specify a file to include on summary page | ||
@@ -46,209 +46,215 @@ char *cgit_querystring = NULL; | |||
46 | char *cgit_query_repo = NULL; | 46 | char *cgit_query_repo = NULL; |
47 | char *cgit_query_page = NULL; | 47 | char *cgit_query_page = NULL; |
48 | char *cgit_query_head = NULL; | 48 | char *cgit_query_head = NULL; |
49 | char *cgit_query_search = NULL; | 49 | char *cgit_query_search = NULL; |
50 | char *cgit_query_sha1 = NULL; | 50 | char *cgit_query_sha1 = NULL; |
51 | char *cgit_query_sha2 = NULL; | 51 | char *cgit_query_sha2 = NULL; |
52 | char *cgit_query_path = NULL; | 52 | char *cgit_query_path = NULL; |
53 | char *cgit_query_name = NULL; | 53 | char *cgit_query_name = NULL; |
54 | int cgit_query_ofs = 0; | 54 | int cgit_query_ofs = 0; |
55 | 55 | ||
56 | int htmlfd = 0; | 56 | int htmlfd = 0; |
57 | 57 | ||
58 | 58 | ||
59 | int cgit_get_cmd_index(const char *cmd) | 59 | int cgit_get_cmd_index(const char *cmd) |
60 | { | 60 | { |
61 | static char *cmds[] = {"log", "commit", "diff", "tree", "view", "blob", "snapshot", NULL}; | 61 | static char *cmds[] = {"log", "commit", "diff", "tree", "view", "blob", "snapshot", NULL}; |
62 | int i; | 62 | int i; |
63 | 63 | ||
64 | for(i = 0; cmds[i]; i++) | 64 | for(i = 0; cmds[i]; i++) |
65 | if (!strcmp(cmd, cmds[i])) | 65 | if (!strcmp(cmd, cmds[i])) |
66 | return i + 1; | 66 | return i + 1; |
67 | return 0; | 67 | return 0; |
68 | } | 68 | } |
69 | 69 | ||
70 | int chk_zero(int result, char *msg) | 70 | int chk_zero(int result, char *msg) |
71 | { | 71 | { |
72 | if (result != 0) | 72 | if (result != 0) |
73 | die("%s: %s", msg, strerror(errno)); | 73 | die("%s: %s", msg, strerror(errno)); |
74 | return result; | 74 | return result; |
75 | } | 75 | } |
76 | 76 | ||
77 | int chk_positive(int result, char *msg) | 77 | int chk_positive(int result, char *msg) |
78 | { | 78 | { |
79 | if (result <= 0) | 79 | if (result <= 0) |
80 | die("%s: %s", msg, strerror(errno)); | 80 | die("%s: %s", msg, strerror(errno)); |
81 | return result; | 81 | return result; |
82 | } | 82 | } |
83 | 83 | ||
84 | struct repoinfo *add_repo(const char *url) | 84 | struct repoinfo *add_repo(const char *url) |
85 | { | 85 | { |
86 | struct repoinfo *ret; | 86 | struct repoinfo *ret; |
87 | 87 | ||
88 | if (++cgit_repolist.count > cgit_repolist.length) { | 88 | if (++cgit_repolist.count > cgit_repolist.length) { |
89 | if (cgit_repolist.length == 0) | 89 | if (cgit_repolist.length == 0) |
90 | cgit_repolist.length = 8; | 90 | cgit_repolist.length = 8; |
91 | else | 91 | else |
92 | cgit_repolist.length *= 2; | 92 | cgit_repolist.length *= 2; |
93 | cgit_repolist.repos = xrealloc(cgit_repolist.repos, | 93 | cgit_repolist.repos = xrealloc(cgit_repolist.repos, |
94 | cgit_repolist.length * | 94 | cgit_repolist.length * |
95 | sizeof(struct repoinfo)); | 95 | sizeof(struct repoinfo)); |
96 | } | 96 | } |
97 | 97 | ||
98 | ret = &cgit_repolist.repos[cgit_repolist.count-1]; | 98 | ret = &cgit_repolist.repos[cgit_repolist.count-1]; |
99 | ret->url = xstrdup(url); | 99 | ret->url = xstrdup(url); |
100 | ret->name = ret->url; | 100 | ret->name = ret->url; |
101 | ret->path = NULL; | 101 | ret->path = NULL; |
102 | ret->desc = NULL; | 102 | ret->desc = NULL; |
103 | ret->owner = NULL; | 103 | ret->owner = NULL; |
104 | ret->group = cgit_repo_group; | 104 | ret->group = cgit_repo_group; |
105 | ret->defbranch = "master"; | 105 | ret->defbranch = "master"; |
106 | ret->snapshots = cgit_snapshots; | 106 | ret->snapshots = cgit_snapshots; |
107 | ret->enable_log_filecount = cgit_enable_log_filecount; | 107 | ret->enable_log_filecount = cgit_enable_log_filecount; |
108 | ret->enable_log_linecount = cgit_enable_log_linecount; | 108 | ret->enable_log_linecount = cgit_enable_log_linecount; |
109 | ret->module_link = cgit_module_link; | 109 | ret->module_link = cgit_module_link; |
110 | ret->readme = NULL; | ||
110 | return ret; | 111 | return ret; |
111 | } | 112 | } |
112 | 113 | ||
113 | struct repoinfo *cgit_get_repoinfo(const char *url) | 114 | struct repoinfo *cgit_get_repoinfo(const char *url) |
114 | { | 115 | { |
115 | int i; | 116 | int i; |
116 | struct repoinfo *repo; | 117 | struct repoinfo *repo; |
117 | 118 | ||
118 | for (i=0; i<cgit_repolist.count; i++) { | 119 | for (i=0; i<cgit_repolist.count; i++) { |
119 | repo = &cgit_repolist.repos[i]; | 120 | repo = &cgit_repolist.repos[i]; |
120 | if (!strcmp(repo->url, url)) | 121 | if (!strcmp(repo->url, url)) |
121 | return repo; | 122 | return repo; |
122 | } | 123 | } |
123 | return NULL; | 124 | return NULL; |
124 | } | 125 | } |
125 | 126 | ||
126 | void cgit_global_config_cb(const char *name, const char *value) | 127 | void cgit_global_config_cb(const char *name, const char *value) |
127 | { | 128 | { |
128 | if (!strcmp(name, "root-title")) | 129 | if (!strcmp(name, "root-title")) |
129 | cgit_root_title = xstrdup(value); | 130 | cgit_root_title = xstrdup(value); |
130 | else if (!strcmp(name, "css")) | 131 | else if (!strcmp(name, "css")) |
131 | cgit_css = xstrdup(value); | 132 | cgit_css = xstrdup(value); |
132 | else if (!strcmp(name, "logo")) | 133 | else if (!strcmp(name, "logo")) |
133 | cgit_logo = xstrdup(value); | 134 | cgit_logo = xstrdup(value); |
134 | else if (!strcmp(name, "index-header")) | 135 | else if (!strcmp(name, "index-header")) |
135 | cgit_index_header = xstrdup(value); | 136 | cgit_index_header = xstrdup(value); |
136 | else if (!strcmp(name, "logo-link")) | 137 | else if (!strcmp(name, "logo-link")) |
137 | cgit_logo_link = xstrdup(value); | 138 | cgit_logo_link = xstrdup(value); |
138 | else if (!strcmp(name, "module-link")) | 139 | else if (!strcmp(name, "module-link")) |
139 | cgit_module_link = xstrdup(value); | 140 | cgit_module_link = xstrdup(value); |
140 | else if (!strcmp(name, "virtual-root")) | 141 | else if (!strcmp(name, "virtual-root")) |
141 | cgit_virtual_root = xstrdup(value); | 142 | cgit_virtual_root = xstrdup(value); |
142 | else if (!strcmp(name, "nocache")) | 143 | else if (!strcmp(name, "nocache")) |
143 | cgit_nocache = atoi(value); | 144 | cgit_nocache = atoi(value); |
144 | else if (!strcmp(name, "snapshots")) | 145 | else if (!strcmp(name, "snapshots")) |
145 | cgit_snapshots = atoi(value); | 146 | cgit_snapshots = atoi(value); |
146 | else if (!strcmp(name, "enable-log-filecount")) | 147 | else if (!strcmp(name, "enable-log-filecount")) |
147 | cgit_enable_log_filecount = atoi(value); | 148 | cgit_enable_log_filecount = atoi(value); |
148 | else if (!strcmp(name, "enable-log-linecount")) | 149 | else if (!strcmp(name, "enable-log-linecount")) |
149 | cgit_enable_log_linecount = atoi(value); | 150 | cgit_enable_log_linecount = atoi(value); |
150 | else if (!strcmp(name, "cache-root")) | 151 | else if (!strcmp(name, "cache-root")) |
151 | cgit_cache_root = xstrdup(value); | 152 | cgit_cache_root = xstrdup(value); |
152 | else if (!strcmp(name, "cache-root-ttl")) | 153 | else if (!strcmp(name, "cache-root-ttl")) |
153 | cgit_cache_root_ttl = atoi(value); | 154 | cgit_cache_root_ttl = atoi(value); |
154 | else if (!strcmp(name, "cache-repo-ttl")) | 155 | else if (!strcmp(name, "cache-repo-ttl")) |
155 | cgit_cache_repo_ttl = atoi(value); | 156 | cgit_cache_repo_ttl = atoi(value); |
156 | else if (!strcmp(name, "cache-static-ttl")) | 157 | else if (!strcmp(name, "cache-static-ttl")) |
157 | cgit_cache_static_ttl = atoi(value); | 158 | cgit_cache_static_ttl = atoi(value); |
158 | else if (!strcmp(name, "cache-dynamic-ttl")) | 159 | else if (!strcmp(name, "cache-dynamic-ttl")) |
159 | cgit_cache_dynamic_ttl = atoi(value); | 160 | cgit_cache_dynamic_ttl = atoi(value); |
160 | else if (!strcmp(name, "max-message-length")) | 161 | else if (!strcmp(name, "max-message-length")) |
161 | cgit_max_msg_len = atoi(value); | 162 | cgit_max_msg_len = atoi(value); |
162 | else if (!strcmp(name, "max-repodesc-length")) | 163 | else if (!strcmp(name, "max-repodesc-length")) |
163 | cgit_max_repodesc_len = atoi(value); | 164 | cgit_max_repodesc_len = atoi(value); |
164 | else if (!strcmp(name, "max-commit-count")) | 165 | else if (!strcmp(name, "max-commit-count")) |
165 | cgit_max_commit_count = atoi(value); | 166 | cgit_max_commit_count = atoi(value); |
166 | else if (!strcmp(name, "agefile")) | 167 | else if (!strcmp(name, "agefile")) |
167 | cgit_agefile = xstrdup(value); | 168 | cgit_agefile = xstrdup(value); |
168 | else if (!strcmp(name, "repo.group")) | 169 | else if (!strcmp(name, "repo.group")) |
169 | cgit_repo_group = xstrdup(value); | 170 | cgit_repo_group = xstrdup(value); |
170 | else if (!strcmp(name, "repo.url")) | 171 | else if (!strcmp(name, "repo.url")) |
171 | cgit_repo = add_repo(value); | 172 | cgit_repo = add_repo(value); |
172 | else if (!strcmp(name, "repo.name")) | 173 | else if (!strcmp(name, "repo.name")) |
173 | cgit_repo->name = xstrdup(value); | 174 | cgit_repo->name = xstrdup(value); |
174 | else if (cgit_repo && !strcmp(name, "repo.path")) | 175 | else if (cgit_repo && !strcmp(name, "repo.path")) |
175 | cgit_repo->path = xstrdup(value); | 176 | cgit_repo->path = xstrdup(value); |
176 | else if (cgit_repo && !strcmp(name, "repo.desc")) | 177 | else if (cgit_repo && !strcmp(name, "repo.desc")) |
177 | cgit_repo->desc = xstrdup(value); | 178 | cgit_repo->desc = xstrdup(value); |
178 | else if (cgit_repo && !strcmp(name, "repo.owner")) | 179 | else if (cgit_repo && !strcmp(name, "repo.owner")) |
179 | cgit_repo->owner = xstrdup(value); | 180 | cgit_repo->owner = xstrdup(value); |
180 | else if (cgit_repo && !strcmp(name, "repo.defbranch")) | 181 | else if (cgit_repo && !strcmp(name, "repo.defbranch")) |
181 | cgit_repo->defbranch = xstrdup(value); | 182 | cgit_repo->defbranch = xstrdup(value); |
182 | else if (cgit_repo && !strcmp(name, "repo.snapshots")) | 183 | else if (cgit_repo && !strcmp(name, "repo.snapshots")) |
183 | cgit_repo->snapshots = cgit_snapshots * atoi(value); | 184 | cgit_repo->snapshots = cgit_snapshots * atoi(value); |
184 | else if (cgit_repo && !strcmp(name, "repo.enable-log-filecount")) | 185 | else if (cgit_repo && !strcmp(name, "repo.enable-log-filecount")) |
185 | cgit_repo->enable_log_filecount = cgit_enable_log_filecount * atoi(value); | 186 | cgit_repo->enable_log_filecount = cgit_enable_log_filecount * atoi(value); |
186 | else if (cgit_repo && !strcmp(name, "repo.enable-log-linecount")) | 187 | else if (cgit_repo && !strcmp(name, "repo.enable-log-linecount")) |
187 | cgit_repo->enable_log_linecount = cgit_enable_log_linecount * atoi(value); | 188 | cgit_repo->enable_log_linecount = cgit_enable_log_linecount * atoi(value); |
188 | else if (cgit_repo && !strcmp(name, "repo.module-link")) | 189 | else if (cgit_repo && !strcmp(name, "repo.module-link")) |
189 | cgit_repo->module_link= xstrdup(value); | 190 | cgit_repo->module_link= xstrdup(value); |
190 | else if (!strcmp(name, "include")) | 191 | else if (cgit_repo && !strcmp(name, "repo.readme") && value != NULL) { |
192 | if (*value == '/') | ||
193 | cgit_repo->readme = xstrdup(value); | ||
194 | else | ||
195 | cgit_repo->readme = xstrdup(fmt("%s/%s", cgit_repo->path, value)); | ||
196 | } else if (!strcmp(name, "include")) | ||
191 | cgit_read_config(value, cgit_global_config_cb); | 197 | cgit_read_config(value, cgit_global_config_cb); |
192 | } | 198 | } |
193 | 199 | ||
194 | void cgit_querystring_cb(const char *name, const char *value) | 200 | void cgit_querystring_cb(const char *name, const char *value) |
195 | { | 201 | { |
196 | if (!strcmp(name,"r")) { | 202 | if (!strcmp(name,"r")) { |
197 | cgit_query_repo = xstrdup(value); | 203 | cgit_query_repo = xstrdup(value); |
198 | cgit_repo = cgit_get_repoinfo(value); | 204 | cgit_repo = cgit_get_repoinfo(value); |
199 | } else if (!strcmp(name, "p")) { | 205 | } else if (!strcmp(name, "p")) { |
200 | cgit_query_page = xstrdup(value); | 206 | cgit_query_page = xstrdup(value); |
201 | cgit_cmd = cgit_get_cmd_index(value); | 207 | cgit_cmd = cgit_get_cmd_index(value); |
202 | } else if (!strcmp(name, "url")) { | 208 | } else if (!strcmp(name, "url")) { |
203 | cgit_parse_url(value); | 209 | cgit_parse_url(value); |
204 | } else if (!strcmp(name, "q")) { | 210 | } else if (!strcmp(name, "q")) { |
205 | cgit_query_search = xstrdup(value); | 211 | cgit_query_search = xstrdup(value); |
206 | } else if (!strcmp(name, "h")) { | 212 | } else if (!strcmp(name, "h")) { |
207 | cgit_query_head = xstrdup(value); | 213 | cgit_query_head = xstrdup(value); |
208 | cgit_query_has_symref = 1; | 214 | cgit_query_has_symref = 1; |
209 | } else if (!strcmp(name, "id")) { | 215 | } else if (!strcmp(name, "id")) { |
210 | cgit_query_sha1 = xstrdup(value); | 216 | cgit_query_sha1 = xstrdup(value); |
211 | cgit_query_has_sha1 = 1; | 217 | cgit_query_has_sha1 = 1; |
212 | } else if (!strcmp(name, "id2")) { | 218 | } else if (!strcmp(name, "id2")) { |
213 | cgit_query_sha2 = xstrdup(value); | 219 | cgit_query_sha2 = xstrdup(value); |
214 | cgit_query_has_sha1 = 1; | 220 | cgit_query_has_sha1 = 1; |
215 | } else if (!strcmp(name, "ofs")) { | 221 | } else if (!strcmp(name, "ofs")) { |
216 | cgit_query_ofs = atoi(value); | 222 | cgit_query_ofs = atoi(value); |
217 | } else if (!strcmp(name, "path")) { | 223 | } else if (!strcmp(name, "path")) { |
218 | cgit_query_path = xstrdup(value); | 224 | cgit_query_path = xstrdup(value); |
219 | } else if (!strcmp(name, "name")) { | 225 | } else if (!strcmp(name, "name")) { |
220 | cgit_query_name = xstrdup(value); | 226 | cgit_query_name = xstrdup(value); |
221 | } | 227 | } |
222 | } | 228 | } |
223 | 229 | ||
224 | void *cgit_free_commitinfo(struct commitinfo *info) | 230 | void *cgit_free_commitinfo(struct commitinfo *info) |
225 | { | 231 | { |
226 | free(info->author); | 232 | free(info->author); |
227 | free(info->author_email); | 233 | free(info->author_email); |
228 | free(info->committer); | 234 | free(info->committer); |
229 | free(info->committer_email); | 235 | free(info->committer_email); |
230 | free(info->subject); | 236 | free(info->subject); |
231 | free(info); | 237 | free(info); |
232 | return NULL; | 238 | return NULL; |
233 | } | 239 | } |
234 | 240 | ||
235 | int hextoint(char c) | 241 | int hextoint(char c) |
236 | { | 242 | { |
237 | if (c >= 'a' && c <= 'f') | 243 | if (c >= 'a' && c <= 'f') |
238 | return 10 + c - 'a'; | 244 | return 10 + c - 'a'; |
239 | else if (c >= 'A' && c <= 'F') | 245 | else if (c >= 'A' && c <= 'F') |
240 | return 10 + c - 'A'; | 246 | return 10 + c - 'A'; |
241 | else if (c >= '0' && c <= '9') | 247 | else if (c >= '0' && c <= '9') |
242 | return c - '0'; | 248 | return c - '0'; |
243 | else | 249 | else |
244 | return -1; | 250 | return -1; |
245 | } | 251 | } |
246 | 252 | ||
247 | void cgit_diff_tree_cb(struct diff_queue_struct *q, | 253 | void cgit_diff_tree_cb(struct diff_queue_struct *q, |
248 | struct diff_options *options, void *data) | 254 | struct diff_options *options, void *data) |
249 | { | 255 | { |
250 | int i; | 256 | int i; |
251 | 257 | ||
252 | for (i = 0; i < q->nr; i++) { | 258 | for (i = 0; i < q->nr; i++) { |
253 | if (q->queue[i]->status == 'U') | 259 | if (q->queue[i]->status == 'U') |
254 | continue; | 260 | continue; |
diff --git a/ui-summary.c b/ui-summary.c index 5799773..5c1fc33 100644 --- a/ui-summary.c +++ b/ui-summary.c | |||
@@ -92,119 +92,121 @@ static int cgit_print_tag_cb(const char *refname, const unsigned char *sha1, | |||
92 | 92 | ||
93 | strncpy(buf, refname, sizeof(buf)); | 93 | strncpy(buf, refname, sizeof(buf)); |
94 | obj = parse_object(sha1); | 94 | obj = parse_object(sha1); |
95 | if (!obj) | 95 | if (!obj) |
96 | return 1; | 96 | return 1; |
97 | if (obj->type == OBJ_TAG) { | 97 | if (obj->type == OBJ_TAG) { |
98 | tag = lookup_tag(sha1); | 98 | tag = lookup_tag(sha1); |
99 | if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag))) | 99 | if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag))) |
100 | return 2; | 100 | return 2; |
101 | if (!header) | 101 | if (!header) |
102 | print_tag_header(); | 102 | print_tag_header(); |
103 | html("<tr><td>"); | 103 | html("<tr><td>"); |
104 | url = cgit_pageurl(cgit_query_repo, "view", | 104 | url = cgit_pageurl(cgit_query_repo, "view", |
105 | fmt("id=%s", sha1_to_hex(sha1))); | 105 | fmt("id=%s", sha1_to_hex(sha1))); |
106 | html_link_open(url, NULL, NULL); | 106 | html_link_open(url, NULL, NULL); |
107 | html_txt(buf); | 107 | html_txt(buf); |
108 | html_link_close(); | 108 | html_link_close(); |
109 | html("</td><td>"); | 109 | html("</td><td>"); |
110 | if (info->tagger_date > 0) | 110 | if (info->tagger_date > 0) |
111 | cgit_print_age(info->tagger_date, -1, NULL); | 111 | cgit_print_age(info->tagger_date, -1, NULL); |
112 | html("</td><td>"); | 112 | html("</td><td>"); |
113 | if (info->tagger) | 113 | if (info->tagger) |
114 | html(info->tagger); | 114 | html(info->tagger); |
115 | html("</td><td>"); | 115 | html("</td><td>"); |
116 | cgit_print_object_ref(tag->tagged); | 116 | cgit_print_object_ref(tag->tagged); |
117 | html("</td></tr>\n"); | 117 | html("</td></tr>\n"); |
118 | } else { | 118 | } else { |
119 | if (!header) | 119 | if (!header) |
120 | print_tag_header(); | 120 | print_tag_header(); |
121 | html("<tr><td>"); | 121 | html("<tr><td>"); |
122 | html_txt(buf); | 122 | html_txt(buf); |
123 | html("</td><td colspan='2'/><td>"); | 123 | html("</td><td colspan='2'/><td>"); |
124 | cgit_print_object_ref(obj); | 124 | cgit_print_object_ref(obj); |
125 | html("</td></tr>\n"); | 125 | html("</td></tr>\n"); |
126 | } | 126 | } |
127 | return 0; | 127 | return 0; |
128 | } | 128 | } |
129 | 129 | ||
130 | static int cgit_print_archive_cb(const char *refname, const unsigned char *sha1, | 130 | static int cgit_print_archive_cb(const char *refname, const unsigned char *sha1, |
131 | int flags, void *cb_data) | 131 | int flags, void *cb_data) |
132 | { | 132 | { |
133 | struct tag *tag; | 133 | struct tag *tag; |
134 | struct taginfo *info; | 134 | struct taginfo *info; |
135 | struct object *obj; | 135 | struct object *obj; |
136 | char buf[256], *url; | 136 | char buf[256], *url; |
137 | unsigned char fileid[20]; | 137 | unsigned char fileid[20]; |
138 | 138 | ||
139 | if (prefixcmp(refname, "refs/archives")) | 139 | if (prefixcmp(refname, "refs/archives")) |
140 | return 0; | 140 | return 0; |
141 | strncpy(buf, refname+14, sizeof(buf)); | 141 | strncpy(buf, refname+14, sizeof(buf)); |
142 | obj = parse_object(sha1); | 142 | obj = parse_object(sha1); |
143 | if (!obj) | 143 | if (!obj) |
144 | return 1; | 144 | return 1; |
145 | if (obj->type == OBJ_TAG) { | 145 | if (obj->type == OBJ_TAG) { |
146 | tag = lookup_tag(sha1); | 146 | tag = lookup_tag(sha1); |
147 | if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag))) | 147 | if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag))) |
148 | return 0; | 148 | return 0; |
149 | hashcpy(fileid, tag->tagged->sha1); | 149 | hashcpy(fileid, tag->tagged->sha1); |
150 | } else if (obj->type != OBJ_BLOB) { | 150 | } else if (obj->type != OBJ_BLOB) { |
151 | return 0; | 151 | return 0; |
152 | } else { | 152 | } else { |
153 | hashcpy(fileid, sha1); | 153 | hashcpy(fileid, sha1); |
154 | } | 154 | } |
155 | if (!header) { | 155 | if (!header) { |
156 | html("<table>"); | 156 | html("<table id='downloads'>"); |
157 | html("<tr><th>Downloads</th></tr>"); | 157 | html("<tr><th>Downloads</th></tr>"); |
158 | header = 1; | 158 | header = 1; |
159 | } | 159 | } |
160 | html("<tr><td>"); | 160 | html("<tr><td>"); |
161 | url = cgit_pageurl(cgit_query_repo, "blob", | 161 | url = cgit_pageurl(cgit_query_repo, "blob", |
162 | fmt("id=%s&path=%s", sha1_to_hex(fileid), | 162 | fmt("id=%s&path=%s", sha1_to_hex(fileid), |
163 | buf)); | 163 | buf)); |
164 | html_link_open(url, NULL, NULL); | 164 | html_link_open(url, NULL, NULL); |
165 | html_txt(buf); | 165 | html_txt(buf); |
166 | html_link_close(); | 166 | html_link_close(); |
167 | html("</td><tr>"); | 167 | html("</td><tr>"); |
168 | return 0; | 168 | return 0; |
169 | } | 169 | } |
170 | 170 | ||
171 | static void cgit_print_branches() | 171 | static void cgit_print_branches() |
172 | { | 172 | { |
173 | html("<tr class='nohover'><th class='left'>Branch</th>" | 173 | html("<tr class='nohover'><th class='left'>Branch</th>" |
174 | "<th class='left'>Idle</th>" | 174 | "<th class='left'>Idle</th>" |
175 | "<th class='left'>Author</th>" | 175 | "<th class='left'>Author</th>" |
176 | "<th class='left'>Head commit</th></tr>\n"); | 176 | "<th class='left'>Head commit</th></tr>\n"); |
177 | for_each_branch_ref(cgit_print_branch_cb, NULL); | 177 | for_each_branch_ref(cgit_print_branch_cb, NULL); |
178 | } | 178 | } |
179 | 179 | ||
180 | static void cgit_print_tags() | 180 | static void cgit_print_tags() |
181 | { | 181 | { |
182 | header = 0; | 182 | header = 0; |
183 | for_each_tag_ref(cgit_print_tag_cb, NULL); | 183 | for_each_tag_ref(cgit_print_tag_cb, NULL); |
184 | } | 184 | } |
185 | 185 | ||
186 | static void cgit_print_archives() | 186 | static void cgit_print_archives() |
187 | { | 187 | { |
188 | header = 0; | 188 | header = 0; |
189 | for_each_ref(cgit_print_archive_cb, NULL); | 189 | for_each_ref(cgit_print_archive_cb, NULL); |
190 | if (header) | 190 | if (header) |
191 | html("</table>"); | 191 | html("</table>"); |
192 | } | 192 | } |
193 | 193 | ||
194 | void cgit_print_summary() | 194 | void cgit_print_summary() |
195 | { | 195 | { |
196 | html("<table class='list nowrap'>"); | 196 | html("<div id='summary'>"); |
197 | html("<tr class='nohover'><td id='summary' colspan='3'>"); | 197 | cgit_print_archives(); |
198 | html("<h2>"); | 198 | html("<h2>"); |
199 | html_txt(cgit_repo->name); | 199 | html_txt(cgit_repo->name); |
200 | html(" - "); | 200 | html(" - "); |
201 | html_txt(cgit_repo->desc); | 201 | html_txt(cgit_repo->desc); |
202 | html("</h2>"); | 202 | html("</h2>"); |
203 | html("</td><td id='archivelist'>"); | 203 | if (cgit_repo->readme) |
204 | cgit_print_archives(); | 204 | html_include(cgit_repo->readme); |
205 | html("</td></tr>"); | 205 | html("</div>"); |
206 | |||
207 | html("<table class='list nowrap'>"); | ||
206 | cgit_print_branches(); | 208 | cgit_print_branches(); |
207 | html("<tr class='nohover'><td colspan='4'> </td></tr>"); | 209 | html("<tr class='nohover'><td colspan='4'> </td></tr>"); |
208 | cgit_print_tags(); | 210 | cgit_print_tags(); |
209 | html("</table>"); | 211 | html("</table>"); |
210 | } | 212 | } |