Skip to content

Commit 86c5f51

Browse files
feature (whitelabel): remove references to Filestash
1 parent 21b1bc8 commit 86c5f51

File tree

16 files changed

+49
-31
lines changed

16 files changed

+49
-31
lines changed

public/assets/index.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
// Want to integrate Filestash as a SDK in your application? You are in the right place!
1+
// Want to create an integration via our SDK in your application? You are in the right place!
22
//
33
// How it works you may ask? it's simple:
4-
// 1) pick a component to render. Filestash components look like this:
4+
// 1) pick a component to render. Components look like this:
55
// function(render, opts = {}) {
66
// // ...
77
// }
@@ -12,8 +12,8 @@
1212
// /***********************************************/
1313
// /* example to render the 3D viewer application */
1414
// /***********************************************/
15-
// import { render } from "https://demo.filestash.app/assets/index.js";
16-
// import * as Component from "https://demo.filestash.app/assets/pages/viewerpage/application_3d.js";
15+
// import { render } from "<YOUR_INSTANCE_URL>/assets/index.js";
16+
// import * as Component from "<YOUR_INSTANCE_URL>/assets/pages/viewerpage/application_3d.js";
1717
//
1818
// render(Component, document.getElementById("app"), {});
1919
//
@@ -28,8 +28,8 @@ export function render(module, $app, opts = {}) {
2828
}
2929

3030
function assertArgs(module, $app) {
31-
if (typeof module.default !== "function") throw new TypeError("Unsupported module - see documentation on how to use Filestash");
32-
else if (!($app instanceof Node)) throw new TypeError("Invalid node - see documentation on how to use Filestash");
31+
if (typeof module.default !== "function") throw new TypeError("Unsupported module - see the SDK documentation");
32+
else if (!($app instanceof Node)) throw new TypeError("Invalid node - see the SDK documentation");
3333
}
3434

3535
function execute(module, $app, opts) {

public/assets/pages/connectpage/ctrl_forkme.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import rxjs from "../../lib/rx.js";
44
import config$ from "./model_config.js";
55

66
export default async function(render) {
7-
const hasFork = await config$.pipe(rxjs.filter(({ fork_button }) => fork_button !== false)).toPromise();
7+
const hasFork = await config$.pipe(rxjs.filter(({ license }) => license === "agpl")).toPromise();
88
if (!hasFork) return;
99

1010
render(createElement(`

public/assets/pages/connectpage/ctrl_poweredby.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import t from "../../locales/index.js";
66
import config$ from "./model_config.js";
77

88
export default async function(render) {
9-
const hasFork = await config$.pipe(rxjs.filter(({ fork_button }) => fork_button !== false)).toPromise();
9+
const hasFork = await config$.pipe(rxjs.filter(({ license }) => license === "agpl")).toPromise();
1010
if (!hasFork) return;
1111

1212
await new Promise((done) => setTimeout(done, 1000));

public/index.frontoffice.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{ if eq .license "agpl" -}}
1+
{{ if .appname | eq "Filestash" }}
22
<!--
33
┌──────────────────────────────────────────────────────────┐
44
│ FILESTASH │
@@ -16,9 +16,9 @@
1616
{{- end }}
1717
<link rel="preload" as="style" href="custom.css" onload="this.rel='stylesheet'">
1818
<meta http-equiv="X-UA-Compatible" content="IE=edge">
19-
<meta name="application-name" content="Filestash">
19+
<meta name="application-name" content="{{ .appname }}">
2020
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1">
21-
<script>{{ if eq .license "agpl" }}{{ template "loader-cat" }}{{ else }}{{ template "loader-basic" }}{{ end }}</script>
21+
<script>{{ if .license | eq "agpl" }}{{ template "loader-cat" }}{{ else }}{{ template "loader-basic" }}{{ end }}</script>
2222
</head>
2323
<body>
2424
<div id="app"><component-bootscreen></component-bootscreen></div>

server/common/config.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,12 @@ func NewConfiguration() Configuration {
6767
Form{
6868
Title: "general",
6969
Elmnts: []FormElement{
70-
FormElement{Name: "name", Type: "text", Default: "Filestash", Description: "Name has shown in the UI", Placeholder: "Default: \"Filestash\""},
70+
FormElement{Name: "name", Type: "text", Default: APPNAME, Description: "Name has shown in the UI", Placeholder: "Default: \"" + APPNAME + "\""},
7171
FormElement{Name: "port", Type: "number", Default: 8334, Description: "Port on which the application is available.", Placeholder: "Default: 8334"},
7272
FormElement{Name: "host", Type: "text", Description: "The host people need to use to access this server", Placeholder: "Eg: \"demo.filestash.app\""},
7373
FormElement{Name: "secret_key", Type: "password", Required: true, Pattern: "[a-zA-Z0-9]{16}", Description: "The key that's used to encrypt and decrypt content. Update this settings will invalidate existing user sessions and shared links, use with caution!"},
7474
FormElement{Name: "force_ssl", Type: "boolean", Description: "Enable the web security mechanism called 'Strict Transport Security'"},
7575
FormElement{Name: "editor", Type: "select", Default: "emacs", Opts: []string{"base", "emacs", "vim"}, Description: "Keybinding to be use in the editor. Default: \"emacs\""},
76-
FormElement{Name: "fork_button", Type: "boolean", Default: true, Description: "Display the fork button in the login screen"},
7776
FormElement{Name: "logout", Type: "text", Default: "", Description: "Redirection URL whenever user click on the logout button"},
7877
FormElement{Name: "display_hidden", Type: "boolean", Default: false, Description: "Should files starting with a dot be visible by default?"},
7978
FormElement{Name: "refresh_after_upload", Type: "boolean", Default: false, Description: "Refresh directory listing after upload"},
@@ -108,7 +107,7 @@ func NewConfiguration() Configuration {
108107
Form{
109108
Title: "protection",
110109
Elmnts: []FormElement{
111-
FormElement{Name: "iframe", Type: "text", Default: "", Description: "list of domains who can use the application from an iframe. eg: https://www.filestash.app http://example.com"},
110+
FormElement{Name: "iframe", Type: "text", Default: "", Description: "list of domains who can use the application from an iframe. eg: https://example.com"},
112111
FormElement{Name: "enable_chromecast", Type: "boolean", Default: true, Description: "Enable users to stream content on a chromecast device. This feature requires the browser to access google's server to download the chromecast SDK."},
113112
FormElement{Name: "signature", Type: "text", Default: "", Description: "Enforce signature when using URL parameters in the authentication process"},
114113
},
@@ -120,7 +119,7 @@ func NewConfiguration() Configuration {
120119
Elmnts: []FormElement{
121120
FormElement{Name: "enable", Type: "enable", Target: []string{"log_level"}, Default: true},
122121
FormElement{Name: "level", Type: "select", Default: defaultValue("INFO", "LOG_LEVEL"), Opts: []string{"DEBUG", "INFO", "WARNING", "ERROR"}, Id: "log_level", Description: "Default: \"INFO\". This setting determines the level of detail at which log events are written to the log file"},
123-
FormElement{Name: "telemetry", Type: "boolean", Default: false, Description: "We won't share anything with any third party. This will only to be used to improve Filestash"},
122+
FormElement{Name: "telemetry", Type: "boolean", Default: false, Description: "We won't share anything with any third party. This will only to be used to improve our software"},
124123
},
125124
},
126125
Form{
@@ -337,7 +336,7 @@ func (this *Configuration) Save() {
337336
func (this *Configuration) Export() interface{} {
338337
return struct {
339338
Editor string `json:"editor"`
340-
ForkButton bool `json:"fork_button"`
339+
License string `json:"license"`
341340
DisplayHidden bool `json:"display_hidden"`
342341
Name string `json:"name"`
343342
UploadButton bool `json:"upload_button"`
@@ -360,7 +359,7 @@ func (this *Configuration) Export() interface{} {
360359
EnableTags bool `json:"enable_tags"`
361360
}{
362361
Editor: this.Get("general.editor").String(),
363-
ForkButton: this.Get("general.fork_button").Bool(),
362+
License: LICENSE,
364363
DisplayHidden: this.Get("general.display_hidden").Bool(),
365364
Name: this.Get("general.name").String(),
366365
UploadButton: this.Get("general.upload_button").Bool(),

server/common/config_state.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ func SaveConfig(v []byte) error {
7979
file, err := os.Create(config_path())
8080
if err != nil {
8181
return fmt.Errorf(
82-
"Filestash needs to be able to create/edit its own configuration which it can't at the moment. "+
83-
"Change the permission for filestash to create and edit `%s`",
82+
APPNAME+" needs to be able to create and edit its configuration, but it currently cannot. "+
83+
"Change the permissions to allow writing to `%s`",
8484
config_path(),
8585
)
8686
}

server/common/constants.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ func init() {
5656
}
5757

5858
var (
59+
APPNAME string = "Filestash"
5960
BUILD_REF string
6061
BUILD_DATE string
6162
LICENSE string = "agpl"
@@ -103,3 +104,7 @@ func env(key string, val string) string {
103104
}
104105
return val
105106
}
107+
108+
func IsWhiteLabel() bool {
109+
return APPNAME != "Filestash"
110+
}

server/common/default.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ import (
1010

1111
var USER_AGENT = fmt.Sprintf("Filestash/%s.%s (http://filestash.app)", APP_VERSION, BUILD_DATE)
1212

13+
func init() {
14+
if IsWhiteLabel() {
15+
USER_AGENT = fmt.Sprintf(APPNAME)
16+
}
17+
}
18+
1319
var HTTPClient = http.Client{
1420
Timeout: 5 * time.Hour,
1521
Transport: NewTransformedTransport(&http.Transport{

server/ctrl/report.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ func ReportHandler(ctx *App, res http.ResponseWriter, req *http.Request) {
1414
}
1515

1616
func WellKnownSecurityHandler(ctx *App, res http.ResponseWriter, req *http.Request) {
17+
if IsWhiteLabel() {
18+
NotFoundHandler(ctx, res, req)
19+
return
20+
}
1721
res.WriteHeader(http.StatusOK)
1822
res.Write([]byte("# If you would like to report a security issue\n"))
1923
res.Write([]byte("# you may report it to me via email\n"))

server/ctrl/static.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ func ServeIndex(indexPath string) func(*App, http.ResponseWriter, *http.Request)
238238
sign := signature()
239239
base := WithBase("/")
240240
templateData := map[string]any{
241+
"appname": APPNAME,
241242
"base": base,
242243
"version": BUILD_REF,
243244
"license": LICENSE,

0 commit comments

Comments
 (0)