Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ Configuration values can be supplied as environment variables, via a JSON config
| `GBM_CSS_COLUMNS` | If set (to any value) the `Column` keyword in your bookmarks will create CSS multi-column breaks rather than table cells. |
| `GBM_PROVIDER` | Git provider to use (`github` or `gitlab`). Defaults to `github`. |
| `GBM_NAMESPACE` | Optional suffix added to the bookmarks repository name. |
| `GBM_TITLE` | Overrides the page title shown in the browser. |
| `GOBM_ENV_FILE` | Path to a file of `KEY=VALUE` pairs loaded before the environment. Defaults to `/etc/gobookmarks/gobookmarks.env`. |
| `GOBM_CONFIG_FILE` | Path to the JSON config file. If unset the program uses `$XDG_CONFIG_HOME/gobookmarks/config.json` or `$HOME/.config/gobookmarks/config.json` for normal users and `/etc/gobookmarks/config.json` when run as root. |

Expand All @@ -83,6 +84,7 @@ The release packages do not install this file; create it manually if you want to
Use `--config <path>` or set `GOBM_CONFIG_FILE` to control which configuration file is loaded.

The `--provider` command line flag or `GBM_PROVIDER` environment variable selects which git provider to use. By default the binary includes both GitHub and GitLab support. Use build tags `nogithub` or `nogitlab` to exclude either provider when building from source. If you specify an unknown provider the program will exit with an error listing the available options.
The `--title` flag or `GBM_TITLE` environment variable sets the browser page title.

Running `gobookmarks --version` will print the version information along with the list of compiled-in providers.
Use `--dump-config` to print the final configuration after merging the environment,
Expand Down
7 changes: 7 additions & 0 deletions cmd/gobookmarks/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ func main() {
ExternalURL: os.Getenv("EXTERNAL_URL"),
CssColumns: os.Getenv("GBM_CSS_COLUMNS") != "",
Namespace: os.Getenv("GBM_NAMESPACE"),
Title: os.Getenv("GBM_TITLE"),
Provider: os.Getenv("GBM_PROVIDER"),
}

Expand All @@ -67,6 +68,7 @@ func main() {
var secretFlag stringFlag
var urlFlag stringFlag
var nsFlag stringFlag
var titleFlag stringFlag
var providerFlag stringFlag
var columnFlag boolFlag
var versionFlag bool
Expand All @@ -76,6 +78,7 @@ func main() {
flag.Var(&secretFlag, "client-secret", "OAuth2 client secret")
flag.Var(&urlFlag, "external-url", "external URL")
flag.Var(&nsFlag, "namespace", "repository namespace")
flag.Var(&titleFlag, "title", "site title")
flag.Var(&providerFlag, "provider", fmt.Sprintf("git provider (%s)", strings.Join(ProviderNames(), ", ")))
flag.Var(&columnFlag, "css-columns", "use CSS columns")
flag.BoolVar(&versionFlag, "version", false, "show version")
Expand Down Expand Up @@ -109,6 +112,9 @@ func main() {
if nsFlag.set {
cfg.Namespace = nsFlag.value
}
if titleFlag.set {
cfg.Title = titleFlag.value
}
if columnFlag.set {
cfg.CssColumns = columnFlag.value
}
Expand All @@ -124,6 +130,7 @@ func main() {

UseCssColumns = cfg.CssColumns
Namespace = cfg.Namespace
SiteTitle = cfg.Title
clientID = cfg.Oauth2ClientID
clientSecret = cfg.Oauth2Secret
externalUrl = cfg.ExternalURL
Expand Down
4 changes: 4 additions & 0 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type Config struct {
ExternalURL string `json:"external_url"`
CssColumns bool `json:"css_columns"`
Namespace string `json:"namespace"`
Title string `json:"title"`
}

// LoadConfigFile loads configuration from the given path if it exists.
Expand Down Expand Up @@ -50,6 +51,9 @@ func MergeConfig(dst *Config, src Config) {
if src.Namespace != "" {
dst.Namespace = src.Namespace
}
if src.Title != "" {
dst.Title = src.Title
}

if src.Provider != "" {
dst.Provider = src.Provider
Expand Down
10 changes: 9 additions & 1 deletion core.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,17 @@ func CoreAdderMiddleware(next http.Handler) http.Handler {
login = githubUser.Login
}

title := SiteTitle
if title == "" {
title = "Arran4's Bookmarks Website"
}
if version == "dev" && !strings.HasPrefix(title, "dev: ") {
title = "dev: " + title
}

ctx := context.WithValue(request.Context(), ContextValues("coreData"), &CoreData{
UserRef: login,
Title: "Arran4's Bookmarks Website",
Title: title,
})
next.ServeHTTP(writer, request.WithContext(ctx))
})
Expand Down
3 changes: 2 additions & 1 deletion packaging/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"oauth2_secret": "",
"external_url": "http://localhost:8080",
"css_columns": false,
"namespace": ""
"namespace": "",
"title": ""
}
1 change: 1 addition & 0 deletions settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ package gobookmarks
var (
UseCssColumns bool
Namespace string
SiteTitle string
)
2 changes: 1 addition & 1 deletion templates/head.gohtml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{define "head"}}
<html>
<head>
<title>{{$.Title}}</title>
<title>{{if eq (version) "dev"}}dev: {{end}}{{$.Title}}</title>
<style type="text/css">
<!--
@import url("/main.css");
Expand Down
Loading