-rw-r--r-- | ui-shared.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/ui-shared.c b/ui-shared.c index 64ee79c..71c899a 100644 --- a/ui-shared.c +++ b/ui-shared.c | |||
@@ -123,60 +123,72 @@ static char *repolink(char *title, char *class, char *page, char *head, | |||
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_repo->defbranch)) { | 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 | static char *reporevlink(char *page, char *name, char *title, char *class, | 139 | static void reporevlink(char *page, char *name, char *title, char *class, |
140 | char *head, 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, page, 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, | 155 | void cgit_tree_link(char *name, char *title, char *class, char *head, |
156 | char *rev, char *path) | 156 | char *rev, char *path) |
157 | { | 157 | { |
158 | reporevlink("tree", name, title, class, head, rev, path); | 158 | reporevlink("tree", name, title, class, head, rev, path); |
159 | } | 159 | } |
160 | 160 | ||
161 | void cgit_log_link(char *name, char *title, char *class, char *head, | 161 | void cgit_log_link(char *name, char *title, char *class, char *head, |
162 | char *rev, char *path) | 162 | char *rev, char *path) |
163 | { | 163 | { |
164 | reporevlink("log", name, title, class, head, rev, path); | 164 | reporevlink("log", name, title, class, head, rev, path); |
165 | } | 165 | } |
166 | 166 | ||
167 | void cgit_commit_link(char *name, char *title, char *class, char *head, | ||
168 | char *rev) | ||
169 | { | ||
170 | if (strlen(name) > cgit_max_msg_len && cgit_max_msg_len >= 15) { | ||
171 | name[cgit_max_msg_len] = '\0'; | ||
172 | name[cgit_max_msg_len - 1] = '.'; | ||
173 | name[cgit_max_msg_len - 2] = '.'; | ||
174 | name[cgit_max_msg_len - 3] = '.'; | ||
175 | } | ||
176 | reporevlink("commit", name, title, class, head, rev, NULL); | ||
177 | } | ||
178 | |||
167 | void cgit_print_date(time_t secs, char *format) | 179 | void cgit_print_date(time_t secs, char *format) |
168 | { | 180 | { |
169 | char buf[64]; | 181 | char buf[64]; |
170 | struct tm *time; | 182 | struct tm *time; |
171 | 183 | ||
172 | time = gmtime(&secs); | 184 | time = gmtime(&secs); |
173 | strftime(buf, sizeof(buf)-1, format, time); | 185 | strftime(buf, sizeof(buf)-1, format, time); |
174 | html_txt(buf); | 186 | html_txt(buf); |
175 | } | 187 | } |
176 | 188 | ||
177 | void cgit_print_age(time_t t, time_t max_relative, char *format) | 189 | void cgit_print_age(time_t t, time_t max_relative, char *format) |
178 | { | 190 | { |
179 | time_t now, secs; | 191 | time_t now, secs; |
180 | 192 | ||
181 | time(&now); | 193 | time(&now); |
182 | secs = now - t; | 194 | secs = now - t; |