model

package
v0.0.0-...-922e9af Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 22, 2019 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package model contains shared entities Part of `wedit` project (https://wedit.io) (https://github.com/sofmon/wedit) Use of this source code is governed by MIT license that can be found in the LICENSE file.

Package model contains shared entities Part of `wedit` project (https://wedit.io) (https://github.com/sofmon/wedit) Use of this source code is governed by MIT license that can be found in the LICENSE file.

Package model contains shared entities Part of `wedit` project (https://wedit.io) (https://github.com/sofmon/wedit) Use of this source code is governed by MIT license that can be found in the LICENSE file.

Package model contains shared entities Part of `wedit` project (https://wedit.io) (https://github.com/sofmon/wedit) Use of this source code is governed by MIT license that can be found in the LICENSE file.

Package model contains shared entities Part of `wedit` project (https://wedit.io) (https://github.com/sofmon/wedit) Use of this source code is governed by MIT license that can be found in the LICENSE file.

Package model contains shared entities Part of `wedit` project (https://wedit.io) (https://github.com/sofmon/wedit) Use of this source code is governed by MIT license that can be found in the LICENSE file.

Package model contains shared entities Part of `wedit` project (https://wedit.io) (https://github.com/sofmon/wedit) Use of this source code is governed by MIT license that can be found in the LICENSE file.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

type Command struct {
	Name  string `json:"n"`
	Color string `json:"c"`
}

Command available for the user

type Element

type Element struct {
	Key  Key    `json:"k"`
	Text string `json:"t"`
}

Element represents an html element on a page

type Image

type Image struct {
	Key          Key       `json:"k"`
	Type         string    `json:"t"`
	Width        []int     `json:"w"`
	PixelDencity []float64 `json:"x"`
}

Image represents an image on a page

func NewImage

func NewImage(key Key, fileType string, srcset string) (img Image)

NewImage from key and srcset Uploaded images has name derivered from the key

func (Image) FileName

func (img Image) FileName() string

FileName for the image source without descriptors

func (Image) FileNameMin

func (img Image) FileNameMin() string

FileNameMin for the image source as the smallest image

func (Image) FileNameW

func (img Image) FileNameW(w int) string

FileNameW for the image source with width descriptors

func (Image) FileNameX

func (img Image) FileNameX(pd float64) string

FileNameX for the image source with pixel density descriptors

func (Image) IsSet

func (img Image) IsSet() bool

IsSet through content editing or is default value

func (Image) Srcset

func (img Image) Srcset() string

Srcset for the image srcset attribute

type Key

type Key string

Key for wedit element

func (Key) IsGlobal

func (k Key) IsGlobal() bool

IsGlobal indicate if key is global for the whole site

type Page

type Page struct {
	Title    string       `json:"t"`
	Repeats  PageRepeats  `json:"r"`
	Elements PageElements `json:"e"`
	Images   PageImages   `json:"i"`
}

Page represents an html page

func NewEmptyPage

func NewEmptyPage() Page

NewEmptyPage creates a new empty page

type PageElements

type PageElements map[Key]Element

PageElements is map[Key]Element that serializes as list

func (PageElements) MarshalJSON

func (x PageElements) MarshalJSON() ([]byte, error)

MarshalJSON converts a map to a json list

func (*PageElements) UnmarshalJSON

func (x *PageElements) UnmarshalJSON(data []byte) (err error)

UnmarshalJSON converts a json list to a

type PageImages

type PageImages map[Key]Image

PageImages is map[Key]Image that serializes as list

func (PageImages) MarshalJSON

func (x PageImages) MarshalJSON() ([]byte, error)

MarshalJSON converts a map to a json list

func (*PageImages) UnmarshalJSON

func (x *PageImages) UnmarshalJSON(data []byte) (err error)

UnmarshalJSON converts a json list to a

type PageRepeats

type PageRepeats map[Key]Repeat

PageRepeats is map[Key]Repeat that serializes as list

func (PageRepeats) MarshalJSON

func (x PageRepeats) MarshalJSON() ([]byte, error)

MarshalJSON converts a map to a json list

func (*PageRepeats) UnmarshalJSON

func (x *PageRepeats) UnmarshalJSON(data []byte) (err error)

UnmarshalJSON converts a json list to a

type PageWithSettings

type PageWithSettings struct {
	Page
	Settings Settings `json:"s"`
}

PageWithSettings is used to transmit page and global settings

type Repeat

type Repeat struct {
	Key      Key   `json:"k"`
	CopyKeys []Key `json:"c"`
}

Repeat represents a repeatable element on a page

type Settings

type Settings struct {
	EditAttribute   string    `json:"e"`
	RepeatAttribute string    `json:"r"`
	MenuTextColor   string    `json:"m"`
	Commands        []Command `json:"c"`
	DarkMode        bool      `json:"d"`
}

Settings for the wedit page

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL