mirror of
https://github.com/defnull/fediwall.git
synced 2024-11-22 07:33:44 +01:00
Renamed some query parameters
Renamed `no` to `hide`, `block` to `ban` and changed `media=yes|no|notext` to two simple boolean parameters `text` and `meida`. Empty parameters now also keep their `=` so empty lists (e.g. `tags`) won't look like boolean switches.
This commit is contained in:
parent
c894d076fe
commit
c560a13e92
@ -70,20 +70,10 @@ const formMediaMedia = computed({
|
|||||||
config.value.showMedia = value
|
config.value.showMedia = value
|
||||||
if (!value) {
|
if (!value) {
|
||||||
config.value.showText = true
|
config.value.showText = true
|
||||||
config.value.playVideos = false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const formAutoplay = computed({
|
|
||||||
get: () => config.value.playVideos,
|
|
||||||
set: (value) => {
|
|
||||||
config.value.playVideos = value
|
|
||||||
if (value)
|
|
||||||
config.value.showMedia = true
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const sourceCount = computed(() => {
|
const sourceCount = computed(() => {
|
||||||
var c = 0
|
var c = 0
|
||||||
c += config.value.servers.length * config.value.tags.length
|
c += config.value.servers.length * config.value.tags.length
|
||||||
@ -304,7 +294,7 @@ const onSubmit = () => {
|
|||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-check ms-3">
|
<div class="form-check ms-3">
|
||||||
<input class="form-check-input" type="checkbox" id="edit-autoplay" v-model="formAutoplay">
|
<input class="form-check-input" type="checkbox" id="edit-autoplay" v-model="config.playVideos" :disabled="!formMediaMedia">
|
||||||
<label class="form-check-label" for="edit-autoplay">
|
<label class="form-check-label" for="edit-autoplay">
|
||||||
Autoplay videos (muted)
|
Autoplay videos (muted)
|
||||||
</label>
|
</label>
|
||||||
|
@ -9,8 +9,8 @@ let siteConfig: Config | undefined;
|
|||||||
let siteConfigSource: string | undefined = undefined;
|
let siteConfigSource: string | undefined = undefined;
|
||||||
|
|
||||||
const themes = ["dark", "light", "auto"];
|
const themes = ["dark", "light", "auto"];
|
||||||
const boolYes = ["", "y", "yes", "true"];
|
const boolYes = ["yes", "", "y", "true"];
|
||||||
const boolNo = ["n", "no", "false"];
|
const boolNo = ["no", "n", "false"];
|
||||||
|
|
||||||
const fromBool = (value: string): boolean | undefined => {
|
const fromBool = (value: string): boolean | undefined => {
|
||||||
return boolYes.includes(value.toLowerCase())
|
return boolYes.includes(value.toLowerCase())
|
||||||
@ -77,7 +77,7 @@ const parameterDefinitions: Array<ParamDef> = [
|
|||||||
|
|
||||||
// Filter options
|
// Filter options
|
||||||
{
|
{
|
||||||
names: ["no"],
|
names: ["hide"],
|
||||||
from: (config: Partial<Config>, value: string) => {
|
from: (config: Partial<Config>, value: string) => {
|
||||||
const flags = value.split(",")
|
const flags = value.split(",")
|
||||||
config.hideSensitive = flags.includes("nsfw")
|
config.hideSensitive = flags.includes("nsfw")
|
||||||
@ -100,7 +100,7 @@ const parameterDefinitions: Array<ParamDef> = [
|
|||||||
to: (config: Config) => (config.languages || []).join(","),
|
to: (config: Config) => (config.languages || []).join(","),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
names: ["block"],
|
names: ["ban"],
|
||||||
from: (config: Partial<Config>, value: string) => config.badWords = value.split(","),
|
from: (config: Partial<Config>, value: string) => config.badWords = value.split(","),
|
||||||
to: (config: Config) => (config.badWords || []).join(","),
|
to: (config: Config) => (config.badWords || []).join(","),
|
||||||
},
|
},
|
||||||
@ -131,24 +131,17 @@ const parameterDefinitions: Array<ParamDef> = [
|
|||||||
to: (config: Config) => toBool(config.showInfobar),
|
to: (config: Config) => toBool(config.showInfobar),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// yes = text+media
|
names: ["text"],
|
||||||
// no = text
|
from: (config: Partial<Config>, value: string) => config.showText = fromBool(value),
|
||||||
// notext = media
|
to: (config: Config) => toBool(config.showText),
|
||||||
names: ["media"],
|
|
||||||
from: (config: Partial<Config>, value: string) => {
|
|
||||||
config.showText = ["yes", "no"].includes(value.trim().toLocaleLowerCase())
|
|
||||||
config.showMedia = ["yes", "notext"].includes(value.trim().toLocaleLowerCase())
|
|
||||||
},
|
|
||||||
to: (config: Config) => {
|
|
||||||
if (!config.showText)
|
|
||||||
return "notext"
|
|
||||||
if (!config.showMedia)
|
|
||||||
return "no"
|
|
||||||
return "yes"
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
names: ["autoplay", "play"],
|
names: ["media"],
|
||||||
|
from: (config: Partial<Config>, value: string) => config.showMedia = fromBool(value),
|
||||||
|
to: (config: Config) => toBool(config.showMedia),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
names: ["autoplay"],
|
||||||
from: (config: Partial<Config>, value: string) => config.playVideos = fromBool(value),
|
from: (config: Partial<Config>, value: string) => config.playVideos = fromBool(value),
|
||||||
to: (config: Config) => toBool(config.playVideos),
|
to: (config: Config) => toBool(config.playVideos),
|
||||||
}]
|
}]
|
||||||
@ -201,7 +194,6 @@ export function toQuery(config: Config, userConfig?: string): string {
|
|||||||
.replace(/%2F/g, '/') // save in query strings
|
.replace(/%2F/g, '/') // save in query strings
|
||||||
.replace(/%2C/g, ',') // save in query strings
|
.replace(/%2C/g, ',') // save in query strings
|
||||||
.replace(/%40/g, '@') // save in query strings
|
.replace(/%40/g, '@') // save in query strings
|
||||||
.replace(/=(&|$)/g, '') // a=&b= -> a&b
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isTag(tag: any) {
|
export function isTag(tag: any) {
|
||||||
@ -258,7 +250,7 @@ export function sanatizeConfig(config: any): Config {
|
|||||||
|
|
||||||
result.languages = arrayUnique((Array.isArray(config.languages) ? [...config.languages] : [...fallback.languages]).filter(isLanguage));
|
result.languages = arrayUnique((Array.isArray(config.languages) ? [...config.languages] : [...fallback.languages]).filter(isLanguage));
|
||||||
result.badWords = arrayUnique((Array.isArray(config.badWords) ? [...config.badWords] : [...fallback.badWords]).filter(isTag));
|
result.badWords = arrayUnique((Array.isArray(config.badWords) ? [...config.badWords] : [...fallback.badWords]).filter(isTag));
|
||||||
result.hideSensitive = boolOr(config.hideNsfw, fallback.hideSensitive)
|
result.hideSensitive = boolOr(config.hideSensitive, fallback.hideSensitive)
|
||||||
result.hideBoosts = boolOr(config.hideBoosts, fallback.hideBoosts)
|
result.hideBoosts = boolOr(config.hideBoosts, fallback.hideBoosts)
|
||||||
result.hideBots = boolOr(config.hideBots, fallback.hideBots)
|
result.hideBots = boolOr(config.hideBots, fallback.hideBots)
|
||||||
result.hideReplies = boolOr(config.hideReplies, fallback.hideReplies)
|
result.hideReplies = boolOr(config.hideReplies, fallback.hideReplies)
|
||||||
@ -272,10 +264,6 @@ export function sanatizeConfig(config: any): Config {
|
|||||||
result.showText = boolOr(config.showText, fallback.showText)
|
result.showText = boolOr(config.showText, fallback.showText)
|
||||||
result.showMedia = boolOr(config.showMedia, fallback.showMedia)
|
result.showMedia = boolOr(config.showMedia, fallback.showMedia)
|
||||||
result.playVideos = boolOr(config.playVideos, fallback.playVideos)
|
result.playVideos = boolOr(config.playVideos, fallback.playVideos)
|
||||||
if (result.playVideos)
|
|
||||||
result.showMedia = true
|
|
||||||
if (!result.showMedia)
|
|
||||||
result.playVideos = false
|
|
||||||
if (!result.showMedia && !result.showText)
|
if (!result.showMedia && !result.showText)
|
||||||
result.showText = true
|
result.showText = true
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user