A layout is a named copy of one canvas page's boxes and background (models.Layout, layout.graphql), saved from the canvas's new Layouts button and loaded onto any page from there or from the admin Pages tab. Loading onto a page with boxes asks whether to replace them or add on top; a replace first saves the page as a "<page> before <layout>" layout so it can be undone. Copies, not links: editing a page never changes a layout or another page. The copying is server-side in one transaction, and everything is @admin since a layout keeps admin-only boxes. /stp loses its static route and becomes a Page with slug "stp", created once at start-up (ensureStpPage), so it can be renamed, hidden or deleted like a shrine. Its boxes were already keyed "stp". Home3.vue is kept as legacy; its starter is now "Old /stp grid" in pageStarters.js. ConfirmDialog gains an optional second button. Co-Authored-By: Claude Opus 5.5 <[email protected]>
35 lines
1.1 KiB
Go
35 lines
1.1 KiB
Go
package graph
|
|
|
|
import "testing"
|
|
|
|
func TestValidateSlug(t *testing.T) {
|
|
for _, c := range []struct {
|
|
slug string
|
|
ok bool
|
|
}{
|
|
{"notes-to-self", true},
|
|
{"shrines/evangelion", true},
|
|
{"shrines/neon-genesis/rei2", true},
|
|
{"", false},
|
|
{"Shrines/GTO", false}, // upper case
|
|
{"shrines/", false}, // empty segment
|
|
{"/shrines/gto", false}, // leading slash
|
|
{"shrines//gto", false}, // empty segment
|
|
{"shrines/gto-", false}, // trailing hyphen
|
|
{"shrines/../admin", false}, // dots
|
|
{"shrines", true}, // the index is a canvas page too
|
|
{"shrines/demoman", true}, // no longer an SPA route
|
|
{"admin/pages", false}, // under an SPA route
|
|
{"jobs/x", false}, // under an nginx route
|
|
{"stp", true}, // the home page is a canvas page too
|
|
{"stp2", false}, // an SPA route
|
|
{"index", false}, // the landing canvas's key
|
|
{"stp-fan-page", true}, // only whole segments are reserved
|
|
} {
|
|
err := validateSlug(c.slug)
|
|
if (err == nil) != c.ok {
|
|
t.Errorf("validateSlug(%q) = %v, want ok=%v", c.slug, err, c.ok)
|
|
}
|
|
}
|
|
}
|