pages

package
v1.6.7 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2024 License: GPL-2.0 Imports: 51 Imported by: 0

Documentation

Overview

templ: version: v0.2.707

Index

Constants

View Source
const (
	AdminPagesAppName   = "pages"
	AdminPagesModelPath = "Page"
)
View Source
const (
	ErrPathLengthTooShort errs.Error = "path is too short"
	ErrPathLengthExceeded errs.Error = "path length exceeded"
	ErrInvalidPathLength  errs.Error = "invalid path length"
	ErrTooLittleAncestors errs.Error = "too little ancestors provided"
	ErrTooManyAncestors   errs.Error = "too many ancestors provided"
	ErrContentTypeInvalid errs.Error = "content type is invalid"
	ErrPageIsRoot         errs.Error = "page is root"
)
View Source
const (
	STEP_LEN = 3
	ALPHABET = "0123456789"
)

Variables

View Source
var (
	SignalRootCreated      = signalRegistry.Get("pages.root_page_created")  // Node is the root node, PageID is zero.
	SignalChildCreated     = signalRegistry.Get("pages.child_page_created") // Node is the child being created, PageID is the parent node's ID.
	SignalNodeUpdated      = signalRegistry.Get("pages.node_updated")       // Node is the node being updated, PageID is the parent node's ID.
	SignalNodeBeforeDelete = signalRegistry.Get("pages.node_before_delete") // Node is the node being deleted, PageID is the parent node's ID.

	SignalNodeMoved = signalMoveRegistry.Get("pages.node_moved") // Node is the node being moved, Parent is the new parent, OldParent is the old parent.
)
View Source
var QuerySet func() models.DBQuerier

Will get set by django_app.go.(NewAppConfig)

Functions

func AncestorNodes

func AncestorNodes(q models.Querier, ctx context.Context, p string, depth int) ([]models.PageNode, error)

func CountNodesByType added in v1.6.6

func CountNodesByType(q models.Querier, ctx context.Context, contentType string) (int64, error)

func CreateChildNode

func CreateChildNode(q models.DBQuerier, ctx context.Context, parent, child *models.PageNode) error

func CreateRootNode

func CreateRootNode(q models.Querier, ctx context.Context, node *models.PageNode) error

func CreateTable

func CreateTable(db *sql.DB) error

func DeleteNode

func DeleteNode(q models.DBQuerier, ctx context.Context, id int64, path string, depth int64) error

func DeletePage

func DeletePage(q models.DBQuerier, ctx context.Context, p DeletablePage) (err error)

func FixTree

func FixTree(querySet models.DBQuerier, ctx context.Context) error

func MoveNode

func MoveNode(q models.DBQuerier, ctx context.Context, node *models.PageNode, newParent *models.PageNode) error

func ParentNode

func ParentNode(q models.Querier, ctx context.Context, path string, depth int) (v models.PageNode, err error)

func PrepareQuerySet

func PrepareQuerySet(ctx context.Context, db *sql.DB) (models.DBQuerier, error)

func PrintTree

func PrintTree(node *Node, depth int)

func PublishNode

func PublishNode(q models.Querier, ctx context.Context, node *models.PageNode) error

func Register

func Register(definition *PageDefinition)

func SavePage

func SavePage(q models.DBQuerier, ctx context.Context, parent *models.PageNode, p SaveablePage) error

func Serve

func Serve(allowedMethods ...string) http.Handler

func SetPrefix

func SetPrefix(prefix string)

func UnpublishNode

func UnpublishNode(q models.DBQuerier, ctx context.Context, node *models.PageNode, unpublishChildren bool) error

func UpdateNode

func UpdateNode(q models.Querier, ctx context.Context, node *models.PageNode) error

func UpdatePage

func UpdatePage(q models.DBQuerier, ctx context.Context, p SaveablePage) error

Types

type BaseSignal

type BaseSignal struct {
	// Querier is the Querier used to perform the operation.
	//
	// This can be used to perform additional queries or operations
	Querier models.Querier

	// Ctx stores the context used to perform the operation.
	Ctx context.Context
}

type DeletablePage

type DeletablePage interface {
	Page
	Delete(ctx context.Context) error
}

type ItemsList

type ItemsList []models.PageNode

func (ItemsList) MarshalJSON

func (il ItemsList) MarshalJSON() ([]byte, error)
type MenuHeader struct {
	Text string `json:"text"`
	URL  string `json:"url"`
}

type Node

type Node struct {
	Ref      *models.PageNode
	Children *orderedmap.OrderedMap[string, *Node]
}

func NewNodeTree

func NewNodeTree(refs []*models.PageNode) *Node

func (*Node) FindNode

func (n *Node) FindNode(path string) *Node

func (*Node) FixTree

func (n *Node) FixTree()

func (*Node) FlatList

func (n *Node) FlatList() []*models.PageNode

func (*Node) ForEach

func (n *Node) ForEach(fn func(*Node, int64) (cancel bool)) (cancelled bool)

type Page

type Page interface {
	ID() int64
	Reference() *models.PageNode
}

func Specific

func Specific(ctx context.Context, node models.PageNode) (Page, error)

type PageAppConfig

type PageAppConfig struct {
	*apps.DBRequiredAppConfig
	// contains filtered or unexported fields
}

func App

func App() *PageAppConfig

func NewAppConfig

func NewAppConfig() *PageAppConfig

func (*PageAppConfig) QuerySet

func (p *PageAppConfig) QuerySet() models.DBQuerier

type PageBaseKeyGetter

type PageBaseKeyGetter interface {
	GetBaseKey(req *http.Request, page Page) string
}

type PageContextGetter

type PageContextGetter interface {
	GetContext(req *http.Request, page Page) (ctx.Context, error)
}

type PageDefinition

type PageDefinition struct {
	*contenttypes.ContentTypeDefinition
	ServePage               func() PageView
	AddPanels               func(r *http.Request, page Page) []admin.Panel
	EditPanels              func(r *http.Request, page Page) []admin.Panel
	GetForID                func(ctx context.Context, ref models.PageNode, id int64) (Page, error)
	OnReferenceUpdate       func(ctx context.Context, ref models.PageNode, id int64) error
	OnReferenceBeforeDelete func(ctx context.Context, ref models.PageNode, id int64) error

	MaxNum          int
	DissalowCreate  bool
	DisallowRoot    bool
	ParentPageTypes []string
	ChildPageTypes  []string
	// contains filtered or unexported fields
}

func DefinitionForObject

func DefinitionForObject(page Page) *PageDefinition

func DefinitionForType

func DefinitionForType(typeName string) *PageDefinition

func FilterCreatableDefinitions added in v1.6.6

func FilterCreatableDefinitions(definitions []*PageDefinition) []*PageDefinition

func ListDefinitions

func ListDefinitions() []*PageDefinition

func ListDefinitionsForType added in v1.6.6

func ListDefinitionsForType(typeName string) []*PageDefinition

func ListRootDefinitions added in v1.6.6

func ListRootDefinitions() []*PageDefinition

func (*PageDefinition) AppLabel

func (p *PageDefinition) AppLabel() string

func (*PageDefinition) ContentType

func (p *PageDefinition) ContentType() contenttypes.ContentType

func (*PageDefinition) Description

func (p *PageDefinition) Description() string

func (*PageDefinition) Label

func (p *PageDefinition) Label() string

func (*PageDefinition) Model

func (p *PageDefinition) Model() string

func (*PageDefinition) PageView

func (p *PageDefinition) PageView() PageView

type PageMovedSignal

type PageMovedSignal struct {
	BaseSignal

	// The node being moved.
	Node *models.PageNode

	// All nodes that are being moved.
	Nodes []*models.PageNode

	// The new parent node.
	NewParent *models.PageNode

	// The old parent node.
	OldParent *models.PageNode
}

type PageNodeSignal

type PageNodeSignal struct {
	BaseSignal

	// The current node, a child node or parent node depending on the signal.
	Node *models.PageNode

	// The current page ID, the parent page ID or a child's page ID depending on the signal.
	PageID int64
}

type PageRenderView

type PageRenderView interface {
	Render(w http.ResponseWriter, req *http.Request, page Page, context ctx.Context) error
}

type PageServeView

type PageServeView struct{}

Register to the page definition.

func (*PageServeView) ServeXXX

func (v *PageServeView) ServeXXX(w http.ResponseWriter, req *http.Request)

func (*PageServeView) TakeControl

func (v *PageServeView) TakeControl(w http.ResponseWriter, req *http.Request)

type PageSignal

type PageSignal struct {
	BaseSignal
	Page Page
}

type PageTemplateGetter

type PageTemplateGetter interface {
	GetTemplate(req *http.Request, page Page) string
}

type PageTemplateRenderView

type PageTemplateRenderView interface {
	PageTemplateView
	Render(w http.ResponseWriter, req *http.Request, template string, page Page, context ctx.Context) error
}

type PageTemplateView

type PageTemplateView interface {
	PageContextGetter
	PageTemplateGetter
}

type PageView

type PageView interface {
	// ServePage is a method that will never get called.
	// It acts like the views.ServeXXX method.
	ServePage()
}

type PageViewHandler

type PageViewHandler interface {
	views.MethodsView
	views.ControlledView
	View() PageView
	CurrentPage() Page
}

A wrapper interface to get the same dynamic functionality as the views.View interface.

This handles "PageView" objects much like the views.Invoke method.

type PagesMenuItem

type PagesMenuItem struct {
	menu.BaseItem
}

func (*PagesMenuItem) Component

func (p *PagesMenuItem) Component() templ.Component

type Querier

type Querier struct {
	models.Querier
	Db *sql.DB
}

func (*Querier) BeginTx

func (q *Querier) BeginTx(ctx context.Context, opts *sql.TxOptions) (*sql.Tx, error)

func (*Querier) DB

func (q *Querier) DB() *sql.DB

type SaveablePage

type SaveablePage interface {
	Page
	Save(ctx context.Context) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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