webserver up and running for http/https, logger timestamp format change
This commit is contained in:
@@ -1,27 +0,0 @@
|
||||
{{ define "body" }}
|
||||
<body>
|
||||
<div class="container-fluid h-100 d-flex flex-column">
|
||||
<div class="row output flex-grow-1">
|
||||
<div class="col-3 left-sidebar" hx-sse="connect:/sse on:status" hx-swap="innerHTML">
|
||||
Status <br>
|
||||
Last Compilation <br>
|
||||
Such Info <br>
|
||||
Much wow
|
||||
</div>
|
||||
<div class="col-9 p-0">
|
||||
<iframe class="pdf-frame" src="servetex.pdf?ts=0" hx-sse="connect:/sse on:pdf" hx-swap="outerHTML"></iframe>
|
||||
</div>
|
||||
</div>
|
||||
<div class="command-out" hx-sse="connect:/sse on:output" hx-swap="innerHTML">
|
||||
compile start
|
||||
compile file-x
|
||||
compile file-y
|
||||
example output
|
||||
warning but who cares
|
||||
finished compilation
|
||||
output file created
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
{{ end }}
|
||||
@@ -1,14 +0,0 @@
|
||||
{{ define "head" }}
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>ServTeX</title>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="stylesheet" href="/jscss/bootstrap.min.css">
|
||||
<link rel="stylesheet" href="/jscss/custom-view.css">
|
||||
<script src="/jscss/htmx.min.js"></script>
|
||||
</head>
|
||||
|
||||
{{ end }}
|
||||
|
||||
@@ -1 +1,41 @@
|
||||
{{ template "header" . }}
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>ServTeX</title>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="stylesheet" href="/jscss/bootstrap.min.css">
|
||||
<link rel="stylesheet" href="/jscss/custom-view.css">
|
||||
<script src="/jscss/htmx.min.js"></script>
|
||||
<script src="/jscss/htmx-ext-sse.js"></script>
|
||||
</head>
|
||||
|
||||
|
||||
<body>
|
||||
<div class="container-fluid h-100 d-flex flex-column">
|
||||
<div class="row output flex-grow-1">
|
||||
<div class="col-3 left-sidebar" hx-sse="connect:/sse on:status" hx-swap="innerHTML">
|
||||
Status <br>
|
||||
Last Compilation <br>
|
||||
Such Info <br>
|
||||
Much wow
|
||||
</div>
|
||||
<div class="col-9 p-0">
|
||||
<iframe class="pdf-frame" src="/pdf?ts=0" hx-sse="connect:/sse on:pdf" hx-swap="outerHTML"></iframe>
|
||||
</div>
|
||||
</div>
|
||||
<div class="command-out" hx-sse="connect:/sse on:output" hx-swap="innerHTML">
|
||||
compile start<br>
|
||||
compile file-x<br>
|
||||
compile file-y<br>
|
||||
example output<br>
|
||||
warning but who cares<br>
|
||||
finished compilation<br>
|
||||
output file created<br>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
|
||||
</html>
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
<iframe class="pdf-frame" src="servetex.pdf?ts={{ .timestamp }}" hx-sse="connect:/sse/pdf" hx-swap="outerHTML"></iframe>
|
||||
@@ -3,6 +3,7 @@ package frontend
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
"embed"
|
||||
"strings"
|
||||
"net/http"
|
||||
"net/url"
|
||||
@@ -10,6 +11,13 @@ import (
|
||||
"git.noctra.dev/noctra/servtex/globals"
|
||||
)
|
||||
|
||||
//go:embed jscss/bootstrap.min.css
|
||||
//go:embed jscss/custom-view.css
|
||||
//go:embed jscss/htmx.min.js
|
||||
//go:embed jscss/htmx-ext-sse.js
|
||||
//go:embed templates/main.html
|
||||
var WebFiles embed.FS
|
||||
|
||||
// Adds necessary Headers for SSE
|
||||
func sseHeadersAdd(writer *http.ResponseWriter) {
|
||||
(*writer).Header().Set("Content-Type", "text/event-stream")
|
||||
@@ -74,7 +82,7 @@ func sseOutputSend(writer *http.ResponseWriter) {
|
||||
// Server Side Event Handler
|
||||
//
|
||||
// Sends a Ping instead of actual data when no new data available to save bandwidth
|
||||
func SSEEventSender(writer http.ResponseWriter, request *http.Request) {
|
||||
func SSEventHandler(writer http.ResponseWriter, request *http.Request) {
|
||||
lastExecution := ""
|
||||
for range time.Tick(time.Second) {
|
||||
if lastExecution == globals.LatexExec.Timestamp {
|
||||
@@ -89,3 +97,15 @@ func SSEEventSender(writer http.ResponseWriter, request *http.Request) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func PDFHandler(writer http.ResponseWriter, request *http.Request) {
|
||||
http.NotFound(writer, request)
|
||||
}
|
||||
|
||||
// Serves the main page of ServTeX
|
||||
func MainHandler(writer http.ResponseWriter, request *http.Request) {
|
||||
writer.Header().Set("Content-Type", "text/html")
|
||||
main, _ := WebFiles.ReadFile("templates/main.html")
|
||||
writer.Write(main)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user