Documentation
¶
Index ¶
- Constants
- Variables
- func AppendTab(bookmarks, name, text string) string
- func BP(b bool) *bool
- func Bookmarks(r *http.Request) (string, error)
- func BookmarksEditCreateAction(w http.ResponseWriter, r *http.Request) error
- func BookmarksEditSaveAction(w http.ResponseWriter, r *http.Request) error
- func BookmarksExist(r *http.Request) (bool, error)
- func CategoryEditSaveAction(w http.ResponseWriter, r *http.Request) error
- func CoreAdderMiddleware(next http.Handler) http.Handler
- func CreateBookmarks(ctx context.Context, user string, token *oauth2.Token, branch, text string) error
- func DefaultConfigPath() string
- func EditCategoryPage(w http.ResponseWriter, r *http.Request) error
- func EditTabPage(w http.ResponseWriter, r *http.Request) error
- func ExtractCategoryByIndex(bookmarks string, index int) (string, error)
- func ExtractTab(bookmarks, name string) (string, error)
- func FaviconProxyHandler(w http.ResponseWriter, r *http.Request)
- func GetBookmarks(ctx context.Context, user, ref string, token *oauth2.Token) (string, string, error)
- func GetBookmarksRepoName() string
- func GetCompiledTemplates(funcs template.FuncMap) *template.Template
- func GetFavicon() []byte
- func GetMainCSSData() []byte
- func GitLoginAction(w http.ResponseWriter, r *http.Request) error
- func GitSignupAction(w http.ResponseWriter, r *http.Request) error
- func JoinURL(base, elem string) string
- func LoadEnvFile(path string) error
- func LoginWithProvider(w http.ResponseWriter, r *http.Request) error
- func MergeConfig(dst *Config, src Config)
- func NewFuncs(r *http.Request) template.FuncMap
- func Oauth2CallbackPage(w http.ResponseWriter, r *http.Request) error
- func ProviderNames() []string
- func RegisterProvider(p Provider)
- func ReplaceCategoryByIndex(bookmarks string, index int, newText string) (string, error)
- func ReplaceTab(bookmarks, name, newName, newText string) (string, error)
- func SP(s string) *string
- func SetVersion(pVersion, pCommit, pDate string)
- func TabEditSaveAction(w http.ResponseWriter, r *http.Request) error
- func TaskDoneAutoRefreshPage(w http.ResponseWriter, r *http.Request) error
- func UpdateBookmarks(ctx context.Context, user string, token *oauth2.Token, ...) error
- func UserAdderMiddleware(next http.Handler) http.Handler
- func UserLogoutAction(w http.ResponseWriter, r *http.Request) error
- type BookmarkBlock
- type BookmarkCategory
- type BookmarkColumn
- type BookmarkEntry
- type BookmarkPage
- type Branch
- type Commit
- type Config
- type Configuration
- type ContextValues
- type CoreData
- type FavIcon
- type GitHubProvider
- func (GitHubProvider) Config(clientID, clientSecret, redirectURL string) *oauth2.Config
- func (p GitHubProvider) CreateBookmarks(ctx context.Context, user string, token *oauth2.Token, branch, text string) error
- func (p GitHubProvider) CreateRepo(ctx context.Context, user string, token *oauth2.Token, name string) error
- func (p GitHubProvider) CurrentUser(ctx context.Context, token *oauth2.Token) (*User, error)
- func (GitHubProvider) DefaultServer() string
- func (p GitHubProvider) GetBookmarks(ctx context.Context, user, ref string, token *oauth2.Token) (string, string, error)
- func (p GitHubProvider) GetBranches(ctx context.Context, user string, token *oauth2.Token) ([]*Branch, error)
- func (p GitHubProvider) GetCommits(ctx context.Context, user string, token *oauth2.Token) ([]*Commit, error)
- func (p GitHubProvider) GetTags(ctx context.Context, user string, token *oauth2.Token) ([]*Tag, error)
- func (GitHubProvider) Name() string
- func (p GitHubProvider) RepoExists(ctx context.Context, user string, token *oauth2.Token, name string) (bool, error)
- func (p GitHubProvider) UpdateBookmarks(ctx context.Context, user string, token *oauth2.Token, ...) error
- type GitLabProvider
- func (GitLabProvider) Config(clientID, clientSecret, redirectURL string) *oauth2.Config
- func (GitLabProvider) CreateBookmarks(ctx context.Context, user string, token *oauth2.Token, branch, text string) error
- func (p GitLabProvider) CreateRepo(ctx context.Context, user string, token *oauth2.Token, name string) error
- func (GitLabProvider) CurrentUser(ctx context.Context, token *oauth2.Token) (*User, error)
- func (GitLabProvider) DefaultServer() string
- func (GitLabProvider) GetBookmarks(ctx context.Context, user, ref string, token *oauth2.Token) (string, string, error)
- func (GitLabProvider) GetBranches(ctx context.Context, user string, token *oauth2.Token) ([]*Branch, error)
- func (GitLabProvider) GetCommits(ctx context.Context, user string, token *oauth2.Token) ([]*Commit, error)
- func (GitLabProvider) GetTags(ctx context.Context, user string, token *oauth2.Token) ([]*Tag, error)
- func (GitLabProvider) Name() string
- func (p GitLabProvider) RepoExists(ctx context.Context, user string, token *oauth2.Token, name string) (bool, error)
- func (GitLabProvider) UpdateBookmarks(ctx context.Context, user string, token *oauth2.Token, ...) error
- type GitProvider
- func (GitProvider) CheckPassword(ctx context.Context, user, password string) (bool, error)
- func (GitProvider) Config(clientID, clientSecret, redirectURL string) *oauth2.Config
- func (GitProvider) CreateBookmarks(ctx context.Context, user string, token *oauth2.Token, branch, text string) error
- func (GitProvider) CreateRepo(ctx context.Context, user string, token *oauth2.Token, name string) error
- func (GitProvider) CreateUser(ctx context.Context, user, password string) error
- func (GitProvider) CurrentUser(ctx context.Context, token *oauth2.Token) (*User, error)
- func (GitProvider) DefaultServer() string
- func (GitProvider) GetBookmarks(ctx context.Context, user, ref string, token *oauth2.Token) (string, string, error)
- func (GitProvider) GetBranches(ctx context.Context, user string, token *oauth2.Token) ([]*Branch, error)
- func (GitProvider) GetCommits(ctx context.Context, user string, token *oauth2.Token) ([]*Commit, error)
- func (GitProvider) GetTags(ctx context.Context, user string, token *oauth2.Token) ([]*Tag, error)
- func (GitProvider) Name() string
- func (GitProvider) RepoExists(ctx context.Context, user string, token *oauth2.Token, name string) (bool, error)
- func (GitProvider) SetPassword(ctx context.Context, user, password string) error
- func (GitProvider) UpdateBookmarks(ctx context.Context, user string, token *oauth2.Token, ...) error
- type PasswordHandler
- type Provider
- type ProviderCreds
- type Tag
- type User
Constants ¶
Variables ¶
var ( SessionStore sessions.Store SessionName string )
var ( UseCssColumns bool Namespace string SiteTitle string GithubServer string GitlabServer string GithubClientID string GithubClientSecret string GitlabClientID string GitlabClientSecret string OauthRedirectURL string FaviconCacheDir string FaviconCacheSize int64 LocalGitPath string )
var ErrHandled = errors.New("handled")
ErrHandled is returned by handlers when they have already written a response and no further handlers should run.
var ErrNoProvider = errors.New("no provider selected")
ErrNoProvider indicates that no provider was selected for the request.
var ErrRepoNotFound = errors.New("repository not found")
ErrRepoNotFound indicates that the bookmarks repository does not exist.
var ErrSignedOut = errors.New("signed out")
ErrSignedOut indicates that the OAuth token is no longer valid and the user must authenticate again.
var ErrUserExists = errors.New("user already exists")
ErrUserExists indicates that a user already exists when attempting signup.
var ErrUserNotFound = errors.New("user not found")
ErrUserNotFound indicates that a user does not exist when attempting to set a password.
var ( FaviconCache = struct { sync.RWMutex cache map[string]*FavIcon }{/* contains filtered or unexported fields */} )
var RepoName = GetBookmarksRepoName()
Functions ¶
func BookmarksEditCreateAction ¶
func BookmarksEditCreateAction(w http.ResponseWriter, r *http.Request) error
func BookmarksEditSaveAction ¶
func BookmarksEditSaveAction(w http.ResponseWriter, r *http.Request) error
func CategoryEditSaveAction ¶ added in v1.0.16
func CategoryEditSaveAction(w http.ResponseWriter, r *http.Request) error
func CreateBookmarks ¶
func DefaultConfigPath ¶ added in v1.0.22
func DefaultConfigPath() string
DefaultConfigPath returns the path to the config file depending on environment and the effective user. If running as a non-root user and XDG variables are set, the config lives under the XDG config directory. Otherwise it falls back to /etc/gobookmarks/config.json.
func EditCategoryPage ¶ added in v1.0.16
func EditCategoryPage(w http.ResponseWriter, r *http.Request) error
func EditTabPage ¶ added in v1.0.24
func EditTabPage(w http.ResponseWriter, r *http.Request) error
func ExtractCategoryByIndex ¶ added in v1.0.16
ExtractCategoryByIndex returns the category text for the nth category (0 based)
func ExtractTab ¶ added in v1.0.24
ExtractTab returns the text for a tab by name including the 'Tab:' line.
func FaviconProxyHandler ¶ added in v1.0.4
func FaviconProxyHandler(w http.ResponseWriter, r *http.Request)
func GetBookmarks ¶
func GetBookmarksRepoName ¶ added in v1.0.2
func GetBookmarksRepoName() string
GetBookmarksRepoName returns the repository name based on the current configuration and build mode. When running a development build the name is suffixed with "-dev". The Namespace value is appended if supplied.
func GetFavicon ¶
func GetFavicon() []byte
func GetMainCSSData ¶
func GetMainCSSData() []byte
func GitLoginAction ¶ added in v1.0.24
func GitLoginAction(w http.ResponseWriter, r *http.Request) error
func GitSignupAction ¶ added in v1.0.24
func GitSignupAction(w http.ResponseWriter, r *http.Request) error
func JoinURL ¶ added in v1.0.26
JoinURL joins base and elem ensuring there is exactly one slash between them. Additional leading or trailing slashes are removed from elem.
func LoadEnvFile ¶ added in v1.0.22
Lines should be in KEY=VALUE format and may be commented with '#'.
func LoginWithProvider ¶ added in v1.0.24
func LoginWithProvider(w http.ResponseWriter, r *http.Request) error
func MergeConfig ¶ added in v1.0.22
MergeConfig copies values from src into dst if they are non-zero.
func Oauth2CallbackPage ¶
func Oauth2CallbackPage(w http.ResponseWriter, r *http.Request) error
func ProviderNames ¶ added in v1.0.22
func ProviderNames() []string
func RegisterProvider ¶ added in v1.0.22
func RegisterProvider(p Provider)
func ReplaceCategoryByIndex ¶ added in v1.0.16
ReplaceCategoryByIndex replaces the nth category with newText
func ReplaceTab ¶ added in v1.0.24
ReplaceTab replaces the tab with name with newName and newText. newText should not include the leading 'Tab:' line.
func SetVersion ¶ added in v1.0.6
func SetVersion(pVersion, pCommit, pDate string)
func TabEditSaveAction ¶ added in v1.0.24
func TabEditSaveAction(w http.ResponseWriter, r *http.Request) error
func TaskDoneAutoRefreshPage ¶
func TaskDoneAutoRefreshPage(w http.ResponseWriter, r *http.Request) error
func UpdateBookmarks ¶
func UserLogoutAction ¶
func UserLogoutAction(w http.ResponseWriter, r *http.Request) error
Types ¶
type BookmarkBlock ¶ added in v1.0.15
type BookmarkBlock struct {
Columns []*BookmarkColumn
HR bool
}
type BookmarkCategory ¶
type BookmarkCategory struct {
Name string
Entries []*BookmarkEntry
Index int
}
type BookmarkColumn ¶
type BookmarkColumn struct {
Categories []*BookmarkCategory
}
type BookmarkEntry ¶
type BookmarkPage ¶ added in v1.0.15
type BookmarkPage struct {
Blocks []*BookmarkBlock
Tab string
}
func PreprocessBookmarks ¶
func PreprocessBookmarks(bookmarks string) []*BookmarkPage
type Commit ¶ added in v1.0.22
type Config ¶ added in v1.0.22
type Config struct {
GithubClientID string `json:"github_client_id"`
GithubSecret string `json:"github_secret"`
GitlabClientID string `json:"gitlab_client_id"`
GitlabSecret string `json:"gitlab_secret"`
ExternalURL string `json:"external_url"`
CssColumns bool `json:"css_columns"`
Namespace string `json:"namespace"`
Title string `json:"title"`
GithubServer string `json:"github_server"`
GitlabServer string `json:"gitlab_server"`
FaviconCacheDir string `json:"favicon_cache_dir"`
FaviconCacheSize int64 `json:"favicon_cache_size"`
LocalGitPath string `json:"local_git_path"`
}
Config holds runtime configuration values.
type Configuration ¶
type Configuration struct {
// contains filtered or unexported fields
}
type ContextValues ¶
type ContextValues string
type GitHubProvider ¶ added in v1.0.22
type GitHubProvider struct{}
GitHubProvider implements Provider for GitHub.
func (GitHubProvider) Config ¶ added in v1.0.24
func (GitHubProvider) Config(clientID, clientSecret, redirectURL string) *oauth2.Config
func (GitHubProvider) CreateBookmarks ¶ added in v1.0.22
func (GitHubProvider) CreateRepo ¶ added in v1.0.23
func (GitHubProvider) CurrentUser ¶ added in v1.0.22
func (GitHubProvider) DefaultServer ¶ added in v1.0.23
func (GitHubProvider) DefaultServer() string
func (GitHubProvider) GetBookmarks ¶ added in v1.0.22
func (GitHubProvider) GetBranches ¶ added in v1.0.22
func (GitHubProvider) GetCommits ¶ added in v1.0.22
func (GitHubProvider) Name ¶ added in v1.0.22
func (GitHubProvider) Name() string
func (GitHubProvider) RepoExists ¶ added in v1.0.24
func (GitHubProvider) UpdateBookmarks ¶ added in v1.0.22
type GitLabProvider ¶ added in v1.0.22
type GitLabProvider struct{}
GitLabProvider implements Provider for GitLab.
The GitLab server URL can be overridden using the GitlabServer variable defined in settings.go.
func (GitLabProvider) Config ¶ added in v1.0.24
func (GitLabProvider) Config(clientID, clientSecret, redirectURL string) *oauth2.Config
func (GitLabProvider) CreateBookmarks ¶ added in v1.0.22
func (GitLabProvider) CreateRepo ¶ added in v1.0.23
func (GitLabProvider) CurrentUser ¶ added in v1.0.22
func (GitLabProvider) DefaultServer ¶ added in v1.0.23
func (GitLabProvider) DefaultServer() string
func (GitLabProvider) GetBookmarks ¶ added in v1.0.22
func (GitLabProvider) GetBranches ¶ added in v1.0.22
func (GitLabProvider) GetCommits ¶ added in v1.0.22
func (GitLabProvider) Name ¶ added in v1.0.22
func (GitLabProvider) Name() string
func (GitLabProvider) RepoExists ¶ added in v1.0.24
func (GitLabProvider) UpdateBookmarks ¶ added in v1.0.22
type GitProvider ¶ added in v1.0.24
type GitProvider struct{}
GitProvider implements Provider using local git repositories.
func (GitProvider) CheckPassword ¶ added in v1.0.24
CheckPassword verifies the provided password against the stored bcrypt hash.
func (GitProvider) Config ¶ added in v1.0.24
func (GitProvider) Config(clientID, clientSecret, redirectURL string) *oauth2.Config
func (GitProvider) CreateBookmarks ¶ added in v1.0.24
func (GitProvider) CreateRepo ¶ added in v1.0.24
func (GitProvider) CreateUser ¶ added in v1.0.24
func (GitProvider) CreateUser(ctx context.Context, user, password string) error
CreateUser writes a bcrypt hash for the given user. It returns ErrUserExists if the password file already exists.
func (GitProvider) CurrentUser ¶ added in v1.0.24
func (GitProvider) DefaultServer ¶ added in v1.0.24
func (GitProvider) DefaultServer() string
func (GitProvider) GetBookmarks ¶ added in v1.0.24
func (GitProvider) GetBranches ¶ added in v1.0.24
func (GitProvider) GetCommits ¶ added in v1.0.24
func (GitProvider) Name ¶ added in v1.0.24
func (GitProvider) Name() string
func (GitProvider) RepoExists ¶ added in v1.0.24
func (GitProvider) SetPassword ¶ added in v1.0.24
func (GitProvider) SetPassword(ctx context.Context, user, password string) error
SetPassword updates the password for an existing user. ErrUserNotFound is returned when no password file exists.
func (GitProvider) UpdateBookmarks ¶ added in v1.0.24
type PasswordHandler ¶ added in v1.0.24
type PasswordHandler interface {
CreateUser(ctx context.Context, user, password string) error
SetPassword(ctx context.Context, user, password string) error
CheckPassword(ctx context.Context, user, password string) (bool, error)
}
PasswordHandler is implemented by providers that manage passwords. PasswordHandler manages user accounts for providers that do not rely on external authentication.
CreateUser registers a new account and returns ErrUserExists if the user is already present. SetPassword updates the password for an existing user and returns ErrUserNotFound when the account does not exist.
type Provider ¶ added in v1.0.22
type Provider interface {
Name() string
Config(clientID, clientSecret, redirectURL string) *oauth2.Config
CurrentUser(ctx context.Context, token *oauth2.Token) (*User, error)
GetTags(ctx context.Context, user string, token *oauth2.Token) ([]*Tag, error)
GetBranches(ctx context.Context, user string, token *oauth2.Token) ([]*Branch, error)
GetCommits(ctx context.Context, user string, token *oauth2.Token) ([]*Commit, error)
GetBookmarks(ctx context.Context, user, ref string, token *oauth2.Token) (string, string, error)
UpdateBookmarks(ctx context.Context, user string, token *oauth2.Token, sourceRef, branch, text, expectSHA string) error
CreateBookmarks(ctx context.Context, user string, token *oauth2.Token, branch, text string) error
CreateRepo(ctx context.Context, user string, token *oauth2.Token, name string) error
RepoExists(ctx context.Context, user string, token *oauth2.Token, name string) (bool, error)
DefaultServer() string
}
func GetProvider ¶ added in v1.0.22
type ProviderCreds ¶ added in v1.0.24
Source Files
¶
- authHandlers.go
- autoRefreshPage.go
- bookmarkActionHandlers.go
- bookmarkCategoryEdit.go
- bookmarkProcessor.go
- bookmarkTabEdit.go
- categoryEditHandlers.go
- config.go
- core.go
- data_embedded.go
- errors.go
- faviconProxy.go
- funcs.go
- pointer_utils.go
- provider.go
- provider_access.go
- provider_git.go
- provider_github.go
- provider_gitlab.go
- repo.go
- settings.go
- tabEditHandlers.go
- urlutils.go





