diff options
author | Tobias Grimm | 2011-07-31 02:44:05 +0200 |
---|---|---|
committer | Lars Hjemli | 2012-01-03 15:20:17 +0000 |
commit | 7530d94f05887b8065742adb614c368d8568a22c (patch) | |
tree | 7364cde2e397b40d84153a1527e50e863b69d69b | |
parent | ui-ssdiff: move LCS table away from the stack (diff) | |
download | cgit-7530d94f05887b8065742adb614c368d8568a22c.tar.gz cgit-7530d94f05887b8065742adb614c368d8568a22c.zip |
Add sort parameter to pager of repo list
When the repolist is paged, the page-links are missing the sort parameter, causing the initial page to be custom sorted, but any clicked page will then be with the default sort order again.
-rw-r--r-- | ui-repolist.c | 6 | ||||
-rw-r--r-- | ui-shared.c | 24 | ||||
-rw-r--r-- | ui-shared.h | 2 |
3 files changed, 19 insertions, 13 deletions
diff --git a/ui-repolist.c b/ui-repolist.c index e138f59..4b21e2f 100644 --- a/ui-repolist.c +++ b/ui-repolist.c | |||
@@ -109,13 +109,13 @@ void print_header(int columns) | |||
109 | } | 109 | } |
110 | 110 | ||
111 | 111 | ||
112 | void print_pager(int items, int pagelen, char *search) | 112 | void print_pager(int items, int pagelen, char *search, char *sort) |
113 | { | 113 | { |
114 | int i; | 114 | int i; |
115 | html("<div class='pager'>"); | 115 | html("<div class='pager'>"); |
116 | for(i = 0; i * pagelen < items; i++) | 116 | for(i = 0; i * pagelen < items; i++) |
117 | cgit_index_link(fmt("[%d]", i+1), fmt("Page %d", i+1), NULL, | 117 | cgit_index_link(fmt("[%d]", i+1), fmt("Page %d", i+1), NULL, |
118 | search, i * pagelen); | 118 | search, sort, i * pagelen); |
119 | html("</div>"); | 119 | html("</div>"); |
120 | } | 120 | } |
121 | 121 | ||
@@ -282,7 +282,7 @@ void cgit_print_repolist() | |||
282 | if (!hits) | 282 | if (!hits) |
283 | cgit_print_error("No repositories found"); | 283 | cgit_print_error("No repositories found"); |
284 | else if (hits > ctx.cfg.max_repo_count) | 284 | else if (hits > ctx.cfg.max_repo_count) |
285 | print_pager(hits, ctx.cfg.max_repo_count, ctx.qry.search); | 285 | print_pager(hits, ctx.cfg.max_repo_count, ctx.qry.search, ctx.qry.sort); |
286 | cgit_print_docend(); | 286 | cgit_print_docend(); |
287 | } | 287 | } |
288 | 288 | ||
diff --git a/ui-shared.c b/ui-shared.c index 5aa9119..85c2096 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, |
@@ -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); |
@@ -782,7 +788,7 @@ static void print_header(struct cgit_context *ctx) | |||
782 | 788 | ||
783 | html("<td class='main'>"); | 789 | html("<td class='main'>"); |
784 | if (ctx->repo) { | 790 | if (ctx->repo) { |
785 | cgit_index_link("index", NULL, NULL, NULL, 0); | 791 | cgit_index_link("index", NULL, NULL, NULL, NULL, 0); |
786 | html(" : "); | 792 | html(" : "); |
787 | cgit_summary_link(ctx->repo->name, ctx->repo->name, NULL, NULL); | 793 | cgit_summary_link(ctx->repo->name, ctx->repo->name, NULL, NULL); |
788 | html("</td><td class='form'>"); | 794 | html("</td><td class='form'>"); |
@@ -858,10 +864,10 @@ void cgit_print_pageheader(struct cgit_context *ctx) | |||
858 | html("<input type='submit' value='search'/>\n"); | 864 | html("<input type='submit' value='search'/>\n"); |
859 | html("</form>\n"); | 865 | html("</form>\n"); |
860 | } else { | 866 | } else { |
861 | site_link(NULL, "index", NULL, hc(ctx, "repolist"), NULL, 0); | 867 | site_link(NULL, "index", NULL, hc(ctx, "repolist"), NULL, NULL, 0); |
862 | if (ctx->cfg.root_readme) | 868 | if (ctx->cfg.root_readme) |
863 | site_link("about", "about", NULL, hc(ctx, "about"), | 869 | site_link("about", "about", NULL, hc(ctx, "about"), |
864 | NULL, 0); | 870 | NULL, NULL, 0); |
865 | html("</td><td class='form'>"); | 871 | html("</td><td class='form'>"); |
866 | html("<form method='get' action='"); | 872 | html("<form method='get' action='"); |
867 | html_attr(cgit_rooturl()); | 873 | html_attr(cgit_rooturl()); |
diff --git a/ui-shared.h b/ui-shared.h index 3cc1258..865bd45 100644 --- a/ui-shared.h +++ b/ui-shared.h | |||
@@ -11,7 +11,7 @@ extern char *cgit_pageurl(const char *reponame, const char *pagename, | |||
11 | const char *query); | 11 | const char *query); |
12 | 12 | ||
13 | extern void cgit_index_link(const char *name, const char *title, | 13 | extern void cgit_index_link(const char *name, const char *title, |
14 | const char *class, const char *pattern, int ofs); | 14 | const char *class, const char *pattern, const char *sort, int ofs); |
15 | extern void cgit_summary_link(const char *name, const char *title, | 15 | extern void cgit_summary_link(const char *name, const char *title, |
16 | const char *class, const char *head); | 16 | const char *class, const char *head); |
17 | extern void cgit_tag_link(const char *name, const char *title, | 17 | extern void cgit_tag_link(const char *name, const char *title, |