feat: redirect to main website if not in iframe
This commit is contained in:
parent
94aec140a8
commit
5602ece097
6 changed files with 27 additions and 4 deletions
|
|
@ -2,6 +2,10 @@
|
|||
"aowowUrl": "https://wotlkdb.com",
|
||||
"websiteUrl": "https://mywebsite.com",
|
||||
"websiteName": "My Website",
|
||||
"iframeMode": {
|
||||
"enabled": false,
|
||||
"url": "https://mywebsite.com/armory"
|
||||
},
|
||||
"loadDbcs": true,
|
||||
"hideGameMasters": true,
|
||||
"realms": [
|
||||
|
|
|
|||
4
package-lock.json
generated
4
package-lock.json
generated
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "azerothcore-armory",
|
||||
"version": "0.7.0",
|
||||
"version": "0.8.0",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "azerothcore-armory",
|
||||
"version": "0.7.0",
|
||||
"version": "0.8.0",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@supercharge/promise-pool": "^2.1.0",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "azerothcore-armory",
|
||||
"version": "0.7.0",
|
||||
"version": "0.8.0",
|
||||
"description": "",
|
||||
"scripts": {
|
||||
"build": "tsc -p tsconfig.json",
|
||||
|
|
|
|||
|
|
@ -74,15 +74,20 @@ export class Armory {
|
|||
}
|
||||
|
||||
this.logger.info("Starting server...");
|
||||
|
||||
app.locals.aowow = this.config.aowowUrl;
|
||||
app.locals.websiteUrl = this.config.websiteUrl;
|
||||
app.locals.websiteName = this.config.websiteName;
|
||||
app.locals.iframeMode = this.config.iframeMode;
|
||||
|
||||
app.engine(".html", handlebarsEngine({
|
||||
extname: "html",
|
||||
partialsDir: path.join(process.cwd(), "static", "partials"),
|
||||
layoutsDir: path.join(process.cwd(), "static"),
|
||||
defaultLayout: "layout.html",
|
||||
helpers: require("handlebars-helpers")(),
|
||||
helpers: {
|
||||
...require("handlebars-helpers")(),
|
||||
},
|
||||
}));
|
||||
app.set("view engine", "handlebars");
|
||||
app.set("views", path.join(process.cwd(), "static"));
|
||||
|
|
|
|||
|
|
@ -18,10 +18,16 @@ export interface IRealmConfig {
|
|||
charactersDatabase: IDatabaseConfig;
|
||||
}
|
||||
|
||||
export interface IIframeModeConfig {
|
||||
enabled: boolean;
|
||||
url: string;
|
||||
}
|
||||
|
||||
export class Config {
|
||||
public aowowUrl: string;
|
||||
public websiteUrl: string;
|
||||
public websiteName: string;
|
||||
public iframeMode: IIframeModeConfig;
|
||||
public loadDbcs: boolean;
|
||||
public hideGameMasters: boolean;
|
||||
public realms: IRealmConfig[];
|
||||
|
|
|
|||
|
|
@ -11,8 +11,16 @@
|
|||
</head>
|
||||
|
||||
<body>
|
||||
{{#if iframeMode.enabled}}
|
||||
<script type="application/javascript">
|
||||
if (window === window.parent) {
|
||||
// If not embedded, redirect to the main website with the iframe in it
|
||||
window.location.href = `{{iframeMode.url}}/?${window.location.pathname.trim().replace(/^\//, "")}`;
|
||||
}
|
||||
</script>
|
||||
<script type="application/javascript" src="/js/sync-url.js"></script>
|
||||
<script type="application/javascript" src="https://cdn.jsdelivr.net/npm/iframe-resizer@4.3.2/js/iframeResizer.contentWindow.min.js"></script>
|
||||
{{/if}}
|
||||
<script type="application/javascript" src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||
|
||||
<section class="section">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue