diff --git a/faxSrc/assets/htmx/editor.html b/faxSrc/assets/htmx/editor.html
index f07a62e..30080bc 100644
--- a/faxSrc/assets/htmx/editor.html
+++ b/faxSrc/assets/htmx/editor.html
@@ -1,10 +1,5 @@
-
\ No newline at end of file
diff --git a/faxSrc/assets/htmx/login.html b/faxSrc/assets/htmx/login.html
index d5461e2..385445d 100644
--- a/faxSrc/assets/htmx/login.html
+++ b/faxSrc/assets/htmx/login.html
@@ -17,6 +17,7 @@
+{{ if .script }}
\ No newline at end of file
+
+{{ end }}
\ No newline at end of file
diff --git a/faxSrc/controllers/sendFax.go b/faxSrc/controllers/sendFax.go
index cfa2398..df9cde5 100644
--- a/faxSrc/controllers/sendFax.go
+++ b/faxSrc/controllers/sendFax.go
@@ -63,6 +63,9 @@ func sendRequestToPrinter(msg string) (PrintServerResponse, error) {
func SendFax(w http.ResponseWriter, r *http.Request) {
authd, token := isAuthenticated(r)
if !authd {
+ w.Header().Set("Content-Type", "text/json")
+ w.Write([]byte("{\"state\":\"unauthenticated\"}"))
+
return
}
@@ -82,6 +85,7 @@ func SendFax(w http.ResponseWriter, r *http.Request) {
_, err = sendRequestToPrinter(formData.Message)
if err != nil {
+ log.Println("Printer failed to process fax:", err)
w.Write([]byte("{\"state\":\"failed\"}"))
return
}
diff --git a/faxSrc/views/editorPage.go b/faxSrc/views/editorPage.go
index 4c33c11..b724b10 100644
--- a/faxSrc/views/editorPage.go
+++ b/faxSrc/views/editorPage.go
@@ -5,8 +5,8 @@ import "net/http"
func EditorPage(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
- mainPage := htmlTemplate("./assets/htmx/terminal.tmpl", map[string]interface{}{
- "content": htmlTemplate("./assets/htmx/editor.html", nil),
+ mainPage := HtmlTemplate("./assets/htmx/terminal.tmpl", map[string]interface{}{
+ "content": HtmlTemplate("./assets/htmx/editor.html", nil),
"renderNavBar": true,
"page": "fax",
})
diff --git a/faxSrc/views/loginPage.go b/faxSrc/views/loginPage.go
index 00ada52..a5b1fcf 100644
--- a/faxSrc/views/loginPage.go
+++ b/faxSrc/views/loginPage.go
@@ -5,8 +5,12 @@ import "net/http"
func LoginPage(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
- loginPage := htmlTemplate("./assets/htmx/terminal.tmpl", map[string]interface{}{
- "content": htmlTemplate("./assets/htmx/login.html", nil),
+ loginTemplate := HtmlTemplate("./assets/htmx/login.html", map[string]interface{}{
+ "script": true,
+ })
+
+ loginPage := HtmlTemplate("./assets/htmx/terminal.tmpl", map[string]interface{}{
+ "content": loginTemplate,
"renderNavBar": true,
"page": "fax",
})
diff --git a/faxSrc/views/templating.go b/faxSrc/views/templating.go
index 8488a20..4d0dd77 100644
--- a/faxSrc/views/templating.go
+++ b/faxSrc/views/templating.go
@@ -15,7 +15,7 @@ import (
// return file
// }
-func htmlTemplate(file string, data map[string]interface{}) template.HTML {
+func HtmlTemplate(file string, data map[string]interface{}) template.HTML {
templateName := path.Base(file)
tmpl, err := template.New(templateName).ParseFiles(file)
if err != nil {