Documentation
¶
Overview ¶
Package demokit - the part of the module SDK a module's demo step uses (app install -demo, docs/modules/write-a-module.md): the step's registration, its texts by language, a block and a menu link of the core's, and the install transaction for the module's own ent client. Light like manifestkit: a manifest registers the step.
Index ¶
- func Content(env Env, fsys fs.FS, v any) error
- func CreateComments(ctx context.Context, env Env, nodeID int, list []Comment, at time.Time) (int, time.Time, error)
- func CreateNode(ctx context.Context, env Env, n Node) (int, error)
- func Driver(env Env) dialect.Driver
- func ImageFile(ctx context.Context, env Env, rel string, w, h, i int, alt string, ...) (int, error)
- func IndexTerm(ctx context.Context, env Env, nodeID, tid int, at time.Time) error
- func Load(fsys fs.FS, lang string, v any) error
- func MenuLink(ctx context.Context, env Env, menuID int, title, url string, ...) error
- func PlacePlugin(ctx context.Context, env Env, plugin manifestkit.PluginBlockID, ...) error
- func PlaceView(ctx context.Context, env Env, v ViewBlock, p Placement) error
- func Register(set string, run Step)
- func Term(ctx context.Context, env Env, vid int, name, description, path string, ...) (int, error)
- func Vocabulary(ctx context.Context, env Env, name, slug, prefix string) (int, error)
- type Comment
- type Env
- type Node
- type Placement
- type Step
- type ViewBlock
- type ViewBlockField
- type ViewBlockFilter
- type ViewBlockSort
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Content ¶
Content reads the step's content into v: a demo set's for the module (app install -demo-set), else demo/<lang>.json of fsys (Load). A set's content has the format of the module's demo/<lang>.json.
func CreateComments ¶
func CreateComments(ctx context.Context, env Env, nodeID int, list []Comment, at time.Time) (int, time.Time, error)
CreateComments adds the comments (and their replies) to node nodeID, from at on; it returns how many and the last one's time.
func CreateNode ¶
CreateNode creates a demo material of the module's content type.
func Driver ¶
Driver - the install transaction as an ent driver, for the module's own client (its generated NewClient(Driver(…))): its rows go in with the core's, seeing them, and nothing stays if the install fails.
func ImageFile ¶
func ImageFile(ctx context.Context, env Env, rel string, w, h, i int, alt string, at time.Time) (int, error)
ImageFile draws a demo picture (palette i, w×h) at rel under the public files directory and stores its file row: its ID.
func Load ¶
Load reads demo/<lang>.json of fsys into v (demo/en.json for a language without its own).
func MenuLink ¶
func MenuLink(ctx context.Context, env Env, menuID int, title, url string, nodeID, weight int) error
MenuLink adds a link to the menu (Env.MainMenu, Env.FooterMenu): to url, or to the node nodeID when url is "". Menu 0 (a demo set names none) - no link.
func PlacePlugin ¶
func PlacePlugin(ctx context.Context, env Env, plugin manifestkit.PluginBlockID, config map[string]string, p Placement) error
PlacePlugin places the plugin block (the module's) with its settings.
func PlaceView ¶
PlaceView creates the block View v (a list of content: say, the module's Views field and sort for a top list) and places it.
Types ¶
type Env ¶
type Env struct {
Lang string
CreatedBy int // the administrator
// Users - the demo users by name, the authors of comments and votes.
Users map[string]int
// Articles - the demo articles' node IDs, the newest first.
Articles []int
// Theme - the block placement key of the site's theme.
Theme string
// MainMenu and FooterMenu - the IDs of the menus in the header and
// the footer.
Now time.Time
// contains filtered or unexported fields
}
Env - what a demo step works with: the site's language, the administrator, the demo users and articles, the theme, the menus; the core's rows it adds through this package's helpers (in the install's transaction).
type ViewBlock ¶
ViewBlock - a block View of content (PlaceView): its fields, filters and sorts, built-in or a module's ("<module>.<key>").
type ViewBlockField ¶
type ViewBlockField = demo.ViewBlockField
ViewBlockField - a ViewBlock's field.
type ViewBlockFilter ¶
type ViewBlockFilter = demo.ViewBlockFilter
ViewBlockFilter - a ViewBlock's filter.