Add per-page backgrounds to canvas pages
Each canvas page key (the landing page, /stp, shrines and other admin-made pages) can have its own background: a colour, an image and how the image fills the window. Admins set it from a Background button beside Edit layout, with live preview and image upload or drop; DefaultLayout paints it behind the whole window and falls back to the halftone. Backed by a new Background GraphQL type keyed by page key, validated server-side, hidden with admin-only pages, and moved or deleted along with its page. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -73,7 +73,7 @@ Dockerized multi-service personal website self-hosted on a Raspberry Pi.
|
|||||||
- `graph/*.resolvers.go` — resolver implementations (one per schema file, `follow-schema` layout)
|
- `graph/*.resolvers.go` — resolver implementations (one per schema file, `follow-schema` layout)
|
||||||
- `graph/generated.go` — auto-generated by gqlgen, do not edit
|
- `graph/generated.go` — auto-generated by gqlgen, do not edit
|
||||||
- `graph/model/models_gen.go` — auto-generated GraphQL models, do not edit
|
- `graph/model/models_gen.go` — auto-generated GraphQL models, do not edit
|
||||||
- `models/models.go` — GORM database models (User, Post, Message, Activity, Favorite, Rowing, Bookmark, Place, Box, Page)
|
- `models/models.go` — GORM database models (User, Post, Message, Activity, Favorite, Rowing, Bookmark, Place, Box, Page, Background)
|
||||||
- `graph/directives.go` — the `@admin` / `@signedIn` schema directives (see Key Patterns)
|
- `graph/directives.go` — the `@admin` / `@signedIn` schema directives (see Key Patterns)
|
||||||
- `services/` — database init, JWT auth, WebSocket server, Spotify OAuth, Gitea feed, the Python-service call helper (`python_call.go`), the `.env` registry (`env_manager.go`), DB seeding. There is no Claude client in Go any more
|
- `services/` — database init, JWT auth, WebSocket server, Spotify OAuth, Gitea feed, the Python-service call helper (`python_call.go`), the `.env` registry (`env_manager.go`), DB seeding. There is no Claude client in Go any more
|
||||||
|
|
||||||
@@ -82,7 +82,7 @@ Dockerized multi-service personal website self-hosted on a Raspberry Pi.
|
|||||||
- `src/graphql.js` — thin axios-based GraphQL client (`POST /api/graphql`)
|
- `src/graphql.js` — thin axios-based GraphQL client (`POST /api/graphql`)
|
||||||
- `src/api.js` — thin REST client for the `/api` JSON endpoints; failures become an `ApiError` carrying the backend's `error` message and the status
|
- `src/api.js` — thin REST client for the `/api` JSON endpoints; failures become an `ApiError` carrying the backend's `error` message and the status
|
||||||
- `src/stores/` — Pinia stores for auth, posts, favorites, activities, songs, messages, homeData, places, boxes, pages. `createCrudStore.js` is the factory behind places, boxes and pages; `createMirrorStore.js` is the one behind the home-page slices
|
- `src/stores/` — Pinia stores for auth, posts, favorites, activities, songs, messages, homeData, places, boxes, pages. `createCrudStore.js` is the factory behind places, boxes and pages; `createMirrorStore.js` is the one behind the home-page slices
|
||||||
- `src/views/` — page components (Home, Admin, CV, Notes, Bookmarks, shrines). `/stp` is `views/home3/Home3.vue`: a canvas of admin-arranged boxes (built-in widgets or sandboxed-iframe HTML) stored as the `Box` GraphQL type. The canvas (`views/home3/BoxCanvas.vue`) is reusable per page key: the landing page (`/`) is one too, and admin-created `Page`s (e.g. shrines) are served at `/<slug>` by the router's catch-all, `views/canvas/CanvasPage.vue`. Boxes and pages can be admin-only, filtered server-side. See "The /stp canvas" in `vue/README.md`
|
- `src/views/` — page components (Home, Admin, CV, Notes, Bookmarks, shrines). `/stp` is `views/home3/Home3.vue`: a canvas of admin-arranged boxes (built-in widgets or sandboxed-iframe HTML) stored as the `Box` GraphQL type. The canvas (`views/home3/BoxCanvas.vue`) is reusable per page key: the landing page (`/`) is one too, and admin-created `Page`s (e.g. shrines) are served at `/<slug>` by the router's catch-all, `views/canvas/CanvasPage.vue`. Boxes and pages can be admin-only, filtered server-side. Each canvas page key also has an optional `Background`, set from the canvas's Background button and painted by `DefaultLayout`. See "The /stp canvas" in `vue/README.md`
|
||||||
- `src/components/` — reusable UI components
|
- `src/components/` — reusable UI components
|
||||||
- `src/assets/styles.css` — design tokens (Tailwind `@theme`), base element styles, shared classes and transitions. `layouts/CVLayout.vue` re-points the colour tokens for the light CV theme. See "Styling" in `vue/README.md`.
|
- `src/assets/styles.css` — design tokens (Tailwind `@theme`), base element styles, shared classes and transitions. `layouts/CVLayout.vue` re-points the colour tokens for the light CV theme. See "Styling" in `vue/README.md`.
|
||||||
|
|
||||||
|
|||||||
@@ -88,3 +88,9 @@ models:
|
|||||||
fields:
|
fields:
|
||||||
deletedAt:
|
deletedAt:
|
||||||
resolver: false
|
resolver: false
|
||||||
|
Background:
|
||||||
|
model:
|
||||||
|
- adam-french.co.uk/backend/models.Background
|
||||||
|
fields:
|
||||||
|
deletedAt:
|
||||||
|
resolver: false
|
||||||
|
|||||||
@@ -0,0 +1,63 @@
|
|||||||
|
package graph
|
||||||
|
|
||||||
|
// This file will be automatically regenerated based on the schema, any resolver
|
||||||
|
// implementations
|
||||||
|
// will be copied through when generating and any unknown code will be moved to the end.
|
||||||
|
// Code generated by github.com/99designs/gqlgen version v0.17.95
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
|
||||||
|
"adam-french.co.uk/backend/graph/model"
|
||||||
|
"adam-french.co.uk/backend/models"
|
||||||
|
"gorm.io/gorm"
|
||||||
|
)
|
||||||
|
|
||||||
|
// SetBackground is the resolver for the setBackground field.
|
||||||
|
func (r *mutationResolver) SetBackground(ctx context.Context, page string, input model.BackgroundInput) (*models.Background, error) {
|
||||||
|
// One row per page: replaced in place if there is one, so its id stays
|
||||||
|
// stable for the store on the front end.
|
||||||
|
bg, err := backgroundFrom(page, input)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
var existing models.Background
|
||||||
|
err = r.Store.DB.Where("page = ?", page).First(&existing).Error
|
||||||
|
switch {
|
||||||
|
case err == nil:
|
||||||
|
bg.ID, bg.CreatedAt = existing.ID, existing.CreatedAt
|
||||||
|
err = r.Store.DB.Save(&bg).Error
|
||||||
|
case errors.Is(err, gorm.ErrRecordNotFound):
|
||||||
|
err = r.Store.DB.Create(&bg).Error
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &bg, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ClearBackground is the resolver for the clearBackground field.
|
||||||
|
func (r *mutationResolver) ClearBackground(ctx context.Context, page string) (bool, error) {
|
||||||
|
res := r.Store.DB.Where("page = ?", page).Delete(&models.Background{})
|
||||||
|
return res.RowsAffected > 0, res.Error
|
||||||
|
}
|
||||||
|
|
||||||
|
// Background is the resolver for the background field.
|
||||||
|
func (r *queryResolver) Background(ctx context.Context, page string) (*models.Background, error) {
|
||||||
|
// Null, not an error, when the page has none: that is the default look.
|
||||||
|
// Hidden along with an adminOnly page, like its boxes.
|
||||||
|
hidden, err := pageHiddenFrom(ctx, r.Store.DB, page)
|
||||||
|
if err != nil || hidden {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
var bg models.Background
|
||||||
|
err = r.Store.DB.Where("page = ?", page).First(&bg).Error
|
||||||
|
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &bg, nil
|
||||||
|
}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
package graph
|
||||||
|
|
||||||
|
// Hand-written helpers for background.resolvers.go, kept out of the resolver
|
||||||
|
// file for the same reason as box_helpers.go.
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"regexp"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"adam-french.co.uk/backend/graph/model"
|
||||||
|
"adam-french.co.uk/backend/models"
|
||||||
|
)
|
||||||
|
|
||||||
|
// The SPA puts these values straight into a style binding, as
|
||||||
|
// `background-color` and `url("<image>")`. Vue sets them through the CSSOM,
|
||||||
|
// so nothing can escape into other properties, but a quote or bracket in the
|
||||||
|
// image could still end the url() early — hence the narrow shapes.
|
||||||
|
var (
|
||||||
|
// A hex colour, a colour name, or one of the colour functions — named,
|
||||||
|
// so that url() and friends don't pass as a "function".
|
||||||
|
bgColorPattern = regexp.MustCompile(`^(#[0-9a-fA-F]{3,8}|[a-zA-Z]+|(rgba?|hsla?|hwb|lab|lch|oklab|oklch)\([0-9a-z.,%/ -]*\))$`)
|
||||||
|
// A site path (an upload, /img/...) or an http(s) URL, with no quotes,
|
||||||
|
// brackets, backslashes or spaces.
|
||||||
|
bgImagePattern = regexp.MustCompile(`^(/|https?://)[^\s"'()\\<>]*$`)
|
||||||
|
)
|
||||||
|
|
||||||
|
const maxBgImageLen = 1000
|
||||||
|
|
||||||
|
var bgFits = map[string]bool{"cover": true, "contain": true, "tile": true}
|
||||||
|
|
||||||
|
// backgroundFrom validates input into a Background for page.
|
||||||
|
func backgroundFrom(page string, input model.BackgroundInput) (models.Background, error) {
|
||||||
|
bg := models.Background{
|
||||||
|
Page: page,
|
||||||
|
Color: strings.TrimSpace(input.Color),
|
||||||
|
Image: strings.TrimSpace(input.Image),
|
||||||
|
Fit: input.Fit,
|
||||||
|
}
|
||||||
|
if !validPageKey(page) {
|
||||||
|
return bg, errors.New("a background needs a valid page")
|
||||||
|
}
|
||||||
|
if bg.Color != "" && (len(bg.Color) > 64 || !bgColorPattern.MatchString(bg.Color)) {
|
||||||
|
return bg, errors.New(`colour must be a CSS colour such as #1b110e, black or rgb(0 0 0 / 50%)`)
|
||||||
|
}
|
||||||
|
if bg.Image != "" && (len(bg.Image) > maxBgImageLen || !bgImagePattern.MatchString(bg.Image)) {
|
||||||
|
return bg, errors.New("image must be a path on this site (e.g. /uploads/...) or an http(s) URL, without spaces or quotes")
|
||||||
|
}
|
||||||
|
if !bgFits[bg.Fit] {
|
||||||
|
return bg, errors.New(`fit must be "cover", "contain" or "tile"`)
|
||||||
|
}
|
||||||
|
return bg, nil
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package graph
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"adam-french.co.uk/backend/graph/model"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestBackgroundFrom(t *testing.T) {
|
||||||
|
for _, c := range []struct {
|
||||||
|
page string
|
||||||
|
input model.BackgroundInput
|
||||||
|
ok bool
|
||||||
|
}{
|
||||||
|
{"index", model.BackgroundInput{Color: "#102030", Fit: "cover"}, true},
|
||||||
|
{"shrines/gto", model.BackgroundInput{Image: "/uploads/abc.gif", Fit: "tile"}, true},
|
||||||
|
{"stp", model.BackgroundInput{Color: "rgb(0 0 0 / 50%)", Image: "https://example.com/a.png", Fit: "contain"}, true},
|
||||||
|
{"index", model.BackgroundInput{Color: "rebeccapurple", Fit: "cover"}, true},
|
||||||
|
{"index", model.BackgroundInput{Fit: "cover"}, true}, // plain theme colour
|
||||||
|
{"Index", model.BackgroundInput{Fit: "cover"}, false}, // bad page key
|
||||||
|
{"index", model.BackgroundInput{Fit: "stretch"}, false}, // unknown fit
|
||||||
|
{"index", model.BackgroundInput{Color: "red; color: blue", Fit: "cover"}, false},
|
||||||
|
{"index", model.BackgroundInput{Color: "url(/x.png)", Fit: "cover"}, false}, // an image in disguise
|
||||||
|
{"index", model.BackgroundInput{Image: `/x.png") , url("/y`, Fit: "cover"}, false},
|
||||||
|
{"index", model.BackgroundInput{Image: "javascript:alert(1)", Fit: "cover"}, false},
|
||||||
|
{"index", model.BackgroundInput{Image: "uploads/relative.png", Fit: "cover"}, false},
|
||||||
|
} {
|
||||||
|
_, err := backgroundFrom(c.page, c.input)
|
||||||
|
if (err == nil) != c.ok {
|
||||||
|
t.Errorf("backgroundFrom(%q, %+v) = %v, want ok=%v", c.page, c.input, err, c.ok)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+639
-23
@@ -56,6 +56,15 @@ type ComplexityRoot struct {
|
|||||||
User func(childComplexity int) int
|
User func(childComplexity int) int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Background struct {
|
||||||
|
Color func(childComplexity int) int
|
||||||
|
Fit func(childComplexity int) int
|
||||||
|
ID func(childComplexity int) int
|
||||||
|
Image func(childComplexity int) int
|
||||||
|
Page func(childComplexity int) int
|
||||||
|
UpdatedAt func(childComplexity int) int
|
||||||
|
}
|
||||||
|
|
||||||
Bookmark struct {
|
Bookmark struct {
|
||||||
Category func(childComplexity int) int
|
Category func(childComplexity int) int
|
||||||
CreatedAt func(childComplexity int) int
|
CreatedAt func(childComplexity int) int
|
||||||
@@ -112,28 +121,30 @@ type ComplexityRoot struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Mutation struct {
|
Mutation struct {
|
||||||
CreateActivity func(childComplexity int, input model.CreateActivityInput) int
|
ClearBackground func(childComplexity int, page string) int
|
||||||
CreateBookmark func(childComplexity int, input model.CreateBookmarkInput) int
|
CreateActivity func(childComplexity int, input model.CreateActivityInput) int
|
||||||
CreateBox func(childComplexity int, input model.CreateBoxInput) int
|
CreateBookmark func(childComplexity int, input model.CreateBookmarkInput) int
|
||||||
CreateFavorite func(childComplexity int, input model.CreateFavoriteInput) int
|
CreateBox func(childComplexity int, input model.CreateBoxInput) int
|
||||||
CreatePage func(childComplexity int, input model.CreatePageInput) int
|
CreateFavorite func(childComplexity int, input model.CreateFavoriteInput) int
|
||||||
CreatePlace func(childComplexity int, input model.CreatePlaceInput) int
|
CreatePage func(childComplexity int, input model.CreatePageInput) int
|
||||||
CreatePost func(childComplexity int, input model.CreatePostInput) int
|
CreatePlace func(childComplexity int, input model.CreatePlaceInput) int
|
||||||
CreateUser func(childComplexity int, input model.CreateUserInput) int
|
CreatePost func(childComplexity int, input model.CreatePostInput) int
|
||||||
DeleteBookmark func(childComplexity int, id int) int
|
CreateUser func(childComplexity int, input model.CreateUserInput) int
|
||||||
DeleteBox func(childComplexity int, id int) int
|
DeleteBookmark func(childComplexity int, id int) int
|
||||||
DeletePage func(childComplexity int, id int) int
|
DeleteBox func(childComplexity int, id int) int
|
||||||
DeletePlace func(childComplexity int, id int) int
|
DeletePage func(childComplexity int, id int) int
|
||||||
DeletePost func(childComplexity int, id int) int
|
DeletePlace func(childComplexity int, id int) int
|
||||||
DeleteUser func(childComplexity int, id int) int
|
DeletePost func(childComplexity int, id int) int
|
||||||
Login func(childComplexity int, input model.LoginInput) int
|
DeleteUser func(childComplexity int, id int) int
|
||||||
Logout func(childComplexity int) int
|
Login func(childComplexity int, input model.LoginInput) int
|
||||||
RefreshToken func(childComplexity int) int
|
Logout func(childComplexity int) int
|
||||||
SetUserAdmin func(childComplexity int, id int, admin bool) int
|
RefreshToken func(childComplexity int) int
|
||||||
UpdateBox func(childComplexity int, id int, input model.UpdateBoxInput) int
|
SetBackground func(childComplexity int, page string, input model.BackgroundInput) int
|
||||||
UpdatePage func(childComplexity int, id int, input model.UpdatePageInput) int
|
SetUserAdmin func(childComplexity int, id int, admin bool) int
|
||||||
UpdatePlace func(childComplexity int, id int, input model.UpdatePlaceInput) int
|
UpdateBox func(childComplexity int, id int, input model.UpdateBoxInput) int
|
||||||
UpdatePost func(childComplexity int, id int, input model.UpdatePostInput) int
|
UpdatePage func(childComplexity int, id int, input model.UpdatePageInput) int
|
||||||
|
UpdatePlace func(childComplexity int, id int, input model.UpdatePlaceInput) int
|
||||||
|
UpdatePost func(childComplexity int, id int, input model.UpdatePostInput) int
|
||||||
}
|
}
|
||||||
|
|
||||||
Page struct {
|
Page struct {
|
||||||
@@ -170,6 +181,7 @@ type ComplexityRoot struct {
|
|||||||
|
|
||||||
Query struct {
|
Query struct {
|
||||||
Activities func(childComplexity int) int
|
Activities func(childComplexity int) int
|
||||||
|
Background func(childComplexity int, page string) int
|
||||||
Bookmarks func(childComplexity int) int
|
Bookmarks func(childComplexity int) int
|
||||||
Boxes func(childComplexity int, page string) int
|
Boxes func(childComplexity int, page string) int
|
||||||
Favorites func(childComplexity int) int
|
Favorites func(childComplexity int) int
|
||||||
@@ -263,6 +275,8 @@ type MutationResolver interface {
|
|||||||
Login(ctx context.Context, input model.LoginInput) (*model.AuthPayload, error)
|
Login(ctx context.Context, input model.LoginInput) (*model.AuthPayload, error)
|
||||||
Logout(ctx context.Context) (bool, error)
|
Logout(ctx context.Context) (bool, error)
|
||||||
RefreshToken(ctx context.Context) (*model.AuthPayload, error)
|
RefreshToken(ctx context.Context) (*model.AuthPayload, error)
|
||||||
|
SetBackground(ctx context.Context, page string, input model.BackgroundInput) (*models.Background, error)
|
||||||
|
ClearBackground(ctx context.Context, page string) (bool, error)
|
||||||
CreateBookmark(ctx context.Context, input model.CreateBookmarkInput) (*models.Bookmark, error)
|
CreateBookmark(ctx context.Context, input model.CreateBookmarkInput) (*models.Bookmark, error)
|
||||||
DeleteBookmark(ctx context.Context, id int) (*models.Bookmark, error)
|
DeleteBookmark(ctx context.Context, id int) (*models.Bookmark, error)
|
||||||
CreateBox(ctx context.Context, input model.CreateBoxInput) (*models.Box, error)
|
CreateBox(ctx context.Context, input model.CreateBoxInput) (*models.Box, error)
|
||||||
@@ -285,6 +299,7 @@ type MutationResolver interface {
|
|||||||
type QueryResolver interface {
|
type QueryResolver interface {
|
||||||
Activities(ctx context.Context) ([]*models.Activity, error)
|
Activities(ctx context.Context) ([]*models.Activity, error)
|
||||||
Me(ctx context.Context) (*models.User, error)
|
Me(ctx context.Context) (*models.User, error)
|
||||||
|
Background(ctx context.Context, page string) (*models.Background, error)
|
||||||
Bookmarks(ctx context.Context) ([]*models.Bookmark, error)
|
Bookmarks(ctx context.Context) ([]*models.Bookmark, error)
|
||||||
Boxes(ctx context.Context, page string) ([]*models.Box, error)
|
Boxes(ctx context.Context, page string) ([]*models.Box, error)
|
||||||
Favorites(ctx context.Context) ([]*models.Favorite, error)
|
Favorites(ctx context.Context) ([]*models.Favorite, error)
|
||||||
@@ -370,6 +385,43 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin
|
|||||||
|
|
||||||
return e.ComplexityRoot.AuthPayload.User(childComplexity), true
|
return e.ComplexityRoot.AuthPayload.User(childComplexity), true
|
||||||
|
|
||||||
|
case "Background.color":
|
||||||
|
if e.ComplexityRoot.Background.Color == nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
return e.ComplexityRoot.Background.Color(childComplexity), true
|
||||||
|
case "Background.fit":
|
||||||
|
if e.ComplexityRoot.Background.Fit == nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
return e.ComplexityRoot.Background.Fit(childComplexity), true
|
||||||
|
case "Background.id":
|
||||||
|
if e.ComplexityRoot.Background.ID == nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
return e.ComplexityRoot.Background.ID(childComplexity), true
|
||||||
|
case "Background.image":
|
||||||
|
if e.ComplexityRoot.Background.Image == nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
return e.ComplexityRoot.Background.Image(childComplexity), true
|
||||||
|
case "Background.page":
|
||||||
|
if e.ComplexityRoot.Background.Page == nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
return e.ComplexityRoot.Background.Page(childComplexity), true
|
||||||
|
case "Background.updatedAt":
|
||||||
|
if e.ComplexityRoot.Background.UpdatedAt == nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
return e.ComplexityRoot.Background.UpdatedAt(childComplexity), true
|
||||||
|
|
||||||
case "Bookmark.category":
|
case "Bookmark.category":
|
||||||
if e.ComplexityRoot.Bookmark.Category == nil {
|
if e.ComplexityRoot.Bookmark.Category == nil {
|
||||||
break
|
break
|
||||||
@@ -615,6 +667,17 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin
|
|||||||
|
|
||||||
return e.ComplexityRoot.Message.Private(childComplexity), true
|
return e.ComplexityRoot.Message.Private(childComplexity), true
|
||||||
|
|
||||||
|
case "Mutation.clearBackground":
|
||||||
|
if e.ComplexityRoot.Mutation.ClearBackground == nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
args, err := ec.field_Mutation_clearBackground_args(ctx, rawArgs)
|
||||||
|
if err != nil {
|
||||||
|
return 0, false
|
||||||
|
}
|
||||||
|
|
||||||
|
return e.ComplexityRoot.Mutation.ClearBackground(childComplexity, args["page"].(string)), true
|
||||||
case "Mutation.createActivity":
|
case "Mutation.createActivity":
|
||||||
if e.ComplexityRoot.Mutation.CreateActivity == nil {
|
if e.ComplexityRoot.Mutation.CreateActivity == nil {
|
||||||
break
|
break
|
||||||
@@ -792,6 +855,17 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin
|
|||||||
}
|
}
|
||||||
|
|
||||||
return e.ComplexityRoot.Mutation.RefreshToken(childComplexity), true
|
return e.ComplexityRoot.Mutation.RefreshToken(childComplexity), true
|
||||||
|
case "Mutation.setBackground":
|
||||||
|
if e.ComplexityRoot.Mutation.SetBackground == nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
args, err := ec.field_Mutation_setBackground_args(ctx, rawArgs)
|
||||||
|
if err != nil {
|
||||||
|
return 0, false
|
||||||
|
}
|
||||||
|
|
||||||
|
return e.ComplexityRoot.Mutation.SetBackground(childComplexity, args["page"].(string), args["input"].(model.BackgroundInput)), true
|
||||||
case "Mutation.setUserAdmin":
|
case "Mutation.setUserAdmin":
|
||||||
if e.ComplexityRoot.Mutation.SetUserAdmin == nil {
|
if e.ComplexityRoot.Mutation.SetUserAdmin == nil {
|
||||||
break
|
break
|
||||||
@@ -995,6 +1069,17 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin
|
|||||||
}
|
}
|
||||||
|
|
||||||
return e.ComplexityRoot.Query.Activities(childComplexity), true
|
return e.ComplexityRoot.Query.Activities(childComplexity), true
|
||||||
|
case "Query.background":
|
||||||
|
if e.ComplexityRoot.Query.Background == nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
args, err := ec.field_Query_background_args(ctx, rawArgs)
|
||||||
|
if err != nil {
|
||||||
|
return 0, false
|
||||||
|
}
|
||||||
|
|
||||||
|
return e.ComplexityRoot.Query.Background(childComplexity, args["page"].(string)), true
|
||||||
case "Query.bookmarks":
|
case "Query.bookmarks":
|
||||||
if e.ComplexityRoot.Query.Bookmarks == nil {
|
if e.ComplexityRoot.Query.Bookmarks == nil {
|
||||||
break
|
break
|
||||||
@@ -1323,6 +1408,7 @@ func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler {
|
|||||||
opCtx := graphql.GetOperationContext(ctx)
|
opCtx := graphql.GetOperationContext(ctx)
|
||||||
ec := newExecutionContext(opCtx, e, make(chan graphql.DeferredResult))
|
ec := newExecutionContext(opCtx, e, make(chan graphql.DeferredResult))
|
||||||
inputUnmarshalMap := graphql.BuildUnmarshalerMap(
|
inputUnmarshalMap := graphql.BuildUnmarshalerMap(
|
||||||
|
ec.unmarshalInputBackgroundInput,
|
||||||
ec.unmarshalInputCreateActivityInput,
|
ec.unmarshalInputCreateActivityInput,
|
||||||
ec.unmarshalInputCreateBookmarkInput,
|
ec.unmarshalInputCreateBookmarkInput,
|
||||||
ec.unmarshalInputCreateBoxInput,
|
ec.unmarshalInputCreateBoxInput,
|
||||||
@@ -1410,7 +1496,7 @@ func newExecutionContext(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//go:embed "schema/activity.graphql" "schema/auth.graphql" "schema/bookmark.graphql" "schema/box.graphql" "schema/favorite.graphql" "schema/gitea.graphql" "schema/message.graphql" "schema/page.graphql" "schema/place.graphql" "schema/post.graphql" "schema/rowing.graphql" "schema/schema.graphql" "schema/spotify.graphql" "schema/steam.graphql" "schema/user.graphql"
|
//go:embed "schema/activity.graphql" "schema/auth.graphql" "schema/background.graphql" "schema/bookmark.graphql" "schema/box.graphql" "schema/favorite.graphql" "schema/gitea.graphql" "schema/message.graphql" "schema/page.graphql" "schema/place.graphql" "schema/post.graphql" "schema/rowing.graphql" "schema/schema.graphql" "schema/spotify.graphql" "schema/steam.graphql" "schema/user.graphql"
|
||||||
var sourcesFS embed.FS
|
var sourcesFS embed.FS
|
||||||
|
|
||||||
func sourceData(filename string) string {
|
func sourceData(filename string) string {
|
||||||
@@ -1424,6 +1510,7 @@ func sourceData(filename string) string {
|
|||||||
var sources = []*ast.Source{
|
var sources = []*ast.Source{
|
||||||
{Name: "schema/activity.graphql", Input: sourceData("schema/activity.graphql"), BuiltIn: false},
|
{Name: "schema/activity.graphql", Input: sourceData("schema/activity.graphql"), BuiltIn: false},
|
||||||
{Name: "schema/auth.graphql", Input: sourceData("schema/auth.graphql"), BuiltIn: false},
|
{Name: "schema/auth.graphql", Input: sourceData("schema/auth.graphql"), BuiltIn: false},
|
||||||
|
{Name: "schema/background.graphql", Input: sourceData("schema/background.graphql"), BuiltIn: false},
|
||||||
{Name: "schema/bookmark.graphql", Input: sourceData("schema/bookmark.graphql"), BuiltIn: false},
|
{Name: "schema/bookmark.graphql", Input: sourceData("schema/bookmark.graphql"), BuiltIn: false},
|
||||||
{Name: "schema/box.graphql", Input: sourceData("schema/box.graphql"), BuiltIn: false},
|
{Name: "schema/box.graphql", Input: sourceData("schema/box.graphql"), BuiltIn: false},
|
||||||
{Name: "schema/favorite.graphql", Input: sourceData("schema/favorite.graphql"), BuiltIn: false},
|
{Name: "schema/favorite.graphql", Input: sourceData("schema/favorite.graphql"), BuiltIn: false},
|
||||||
@@ -1470,6 +1557,24 @@ func (ec *executionContext) childFields_AuthPayload(ctx context.Context, field g
|
|||||||
return nil, fmt.Errorf("no field named %q was found under type AuthPayload", field.Name)
|
return nil, fmt.Errorf("no field named %q was found under type AuthPayload", field.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (ec *executionContext) childFields_Background(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
|
||||||
|
switch field.Name {
|
||||||
|
case "id":
|
||||||
|
return ec.fieldContext_Background_id(ctx, field)
|
||||||
|
case "updatedAt":
|
||||||
|
return ec.fieldContext_Background_updatedAt(ctx, field)
|
||||||
|
case "page":
|
||||||
|
return ec.fieldContext_Background_page(ctx, field)
|
||||||
|
case "color":
|
||||||
|
return ec.fieldContext_Background_color(ctx, field)
|
||||||
|
case "image":
|
||||||
|
return ec.fieldContext_Background_image(ctx, field)
|
||||||
|
case "fit":
|
||||||
|
return ec.fieldContext_Background_fit(ctx, field)
|
||||||
|
}
|
||||||
|
return nil, fmt.Errorf("no field named %q was found under type Background", field.Name)
|
||||||
|
}
|
||||||
|
|
||||||
func (ec *executionContext) childFields_Bookmark(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
|
func (ec *executionContext) childFields_Bookmark(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
|
||||||
switch field.Name {
|
switch field.Name {
|
||||||
case "id":
|
case "id":
|
||||||
@@ -1880,6 +1985,20 @@ func (ec *executionContext) childFields___Type(ctx context.Context, field graphq
|
|||||||
|
|
||||||
// region ***************************** args.gotpl *****************************
|
// region ***************************** args.gotpl *****************************
|
||||||
|
|
||||||
|
func (ec *executionContext) field_Mutation_clearBackground_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
|
||||||
|
var err error
|
||||||
|
args := map[string]any{}
|
||||||
|
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "page",
|
||||||
|
func(ctx context.Context, v any) (string, error) {
|
||||||
|
return ec.unmarshalNString2string(ctx, v)
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
args["page"] = arg0
|
||||||
|
return args, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (ec *executionContext) field_Mutation_createActivity_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
|
func (ec *executionContext) field_Mutation_createActivity_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
|
||||||
var err error
|
var err error
|
||||||
args := map[string]any{}
|
args := map[string]any{}
|
||||||
@@ -2090,6 +2209,28 @@ func (ec *executionContext) field_Mutation_login_args(ctx context.Context, rawAr
|
|||||||
return args, nil
|
return args, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (ec *executionContext) field_Mutation_setBackground_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
|
||||||
|
var err error
|
||||||
|
args := map[string]any{}
|
||||||
|
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "page",
|
||||||
|
func(ctx context.Context, v any) (string, error) {
|
||||||
|
return ec.unmarshalNString2string(ctx, v)
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
args["page"] = arg0
|
||||||
|
arg1, err := graphql.ProcessArgField(ctx, rawArgs, "input",
|
||||||
|
func(ctx context.Context, v any) (model.BackgroundInput, error) {
|
||||||
|
return ec.unmarshalNBackgroundInput2adamᚑfrenchᚗcoᚗukᚋbackendᚋgraphᚋmodelᚐBackgroundInput(ctx, v)
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
args["input"] = arg1
|
||||||
|
return args, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (ec *executionContext) field_Mutation_setUserAdmin_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
|
func (ec *executionContext) field_Mutation_setUserAdmin_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
|
||||||
var err error
|
var err error
|
||||||
args := map[string]any{}
|
args := map[string]any{}
|
||||||
@@ -2214,6 +2355,20 @@ func (ec *executionContext) field_Query___type_args(ctx context.Context, rawArgs
|
|||||||
return args, nil
|
return args, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (ec *executionContext) field_Query_background_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
|
||||||
|
var err error
|
||||||
|
args := map[string]any{}
|
||||||
|
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "page",
|
||||||
|
func(ctx context.Context, v any) (string, error) {
|
||||||
|
return ec.unmarshalNString2string(ctx, v)
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
args["page"] = arg0
|
||||||
|
return args, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (ec *executionContext) field_Query_boxes_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
|
func (ec *executionContext) field_Query_boxes_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
|
||||||
var err error
|
var err error
|
||||||
args := map[string]any{}
|
args := map[string]any{}
|
||||||
@@ -2500,6 +2655,144 @@ func (ec *executionContext) fieldContext_AuthPayload_user(_ context.Context, fie
|
|||||||
return fc, nil
|
return fc, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (ec *executionContext) _Background_id(ctx context.Context, field graphql.CollectedField, obj *models.Background) (ret graphql.Marshaler) {
|
||||||
|
return graphql.ResolveField(
|
||||||
|
ctx,
|
||||||
|
ec.OperationContext,
|
||||||
|
field,
|
||||||
|
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
|
||||||
|
return ec.fieldContext_Background_id(ctx, field)
|
||||||
|
},
|
||||||
|
func(ctx context.Context) (any, error) {
|
||||||
|
return obj.ID, nil
|
||||||
|
},
|
||||||
|
nil,
|
||||||
|
func(ctx context.Context, selections ast.SelectionSet, v uint) graphql.Marshaler {
|
||||||
|
return ec.marshalNID2uint(ctx, selections, v)
|
||||||
|
},
|
||||||
|
true,
|
||||||
|
true,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
func (ec *executionContext) fieldContext_Background_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
|
||||||
|
return graphql.NewScalarFieldContext("Background", field, false, false, errors.New("field of type ID does not have child fields"))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ec *executionContext) _Background_updatedAt(ctx context.Context, field graphql.CollectedField, obj *models.Background) (ret graphql.Marshaler) {
|
||||||
|
return graphql.ResolveField(
|
||||||
|
ctx,
|
||||||
|
ec.OperationContext,
|
||||||
|
field,
|
||||||
|
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
|
||||||
|
return ec.fieldContext_Background_updatedAt(ctx, field)
|
||||||
|
},
|
||||||
|
func(ctx context.Context) (any, error) {
|
||||||
|
return obj.UpdatedAt, nil
|
||||||
|
},
|
||||||
|
nil,
|
||||||
|
func(ctx context.Context, selections ast.SelectionSet, v time.Time) graphql.Marshaler {
|
||||||
|
return ec.marshalNTime2timeᚐTime(ctx, selections, v)
|
||||||
|
},
|
||||||
|
true,
|
||||||
|
true,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
func (ec *executionContext) fieldContext_Background_updatedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
|
||||||
|
return graphql.NewScalarFieldContext("Background", field, false, false, errors.New("field of type Time does not have child fields"))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ec *executionContext) _Background_page(ctx context.Context, field graphql.CollectedField, obj *models.Background) (ret graphql.Marshaler) {
|
||||||
|
return graphql.ResolveField(
|
||||||
|
ctx,
|
||||||
|
ec.OperationContext,
|
||||||
|
field,
|
||||||
|
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
|
||||||
|
return ec.fieldContext_Background_page(ctx, field)
|
||||||
|
},
|
||||||
|
func(ctx context.Context) (any, error) {
|
||||||
|
return obj.Page, nil
|
||||||
|
},
|
||||||
|
nil,
|
||||||
|
func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler {
|
||||||
|
return ec.marshalNString2string(ctx, selections, v)
|
||||||
|
},
|
||||||
|
true,
|
||||||
|
true,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
func (ec *executionContext) fieldContext_Background_page(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
|
||||||
|
return graphql.NewScalarFieldContext("Background", field, false, false, errors.New("field of type String does not have child fields"))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ec *executionContext) _Background_color(ctx context.Context, field graphql.CollectedField, obj *models.Background) (ret graphql.Marshaler) {
|
||||||
|
return graphql.ResolveField(
|
||||||
|
ctx,
|
||||||
|
ec.OperationContext,
|
||||||
|
field,
|
||||||
|
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
|
||||||
|
return ec.fieldContext_Background_color(ctx, field)
|
||||||
|
},
|
||||||
|
func(ctx context.Context) (any, error) {
|
||||||
|
return obj.Color, nil
|
||||||
|
},
|
||||||
|
nil,
|
||||||
|
func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler {
|
||||||
|
return ec.marshalNString2string(ctx, selections, v)
|
||||||
|
},
|
||||||
|
true,
|
||||||
|
true,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
func (ec *executionContext) fieldContext_Background_color(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
|
||||||
|
return graphql.NewScalarFieldContext("Background", field, false, false, errors.New("field of type String does not have child fields"))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ec *executionContext) _Background_image(ctx context.Context, field graphql.CollectedField, obj *models.Background) (ret graphql.Marshaler) {
|
||||||
|
return graphql.ResolveField(
|
||||||
|
ctx,
|
||||||
|
ec.OperationContext,
|
||||||
|
field,
|
||||||
|
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
|
||||||
|
return ec.fieldContext_Background_image(ctx, field)
|
||||||
|
},
|
||||||
|
func(ctx context.Context) (any, error) {
|
||||||
|
return obj.Image, nil
|
||||||
|
},
|
||||||
|
nil,
|
||||||
|
func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler {
|
||||||
|
return ec.marshalNString2string(ctx, selections, v)
|
||||||
|
},
|
||||||
|
true,
|
||||||
|
true,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
func (ec *executionContext) fieldContext_Background_image(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
|
||||||
|
return graphql.NewScalarFieldContext("Background", field, false, false, errors.New("field of type String does not have child fields"))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ec *executionContext) _Background_fit(ctx context.Context, field graphql.CollectedField, obj *models.Background) (ret graphql.Marshaler) {
|
||||||
|
return graphql.ResolveField(
|
||||||
|
ctx,
|
||||||
|
ec.OperationContext,
|
||||||
|
field,
|
||||||
|
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
|
||||||
|
return ec.fieldContext_Background_fit(ctx, field)
|
||||||
|
},
|
||||||
|
func(ctx context.Context) (any, error) {
|
||||||
|
return obj.Fit, nil
|
||||||
|
},
|
||||||
|
nil,
|
||||||
|
func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler {
|
||||||
|
return ec.marshalNString2string(ctx, selections, v)
|
||||||
|
},
|
||||||
|
true,
|
||||||
|
true,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
func (ec *executionContext) fieldContext_Background_fit(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
|
||||||
|
return graphql.NewScalarFieldContext("Background", field, false, false, errors.New("field of type String does not have child fields"))
|
||||||
|
}
|
||||||
|
|
||||||
func (ec *executionContext) _Bookmark_id(ctx context.Context, field graphql.CollectedField, obj *models.Bookmark) (ret graphql.Marshaler) {
|
func (ec *executionContext) _Bookmark_id(ctx context.Context, field graphql.CollectedField, obj *models.Bookmark) (ret graphql.Marshaler) {
|
||||||
return graphql.ResolveField(
|
return graphql.ResolveField(
|
||||||
ctx,
|
ctx,
|
||||||
@@ -3576,6 +3869,120 @@ func (ec *executionContext) fieldContext_Mutation_refreshToken(_ context.Context
|
|||||||
return fc, nil
|
return fc, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (ec *executionContext) _Mutation_setBackground(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
|
||||||
|
return graphql.ResolveField(
|
||||||
|
ctx,
|
||||||
|
ec.OperationContext,
|
||||||
|
field,
|
||||||
|
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
|
||||||
|
return ec.fieldContext_Mutation_setBackground(ctx, field)
|
||||||
|
},
|
||||||
|
func(ctx context.Context) (any, error) {
|
||||||
|
fc := graphql.GetFieldContext(ctx)
|
||||||
|
return ec.Resolvers.Mutation().SetBackground(ctx, fc.Args["page"].(string), fc.Args["input"].(model.BackgroundInput))
|
||||||
|
},
|
||||||
|
func(ctx context.Context, next graphql.Resolver) graphql.Resolver {
|
||||||
|
directive0 := next
|
||||||
|
|
||||||
|
directive1 := func(ctx context.Context) (any, error) {
|
||||||
|
if ec.Directives.Admin == nil {
|
||||||
|
var zeroVal *models.Background
|
||||||
|
return zeroVal, errors.New("directive admin is not implemented")
|
||||||
|
}
|
||||||
|
return ec.Directives.Admin(ctx, nil, directive0)
|
||||||
|
}
|
||||||
|
|
||||||
|
next = directive1
|
||||||
|
return next
|
||||||
|
},
|
||||||
|
func(ctx context.Context, selections ast.SelectionSet, v *models.Background) graphql.Marshaler {
|
||||||
|
return ec.marshalNBackground2ᚖadamᚑfrenchᚗcoᚗukᚋbackendᚋmodelsᚐBackground(ctx, selections, v)
|
||||||
|
},
|
||||||
|
true,
|
||||||
|
true,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
func (ec *executionContext) fieldContext_Mutation_setBackground(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
|
||||||
|
fc = &graphql.FieldContext{
|
||||||
|
Object: "Mutation",
|
||||||
|
Field: field,
|
||||||
|
IsMethod: true,
|
||||||
|
IsResolver: true,
|
||||||
|
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
|
||||||
|
return ec.childFields_Background(ctx, field)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
defer func() {
|
||||||
|
if r := recover(); r != nil {
|
||||||
|
err = ec.Recover(ctx, r)
|
||||||
|
ec.Error(ctx, err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
ctx = graphql.WithFieldContext(ctx, fc)
|
||||||
|
if fc.Args, err = ec.field_Mutation_setBackground_args(ctx, field.ArgumentMap(ec.Variables)); err != nil {
|
||||||
|
ec.Error(ctx, err)
|
||||||
|
return fc, err
|
||||||
|
}
|
||||||
|
return fc, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ec *executionContext) _Mutation_clearBackground(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
|
||||||
|
return graphql.ResolveField(
|
||||||
|
ctx,
|
||||||
|
ec.OperationContext,
|
||||||
|
field,
|
||||||
|
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
|
||||||
|
return ec.fieldContext_Mutation_clearBackground(ctx, field)
|
||||||
|
},
|
||||||
|
func(ctx context.Context) (any, error) {
|
||||||
|
fc := graphql.GetFieldContext(ctx)
|
||||||
|
return ec.Resolvers.Mutation().ClearBackground(ctx, fc.Args["page"].(string))
|
||||||
|
},
|
||||||
|
func(ctx context.Context, next graphql.Resolver) graphql.Resolver {
|
||||||
|
directive0 := next
|
||||||
|
|
||||||
|
directive1 := func(ctx context.Context) (any, error) {
|
||||||
|
if ec.Directives.Admin == nil {
|
||||||
|
var zeroVal bool
|
||||||
|
return zeroVal, errors.New("directive admin is not implemented")
|
||||||
|
}
|
||||||
|
return ec.Directives.Admin(ctx, nil, directive0)
|
||||||
|
}
|
||||||
|
|
||||||
|
next = directive1
|
||||||
|
return next
|
||||||
|
},
|
||||||
|
func(ctx context.Context, selections ast.SelectionSet, v bool) graphql.Marshaler {
|
||||||
|
return ec.marshalNBoolean2bool(ctx, selections, v)
|
||||||
|
},
|
||||||
|
true,
|
||||||
|
true,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
func (ec *executionContext) fieldContext_Mutation_clearBackground(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
|
||||||
|
fc = &graphql.FieldContext{
|
||||||
|
Object: "Mutation",
|
||||||
|
Field: field,
|
||||||
|
IsMethod: true,
|
||||||
|
IsResolver: true,
|
||||||
|
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
|
||||||
|
return nil, errors.New("field of type Boolean does not have child fields")
|
||||||
|
},
|
||||||
|
}
|
||||||
|
defer func() {
|
||||||
|
if r := recover(); r != nil {
|
||||||
|
err = ec.Recover(ctx, r)
|
||||||
|
ec.Error(ctx, err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
ctx = graphql.WithFieldContext(ctx, fc)
|
||||||
|
if fc.Args, err = ec.field_Mutation_clearBackground_args(ctx, field.ArgumentMap(ec.Variables)); err != nil {
|
||||||
|
ec.Error(ctx, err)
|
||||||
|
return fc, err
|
||||||
|
}
|
||||||
|
return fc, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (ec *executionContext) _Mutation_createBookmark(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
|
func (ec *executionContext) _Mutation_createBookmark(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
|
||||||
return graphql.ResolveField(
|
return graphql.ResolveField(
|
||||||
ctx,
|
ctx,
|
||||||
@@ -5204,6 +5611,50 @@ func (ec *executionContext) fieldContext_Query_me(_ context.Context, field graph
|
|||||||
return fc, nil
|
return fc, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (ec *executionContext) _Query_background(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
|
||||||
|
return graphql.ResolveField(
|
||||||
|
ctx,
|
||||||
|
ec.OperationContext,
|
||||||
|
field,
|
||||||
|
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
|
||||||
|
return ec.fieldContext_Query_background(ctx, field)
|
||||||
|
},
|
||||||
|
func(ctx context.Context) (any, error) {
|
||||||
|
fc := graphql.GetFieldContext(ctx)
|
||||||
|
return ec.Resolvers.Query().Background(ctx, fc.Args["page"].(string))
|
||||||
|
},
|
||||||
|
nil,
|
||||||
|
func(ctx context.Context, selections ast.SelectionSet, v *models.Background) graphql.Marshaler {
|
||||||
|
return ec.marshalOBackground2ᚖadamᚑfrenchᚗcoᚗukᚋbackendᚋmodelsᚐBackground(ctx, selections, v)
|
||||||
|
},
|
||||||
|
true,
|
||||||
|
false,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
func (ec *executionContext) fieldContext_Query_background(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
|
||||||
|
fc = &graphql.FieldContext{
|
||||||
|
Object: "Query",
|
||||||
|
Field: field,
|
||||||
|
IsMethod: true,
|
||||||
|
IsResolver: true,
|
||||||
|
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
|
||||||
|
return ec.childFields_Background(ctx, field)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
defer func() {
|
||||||
|
if r := recover(); r != nil {
|
||||||
|
err = ec.Recover(ctx, r)
|
||||||
|
ec.Error(ctx, err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
ctx = graphql.WithFieldContext(ctx, fc)
|
||||||
|
if fc.Args, err = ec.field_Query_background_args(ctx, field.ArgumentMap(ec.Variables)); err != nil {
|
||||||
|
ec.Error(ctx, err)
|
||||||
|
return fc, err
|
||||||
|
}
|
||||||
|
return fc, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (ec *executionContext) _Query_bookmarks(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
|
func (ec *executionContext) _Query_bookmarks(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
|
||||||
return graphql.ResolveField(
|
return graphql.ResolveField(
|
||||||
ctx,
|
ctx,
|
||||||
@@ -7705,6 +8156,50 @@ func (ec *executionContext) fieldContext___Type_isOneOf(_ context.Context, field
|
|||||||
|
|
||||||
// region **************************** input.gotpl *****************************
|
// region **************************** input.gotpl *****************************
|
||||||
|
|
||||||
|
func (ec *executionContext) unmarshalInputBackgroundInput(ctx context.Context, obj any) (model.BackgroundInput, error) {
|
||||||
|
var it model.BackgroundInput
|
||||||
|
if obj == nil {
|
||||||
|
return it, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
asMap := map[string]any{}
|
||||||
|
for k, v := range obj.(map[string]any) {
|
||||||
|
asMap[k] = v
|
||||||
|
}
|
||||||
|
|
||||||
|
fieldsInOrder := [...]string{"color", "image", "fit"}
|
||||||
|
for _, k := range fieldsInOrder {
|
||||||
|
v, ok := asMap[k]
|
||||||
|
if !ok {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
switch k {
|
||||||
|
case "color":
|
||||||
|
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("color"))
|
||||||
|
data, err := ec.unmarshalNString2string(ctx, v)
|
||||||
|
if err != nil {
|
||||||
|
return it, err
|
||||||
|
}
|
||||||
|
it.Color = data
|
||||||
|
case "image":
|
||||||
|
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("image"))
|
||||||
|
data, err := ec.unmarshalNString2string(ctx, v)
|
||||||
|
if err != nil {
|
||||||
|
return it, err
|
||||||
|
}
|
||||||
|
it.Image = data
|
||||||
|
case "fit":
|
||||||
|
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fit"))
|
||||||
|
data, err := ec.unmarshalNString2string(ctx, v)
|
||||||
|
if err != nil {
|
||||||
|
return it, err
|
||||||
|
}
|
||||||
|
it.Fit = data
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return it, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (ec *executionContext) unmarshalInputCreateActivityInput(ctx context.Context, obj any) (model.CreateActivityInput, error) {
|
func (ec *executionContext) unmarshalInputCreateActivityInput(ctx context.Context, obj any) (model.CreateActivityInput, error) {
|
||||||
var it model.CreateActivityInput
|
var it model.CreateActivityInput
|
||||||
if obj == nil {
|
if obj == nil {
|
||||||
@@ -8554,6 +9049,69 @@ func (ec *executionContext) _AuthPayload(ctx context.Context, sel ast.SelectionS
|
|||||||
return out
|
return out
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var backgroundImplementors = []string{"Background"}
|
||||||
|
|
||||||
|
func (ec *executionContext) _Background(ctx context.Context, sel ast.SelectionSet, obj *models.Background) graphql.Marshaler {
|
||||||
|
fields := graphql.CollectFields(ec.OperationContext, sel, backgroundImplementors)
|
||||||
|
|
||||||
|
out := graphql.NewFieldSet(fields)
|
||||||
|
deferredFieldSet := graphql.NewFieldSet(nil)
|
||||||
|
deferLabelToView := make(map[string]*graphql.FieldSetView)
|
||||||
|
for i, field := range fields {
|
||||||
|
switch field.Name {
|
||||||
|
case "__typename":
|
||||||
|
out.Values[i] = graphql.MarshalString("Background")
|
||||||
|
case "id":
|
||||||
|
out.Values[i] = ec._Background_id(ctx, field, obj)
|
||||||
|
if out.Values[i] == graphql.Null {
|
||||||
|
out.Invalids++
|
||||||
|
}
|
||||||
|
case "updatedAt":
|
||||||
|
out.Values[i] = ec._Background_updatedAt(ctx, field, obj)
|
||||||
|
if out.Values[i] == graphql.Null {
|
||||||
|
out.Invalids++
|
||||||
|
}
|
||||||
|
case "page":
|
||||||
|
out.Values[i] = ec._Background_page(ctx, field, obj)
|
||||||
|
if out.Values[i] == graphql.Null {
|
||||||
|
out.Invalids++
|
||||||
|
}
|
||||||
|
case "color":
|
||||||
|
out.Values[i] = ec._Background_color(ctx, field, obj)
|
||||||
|
if out.Values[i] == graphql.Null {
|
||||||
|
out.Invalids++
|
||||||
|
}
|
||||||
|
case "image":
|
||||||
|
out.Values[i] = ec._Background_image(ctx, field, obj)
|
||||||
|
if out.Values[i] == graphql.Null {
|
||||||
|
out.Invalids++
|
||||||
|
}
|
||||||
|
case "fit":
|
||||||
|
out.Values[i] = ec._Background_fit(ctx, field, obj)
|
||||||
|
if out.Values[i] == graphql.Null {
|
||||||
|
out.Invalids++
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
panic("unknown field " + strconv.Quote(field.Name))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
out.Dispatch(ctx)
|
||||||
|
if out.Invalids > 0 {
|
||||||
|
return graphql.Null
|
||||||
|
}
|
||||||
|
|
||||||
|
atomic.AddInt32(&ec.Deferred, int32(min(len(deferLabelToView), math.MaxInt32)))
|
||||||
|
|
||||||
|
ec.ProcessDeferredGroup(graphql.DeferredGroup{
|
||||||
|
Defers: deferLabelToView,
|
||||||
|
Path: graphql.GetPath(ctx),
|
||||||
|
FieldSet: deferredFieldSet,
|
||||||
|
Context: ctx,
|
||||||
|
})
|
||||||
|
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
var bookmarkImplementors = []string{"Bookmark"}
|
var bookmarkImplementors = []string{"Bookmark"}
|
||||||
|
|
||||||
func (ec *executionContext) _Bookmark(ctx context.Context, sel ast.SelectionSet, obj *models.Bookmark) graphql.Marshaler {
|
func (ec *executionContext) _Bookmark(ctx context.Context, sel ast.SelectionSet, obj *models.Bookmark) graphql.Marshaler {
|
||||||
@@ -9000,6 +9558,20 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet)
|
|||||||
if out.Values[i] == graphql.Null {
|
if out.Values[i] == graphql.Null {
|
||||||
out.Invalids++
|
out.Invalids++
|
||||||
}
|
}
|
||||||
|
case "setBackground":
|
||||||
|
out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) {
|
||||||
|
return ec._Mutation_setBackground(ctx, field)
|
||||||
|
})
|
||||||
|
if out.Values[i] == graphql.Null {
|
||||||
|
out.Invalids++
|
||||||
|
}
|
||||||
|
case "clearBackground":
|
||||||
|
out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) {
|
||||||
|
return ec._Mutation_clearBackground(ctx, field)
|
||||||
|
})
|
||||||
|
if out.Values[i] == graphql.Null {
|
||||||
|
out.Invalids++
|
||||||
|
}
|
||||||
case "createBookmark":
|
case "createBookmark":
|
||||||
out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) {
|
out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) {
|
||||||
return ec._Mutation_createBookmark(ctx, field)
|
return ec._Mutation_createBookmark(ctx, field)
|
||||||
@@ -9424,6 +9996,28 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
|
|||||||
func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) })
|
func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) })
|
||||||
|
case "background":
|
||||||
|
field := field
|
||||||
|
|
||||||
|
innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) {
|
||||||
|
defer func() {
|
||||||
|
if r := recover(); r != nil {
|
||||||
|
ec.Error(ctx, ec.Recover(ctx, r))
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
res = ec._Query_background(ctx, field)
|
||||||
|
if res == graphql.RequiredNull {
|
||||||
|
atomic.AddUint32(&fs.Invalids, 1)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
rrm := func(ctx context.Context) graphql.Marshaler {
|
||||||
|
return ec.OperationContext.RootResolverMiddleware(ctx,
|
||||||
|
func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) })
|
||||||
|
}
|
||||||
|
|
||||||
out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) })
|
out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) })
|
||||||
case "bookmarks":
|
case "bookmarks":
|
||||||
field := field
|
field := field
|
||||||
@@ -10808,6 +11402,21 @@ func (ec *executionContext) marshalNAuthPayload2ᚖadamᚑfrenchᚗcoᚗukᚋbac
|
|||||||
return ec._AuthPayload(ctx, sel, v)
|
return ec._AuthPayload(ctx, sel, v)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (ec *executionContext) marshalNBackground2ᚖadamᚑfrenchᚗcoᚗukᚋbackendᚋmodelsᚐBackground(ctx context.Context, sel ast.SelectionSet, v *models.Background) graphql.Marshaler {
|
||||||
|
if v == nil {
|
||||||
|
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
|
||||||
|
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
|
||||||
|
}
|
||||||
|
return graphql.Null
|
||||||
|
}
|
||||||
|
return ec._Background(ctx, sel, v)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ec *executionContext) unmarshalNBackgroundInput2adamᚑfrenchᚗcoᚗukᚋbackendᚋgraphᚋmodelᚐBackgroundInput(ctx context.Context, v any) (model.BackgroundInput, error) {
|
||||||
|
res, err := ec.unmarshalInputBackgroundInput(ctx, v)
|
||||||
|
return res, graphql.ErrorOnPath(ctx, err)
|
||||||
|
}
|
||||||
|
|
||||||
func (ec *executionContext) marshalNBookmark2ᚕᚖadamᚑfrenchᚗcoᚗukᚋbackendᚋmodelsᚐBookmarkᚄ(ctx context.Context, sel ast.SelectionSet, v []*models.Bookmark) graphql.Marshaler {
|
func (ec *executionContext) marshalNBookmark2ᚕᚖadamᚑfrenchᚗcoᚗukᚋbackendᚋmodelsᚐBookmarkᚄ(ctx context.Context, sel ast.SelectionSet, v []*models.Bookmark) graphql.Marshaler {
|
||||||
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
|
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
|
||||||
fc := graphql.GetFieldContext(ctx)
|
fc := graphql.GetFieldContext(ctx)
|
||||||
@@ -11467,6 +12076,13 @@ func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel a
|
|||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (ec *executionContext) marshalOBackground2ᚖadamᚑfrenchᚗcoᚗukᚋbackendᚋmodelsᚐBackground(ctx context.Context, sel ast.SelectionSet, v *models.Background) graphql.Marshaler {
|
||||||
|
if v == nil {
|
||||||
|
return graphql.Null
|
||||||
|
}
|
||||||
|
return ec._Background(ctx, sel, v)
|
||||||
|
}
|
||||||
|
|
||||||
func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v any) (bool, error) {
|
func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v any) (bool, error) {
|
||||||
res, err := graphql.UnmarshalBoolean(v)
|
res, err := graphql.UnmarshalBoolean(v)
|
||||||
return res, graphql.ErrorOnPath(ctx, err)
|
return res, graphql.ErrorOnPath(ctx, err)
|
||||||
|
|||||||
@@ -12,6 +12,12 @@ type AuthPayload struct {
|
|||||||
User *models.User `json:"user"`
|
User *models.User `json:"user"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type BackgroundInput struct {
|
||||||
|
Color string `json:"color"`
|
||||||
|
Image string `json:"image"`
|
||||||
|
Fit string `json:"fit"`
|
||||||
|
}
|
||||||
|
|
||||||
type CreateActivityInput struct {
|
type CreateActivityInput struct {
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
|
|||||||
@@ -45,8 +45,9 @@ func (r *mutationResolver) CreatePage(ctx context.Context, input model.CreatePag
|
|||||||
|
|
||||||
// UpdatePage is the resolver for the updatePage field.
|
// UpdatePage is the resolver for the updatePage field.
|
||||||
func (r *mutationResolver) UpdatePage(ctx context.Context, id int, input model.UpdatePageInput) (*models.Page, error) {
|
func (r *mutationResolver) UpdatePage(ctx context.Context, id int, input model.UpdatePageInput) (*models.Page, error) {
|
||||||
// Partial update, like updateBox. A new slug moves the page's boxes with
|
// Partial update, like updateBox. A new slug moves the page's boxes and
|
||||||
// it in the same transaction, since boxes find their page by slug.
|
// background with it in the same transaction, since both find their page
|
||||||
|
// by slug.
|
||||||
var page models.Page
|
var page models.Page
|
||||||
if err := r.Store.DB.First(&page, id).Error; err != nil {
|
if err := r.Store.DB.First(&page, id).Error; err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -81,6 +82,9 @@ func (r *mutationResolver) UpdatePage(ctx context.Context, id int, input model.U
|
|||||||
if err := tx.Model(&models.Box{}).Where("page = ?", oldSlug).Update("page", page.Slug).Error; err != nil {
|
if err := tx.Model(&models.Box{}).Where("page = ?", oldSlug).Update("page", page.Slug).Error; err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if err := tx.Model(&models.Background{}).Where("page = ?", oldSlug).Update("page", page.Slug).Error; err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return tx.Save(&page).Error
|
return tx.Save(&page).Error
|
||||||
})
|
})
|
||||||
@@ -92,8 +96,8 @@ func (r *mutationResolver) UpdatePage(ctx context.Context, id int, input model.U
|
|||||||
|
|
||||||
// DeletePage is the resolver for the deletePage field.
|
// DeletePage is the resolver for the deletePage field.
|
||||||
func (r *mutationResolver) DeletePage(ctx context.Context, id int) (*models.Page, error) {
|
func (r *mutationResolver) DeletePage(ctx context.Context, id int) (*models.Page, error) {
|
||||||
// The boxes go too: left behind, they would reappear on any page later
|
// The boxes and background go too: left behind, they would reappear on
|
||||||
// created at the same address.
|
// any page later created at the same address.
|
||||||
var page models.Page
|
var page models.Page
|
||||||
if err := r.Store.DB.First(&page, id).Error; err != nil {
|
if err := r.Store.DB.First(&page, id).Error; err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -102,6 +106,9 @@ func (r *mutationResolver) DeletePage(ctx context.Context, id int) (*models.Page
|
|||||||
if err := tx.Where("page = ?", page.Slug).Delete(&models.Box{}).Error; err != nil {
|
if err := tx.Where("page = ?", page.Slug).Delete(&models.Box{}).Error; err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if err := tx.Where("page = ?", page.Slug).Delete(&models.Background{}).Error; err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
return tx.Delete(&page).Error
|
return tx.Delete(&page).Error
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -0,0 +1,37 @@
|
|||||||
|
# The background behind a canvas page, keyed by the same page key as its
|
||||||
|
# boxes ("index" for the landing page, "stp", or a Page's slug), so the
|
||||||
|
# landing page and every shrine are set the same way. Edited from the
|
||||||
|
# canvas's "Background" button; see models.Background.
|
||||||
|
#
|
||||||
|
# Anyone may read it, as part of the page, except that an adminOnly page's
|
||||||
|
# background is null to everyone but an admin.
|
||||||
|
|
||||||
|
type Background {
|
||||||
|
id: ID!
|
||||||
|
updatedAt: Time!
|
||||||
|
page: String!
|
||||||
|
# A CSS colour, or "" for the theme's page colour.
|
||||||
|
color: String!
|
||||||
|
# An image URL, or "" for none.
|
||||||
|
image: String!
|
||||||
|
# "cover", "contain" or "tile".
|
||||||
|
fit: String!
|
||||||
|
}
|
||||||
|
|
||||||
|
input BackgroundInput {
|
||||||
|
color: String!
|
||||||
|
image: String!
|
||||||
|
fit: String!
|
||||||
|
}
|
||||||
|
|
||||||
|
extend type Query {
|
||||||
|
# Null when the page has none, i.e. shows the theme's default.
|
||||||
|
background(page: String!): Background
|
||||||
|
}
|
||||||
|
|
||||||
|
extend type Mutation {
|
||||||
|
# Creates or replaces the page's background.
|
||||||
|
setBackground(page: String!, input: BackgroundInput!): Background! @admin
|
||||||
|
# Back to the theme's default. True if there was one to remove.
|
||||||
|
clearBackground(page: String!): Boolean! @admin
|
||||||
|
}
|
||||||
@@ -205,3 +205,22 @@ type Page struct {
|
|||||||
// AdminOnly hides the whole page, boxes included, from everyone else.
|
// AdminOnly hides the whole page, boxes included, from everyone else.
|
||||||
AdminOnly bool `gorm:"not null;default:false" json:"adminOnly"`
|
AdminOnly bool `gorm:"not null;default:false" json:"adminOnly"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Background is the page background behind one canvas (Page is the same page
|
||||||
|
// key a Box has: "index" for the landing page, "stp", or a Page's slug), so
|
||||||
|
// built-in canvases and admin-created pages are set the same way. A page with
|
||||||
|
// no row shows the theme's halftone; deleting the row is "reset to default".
|
||||||
|
// The unique index is partial for the same reason as Page's.
|
||||||
|
type Background struct {
|
||||||
|
ID uint `gorm:"primarykey" json:"id"`
|
||||||
|
CreatedAt time.Time `json:"createdAt"`
|
||||||
|
UpdatedAt time.Time `json:"updatedAt"`
|
||||||
|
DeletedAt gorm.DeletedAt `gorm:"index" json:"deletedAt"`
|
||||||
|
Page string `gorm:"not null;index:idx_backgrounds_page,unique,where:deleted_at IS NULL" json:"page"`
|
||||||
|
// Color is a CSS colour, or "" for the theme's page colour.
|
||||||
|
Color string `gorm:"not null;default:''" json:"color"`
|
||||||
|
// Image is a URL, or "" for none. Drawn over Color.
|
||||||
|
Image string `gorm:"not null;default:''" json:"image"`
|
||||||
|
// Fit is how Image fills the window: "cover", "contain" or "tile".
|
||||||
|
Fit string `gorm:"not null;default:cover" json:"fit"`
|
||||||
|
}
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ func migrateDatabase(db *gorm.DB) error {
|
|||||||
&models.Place{},
|
&models.Place{},
|
||||||
&models.Box{},
|
&models.Box{},
|
||||||
&models.Page{},
|
&models.Page{},
|
||||||
|
&models.Background{},
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -216,6 +216,14 @@ renders any page's boxes.
|
|||||||
The server refuses slugs that an SPA or nginx route would answer first
|
The server refuses slugs that an SPA or nginx route would answer first
|
||||||
(`validateSlug` in `backend/graph/page_helpers.go`) — add to that list when
|
(`validateSlug` in `backend/graph/page_helpers.go`) — add to that list when
|
||||||
adding a route.
|
adding a route.
|
||||||
|
- **Backgrounds.** Each page key can have its own background (`Background` in
|
||||||
|
GraphQL, `stores/background.js`): a colour, an image, and whether the image
|
||||||
|
fills the window, fits inside it or tiles. Admins set it with the
|
||||||
|
"Background" button next to "Edit layout" (`BackgroundEditor.vue`), which
|
||||||
|
previews live and takes an uploaded or dropped image. `DefaultLayout` paints
|
||||||
|
it behind the whole window, navbar included, while that canvas is mounted,
|
||||||
|
and falls back to the halftone. Renaming or deleting a page carries its
|
||||||
|
background along; an admin-only page's background is hidden with it.
|
||||||
- **Admin only.** A box or a page can be marked admin-only. The server never
|
- **Admin only.** A box or a page can be marked admin-only. The server never
|
||||||
sends those to anyone else, so they are fit for private notes; admins see
|
sends those to anyone else, so they are fit for private notes; admins see
|
||||||
such boxes outlined, with a 🔒 in edit mode. The "Note" template starts
|
such boxes outlined, with a 🔒 in edit mode. The "Note" template starts
|
||||||
|
|||||||
@@ -6,14 +6,21 @@
|
|||||||
* assets/styles.css). `:key="$route.path"` forces a full remount on every path
|
* assets/styles.css). `:key="$route.path"` forces a full remount on every path
|
||||||
* change so the transition actually runs even between two routes that share a
|
* change so the transition actually runs even between two routes that share a
|
||||||
* component; `mode="out-in"` stops the outgoing and incoming pages overlapping.
|
* component; `mode="out-in"` stops the outgoing and incoming pages overlapping.
|
||||||
|
*
|
||||||
|
* The background is the halftone unless the page on screen has one of its
|
||||||
|
* own (stores/background.js — set per canvas page, landing page and shrines
|
||||||
|
* included). The inline style overrides the halftone's layers.
|
||||||
*/
|
*/
|
||||||
import { RouterView } from "vue-router";
|
import { RouterView } from "vue-router";
|
||||||
|
import { useBackgroundStore } from "@/stores/background";
|
||||||
import Navbar from "@/components/Navbar.vue";
|
import Navbar from "@/components/Navbar.vue";
|
||||||
import Footer from "@/components/Footer.vue";
|
import Footer from "@/components/Footer.vue";
|
||||||
|
|
||||||
|
const background = useBackgroundStore();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="default-layout halftone">
|
<div class="default-layout halftone" :style="background.style">
|
||||||
<Navbar class="no-print sticky top-0 z-50" />
|
<Navbar class="no-print sticky top-0 z-50" />
|
||||||
<main class="default-content">
|
<main class="default-content">
|
||||||
<RouterView v-slot="{ Component }">
|
<RouterView v-slot="{ Component }">
|
||||||
|
|||||||
@@ -0,0 +1,100 @@
|
|||||||
|
/**
|
||||||
|
* Page backgrounds (the `Background` GraphQL type), one per canvas page key —
|
||||||
|
* "index" for the landing page, "stp", or a Page slug such as
|
||||||
|
* "shrines/evangelion" — and which one is on screen.
|
||||||
|
*
|
||||||
|
* DefaultLayout paints `style` behind everything, navbar included, so a
|
||||||
|
* background covers the whole window rather than just the canvas. Each
|
||||||
|
* BoxCanvas calls show(page) when it mounts and hide(page) when it goes;
|
||||||
|
* a page with no background (null) keeps the theme's halftone.
|
||||||
|
*
|
||||||
|
* `preview` is BackgroundEditor's unsaved draft: while it is set for the page
|
||||||
|
* on screen, it is what the layout paints, so every change shows at once.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { defineStore } from "pinia";
|
||||||
|
import { computed, ref } from "vue";
|
||||||
|
import { gql } from "@/graphql";
|
||||||
|
|
||||||
|
const FIELDS = "id page color image fit";
|
||||||
|
|
||||||
|
export const FITS = [
|
||||||
|
{ id: "cover", label: "Fill the window" },
|
||||||
|
{ id: "contain", label: "Fit inside the window" },
|
||||||
|
{ id: "tile", label: "Tile" },
|
||||||
|
];
|
||||||
|
|
||||||
|
/** CSS for a background, or null for the theme default. */
|
||||||
|
export function backgroundStyle(bg) {
|
||||||
|
if (!bg || (!bg.color && !bg.image)) return null;
|
||||||
|
const style = {
|
||||||
|
backgroundColor: bg.color || "var(--color-surface-deep)",
|
||||||
|
// "none" as well as a URL: either way the halftone's own layers go.
|
||||||
|
backgroundImage: bg.image ? `url("${bg.image}")` : "none",
|
||||||
|
};
|
||||||
|
if (bg.fit === "tile") {
|
||||||
|
Object.assign(style, { backgroundSize: "auto", backgroundRepeat: "repeat", backgroundPosition: "0 0" });
|
||||||
|
} else {
|
||||||
|
// Pinned to the window, so a tall page scrolls over one picture rather
|
||||||
|
// than stretching it down the whole page.
|
||||||
|
Object.assign(style, {
|
||||||
|
backgroundSize: bg.fit,
|
||||||
|
backgroundRepeat: "no-repeat",
|
||||||
|
backgroundPosition: "center",
|
||||||
|
backgroundAttachment: "fixed",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return style;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const useBackgroundStore = defineStore("background", () => {
|
||||||
|
// page key -> Background or null; a key not present hasn't been loaded.
|
||||||
|
const byPage = ref({});
|
||||||
|
const active = ref(null);
|
||||||
|
const preview = ref(null); // { page, color, image, fit }
|
||||||
|
|
||||||
|
const current = computed(() =>
|
||||||
|
preview.value && preview.value.page === active.value ? preview.value : byPage.value[active.value],
|
||||||
|
);
|
||||||
|
const style = computed(() => backgroundStyle(current.value));
|
||||||
|
|
||||||
|
async function load(page) {
|
||||||
|
try {
|
||||||
|
const data = await gql(`query Background($page: String!) { background(page: $page) { ${FIELDS} } }`, {
|
||||||
|
page,
|
||||||
|
});
|
||||||
|
byPage.value[page] = data.background;
|
||||||
|
} catch (err) {
|
||||||
|
// The theme default is a fine fallback; the page itself still loads.
|
||||||
|
console.warn(`Couldn't load the background for ${page}:`, err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function show(page) {
|
||||||
|
active.value = page;
|
||||||
|
if (!(page in byPage.value)) load(page);
|
||||||
|
}
|
||||||
|
|
||||||
|
function hide(page) {
|
||||||
|
if (active.value === page) active.value = null;
|
||||||
|
if (preview.value?.page === page) preview.value = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function save(page, { color, image, fit }) {
|
||||||
|
const data = await gql(
|
||||||
|
`mutation SetBackground($page: String!, $input: BackgroundInput!) {
|
||||||
|
setBackground(page: $page, input: $input) { ${FIELDS} }
|
||||||
|
}`,
|
||||||
|
{ page, input: { color, image, fit } },
|
||||||
|
);
|
||||||
|
byPage.value[page] = data.setBackground;
|
||||||
|
return data.setBackground;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function clear(page) {
|
||||||
|
await gql(`mutation ClearBackground($page: String!) { clearBackground(page: $page) }`, { page });
|
||||||
|
byPage.value[page] = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return { byPage, active, preview, current, style, load, show, hide, save, clear };
|
||||||
|
});
|
||||||
@@ -0,0 +1,228 @@
|
|||||||
|
<script setup>
|
||||||
|
/**
|
||||||
|
* The admin's background panel for one canvas page, opened from BoxCanvas's
|
||||||
|
* "Background" button: a colour, an image (uploaded, dropped on the panel or
|
||||||
|
* given as a URL) and how the image fills the window.
|
||||||
|
*
|
||||||
|
* Every change previews live through the background store; Cancel (or
|
||||||
|
* closing) puts the saved one back. Saving with neither colour nor image is
|
||||||
|
* the same as "Theme default", which removes the page's background.
|
||||||
|
*/
|
||||||
|
import { computed, onBeforeUnmount, ref, watch } from "vue";
|
||||||
|
import { FITS, useBackgroundStore } from "@/stores/background";
|
||||||
|
import { uploadFile, isImage } from "./upload";
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
page: { type: String, required: true },
|
||||||
|
});
|
||||||
|
const emit = defineEmits(["close"]);
|
||||||
|
|
||||||
|
const bg = useBackgroundStore();
|
||||||
|
const saved = bg.byPage[props.page];
|
||||||
|
const draft = ref({
|
||||||
|
color: saved?.color ?? "",
|
||||||
|
image: saved?.image ?? "",
|
||||||
|
fit: saved?.fit ?? "cover",
|
||||||
|
});
|
||||||
|
watch(draft, (d) => (bg.preview = { page: props.page, ...d }), { deep: true, immediate: true });
|
||||||
|
onBeforeUnmount(() => {
|
||||||
|
if (bg.preview?.page === props.page) bg.preview = null;
|
||||||
|
});
|
||||||
|
|
||||||
|
// <input type="color"> only takes #rrggbb; a colour typed as a name or rgb()
|
||||||
|
// still works, the swatch just can't show it.
|
||||||
|
const HEX = /^#[0-9a-f]{6}$/i;
|
||||||
|
const swatch = computed(() => (HEX.test(draft.value.color) ? draft.value.color : "#04080f"));
|
||||||
|
|
||||||
|
const busy = ref(false);
|
||||||
|
const error = ref("");
|
||||||
|
const dragOver = ref(false);
|
||||||
|
|
||||||
|
async function upload(file) {
|
||||||
|
if (!file) return;
|
||||||
|
if (!file.type.startsWith("image/")) {
|
||||||
|
error.value = "That isn't an image";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
error.value = "";
|
||||||
|
busy.value = true;
|
||||||
|
try {
|
||||||
|
draft.value.image = await uploadFile(file);
|
||||||
|
} catch (err) {
|
||||||
|
error.value = err?.message || "Upload failed";
|
||||||
|
} finally {
|
||||||
|
busy.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function onDrop(event) {
|
||||||
|
dragOver.value = false;
|
||||||
|
upload(event.dataTransfer?.files?.[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function save() {
|
||||||
|
error.value = "";
|
||||||
|
busy.value = true;
|
||||||
|
try {
|
||||||
|
const { color, image, fit } = draft.value;
|
||||||
|
if (!color.trim() && !image.trim()) await bg.clear(props.page);
|
||||||
|
else await bg.save(props.page, { color, image, fit });
|
||||||
|
emit("close");
|
||||||
|
} catch (err) {
|
||||||
|
error.value = err?.message || "Failed to save";
|
||||||
|
} finally {
|
||||||
|
busy.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function resetToDefault() {
|
||||||
|
if (!confirm("Go back to the site's default background on this page?")) return;
|
||||||
|
error.value = "";
|
||||||
|
busy.value = true;
|
||||||
|
try {
|
||||||
|
await bg.clear(props.page);
|
||||||
|
emit("close");
|
||||||
|
} catch (err) {
|
||||||
|
error.value = err?.message || "Failed to reset";
|
||||||
|
} finally {
|
||||||
|
busy.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<form
|
||||||
|
class="bg-editor bdr-2 bg-surface"
|
||||||
|
:class="{ 'drag-over': dragOver }"
|
||||||
|
@submit.prevent="save"
|
||||||
|
@dragover.prevent="dragOver = true"
|
||||||
|
@dragleave.self="dragOver = false"
|
||||||
|
@drop.prevent="onDrop"
|
||||||
|
>
|
||||||
|
<h3>Page background</h3>
|
||||||
|
|
||||||
|
<label>
|
||||||
|
Colour
|
||||||
|
<span class="row">
|
||||||
|
<input type="color" :value="swatch" @input="draft.color = $event.target.value" />
|
||||||
|
<input v-model="draft.color" type="text" placeholder="theme colour" class="flex-1" />
|
||||||
|
<button v-if="draft.color" type="button" class="bar-btn small" @click="draft.color = ''">✕</button>
|
||||||
|
</span>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<label>
|
||||||
|
Image
|
||||||
|
<span class="row">
|
||||||
|
<input v-model="draft.image" type="text" placeholder="/uploads/… or https://…" class="flex-1" />
|
||||||
|
<button v-if="draft.image" type="button" class="bar-btn small" @click="draft.image = ''">✕</button>
|
||||||
|
</span>
|
||||||
|
</label>
|
||||||
|
<span class="row">
|
||||||
|
<label class="bar-btn upload">
|
||||||
|
{{ busy ? "Working…" : "Upload image…" }}
|
||||||
|
<input type="file" accept="image/*" hidden :disabled="busy" @change="upload($event.target.files[0])" />
|
||||||
|
</label>
|
||||||
|
<span class="hint">or drop one on this panel</span>
|
||||||
|
</span>
|
||||||
|
<img v-if="draft.image && isImage(draft.image)" :src="draft.image" alt="" class="thumb" />
|
||||||
|
|
||||||
|
<label v-if="draft.image">
|
||||||
|
Image fit
|
||||||
|
<select v-model="draft.fit">
|
||||||
|
<option v-for="f in FITS" :key="f.id" :value="f.id">{{ f.label }}</option>
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<button type="submit" class="bar-btn" :disabled="busy">Save</button>
|
||||||
|
<button type="button" class="bar-btn" @click="emit('close')">Cancel</button>
|
||||||
|
<button v-if="saved" type="button" class="bar-btn" :disabled="busy" @click="resetToDefault">
|
||||||
|
Theme default
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<p v-if="error" class="text-tertiary">{{ error }}</p>
|
||||||
|
</form>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.bg-editor {
|
||||||
|
position: fixed;
|
||||||
|
top: 80px;
|
||||||
|
left: 16px;
|
||||||
|
z-index: 65;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 0.5rem;
|
||||||
|
width: min(380px, calc(100vw - 32px));
|
||||||
|
padding: 0.75rem;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
.bg-editor.drag-over {
|
||||||
|
outline: 3px dashed var(--color-primary);
|
||||||
|
}
|
||||||
|
h3 {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
label {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 2px;
|
||||||
|
color: var(--color-muted);
|
||||||
|
}
|
||||||
|
.row {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.4rem;
|
||||||
|
}
|
||||||
|
input[type="color"] {
|
||||||
|
width: 2.5rem;
|
||||||
|
height: 2.2rem;
|
||||||
|
padding: 0;
|
||||||
|
border: 1px solid var(--color-quaternary);
|
||||||
|
background: none;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
select {
|
||||||
|
padding: 0.4rem;
|
||||||
|
color: var(--color-primary);
|
||||||
|
background: var(--color-surface-deep);
|
||||||
|
border: 1px solid var(--color-primary);
|
||||||
|
}
|
||||||
|
.thumb {
|
||||||
|
max-height: 100px;
|
||||||
|
max-width: 100%;
|
||||||
|
align-self: flex-start;
|
||||||
|
border: 1px solid var(--color-quaternary);
|
||||||
|
}
|
||||||
|
.hint {
|
||||||
|
color: var(--color-muted);
|
||||||
|
font-size: 0.85rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bar-btn {
|
||||||
|
padding: 0.25rem 0.75rem;
|
||||||
|
color: var(--color-primary);
|
||||||
|
background: var(--color-link-bg);
|
||||||
|
border: 2px solid var(--color-quaternary);
|
||||||
|
font-family: var(--font-heading);
|
||||||
|
font-size: 1.1rem;
|
||||||
|
letter-spacing: 0.025em;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
.bar-btn:hover {
|
||||||
|
border-color: var(--color-primary);
|
||||||
|
}
|
||||||
|
.bar-btn:disabled {
|
||||||
|
opacity: 0.5;
|
||||||
|
}
|
||||||
|
.bar-btn.small {
|
||||||
|
padding: 0.1rem 0.5rem;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
}
|
||||||
|
/* The label is the button; the file input inside it is hidden. */
|
||||||
|
.bar-btn.upload {
|
||||||
|
display: inline-block;
|
||||||
|
flex-direction: row;
|
||||||
|
color: var(--color-primary);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -21,11 +21,17 @@
|
|||||||
* marked adminOnly are never sent to anyone else (the server filters them);
|
* marked adminOnly are never sent to anyone else (the server filters them);
|
||||||
* admins see them outlined. Image and video files dropped onto the canvas in
|
* admins see them outlined. Image and video files dropped onto the canvas in
|
||||||
* edit mode are uploaded and each becomes a box where it was dropped.
|
* edit mode are uploaded and each becomes a box where it was dropped.
|
||||||
|
*
|
||||||
|
* The canvas also owns its page's background (stores/background.js), which
|
||||||
|
* DefaultLayout paints behind the whole window while the canvas is mounted;
|
||||||
|
* admins change it with the Background button.
|
||||||
*/
|
*/
|
||||||
import { computed, onBeforeUnmount, onMounted, ref, watch } from "vue";
|
import { computed, onBeforeUnmount, onMounted, ref, watch } from "vue";
|
||||||
import { useMediaQuery } from "@vueuse/core";
|
import { useMediaQuery } from "@vueuse/core";
|
||||||
import { useAuthStore } from "@/stores/auth";
|
import { useAuthStore } from "@/stores/auth";
|
||||||
import { useBoxesStore } from "@/stores/boxes";
|
import { useBoxesStore } from "@/stores/boxes";
|
||||||
|
import { useBackgroundStore } from "@/stores/background";
|
||||||
|
import BackgroundEditor from "./BackgroundEditor.vue";
|
||||||
import BoxFrame from "./BoxFrame.vue";
|
import BoxFrame from "./BoxFrame.vue";
|
||||||
import BoxEditor from "./BoxEditor.vue";
|
import BoxEditor from "./BoxEditor.vue";
|
||||||
import HtmlBox from "./HtmlBox.vue";
|
import HtmlBox from "./HtmlBox.vue";
|
||||||
@@ -54,10 +60,19 @@ auth.ensureLoaded();
|
|||||||
|
|
||||||
store.fetch();
|
store.fetch();
|
||||||
|
|
||||||
|
const background = useBackgroundStore();
|
||||||
|
background.show(props.page);
|
||||||
|
onBeforeUnmount(() => background.hide(props.page));
|
||||||
|
const backgroundOpen = ref(false);
|
||||||
|
|
||||||
const isMobile = useMediaQuery(MOBILE_QUERY);
|
const isMobile = useMediaQuery(MOBILE_QUERY);
|
||||||
const isAdmin = computed(() => auth.loggedIn && !!auth.user.admin);
|
const isAdmin = computed(() => auth.loggedIn && !!auth.user.admin);
|
||||||
// adminOnly boxes come and go with the session.
|
// adminOnly boxes come and go with the session, and so does an adminOnly
|
||||||
watch(isAdmin, () => store.fetch());
|
// page's background.
|
||||||
|
watch(isAdmin, () => {
|
||||||
|
store.fetch();
|
||||||
|
background.load(props.page);
|
||||||
|
});
|
||||||
|
|
||||||
const editing = ref(false);
|
const editing = ref(false);
|
||||||
const canEdit = computed(() => isAdmin.value && !isMobile.value);
|
const canEdit = computed(() => isAdmin.value && !isMobile.value);
|
||||||
@@ -284,6 +299,9 @@ function toggleEdit() {
|
|||||||
<button type="button" class="bar-btn" :class="{ on: editing }" @click="toggleEdit">
|
<button type="button" class="bar-btn" :class="{ on: editing }" @click="toggleEdit">
|
||||||
{{ editing ? "Done" : "Edit layout" }}
|
{{ editing ? "Done" : "Edit layout" }}
|
||||||
</button>
|
</button>
|
||||||
|
<button type="button" class="bar-btn" :class="{ on: backgroundOpen }" @click="backgroundOpen = !backgroundOpen">
|
||||||
|
Background
|
||||||
|
</button>
|
||||||
<template v-if="inEditMode">
|
<template v-if="inEditMode">
|
||||||
<select v-model="newChoice" class="bar-btn" @change="addBox">
|
<select v-model="newChoice" class="bar-btn" @change="addBox">
|
||||||
<option value="" disabled>+ New box…</option>
|
<option value="" disabled>+ New box…</option>
|
||||||
@@ -369,6 +387,8 @@ function toggleEdit() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<BackgroundEditor v-if="backgroundOpen && canEdit" :page="page" @close="backgroundOpen = false" />
|
||||||
|
|
||||||
<BoxEditor
|
<BoxEditor
|
||||||
v-if="inEditMode && selected"
|
v-if="inEditMode && selected"
|
||||||
ref="editor"
|
ref="editor"
|
||||||
|
|||||||
Reference in New Issue
Block a user