updates
This commit is contained in:
parent
7c202c21c7
commit
18c3bf3dd8
@ -301,11 +301,8 @@ func stopGameHandler(c *fiber.Ctx) error { // exit game
|
|||||||
}
|
}
|
||||||
|
|
||||||
func gameStartHandler(c *fiber.Ctx) error {
|
func gameStartHandler(c *fiber.Ctx) error {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
data := *web.Common(c)
|
data := *web.Common(c)
|
||||||
data["Title"] = "tmp"
|
data["Title"] = "Flags Game | tijl.dev"
|
||||||
data["SupportedTags"] = supportedTags
|
data["SupportedTags"] = supportedTags
|
||||||
return c.Render("apps/flags/start", data, "layouts/base")
|
return c.Render("apps/flags/start", data, "layouts/base")
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
{
|
{
|
||||||
|
"flags": "Flags",
|
||||||
"select_more_countries": "Too few countries",
|
"select_more_countries": "Too few countries",
|
||||||
|
"play": "Play",
|
||||||
|
"max_questions": "Max Questions",
|
||||||
|
"time_limit": "Time limit (seconds)",
|
||||||
|
"share_game": "Save",
|
||||||
"Asia": "Asia",
|
"Asia": "Asia",
|
||||||
"MiddleEast": "Middle East",
|
"MiddleEast": "Middle East",
|
||||||
"SoutheastAsia": "Southeast Asia",
|
"SoutheastAsia": "Southeast Asia",
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
{
|
{
|
||||||
|
"flags": "Vlaggen",
|
||||||
"select_more_countries": "Te weinig landen",
|
"select_more_countries": "Te weinig landen",
|
||||||
|
"play": "Play",
|
||||||
|
"time_limit": "Tijdlimit (seconden)",
|
||||||
|
"max_questions": "Maximaal aantal vragen",
|
||||||
|
"share_game": "Opslaan",
|
||||||
"Asia": "Azië",
|
"Asia": "Azië",
|
||||||
"MiddleEast": "Midden-Oosten",
|
"MiddleEast": "Midden-Oosten",
|
||||||
"SoutheastAsia": "Zuidoost-Azië",
|
"SoutheastAsia": "Zuidoost-Azië",
|
||||||
|
@ -58,6 +58,13 @@ func routes(app *fiber.App) {
|
|||||||
app.Use("/static/", filesystem.New(filesystem.Config{
|
app.Use("/static/", filesystem.New(filesystem.Config{
|
||||||
Root: http.FS(static),
|
Root: http.FS(static),
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
/*
|
||||||
|
Robots
|
||||||
|
*/
|
||||||
|
app.Get("/robots.txt", func(c *fiber.Ctx) error {
|
||||||
|
return c.SendString(`User-agent: *`)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// last function with low priority for 404 handler
|
// last function with low priority for 404 handler
|
||||||
|
@ -22,6 +22,8 @@ import (
|
|||||||
webf "git.tijl.dev/tijl/tijl.dev-core/web"
|
webf "git.tijl.dev/tijl/tijl.dev-core/web"
|
||||||
"github.com/gofiber/contrib/fiberzerolog"
|
"github.com/gofiber/contrib/fiberzerolog"
|
||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
|
"github.com/gofiber/fiber/v2/middleware/compress"
|
||||||
|
"github.com/gofiber/fiber/v2/middleware/helmet"
|
||||||
"github.com/gofiber/template/html/v2"
|
"github.com/gofiber/template/html/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -72,6 +74,10 @@ func Listen() {
|
|||||||
app.Use(fiberzerolog.New(fiberzerolog.Config{
|
app.Use(fiberzerolog.New(fiberzerolog.Config{
|
||||||
Logger: &log.Logger,
|
Logger: &log.Logger,
|
||||||
}))
|
}))
|
||||||
|
app.Use(compress.New(compress.Config{
|
||||||
|
Level: compress.LevelBestSpeed,
|
||||||
|
}))
|
||||||
|
app.Use(helmet.New(helmet.Config{}))
|
||||||
|
|
||||||
// Setup routes
|
// Setup routes
|
||||||
web.Setup(app)
|
web.Setup(app)
|
||||||
|
@ -1,40 +1,116 @@
|
|||||||
<div hx-boost="true"> <div id="error-message" class="text-red-500 mb-4"></div>
|
<div hx-boost="true">
|
||||||
<form method="post" hx-on="htmx:responseError:
|
|
||||||
document.getElementById('error-message').innerHTML = '{{.T.error_long}}:
|
<div id="error-message" class="text-red-500 mb-4"></div>
|
||||||
' + event.detail.xhr.responseText; htmx.trigger(this, 'htmx:swap', {
|
|
||||||
target: '#error-message', swap: 'innerHTML' });">
|
<form method="post" hx-on="htmx:responseError: handleResponseError(event)">
|
||||||
<input type="text" class="hidden" name="type" value="start" />
|
<input type="text" class="hidden" name="type" value="start" />
|
||||||
|
|
||||||
<div> {{range .SupportedTags}} <label class="cursor-pointer label">
|
<div id="tags-js">
|
||||||
<span class="label-text">{{index $.T .}}</span> <input
|
<div class="flex gap-2">
|
||||||
name="tags" value="{{.}}" type="checkbox" class="checkbox
|
<button type="button" id="selectAll" class="btn btn-sm btn-primary">Select All</button>
|
||||||
checkbox-primary" />
|
<button type="button" id="deselectAll" class="btn btn-sm btn-secondary">Deselect All</button>
|
||||||
</label> {{end}}
|
</div>
|
||||||
|
|
||||||
|
<div class="mt-4 flex flex-wrap gap-2">
|
||||||
|
{{range .SupportedTags}}
|
||||||
|
<label class="cursor-pointer badge badge-ghost badge-lg p-4 transition-colors duration-150">
|
||||||
|
<input name="tags" value="{{.}}" type="checkbox" class="hidden" />
|
||||||
|
<span>{{index $.T .}}</span>
|
||||||
|
</label>
|
||||||
|
{{end}}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{if .SignedIn}}
|
{{if .SignedIn}}
|
||||||
<label class="cursor-pointer label mt-5"> <span
|
<label class="cursor-pointer label mt-2"> <span class="label-text">{{.T.share_game}}</span> <input name="share"
|
||||||
class="label-text">Share</span> <input name="share" type="checkbox"
|
type="checkbox" class="checkbox checkbox-primary" />
|
||||||
class="checkbox checkbox-primary" />
|
|
||||||
</label>
|
</label>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
<div> <label>
|
<div>
|
||||||
<span>max questions</span> <input value="0" placeholder="max
|
<label class="input input-bordered flex items-center gap-2 mt-2">
|
||||||
questions" name="max_questions" type="number"
|
{{.T.max_questions}}
|
||||||
class="input input-bordered" /> </label>
|
<input placeholder="25" value="0" name="max_questions" type="number" class="grow" />
|
||||||
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div> <label>
|
<div>
|
||||||
<span>time limit</span> <input value="0" placeholder="seconds
|
<label class="input input-bordered flex items-center gap-2 mt-2">
|
||||||
time limit" name="seconds" type="number"
|
{{.T.time_limit}}
|
||||||
class="input input-bordered" /> </label>
|
<input placeholder="60" value="0" name="seconds" type="number" class="grow" />
|
||||||
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button type="submit" class="btn btn-primary">Submit</button> </form>
|
<div class="mt-2 flex">
|
||||||
<form class="mt-4" method="post"> <input type="text" class="hidden"
|
<button type="submit" class="ml-auto btn btn-primary">{{.T.play}}</button>
|
||||||
name="type" value="shared" /> <input type="text" class="input
|
</div>
|
||||||
input-bordered" name="sharekey" placeholder="sharekey" /> <button
|
|
||||||
type="submit" class="btn btn-primary">Shared</button>
|
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
<form class="mt-8" method="post">
|
||||||
|
<input type="text" class="hidden" name="type" value="shared" />
|
||||||
|
<div class="join">
|
||||||
|
<label class="input input-bordered flex items-center gap-2 join-item">
|
||||||
|
share key
|
||||||
|
<input placeholder="aBc2d" name="sharekey" type="text" class="grow" />
|
||||||
|
</label>
|
||||||
|
<button type="submit" class="btn join-item btn-primary">{{.T.play}}</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
function handleResponseError(event) {
|
||||||
|
const errorMessageElement = document.getElementById('error-message');
|
||||||
|
errorMessageElement.innerHTML = `{{.T.error_long}}: ${event.detail.xhr.responseText}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
var tagsDiv = document.getElementById('tags-js');
|
||||||
|
var selectAllButton = tagsDiv.querySelector('#selectAll');
|
||||||
|
var deselectAllButton = tagsDiv.querySelector('#deselectAll');
|
||||||
|
var checkboxes = tagsDiv.querySelectorAll('input[name="tags"]');
|
||||||
|
|
||||||
|
// Function to update button visibility
|
||||||
|
function updateButtonVisibility() {
|
||||||
|
const anyChecked = Array.from(checkboxes).some(checkbox => checkbox.checked);
|
||||||
|
if (anyChecked) {
|
||||||
|
selectAllButton.classList.add('hidden');
|
||||||
|
deselectAllButton.classList.remove('hidden');
|
||||||
|
} else {
|
||||||
|
selectAllButton.classList.remove('hidden');
|
||||||
|
deselectAllButton.classList.add('hidden');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initialize button visibility
|
||||||
|
updateButtonVisibility();
|
||||||
|
|
||||||
|
// Select all functionality
|
||||||
|
selectAllButton.addEventListener('click', function () {
|
||||||
|
checkboxes.forEach(function (checkbox) {
|
||||||
|
checkbox.checked = true;
|
||||||
|
checkbox.parentElement.classList.add('bg-primary', 'text-black');
|
||||||
|
});
|
||||||
|
updateButtonVisibility();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Deselect all functionality
|
||||||
|
deselectAllButton.addEventListener('click', function () {
|
||||||
|
checkboxes.forEach(function (checkbox) {
|
||||||
|
checkbox.checked = false;
|
||||||
|
checkbox.parentElement.classList.remove('bg-primary', 'text-black');
|
||||||
|
});
|
||||||
|
updateButtonVisibility();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Toggle style and button visibility on click
|
||||||
|
tagsDiv.querySelectorAll('label').forEach(function (label) {
|
||||||
|
label.addEventListener('click', function (e) {
|
||||||
|
const checkbox = label.querySelector('input[type="checkbox"]');
|
||||||
|
checkbox.checked = !checkbox.checked;
|
||||||
|
label.classList.toggle('bg-primary', checkbox.checked);
|
||||||
|
label.classList.toggle('text-black', checkbox.checked);
|
||||||
|
updateButtonVisibility();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
@ -1,12 +1,19 @@
|
|||||||
<form enctype="multipart/form-data" method="post" hx-boost="true">
|
<form enctype="multipart/form-data" method="post" hx-boost="true">
|
||||||
<label>
|
<div>
|
||||||
<span>Max downloaders</span>
|
<label class="input input-bordered flex items-center gap-2 mt-2">
|
||||||
<input name="max_downloads" required type="number" value="1" placeholder="Max downloaders" class="input input-bordered" />
|
Max downloaders
|
||||||
|
<input name="max_downloads" required type="number" placeholder="1" default="1" class="grow" />
|
||||||
|
</label>
|
||||||
|
<label class="input input-bordered flex items-center gap-2 mt-2">
|
||||||
|
Expire in (days)
|
||||||
|
<input name="expire_days" required type="number" placeholder="7" default="7" class="grow" />
|
||||||
</label>
|
</label>
|
||||||
<label>
|
<label>
|
||||||
<span>Expire in (days)</span>
|
<span class="hidden">File for uploading</span>
|
||||||
<input name="expire_days" required type="number" value="1" placeholder="Expire in days from now" class="input input-bordered" />
|
<input required type="file" name="file" class="file-input file-input-bordered w-full mt-2" />
|
||||||
</label>
|
</label>
|
||||||
<input required type="file" name="file" class="file-input file-input-bordered w-full max-w-xs" />
|
<div class="flex">
|
||||||
<input class="btn" type="submit" value="Upload">
|
<input class="ml-auto btn btn-primary mt-4" type="submit" value="Upload">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
<link rel="icon" href="/static/favicon.ico" />
|
<link rel="icon" href="/static/favicon.ico" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
<meta name="theme-color" content="#f28c18" />
|
<meta name="theme-color" content="#f28c18" />
|
||||||
|
<meta name="description" content="{{.Description}}" />
|
||||||
<script type="module" defer src="/static/js/interactive.js"></script>
|
<script type="module" defer src="/static/js/interactive.js"></script>
|
||||||
<title>{{.Title}}</title>
|
<title>{{.Title}}</title>
|
||||||
</head>
|
</head>
|
||||||
|
@ -57,12 +57,12 @@
|
|||||||
</li>
|
</li>
|
||||||
<li class="flex-none">
|
<li class="flex-none">
|
||||||
<details class="dropdown">
|
<details class="dropdown">
|
||||||
<summary><a class="flex gap-4">
|
<summary><button class="flex gap-4">
|
||||||
<span class="w-5 text-center">
|
<span class="w-5 text-center">
|
||||||
{{icon "language"}}
|
{{icon "language"}}
|
||||||
</span>
|
</span>
|
||||||
<span class="text-base">{{.T.language}}</span>
|
<span class="text-base">{{.T.language}}</span>
|
||||||
</a>
|
</button>
|
||||||
</summary>
|
</summary>
|
||||||
|
|
||||||
<ul class="menu dropdown-content z-[102] bg-base-200 rounded-box w-48 p-3 shadow-xl gap-1">
|
<ul class="menu dropdown-content z-[102] bg-base-200 rounded-box w-48 p-3 shadow-xl gap-1">
|
||||||
|
@ -1 +1,2 @@
|
|||||||
<div><a hx-boost="true" href="/app/flags">flags</a></div>
|
<div><a hx-boost="true" href="/app/flags">flags</a></div>
|
||||||
|
<div><a hx-boost="true" href="/app/uploader">uploader</a></div>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<div class="prose mb-4">
|
<div class="prose mb-4">
|
||||||
<h1 class="m-0">Service's</h1>
|
<h1 class="m-0">Service's</h1>
|
||||||
<hr class="m-0" />
|
<hr class="m-0 w-full" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mt-4 flex justify-center">
|
<div class="mt-4 flex justify-center">
|
||||||
@ -9,14 +9,14 @@
|
|||||||
<a href="#{{$key}}" id="service-{{$key}}" class="group"
|
<a href="#{{$key}}" id="service-{{$key}}" class="group"
|
||||||
onmouseover="this.querySelector('img').style.transform='scale({{incfloat .Scale 1.1}})';"
|
onmouseover="this.querySelector('img').style.transform='scale({{incfloat .Scale 1.1}})';"
|
||||||
onmouseout="this.querySelector('img').style.transform='scale({{incfloat .Scale 1}})';">
|
onmouseout="this.querySelector('img').style.transform='scale({{incfloat .Scale 1}})';">
|
||||||
<div class="relative w-24 h-24 rounded-3xl shadow-2xl" style="background-color: {{.Color}};">
|
<div class="relative w-24 h-24 rounded-2xl rounded-3xl shadow-2xl" style="background-color: {{.Color}};">
|
||||||
<div class="absolute inset-0 flex items-center justify-center">
|
<div class="absolute inset-0 flex items-center justify-center">
|
||||||
<img alt="{{.Name}} logo"
|
<img alt="{{.Name}} logo"
|
||||||
class="text-white transform transition-transform duration-300 drop-shadow-2xl"
|
class="text-white transform transition-transform duration-300 drop-shadow-2xl"
|
||||||
style="transform: scale({{incfloat .Scale 1}});" src="/static/assets/{{$key}}.svg" />
|
style="transform: scale({{incfloat .Scale 1}});" src="/static/assets/{{$key}}.svg" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="service-{{$key}}-label" class="w-24 text-center my-1 rounded-2xl">
|
<div id="service-{{$key}}-label" class="w-24 text-center mt-2 rounded-2xl rounded-b-none py-1">
|
||||||
{{.Name}}
|
{{.Name}}
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
@ -24,7 +24,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mt-4 mx-2 card bg-base-300" id="services-info">
|
<div class="card bg-base-300" id="services-info">
|
||||||
{{range $key, $value := .Services}}
|
{{range $key, $value := .Services}}
|
||||||
<div class="card-body hidden" id="service-{{$key}}-info">
|
<div class="card-body hidden" id="service-{{$key}}-info">
|
||||||
<h2 class="card-title">{{.Name}}</h2>
|
<h2 class="card-title">{{.Name}}</h2>
|
||||||
|
Loading…
Reference in New Issue
Block a user