repo

package
v0.9.0-rc.53 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: AGPL-3.0 Imports: 25 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package repo composes the data layer into the renderer's Repository.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HiddenCategories

func HiddenCategories(ctx context.Context, d *db.DB, user *db.User) ([]string, error)

func HiddenCategoriesOn

func HiddenCategoriesOn(ctx context.Context, d *db.DB, s *db.Site, user *db.User) ([]string, error)

func ReviewsTickets

func ReviewsTickets(ctx context.Context, d *db.DB, u *db.User, now time.Time) (bool, error)

func UserJSON

func UserJSON(ctx context.Context, d *db.DB, u *db.User) (wikijson.Object, error)

func UsersJSON

func UsersJSON(ctx context.Context, d *db.DB, users []db.User, now time.Time) (wikijson.Array, error)

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 NewPerms

func NewPerms(ctx context.Context, d *db.DB) *Perms

func NewPermsOn

func NewPermsOn(ctx context.Context, d *db.DB, s *db.Site) *Perms

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

func (p *Perms) Article(a *db.Article, u *db.User) (*perms.Object, error)

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

func (p *Perms) Category(name string) (*perms.Object, error)

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) ForumPost

func (p *Perms) ForumPost(post *db.ForumThreadPost, thread *perms.Object, u *db.User) *perms.Object

func (*Perms) ForumSection

func (p *Perms) ForumSection(s *db.ForumSection) *perms.Object

func (*Perms) ForumThread

func (p *Perms) ForumThread(t *db.ForumThread, u *db.User) (*perms.Object, error)

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.

func (*Perms) Holders

func (p *Perms) Holders(need string, now time.Time) ([]int64, error)

func (*Perms) Subject

func (p *Perms) Subject(u *db.User, now time.Time) (perms.Subject, error)

Subject collects the roles one visitor carries. A nil user is the anonymous visitor, who still holds the default role.

type Repository

type Repository struct {
	// contains filtered or unexported fields
}

func New

func New(ctx context.Context, d *db.DB, users *printuser.Renderer, opts Options) *Repository

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 NewVarSource

func NewVarSource(ctx context.Context, d *db.DB, site *db.Site) *VarSource

func (*VarSource) ArticleByID

func (s *VarSource) ArticleByID(id int64) (*db.Article, error)

func (*VarSource) Authors

func (s *VarSource) Authors(articleID int64) ([]db.User, error)

func (*VarSource) CategoryForm

func (s *VarSource) CategoryForm(category string) (*form.Definition, error)

func (*VarSource) CategoryRatingMode

func (s *VarSource) CategoryRatingMode(category string) (string, error)

func (*VarSource) ChildCount

func (s *VarSource) ChildCount(articleID int64) (int, error)

func (*VarSource) CommentCount

func (s *VarSource) CommentCount(articleID int64) (int, error)

func (*VarSource) HasVoted

func (s *VarSource) HasVoted(articleID int64, userID *int64) (bool, error)

func (*VarSource) LastComment

func (s *VarSource) LastComment(articleID int64) (*page.Comment, error)

func (*VarSource) LatestEditor

func (s *VarSource) LatestEditor(articleID int64) (*db.User, error)

func (*VarSource) LatestSource

func (s *VarSource) LatestSource(articleID int64) (string, error)

func (*VarSource) RevisionCount

func (s *VarSource) RevisionCount(articleID int64) (int, error)

func (*VarSource) SiteDomain

func (s *VarSource) SiteDomain() string

func (*VarSource) SiteName

func (s *VarSource) SiteName() string

func (*VarSource) SiteRatingMode

func (s *VarSource) SiteRatingMode() (string, error)

func (*VarSource) SiteTitle

func (s *VarSource) SiteTitle() string

func (*VarSource) Tags

func (s *VarSource) Tags(articleID int64) ([]string, error)

func (*VarSource) VoteStats

func (s *VarSource) VoteStats(articleID int64) (db.VoteStats, error)

Jump to

Keyboard shortcuts

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