X-Git-Url: https://gitweb.ps.run/ps-cgit/blobdiff_plain/2e4a41e84029cbfa70c654fe5dfb35747f2dfbba..121e65391446069a538ae8d3f7938452178de7c6:/ui-shared.c?ds=sidebyside
diff --git a/ui-shared.c b/ui-shared.c
index ff03cb2..ac5a287 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -11,7 +11,7 @@
#include "cmd.h"
#include "html.h"
-const char cgit_doctype[] =
+static const char cgit_doctype[] =
"\n";
@@ -46,7 +46,7 @@ void cgit_vprint_error(const char *fmt, va_list ap)
html("\n");
}
-const char *cgit_httpscheme()
+const char *cgit_httpscheme(void)
{
if (ctx.env.https && !strcmp(ctx.env.https, "on"))
return "https://";
@@ -54,7 +54,7 @@ const char *cgit_httpscheme()
return "http://";
}
-const char *cgit_hosturl()
+const char *cgit_hosturl(void)
{
if (ctx.env.http_host)
return ctx.env.http_host;
@@ -65,14 +65,18 @@ const char *cgit_hosturl()
return fmtalloc("%s:%s", ctx.env.server_name, ctx.env.server_port);
}
-const char *cgit_currenturl()
+const char *cgit_currenturl(void)
{
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()
+const char *cgit_rooturl(void)
{
if (ctx.cfg.virtual_root)
return ctx.cfg.virtual_root;
@@ -80,9 +84,9 @@ const char *cgit_rooturl()
return ctx.cfg.script_name;
}
-const char *cgit_loginurl()
+const char *cgit_loginurl(void)
{
- static const char *login_url = 0;
+ static const char *login_url;
if (!login_url)
login_url = fmtalloc("%s?p=login", cgit_rooturl());
return login_url;
@@ -119,7 +123,7 @@ char *cgit_fileurl(const char *reponame, const char *pagename,
char *cgit_pageurl(const char *reponame, const char *pagename,
const char *query)
{
- return cgit_fileurl(reponame, pagename, 0, query);
+ return cgit_fileurl(reponame, pagename, NULL, query);
}
const char *cgit_repobasename(const char *reponame)
@@ -555,25 +559,32 @@ void cgit_submodule_link(const char *class, char *path, const char *rev)
item = lookup_path(list, path);
}
}
- html("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("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("");
} else {
- html("#");
+ html("");
+ html_txt(path);
+ html("");
}
- html("'>");
- html_txt(path);
- html("");
html_txtf(" @ %.7s", rev);
if (item && tail)
path[len - 1] = tail;
@@ -735,7 +746,7 @@ void cgit_print_docstart(void)
html_include(ctx.cfg.header);
}
-void cgit_print_docend()
+void cgit_print_docend(void)
{
html(" \n");
if (ctx.cfg.embedded) {
@@ -884,6 +895,8 @@ static void print_header(void)
cgit_add_hidden_formfields(0, 1, ctx.qry.page);
html(" ");
html("");
html("");