start forum routes, fix db concurrency issue, add new font for headings
This commit is contained in:
parent
84e7c68f0b
commit
b94d768b5c
@ -4,12 +4,22 @@
|
|||||||
for legibility and design, but keep the soul of the original project.
|
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 {
|
:root {
|
||||||
color: #222;
|
color: #222;
|
||||||
font-family: Cambria, Cochin, Georgia, Times, 'Times New Roman', serif;
|
font-family: Cambria, Cochin, Georgia, Times, 'Times New Roman', serif;
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.seagram {
|
||||||
|
font-family: 'Seagram', Cambria, Cochin, Georgia, Times, 'Times New Roman', serif;
|
||||||
|
}
|
||||||
|
|
||||||
* {
|
* {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
@ -26,10 +36,13 @@ body {
|
|||||||
i { font-style: italic; }
|
i { font-style: italic; }
|
||||||
b { font-weight: bold; }
|
b { font-weight: bold; }
|
||||||
|
|
||||||
h1 { font-size: 2rem; font-weight: bold; }
|
h1, h2, h3, h4, h5 {
|
||||||
h2 { font-size: 1.7rem; font-weight: bold; }
|
font-family: 'Seagram', Cambria, Cochin, Georgia, Times, 'Times New Roman', serif;
|
||||||
h3 { font-size: 1.4rem; font-weight: bold; }
|
}
|
||||||
h4 { font-size: 1.1rem; font-weight: bold; }
|
h1 { font-size: 2rem; }
|
||||||
|
h2 { font-size: 1.7rem; }
|
||||||
|
h3 { font-size: 1.4rem; }
|
||||||
|
h4 { font-size: 1.1rem; }
|
||||||
|
|
||||||
div#container {
|
div#container {
|
||||||
max-width: 1024px;
|
max-width: 1024px;
|
||||||
@ -56,17 +69,20 @@ section#game {
|
|||||||
margin: 1rem 0;
|
margin: 1rem 0;
|
||||||
border-top: 2px solid #000;
|
border-top: 2px solid #000;
|
||||||
|
|
||||||
& > aside {
|
& > aside > section:not(:last-of-type) {
|
||||||
padding: 0.5rem;
|
margin-bottom: 0.5rem;
|
||||||
}
|
padding-bottom: 1rem;
|
||||||
|
border-bottom: 2px solid black;
|
||||||
& > aside > section:not(:last-child) {
|
|
||||||
margin-bottom: 1rem;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
& > aside > section {
|
& > aside > section {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
padding: 0.5rem;
|
||||||
|
|
||||||
|
h5 {
|
||||||
|
margin-bottom: 0.25rem;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
& > aside#left {
|
& > aside#left {
|
||||||
@ -267,6 +283,10 @@ form.standard {
|
|||||||
margin-bottom: 0.5rem;
|
margin-bottom: 0.5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.mb-025 {
|
||||||
|
margin-bottom: 0.25rem;
|
||||||
|
}
|
||||||
|
|
||||||
div.town {
|
div.town {
|
||||||
& > section:not(:last-child) {
|
& > section:not(:last-child) {
|
||||||
margin-bottom: 2rem;
|
margin-bottom: 2rem;
|
||||||
@ -294,7 +314,7 @@ button.img-button {
|
|||||||
div#statbars {
|
div#statbars {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-around;
|
justify-content: space-around;
|
||||||
margin: 1rem 0;
|
margin-top: 1rem;
|
||||||
|
|
||||||
& > div.stat {
|
& > div.stat {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
BIN
assets/fonts/seagram.ttf
Normal file
BIN
assets/fonts/seagram.ttf
Normal file
Binary file not shown.
BIN
data/dk.db
BIN
data/dk.db
Binary file not shown.
2
go.mod
2
go.mod
@ -3,7 +3,7 @@ module dk
|
|||||||
go 1.25.0
|
go 1.25.0
|
||||||
|
|
||||||
require (
|
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
|
git.sharkk.net/Sharkk/Sushi v1.2.0
|
||||||
github.com/valyala/fasthttp v1.65.0
|
github.com/valyala/fasthttp v1.65.0
|
||||||
)
|
)
|
||||||
|
4
go.sum
4
go.sum
@ -1,5 +1,5 @@
|
|||||||
git.sharkk.net/Sharkk/Sashimi v1.0.1 h1:5YMmxnCgcsyasg5J91AS5FVzzJoDZ17I3J4hlJyyMR4=
|
git.sharkk.net/Sharkk/Sashimi v1.1.1 h1:ST7YQjnQq3ydAKy/Kerx89cx+b/mXDOq7W/ll1aX1jA=
|
||||||
git.sharkk.net/Sharkk/Sashimi v1.0.1/go.mod h1:wTMnO6jo34LIjpDJ0qToq14RbwP6Uf4HtdWDmqxrdAM=
|
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 h1:RwOCZmgaOqtkmuK2Z7/esdLbhSXJZphsOsWEHni4Sss=
|
||||||
git.sharkk.net/Sharkk/Sushi v1.2.0/go.mod h1:S84ACGkuZ+BKzBO4lb5WQnm5aw9+l7VSO2T1bjzxL3o=
|
git.sharkk.net/Sharkk/Sushi v1.2.0/go.mod h1:S84ACGkuZ+BKzBO4lb5WQnm5aw9+l7VSO2T1bjzxL3o=
|
||||||
github.com/andybalholm/brotli v1.2.0 h1:ukwgCxwYrmACq68yiUqwIWnGY0cTPox/M94sVwToPjQ=
|
github.com/andybalholm/brotli v1.2.0 h1:ukwgCxwYrmACq68yiUqwIWnGY0cTPox/M94sVwToPjQ=
|
||||||
|
@ -21,6 +21,10 @@ func LeftAside(ctx sushi.Ctx) map[string]any {
|
|||||||
|
|
||||||
user := ctx.UserValue("user").(*users.User)
|
user := ctx.UserValue("user").(*users.User)
|
||||||
|
|
||||||
|
if user.Currently == "In Town" {
|
||||||
|
data["town"], _ = towns.ByCoords(user.X, user.Y)
|
||||||
|
}
|
||||||
|
|
||||||
// Build owned town maps list
|
// Build owned town maps list
|
||||||
if user.Towns != "" {
|
if user.Towns != "" {
|
||||||
townMap := helpers.NewOrderedMap[int, *towns.Town]()
|
townMap := helpers.NewOrderedMap[int, *towns.Town]()
|
||||||
|
@ -9,7 +9,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func GenerateTownNews() string {
|
func GenerateTownNews() string {
|
||||||
title := `<div class="title">Latest News</div>`
|
title := `<h4 class="mb-025">Latest News</h4>`
|
||||||
|
|
||||||
news, err := news.Recent(1)
|
news, err := news.Recent(1)
|
||||||
if err == nil && len(news) > 0 {
|
if err == nil && len(news) > 0 {
|
||||||
@ -22,7 +22,7 @@ func GenerateTownNews() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func GenerateTownWhosOnline() 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)
|
onlineUsers, err := users.Online(10 * time.Minute)
|
||||||
if err == nil && len(onlineUsers) > 0 {
|
if err == nil && len(onlineUsers) > 0 {
|
||||||
|
@ -35,7 +35,7 @@ func Close() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Wrapper functions for convenience
|
// 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...)
|
return db.Query(query, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
18
internal/routes/forum.go
Normal file
18
internal/routes/forum.go
Normal 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{})
|
||||||
|
}
|
1
main.go
1
main.go
@ -177,6 +177,7 @@ func start(port string) error {
|
|||||||
routes.RegisterAuthRoutes(app)
|
routes.RegisterAuthRoutes(app)
|
||||||
routes.RegisterTownRoutes(app)
|
routes.RegisterTownRoutes(app)
|
||||||
routes.RegisterFightRoutes(app)
|
routes.RegisterFightRoutes(app)
|
||||||
|
routes.RegisterForumRoutes(app)
|
||||||
|
|
||||||
app.Get("/assets/*path", sushi.Static(cwd))
|
app.Get("/assets/*path", sushi.Static(cwd))
|
||||||
|
|
||||||
|
5
templates/forum/index.html
Normal file
5
templates/forum/index.html
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{include "layout.html"}
|
||||||
|
|
||||||
|
{block "content"}
|
||||||
|
FORUM PAGE
|
||||||
|
{/block}
|
@ -1,5 +1,9 @@
|
|||||||
{include "layout.html"}
|
{include "layout.html"}
|
||||||
|
|
||||||
{block "content"}
|
{block "content"}
|
||||||
Hey there!
|
<h1>Welcome to Dragon Knight</h1>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Hey there!
|
||||||
|
</p>
|
||||||
{/block}
|
{/block}
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
<section>
|
<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}
|
{if user.Currently == "In Town" and town != nil}
|
||||||
In {town.Name}
|
In {town.Name}
|
||||||
{else}
|
{else}
|
||||||
{user.Currently}
|
{user.Currently}
|
||||||
{/if}
|
{/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>
|
<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"}
|
{if user.Currently != "Fighting"}
|
||||||
@ -26,7 +26,7 @@
|
|||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section>
|
<section>
|
||||||
<div class="title"><img src="/assets/images/button_towns.gif" alt="Towns" title="Towns"></div>
|
<h5>Town Maps</h5>
|
||||||
{if #_towns > 0}
|
{if #_towns > 0}
|
||||||
<i>Teleport to:</i>
|
<i>Teleport to:</i>
|
||||||
{for t in _towns}
|
{for t in _towns}
|
||||||
@ -46,7 +46,6 @@
|
|||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section id="functions">
|
<section id="functions">
|
||||||
<div class="title"><img src="/assets/images/button_functions.gif" alt="Functions" title="Functions"></div>
|
|
||||||
<a href="/">Home</a>
|
<a href="/">Home</a>
|
||||||
<a href="/forum">Forum</a>
|
<a href="/forum">Forum</a>
|
||||||
<a href="/change-password">Change Password</a>
|
<a href="/change-password">Change Password</a>
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
<section>
|
<section>
|
||||||
<div class="title"><img src="/assets/images/button_character.gif" alt="Character" title="Character"></div>
|
|
||||||
<ul class="unstyled">
|
<ul class="unstyled">
|
||||||
<li><b>{user.Username}</b></li>
|
<li><b>{user.Username}</b></li>
|
||||||
<li>Level {user.Level} {_class.Name}</li>
|
<li>Level {user.Level} {_class.Name}</li>
|
||||||
@ -30,7 +29,7 @@
|
|||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section>
|
<section>
|
||||||
<div class="title"><img src="/assets/images/button_inventory.gif" alt="Inventory" title="Inventory"></div>
|
<h5>Equipment</h5>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<img src="/assets/images/icon_weapon.gif" alt="Weapon" title="Weapon">
|
<img src="/assets/images/icon_weapon.gif" alt="Weapon" title="Weapon">
|
||||||
@ -69,7 +68,7 @@
|
|||||||
</section>
|
</section>
|
||||||
|
|
||||||
<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}
|
{if #_spells > 0}
|
||||||
{for id,name in _spells}
|
{for id,name in _spells}
|
||||||
<a href="#">{name}</a>
|
<a href="#">{name}</a>
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
{block "content"}
|
{block "content"}
|
||||||
<div class="town inn">
|
<div class="town inn">
|
||||||
<div class="title"><h3>{town.Name} Inn</h3></div>
|
<h3 class="mb-025">{town.Name} Inn</h3>
|
||||||
|
|
||||||
{if rested}
|
{if rested}
|
||||||
<p>You wake up feeling refreshed and ready for action!</p>
|
<p>You wake up feeling refreshed and ready for action!</p>
|
||||||
@ -22,4 +22,4 @@
|
|||||||
{/if}
|
{/if}
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
{/block}
|
{/block}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
{block "content"}
|
{block "content"}
|
||||||
<div class="town shop">
|
<div class="town shop">
|
||||||
<div class="title"><h3>{town.Name} Maps</h3></div>
|
<h3 class="mb-025">{town.Name} Maps</h3>
|
||||||
<section>
|
<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>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>
|
<p>Click a town name to purchase its map.</p>
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
{block "content"}
|
{block "content"}
|
||||||
<div class="town shop">
|
<div class="town shop">
|
||||||
<div class="title"><h3>{town.Name} Shop</h3></div>
|
<h3 class="mb-025">{town.Name} Shop</h3>
|
||||||
<section>
|
<section>
|
||||||
<p>Buying weapons will increase your Attack. Buying armor and shields will increase your Defense.</p>
|
<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>
|
<p>Click an item name to purchase it.</p>
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
{block "content"}
|
{block "content"}
|
||||||
<div class="town">
|
<div class="town">
|
||||||
<section class="options">
|
<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>
|
<b>Town Options</b><br>
|
||||||
<ul class="unstyled">
|
<ul class="unstyled">
|
||||||
<li><a href="/town/inn">Rest at the Inn</a></li>
|
<li><a href="/town/inn">Rest at the Inn</a></li>
|
||||||
@ -22,7 +22,7 @@
|
|||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section class="babblebox">
|
<section class="babblebox">
|
||||||
<div class="title">Babblebox</div>
|
<h4 class="mb-025">Babblebox</h4>
|
||||||
@TODO
|
@TODO
|
||||||
</section>
|
</section>
|
||||||
</section>
|
</section>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user