diff options
author | Jason A. Donenfeld | 2015-03-03 17:23:40 +0100 |
---|---|---|
committer | Jason A. Donenfeld | 2015-03-03 17:33:34 +0100 |
commit | 2e4a41e84029cbfa70c654fe5dfb35747f2dfbba (patch) | |
tree | db4a982a97a488d91370e252072286190b90530a | |
parent | ui-shared: Add current url helper function. (diff) | |
download | cgit-2e4a41e84029cbfa70c654fe5dfb35747f2dfbba.tar.gz cgit-2e4a41e84029cbfa70c654fe5dfb35747f2dfbba.zip |
Make root handling sane again.
-rw-r--r-- | ui-repolist.c | 2 | ||||
-rw-r--r-- | ui-shared.c | 24 | ||||
-rw-r--r-- | ui-shared.h | 2 |
3 files changed, 14 insertions, 14 deletions
diff --git a/ui-repolist.c b/ui-repolist.c index 12ac1fc..e945f67 100644 --- a/ui-repolist.c +++ b/ui-repolist.c | |||
@@ -140,7 +140,7 @@ static void print_pager(int items, int pagelen, char *search, char *sort) | |||
140 | class = (ctx.qry.ofs == ofs) ? "current" : NULL; | 140 | class = (ctx.qry.ofs == ofs) ? "current" : NULL; |
141 | html("<li>"); | 141 | html("<li>"); |
142 | cgit_index_link(fmt("[%d]", i + 1), fmt("Page %d", i + 1), | 142 | cgit_index_link(fmt("[%d]", i + 1), fmt("Page %d", i + 1), |
143 | class, search, sort, ofs); | 143 | class, search, sort, ofs, 0); |
144 | html("</li>"); | 144 | html("</li>"); |
145 | } | 145 | } |
146 | html("</ul>"); | 146 | html("</ul>"); |
diff --git a/ui-shared.c b/ui-shared.c index 838437c..ff03cb2 100644 --- a/ui-shared.c +++ b/ui-shared.c | |||
@@ -147,14 +147,14 @@ const char *cgit_repobasename(const char *reponame) | |||
147 | return rvbuf; | 147 | return rvbuf; |
148 | } | 148 | } |
149 | 149 | ||
150 | static void site_url(const char *page, const char *search, const char *sort, int ofs) | 150 | static void site_url(const char *page, const char *search, const char *sort, int ofs, int always_root) |
151 | { | 151 | { |
152 | char *delim = "?"; | 152 | char *delim = "?"; |
153 | 153 | ||
154 | if (!page) | 154 | if (always_root || page) |
155 | html_attr(cgit_currenturl()); | ||
156 | else | ||
157 | html_attr(cgit_rooturl()); | 155 | html_attr(cgit_rooturl()); |
156 | else | ||
157 | html_attr(cgit_currenturl()); | ||
158 | 158 | ||
159 | if (page) { | 159 | if (page) { |
160 | htmlf("?p=%s", page); | 160 | htmlf("?p=%s", page); |
@@ -179,7 +179,7 @@ static void site_url(const char *page, const char *search, const char *sort, int | |||
179 | } | 179 | } |
180 | 180 | ||
181 | static void site_link(const char *page, const char *name, const char *title, | 181 | static void site_link(const char *page, const char *name, const char *title, |
182 | const char *class, const char *search, const char *sort, int ofs) | 182 | const char *class, const char *search, const char *sort, int ofs, int always_root) |
183 | { | 183 | { |
184 | html("<a"); | 184 | html("<a"); |
185 | if (title) { | 185 | if (title) { |
@@ -193,16 +193,16 @@ static void site_link(const char *page, const char *name, const char *title, | |||
193 | html("'"); | 193 | html("'"); |
194 | } | 194 | } |
195 | html(" href='"); | 195 | html(" href='"); |
196 | site_url(page, search, sort, ofs); | 196 | site_url(page, search, sort, ofs, always_root); |
197 | html("'>"); | 197 | html("'>"); |
198 | html_txt(name); | 198 | html_txt(name); |
199 | html("</a>"); | 199 | html("</a>"); |
200 | } | 200 | } |
201 | 201 | ||
202 | void cgit_index_link(const char *name, const char *title, const char *class, | 202 | void cgit_index_link(const char *name, const char *title, const char *class, |
203 | const char *pattern, const char *sort, int ofs) | 203 | const char *pattern, const char *sort, int ofs, int always_root) |
204 | { | 204 | { |
205 | site_link(NULL, name, title, class, pattern, sort, ofs); | 205 | site_link(NULL, name, title, class, pattern, sort, ofs, always_root); |
206 | } | 206 | } |
207 | 207 | ||
208 | static char *repolink(const char *title, const char *class, const char *page, | 208 | static char *repolink(const char *title, const char *class, const char *page, |
@@ -446,7 +446,7 @@ static void cgit_self_link(char *name, const char *title, const char *class) | |||
446 | { | 446 | { |
447 | if (!strcmp(ctx.qry.page, "repolist")) | 447 | if (!strcmp(ctx.qry.page, "repolist")) |
448 | cgit_index_link(name, title, class, ctx.qry.search, ctx.qry.sort, | 448 | cgit_index_link(name, title, class, ctx.qry.search, ctx.qry.sort, |
449 | ctx.qry.ofs); | 449 | ctx.qry.ofs, 1); |
450 | else if (!strcmp(ctx.qry.page, "summary")) | 450 | else if (!strcmp(ctx.qry.page, "summary")) |
451 | cgit_summary_link(name, title, class, ctx.qry.head); | 451 | cgit_summary_link(name, title, class, ctx.qry.head); |
452 | else if (!strcmp(ctx.qry.page, "tag")) | 452 | else if (!strcmp(ctx.qry.page, "tag")) |
@@ -875,7 +875,7 @@ static void print_header(void) | |||
875 | 875 | ||
876 | html("<td class='main'>"); | 876 | html("<td class='main'>"); |
877 | if (ctx.repo) { | 877 | if (ctx.repo) { |
878 | cgit_index_link("index", NULL, NULL, NULL, NULL, 0); | 878 | cgit_index_link("index", NULL, NULL, NULL, NULL, 0, 1); |
879 | html(" : "); | 879 | html(" : "); |
880 | cgit_summary_link(ctx.repo->name, ctx.repo->name, NULL, NULL); | 880 | cgit_summary_link(ctx.repo->name, ctx.repo->name, NULL, NULL); |
881 | if (ctx.env.authenticated) { | 881 | if (ctx.env.authenticated) { |
@@ -953,10 +953,10 @@ void cgit_print_pageheader(void) | |||
953 | html("<input type='submit' value='search'/>\n"); | 953 | html("<input type='submit' value='search'/>\n"); |
954 | html("</form>\n"); | 954 | html("</form>\n"); |
955 | } else if (ctx.env.authenticated) { | 955 | } else if (ctx.env.authenticated) { |
956 | site_link(NULL, "index", NULL, hc("repolist"), NULL, NULL, 0); | 956 | site_link(NULL, "index", NULL, hc("repolist"), NULL, NULL, 0, 1); |
957 | if (ctx.cfg.root_readme) | 957 | if (ctx.cfg.root_readme) |
958 | site_link("about", "about", NULL, hc("about"), | 958 | site_link("about", "about", NULL, hc("about"), |
959 | NULL, NULL, 0); | 959 | NULL, NULL, 0, 1); |
960 | html("</td><td class='form'>"); | 960 | html("</td><td class='form'>"); |
961 | html("<form method='get' action='"); | 961 | html("<form method='get' action='"); |
962 | html_attr(cgit_currenturl()); | 962 | html_attr(cgit_currenturl()); |
diff --git a/ui-shared.h b/ui-shared.h index af78a13..1b8ecb5 100644 --- a/ui-shared.h +++ b/ui-shared.h | |||
@@ -15,7 +15,7 @@ extern char *cgit_pageurl(const char *reponame, const char *pagename, | |||
15 | extern void cgit_add_clone_urls(void (*fn)(const char *)); | 15 | extern void cgit_add_clone_urls(void (*fn)(const char *)); |
16 | 16 | ||
17 | extern void cgit_index_link(const char *name, const char *title, | 17 | extern void cgit_index_link(const char *name, const char *title, |
18 | const char *class, const char *pattern, const char *sort, int ofs); | 18 | const char *class, const char *pattern, const char *sort, int ofs, int always_root); |
19 | extern void cgit_summary_link(const char *name, const char *title, | 19 | extern void cgit_summary_link(const char *name, const char *title, |
20 | const char *class, const char *head); | 20 | const char *class, const char *head); |
21 | extern void cgit_tag_link(const char *name, const char *title, | 21 | extern void cgit_tag_link(const char *name, const char *title, |