Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type App ¶
type App interface { // Get access to GoBlog's database GetDatabase() Database // Get a post from the database or an error when there is no post for the given path GetPost(path string) (Post, error) // Get a blog and a bool whether it exists GetBlog(name string) (Blog, bool) // Purge the rendering cache PurgeCache() // Get the HTTP client used by GoBlog GetHTTPClient() *http.Client // Compile an asset (like CSS, JS, etc.) and add it to use when rendering, for some filetypes, it also get's compressed CompileAsset(filename string, reader io.Reader) error // Get the asset path with the filename used when compiling the assert AssetPath(filename string) string // Set parameter values for a post path SetPostParameter(path string, parameter string, values []string) error // Render markdown as text (without HTML) RenderMarkdownAsText(markdown string) (text string, err error) // Check if user is logged in IsLoggedIn(req *http.Request) bool }
App is used to access GoBlog's app instance.
type Blog ¶
type Blog interface { // Get the language GetLanguage() string }
Blog contains methods to access the blog's configuration.
type Database ¶
type Database interface { Exec(string, ...any) (sql.Result, error) ExecContext(context.Context, string, ...any) (sql.Result, error) Query(string, ...any) (*sql.Rows, error) QueryContext(context.Context, string, ...any) (*sql.Rows, error) QueryRow(string, ...any) (*sql.Row, error) QueryRowContext(context.Context, string, ...any) (*sql.Row, error) }
Database is used to provide access to GoBlog's database.
type Exec ¶
type Exec interface {
// Exec gets called from a Goroutine, so it runs asynchronously.
Exec()
}
Exec plugins are executed after all plugins where initialized.
type Middleware ¶
type Middleware interface { Handler(next http.Handler) http.Handler // Return a priority, the higher prio middlewares get called first. Prio() int }
Middleware plugins can intercept and modify HTTP requests or responses.
type Post ¶
type Post interface { // Get the post path GetPath() string // Get the blog name GetBlog() string // Get a string array map with all the post's parameters GetParameters() map[string][]string // Get a single parameter array (a parameter can have multiple values) GetParameter(parameter string) []string // Get the first value of a post parameter GetFirstParameterValue(parameter string) string // Get the post section name GetSection() string // Get the published date string GetPublished() string // Get the updated date string GetUpdated() string // Get the post content (markdown) GetContent() string // Get the post title GetTitle() string }
Post contains methods to access the post's data.
type PostCreatedHook ¶
type PostCreatedHook interface { // Handle the post. PostCreated(post Post) }
PostCreatedHook plugins get called after a post is created.
type PostDeletedHook ¶
type PostDeletedHook interface { // Handle the post. PostDeleted(post Post) }
PostUpdatedHook plugins get called after a post is deleted.
type PostUpdatedHook ¶
type PostUpdatedHook interface { // Handle the post. PostUpdated(post Post) }
PostUpdatedHook plugins get called after a post is updated.
type RenderContext ¶
type RenderContext interface { // Get the path of the request GetPath() string // Get the URL GetURL() string // Get the blog name GetBlog() string // Check if user is logged in IsLoggedIn() bool }
RenderContext gives some context of the current rendering.
type SetApp ¶
type SetApp interface {
SetApp(app App)
}
SetApp is used to allow GoBlog set its app instance to be accessible by the plugin.
type SetConfig ¶
SetConfig is used in all plugin types to allow GoBlog set the plugin configuration.
type UI ¶
type UI interface { // rendered is a reader with all the rendered HTML, modify it and write it to modified. This is then returned to the client. // The renderContext provides information such as the path of the request or the blog name. Render(renderContext RenderContext, rendered io.Reader, modified io.Writer) }
UI plugins get called when rendering HTML.
type UI2 ¶
type UI2 interface { // The renderContext provides information such as the path of the request or the blog name. // The document can be used to add or modify HTML. RenderWithDocument(renderContext RenderContext, doc *goquery.Document) }
UI2 plugins get called when rendering HTML.
type UIFooter ¶
type UIFooter interface { // The document can be used to add or modify the default HTML. RenderFooter(renderContext RenderContext, doc *goquery.Document) }
UIFooter plugins get called when rendering the footer on each HTML page.
type UIPost ¶
type UIPost interface { // The renderContext provides information such as the path of the request or the blog name. // The post contains information about the post for which to render the summary. // The document can be used to add or modify the default HTML. But it only contains the HTML for the post, not for the whole page. RenderPost(renderContext RenderContext, post Post, doc *goquery.Document) }
UIPost plugins get called when rendering the h-entry for a post. But only on the HTML frontend, not ActivityPub or feeds.
type UISummary ¶
type UISummary interface { // The renderContext provides information such as the path of the request or the blog name. // The post contains information about the post for which to render the summary. // The document can be used to add or modify the default HTML. RenderSummaryForPost(renderContext RenderContext, post Post, doc *goquery.Document) }
UISummary plugins get called when rendering the summary on indexes for a post.