Documentation
¶
Overview ¶
templ: version: v0.3.1020
templ: version: v0.3.1020
Index ¶
- Constants
- Variables
- func FixTree(ctx context.Context) error
- func IsPreviewContext(ctx context.Context) bool
- func NewAppConfig() django.AppConfig
- func PageEditForm(r *http.Request, instance Page) *admin.AdminForm[*modelforms.BaseModelForm[attrs.Definer], attrs.Definer]
- func PageServeView(w http.ResponseWriter, r *http.Request)
- func PrintTree(node *Node, depth int)
- func Register(definition *PageDefinition)
- func Serve(allowedMethods ...string) http.Handler
- func SetRoutePrefix(prefix string)
- func URLPath(page Page) string
- type BaseSignal
- type GenericBoundPreview
- func (v *GenericBoundPreview[T]) BuildPreviewRequest(r *http.Request, instance attrs.Definer) (*http.Request, error)
- func (v *GenericBoundPreview[T]) DeletePreviewData(r *http.Request) error
- func (v *GenericBoundPreview[T]) GetForm(r *http.Request, instance attrs.Definer, oldData url.Values) (forms.Form, error)
- func (v *GenericBoundPreview[T]) GetObject(r *http.Request) (attrs.Definer, error)
- func (v *GenericBoundPreview[T]) GetPreviewData(r *http.Request) (url.Values, error)
- func (v *GenericBoundPreview[T]) MakePreviewRequest(w http.ResponseWriter, original *http.Request, previewReq *http.Request, ...)
- func (v *GenericBoundPreview[T]) RemoveOldPreviewData(r *http.Request) error
- func (v *GenericBoundPreview[T]) ServeXXX(w http.ResponseWriter, r *http.Request)
- func (v *GenericBoundPreview[T]) SetPreviewData(r *http.Request, data url.Values) error
- func (v *GenericBoundPreview[T]) ValidateForm(r *http.Request, form forms.Form) error
- type GenericPreviewHandler
- func (v *GenericPreviewHandler[T]) Bind(w http.ResponseWriter, req *http.Request) (views.View, error)
- func (v *GenericPreviewHandler[T]) Methods() []string
- func (v *GenericPreviewHandler[T]) PathKey() string
- func (v *GenericPreviewHandler[T]) ServeXXX(w http.ResponseWriter, r *http.Request)
- func (v *GenericPreviewHandler[T]) SessionKey(obj attrs.Definer) string
- func (v *GenericPreviewHandler[T]) TakeControl(w http.ResponseWriter, req *http.Request, view views.View)
- type ItemsList
- type MenuHeader
- type Node
- type Page
- type PageAppConfig
- type PageBaseKeyGetter
- type PageChooserList
- type PageComponentView
- type PageContextGetter
- type PageDefinition
- func DefinitionForObject(page Page) *PageDefinition
- func DefinitionForType(typeName string) *PageDefinition
- func FilterCreatableDefinitions(definitions []*PageDefinition, otherChecks ...func(*PageDefinition) bool) []*PageDefinition
- func ListDefinitions() []*PageDefinition
- func ListDefinitionsForType(typeName string) []*PageDefinition
- func ListRootDefinitions() []*PageDefinition
- func (p *PageDefinition) AppLabel() string
- func (p *PageDefinition) ContentType() contenttypes.ContentType
- func (p *PageDefinition) Description(ctx context.Context) string
- func (p *PageDefinition) IsValidChildType(typeName string) bool
- func (p *PageDefinition) IsValidParentType(typeName string) bool
- func (p *PageDefinition) Label(ctx context.Context) string
- func (p *PageDefinition) Model() string
- func (p *PageDefinition) PageView(page Page) PageView
- type PageMovedSignal
- type PageNode
- func (n *PageNode) AddChild(ctx context.Context, child *PageNode) error
- func (n *PageNode) Ancestors(inclusive ...bool) *PageQuerySet
- func (n *PageNode) BeforeCreate(context.Context) error
- func (n *PageNode) BeforeSave(context.Context) error
- func (n *PageNode) Children() *PageQuerySet
- func (n *PageNode) ControlsEmbedderSaving() bool
- func (n *PageNode) CreateRevision(ctx context.Context, user users.User, save bool) (*revisions.Revision, error)
- func (n *PageNode) DatabaseIndexes(obj attrs.Definer) []migrator.Index
- func (n *PageNode) DeleteObject(ctx context.Context) error
- func (n *PageNode) Descendants(inclusive ...bool) *PageQuerySet
- func (n *PageNode) ExcludeFromRevisionData() []string
- func (n *PageNode) FieldDefs() attrs.Definitions
- func (n *PageNode) GetRevisionInfo(ctx context.Context) (pk any, contentType string, err error)
- func (n *PageNode) ID() int64
- func (n *PageNode) IsDeleted() bool
- func (n *PageNode) IsHidden() bool
- func (n *PageNode) IsPublished() bool
- func (n *PageNode) IsRoot() bool
- func (n *PageNode) Move(ctx context.Context, newParent *PageNode) error
- func (n *PageNode) Parent(ctx context.Context, refresh ...bool) (parent *PageNode, err error)
- func (n *PageNode) Publish(ctx context.Context) error
- func (n *PageNode) Reference() *PageNode
- func (n *PageNode) Route(r *http.Request, pathComponents []string) (Page, error)
- func (n *PageNode) SaveObject(ctx context.Context, cnf models.SaveConfig) (err error)
- func (n *PageNode) SearchableFields() []search.SearchField
- func (n *PageNode) SetSpecificPageObject(p Page)
- func (n *PageNode) SetUrlPath(parent *PageNode) (newPath, oldPath string)
- func (n *PageNode) Specific(ctx context.Context, refresh ...bool) (Page, error)
- func (n *PageNode) TargetContentTypeField() attrs.FieldDefinition
- func (n *PageNode) TargetPrimaryField() attrs.FieldDefinition
- func (n *PageNode) Unpublish(ctx context.Context, unpublishChildren bool) error
- type PageNodeSignal
- type PageQuerySet
- func (qs *PageQuerySet) AddChildren(parent *PageNode, children ...*PageNode) error
- func (qs *PageQuerySet) AddRoot(node *PageNode) error
- func (qs *PageQuerySet) AddRoots(nodes ...*PageNode) error
- func (qs *PageQuerySet) AllNodes() ([]*PageNode, error)
- func (qs *PageQuerySet) AncestorOf(node *PageNode, inclusive ...bool) *PageQuerySet
- func (qs *PageQuerySet) Ancestors(path string, depth int64, inclusive ...bool) *PageQuerySet
- func (qs *PageQuerySet) BatchCreate([]*PageNode) ([]*PageNode, error)
- func (qs *PageQuerySet) BatchUpdate(...any) (int64, error)
- func (qs *PageQuerySet) BuildSearchQuery(_ []search.BuiltSearchField, query string) (search.Searchable, error)
- func (qs *PageQuerySet) BulkCreate([]*PageNode) ([]*PageNode, error)
- func (qs *PageQuerySet) BulkUpdate(...any) (int64, error)
- func (qs *PageQuerySet) Children(path string, depth int64) *PageQuerySet
- func (qs *PageQuerySet) ChildrenOf(node *PageNode) *PageQuerySet
- func (qs *PageQuerySet) CloneQuerySet(...) *PageQuerySet
- func (qs *PageQuerySet) Create(*PageNode) (*PageNode, error)
- func (qs *PageQuerySet) Delete(nodes ...*PageNode) (int64, error)
- func (qs *PageQuerySet) DescendantOf(node *PageNode, inclusive ...bool) *PageQuerySet
- func (qs *PageQuerySet) Descendants(path string, depth int64, inclusive ...bool) *PageQuerySet
- func (qs *PageQuerySet) GetAncestors(p string, depth int64) ([]*PageNode, error)
- func (qs *PageQuerySet) GetChildNodes(node *PageNode, statusFlags StatusFlag, offset int32, limit int32) ([]*PageNode, error)
- func (qs *PageQuerySet) GetDescendants(path string, depth int64, statusFlags StatusFlag, offset int32, limit int32) ([]*PageNode, error)
- func (qs *PageQuerySet) GetNodeByID(id int64) (*PageNode, error)
- func (qs *PageQuerySet) GetNodeByPath(path string) (*PageNode, error)
- func (qs *PageQuerySet) GetNodeBySlug(slug string, depth int64, path string) (*PageNode, error)
- func (qs *PageQuerySet) GetNodesByDepth(depth int64, statusFlags StatusFlag, offset int32, limit int32) ([]*PageNode, error)
- func (qs *PageQuerySet) GetNodesByIDs(id []int64) ([]*PageNode, error)
- func (qs *PageQuerySet) MoveNode(node *PageNode, newParent *PageNode) error
- func (qs *PageQuerySet) ParentNode(path string, depth int) (v *PageNode, err error)
- func (qs *PageQuerySet) PublishNode(node *PageNode) error
- func (qs *PageQuerySet) Published() *PageQuerySet
- func (qs *PageQuerySet) RootPages() *PageQuerySet
- func (qs *PageQuerySet) Search(query string) *PageQuerySet
- func (qs *PageQuerySet) Siblings(path string, depth int64, inclusive ...bool) *PageQuerySet
- func (qs *PageQuerySet) SiblingsOf(node *PageNode, inclusive ...bool) *PageQuerySet
- func (qs *PageQuerySet) Specific() *SpecificPageQuerySet
- func (qs *PageQuerySet) StatusFlags(statusFlags StatusFlag) *PageQuerySet
- func (qs *PageQuerySet) Types(types ...any) *PageQuerySet
- func (qs *PageQuerySet) UnpublishNode(node *PageNode, unpublishChildren bool) error
- func (qs *PageQuerySet) Unpublished() *PageQuerySet
- func (qs *PageQuerySet) Update(*PageNode, ...any) (int64, error)
- func (qs *PageQuerySet) UpdateNode(node *PageNode) error
- type PageRenderView
- type PageSignal
- type PageTemplateGetter
- type PageTemplateRenderView
- type PageTemplateView
- type PageView
- type PageViewHandler
- type PagesAdminHomeComponent
- type PagesMenuItem
- type RoutablePage
- type Site
- func (n *Site) BeforeDelete(ctx context.Context) error
- func (n *Site) BeforeSave(ctx context.Context) error
- func (n *Site) DatabaseIndexes(obj attrs.Definer) []migrator.Index
- func (n *Site) FieldDefs() attrs.Definitions
- func (n *Site) Fields(d attrs.Definer) []attrs.Field
- func (n *Site) URL() string
- func (n *Site) Validate(ctx context.Context) error
- type SpecificPageQuerySet
- func (qs *SpecificPageQuerySet) AddChildren(parent Page, children ...Page) error
- func (qs *SpecificPageQuerySet) AddRoot(page Page) error
- func (qs *SpecificPageQuerySet) AddRoots(pages ...Page) error
- func (qs *SpecificPageQuerySet) All() (queries.Rows[Page], error)
- func (qs *SpecificPageQuerySet) AncestorOf(node *PageNode, inclusive ...bool) *SpecificPageQuerySet
- func (qs *SpecificPageQuerySet) ChildrenOf(node *PageNode) *SpecificPageQuerySet
- func (qs *SpecificPageQuerySet) CloneQuerySet(...) *SpecificPageQuerySet
- func (qs *SpecificPageQuerySet) DeletePage(page Page) error
- func (qs *SpecificPageQuerySet) DescendantOf(node *PageNode, inclusive ...bool) *SpecificPageQuerySet
- func (qs *SpecificPageQuerySet) First() (*queries.Row[Page], error)
- func (qs *SpecificPageQuerySet) Get() (*queries.Row[Page], error)
- func (qs *SpecificPageQuerySet) Last() (*queries.Row[Page], error)
- func (qs *SpecificPageQuerySet) MovePage(page Page, newParent Page) error
- func (qs *SpecificPageQuerySet) PublishPage(page Page) error
- func (qs *SpecificPageQuerySet) Published() *SpecificPageQuerySet
- func (qs *SpecificPageQuerySet) Search(query string) *SpecificPageQuerySet
- func (qs *SpecificPageQuerySet) SiblingsOf(node *PageNode, inclusive ...bool) *SpecificPageQuerySet
- func (qs *SpecificPageQuerySet) StatusFlags(statusFlags StatusFlag) *SpecificPageQuerySet
- func (qs *SpecificPageQuerySet) Types(types ...any) *SpecificPageQuerySet
- func (qs *SpecificPageQuerySet) UnpublishPage(page Page, unpublishChildren bool) error
- func (qs *SpecificPageQuerySet) Unpublished() *SpecificPageQuerySet
- type StatusFlag
Constants ¶
const ( AdminPagesAppName = "pages" AdminPagesModelPath = "PageNode" )
const ( // The variable name generally used to refer to the page id in the URL. // // This is used in the URL patterns for the pages app, as well as javascript code and queries in URLs. PageIDVariableName = "page_id" CHOOSER_ROOT_PAGES_KEY = "pages.nodes.root" CHOOSER_PAGE_REVISIONS_KEY = "pages.page.revisions" )
const ( ErrCodeNoPage errors.GoCode = "NoPage" ErrCodeNoPageID errors.GoCode = "NoPageID" )
const ( STEP_LEN = 3 ALPHABET = "0123456789" )
const ( APPVAR_OUTDATED_AFTER_DURATION = "pages.outdated_after_duration" // time.Duration APPVAR_OUTDATED_LIST_DISPLAY = "pages.outdated_list_display" // []string )
const DEFAULT_SITE_KEY = "default_site"
Variables ¶
var ( ErrNoPage = errors.New(ErrCodeNoPage, "pages: PageNode has no Page set") ErrNoPageID = errors.New(ErrCodeNoPageID, "pages: PageNode has no PageID set", ErrNoPage) ErrInvalidPathLength = errors.ValueError.Wrap("invalid path length") ErrTooLittleAncestors = errors.ValueError.Wrap("too little ancestors provided") ErrTooManyAncestors = errors.ValueError.Wrap("too many ancestors provided") ErrPageIsRoot = errors.ValueError.Wrap("page is root") )
var ( // A signal which is sent when a new root page is created. SignalRootCreated = signalRegistry.Get("pages.root_page_created") // Node is the root node, PageID is zero. // A signal which is sent when a new child page is created. SignalChildCreated = signalRegistry.Get("pages.child_page_created") // Node is the child being created, PageID is the parent node's ID. // A signal which is sent when a node is updated. SignalNodeUpdated = signalRegistry.Get("pages.node_updated") // Node is the node being updated, PageID is the parent node's ID. // A signal which is sent before a node is deleted. SignalNodeBeforeDelete = signalRegistry.Get("pages.node_before_delete") // Node is the node being deleted, PageID is the parent node's ID. // A signal which is sent after a node is moved. SignalNodeMoved = signalMoveRegistry.Get("pages.node_moved") // Node is the node being moved, Parent is the new parent, OldParent is the old parent. )
var ErrRouteNotFound = mux.ErrRouteNotFound
var PagePreviewHandler = &GenericPreviewHandler[Page]{ Model: &PageNode{}, SessionKeyPrefix: "page_preview_", URLKey: PageIDVariableName, Expiration: 10 * time.Minute, GetFormFunc: func(h *GenericPreviewHandler[Page], r *http.Request, instance Page, oldData url.Values) (forms.Form, error) { return PageEditForm(r, instance), nil }, ServePreview: func(h *GenericPreviewHandler[Page], w http.ResponseWriter, original, previewReq *http.Request, instance Page) { servePageView(w, previewReq, instance) }, BuildPreviewRequest: func(h *GenericPreviewHandler[Page], r *http.Request, instance Page) (*http.Request, error) { var cloned = r.Clone(context.WithValue( r.Context(), previewContextKey{}, struct{}{}, )) cloned.URL.Path = URLPath(instance) return cloned, nil }, GetObjectFunc: func(h *GenericPreviewHandler[Page], r *http.Request, pk string) (Page, error) { var objRow, err = NewPageQuerySet(). WithContext(r.Context()). Filter("PK", pk). Get() if err != nil { return nil, fmt.Errorf("failed to get page with ID %v: %w", pk, err) } specific, err := Specific(r.Context(), objRow.Object, true) if err != nil { return nil, fmt.Errorf("failed to get specific page type for page ID %v: %w", pk, err) } return specific, nil }, }
var PageRevisionPreviewHandler = &GenericPreviewHandler[Page]{ Model: &PageNode{}, SessionKeyPrefix: "page_revision_preview_", URLKey: PageIDVariableName, Expiration: 10 * time.Minute, BuildPreviewRequest: func(h *GenericPreviewHandler[Page], r *http.Request, instance Page) (*http.Request, error) { var cloned = r.Clone(context.WithValue( r.Context(), previewContextKey{}, struct{}{}, )) cloned.URL.Path = URLPath(instance) return cloned, nil }, GetFormFunc: func(h *GenericPreviewHandler[Page], r *http.Request, instance Page, oldData url.Values) (forms.Form, error) { return PageEditForm(r, instance), nil }, ServePreview: func(h *GenericPreviewHandler[Page], w http.ResponseWriter, original, previewReq *http.Request, instance Page) { servePageView(w, previewReq, instance) }, GetObjectFunc: func(h *GenericPreviewHandler[Page], r *http.Request, pk string) (Page, error) { var vars = mux.Vars(r) var revisionID = vars.GetInt("revision_id") var chosenRevision *revisions.Revision var objRow, err = NewPageQuerySet(). WithContext(r.Context()). Filter("PK", pk). Get() if err != nil { return nil, fmt.Errorf("failed to get page with ID %v: %w", pk, err) } if revisionID != 0 { chosenRevision, err = revisions.GetRevisionByID(r.Context(), int64(revisionID)) } else { chosenRevision, err = revisions.LatestRevision(r.Context(), objRow.Object) } if err != nil { return nil, fmt.Errorf("failed to get latest revision for page ID %v: %w", pk, err) } specific, err := Specific(r.Context(), objRow.Object.Reference(), true) if err != nil { return nil, fmt.Errorf("failed to get specific page type for page ID %v: %w", pk, err) } err = revisions.UnmarshalRevisionData(specific, []byte(chosenRevision.Data)) if err != nil { return nil, fmt.Errorf("failed to unmarshal latest revision data for page ID %v: %w", pk, err) } return specific, nil }, }
Functions ¶
func FixTree ¶
Fixtree fixes the tree structure of the page nodes.
It scans for errors in the tree structure in the database and fixes them.
func IsPreviewContext ¶ added in v1.7.2
func NewAppConfig ¶
NewAppConfig returns a new pages app config.
This is used to initialize the pages app, set up routes, and register the admin application.
func PageEditForm ¶ added in v1.7.2
func PageServeView ¶
func PageServeView(w http.ResponseWriter, r *http.Request)
func Register ¶
func Register(definition *PageDefinition)
Register a page definition
This is an extension of the contenttypes.ContentTypeDefinition
func SetRoutePrefix ¶ added in v1.7.0
func SetRoutePrefix(prefix string)
SetRoutePrefix sets the route prefix for the pages app.
Pages app will be served at the route prefix.
Types ¶
type BaseSignal ¶
type GenericBoundPreview ¶ added in v1.7.2
type GenericBoundPreview[T attrs.Definer] struct { Handler *GenericPreviewHandler[T] ContentType *contenttypes.ContentTypeDefinition Object T }
func (*GenericBoundPreview[T]) BuildPreviewRequest ¶ added in v1.7.2
func (*GenericBoundPreview[T]) DeletePreviewData ¶ added in v1.7.2
func (v *GenericBoundPreview[T]) DeletePreviewData(r *http.Request) error
func (*GenericBoundPreview[T]) GetPreviewData ¶ added in v1.7.2
func (*GenericBoundPreview[T]) MakePreviewRequest ¶ added in v1.7.2
func (v *GenericBoundPreview[T]) MakePreviewRequest(w http.ResponseWriter, original *http.Request, previewReq *http.Request, instance attrs.Definer)
func (*GenericBoundPreview[T]) RemoveOldPreviewData ¶ added in v1.7.2
func (v *GenericBoundPreview[T]) RemoveOldPreviewData(r *http.Request) error
func (*GenericBoundPreview[T]) ServeXXX ¶ added in v1.7.2
func (v *GenericBoundPreview[T]) ServeXXX(w http.ResponseWriter, r *http.Request)
func (*GenericBoundPreview[T]) SetPreviewData ¶ added in v1.7.2
func (*GenericBoundPreview[T]) ValidateForm ¶ added in v1.7.2
type GenericPreviewHandler ¶ added in v1.7.2
type GenericPreviewHandler[T attrs.Definer] struct { Model T URLKey string Expiration time.Duration SessionKeyPrefix string GetObjectQuerySet func(h *GenericPreviewHandler[T], r *http.Request) *queries.QuerySet[T] GetObjectFunc func(h *GenericPreviewHandler[T], r *http.Request, pk string) (T, error) GetFormFunc func(h *GenericPreviewHandler[T], r *http.Request, instance T, oldData url.Values) (forms.Form, error) BuildPreviewRequest func(h *GenericPreviewHandler[T], r *http.Request, instance T) (*http.Request, error) ServePreview func(h *GenericPreviewHandler[T], w http.ResponseWriter, original *http.Request, previewReq *http.Request, instance T) }
func (*GenericPreviewHandler[T]) Bind ¶ added in v1.7.2
func (v *GenericPreviewHandler[T]) Bind(w http.ResponseWriter, req *http.Request) (views.View, error)
func (*GenericPreviewHandler[T]) Methods ¶ added in v1.7.2
func (v *GenericPreviewHandler[T]) Methods() []string
func (*GenericPreviewHandler[T]) PathKey ¶ added in v1.7.2
func (v *GenericPreviewHandler[T]) PathKey() string
func (*GenericPreviewHandler[T]) ServeXXX ¶ added in v1.7.2
func (v *GenericPreviewHandler[T]) ServeXXX(w http.ResponseWriter, r *http.Request)
Handle embedders of GenericPreviewHandler that also implement genericPreviewView.
This ensures that the correct methods are called on the embedder if they are available.
func (*GenericPreviewHandler[T]) SessionKey ¶ added in v1.7.2
func (v *GenericPreviewHandler[T]) SessionKey(obj attrs.Definer) string
func (*GenericPreviewHandler[T]) TakeControl ¶ added in v1.7.2
func (v *GenericPreviewHandler[T]) TakeControl(w http.ResponseWriter, req *http.Request, view views.View)
type MenuHeader ¶
type Node ¶
type Node struct {
Ref *PageNode
Children *orderedmap.OrderedMap[string, *Node]
}
func NewNodeTree ¶
type Page ¶
type PageAppConfig ¶
type PageAppConfig struct {
*apps.DBRequiredAppConfig
// contains filtered or unexported fields
}
type PageBaseKeyGetter ¶
type PageChooserList ¶ added in v1.7.2
type PageChooserList struct {
*chooser.WrappedModel[*PageNode]
Models []*chooser.WrappedModel[*PageNode]
}
type PageComponentView ¶ added in v1.7.2
type PageContextGetter ¶
type PageDefinition ¶
type PageDefinition struct {
// The underlying content type definition for the blog page model
*contenttypes.ContentTypeDefinition
// Serve the page with this view instead
ServePage func(page Page) PageView
// Panels for the model when creating a new page
//
// This contains fields from the custom model, as well as the underlying page node model.
AddPanels func(r *http.Request, page Page) []admin.Panel
// Panels for the model when editing a page
//
// This contains fields from the custom model, as well as the underlying page node model.
EditPanels func(r *http.Request, page Page) []admin.Panel
// Query for an instance of this model by its ID
GetForID func(ctx context.Context, ref *PageNode, id int64) (Page, error)
// Callback function to be called when a reference node is updated
OnReferenceUpdate func(ctx context.Context, ref *PageNode, id int64) error
// Callback function to be called before a reference node is deleted
OnReferenceBeforeDelete func(ctx context.Context, ref *PageNode, id int64) error
// Prefetches to use when calling Specific on a page.
Prefetch admin.Prefetch
// Disallow creation of this model through the admin interface
DisallowCreate bool
// Disallow this page type to be a root page (i.e. it must have a parent)
DisallowRoot bool
// IsValidChild checks if the given page type is allowed as a child of this page type
IsValidChild func(parent Page) (bool, error)
// IsValidParent checks if the given page type is allowed as a parent of this page type
IsValidParent func(child Page) (bool, error)
// Allowed parent page types for this model
//
// This is a list of content type strings that this model can be a child of.
ParentPageTypes []string
// Allowed child page types for this model
//
// This is a list of content type strings that this model can be a parent of.
ChildPageTypes []string
// contains filtered or unexported fields
}
func DefinitionForObject ¶
func DefinitionForObject(page Page) *PageDefinition
Return the content type definition for the given page object
func DefinitionForType ¶
func DefinitionForType(typeName string) *PageDefinition
Return the content type definition for the given page type
func FilterCreatableDefinitions ¶ added in v1.6.6
func FilterCreatableDefinitions(definitions []*PageDefinition, otherChecks ...func(*PageDefinition) bool) []*PageDefinition
func ListDefinitions ¶
func ListDefinitions() []*PageDefinition
Returns a list of all registered page definitions
func ListDefinitionsForType ¶ added in v1.6.6
func ListDefinitionsForType(typeName string) []*PageDefinition
Returns a list of all registered page definitions for the given type
func ListRootDefinitions ¶ added in v1.6.6
func ListRootDefinitions() []*PageDefinition
Returns a list of all registered root page definitions
func (*PageDefinition) AppLabel ¶
func (p *PageDefinition) AppLabel() string
func (*PageDefinition) ContentType ¶
func (p *PageDefinition) ContentType() contenttypes.ContentType
func (*PageDefinition) Description ¶
func (p *PageDefinition) Description(ctx context.Context) string
func (*PageDefinition) IsValidChildType ¶ added in v1.7.2
func (p *PageDefinition) IsValidChildType(typeName string) bool
func (*PageDefinition) IsValidParentType ¶ added in v1.7.2
func (p *PageDefinition) IsValidParentType(typeName string) bool
func (*PageDefinition) Model ¶
func (p *PageDefinition) Model() string
func (*PageDefinition) PageView ¶
func (p *PageDefinition) PageView(page Page) PageView
type PageMovedSignal ¶
type PageMovedSignal struct {
BaseSignal
// The node being moved.
Node *PageNode
// All nodes that are being moved.
Nodes []*PageNode
// The new parent node.
NewParent *PageNode
// The old parent node.
OldParent *PageNode
}
type PageNode ¶ added in v1.7.2
type PageNode struct {
models.Model `table:"PageNode"`
PK int64 `json:"id" attrs:"primary;readonly;column=id"`
Title string `json:"title"`
Path string `json:"path" attrs:"blank"`
Depth int64 `json:"depth" attrs:"blank"`
Numchild int64 `json:"numchild" attrs:"blank"`
UrlPath string `json:"url_path" attrs:"readonly;blank"`
Slug string `json:"slug"`
StatusFlags StatusFlag `json:"status_flags" attrs:"null;blank"`
PageID int64 `json:"page_id" attrs:"null;blank"`
ContentType string `json:"content_type" attrs:"null;blank"`
PublishedAt time.Time `json:"published_at" attrs:"null;blank"`
LatestRevisionCreatedAt time.Time `json:"latest_revision_created_at" attrs:"readonly;label=Latest Revision Created At"`
CreatedAt time.Time `json:"created_at" attrs:"readonly;label=Created At"`
UpdatedAt time.Time `json:"updated_at" attrs:"readonly;label=Updated At"`
// PageObject is the specific page object associated with this node.
//
// It is used to cache the specific page object for performance optimization.
//
// It is also used to save the specific page object when the node is saved.
PageObject Page `json:"-" attrs:"-"`
// contains filtered or unexported fields
}
func (*PageNode) Ancestors ¶ added in v1.7.2
func (n *PageNode) Ancestors(inclusive ...bool) *PageQuerySet
func (*PageNode) BeforeCreate ¶ added in v1.7.2
func (*PageNode) Children ¶ added in v1.7.2
func (n *PageNode) Children() *PageQuerySet
func (*PageNode) ControlsEmbedderSaving ¶ added in v1.7.2
func (*PageNode) CreateRevision ¶ added in v1.7.2
func (*PageNode) DatabaseIndexes ¶ added in v1.7.2
func (*PageNode) DeleteObject ¶ added in v1.7.2
func (*PageNode) Descendants ¶ added in v1.7.2
func (n *PageNode) Descendants(inclusive ...bool) *PageQuerySet
func (*PageNode) ExcludeFromRevisionData ¶ added in v1.7.2
func (*PageNode) FieldDefs ¶ added in v1.7.2
func (n *PageNode) FieldDefs() attrs.Definitions
func (*PageNode) GetRevisionInfo ¶ added in v1.7.2
func (*PageNode) IsPublished ¶ added in v1.7.2
func (*PageNode) SaveObject ¶ added in v1.7.2
func (*PageNode) SearchableFields ¶ added in v1.7.2
func (n *PageNode) SearchableFields() []search.SearchField
func (*PageNode) SetSpecificPageObject ¶ added in v1.7.2
func (*PageNode) SetUrlPath ¶ added in v1.7.2
func (*PageNode) TargetContentTypeField ¶ added in v1.7.2
func (n *PageNode) TargetContentTypeField() attrs.FieldDefinition
func (*PageNode) TargetPrimaryField ¶ added in v1.7.2
func (n *PageNode) TargetPrimaryField() attrs.FieldDefinition
type PageNodeSignal ¶
type PageNodeSignal struct {
BaseSignal
// The current node, a child node or parent node depending on the signal.
Node *PageNode
Nodes []*PageNode
// The current page ID, the parent page ID or a child's page ID depending on the signal.
PageID int64
}
type PageQuerySet ¶ added in v1.7.2
type PageQuerySet struct {
*queries.WrappedQuerySet[*PageNode, *PageQuerySet, *queries.QuerySet[*PageNode]]
}
func NewPageQuerySet ¶ added in v1.7.2
func NewPageQuerySet() *PageQuerySet
func (*PageQuerySet) AddChildren ¶ added in v1.7.2
func (qs *PageQuerySet) AddChildren(parent *PageNode, children ...*PageNode) error
CreateChildNode creates a new child node.
The parent node path must not be empty.
The child node path must be empty.
The child node title must not be empty, if not provided the page's slug (and thus URLPath) will be based on the page's title.
The child node path is set to a new path part based on the number of children of the parent node.
func (*PageQuerySet) AddRoot ¶ added in v1.7.2
func (qs *PageQuerySet) AddRoot(node *PageNode) error
AddRoot creates a new root node.
For more information, see PageQuerySet.AddRoots.
func (*PageQuerySet) AddRoots ¶ added in v1.7.2
func (qs *PageQuerySet) AddRoots(nodes ...*PageNode) error
AddRoots creates new root nodes.
The following conditions **must** be met for each node: - The node path must be empty. - The node title must not be empty. - The node title must not be empty, if not provided the page's slug (and thus URLPath) will be based on the page's title.
func (*PageQuerySet) AllNodes ¶ added in v1.7.2
func (qs *PageQuerySet) AllNodes() ([]*PageNode, error)
func (*PageQuerySet) AncestorOf ¶ added in v1.7.2
func (qs *PageQuerySet) AncestorOf(node *PageNode, inclusive ...bool) *PageQuerySet
func (*PageQuerySet) Ancestors ¶ added in v1.7.2
func (qs *PageQuerySet) Ancestors(path string, depth int64, inclusive ...bool) *PageQuerySet
func (*PageQuerySet) BatchCreate ¶ added in v1.7.2
func (qs *PageQuerySet) BatchCreate([]*PageNode) ([]*PageNode, error)
func (*PageQuerySet) BatchUpdate ¶ added in v1.7.2
func (qs *PageQuerySet) BatchUpdate(...any) (int64, error)
func (*PageQuerySet) BuildSearchQuery ¶ added in v1.7.2
func (qs *PageQuerySet) BuildSearchQuery(_ []search.BuiltSearchField, query string) (search.Searchable, error)
func (*PageQuerySet) BulkCreate ¶ added in v1.7.2
func (qs *PageQuerySet) BulkCreate([]*PageNode) ([]*PageNode, error)
func (*PageQuerySet) BulkUpdate ¶ added in v1.7.2
func (qs *PageQuerySet) BulkUpdate(...any) (int64, error)
func (*PageQuerySet) Children ¶ added in v1.7.2
func (qs *PageQuerySet) Children(path string, depth int64) *PageQuerySet
func (*PageQuerySet) ChildrenOf ¶ added in v1.7.2
func (qs *PageQuerySet) ChildrenOf(node *PageNode) *PageQuerySet
func (*PageQuerySet) CloneQuerySet ¶ added in v1.7.2
func (qs *PageQuerySet) CloneQuerySet(wrapped *queries.WrappedQuerySet[*PageNode, *PageQuerySet, *queries.QuerySet[*PageNode]]) *PageQuerySet
func (*PageQuerySet) Create ¶ added in v1.7.2
func (qs *PageQuerySet) Create(*PageNode) (*PageNode, error)
func (*PageQuerySet) Delete ¶ added in v1.7.2
func (qs *PageQuerySet) Delete(nodes ...*PageNode) (int64, error)
func (*PageQuerySet) DescendantOf ¶ added in v1.7.2
func (qs *PageQuerySet) DescendantOf(node *PageNode, inclusive ...bool) *PageQuerySet
func (*PageQuerySet) Descendants ¶ added in v1.7.2
func (qs *PageQuerySet) Descendants(path string, depth int64, inclusive ...bool) *PageQuerySet
func (*PageQuerySet) GetAncestors ¶ added in v1.7.2
func (qs *PageQuerySet) GetAncestors(p string, depth int64) ([]*PageNode, error)
AncestorNodes returns the ancestor nodes of the given node.
The path is a PageNode.Path, the depth is the depth of the page.
func (*PageQuerySet) GetChildNodes ¶ added in v1.7.2
func (qs *PageQuerySet) GetChildNodes(node *PageNode, statusFlags StatusFlag, offset int32, limit int32) ([]*PageNode, error)
func (*PageQuerySet) GetDescendants ¶ added in v1.7.2
func (qs *PageQuerySet) GetDescendants(path string, depth int64, statusFlags StatusFlag, offset int32, limit int32) ([]*PageNode, error)
func (*PageQuerySet) GetNodeByID ¶ added in v1.7.2
func (qs *PageQuerySet) GetNodeByID(id int64) (*PageNode, error)
func (*PageQuerySet) GetNodeByPath ¶ added in v1.7.2
func (qs *PageQuerySet) GetNodeByPath(path string) (*PageNode, error)
func (*PageQuerySet) GetNodeBySlug ¶ added in v1.7.2
func (*PageQuerySet) GetNodesByDepth ¶ added in v1.7.2
func (qs *PageQuerySet) GetNodesByDepth(depth int64, statusFlags StatusFlag, offset int32, limit int32) ([]*PageNode, error)
func (*PageQuerySet) GetNodesByIDs ¶ added in v1.7.2
func (qs *PageQuerySet) GetNodesByIDs(id []int64) ([]*PageNode, error)
func (*PageQuerySet) MoveNode ¶ added in v1.7.2
func (qs *PageQuerySet) MoveNode(node *PageNode, newParent *PageNode) error
MoveNode moves a node to a new parent.
The node and new parent paths must not be empty or equal.
The new parent must not be a descendant of the node.
This function will update the url paths of all descendants, as well as the tree paths of the node and its descendants.
func (*PageQuerySet) ParentNode ¶ added in v1.7.2
func (qs *PageQuerySet) ParentNode(path string, depth int) (v *PageNode, err error)
ParentNode returns the parent node of the given node.
func (*PageQuerySet) PublishNode ¶ added in v1.7.2
func (qs *PageQuerySet) PublishNode(node *PageNode) error
PublishNode will set the published flag on the node and update it accordingly in the database.
func (*PageQuerySet) Published ¶ added in v1.7.2
func (qs *PageQuerySet) Published() *PageQuerySet
func (*PageQuerySet) RootPages ¶ added in v1.7.2
func (qs *PageQuerySet) RootPages() *PageQuerySet
func (*PageQuerySet) Search ¶ added in v1.7.2
func (qs *PageQuerySet) Search(query string) *PageQuerySet
func (*PageQuerySet) Siblings ¶ added in v1.7.2
func (qs *PageQuerySet) Siblings(path string, depth int64, inclusive ...bool) *PageQuerySet
func (*PageQuerySet) SiblingsOf ¶ added in v1.7.2
func (qs *PageQuerySet) SiblingsOf(node *PageNode, inclusive ...bool) *PageQuerySet
func (*PageQuerySet) Specific ¶ added in v1.7.2
func (qs *PageQuerySet) Specific() *SpecificPageQuerySet
func (*PageQuerySet) StatusFlags ¶ added in v1.7.2
func (qs *PageQuerySet) StatusFlags(statusFlags StatusFlag) *PageQuerySet
func (*PageQuerySet) Types ¶ added in v1.7.2
func (qs *PageQuerySet) Types(types ...any) *PageQuerySet
func (*PageQuerySet) UnpublishNode ¶ added in v1.7.2
func (qs *PageQuerySet) UnpublishNode(node *PageNode, unpublishChildren bool) error
UnpublishNode will unset the published flag on the node and update it accordingly in the database.
If unpublishChildren is true, it will also unpublish all descendants.
func (*PageQuerySet) Unpublished ¶ added in v1.7.2
func (qs *PageQuerySet) Unpublished() *PageQuerySet
func (*PageQuerySet) Update ¶ added in v1.7.2
func (qs *PageQuerySet) Update(*PageNode, ...any) (int64, error)
func (*PageQuerySet) UpdateNode ¶ added in v1.7.2
func (qs *PageQuerySet) UpdateNode(node *PageNode) error
UpdateNode updates a node.
This function will update the node's url path if the slug has changed.
In that case, it will also update the url paths of all descendants.
type PageRenderView ¶
type PageSignal ¶
type PageSignal struct {
BaseSignal
Page Page
}
type PageTemplateGetter ¶
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 PagesAdminHomeComponent ¶ added in v1.7.0
type PagesAdminHomeComponent struct {
ListFields []string
AdminApplication *admin.AdminApplication
Request *http.Request
}
func (*PagesAdminHomeComponent) HTML ¶ added in v1.7.0
func (p *PagesAdminHomeComponent) HTML() template.HTML
func (*PagesAdminHomeComponent) Media ¶ added in v1.7.0
func (p *PagesAdminHomeComponent) Media() media.Media
func (*PagesAdminHomeComponent) Ordering ¶ added in v1.7.0
func (p *PagesAdminHomeComponent) Ordering() int
type PagesMenuItem ¶
func (*PagesMenuItem) Component ¶
func (p *PagesMenuItem) Component() templ.Component
type RoutablePage ¶ added in v1.7.2
type Site ¶ added in v1.7.2
type Site struct {
models.Model `table:"sites"`
ID int64
Name string
Domain string
Port int
Default bool
Root *PageNode
}
func SiteForRequest ¶ added in v1.7.2
func (*Site) DatabaseIndexes ¶ added in v1.7.2
func (*Site) FieldDefs ¶ added in v1.7.2
func (n *Site) FieldDefs() attrs.Definitions
type SpecificPageQuerySet ¶ added in v1.7.2
type SpecificPageQuerySet struct {
*queries.WrappedQuerySet[*PageNode, *SpecificPageQuerySet, *PageQuerySet]
}
func (*SpecificPageQuerySet) AddChildren ¶ added in v1.7.2
func (qs *SpecificPageQuerySet) AddChildren(parent Page, children ...Page) error
AddChildren adds child pages to a parent page. It creates PageNode objects for each child page and then passes them to the PageQuerySet's AddChildren method.
func (*SpecificPageQuerySet) AddRoot ¶ added in v1.7.2
func (qs *SpecificPageQuerySet) AddRoot(page Page) error
AddRoot adds a root page to the queryset.
It is a wrapper around AddRoots that takes a single page.
func (*SpecificPageQuerySet) AddRoots ¶ added in v1.7.2
func (qs *SpecificPageQuerySet) AddRoots(pages ...Page) error
AddRoots adds multiple root pages to the queryset.
It does so by creating PageNode objects for each page, and then passing it to the PageQuerySet's AddRoots method.
func (*SpecificPageQuerySet) All ¶ added in v1.7.2
func (qs *SpecificPageQuerySet) All() (queries.Rows[Page], error)
func (*SpecificPageQuerySet) AncestorOf ¶ added in v1.7.2
func (qs *SpecificPageQuerySet) AncestorOf(node *PageNode, inclusive ...bool) *SpecificPageQuerySet
func (*SpecificPageQuerySet) ChildrenOf ¶ added in v1.7.2
func (qs *SpecificPageQuerySet) ChildrenOf(node *PageNode) *SpecificPageQuerySet
func (*SpecificPageQuerySet) CloneQuerySet ¶ added in v1.7.2
func (qs *SpecificPageQuerySet) CloneQuerySet(wrapped *queries.WrappedQuerySet[*PageNode, *SpecificPageQuerySet, *PageQuerySet]) *SpecificPageQuerySet
func (*SpecificPageQuerySet) DeletePage ¶ added in v1.7.2
func (qs *SpecificPageQuerySet) DeletePage(page Page) error
DeletePage deletes a page from the queryset.
func (*SpecificPageQuerySet) DescendantOf ¶ added in v1.7.2
func (qs *SpecificPageQuerySet) DescendantOf(node *PageNode, inclusive ...bool) *SpecificPageQuerySet
func (*SpecificPageQuerySet) First ¶ added in v1.7.2
func (qs *SpecificPageQuerySet) First() (*queries.Row[Page], error)
First is used to retrieve the first row from the database.
It returns a Query that can be executed to get the result, which is a Row object that contains the model object and a map of annotations.
func (*SpecificPageQuerySet) Get ¶ added in v1.7.2
func (qs *SpecificPageQuerySet) Get() (*queries.Row[Page], error)
func (*SpecificPageQuerySet) Last ¶ added in v1.7.2
func (qs *SpecificPageQuerySet) Last() (*queries.Row[Page], error)
Last is used to retrieve the last row from the database.
It reverses the order of the results and then calls First to get the last row.
It returns a Query that can be executed to get the result, which is a Row object that contains the model object and a map of annotations.
func (*SpecificPageQuerySet) MovePage ¶ added in v1.7.2
func (qs *SpecificPageQuerySet) MovePage(page Page, newParent Page) error
MovePage moves a page and all it's children under a new parent page.
func (*SpecificPageQuerySet) PublishPage ¶ added in v1.7.2
func (qs *SpecificPageQuerySet) PublishPage(page Page) error
PublishPage publishes the given page.
func (*SpecificPageQuerySet) Published ¶ added in v1.7.2
func (qs *SpecificPageQuerySet) Published() *SpecificPageQuerySet
func (*SpecificPageQuerySet) Search ¶ added in v1.7.2
func (qs *SpecificPageQuerySet) Search(query string) *SpecificPageQuerySet
func (*SpecificPageQuerySet) SiblingsOf ¶ added in v1.7.2
func (qs *SpecificPageQuerySet) SiblingsOf(node *PageNode, inclusive ...bool) *SpecificPageQuerySet
func (*SpecificPageQuerySet) StatusFlags ¶ added in v1.7.2
func (qs *SpecificPageQuerySet) StatusFlags(statusFlags StatusFlag) *SpecificPageQuerySet
func (*SpecificPageQuerySet) Types ¶ added in v1.7.2
func (qs *SpecificPageQuerySet) Types(types ...any) *SpecificPageQuerySet
func (*SpecificPageQuerySet) UnpublishPage ¶ added in v1.7.2
func (qs *SpecificPageQuerySet) UnpublishPage(page Page, unpublishChildren bool) error
UnpublishPage unpublishes the given page.
func (*SpecificPageQuerySet) Unpublished ¶ added in v1.7.2
func (qs *SpecificPageQuerySet) Unpublished() *SpecificPageQuerySet
type StatusFlag ¶ added in v1.7.2
type StatusFlag int64
const ( // StatusFlagPublished is the status flag for published pages. StatusFlagPublished StatusFlag = 1 << iota // StatusFlagHidden is the status flag for hidden pages. StatusFlagHidden // StatusFlagDeleted is the status flag for deleted pages. StatusFlagDeleted // StatusflagNone is the status flag for no status. // // It is mainly used in queries to ignore the status flag in where clauses. StatusFlagNone StatusFlag = 0 )
func (StatusFlag) Is ¶ added in v1.7.2
func (f StatusFlag) Is(flag StatusFlag) bool
Source Files
¶
- commands.go
- django_admin.go
- django_admin_api_menus.go
- django_admin_home_component_templ.go
- django_admin_templ.go
- django_admin_views.go
- django_admin_views_revisions.go
- django_admin_views_root.go
- django_admin_views_utils.go
- django_app.go
- errors.go
- model_page.go
- model_site.go
- model_statusflags.go
- page_resolver.go
- pages.go
- pages_definitions.go
- pages_fixtree.go
- pages_redirects.go
- pages_registry.go
- pages_serve.go
- pages_signals.go
- path_utils.go
- queryset.go
- queryset_page.go
- settings.go