start forum routes, fix db concurrency issue, add new font for headings

This commit is contained in:
Sky Johnson 2025-08-22 15:56:50 -05:00
parent 84e7c68f0b
commit b94d768b5c
18 changed files with 82 additions and 32 deletions

View File

@ -4,12 +4,22 @@
for legibility and design, but keep the soul of the original project.
*/
@font-face {
font-family: 'Seagram';
src: url('/assets/fonts/seagram.ttf') format('truetype');
font-display: swap;
}
:root {
color: #222;
font-family: Cambria, Cochin, Georgia, Times, 'Times New Roman', serif;
font-size: 16px;
}
.seagram {
font-family: 'Seagram', Cambria, Cochin, Georgia, Times, 'Times New Roman', serif;
}
* {
margin: 0;
padding: 0;
@ -26,10 +36,13 @@ body {
i { font-style: italic; }
b { font-weight: bold; }
h1 { font-size: 2rem; font-weight: bold; }
h2 { font-size: 1.7rem; font-weight: bold; }
h3 { font-size: 1.4rem; font-weight: bold; }
h4 { font-size: 1.1rem; font-weight: bold; }
h1, h2, h3, h4, h5 {
font-family: 'Seagram', Cambria, Cochin, Georgia, Times, 'Times New Roman', serif;
}
h1 { font-size: 2rem; }
h2 { font-size: 1.7rem; }
h3 { font-size: 1.4rem; }
h4 { font-size: 1.1rem; }
div#container {
max-width: 1024px;
@ -56,17 +69,20 @@ section#game {
margin: 1rem 0;
border-top: 2px solid #000;
& > aside {
padding: 0.5rem;
}
& > aside > section:not(:last-child) {
margin-bottom: 1rem;
& > aside > section:not(:last-of-type) {
margin-bottom: 0.5rem;
padding-bottom: 1rem;
border-bottom: 2px solid black;
}
& > aside > section {
display: flex;
flex-direction: column;
padding: 0.5rem;
h5 {
margin-bottom: 0.25rem;
}
}
& > aside#left {
@ -267,6 +283,10 @@ form.standard {
margin-bottom: 0.5rem;
}
.mb-025 {
margin-bottom: 0.25rem;
}
div.town {
& > section:not(:last-child) {
margin-bottom: 2rem;
@ -294,7 +314,7 @@ button.img-button {
div#statbars {
display: flex;
justify-content: space-around;
margin: 1rem 0;
margin-top: 1rem;
& > div.stat {
display: flex;

BIN
assets/fonts/seagram.ttf Normal file

Binary file not shown.

Binary file not shown.

2
go.mod
View File

@ -3,7 +3,7 @@ module dk
go 1.25.0
require (
git.sharkk.net/Sharkk/Sashimi v1.0.1
git.sharkk.net/Sharkk/Sashimi v1.1.1
git.sharkk.net/Sharkk/Sushi v1.2.0
github.com/valyala/fasthttp v1.65.0
)

4
go.sum
View File

@ -1,5 +1,5 @@
git.sharkk.net/Sharkk/Sashimi v1.0.1 h1:5YMmxnCgcsyasg5J91AS5FVzzJoDZ17I3J4hlJyyMR4=
git.sharkk.net/Sharkk/Sashimi v1.0.1/go.mod h1:wTMnO6jo34LIjpDJ0qToq14RbwP6Uf4HtdWDmqxrdAM=
git.sharkk.net/Sharkk/Sashimi v1.1.1 h1:ST7YQjnQq3ydAKy/Kerx89cx+b/mXDOq7W/ll1aX1jA=
git.sharkk.net/Sharkk/Sashimi v1.1.1/go.mod h1:wTMnO6jo34LIjpDJ0qToq14RbwP6Uf4HtdWDmqxrdAM=
git.sharkk.net/Sharkk/Sushi v1.2.0 h1:RwOCZmgaOqtkmuK2Z7/esdLbhSXJZphsOsWEHni4Sss=
git.sharkk.net/Sharkk/Sushi v1.2.0/go.mod h1:S84ACGkuZ+BKzBO4lb5WQnm5aw9+l7VSO2T1bjzxL3o=
github.com/andybalholm/brotli v1.2.0 h1:ukwgCxwYrmACq68yiUqwIWnGY0cTPox/M94sVwToPjQ=

View File

@ -21,6 +21,10 @@ func LeftAside(ctx sushi.Ctx) map[string]any {
user := ctx.UserValue("user").(*users.User)
if user.Currently == "In Town" {
data["town"], _ = towns.ByCoords(user.X, user.Y)
}
// Build owned town maps list
if user.Towns != "" {
townMap := helpers.NewOrderedMap[int, *towns.Town]()

View File

@ -9,7 +9,7 @@ import (
)
func GenerateTownNews() string {
title := `<div class="title">Latest News</div>`
title := `<h4 class="mb-025">Latest News</h4>`
news, err := news.Recent(1)
if err == nil && len(news) > 0 {
@ -22,7 +22,7 @@ func GenerateTownNews() string {
}
func GenerateTownWhosOnline() string {
title := `<div class="title">Who's Online</div>`
title := `<h4 class="mb-025">Who's Online</h4>`
onlineUsers, err := users.Online(10 * time.Minute)
if err == nil && len(onlineUsers) > 0 {

View File

@ -35,7 +35,7 @@ func Close() error {
}
// Wrapper functions for convenience
func Query(query string, args ...any) (*sashimi.Stmt, error) {
func Query(query string, args ...any) (*sashimi.PooledStmt, error) {
return db.Query(query, args...)
}

18
internal/routes/forum.go Normal file
View File

@ -0,0 +1,18 @@
package routes
import (
"dk/internal/components"
sushi "git.sharkk.net/Sharkk/Sushi"
"git.sharkk.net/Sharkk/Sushi/auth"
)
func RegisterForumRoutes(app *sushi.App) {
authed := app.Group("/forum")
authed.Use(auth.RequireAuth())
authed.Get("/", index)
}
func index(ctx sushi.Ctx) {
components.RenderPage(ctx, "Forum", "forum/index.html", map[string]any{})
}

View File

@ -177,6 +177,7 @@ func start(port string) error {
routes.RegisterAuthRoutes(app)
routes.RegisterTownRoutes(app)
routes.RegisterFightRoutes(app)
routes.RegisterForumRoutes(app)
app.Get("/assets/*path", sushi.Static(cwd))

View File

@ -0,0 +1,5 @@
{include "layout.html"}
{block "content"}
FORUM PAGE
{/block}

View File

@ -1,5 +1,9 @@
{include "layout.html"}
{block "content"}
<h1>Welcome to Dragon Knight</h1>
<p>
Hey there!
</p>
{/block}

View File

@ -1,13 +1,13 @@
<section>
<div class="title"><img src="/assets/images/button_location.gif" alt="Location" title="Location"></div>
<h5>Compass</h5>
<div><b>
<div>
{if user.Currently == "In Town" and town != nil}
In {town.Name}
{else}
{user.Currently}
{/if}
</b></div>
</div>
<div>{user.X}{if user.X < 0}W{else}E{/if}, {user.Y}{if user.Y < 0}S{else}N{/if}</div>
{if user.Currently != "Fighting"}
@ -26,7 +26,7 @@
</section>
<section>
<div class="title"><img src="/assets/images/button_towns.gif" alt="Towns" title="Towns"></div>
<h5>Town Maps</h5>
{if #_towns > 0}
<i>Teleport to:</i>
{for t in _towns}
@ -46,7 +46,6 @@
</section>
<section id="functions">
<div class="title"><img src="/assets/images/button_functions.gif" alt="Functions" title="Functions"></div>
<a href="/">Home</a>
<a href="/forum">Forum</a>
<a href="/change-password">Change Password</a>

View File

@ -1,5 +1,4 @@
<section>
<div class="title"><img src="/assets/images/button_character.gif" alt="Character" title="Character"></div>
<ul class="unstyled">
<li><b>{user.Username}</b></li>
<li>Level {user.Level} {_class.Name}</li>
@ -30,7 +29,7 @@
</section>
<section>
<div class="title"><img src="/assets/images/button_inventory.gif" alt="Inventory" title="Inventory"></div>
<h5>Equipment</h5>
<div>
<img src="/assets/images/icon_weapon.gif" alt="Weapon" title="Weapon">
@ -69,7 +68,7 @@
</section>
<section>
<div class="title"><img src="/assets/images/button_fastspells.gif" alt="Fast Spells" title="Fast Spells"></div>
<h5>Spells</h5>
{if #_spells > 0}
{for id,name in _spells}
<a href="#">{name}</a>

View File

@ -2,7 +2,7 @@
{block "content"}
<div class="town inn">
<div class="title"><h3>{town.Name} Inn</h3></div>
<h3 class="mb-025">{town.Name} Inn</h3>
{if rested}
<p>You wake up feeling refreshed and ready for action!</p>

View File

@ -2,7 +2,7 @@
{block "content"}
<div class="town shop">
<div class="title"><h3>{town.Name} Maps</h3></div>
<h3 class="mb-025">{town.Name} Maps</h3>
<section>
<p>Buying maps will put the town in your Travel To box, and it won't cost you as many TP to get there.</p>
<p>Click a town name to purchase its map.</p>

View File

@ -2,7 +2,7 @@
{block "content"}
<div class="town shop">
<div class="title"><h3>{town.Name} Shop</h3></div>
<h3 class="mb-025">{town.Name} Shop</h3>
<section>
<p>Buying weapons will increase your Attack. Buying armor and shields will increase your Defense.</p>
<p>Click an item name to purchase it.</p>

View File

@ -3,7 +3,7 @@
{block "content"}
<div class="town">
<section class="options">
<div class="title"><img src="/assets/images/town_{town.ID}.gif" alt="Welcome to {town.Name}" title="Welcome to {town.Name}"></div>
<h2 class="title mb-1">Welcome to {town.Name}</h2>
<b>Town Options</b><br>
<ul class="unstyled">
<li><a href="/town/inn">Rest at the Inn</a></li>
@ -22,7 +22,7 @@
</section>
<section class="babblebox">
<div class="title">Babblebox</div>
<h4 class="mb-025">Babblebox</h4>
@TODO
</section>
</section>