Skip to content

Commit

Permalink
feat: add manifest theme color param (#1542)
Browse files Browse the repository at this point in the history
  • Loading branch information
bekcpear committed Sep 10, 2021
1 parent 3768e33 commit 0358e42
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 3 deletions.
2 changes: 2 additions & 0 deletions cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ func addConfigFlags(flags *pflag.FlagSet) {
flags.String("recaptcha.secret", "", "ReCaptcha secret")

flags.String("branding.name", "", "replace 'File Browser' by this name")
flags.String("branding.color", "", "set the theme color")
flags.String("branding.files", "", "path to directory with images and custom styles")
flags.Bool("branding.disableExternal", false, "disable external links such as GitHub links")
}
Expand Down Expand Up @@ -131,6 +132,7 @@ func printSettings(ser *settings.Server, set *settings.Settings, auther auth.Aut
fmt.Fprintf(w, "\tName:\t%s\n", set.Branding.Name)
fmt.Fprintf(w, "\tFiles override:\t%s\n", set.Branding.Files)
fmt.Fprintf(w, "\tDisable external links:\t%t\n", set.Branding.DisableExternal)
fmt.Fprintf(w, "\tColor:\t%s\n", set.Branding.Color)
fmt.Fprintln(w, "\nServer:")
fmt.Fprintf(w, "\tLog:\t%s\n", ser.Log)
fmt.Fprintf(w, "\tPort:\t%s\n", ser.Port)
Expand Down
2 changes: 2 additions & 0 deletions cmd/config_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ you want to change. Other options will remain unchanged.`,
set.Shell = convertCmdStrToCmdArray(mustGetString(flags, flag.Name))
case "branding.name":
set.Branding.Name = mustGetString(flags, flag.Name)
case "branding.color":
set.Branding.Color = mustGetString(flags, flag.Name)
case "branding.disableExternal":
set.Branding.DisableExternal = mustGetBool(flags, flag.Name)
case "branding.files":
Expand Down
6 changes: 3 additions & 3 deletions frontend/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

<!-- Add to home screen for Android and modern mobile browsers -->
<link rel="manifest" id="manifestPlaceholder" crossorigin="use-credentials">
<meta name="theme-color" content="#2979ff">
<meta name="theme-color" content="[{[ if .Color -]}][{[ .Color ]}][{[ else ]}]#2979ff[{[ end ]}]">

<!-- Add to home screen for Safari on iOS/iPadOS -->
<meta name="apple-mobile-web-app-capable" content="yes">
Expand All @@ -26,7 +26,7 @@

<!-- Add to home screen for Windows -->
<meta name="msapplication-TileImage" content="[{[ .StaticURL ]}]/img/icons/mstile-144x144.png">
<meta name="msapplication-TileColor" content="#2979ff">
<meta name="msapplication-TileColor" content="[{[ if .Color -]}][{[ .Color ]}][{[ else ]}]#2979ff[{[ end ]}]">

<!-- Inject Some Variables and generate the manifest json -->
<script>
Expand All @@ -51,7 +51,7 @@
"start_url": window.location.origin + window.FileBrowser.BaseURL,
"display": "standalone",
"background_color": "#ffffff",
"theme_color": "#455a64"
"theme_color": window.FileBrowser.Color || "#455a64"
}

const stringManifest = JSON.stringify(dynamicManifest);
Expand Down
1 change: 1 addition & 0 deletions http/static.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ func handleWithStaticData(w http.ResponseWriter, _ *http.Request, d *data, fSys
data := map[string]interface{}{
"Name": d.settings.Branding.Name,
"DisableExternal": d.settings.Branding.DisableExternal,
"Color": d.settings.Branding.Color,
"BaseURL": d.server.BaseURL,
"Version": version.Version,
"StaticURL": path.Join(d.server.BaseURL, "/static"),
Expand Down
1 change: 1 addition & 0 deletions settings/branding.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ type Branding struct {
DisableExternal bool `json:"disableExternal"`
Files string `json:"files"`
Theme string `json:"theme"`
Color string `json:"color"`
}

0 comments on commit 0358e42

Please sign in to comment.