aboutsummaryrefslogtreecommitdiffstats
path: root/ui-shared.c
diff options
context:
space:
mode:
authorGravatar Tobias Grimm <git@e-tobi.net>2011-07-31 09:44:05 (JST)
committerGravatar Lars Hjemli <hjemli@gmail.com>2012-01-04 00:20:17 (JST)
commit7530d94f05887b8065742adb614c368d8568a22c (patch)
tree7364cde2e397b40d84153a1527e50e863b69d69b /ui-shared.c
parente19f7d7180d64c8ba9ca15f5fe164606f0ec88c1 (diff)
downloadcgit-7530d94f05887b8065742adb614c368d8568a22c.zip
cgit-7530d94f05887b8065742adb614c368d8568a22c.tar.gz
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.
Diffstat (limited to 'ui-shared.c')
-rw-r--r--ui-shared.c24
1 files changed, 15 insertions, 9 deletions
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
136static void site_url(const char *page, const char *search, int ofs) 136static 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
163static void site_link(const char *page, const char *name, const char *title, 169static 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
184void cgit_index_link(const char *name, const char *title, const char *class, 190void 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
190static char *repolink(const char *title, const char *class, const char *page, 196static 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());