Merge pull request 'Release v0.4.0: Add possibility to disable platforms' (#106) from v0.4.0/add-plaform-disabling-support into develop
Reviewed-on: #106
This commit is contained in:
commit
409ccfc883
|
@ -12,4 +12,9 @@ REDIS_URL='redis://127.0.0.1:6379'
|
||||||
# please generate a new one with command `pwgen 20 1` (pwgen command needs to be installed)
|
# please generate a new one with command `pwgen 20 1` (pwgen command needs to be installed)
|
||||||
# uncomment variable below and add generated value
|
# uncomment variable below and add generated value
|
||||||
|
|
||||||
# ENCODING_KEY=''
|
# ENCODING_KEY=''
|
||||||
|
|
||||||
|
# this key can be use to disable specific platforms
|
||||||
|
# please add platforms list (comma separated, eg: 'pornhub,youporn,xnxx')
|
||||||
|
# list of platform values can be found in Platforms enum inside src/meta/settings.ts
|
||||||
|
# DISABLED_PLATFORMS=''
|
15
README.md
15
README.md
|
@ -111,4 +111,17 @@ You can deploy the app on Vercel by cloning this repo on your GitHub/Gitlab and
|
||||||
Due to Vercel's *serverless* nature (which makes every request to XVideos and other platforms come from a different IP) it becomes very hard for *web application firewalls* to ban addresses effectively.
|
Due to Vercel's *serverless* nature (which makes every request to XVideos and other platforms come from a different IP) it becomes very hard for *web application firewalls* to ban addresses effectively.
|
||||||
|
|
||||||
## Self-host
|
## Self-host
|
||||||
You can self host the project on your local server via docker-compose and reverse-proxy exposed port to nginx.
|
|
||||||
|
You can self host the project on your local server via docker-compose and reverse-proxy exposed port to nginx.
|
||||||
|
|
||||||
|
### Disabling platforms (both Vercel / Self-host)
|
||||||
|
|
||||||
|
For several reason you might want to disable some platforms. You can do it by adding `DISABLED_PLATFORMS` environment variable.
|
||||||
|
|
||||||
|
List of platform values can be found in Platforms enum inside `src/meta/settings.ts`
|
||||||
|
|
||||||
|
Please add platforms list comma separated. Example:
|
||||||
|
|
||||||
|
```
|
||||||
|
DISABLED_PLATFORMS='pornhub, xnxx'
|
||||||
|
```
|
||||||
|
|
|
@ -11,6 +11,7 @@ import { useCookies } from 'react-cookie';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
handleClose(): void
|
handleClose(): void
|
||||||
|
enabledPlatforms: string[]
|
||||||
labels: {
|
labels: {
|
||||||
title: string,
|
title: string,
|
||||||
}
|
}
|
||||||
|
@ -38,7 +39,7 @@ const mapOrientationToPlatform = (platform: string, orientation: string): string
|
||||||
|
|
||||||
const Platform: React.FC<Props> = (props) => {
|
const Platform: React.FC<Props> = (props) => {
|
||||||
|
|
||||||
const { labels, handleClose } = props
|
const { labels, handleClose, enabledPlatforms } = props
|
||||||
|
|
||||||
const [cookies] = useCookies([Cookies.platform, Cookies.orientation]);
|
const [cookies] = useCookies([Cookies.platform, Cookies.orientation]);
|
||||||
|
|
||||||
|
@ -60,6 +61,10 @@ const Platform: React.FC<Props> = (props) => {
|
||||||
<div className={css.title}>{labels.title}</div>
|
<div className={css.title}>{labels.title}</div>
|
||||||
<select defaultValue={cookies.platform ?? Platforms.xvideos} onChange={handleChange} name={'platform'} aria-label={labels.title}>
|
<select defaultValue={cookies.platform ?? Platforms.xvideos} onChange={handleChange} name={'platform'} aria-label={labels.title}>
|
||||||
{Object.keys(Platforms).map((elem, key) => {
|
{Object.keys(Platforms).map((elem, key) => {
|
||||||
|
if (!enabledPlatforms.includes(elem)) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
return <option className={css.option} key={key} value={elem}>{elem.toUpperCase()}</option>
|
return <option className={css.option} key={key} value={elem}>{elem.toUpperCase()}</option>
|
||||||
})}
|
})}
|
||||||
</select>
|
</select>
|
||||||
|
|
|
@ -10,6 +10,7 @@ import Orientation from './Orientation';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
handleClose(): void
|
handleClose(): void
|
||||||
|
enabledPlatforms: string[]
|
||||||
labels: {
|
labels: {
|
||||||
title: string
|
title: string
|
||||||
platform: any
|
platform: any
|
||||||
|
@ -19,7 +20,7 @@ interface Props {
|
||||||
|
|
||||||
const LangSwitcher: React.FC<Props> = (props) => {
|
const LangSwitcher: React.FC<Props> = (props) => {
|
||||||
|
|
||||||
const { labels, handleClose } = props
|
const { labels, handleClose, enabledPlatforms } = props
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<dialog open>
|
<dialog open>
|
||||||
|
@ -29,7 +30,7 @@ const LangSwitcher: React.FC<Props> = (props) => {
|
||||||
<div className={style.close} onClick={() => { handleClose() }}><IoCloseCircleOutline size={24} /></div>
|
<div className={style.close} onClick={() => { handleClose() }}><IoCloseCircleOutline size={24} /></div>
|
||||||
</header>
|
</header>
|
||||||
<div className={style.content}>
|
<div className={style.content}>
|
||||||
<Platform handleClose={handleClose} labels={{ title: labels.platform.title }} />
|
<Platform enabledPlatforms={enabledPlatforms} handleClose={handleClose} labels={{ title: labels.platform.title }} />
|
||||||
<Orientation handleClose={handleClose} labels={{ title: labels.orientation.title }} />
|
<Orientation handleClose={handleClose} labels={{ title: labels.orientation.title }} />
|
||||||
</div>
|
</div>
|
||||||
</article>
|
</article>
|
||||||
|
|
|
@ -9,11 +9,12 @@ import Modal from './Modal';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
labels: any
|
labels: any
|
||||||
|
enabledPlatforms: string[]
|
||||||
}
|
}
|
||||||
|
|
||||||
const Settings: React.FC<Props> = (props) => {
|
const Settings: React.FC<Props> = (props) => {
|
||||||
|
|
||||||
const { labels } = props
|
const { labels, enabledPlatforms } = props
|
||||||
|
|
||||||
const [showModal, setShowModal] = useState<boolean>(false)
|
const [showModal, setShowModal] = useState<boolean>(false)
|
||||||
|
|
||||||
|
@ -23,7 +24,7 @@ const Settings: React.FC<Props> = (props) => {
|
||||||
{<IoSettingsOutline size={24} />}
|
{<IoSettingsOutline size={24} />}
|
||||||
</Icon>
|
</Icon>
|
||||||
|
|
||||||
{showModal && <Modal handleClose={() => setShowModal(false)} labels={labels} />}
|
{showModal && <Modal enabledPlatforms={enabledPlatforms} handleClose={() => setShowModal(false)} labels={labels} />}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -9,6 +9,7 @@ import Repo from './Repo';
|
||||||
import Language from './Language';
|
import Language from './Language';
|
||||||
import { LangOption } from '@/meta/settings';
|
import { LangOption } from '@/meta/settings';
|
||||||
import Settings from './Settings';
|
import Settings from './Settings';
|
||||||
|
import { getEnabledPlatforms } from '@/utils/platforms';
|
||||||
|
|
||||||
const Menu: React.FC = () => {
|
const Menu: React.FC = () => {
|
||||||
|
|
||||||
|
@ -34,12 +35,14 @@ const Menu: React.FC = () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const enabledPlatforms = getEnabledPlatforms()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={style.container}>
|
<div className={style.container}>
|
||||||
<Repo />
|
<Repo />
|
||||||
<Language labels={languageLabels} />
|
<Language labels={languageLabels} />
|
||||||
<Theme />
|
<Theme />
|
||||||
<Settings labels={settingsLabels} />
|
<Settings enabledPlatforms={enabledPlatforms} labels={settingsLabels} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
import { Platforms } from "@/meta/settings";
|
||||||
|
|
||||||
|
export const getEnabledPlatforms = ():string[] => {
|
||||||
|
if (process.env.DISABLED_PLATFORMS) {
|
||||||
|
const disabledPlatforms: string[] = String(process.env.DISABLED_PLATFORMS).replace(/\s/g, "").split(',')
|
||||||
|
|
||||||
|
return [...Object.values(Platforms)].filter(p => !disabledPlatforms.includes(p))
|
||||||
|
} else {
|
||||||
|
return [...Object.values(Platforms)]
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue