Documentation
¶
Overview ¶
Package repo composes the data layer into the renderer's Repository.
Index ¶
- func HiddenCategories(ctx context.Context, d *db.DB, user *db.User) ([]string, error)
- func HiddenCategoriesOn(ctx context.Context, d *db.DB, s *db.Site, user *db.User) ([]string, error)
- func ReviewsTickets(ctx context.Context, d *db.DB, u *db.User, now time.Time) (bool, error)
- func UserJSON(ctx context.Context, d *db.DB, u *db.User) (wikijson.Object, error)
- func UsersJSON(ctx context.Context, d *db.DB, users []db.User, now time.Time) (wikijson.Array, error)
- type Options
- type Perms
- func (p *Perms) Article(a *db.Article, u *db.User) (*perms.Object, error)
- func (p *Perms) Category(name string) (*perms.Object, error)
- func (p *Perms) ForumPost(post *db.ForumThreadPost, thread *perms.Object, u *db.User) *perms.Object
- func (p *Perms) ForumSection(s *db.ForumSection) *perms.Object
- func (p *Perms) ForumThread(t *db.ForumThread, u *db.User) (*perms.Object, error)
- func (p *Perms) Holders(need string, now time.Time) ([]int64, error)
- func (p *Perms) Subject(u *db.User, now time.Time) (perms.Subject, error)
- type Repository
- func (r *Repository) CallAPI(pc *page.Context, name, method string, params map[string]string) (wikijson.Object, error)
- func (r *Repository) IncludeSources(refs []renderer.IncludeRef) ([]renderer.FetchedPage, error)
- func (r *Repository) PageInfo(refs []string) ([]renderer.PartialPageInfo, error)
- func (r *Repository) RenderModule(pc *page.Context, name string, params map[string]string, body string) (string, error)
- func (r *Repository) RenderUser(username string, avatar bool) (string, error)
- type VarSource
- func (s *VarSource) ArticleByID(id int64) (*db.Article, error)
- func (s *VarSource) Authors(articleID int64) ([]db.User, error)
- func (s *VarSource) CategoryForm(category string) (*form.Definition, error)
- func (s *VarSource) CategoryRatingMode(category string) (string, error)
- func (s *VarSource) ChildCount(articleID int64) (int, error)
- func (s *VarSource) CommentCount(articleID int64) (int, error)
- func (s *VarSource) HasVoted(articleID int64, userID *int64) (bool, error)
- func (s *VarSource) LastComment(articleID int64) (*page.Comment, error)
- func (s *VarSource) LatestEditor(articleID int64) (*db.User, error)
- func (s *VarSource) LatestSource(articleID int64) (string, error)
- func (s *VarSource) RevisionCount(articleID int64) (int, error)
- func (s *VarSource) SiteDomain() string
- func (s *VarSource) SiteName() string
- func (s *VarSource) SiteRatingMode() (string, error)
- func (s *VarSource) SiteTitle() string
- func (s *VarSource) Tags(articleID int64) ([]string, error)
- func (s *VarSource) VoteStats(articleID int64) (db.VoteStats, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HiddenCategories ¶
func HiddenCategoriesOn ¶
func ReviewsTickets ¶
Types ¶
type Options ¶
type Options struct {
Loc *i18n.Localizer
Site *db.Site
User *db.User
// Render is how a module runs the wikitext it produced. The engine is not
// reachable from here, so the caller that owns it supplies this.
Render func(source string, pc *page.Context) (string, error)
RenderMessage func(source string) (string, error)
RenderMessageText func(source string) (string, error)
Vars page.VarSource
// ClientIP is what the action log records, and the entry layer is the only
// layer that knows which forwarded address to believe.
ClientIP *netip.Addr
}
Options is what the modules read besides the database.
type Perms ¶
type Perms struct {
// contains filtered or unexported fields
}
Perms assembles what internal/perms needs out of the database.
func NewPermsOn ¶
NewPermsOn answers for a site the request is not on, which is what an include naming another wiki has to ask before it may read there.
func (*Perms) Article ¶
Article is the object side for a page that exists. Its category is the only step taken before the page's own overrides.
func (*Perms) Category ¶
Category is the object side for a page that does not exist. A category with no row of its own answers the same as no object at all.
func (*Perms) ForumSection ¶
func (p *Perms) ForumSection(s *db.ForumSection) *perms.Object
func (*Perms) ForumThread ¶
A comment thread reads its overrides through the category of the page it is under, and a thread of its own through its forum section.
type Repository ¶
type Repository struct {
// contains filtered or unexported fields
}
func (*Repository) CallAPI ¶
func (r *Repository) CallAPI(pc *page.Context, name, method string, params map[string]string) (wikijson.Object, error)
CallAPI answers the page asking a module a question of its own, which is not a render and so produces JSON rather than markup.
func (*Repository) IncludeSources ¶
func (r *Repository) IncludeSources(refs []renderer.IncludeRef) ([]renderer.FetchedPage, error)
func (*Repository) PageInfo ¶
func (r *Repository) PageInfo(refs []string) ([]renderer.PartialPageInfo, error)
func (*Repository) RenderModule ¶
func (r *Repository) RenderModule(pc *page.Context, name string, params map[string]string, body string) (string, error)
Any failure stays inside the module's own block. Passing it up would fail the whole render, and the reader would get an empty page with no hint why.
func (*Repository) RenderUser ¶
func (r *Repository) RenderUser(username string, avatar bool) (string, error)
The external: prefix never touches the database, wd: may only ever match an imported account, and a bare name is matched against both name columns.
type VarSource ¶
type VarSource struct {
// contains filtered or unexported fields
}
VarSource backs the page variables of one request. The site is fixed for the whole render because the rating setting is resolved against the site the request arrived on.
func (*VarSource) CategoryForm ¶
func (s *VarSource) CategoryForm(category string) (*form.Definition, error)