-rw-r--r-- | cgit.h | 2 | ||||
-rw-r--r-- | ui-repolist.c | 4 | ||||
-rw-r--r-- | ui-shared.c | 20 | ||||
-rw-r--r-- | ui-summary.c | 6 | ||||
-rw-r--r-- | ui-tree.c | 12 |
5 files changed, 24 insertions, 20 deletions
@@ -182,48 +182,50 @@ extern void html_hidden(char *name, char *value); | |||
182 | extern void html_link_open(char *url, char *title, char *class); | 182 | extern void html_link_open(char *url, char *title, char *class); |
183 | extern void html_link_close(void); | 183 | extern void html_link_close(void); |
184 | extern void html_filemode(unsigned short mode); | 184 | extern void html_filemode(unsigned short mode); |
185 | extern int html_include(const char *filename); | 185 | extern int html_include(const char *filename); |
186 | 186 | ||
187 | extern int cgit_read_config(const char *filename, configfn fn); | 187 | extern int cgit_read_config(const char *filename, configfn fn); |
188 | extern int cgit_parse_query(char *txt, configfn fn); | 188 | extern int cgit_parse_query(char *txt, configfn fn); |
189 | extern struct commitinfo *cgit_parse_commit(struct commit *commit); | 189 | extern struct commitinfo *cgit_parse_commit(struct commit *commit); |
190 | extern struct taginfo *cgit_parse_tag(struct tag *tag); | 190 | extern struct taginfo *cgit_parse_tag(struct tag *tag); |
191 | extern void cgit_parse_url(const char *url); | 191 | extern void cgit_parse_url(const char *url); |
192 | 192 | ||
193 | extern char *cache_safe_filename(const char *unsafe); | 193 | extern char *cache_safe_filename(const char *unsafe); |
194 | extern int cache_lock(struct cacheitem *item); | 194 | extern int cache_lock(struct cacheitem *item); |
195 | extern int cache_unlock(struct cacheitem *item); | 195 | extern int cache_unlock(struct cacheitem *item); |
196 | extern int cache_cancel_lock(struct cacheitem *item); | 196 | extern int cache_cancel_lock(struct cacheitem *item); |
197 | extern int cache_exist(struct cacheitem *item); | 197 | extern int cache_exist(struct cacheitem *item); |
198 | extern int cache_expired(struct cacheitem *item); | 198 | extern int cache_expired(struct cacheitem *item); |
199 | 199 | ||
200 | extern char *cgit_repourl(const char *reponame); | 200 | extern char *cgit_repourl(const char *reponame); |
201 | extern char *cgit_pageurl(const char *reponame, const char *pagename, | 201 | extern char *cgit_pageurl(const char *reponame, const char *pagename, |
202 | const char *query); | 202 | const char *query); |
203 | 203 | ||
204 | extern void cgit_tree_link(char *name, char *title, char *class, char *head, | 204 | extern void cgit_tree_link(char *name, char *title, char *class, char *head, |
205 | char *rev, char *path); | 205 | char *rev, char *path); |
206 | extern void cgit_log_link(char *name, char *title, char *class, char *head, | ||
207 | char *rev, char *path); | ||
206 | 208 | ||
207 | extern void cgit_print_error(char *msg); | 209 | extern void cgit_print_error(char *msg); |
208 | extern void cgit_print_date(time_t secs, char *format); | 210 | extern void cgit_print_date(time_t secs, char *format); |
209 | extern void cgit_print_age(time_t t, time_t max_relative, char *format); | 211 | extern void cgit_print_age(time_t t, time_t max_relative, char *format); |
210 | extern void cgit_print_docstart(char *title, struct cacheitem *item); | 212 | extern void cgit_print_docstart(char *title, struct cacheitem *item); |
211 | extern void cgit_print_docend(); | 213 | extern void cgit_print_docend(); |
212 | extern void cgit_print_pageheader(char *title, int show_search); | 214 | extern void cgit_print_pageheader(char *title, int show_search); |
213 | extern void cgit_print_snapshot_start(const char *mimetype, | 215 | extern void cgit_print_snapshot_start(const char *mimetype, |
214 | const char *filename, | 216 | const char *filename, |
215 | struct cacheitem *item); | 217 | struct cacheitem *item); |
216 | 218 | ||
217 | extern void cgit_print_repolist(struct cacheitem *item); | 219 | extern void cgit_print_repolist(struct cacheitem *item); |
218 | extern void cgit_print_summary(); | 220 | extern void cgit_print_summary(); |
219 | extern void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *path, int pager); | 221 | extern void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *path, int pager); |
220 | extern void cgit_print_blob(struct cacheitem *item, const char *hex, char *path); | 222 | extern void cgit_print_blob(struct cacheitem *item, const char *hex, char *path); |
221 | extern void cgit_print_tree(const char *rev, char *path); | 223 | extern void cgit_print_tree(const char *rev, char *path); |
222 | extern void cgit_print_commit(const char *hex); | 224 | extern void cgit_print_commit(const char *hex); |
223 | extern void cgit_print_diff(const char *head, const char *old_hex, const char *new_hex, | 225 | extern void cgit_print_diff(const char *head, const char *old_hex, const char *new_hex, |
224 | char *path); | 226 | char *path); |
225 | extern void cgit_print_snapshot(struct cacheitem *item, const char *hex, | 227 | extern void cgit_print_snapshot(struct cacheitem *item, const char *hex, |
226 | const char *format, const char *prefix, | 228 | const char *format, const char *prefix, |
227 | const char *filename); | 229 | const char *filename); |
228 | 230 | ||
229 | #endif /* CGIT_H */ | 231 | #endif /* CGIT_H */ |
diff --git a/ui-repolist.c b/ui-repolist.c index 8ade91a..2018dab 100644 --- a/ui-repolist.c +++ b/ui-repolist.c | |||
@@ -68,33 +68,31 @@ void cgit_print_repolist(struct cacheitem *item) | |||
68 | if ((last_group == NULL && cgit_repo->group != NULL) || | 68 | if ((last_group == NULL && cgit_repo->group != NULL) || |
69 | (last_group != NULL && cgit_repo->group == NULL) || | 69 | (last_group != NULL && cgit_repo->group == NULL) || |
70 | (last_group != NULL && cgit_repo->group != NULL && | 70 | (last_group != NULL && cgit_repo->group != NULL && |
71 | strcmp(cgit_repo->group, last_group))) { | 71 | strcmp(cgit_repo->group, last_group))) { |
72 | html("<tr class='nohover'><td colspan='4' class='repogroup'>"); | 72 | html("<tr class='nohover'><td colspan='4' class='repogroup'>"); |
73 | html_txt(cgit_repo->group); | 73 | html_txt(cgit_repo->group); |
74 | html("</td></tr>"); | 74 | html("</td></tr>"); |
75 | last_group = cgit_repo->group; | 75 | last_group = cgit_repo->group; |
76 | } | 76 | } |
77 | htmlf("<tr><td class='%s'>", | 77 | htmlf("<tr><td class='%s'>", |
78 | cgit_repo->group ? "sublevel-repo" : "toplevel-repo"); | 78 | cgit_repo->group ? "sublevel-repo" : "toplevel-repo"); |
79 | html_link_open(cgit_repourl(cgit_repo->url), NULL, NULL); | 79 | html_link_open(cgit_repourl(cgit_repo->url), NULL, NULL); |
80 | html_txt(cgit_repo->name); | 80 | html_txt(cgit_repo->name); |
81 | html_link_close(); | 81 | html_link_close(); |
82 | html("</td><td>"); | 82 | html("</td><td>"); |
83 | html_ntxt(cgit_max_repodesc_len, cgit_repo->desc); | 83 | html_ntxt(cgit_max_repodesc_len, cgit_repo->desc); |
84 | html("</td><td>"); | 84 | html("</td><td>"); |
85 | html_txt(cgit_repo->owner); | 85 | html_txt(cgit_repo->owner); |
86 | html("</td><td>"); | 86 | html("</td><td>"); |
87 | print_modtime(cgit_repo); | 87 | print_modtime(cgit_repo); |
88 | html("</td><td>"); | 88 | html("</td><td>"); |
89 | html_link_open(cgit_repourl(cgit_repo->url), | 89 | html_link_open(cgit_repourl(cgit_repo->url), |
90 | "Summary", "button"); | 90 | "Summary", "button"); |
91 | html("S</a>"); | 91 | html("S</a>"); |
92 | html_link_open(cgit_pageurl(cgit_repo->name, "log", NULL), | 92 | cgit_log_link("L", "Log", "button", NULL, NULL, NULL); |
93 | "Log", "button"); | ||
94 | html("L</a>"); | ||
95 | cgit_tree_link("F", "Files", "button", NULL, NULL, NULL); | 93 | cgit_tree_link("F", "Files", "button", NULL, NULL, NULL); |
96 | html("</td></tr>\n"); | 94 | html("</td></tr>\n"); |
97 | } | 95 | } |
98 | html("</table>"); | 96 | html("</table>"); |
99 | cgit_print_docend(); | 97 | cgit_print_docend(); |
100 | } | 98 | } |
diff --git a/ui-shared.c b/ui-shared.c index 657e8af..64ee79c 100644 --- a/ui-shared.c +++ b/ui-shared.c | |||
@@ -106,73 +106,85 @@ static char *repolink(char *title, char *class, char *page, char *head, | |||
106 | html(" href='"); | 106 | html(" href='"); |
107 | if (cgit_virtual_root) { | 107 | if (cgit_virtual_root) { |
108 | html_attr(cgit_virtual_root); | 108 | html_attr(cgit_virtual_root); |
109 | if (cgit_virtual_root[strlen(cgit_virtual_root) - 1] != '/') | 109 | if (cgit_virtual_root[strlen(cgit_virtual_root) - 1] != '/') |
110 | html("/"); | 110 | html("/"); |
111 | html_attr(cgit_repo->url); | 111 | html_attr(cgit_repo->url); |
112 | if (cgit_repo->url[strlen(cgit_repo->url) - 1] != '/') | 112 | if (cgit_repo->url[strlen(cgit_repo->url) - 1] != '/') |
113 | html("/"); | 113 | html("/"); |
114 | html(page); | 114 | html(page); |
115 | html("/"); | 115 | html("/"); |
116 | if (path) | 116 | if (path) |
117 | html_attr(path); | 117 | html_attr(path); |
118 | } else { | 118 | } else { |
119 | html(cgit_script_name); | 119 | html(cgit_script_name); |
120 | html("?url="); | 120 | html("?url="); |
121 | html_attr(cgit_repo->url); | 121 | html_attr(cgit_repo->url); |
122 | if (cgit_repo->url[strlen(cgit_repo->url) - 1] != '/') | 122 | if (cgit_repo->url[strlen(cgit_repo->url) - 1] != '/') |
123 | html("/"); | 123 | html("/"); |
124 | html(page); | 124 | html(page); |
125 | html("/"); | 125 | html("/"); |
126 | if (path) | 126 | if (path) |
127 | html_attr(path); | 127 | html_attr(path); |
128 | delim = "&"; | 128 | delim = "&"; |
129 | } | 129 | } |
130 | if (head && strcmp(head, cgit_query_head)) { | 130 | if (head && strcmp(head, cgit_repo->defbranch)) { |
131 | html(delim); | 131 | html(delim); |
132 | html("h="); | 132 | html("h="); |
133 | html_attr(head); | 133 | html_attr(head); |
134 | delim = "&"; | 134 | delim = "&"; |
135 | } | 135 | } |
136 | return fmt("%s", delim); | 136 | return fmt("%s", delim); |
137 | } | 137 | } |
138 | 138 | ||
139 | void cgit_tree_link(char *name, char *title, char *class, char *head, | 139 | static char *reporevlink(char *page, char *name, char *title, char *class, |
140 | char *rev, char *path) | 140 | char *head, char *rev, char *path) |
141 | { | 141 | { |
142 | char *delim; | 142 | char *delim; |
143 | 143 | ||
144 | delim = repolink(title, class, "tree", head, path); | 144 | delim = repolink(title, class, page, head, path); |
145 | if (rev && strcmp(rev, cgit_query_head)) { | 145 | if (rev && strcmp(rev, cgit_query_head)) { |
146 | html(delim); | 146 | html(delim); |
147 | html("id="); | 147 | html("id="); |
148 | html_attr(rev); | 148 | html_attr(rev); |
149 | } | 149 | } |
150 | html("'>"); | 150 | html("'>"); |
151 | html_txt(name); | 151 | html_txt(name); |
152 | html("</a>"); | 152 | html("</a>"); |
153 | } | 153 | } |
154 | 154 | ||
155 | void cgit_tree_link(char *name, char *title, char *class, char *head, | ||
156 | char *rev, char *path) | ||
157 | { | ||
158 | reporevlink("tree", name, title, class, head, rev, path); | ||
159 | } | ||
160 | |||
161 | void cgit_log_link(char *name, char *title, char *class, char *head, | ||
162 | char *rev, char *path) | ||
163 | { | ||
164 | reporevlink("log", name, title, class, head, rev, path); | ||
165 | } | ||
166 | |||
155 | void cgit_print_date(time_t secs, char *format) | 167 | void cgit_print_date(time_t secs, char *format) |
156 | { | 168 | { |
157 | char buf[64]; | 169 | char buf[64]; |
158 | struct tm *time; | 170 | struct tm *time; |
159 | 171 | ||
160 | time = gmtime(&secs); | 172 | time = gmtime(&secs); |
161 | strftime(buf, sizeof(buf)-1, format, time); | 173 | strftime(buf, sizeof(buf)-1, format, time); |
162 | html_txt(buf); | 174 | html_txt(buf); |
163 | } | 175 | } |
164 | 176 | ||
165 | void cgit_print_age(time_t t, time_t max_relative, char *format) | 177 | void cgit_print_age(time_t t, time_t max_relative, char *format) |
166 | { | 178 | { |
167 | time_t now, secs; | 179 | time_t now, secs; |
168 | 180 | ||
169 | time(&now); | 181 | time(&now); |
170 | secs = now - t; | 182 | secs = now - t; |
171 | 183 | ||
172 | if (secs > max_relative && max_relative >= 0) { | 184 | if (secs > max_relative && max_relative >= 0) { |
173 | cgit_print_date(t, format); | 185 | cgit_print_date(t, format); |
174 | return; | 186 | return; |
175 | } | 187 | } |
176 | 188 | ||
177 | if (secs < TM_HOUR * 2) { | 189 | if (secs < TM_HOUR * 2) { |
178 | htmlf("<span class='age-mins'>%.0f min.</span>", | 190 | htmlf("<span class='age-mins'>%.0f min.</span>", |
diff --git a/ui-summary.c b/ui-summary.c index 4bda4c2..29b76e3 100644 --- a/ui-summary.c +++ b/ui-summary.c | |||
@@ -4,53 +4,49 @@ | |||
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 header; | 11 | static int header; |
12 | 12 | ||
13 | static int cgit_print_branch_cb(const char *refname, const unsigned char *sha1, | 13 | static int cgit_print_branch_cb(const char *refname, const unsigned char *sha1, |
14 | int flags, void *cb_data) | 14 | int flags, void *cb_data) |
15 | { | 15 | { |
16 | struct commit *commit; | 16 | struct commit *commit; |
17 | struct commitinfo *info; | 17 | struct commitinfo *info; |
18 | char buf[256], *url; | 18 | char buf[256], *url; |
19 | 19 | ||
20 | strncpy(buf, refname, sizeof(buf)); | 20 | strncpy(buf, refname, sizeof(buf)); |
21 | commit = lookup_commit(sha1); | 21 | commit = lookup_commit(sha1); |
22 | // object is not really parsed at this point, because of some fallout | 22 | // object is not really parsed at this point, because of some fallout |
23 | // from previous calls to git functions in cgit_print_log() | 23 | // from previous calls to git functions in cgit_print_log() |
24 | commit->object.parsed = 0; | 24 | commit->object.parsed = 0; |
25 | if (commit && !parse_commit(commit)){ | 25 | if (commit && !parse_commit(commit)){ |
26 | info = cgit_parse_commit(commit); | 26 | info = cgit_parse_commit(commit); |
27 | html("<tr><td>"); | 27 | html("<tr><td>"); |
28 | url = cgit_pageurl(cgit_query_repo, "log", | 28 | cgit_log_link(refname, NULL, NULL, refname, NULL, NULL); |
29 | fmt("h=%s", refname)); | ||
30 | html_link_open(url, NULL, NULL); | ||
31 | html_txt(buf); | ||
32 | html_link_close(); | ||
33 | html("</td><td>"); | 29 | html("</td><td>"); |
34 | cgit_print_age(commit->date, -1, NULL); | 30 | cgit_print_age(commit->date, -1, NULL); |
35 | html("</td><td>"); | 31 | html("</td><td>"); |
36 | html_txt(info->author); | 32 | html_txt(info->author); |
37 | html("</td><td>"); | 33 | html("</td><td>"); |
38 | url = cgit_pageurl(cgit_query_repo, "commit", | 34 | url = cgit_pageurl(cgit_query_repo, "commit", |
39 | fmt("h=%s", sha1_to_hex(sha1))); | 35 | fmt("h=%s", sha1_to_hex(sha1))); |
40 | html_link_open(url, NULL, NULL); | 36 | html_link_open(url, NULL, NULL); |
41 | html_ntxt(cgit_max_msg_len, info->subject); | 37 | html_ntxt(cgit_max_msg_len, info->subject); |
42 | html_link_close(); | 38 | html_link_close(); |
43 | html("</td></tr>\n"); | 39 | html("</td></tr>\n"); |
44 | cgit_free_commitinfo(info); | 40 | cgit_free_commitinfo(info); |
45 | } else { | 41 | } else { |
46 | html("<tr><td>"); | 42 | html("<tr><td>"); |
47 | html_txt(buf); | 43 | html_txt(buf); |
48 | html("</td><td colspan='3'>"); | 44 | html("</td><td colspan='3'>"); |
49 | htmlf("*** bad ref %s ***", sha1_to_hex(sha1)); | 45 | htmlf("*** bad ref %s ***", sha1_to_hex(sha1)); |
50 | html("</td></tr>\n"); | 46 | html("</td></tr>\n"); |
51 | } | 47 | } |
52 | return 0; | 48 | return 0; |
53 | } | 49 | } |
54 | 50 | ||
55 | 51 | ||
56 | static void cgit_print_object_ref(struct object *obj) | 52 | static void cgit_print_object_ref(struct object *obj) |
@@ -71,56 +71,52 @@ static int ls_item(const unsigned char *sha1, const char *base, int baselen, | |||
71 | sha1_to_hex(sha1)); | 71 | sha1_to_hex(sha1)); |
72 | return 0; | 72 | return 0; |
73 | } | 73 | } |
74 | 74 | ||
75 | html("<tr><td class='ls-mode'>"); | 75 | html("<tr><td class='ls-mode'>"); |
76 | html_filemode(mode); | 76 | html_filemode(mode); |
77 | html("</td><td>"); | 77 | html("</td><td>"); |
78 | if (S_ISDIRLNK(mode)) { | 78 | if (S_ISDIRLNK(mode)) { |
79 | htmlf("<a class='ls-mod' href='"); | 79 | htmlf("<a class='ls-mod' href='"); |
80 | html_attr(fmt(cgit_repo->module_link, | 80 | html_attr(fmt(cgit_repo->module_link, |
81 | name, | 81 | name, |
82 | sha1_to_hex(sha1))); | 82 | sha1_to_hex(sha1))); |
83 | html("'>"); | 83 | html("'>"); |
84 | html_txt(name); | 84 | html_txt(name); |
85 | html("</a>"); | 85 | html("</a>"); |
86 | } else if (S_ISDIR(mode)) { | 86 | } else if (S_ISDIR(mode)) { |
87 | cgit_tree_link(name, NULL, "ls-dir", cgit_query_head, | 87 | cgit_tree_link(name, NULL, "ls-dir", cgit_query_head, |
88 | curr_rev, fullpath); | 88 | curr_rev, fullpath); |
89 | } else { | 89 | } else { |
90 | cgit_tree_link(name, NULL, "ls-blob", cgit_query_head, | 90 | cgit_tree_link(name, NULL, "ls-blob", cgit_query_head, |
91 | curr_rev, fullpath); | 91 | curr_rev, fullpath); |
92 | } | 92 | } |
93 | htmlf("</td><td class='ls-size'>%li</td>", size); | 93 | htmlf("</td><td class='ls-size'>%li</td>", size); |
94 | 94 | ||
95 | html("<td><a href='"); | 95 | html("<td>"); |
96 | qry = fmt("h=%s&path=%s%s%s", curr_rev, | 96 | cgit_log_link("L", "Log", "button", cgit_query_head, curr_rev, |
97 | cgit_query_path ? cgit_query_path : "", | 97 | fullpath); |
98 | cgit_query_path ? "/" : "", pathname); | 98 | html("</td></tr>\n"); |
99 | url = cgit_pageurl(cgit_query_repo, "log", qry); | ||
100 | html_attr(url); | ||
101 | html("' title='Log' class='button'>L</a></td>"); | ||
102 | html("</tr>\n"); | ||
103 | free(name); | 99 | free(name); |
104 | return 0; | 100 | return 0; |
105 | } | 101 | } |
106 | 102 | ||
107 | static void ls_head() | 103 | static void ls_head() |
108 | { | 104 | { |
109 | html("<table class='list'>\n"); | 105 | html("<table class='list'>\n"); |
110 | html("<tr class='nohover'>"); | 106 | html("<tr class='nohover'>"); |
111 | html("<th class='left'>Mode</th>"); | 107 | html("<th class='left'>Mode</th>"); |
112 | html("<th class='left'>Name</th>"); | 108 | html("<th class='left'>Name</th>"); |
113 | html("<th class='right'>Size</th>"); | 109 | html("<th class='right'>Size</th>"); |
114 | html("<th/>"); | 110 | html("<th/>"); |
115 | html("</tr>\n"); | 111 | html("</tr>\n"); |
116 | header = 1; | 112 | header = 1; |
117 | } | 113 | } |
118 | 114 | ||
119 | static void ls_tail() | 115 | static void ls_tail() |
120 | { | 116 | { |
121 | if (!header) | 117 | if (!header) |
122 | return; | 118 | return; |
123 | html("</table>\n"); | 119 | html("</table>\n"); |
124 | header = 0; | 120 | header = 0; |
125 | } | 121 | } |
126 | 122 | ||