admin

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var UploadsFolder = "uploads/"
View Source
var WWWFolder = "www/"

WWWFolder and UploadsFolder configures where the file uploads should be stored. This is mostly used for testing

Functions

func ListThemes

func ListThemes() []string

ListThemes returns every theme goblog can activate: built-in and installed.

Types

type Admin

type Admin struct {
	OnThemeChange func(theme string)    // callback to reload templates when theme changes
	Installer     *installer.Installer  // plugin directory install/update; nil when not wired
	Directory     *directory.Plugin     // the directory this site hosts; nil when not wired
	Themes        *tinstaller.Installer // theme directory install/activate; nil when not wired
	// contains filtered or unexported fields
}

Admin handles admin requests

func New

func New(db *gorm.DB, auth auth.IAuth, b *blog.Blog, version string) Admin

New constructs an Admin API

func (*Admin) ActivateTheme

func (a *Admin) ActivateTheme(c *gin.Context)

ActivateTheme makes a built-in or installed theme the site's theme: POST {name}.

func (*Admin) AddDirectoryRepo

func (a *Admin) AddDirectoryRepo(c *gin.Context)

AddDirectoryRepo validates a repository and lists it at once: POST {repo, kind}. kind is optional and detected from the manifest when empty.

func (*Admin) AddSetting

func (a *Admin) AddSetting(c *gin.Context)

func (*Admin) Admin

func (a *Admin) Admin(c *gin.Context)

Admin sends /admin to the dashboard. It used to render admin.html, an "all posts + create post" mashup that duplicated two other pages.

func (*Admin) AdminComments

func (a *Admin) AdminComments(c *gin.Context)

AdminComments renders a paginated list of all comments, newest first

func (*Admin) AdminDashboard

func (a *Admin) AdminDashboard(c *gin.Context)

AdminDashboard renders the admin landing page: content counts, the newest posts and comments, and what the site is running (theme, plugins, version).

func (*Admin) AdminEditPage

func (a *Admin) AdminEditPage(c *gin.Context)

AdminEditPage renders the form to edit a single page

func (*Admin) AdminEditPostType

func (a *Admin) AdminEditPostType(c *gin.Context)

AdminEditPostType renders the form to edit a single post type

func (*Admin) AdminNewPost

func (a *Admin) AdminNewPost(c *gin.Context)

func (*Admin) AdminPages

func (a *Admin) AdminPages(c *gin.Context)

AdminPages renders the admin page listing

func (*Admin) AdminPluginSettings

func (a *Admin) AdminPluginSettings(c *gin.Context)

AdminPluginSettings renders one installed plugin's settings page: GET /admin/plugins/:name. The name must follow the plugin name rule and be registered; anything else is the admin 404 page.

func (*Admin) AdminPlugins

func (a *Admin) AdminPlugins(c *gin.Context)

AdminPlugins renders the Plugins admin page; the data is loaded by the page over the API.

func (*Admin) AdminPostTypes

func (a *Admin) AdminPostTypes(c *gin.Context)

AdminPostTypes renders the admin post types listing

func (*Admin) AdminPosts

func (a *Admin) AdminPosts(c *gin.Context)

func (*Admin) AdminSettings

func (a *Admin) AdminSettings(c *gin.Context)

func (*Admin) AdminThemes

func (a *Admin) AdminThemes(c *gin.Context)

AdminThemes renders the Themes admin page; the data is loaded by the page over the API.

func (*Admin) AdminUsers

func (a *Admin) AdminUsers(c *gin.Context)

AdminUsers renders the user list with promote/demote controls (#548).

func (*Admin) ApproveDirectoryRepo

func (a *Admin) ApproveDirectoryRepo(c *gin.Context)

ApproveDirectoryRepo lists a pending or rejected repository.

func (*Admin) CreatePage

func (a *Admin) CreatePage(c *gin.Context)

CreatePage creates a new page

func (*Admin) CreatePost

func (a *Admin) CreatePost(c *gin.Context)

CreatePost adds a post if the user has permission

func (*Admin) CreatePostType

func (a *Admin) CreatePostType(c *gin.Context)

CreatePostType creates a new post type

func (*Admin) DeleteComment

func (a *Admin) DeleteComment(c *gin.Context)

DeleteComment deletes a comment from the database

func (*Admin) DeletePage

func (a *Admin) DeletePage(c *gin.Context)

DeletePage deletes a page

func (*Admin) DeletePost

func (a *Admin) DeletePost(c *gin.Context)

DeletePost deletes a post from the database

func (*Admin) DeletePostType

func (a *Admin) DeletePostType(c *gin.Context)

DeletePostType deletes a post type if no posts reference it

func (*Admin) DelistDirectoryRepo

func (a *Admin) DelistDirectoryRepo(c *gin.Context)

DelistDirectoryRepo forgets a repository.

func (*Admin) DemoteAdmin

func (a *Admin) DemoteAdmin(c *gin.Context)

DemoteAdmin removes admin from the user in the request body. Refused with 409 when they are the last admin. DELETE /api/v1/admins {"id": <blog user id>}

func (*Admin) DraftPost

func (a *Admin) DraftPost(c *gin.Context)

func (*Admin) GetDirectoryRepo

func (a *Admin) GetDirectoryRepo(c *gin.Context)

GetDirectoryRepo returns one repository with its full detail document.

func (*Admin) GetSetting

func (a *Admin) GetSetting(c *gin.Context)

func (*Admin) GetSettings

func (a *Admin) GetSettings(c *gin.Context)

func (*Admin) InstallPlugin

func (a *Admin) InstallPlugin(c *gin.Context)

InstallPlugin installs a directory plugin: POST {name}.

func (*Admin) InstallTheme

func (a *Admin) InstallTheme(c *gin.Context)

InstallTheme installs a directory theme: POST {name}.

func (*Admin) ListDirectoryRepos

func (a *Admin) ListDirectoryRepos(c *gin.Context)

ListDirectoryRepos returns submitted repositories, optionally filtered by ?status=.

func (*Admin) ListPages

func (a *Admin) ListPages(c *gin.Context)

ListPages returns all pages as JSON

func (*Admin) ListPostTypes

func (a *Admin) ListPostTypes(c *gin.Context)

ListPostTypes returns all post types as JSON

func (*Admin) ListRevisions

func (a *Admin) ListRevisions(c *gin.Context)

ListRevisions returns the revision history for a post

func (*Admin) PluginDirectory

func (a *Admin) PluginDirectory(c *gin.Context)

PluginDirectory returns available plugins filtered by ?q= and ordered by ?sort= (stars|name|newest).

func (*Admin) PluginStatus

func (a *Admin) PluginStatus(c *gin.Context)

PluginStatus returns installed plugins and the directory entries not yet installed.

func (*Admin) Post

func (a *Admin) Post(c *gin.Context)

func (*Admin) Preview

func (a *Admin) Preview(c *gin.Context)

Preview renders unsaved markdown for the editor's Preview tab, through exactly the path the published page uses (blog.Post.HTML), so what an author sees is what readers get. Admin only: the renderer keeps raw HTML.

func (*Admin) PromoteAdmin

func (a *Admin) PromoteAdmin(c *gin.Context)

PromoteAdmin makes the user in the request body an admin. POST /api/v1/admins {"id": <blog user id>}

func (*Admin) PublishPost

func (a *Admin) PublishPost(c *gin.Context)

func (*Admin) RebuildDirectoryRepo

func (a *Admin) RebuildDirectoryRepo(c *gin.Context)

RebuildDirectoryRepo re-validates a repository now.

func (*Admin) RefreshPluginDirectory

func (a *Admin) RefreshPluginDirectory(c *gin.Context)

RefreshPluginDirectory re-fetches the directory index now.

func (*Admin) RefreshThemeDirectory

func (a *Admin) RefreshThemeDirectory(c *gin.Context)

RefreshThemeDirectory re-fetches the theme directory index now.

func (*Admin) RejectDirectoryRepo

func (a *Admin) RejectDirectoryRepo(c *gin.Context)

RejectDirectoryRepo keeps a repository off the directory: POST {reason}.

func (*Admin) RollbackRevision

func (a *Admin) RollbackRevision(c *gin.Context)

RollbackRevision restores a post to a previous revision

func (*Admin) SaveGithubLogin

func (a *Admin) SaveGithubLogin(c *gin.Context)

SaveGithubLogin (PUT /api/v1/login-methods/github) stores a GitHub OAuth app's client id and secret in .env and in the environment, which the login page and /login/github read on each request, so GitHub login works without a restart. Before this only the install wizard could set them, so a site installed with a password admin needed .env edited by hand (#668).

func (*Admin) ThemeDirectory

func (a *Admin) ThemeDirectory(c *gin.Context)

ThemeDirectory returns available themes filtered by ?q= and ordered by ?sort= (stars|name|newest).

func (*Admin) ThemeScreenshot

func (a *Admin) ThemeScreenshot(c *gin.Context)

ThemeScreenshot serves an on-disk theme's own screenshot for the Themes page cards: GET /admin/themes/:name/screenshot. theme.Screenshot only resolves a name theme.ValidName accepts (letters, digits, "_", "-") that is a theme on disk with a screenshot, so nothing else in the URL ever reaches the filesystem as a path. Admin-only like the rest of the page; the file is static, so the browser may cache it for the session.

func (*Admin) ThemeStatus

func (a *Admin) ThemeStatus(c *gin.Context)

ThemeStatus returns installed themes and the directory entries not yet installed.

func (*Admin) UninstallPlugin

func (a *Admin) UninstallPlugin(c *gin.Context)

UninstallPlugin removes a dynamic plugin: DELETE /api/v1/plugins/:name.

func (*Admin) UninstallTheme

func (a *Admin) UninstallTheme(c *gin.Context)

UninstallTheme removes an installed theme: DELETE /api/v1/themes/:name.

func (*Admin) UpdateDb

func (a *Admin) UpdateDb(db *gorm.DB)

func (*Admin) UpdatePage

func (a *Admin) UpdatePage(c *gin.Context)

UpdatePage updates an existing page

func (*Admin) UpdatePlugin

func (a *Admin) UpdatePlugin(c *gin.Context)

UpdatePlugin updates an installed dynamic plugin to the directory version: POST {name}.

func (*Admin) UpdatePluginSettings

func (a *Admin) UpdatePluginSettings(c *gin.Context)

UpdatePluginSettings saves plugin settings via the plugin registry.

func (*Admin) UpdatePost

func (a *Admin) UpdatePost(c *gin.Context)

UpdatePost modifies an existing post Requires the ID of the post, title and content to not be empty

func (*Admin) UpdatePostType

func (a *Admin) UpdatePostType(c *gin.Context)

UpdatePostType updates an existing post type

func (*Admin) UpdateSettings

func (a *Admin) UpdateSettings(c *gin.Context)

func (*Admin) UpdateTheme

func (a *Admin) UpdateTheme(c *gin.Context)

UpdateTheme updates an installed theme to the directory version: POST {name}.

func (*Admin) UploadFile

func (a *Admin) UploadFile(c *gin.Context)

UploadFile is the endpoint for storing files on the server https://github.com/gin-gonic/examples/blob/master/upload-file/single/main.go

type SettingField

type SettingField struct {
	blog.Setting
	Label string
	Help  string
}

SettingField is one site setting as the Settings page renders it: the stored row plus the label and help text shown next to its input.

type SettingGroup

type SettingGroup struct {
	ID     string // tab id, also the location.hash fragment that reopens it
	Title  string
	Fields []SettingField
}

SettingGroup is one tab on the Settings page.

func GroupSettings

func GroupSettings(settings map[string]blog.Setting) []SettingGroup

GroupSettings arranges the site settings into the Settings page's tabs. Groups with no stored setting are left out; keys the layout does not know land in an Advanced tab, sorted, labelled by their raw key.

Jump to

Keyboard shortcuts

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