]> gitweb.ps.run Git - ps-cgit/blobdiff - ui-shared.c
ui-shared: Add current url helper function.
[ps-cgit] / ui-shared.c
index 1a84afc6bf39564aa73ef7f58826fe9f67f985f1..838437c46e07b1b632ceb6a915760c07d755f8c0 100644 (file)
@@ -65,6 +65,13 @@ const char *cgit_hosturl()
        return fmtalloc("%s:%s", ctx.env.server_name, ctx.env.server_port);
 }
 
+const char *cgit_currenturl()
+{
+       if (!ctx.qry.url)
+               return cgit_rooturl();
+       return ctx.qry.url;
+}
+
 const char *cgit_rooturl()
 {
        if (ctx.cfg.virtual_root)
@@ -144,10 +151,10 @@ static void site_url(const char *page, const char *search, const char *sort, int
 {
        char *delim = "?";
 
-       if (ctx.cfg.virtual_root)
-               html_attr(ctx.cfg.virtual_root);
+       if (!page)
+               html_attr(cgit_currenturl());
        else
-               html_url_path(ctx.cfg.script_name);
+               html_attr(cgit_rooturl());
 
        if (page) {
                htmlf("?p=%s", page);
@@ -952,7 +959,7 @@ void cgit_print_pageheader(void)
                                  NULL, NULL, 0);
                html("</td><td class='form'>");
                html("<form method='get' action='");
-               html_attr(cgit_rooturl());
+               html_attr(cgit_currenturl());
                html("'>\n");
                html("<input type='text' name='q' size='10' value='");
                html_attr(ctx.qry.search);