-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
@@ -127,48 +127,46 @@ td#search { | |||
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 | } |
@@ -55,32 +55,33 @@ typedef void (*linediff_fn)(char *line, int len); | |||
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; |
@@ -95,16 +95,17 @@ | |||
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 | ||
@@ -94,32 +94,33 @@ struct repoinfo *add_repo(const char *url) | |||
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 | ||
@@ -174,33 +175,38 @@ void cgit_global_config_cb(const char *name, const char *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")) { |
diff --git a/ui-summary.c b/ui-summary.c index 5799773..5c1fc33 100644 --- a/ui-summary.c +++ b/ui-summary.c | |||
@@ -140,33 +140,33 @@ static int cgit_print_archive_cb(const char *refname, const unsigned char *sha1, | |||
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 | { |
@@ -180,31 +180,33 @@ static void cgit_print_branches() | |||
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 | } |