Commit b27da80170166a2622d2abce31dcd388edc14ae7

Tracey Emery 2020-01-29T17:48:56

remove html from blob output

diff --git a/gotweb/files/cgi-bin/gw_tmpl/blob.tmpl b/gotweb/files/cgi-bin/gw_tmpl/blob.tmpl
index 1281926..e434f32 100644
--- a/gotweb/files/cgi-bin/gw_tmpl/blob.tmpl
+++ b/gotweb/files/cgi-bin/gw_tmpl/blob.tmpl
@@ -1,22 +1 @@
-<!DOCTYPE html>
-<html>
-	<head>
-		<title>@@title@@</title>
-		@@head@@
-	</head>
-	<body>
-	<div id="gw_body">
-		<div id="header">
-			@@header@@
-		</div>
-		<div id="site_path">
-			@@sitepath@@
-			@@search@@
-		</div>
-		<div id="content">
-			@@content@@
-		</div>
-		@@siteowner@@
-	</div>
-	</body>
-</html>
+@@content@@
diff --git a/gotweb/gotweb.c b/gotweb/gotweb.c
index f1c85a7..b660738 100644
--- a/gotweb/gotweb.c
+++ b/gotweb/gotweb.c
@@ -367,7 +367,7 @@ gw_blob(struct gw_trans *gw_trans)
 {
 	const struct got_error *error = NULL;
 	struct gw_header *header = NULL;
-	char *blob = NULL, *blob_html = NULL, *blob_html_disp = NULL;
+	char *blob = NULL;
 	enum kcgi_err kerr;
 
 	if (pledge("stdio rpath wpath cpath proc exec sendfd unveil",
@@ -385,37 +385,22 @@ gw_blob(struct gw_trans *gw_trans)
 	if (error)
 		goto done;
 
-	blob_html = gw_get_file_blame_blob(gw_trans);
+	blob = gw_get_file_blame_blob(gw_trans);
 
-	if (blob_html == NULL) {
-		blob_html = strdup("");
-		if (blob_html == NULL) {
+	if (blob == NULL) {
+		blob = strdup("");
+		if (blob == NULL) {
 			error = got_error_from_errno("strdup");
 			goto done;
 		}
 	}
 
-	if (asprintf(&blob_html_disp, blob_header,
-	    gw_gen_age_header(gw_get_time_str(header->committer_time, TM_LONG)),
-	    gw_gen_commit_msg_header(gw_html_escape(header->commit_msg)),
-	    blob_html) == -1) {
-		error = got_error_from_errno("asprintf");
-		goto done;
-	}
-
-	if (asprintf(&blob, blob_wrapper, blob_html_disp) == -1) {
-		error = got_error_from_errno("asprintf");
-		goto done;
-	}
-
 	kerr = khttp_puts(gw_trans->gw_req, blob);
 	if (kerr != KCGI_OK)
 		error = gw_kcgi_error(kerr);
 done:
 	got_ref_list_free(&header->refs);
 	gw_free_headers(header);
-	free(blob_html_disp);
-	free(blob_html);
 	free(blob);
 	return error;
 }
@@ -1194,8 +1179,8 @@ gw_parse_querystring(struct gw_trans *gw_trans)
 	if ((p = gw_trans->gw_req->fieldmap[KEY_PAGE]))
 		gw_trans->page = p->parsed.i;
 
-	/* if (gw_trans->action == GW_RAW) */
-	/* 	gw_trans->mime = KMIME_TEXT_PLAIN; */
+	if (gw_trans->action == GW_BLOB)
+		gw_trans->mime = KMIME_TEXT_PLAIN;
 
 	return error;
 }
diff --git a/gotweb/gotweb_ui.h b/gotweb/gotweb_ui.h
index 47c732d..fb264cc 100644
--- a/gotweb/gotweb_ui.h
+++ b/gotweb/gotweb_ui.h
@@ -208,30 +208,6 @@ char *briefs_navs =
 	"<a href='?path=%s&action=tree&commit=%s'>tree</a><!--/* | " \
 	"<a href='?path=%s&action=snapshot&commit=%s'>snapshot</a> */-->";
 
-/* blob.tmpl */
-
-char *blob_wrapper =
-	"<div id='blob_title_wrapper'>" \
-	"<div id='blob_title'>Blob</div></div>" \
-	"<div id='blob_content'>%s</div>";
-
-char *blob_header =
-	"<div id='blob_header_wrapper'>" \
-	"<div id='blob_header'>%s%s</div>" \
-	"</div>" \
-	"<div id='dotted_line'></div>" \
-	"<div id='blob'>%s</div>" \
-	"</div>";
-
-char *blob_line =
-	"<div id='blob_wrapper'>" \
-	"<div id='blob_number'>%.*d</div>" \
-	"<div id='blob_hash'>%.8s</div>" \
-	"<div id='blob_date'>%s</div>" \
-	"<div id='blob_author'>%-8s</div>" \
-	"<div id='blob_code'>%s</div>" \
-	"</div>";
-
 /* blame.tmpl */
 
 char *blame_wrapper =