Google adsense implementation

This commit is contained in:
Čarodej
2022-02-07 17:47:29 +01:00
parent 81362fef2d
commit 09774b1d48
9 changed files with 162 additions and 13 deletions

View File

@@ -71,5 +71,6 @@
"/js/chunks/shared-with-me.js": "/js/chunks/shared-with-me.js", "/js/chunks/shared-with-me.js": "/js/chunks/shared-with-me.js",
"/js/chunks/invitation.js": "/js/chunks/invitation.js", "/js/chunks/invitation.js": "/js/chunks/invitation.js",
"/css/tailwind.css": "/css/tailwind.css", "/css/tailwind.css": "/css/tailwind.css",
"/css/app.css": "/css/app.css" "/css/app.css": "/css/app.css",
"/js/chunks/app-adsense.js": "/js/chunks/app-adsense.js"
} }

View File

@@ -14,8 +14,6 @@
tabindex="-1" tabindex="-1"
@click.self="deselect" @click.self="deselect"
> >
<!--<div v-html="config.ads"></div>-->
<ItemHandler <ItemHandler
@click.native="hideContextMenu" @click.native="hideContextMenu"
@dragstart="dragStart(item)" @dragstart="dragStart(item)"

View File

@@ -312,6 +312,15 @@ const routesAdmin = [
title: 'Sign In/Up', title: 'Sign In/Up',
}, },
}, },
{
name: 'AppAdsense',
path: '/admin/settings/adsense',
component: () => import(/* webpackChunkName: "chunks/app-adsense" */ '../views/Admin/AppSettings/AppSettingsTabs/Adsense'),
meta: {
requiresAuth: true,
title: 'Adsense',
},
},
], ],
}, },
{ {

View File

@@ -33,6 +33,10 @@ export default {
title: this.$t('admin_settings.tabs.appearance'), title: this.$t('admin_settings.tabs.appearance'),
route: 'AppAppearance', route: 'AppAppearance',
}, },
{
title: this.$t('Adsense'),
route: 'AppAdsense',
},
{ {
title: this.$t('Homepage'), title: this.$t('Homepage'),
route: 'AppIndex', route: 'AppIndex',

View File

@@ -0,0 +1,115 @@
<template>
<PageTab>
<!--Adsense basic setup-->
<div v-if="adsense" class="card shadow-card">
<FormLabel>
{{ $t('Basic Setup') }}
</FormLabel>
<AppInputSwitch
:title="$t('Allow Google Adsense')"
:description="$t('Allow ads on app pages.')"
>
<SwitchInput
@input="$updateText('/admin/settings', 'allowed_adsense', adsense.allowedService)"
v-model="adsense.allowedService"
class="switch"
:state="adsense.allowedService"
/>
</AppInputSwitch>
<AppInputText :title="$t('Client Id')" :description="$t('Paste your Adsense Client ID e.g. ca-pub-XXXXXXXXXXXXXXXXX')" :is-last="true">
<input
@input="$updateText('/admin/settings', 'adsense_client_id', adsense.clientId, true)"
v-model="adsense.clientId"
:placeholder="$t('Client Id...')"
type="text"
class="focus-border-theme input-dark"
/>
</AppInputText>
</div>
<!--Adsense places-->
<div v-if="adsense" class="card shadow-card">
<FormLabel>
{{ $t('Ads') }}
</FormLabel>
<AppInputText :title="$t('File Viewport Banner')" :description="$t('This banner will be showed above user files')">
<textarea
rows="3"
@input="$updateText('/admin/settings', 'adsense_banner_01', adsense.banner01, true)"
v-model="adsense.banner01"
:placeholder="$t('Paste the <ins></ins> tag here...')"
type="text"
class="focus-border-theme input-dark"
/>
</AppInputText>
<AppInputText :title="$t('Download Page Banner')" :description="$t('This banner will be showed below file download page')">
<textarea
rows="3"
@input="$updateText('/admin/settings', 'adsense_banner_02', adsense.banner02, true)"
v-model="adsense.banner02"
:placeholder="$t('Paste the <ins></ins> tag here...')"
type="text"
class="focus-border-theme input-dark"
/>
</AppInputText>
<AppInputText :title="$t('Homepage Banner')" :description="$t('This banner will be showed on the homepage')" :is-last="true">
<textarea
rows="3"
@input="$updateText('/admin/settings', 'adsense_banner_03', adsense.banner03, true)"
v-model="adsense.banner03"
:placeholder="$t('Paste the <ins></ins> tag here...')"
type="text"
class="focus-border-theme input-dark"
/>
</AppInputText>
</div>
</PageTab>
</template>
<script>
import SwitchInput from '../../../../components/Others/Forms/SwitchInput'
import AppInputButton from '../../../../components/Admin/AppInputButton'
import AppInputSwitch from '../../../../components/Admin/AppInputSwitch'
import FormLabel from '../../../../components/Others/Forms/FormLabel'
import AppInputText from '../../../../components/Admin/AppInputText'
import PageTab from '../../../../components/Others/Layout/PageTab'
import { mapGetters } from 'vuex'
export default {
name: 'Adsense',
components: {
AppInputButton,
AppInputSwitch,
AppInputText,
SwitchInput,
FormLabel,
PageTab,
},
computed: {
...mapGetters(['config']),
},
data() {
return {
adsense: {
allowedService: undefined,
clientId: undefined,
banner01: undefined,
},
}
},
created() {
this.adsense = {
allowedService: this.config.allowedAdsense,
clientId: this.config.adsenseClientId,
banner01: this.config.adsenseBanner01,
banner02: this.config.adsenseBanner02,
banner03: this.config.adsenseBanner03,
}
},
}
</script>

View File

@@ -10,11 +10,14 @@
<!--VueFileManager ScreenShot--> <!--VueFileManager ScreenShot-->
<HeroScreenshot /> <HeroScreenshot />
<!--Google Adsense banner-->
<div v-if="config.allowedAdsense" v-html="config.adsenseBanner01" class="min-h-[120px] mb-5"></div>
<!--Main Features--> <!--Main Features-->
<MainFeatures /> <MainFeatures />
<!--Pricing Tables--> <!--Pricing Tables-->
<!-- <PricingTables v-if="config.isSaaS" />--> <!--<PricingTables v-if="config.isSaaS" />-->
<!--Get Started Call To Action--> <!--Get Started Call To Action-->
<GetStarted /> <GetStarted />

View File

@@ -32,11 +32,17 @@
<SidebarNavigation /> <SidebarNavigation />
<PanelNavigationFiles /> <PanelNavigationFiles />
<div @contextmenu.prevent.capture="contextMenu($event, undefined)" class="transition-transform duration-200 lg:grid lg:flex-grow lg:content-start lg:px-3.5"> <div
@contextmenu.prevent.capture="contextMenu($event, undefined)"
class="transition-transform duration-200 lg:grid lg:flex-grow lg:content-start lg:px-3.5"
>
<DesktopToolbar /> <DesktopToolbar />
<MobileToolbar /> <MobileToolbar />
<!--Google Adsense banner-->
<div v-if="config.allowedAdsense" v-html="config.adsenseBanner01" class="min-h-[120px] mb-5"></div>
<!--File list & info sidebar--> <!--File list & info sidebar-->
<div class="flex space-x-3 lg:overflow-hidden"> <div class="flex space-x-3 lg:overflow-hidden">
<router-view id="file-view" class="relative w-full" :key="$route.fullPath" /> <router-view id="file-view" class="relative w-full" :key="$route.fullPath" />
@@ -96,7 +102,7 @@ export default {
DragUI, DragUI,
}, },
computed: { computed: {
...mapGetters(['isVisibleSidebar', 'isLimitedUser']), ...mapGetters(['isVisibleSidebar', 'isLimitedUser', 'config']),
}, },
data() { data() {
return { return {

View File

@@ -1,11 +1,14 @@
<template> <template>
<div class="flex h-screen items-center justify-center"> <div class="flex h-screen items-center justify-center">
<div> <div class="w-full text-center">
<ItemGrid v-if="sharedFile" :entry="sharedFile" :highlight="true" :mobile-handler="true" /> <ItemGrid v-if="sharedFile" :entry="sharedFile" :highlight="true" :mobile-handler="true" />
<ButtonBase @click.native="download" button-style="theme"> <ButtonBase @click.native="download" button-style="theme" class="mx-auto">
{{ $t('page_shared.download_file') }} {{ $t('page_shared.download_file') }}
</ButtonBase> </ButtonBase>
<!--Google Adsense banner-->
<div v-if="config.allowedAdsense" v-html="config.adsenseBanner01" class="min-h-[120px] mt-5"></div>
</div> </div>
</div> </div>
</template> </template>
@@ -22,7 +25,7 @@ export default {
ItemGrid, ItemGrid,
}, },
computed: { computed: {
...mapGetters(['sharedDetail', 'sharedFile']), ...mapGetters(['sharedDetail', 'sharedFile', 'config']),
}, },
methods: { methods: {
download() { download() {

View File

@@ -143,6 +143,13 @@
allowedGithubLogin: {{ $settings->allowed_github_login ?? 0 }}, allowedGithubLogin: {{ $settings->allowed_github_login ?? 0 }},
isGithubLoginConfigured: {{ env('GITHUB_CLIENT_ID') ? 1 : 0 }}, isGithubLoginConfigured: {{ env('GITHUB_CLIENT_ID') ? 1 : 0 }},
// Adsense
allowedAdsense: {{ $settings->allowed_adsense ?? 0 }},
adsenseClientId: '{{ $settings->adsense_client_id ?? '' }}',
adsenseBanner01: `{!! $settings->adsense_banner_01 ?? '' !!}`,
adsenseBanner02: `{!! $settings->adsense_banner_02 ?? '' !!}`,
adsenseBanner03: `{!! $settings->adsense_banner_03 ?? '' !!}`,
// User settings // User settings
defaultEmoji: '{{ $defaultEmoji }}', defaultEmoji: '{{ $defaultEmoji }}',
defaultThemeMode: '{{ $defaultThemeMode }}', defaultThemeMode: '{{ $defaultThemeMode }}',
@@ -174,10 +181,13 @@
<script src="{{ mix('js/main.js') }}"></script> <script src="{{ mix('js/main.js') }}"></script>
@endif @endif
<!-- <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-8058330732865164" crossorigin="anonymous"></script> {{--Adsense code--}}
@if($settings->allowed_adsense)
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client={{ $settings->adsense_client_id }}" crossorigin="anonymous"></script>
<script> <script>
(adsbygoogle = window.adsbygoogle || []).push({}); (adsbygoogle = window.adsbygoogle || []).push({});
</script>--> </script>
@endif
</body> </body>
</html> </html>