fix: legacy QR URLs without '?' (productid in path) redirect to /t/CODE (new tag 97 now scans); preview page photo portrait aspect; Preview button on user tags list; admin photo form = preview + standalone Upload button (removed URL TextInput — no duplicate, no stale placeholder)
This commit is contained in:
21
frontend/internal/handlers/legacy.go
Normal file
21
frontend/internal/handlers/legacy.go
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
package handlers
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
// LegacyNotFound handles old printed QR URLs of the form
|
||||||
|
// https://where-woof.com/x=5&productid=CODE (no '?' before productid —
|
||||||
|
// the whole thing lands in the path). Redirects to /t/CODE.
|
||||||
|
func (a *App) LegacyNotFound(w http.ResponseWriter, r *http.Request) {
|
||||||
|
path := r.URL.Path
|
||||||
|
if i := strings.Index(path, "productid="); i >= 0 {
|
||||||
|
code := path[i+len("productid="):]
|
||||||
|
if code != "" {
|
||||||
|
http.Redirect(w, r, "/t/"+code, http.StatusFound)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
http.NotFound(w, r)
|
||||||
|
}
|
||||||
@@ -70,7 +70,7 @@ func main() {
|
|||||||
mux.HandleFunc("GET /about", app.About)
|
mux.HandleFunc("GET /about", app.About)
|
||||||
mux.HandleFunc("GET /what-is-this", app.WhatIsThis)
|
mux.HandleFunc("GET /what-is-this", app.WhatIsThis)
|
||||||
mux.HandleFunc("GET /contact", app.Contact)
|
mux.HandleFunc("GET /contact", app.Contact)
|
||||||
mux.HandleFunc("/{path...}", http.NotFound)
|
mux.HandleFunc("/{path...}", app.LegacyNotFound)
|
||||||
mux.HandleFunc("GET /t/{tag_code}", app.PublicTag)
|
mux.HandleFunc("GET /t/{tag_code}", app.PublicTag)
|
||||||
mux.HandleFunc("GET /s/{code}", app.ServeShort)
|
mux.HandleFunc("GET /s/{code}", app.ServeShort)
|
||||||
mux.HandleFunc("POST /t/{tag_code}/scan", app.Scan)
|
mux.HandleFunc("POST /t/{tag_code}/scan", app.Scan)
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
{{if ne .Status "closed"}}
|
{{if ne .Status "closed"}}
|
||||||
<a href="/account/tags/{{.ID}}/edit" class="text-amber-600 hover:underline">Edit</a>
|
<a href="/account/tags/{{.ID}}/edit" class="text-amber-600 hover:underline">Edit</a>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
<a href="/t/{{.TagCode}}?preview=1" target="_blank" rel="noopener" class="ml-3 text-blue-600 hover:underline">Preview</a>
|
||||||
<form hx-post="/account/tags/{{.ID}}/close" hx-target="#account-panel" hx-swap="outerHTML" hx-confirm="Close this tag? It will stop alerts but keep its details." class="inline">
|
<form hx-post="/account/tags/{{.ID}}/close" hx-target="#account-panel" hx-swap="outerHTML" hx-confirm="Close this tag? It will stop alerts but keep its details." class="inline">
|
||||||
<button class="ml-3 text-stone-500 hover:underline">Close</button>
|
<button class="ml-3 text-stone-500 hover:underline">Close</button>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
@@ -40,7 +40,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="p-6">
|
<div class="p-6">
|
||||||
{{if .Data.PhotoUrl.Valid}}
|
{{if .Data.PhotoUrl.Valid}}
|
||||||
<img src="{{.Data.PhotoUrl.String}}?v={{.Data.UpdatedAt.Time.Unix}}" alt="Item photo" class="mb-4 h-56 w-full rounded-lg object-cover">
|
<img src="{{.Data.PhotoUrl.String}}?v={{.Data.UpdatedAt.Time.Unix}}" alt="Item photo" class="mb-4 w-full rounded-lg object-cover" style="aspect-ratio: 3 / 4;">
|
||||||
{{end}}
|
{{end}}
|
||||||
{{if .Data.Description.Valid}}
|
{{if .Data.Description.Valid}}
|
||||||
<p class="text-stone-700">{{.Data.Description.String}}</p>
|
<p class="text-stone-700">{{.Data.Description.String}}</p>
|
||||||
|
|||||||
Reference in New Issue
Block a user