Documentation
¶
Index ¶
- Variables
- func ListThemes() []string
- type Admin
- func (a *Admin) ActivateTheme(c *gin.Context)
- func (a *Admin) AddDirectoryRepo(c *gin.Context)
- func (a *Admin) AddSetting(c *gin.Context)
- func (a *Admin) Admin(c *gin.Context)
- func (a *Admin) AdminComments(c *gin.Context)
- func (a *Admin) AdminDashboard(c *gin.Context)
- func (a *Admin) AdminEditPage(c *gin.Context)
- func (a *Admin) AdminEditPostType(c *gin.Context)
- func (a *Admin) AdminNewPost(c *gin.Context)
- func (a *Admin) AdminPages(c *gin.Context)
- func (a *Admin) AdminPluginSettings(c *gin.Context)
- func (a *Admin) AdminPlugins(c *gin.Context)
- func (a *Admin) AdminPostTypes(c *gin.Context)
- func (a *Admin) AdminPosts(c *gin.Context)
- func (a *Admin) AdminSettings(c *gin.Context)
- func (a *Admin) AdminThemes(c *gin.Context)
- func (a *Admin) AdminUsers(c *gin.Context)
- func (a *Admin) ApproveDirectoryRepo(c *gin.Context)
- func (a *Admin) CreatePage(c *gin.Context)
- func (a *Admin) CreatePost(c *gin.Context)
- func (a *Admin) CreatePostType(c *gin.Context)
- func (a *Admin) DeleteComment(c *gin.Context)
- func (a *Admin) DeletePage(c *gin.Context)
- func (a *Admin) DeletePost(c *gin.Context)
- func (a *Admin) DeletePostType(c *gin.Context)
- func (a *Admin) DelistDirectoryRepo(c *gin.Context)
- func (a *Admin) DemoteAdmin(c *gin.Context)
- func (a *Admin) DraftPost(c *gin.Context)
- func (a *Admin) GetDirectoryRepo(c *gin.Context)
- func (a *Admin) GetSetting(c *gin.Context)
- func (a *Admin) GetSettings(c *gin.Context)
- func (a *Admin) InstallPlugin(c *gin.Context)
- func (a *Admin) InstallTheme(c *gin.Context)
- func (a *Admin) ListDirectoryRepos(c *gin.Context)
- func (a *Admin) ListPages(c *gin.Context)
- func (a *Admin) ListPostTypes(c *gin.Context)
- func (a *Admin) ListRevisions(c *gin.Context)
- func (a *Admin) PluginDirectory(c *gin.Context)
- func (a *Admin) PluginStatus(c *gin.Context)
- func (a *Admin) Post(c *gin.Context)
- func (a *Admin) Preview(c *gin.Context)
- func (a *Admin) PromoteAdmin(c *gin.Context)
- func (a *Admin) PublishPost(c *gin.Context)
- func (a *Admin) RebuildDirectoryRepo(c *gin.Context)
- func (a *Admin) RefreshPluginDirectory(c *gin.Context)
- func (a *Admin) RefreshThemeDirectory(c *gin.Context)
- func (a *Admin) RejectDirectoryRepo(c *gin.Context)
- func (a *Admin) RollbackRevision(c *gin.Context)
- func (a *Admin) SaveGithubLogin(c *gin.Context)
- func (a *Admin) ThemeDirectory(c *gin.Context)
- func (a *Admin) ThemeScreenshot(c *gin.Context)
- func (a *Admin) ThemeStatus(c *gin.Context)
- func (a *Admin) UninstallPlugin(c *gin.Context)
- func (a *Admin) UninstallTheme(c *gin.Context)
- func (a *Admin) UpdateDb(db *gorm.DB)
- func (a *Admin) UpdatePage(c *gin.Context)
- func (a *Admin) UpdatePlugin(c *gin.Context)
- func (a *Admin) UpdatePluginSettings(c *gin.Context)
- func (a *Admin) UpdatePost(c *gin.Context)
- func (a *Admin) UpdatePostType(c *gin.Context)
- func (a *Admin) UpdateSettings(c *gin.Context)
- func (a *Admin) UpdateTheme(c *gin.Context)
- func (a *Admin) UploadFile(c *gin.Context)
- type SettingField
- type SettingGroup
Constants ¶
This section is empty.
Variables ¶
var UploadsFolder = "uploads/"
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 (*Admin) ActivateTheme ¶
ActivateTheme makes a built-in or installed theme the site's theme: POST {name}.
func (*Admin) AddDirectoryRepo ¶
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 (*Admin) Admin ¶
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 ¶
AdminComments renders a paginated list of all comments, newest first
func (*Admin) AdminDashboard ¶
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 ¶
AdminEditPage renders the form to edit a single page
func (*Admin) AdminEditPostType ¶
AdminEditPostType renders the form to edit a single post type
func (*Admin) AdminNewPost ¶
func (*Admin) AdminPages ¶
AdminPages renders the admin page listing
func (*Admin) AdminPluginSettings ¶
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 ¶
AdminPlugins renders the Plugins admin page; the data is loaded by the page over the API.
func (*Admin) AdminPostTypes ¶
AdminPostTypes renders the admin post types listing
func (*Admin) AdminPosts ¶
func (*Admin) AdminSettings ¶
func (*Admin) AdminThemes ¶
AdminThemes renders the Themes admin page; the data is loaded by the page over the API.
func (*Admin) AdminUsers ¶
AdminUsers renders the user list with promote/demote controls (#548).
func (*Admin) ApproveDirectoryRepo ¶
ApproveDirectoryRepo lists a pending or rejected repository.
func (*Admin) CreatePost ¶
CreatePost adds a post if the user has permission
func (*Admin) CreatePostType ¶
CreatePostType creates a new post type
func (*Admin) DeleteComment ¶
DeleteComment deletes a comment from the database
func (*Admin) DeletePost ¶
DeletePost deletes a post from the database
func (*Admin) DeletePostType ¶
DeletePostType deletes a post type if no posts reference it
func (*Admin) DelistDirectoryRepo ¶
DelistDirectoryRepo forgets a repository.
func (*Admin) DemoteAdmin ¶
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) GetDirectoryRepo ¶
GetDirectoryRepo returns one repository with its full detail document.
func (*Admin) GetSetting ¶
func (*Admin) GetSettings ¶
func (*Admin) InstallPlugin ¶
InstallPlugin installs a directory plugin: POST {name}.
func (*Admin) InstallTheme ¶
InstallTheme installs a directory theme: POST {name}.
func (*Admin) ListDirectoryRepos ¶
ListDirectoryRepos returns submitted repositories, optionally filtered by ?status=.
func (*Admin) ListPostTypes ¶
ListPostTypes returns all post types as JSON
func (*Admin) ListRevisions ¶
ListRevisions returns the revision history for a post
func (*Admin) PluginDirectory ¶
PluginDirectory returns available plugins filtered by ?q= and ordered by ?sort= (stars|name|newest).
func (*Admin) PluginStatus ¶
PluginStatus returns installed plugins and the directory entries not yet installed.
func (*Admin) Preview ¶
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 ¶
PromoteAdmin makes the user in the request body an admin. POST /api/v1/admins {"id": <blog user id>}
func (*Admin) PublishPost ¶
func (*Admin) RebuildDirectoryRepo ¶
RebuildDirectoryRepo re-validates a repository now.
func (*Admin) RefreshPluginDirectory ¶
RefreshPluginDirectory re-fetches the directory index now.
func (*Admin) RefreshThemeDirectory ¶
RefreshThemeDirectory re-fetches the theme directory index now.
func (*Admin) RejectDirectoryRepo ¶
RejectDirectoryRepo keeps a repository off the directory: POST {reason}.
func (*Admin) RollbackRevision ¶
RollbackRevision restores a post to a previous revision
func (*Admin) SaveGithubLogin ¶
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 ¶
ThemeDirectory returns available themes filtered by ?q= and ordered by ?sort= (stars|name|newest).
func (*Admin) ThemeScreenshot ¶
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 ¶
ThemeStatus returns installed themes and the directory entries not yet installed.
func (*Admin) UninstallPlugin ¶
UninstallPlugin removes a dynamic plugin: DELETE /api/v1/plugins/:name.
func (*Admin) UninstallTheme ¶
UninstallTheme removes an installed theme: DELETE /api/v1/themes/:name.
func (*Admin) UpdatePage ¶
UpdatePage updates an existing page
func (*Admin) UpdatePlugin ¶
UpdatePlugin updates an installed dynamic plugin to the directory version: POST {name}.
func (*Admin) UpdatePluginSettings ¶
UpdatePluginSettings saves plugin settings via the plugin registry.
func (*Admin) UpdatePost ¶
UpdatePost modifies an existing post Requires the ID of the post, title and content to not be empty
func (*Admin) UpdatePostType ¶
UpdatePostType updates an existing post type
func (*Admin) UpdateSettings ¶
func (*Admin) UpdateTheme ¶
UpdateTheme updates an installed theme to the directory version: POST {name}.
func (*Admin) UploadFile ¶
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 ¶
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.