This repository has been archived by the owner on Nov 26, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix extension with subfolder setups & some cleanup (#18)
* Hopefully fix middleware logic to work with subfolder setups * Add Flarum tsconfig & prettier setups * Run Prettier * Update to Webpack 5 * Update flarum/core requirement constraint Co-authored-by: StyleCI Bot <[email protected]>
- Loading branch information
1 parent
74fcece
commit ea55ab9
Showing
7 changed files
with
953 additions
and
5,842 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,97 +1,143 @@ | ||
import app from 'flarum/admin/app'; | ||
import ExtensionPage from 'flarum/admin/components/ExtensionPage'; | ||
import Link from 'flarum/common/components/Link'; | ||
import app from "flarum/admin/app"; | ||
import ExtensionPage from "flarum/admin/components/ExtensionPage"; | ||
import Link from "flarum/common/components/Link"; | ||
|
||
export default class StopForumSpamSettings extends ExtensionPage { | ||
oninit(vnode) { | ||
super.oninit(vnode); | ||
} | ||
oninit(vnode) { | ||
super.oninit(vnode); | ||
} | ||
|
||
content() { | ||
const apiRegions = ['closest', 'europe', 'us']; | ||
const fofSpamblockEnabled = !!app.initializers.has('fof-spamblock'); | ||
content() { | ||
const apiRegions = ["closest", "europe", "us"]; | ||
const fofSpamblockEnabled = !!app.initializers.has("fof-spamblock"); | ||
|
||
return [ | ||
<div className="StopForumSpamSettings"> | ||
<div className="container"> | ||
<div className="Form"> | ||
<div className="Introduction"> | ||
<p className="helpText">{app.translator.trans('fof-stopforumspam.admin.settings.introduction', { | ||
a: <Link href="https://stopforumspam.com" target="_blank" external={true}/> | ||
})}</p> | ||
</div> | ||
<hr /> | ||
{this.buildSettingComponent({ | ||
type: 'select', | ||
setting: 'fof-stopforumspam.regionalEndpoint', | ||
options: apiRegions.reduce((o, p) => { | ||
o[p] = app.translator.trans(`fof-stopforumspam.admin.settings.region_${p}_label`); | ||
return [ | ||
<div className="StopForumSpamSettings"> | ||
<div className="container"> | ||
<div className="Form"> | ||
<div className="Introduction"> | ||
<p className="helpText"> | ||
{app.translator.trans( | ||
"fof-stopforumspam.admin.settings.introduction", | ||
{ | ||
a: ( | ||
<Link | ||
href="https://stopforumspam.com" | ||
target="_blank" | ||
external={true} | ||
/> | ||
), | ||
} | ||
)} | ||
</p> | ||
</div> | ||
<hr /> | ||
{this.buildSettingComponent({ | ||
type: "select", | ||
setting: "fof-stopforumspam.regionalEndpoint", | ||
options: apiRegions.reduce((o, p) => { | ||
o[p] = app.translator.trans( | ||
`fof-stopforumspam.admin.settings.region_${p}_label` | ||
); | ||
|
||
return o; | ||
}, {}), | ||
label: app.translator.trans('fof-stopforumspam.admin.settings.regional_endpoint_label'), | ||
help: app.translator.trans('fof-stopforumspam.admin.settings.regional_endpoint_help'), | ||
default: 'closest', | ||
})} | ||
{this.buildSettingComponent({ | ||
type: 'boolean', | ||
setting: 'fof-stopforumspam.username', | ||
label: app.translator.trans('fof-stopforumspam.admin.settings.username_label'), | ||
})} | ||
{this.buildSettingComponent({ | ||
type: 'boolean', | ||
setting: 'fof-stopforumspam.ip', | ||
label: app.translator.trans('fof-stopforumspam.admin.settings.ip_label'), | ||
})} | ||
{this.buildSettingComponent({ | ||
type: 'boolean', | ||
setting: 'fof-stopforumspam.email', | ||
label: app.translator.trans('fof-stopforumspam.admin.settings.email_label'), | ||
})} | ||
{this.buildSettingComponent({ | ||
type: 'boolean', | ||
setting: 'fof-stopforumspam.emailhash', | ||
label: app.translator.trans('fof-stopforumspam.admin.settings.email_hash_label'), | ||
help: app.translator.trans('fof-stopforumspam.admin.settings.email_hash_help'), | ||
})} | ||
{this.buildSettingComponent({ | ||
type: 'number', | ||
setting: 'fof-stopforumspam.frequency', | ||
label: app.translator.trans('fof-stopforumspam.admin.settings.frequency_label'), | ||
help: app.translator.trans('fof-stopforumspam.admin.settings.frequency_help'), | ||
placeholder: '5', | ||
required: true, | ||
})} | ||
{this.buildSettingComponent({ | ||
type: 'number', | ||
setting: 'fof-stopforumspam.confidence', | ||
label: app.translator.trans('fof-stopforumspam.admin.settings.confidence_label'), | ||
help: app.translator.trans('fof-stopforumspam.admin.settings.confidence_help'), | ||
min: 0, | ||
max: 100, | ||
placeholder: '50', | ||
required: true, | ||
})} | ||
{fofSpamblockEnabled | ||
? [ | ||
<hr />, | ||
<p className="helpText">{app.translator.trans('fof-stopforumspam.admin.settings.api_key_text')}</p>, | ||
this.buildSettingComponent({ | ||
type: 'string', | ||
setting: 'fof-stopforumspam.api_key', | ||
label: app.translator.trans('fof-stopforumspam.admin.settings.api_key_label'), | ||
help: app.translator.trans('fof-stopforumspam.admin.settings.api_key_instructions_text', { | ||
register: <a href="https://www.stopforumspam.com/forum/register.php" />, | ||
key: <a href="https://www.stopforumspam.com/keys" />, | ||
}) | ||
}) | ||
] | ||
: ''} | ||
<hr /> | ||
{this.submitButton()} | ||
</div> | ||
</div> | ||
</div>, | ||
]; | ||
} | ||
return o; | ||
}, {}), | ||
label: app.translator.trans( | ||
"fof-stopforumspam.admin.settings.regional_endpoint_label" | ||
), | ||
help: app.translator.trans( | ||
"fof-stopforumspam.admin.settings.regional_endpoint_help" | ||
), | ||
default: "closest", | ||
})} | ||
{this.buildSettingComponent({ | ||
type: "boolean", | ||
setting: "fof-stopforumspam.username", | ||
label: app.translator.trans( | ||
"fof-stopforumspam.admin.settings.username_label" | ||
), | ||
})} | ||
{this.buildSettingComponent({ | ||
type: "boolean", | ||
setting: "fof-stopforumspam.ip", | ||
label: app.translator.trans( | ||
"fof-stopforumspam.admin.settings.ip_label" | ||
), | ||
})} | ||
{this.buildSettingComponent({ | ||
type: "boolean", | ||
setting: "fof-stopforumspam.email", | ||
label: app.translator.trans( | ||
"fof-stopforumspam.admin.settings.email_label" | ||
), | ||
})} | ||
{this.buildSettingComponent({ | ||
type: "boolean", | ||
setting: "fof-stopforumspam.emailhash", | ||
label: app.translator.trans( | ||
"fof-stopforumspam.admin.settings.email_hash_label" | ||
), | ||
help: app.translator.trans( | ||
"fof-stopforumspam.admin.settings.email_hash_help" | ||
), | ||
})} | ||
{this.buildSettingComponent({ | ||
type: "number", | ||
setting: "fof-stopforumspam.frequency", | ||
label: app.translator.trans( | ||
"fof-stopforumspam.admin.settings.frequency_label" | ||
), | ||
help: app.translator.trans( | ||
"fof-stopforumspam.admin.settings.frequency_help" | ||
), | ||
placeholder: "5", | ||
required: true, | ||
})} | ||
{this.buildSettingComponent({ | ||
type: "number", | ||
setting: "fof-stopforumspam.confidence", | ||
label: app.translator.trans( | ||
"fof-stopforumspam.admin.settings.confidence_label" | ||
), | ||
help: app.translator.trans( | ||
"fof-stopforumspam.admin.settings.confidence_help" | ||
), | ||
min: 0, | ||
max: 100, | ||
placeholder: "50", | ||
required: true, | ||
})} | ||
{fofSpamblockEnabled | ||
? [ | ||
<hr />, | ||
<p className="helpText"> | ||
{app.translator.trans( | ||
"fof-stopforumspam.admin.settings.api_key_text" | ||
)} | ||
</p>, | ||
this.buildSettingComponent({ | ||
type: "string", | ||
setting: "fof-stopforumspam.api_key", | ||
label: app.translator.trans( | ||
"fof-stopforumspam.admin.settings.api_key_label" | ||
), | ||
help: app.translator.trans( | ||
"fof-stopforumspam.admin.settings.api_key_instructions_text", | ||
{ | ||
register: ( | ||
<a href="https://www.stopforumspam.com/forum/register.php" /> | ||
), | ||
key: <a href="https://www.stopforumspam.com/keys" />, | ||
} | ||
), | ||
}), | ||
] | ||
: ""} | ||
<hr /> | ||
{this.submitButton()} | ||
</div> | ||
</div> | ||
</div>, | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
import app from 'flarum/admin/app'; | ||
import StopForumSpamSettings from './components/StopForumSpamSettings'; | ||
import app from "flarum/admin/app"; | ||
import StopForumSpamSettings from "./components/StopForumSpamSettings"; | ||
|
||
app.initializers.add('fof-stopforumspam', () => { | ||
app.extensionData.for('fof-stopforumspam').registerPage(StopForumSpamSettings); | ||
app.initializers.add("fof-stopforumspam", () => { | ||
app.extensionData | ||
.for("fof-stopforumspam") | ||
.registerPage(StopForumSpamSettings); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
// Use Flarum's tsconfig as a starting point | ||
"extends": "flarum-tsconfig", | ||
// This will match all .ts, .tsx, .d.ts, .js, .jsx files in your `src` folder | ||
// and also tells your Typescript server to read core's global typings for | ||
// access to `dayjs` and `$` in the global namespace. | ||
"include": ["src/**/*", "../vendor/flarum/core/js/dist-typings/@types/**/*"], | ||
"compilerOptions": { | ||
// This will output typings to `dist-typings` | ||
"declarationDir": "./dist-typings", | ||
"baseUrl": ".", | ||
"paths": { | ||
"flarum/*": ["../vendor/flarum/core/js/dist-typings/*"] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters