]> gitweb.ps.run Git - ps-cgit/blobdiff - ui-shared.c
contrib/hooks: add sample post-receive hook using agefile
[ps-cgit] / ui-shared.c
index 7bcb8d33f5ba38a4421a1b7aac48d229a0e5a3d7..ac5a2871e3625fb3c4d6a5e1f30cb1bb65561022 100644 (file)
@@ -69,7 +69,11 @@ const char *cgit_currenturl(void)
 {
        if (!ctx.qry.url)
                return cgit_rooturl();
 {
        if (!ctx.qry.url)
                return cgit_rooturl();
-       return ctx.qry.url;
+       const char *root = cgit_rooturl();
+       size_t len = strlen(root);
+       if (len && root[len - 1] == '/')
+               return fmtalloc("%s%s", root, ctx.qry.url);
+       return fmtalloc("%s/%s", root, ctx.qry.url);
 }
 
 const char *cgit_rooturl(void)
 }
 
 const char *cgit_rooturl(void)
@@ -555,25 +559,32 @@ void cgit_submodule_link(const char *class, char *path, const char *rev)
                        item = lookup_path(list, path);
                }
        }
                        item = lookup_path(list, path);
                }
        }
-       html("<a ");
-       if (class)
-               htmlf("class='%s' ", class);
-       html("href='");
-       if (item) {
-               html_attrf(item->util, rev);
-       } else if (ctx.repo->module_link) {
-               dir = strrchr(path, '/');
-               if (dir)
-                       dir++;
-               else
-                       dir = path;
-               html_attrf(ctx.repo->module_link, dir, rev);
+       if (item || ctx.repo->module_link) {
+               html("<a ");
+               if (class)
+                       htmlf("class='%s' ", class);
+               html("href='");
+               if (item) {
+                       html_attrf(item->util, rev);
+               } else {
+                       dir = strrchr(path, '/');
+                       if (dir)
+                               dir++;
+                       else
+                               dir = path;
+                       html_attrf(ctx.repo->module_link, dir, rev);
+               }
+               html("'>");
+               html_txt(path);
+               html("</a>");
        } else {
        } else {
-               html("#");
+               html("<span");
+               if (class)
+                       htmlf(" class='%s'", class);
+               html(">");
+               html_txt(path);
+               html("</span>");
        }
        }
-       html("'>");
-       html_txt(path);
-       html("</a>");
        html_txtf(" @ %.7s", rev);
        if (item && tail)
                path[len - 1] = tail;
        html_txtf(" @ %.7s", rev);
        if (item && tail)
                path[len - 1] = tail;
@@ -884,6 +895,8 @@ static void print_header(void)
                        cgit_add_hidden_formfields(0, 1, ctx.qry.page);
                        html("<select name='h' onchange='this.form.submit();'>\n");
                        for_each_branch_ref(print_branch_option, ctx.qry.head);
                        cgit_add_hidden_formfields(0, 1, ctx.qry.page);
                        html("<select name='h' onchange='this.form.submit();'>\n");
                        for_each_branch_ref(print_branch_option, ctx.qry.head);
+                       if (ctx.repo->enable_remote_branches)
+                               for_each_remote_ref(print_branch_option, ctx.qry.head);
                        html("</select> ");
                        html("<input type='submit' name='' value='switch'/>");
                        html("</form>");
                        html("</select> ");
                        html("<input type='submit' name='' value='switch'/>");
                        html("</form>");