Skip to content

Commit

Permalink
fix (#771): search from text editor
Browse files Browse the repository at this point in the history
  • Loading branch information
mickael-kerjean committed Dec 14, 2024
1 parent 2543e6f commit 8422268
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
19 changes: 19 additions & 0 deletions public/assets/boot/ctrl_boot_frontoffice.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export default async function main() {
await Promise.all([ // procedure with dependency on config
setup_chromecast(),
setup_title(),
verify_origin(),
]);

window.dispatchEvent(new window.Event("pagechange"));
Expand Down Expand Up @@ -78,3 +79,21 @@ async function setup_polyfill() {
await loadJS(import.meta.url, "../lib/polyfill.js");
}
}

async function verify_origin() {
const origin = window.CONFIG["origin"];

// happy path
if (!origin) return;
else if (location.origin === origin) return;

// non happy path
const u = new URL(origin);
if (u.host === location.host) return;
else if (u.hostname === location.hostname) return;

setTimeout(() => {
location.href = origin + location.pathname + location.search;
}, 1000);
throw new Error("Redirecting to " + origin);
}
5 changes: 4 additions & 1 deletion public/assets/pages/viewerpage/application_editor.css
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@

/* SEARCH */
.CodeMirror-dialog {
position: fixed;
position: sticky;
left: 0;
right: 0;
background: #525659;
Expand All @@ -77,6 +77,9 @@
background: transparent;
width: 20em;
color: white;
font-family: inherit;
padding-left: 5px;
font-size: inherit;
}

.CodeMirror-dialog button {
Expand Down
12 changes: 12 additions & 0 deletions server/common/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ func (this *Configuration) Export() interface{} {
AuthMiddleware []string `json:"auth"`
Thumbnailer []string `json:"thumbnailer"`
EnableChromecast bool `json:"enable_chromecast"`
Origin string `json:"origin"`
}{
Editor: this.Get("general.editor").String(),
ForkButton: this.Get("general.fork_button").Bool(),
Expand Down Expand Up @@ -403,6 +404,17 @@ func (this *Configuration) Export() interface{} {
return tArray
}(),
EnableChromecast: this.Get("features.protection.enable_chromecast").Bool(),
Origin: func() string {
host := this.Get("general.host").String()
if host == "" {
return ""
}
scheme := "http://"
if this.Get("general.force_ssl").Bool() {
scheme = "https://"
}
return scheme + host
}(),
}
}

Expand Down

0 comments on commit 8422268

Please sign in to comment.