diff options
Diffstat (limited to 'ui-shared.c')
-rw-r--r-- | ui-shared.c | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/ui-shared.c b/ui-shared.c index b736fca..43166af 100644 --- a/ui-shared.c +++ b/ui-shared.c | |||
@@ -133,7 +133,7 @@ char *cgit_currurl() | |||
133 | return fmt("%s/", ctx.cfg.virtual_root); | 133 | return fmt("%s/", ctx.cfg.virtual_root); |
134 | } | 134 | } |
135 | 135 | ||
136 | static void site_url(const char *page, const char *search, int ofs) | 136 | static void site_url(const char *page, const char *search, const char *sort, int ofs) |
137 | { | 137 | { |
138 | char *delim = "?"; | 138 | char *delim = "?"; |
139 | 139 | ||
@@ -154,6 +154,12 @@ static void site_url(const char *page, const char *search, int ofs) | |||
154 | html_attr(search); | 154 | html_attr(search); |
155 | delim = "&"; | 155 | delim = "&"; |
156 | } | 156 | } |
157 | if (sort) { | ||
158 | html(delim); | ||
159 | html("s="); | ||
160 | html_attr(sort); | ||
161 | delim = "&"; | ||
162 | } | ||
157 | if (ofs) { | 163 | if (ofs) { |
158 | html(delim); | 164 | html(delim); |
159 | htmlf("ofs=%d", ofs); | 165 | htmlf("ofs=%d", ofs); |
@@ -161,7 +167,7 @@ static void site_url(const char *page, const char *search, int ofs) | |||
161 | } | 167 | } |
162 | 168 | ||
163 | static void site_link(const char *page, const char *name, const char *title, | 169 | static void site_link(const char *page, const char *name, const char *title, |
164 | const char *class, const char *search, int ofs) | 170 | const char *class, const char *search, const char *sort, int ofs) |
165 | { | 171 | { |
166 | html("<a"); | 172 | html("<a"); |
167 | if (title) { | 173 | if (title) { |
@@ -175,16 +181,16 @@ static void site_link(const char *page, const char *name, const char *title, | |||
175 | html("'"); | 181 | html("'"); |
176 | } | 182 | } |
177 | html(" href='"); | 183 | html(" href='"); |
178 | site_url(page, search, ofs); | 184 | site_url(page, search, sort, ofs); |
179 | html("'>"); | 185 | html("'>"); |
180 | html_txt(name); | 186 | html_txt(name); |
181 | html("</a>"); | 187 | html("</a>"); |
182 | } | 188 | } |
183 | 189 | ||
184 | void cgit_index_link(const char *name, const char *title, const char *class, | 190 | void cgit_index_link(const char *name, const char *title, const char *class, |
185 | const char *pattern, int ofs) | 191 | const char *pattern, const char *sort, int ofs) |
186 | { | 192 | { |
187 | site_link(NULL, name, title, class, pattern, ofs); | 193 | site_link(NULL, name, title, class, pattern, sort, ofs); |
188 | } | 194 | } |
189 | 195 | ||
190 | static char *repolink(const char *title, const char *class, const char *page, | 196 | static char *repolink(const char *title, const char *class, const char *page, |
@@ -288,7 +294,7 @@ void cgit_log_link(const char *name, const char *title, const char *class, | |||
288 | char *delim; | 294 | char *delim; |
289 | 295 | ||
290 | delim = repolink(title, class, "log", head, path); | 296 | delim = repolink(title, class, "log", head, path); |
291 | if (rev && strcmp(rev, ctx.qry.head)) { | 297 | if (rev && ctx.qry.head && strcmp(rev, ctx.qry.head)) { |
292 | html(delim); | 298 | html(delim); |
293 | html("id="); | 299 | html("id="); |
294 | html_url_arg(rev); | 300 | html_url_arg(rev); |
@@ -332,7 +338,7 @@ void cgit_commit_link(char *name, const char *title, const char *class, | |||
332 | char *delim; | 338 | char *delim; |
333 | 339 | ||
334 | delim = repolink(title, class, "commit", head, path); | 340 | delim = repolink(title, class, "commit", head, path); |
335 | if (rev && strcmp(rev, ctx.qry.head)) { | 341 | if (rev && ctx.qry.head && strcmp(rev, ctx.qry.head)) { |
336 | html(delim); | 342 | html(delim); |
337 | html("id="); | 343 | html("id="); |
338 | html_url_arg(rev); | 344 | html_url_arg(rev); |
@@ -428,7 +434,7 @@ void cgit_self_link(char *name, const char *title, const char *class, | |||
428 | struct cgit_context *ctx) | 434 | struct cgit_context *ctx) |
429 | { | 435 | { |
430 | if (!strcmp(ctx->qry.page, "repolist")) | 436 | if (!strcmp(ctx->qry.page, "repolist")) |
431 | return cgit_index_link(name, title, class, ctx->qry.search, | 437 | return cgit_index_link(name, title, class, ctx->qry.search, ctx->qry.sort, |
432 | ctx->qry.ofs); | 438 | ctx->qry.ofs); |
433 | else if (!strcmp(ctx->qry.page, "summary")) | 439 | else if (!strcmp(ctx->qry.page, "summary")) |
434 | return cgit_summary_link(name, title, class, ctx->qry.head); | 440 | return cgit_summary_link(name, title, class, ctx->qry.head); |
@@ -669,7 +675,7 @@ void cgit_print_docstart(struct cgit_context *ctx) | |||
669 | html_attr(ctx->cfg.favicon); | 675 | html_attr(ctx->cfg.favicon); |
670 | html("'/>\n"); | 676 | html("'/>\n"); |
671 | } | 677 | } |
672 | if (host && ctx->repo) { | 678 | if (host && ctx->repo && ctx->qry.head) { |
673 | html("<link rel='alternate' title='Atom feed' href='"); | 679 | html("<link rel='alternate' title='Atom feed' href='"); |
674 | html(cgit_httpscheme()); | 680 | html(cgit_httpscheme()); |
675 | html_attr(cgit_hosturl()); | 681 | html_attr(cgit_hosturl()); |
@@ -838,7 +844,7 @@ static void print_header(struct cgit_context *ctx) | |||
838 | 844 | ||
839 | html("<td class='main'>"); | 845 | html("<td class='main'>"); |
840 | if (ctx->repo) { | 846 | if (ctx->repo) { |
841 | cgit_index_link("index", NULL, NULL, NULL, 0); | 847 | cgit_index_link("index", NULL, NULL, NULL, NULL, 0); |
842 | html(" : "); | 848 | html(" : "); |
843 | cgit_summary_link(ctx->repo->name, ctx->repo->name, NULL, NULL); | 849 | cgit_summary_link(ctx->repo->name, ctx->repo->name, NULL, NULL); |
844 | html("</td><td class='form'>"); | 850 | html("</td><td class='form'>"); |
@@ -914,10 +920,10 @@ void cgit_print_pageheader(struct cgit_context *ctx) | |||
914 | html("<input type='submit' value='search'/>\n"); | 920 | html("<input type='submit' value='search'/>\n"); |
915 | html("</form>\n"); | 921 | html("</form>\n"); |
916 | } else { | 922 | } else { |
917 | site_link(NULL, "index", NULL, hc(ctx, "repolist"), NULL, 0); | 923 | site_link(NULL, "index", NULL, hc(ctx, "repolist"), NULL, NULL, 0); |
918 | if (ctx->cfg.root_readme) | 924 | if (ctx->cfg.root_readme) |
919 | site_link("about", "about", NULL, hc(ctx, "about"), | 925 | site_link("about", "about", NULL, hc(ctx, "about"), |
920 | NULL, 0); | 926 | NULL, NULL, 0); |
921 | html("</td><td class='form'>"); | 927 | html("</td><td class='form'>"); |
922 | html("<form method='get' action='"); | 928 | html("<form method='get' action='"); |
923 | html_attr(cgit_rooturl()); | 929 | html_attr(cgit_rooturl()); |