Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions _datafiles/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
# overwrite your changes.
#
################################################################################
# - MudName -
# Display name of the MUD.
# This will be used a few places by default (such as the web pages).
MudName: "GoMud"
# - Version -
# Latest semantic version of the datafiles (MAJOR.MINOR.PATCH)
# Do not change this value, it will be handled by the server when updated
Expand Down
6 changes: 3 additions & 3 deletions _datafiles/html/public/_header.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>GoMud: The Open-source MUD server, written in Go</title>
<title>Welcome to {{ mudname }}</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap" />
<link rel="stylesheet" href="/static/public/css/gomud.css">
</head>
<body>
<header>
<div>
<a class="gomud-btn" href="/">GoMud</a>
<a class="gomud-btn" href="/">{{ mudname }}</a>
</div>
<div class="nav-toggle" onclick="toggleMenu()">
<div></div>
Expand All @@ -22,7 +22,7 @@

<nav>
<div class="nav-container">
<a href="/">Home</a>
<a href="/">Go Home</a>
<a href="/online">Who's Online</a>
<a href="/webclient">Web Client</a>
<a href="/viewconfig">See Configuration</a>
Expand Down
8 changes: 4 additions & 4 deletions _datafiles/html/public/webclient.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<title>GoMud Web Terminal</title>
<title>{{ mudname }} Web Terminal</title>
<style>
* {
box-sizing: border-box;
Expand Down Expand Up @@ -190,7 +190,7 @@ <h3>Volume Controls</h3>
</div>

<!-- CONNECT BUTTON FLOATED IN CENTER -->
<button id="connect-button">Connect</button>
<button id="connect-button">Connect to {{ .MudName }}</button>

<div id="input-area">
<input type="text" id="command-input" placeholder="Enter command...">
Expand Down Expand Up @@ -298,8 +298,8 @@ <h3>Volume Controls</h3>
socket.close();
return;
}
debugLog("Connecting to: " + 'ws://'+location.host +':80/ws');
socket = new WebSocket('ws://'+location.host +':80/ws');
debugLog("Connecting to: " + 'ws://'+location.host +':{{ .WebPort }}/ws');
socket = new WebSocket('ws://'+location.host +':{{ .WebPort }}/ws');

socket.onopen = function() {
term.writeln("Connected to the server!");
Expand Down
3 changes: 2 additions & 1 deletion internal/configs/configs.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ const (
)

type Config struct {
Version ConfigString `yaml:"Version"` // Cuurrent version of all datafiles
MudName ConfigString `yaml:"MudName"` // Name of the MUD
Version ConfigString `yaml:"Version"` // Current version of all datafiles
MaxCPUCores ConfigInt `yaml:"MaxCPUCores"`
FolderDataFiles ConfigString `yaml:"FolderDataFiles"`
FolderHtmlFiles ConfigString `yaml:"FolderHtmlFiles"`
Expand Down
9 changes: 8 additions & 1 deletion internal/web/home.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,12 @@ func serveHome(w http.ResponseWriter, r *http.Request) {

func serveClient(w http.ResponseWriter, r *http.Request) {
// read contents of webclient.html and print it out
http.ServeFile(w, r, configs.GetConfig().FolderHtmlFiles.String()+"/public/webclient.html")

tmpl, err := template.New("webclient.html").Funcs(funcMap).ParseFiles(configs.GetConfig().FolderHtmlFiles.String() + "/public/webclient.html")
if err != nil {
mudlog.Error("HTML ERROR", "error", err)
}

tmpl.Execute(w, configs.GetConfig())

}
5 changes: 5 additions & 0 deletions internal/web/template_func.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"html"
"strings"
"text/template"

"github.com/volte6/gomud/internal/configs"
)

var (
Expand Down Expand Up @@ -97,5 +99,8 @@ var (
"lowercase": func(str string) string {
return strings.ToLower(str)
},
"mudname": func() string {
return string(configs.GetConfig().MudName)
},
}
)
1 change: 1 addition & 0 deletions internal/web/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ func Listen(webPort int, wg *sync.WaitGroup, webSocketHandler func(*websocket.Co

// HTTP Server
httpServer = &http.Server{Addr: fmt.Sprintf(`:%d`, webPort)}

// Routing
// Basic homepage
http.HandleFunc("/", serveHome)
Expand Down
Loading