From afc42b29912adcdd74560168b9fef6ecec267cb2 Mon Sep 17 00:00:00 2001 From: riomoo Date: Sun, 23 Nov 2025 04:46:02 -0500 Subject: [PATCH] feat: seperate html template --- app/gopherbook/main.go | 1828 +-------------------------- app/gopherbook/templates/index.html | 1814 ++++++++++++++++++++++++++ 2 files changed, 1824 insertions(+), 1818 deletions(-) create mode 100644 app/gopherbook/templates/index.html diff --git a/app/gopherbook/main.go b/app/gopherbook/main.go index 1173615..d4e695e 100644 --- a/app/gopherbook/main.go +++ b/app/gopherbook/main.go @@ -6,6 +6,7 @@ import ( "crypto/cipher" "crypto/rand" "crypto/sha256" + "embed" "encoding/base64" "encoding/json" "encoding/xml" @@ -26,6 +27,9 @@ import ( yzip "github.com/yeka/zip" ) +//go:embed templates/index.html +var templateFS embed.FS + // ComicInfo represents the standard ComicInfo.xml metadata type ComicInfo struct { XMLName xml.Name `xml:"ComicInfo"` @@ -1751,1823 +1755,11 @@ func encryptAES(plaintext []byte, key []byte) ([]byte, error) { } func serveUI(w http.ResponseWriter, r *http.Request) { + data, err := templateFS.ReadFile("templates/index.html") + if err != nil { + http.Error(w, "Template not found", http.StatusInternalServerError) + return + } w.Header().Set("Content-Type", "text/html") - w.Write([]byte(getHTML())) -} - -func getHTML() string { - return ` - - - - - Gopherbook - - - -
-
-

Gopherbook

- -
-
- -
-
- -
- - -
- -
-
- - -
-
- - -
- -
- - -
- - -
- -
-
-
Loading...
-
- - - / 0 - - - - - - -
-
-
- - Comic page -
- - - -
-
-
- -
- -
- -
-
-
-
🔒 Password Required
-
This comic is encrypted
-
- - - -
- - -
- -
- - -
-
-
- - - - - -` + w.Write(data) } diff --git a/app/gopherbook/templates/index.html b/app/gopherbook/templates/index.html new file mode 100644 index 0000000..60c298e --- /dev/null +++ b/app/gopherbook/templates/index.html @@ -0,0 +1,1814 @@ + + + + + + Gopherbook + + + +
+
+

Gopherbook

+ +
+
+ +
+
+ +
+ + +
+ +
+
+ + +
+
+ + +
+ +
+ + +
+ + +
+ +
+
+
Loading...
+
+ + + / 0 + + + + + + +
+
+
+ + Comic page +
+ + + +
+
+
+ +
+ +
+ +
+
+
+
🔒 Password Required
+
This comic is encrypted
+
+ + + +
+ + +
+ +
+ + +
+
+
+ + + + + +