Commit Diff


commit - e03cc83491255ff69034ff6c824f9ba6062fcddd
commit + 9f6f394340870ce92e48a6d248d41d3d35d3fbf2
blob - e0c4b29b1bbf16ca75bef799ffca5591edb2048a
blob + 6ea20ef0a924a94c08ae5889e41d840e289d9de3
--- gotweb/gotweb.c
+++ gotweb/gotweb.c
@@ -2192,8 +2192,32 @@ gw_template(size_t key, void *arg)
 	const struct got_error *error = NULL;
 	enum kcgi_err kerr = KCGI_OK;
 	struct gw_trans *gw_trans = arg;
-	char *img_src = NULL;
+	char *ati = NULL, *fic32 = NULL, *fic16 = NULL;
+	char *swm = NULL, *spt = NULL, *css = NULL, *logo = NULL;
 
+	if (asprintf(&ati, "%s%s", gw_trans->gw_conf->got_www_path,
+	    "/apple-touch-icon.png") == -1)
+		goto err;
+	if (asprintf(&fic32, "%s%s", gw_trans->gw_conf->got_www_path,
+	     "/favicon-32x32.png") == -1)
+		goto err;
+	if (asprintf(&fic16, "%s%s", gw_trans->gw_conf->got_www_path,
+	    "/favicon-16x16.png") == -1)
+		goto err;
+	if (asprintf(&swm, "%s%s", gw_trans->gw_conf->got_www_path,
+	    "/site.webmanifest") == -1)
+		goto err;
+	if (asprintf(&spt, "%s%s", gw_trans->gw_conf->got_www_path,
+	    "/safari-pinned-tab.svg") == -1)
+		goto err;
+	if (asprintf(&css, "%s%s", gw_trans->gw_conf->got_www_path,
+	    "/gotweb.css") == -1)
+		goto err;
+	if (asprintf(&logo, "%s%s%s", gw_trans->gw_conf->got_www_path,
+	    gw_trans->gw_conf->got_www_path ? "/" : "",
+	    gw_trans->gw_conf->got_logo) == -1)
+		goto err;
+
 	switch (key) {
 	case (TEMPL_HEAD):
 		kerr = khtml_attr(gw_trans->gw_html_req, KELEM_META,
@@ -2231,7 +2255,7 @@ gw_template(size_t key, void *arg)
 			return 0;
 		kerr = khtml_attr(gw_trans->gw_html_req, KELEM_LINK,
 		    KATTR_REL, "apple-touch-icon", KATTR_SIZES, "180x180",
-		    KATTR_HREF, "/apple-touch-icon.png", KATTR__MAX);
+		    KATTR_HREF, ati, KATTR__MAX);
 		if (kerr != KCGI_OK)
 			return 0;
 		kerr = khtml_closeelem(gw_trans->gw_html_req, 1);
@@ -2239,7 +2263,7 @@ gw_template(size_t key, void *arg)
 			return 0;
 		kerr = khtml_attr(gw_trans->gw_html_req, KELEM_LINK,
 		    KATTR_REL, "icon", KATTR_TYPE, "image/png", KATTR_SIZES,
-		    "32x32", KATTR_HREF, "/favicon-32x32.png", KATTR__MAX);
+		    "32x32", KATTR_HREF, fic32, KATTR__MAX);
 		if (kerr != KCGI_OK)
 			return 0;
 		kerr = khtml_closeelem(gw_trans->gw_html_req, 1);
@@ -2247,14 +2271,14 @@ gw_template(size_t key, void *arg)
 			return 0;
 		kerr = khtml_attr(gw_trans->gw_html_req, KELEM_LINK,
 		    KATTR_REL, "icon", KATTR_TYPE, "image/png", KATTR_SIZES,
-		    "16x16", KATTR_HREF, "/favicon-16x16.png", KATTR__MAX);
+		    "16x16", KATTR_HREF, fic16, KATTR__MAX);
 		if (kerr != KCGI_OK)
 			return 0;
 		kerr = khtml_closeelem(gw_trans->gw_html_req, 1);
 		if (kerr != KCGI_OK)
 			return 0;
 		kerr = khtml_attr(gw_trans->gw_html_req, KELEM_LINK,
-		    KATTR_REL, "manifest", KATTR_HREF, "/site.webmanifest",
+		    KATTR_REL, "manifest", KATTR_HREF, swm,
 		    KATTR__MAX);
 		if (kerr != KCGI_OK)
 			return 0;
@@ -2263,7 +2287,7 @@ gw_template(size_t key, void *arg)
 			return 0;
 		kerr = khtml_attr(gw_trans->gw_html_req, KELEM_LINK,
 		    KATTR_REL, "mask-icon", KATTR_HREF,
-		    "/safari-pinned-tab.svg", KATTR__MAX);
+		    spt, KATTR__MAX);
 		if (kerr != KCGI_OK)
 			return 0;
 		kerr = khtml_closeelem(gw_trans->gw_html_req, 1);
@@ -2271,7 +2295,7 @@ gw_template(size_t key, void *arg)
 			return 0;
 		kerr = khtml_attr(gw_trans->gw_html_req, KELEM_LINK,
 		    KATTR_REL, "stylesheet", KATTR_TYPE, "text/css",
-		    KATTR_HREF, "/gotweb.css", KATTR__MAX);
+		    KATTR_HREF, css, KATTR__MAX);
 		if (kerr != KCGI_OK)
 			return 0;
 		kerr = khtml_closeelem(gw_trans->gw_html_req, 1);
@@ -2288,20 +2312,13 @@ gw_template(size_t key, void *arg)
 		    KATTR_TARGET, "_sotd", KATTR__MAX);
 		if (kerr != KCGI_OK)
 			return 0;
-		if (asprintf(&img_src, "/%s",
-		    gw_trans->gw_conf->got_logo) == -1)
-			return 0;
 		kerr = khtml_attr(gw_trans->gw_html_req, KELEM_IMG,
-		    KATTR_SRC, img_src, KATTR__MAX);
-		if (kerr != KCGI_OK) {
-			free(img_src);
+		    KATTR_SRC, logo, KATTR__MAX);
+		if (kerr != KCGI_OK)
 			return 0;
-		}
 		kerr = khtml_closeelem(gw_trans->gw_html_req, 3);
-		if (kerr != KCGI_OK) {
-			free(img_src);
+		if (kerr != KCGI_OK)
 			return 0;
-		}
 		break;
 	case (TEMPL_SITEPATH):
 		error = gw_output_site_link(gw_trans);
@@ -2379,7 +2396,23 @@ gw_template(size_t key, void *arg)
 	default:
 		return 0;
 	}
+	free(ati);
+	free(fic32);
+	free(fic16);
+	free(swm);
+	free(spt);
+	free(css);
+	free(logo);
 	return 1;
+err:
+	free(ati);
+	free(fic32);
+	free(fic16);
+	free(swm);
+	free(spt);
+	free(css);
+	free(logo);
+	return 0;
 }
 
 static const struct got_error *
@@ -4701,6 +4734,7 @@ main(int argc, char *argv[])
 done:
 	if (gw_malloc) {
 		free(gw_trans->gw_conf->got_repos_path);
+		free(gw_trans->gw_conf->got_www_path);
 		free(gw_trans->gw_conf->got_site_name);
 		free(gw_trans->gw_conf->got_site_owner);
 		free(gw_trans->gw_conf->got_site_link);
blob - 62d2057c8f471e7dfccf179ea8bd7c98fd0d8de1
blob + d1056ee45db9e7d5294040b6585e57797ed9ffcf
--- gotweb/gotweb.conf.5
+++ gotweb/gotweb.conf.5
@@ -88,6 +88,8 @@ Set the displayed site name title.
 Set the displayed site owner.
 .It Ic got_show_site_owner Ar on | off
 Toggle display of the site owner.
+.It Ic got_www_path Ar string
+Set the public gotweb httpd path.
 .El
 .Sh EXAMPLES
 These are the currently configurable items for
@@ -101,6 +103,7 @@ with their default values.
 #
 
 got_repos_path			"/got/public"
+got_www_path			"/gotweb"
 
 #got_max_repos			100
 #got_max_repos_display		25
blob - c2c8f7043eff68f8b9dfc3de1baa9d8d8fef8de5
blob + 0f7fca003fcd9433a1c8592954cba83f34534467
--- gotweb/gotweb.h
+++ gotweb/gotweb.h
@@ -27,6 +27,7 @@
 #define GOTWEB_GOT_DIR	 ".got"
 #define GOTWEB_GIT_DIR	 ".git"
 
+#define D_GOTWWW	 ""
 #define D_GOTPATH	 "/got/public"
 #define D_SITENAME	 "Gotweb"
 #define D_SITEOWNER	 "Got Owner"
@@ -48,6 +49,7 @@
 
 struct gotweb_config {
 	char		*got_repos_path;
+	char		*got_www_path;
 	char		*got_site_name;
 	char		*got_site_owner;
 	char		*got_site_link;
blob - 93c6e03f94ed0176787d92976b2a68085ae10de3
blob + c662466befc147e80fcf92724f47490bd4b4c45e
--- gotweb/parse.y
+++ gotweb/parse.y
@@ -130,13 +130,22 @@ boolean		: STRING {
 		;
 main		: GOT_REPOS_PATH STRING {
 			gw_conf->got_repos_path = strdup($2);
-			if (gw_conf->got_repos_path== NULL) {
+			if (gw_conf->got_repos_path == NULL) {
 				free($2);
 				yyerror("strdup");
 				YYERROR;
 			}
 			free($2);
 		}
+		| GOT_WWW_PATH STRING {
+			gw_conf->got_www_path = strdup($2);
+			if (gw_conf->got_www_path == NULL) {
+				free($2);
+				yyerror("strdup");
+				YYERROR;
+			}
+			free($2);
+		}
 		| GOT_MAX_REPOS NUMBER {
 			if ($2 > 0)
 				gw_conf->got_max_repos = $2;
@@ -265,6 +274,7 @@ lookup(char *s)
 		{ "got_site_link",		GOT_SITE_LINK },
 		{ "got_site_name",		GOT_SITE_NAME },
 		{ "got_site_owner",		GOT_SITE_OWNER },
+		{ "got_www_path",		GOT_WWW_PATH },
 	};
 	const struct keywords	*p;
 
@@ -594,6 +604,11 @@ parse_gotweb_config(struct gotweb_config **gconf, cons
 	}
 	gw_conf->got_repos_path = strdup(D_GOTPATH);
 	if (gw_conf->got_repos_path == NULL) {
+		gerror = got_error_from_errno("strdup");
+		goto done;
+	}
+	gw_conf->got_www_path = strdup(D_GOTWWW);
+	if (gw_conf->got_www_path == NULL) {
 		gerror = got_error_from_errno("strdup");
 		goto done;
 	}