You've already forked AstralRinth
forked from didirus/AstralRinth
Switch ads provider, and switch the analytics system to Ariadne (#214)
* Switch ads provider, and switch the analytics system to Ariadne * Fix CI error * Remove debug messages and errors * Updated nuxtjs
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="ad-wrapper">
|
<div v-if="displayed && !hidden" class="ad-wrapper">
|
||||||
<div v-if="displayed" class="ad">
|
<div class="ad">
|
||||||
<GptAd
|
<GptAd
|
||||||
:key="format.adUnit"
|
:key="format.adUnit"
|
||||||
ref="ad_slot"
|
ref="ad_slot"
|
||||||
@@ -10,6 +10,25 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div v-else-if="ethical_ads_on">
|
||||||
|
<div v-if="ethical_ad_display && ethicalAdType === 'text'">
|
||||||
|
<div
|
||||||
|
:class="ethical_ad_style"
|
||||||
|
data-ea-publisher="modrinth-com"
|
||||||
|
:data-ea-type="ethicalAdType"
|
||||||
|
data-ea-manual="true"
|
||||||
|
></div>
|
||||||
|
</div>
|
||||||
|
<div v-else-if="ethical_ad_display" class="ethical-wrapper">
|
||||||
|
<div
|
||||||
|
:class="ethical_ad_style"
|
||||||
|
data-ea-publisher="modrinth-com"
|
||||||
|
:data-ea-type="ethicalAdType"
|
||||||
|
data-ea-manual="true"
|
||||||
|
></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-else></div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
@@ -36,20 +55,59 @@ export default {
|
|||||||
type: String,
|
type: String,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
|
ethicalAdsBig: {
|
||||||
|
type: Boolean,
|
||||||
|
required: false,
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
ethicalAdsSmall: {
|
||||||
|
type: Boolean,
|
||||||
|
required: false,
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
ethicalAdType: {
|
||||||
|
type: String,
|
||||||
|
required: false,
|
||||||
|
default: 'text',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
isDark: false,
|
||||||
format: null,
|
format: null,
|
||||||
displayed: false,
|
displayed: false,
|
||||||
onSmallScreen: false,
|
onSmallScreen: false,
|
||||||
windowResizeListenerDebounce: null,
|
windowResizeListenerDebounce: null,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
ethical_ads_on() {
|
||||||
|
return (
|
||||||
|
this.$store.app.$config.ads.ethicalAds === 'true' &&
|
||||||
|
(this.ethicalAdsSmall || this.ethicalAdsBig)
|
||||||
|
)
|
||||||
|
},
|
||||||
|
hidden() {
|
||||||
|
return this.$store.app.$config.ads.ethicalAds === 'true'
|
||||||
|
},
|
||||||
|
ethical_ad_display() {
|
||||||
|
return (
|
||||||
|
(this.onSmallScreen && this.ethicalAdsSmall) ||
|
||||||
|
(!this.onSmallScreen && this.ethicalAdsBig)
|
||||||
|
)
|
||||||
|
},
|
||||||
|
ethical_ad_style() {
|
||||||
|
return {
|
||||||
|
dark: this.isDark,
|
||||||
|
raised: true,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
mounted() {
|
mounted() {
|
||||||
// Register hook on resize
|
// Register hook on resize
|
||||||
window.addEventListener('resize', this.handleWindowResize)
|
window.addEventListener('resize', this.handleWindowResize)
|
||||||
|
this.isDark = this.$colorMode.value !== 'light'
|
||||||
// Find ad
|
// Find ad
|
||||||
if (!(this.type in sizes)) {
|
if (!(this.type in sizes)) {
|
||||||
console.error('Ad type not recognized.')
|
console.error('Ad type not recognized.')
|
||||||
@@ -60,6 +118,7 @@ export default {
|
|||||||
this.displayed = true
|
this.displayed = true
|
||||||
if (process.browser) {
|
if (process.browser) {
|
||||||
this.handleWindowResize()
|
this.handleWindowResize()
|
||||||
|
this.refresh_ad()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@@ -72,9 +131,16 @@ export default {
|
|||||||
this.onSmallScreen = false
|
this.onSmallScreen = false
|
||||||
this.format = sizes[this.type]
|
this.format = sizes[this.type]
|
||||||
this.displayed = true
|
this.displayed = true
|
||||||
|
// Refresh ad
|
||||||
|
this.refresh_ad()
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if (this.onSmallScreen === false) {
|
||||||
|
// Reload ad
|
||||||
|
this.onSmallScreen = true
|
||||||
|
this.refresh_ad()
|
||||||
|
}
|
||||||
this.onSmallScreen = true
|
this.onSmallScreen = true
|
||||||
if (this.smallScreen === 'destroy') {
|
if (this.smallScreen === 'destroy') {
|
||||||
this.displayed = false
|
this.displayed = false
|
||||||
@@ -84,6 +150,23 @@ export default {
|
|||||||
}
|
}
|
||||||
}, 300)
|
}, 300)
|
||||||
},
|
},
|
||||||
|
refresh_ad() {
|
||||||
|
if (this.ethical_ads_on && typeof window.ethicalads !== 'undefined') {
|
||||||
|
ethicalads.load()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
head: {
|
||||||
|
script: [
|
||||||
|
{
|
||||||
|
hid: 'ethical_ads_script',
|
||||||
|
type: 'text/javascript',
|
||||||
|
src: 'https://media.ethicalads.io/media/client/ethicalads.min.js',
|
||||||
|
async: true,
|
||||||
|
body: true,
|
||||||
|
defer: true,
|
||||||
|
}, // Insert in body
|
||||||
|
],
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
@@ -97,4 +180,11 @@ export default {
|
|||||||
margin-bottom: var(--spacing-card-md);
|
margin-bottom: var(--spacing-card-md);
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
}
|
}
|
||||||
|
.ethical-wrapper {
|
||||||
|
width: 100%;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
margin-bottom: var(--spacing-card-md);
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.filter-active {
|
.filter-active {
|
||||||
@extend %transparent-clickable.selected;
|
@extend %transparent-clickable, .selected;
|
||||||
svg {
|
svg {
|
||||||
color: var(--color-brand-light);
|
color: var(--color-brand-light);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
/* eslint-disable no-undef */
|
|
||||||
export default function ({ route }) {
|
|
||||||
if (process.client) {
|
|
||||||
googletag.cmd.push(function () {
|
|
||||||
googletag.pubads().setTargeting('path', route.path)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
20
middleware/analytics.js
Normal file
20
middleware/analytics.js
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
import axios from 'axios'
|
||||||
|
export default async function (context) {
|
||||||
|
let domain = ''
|
||||||
|
if (process.server) {
|
||||||
|
domain = context.req.headers.host
|
||||||
|
} else {
|
||||||
|
domain = location.host
|
||||||
|
}
|
||||||
|
const url = context.$config.analytics.base_url + '/register/visit'
|
||||||
|
const path = context.route.path.split('?')[0]
|
||||||
|
try {
|
||||||
|
return await axios.post(url, {
|
||||||
|
path,
|
||||||
|
domain,
|
||||||
|
consent: false,
|
||||||
|
})
|
||||||
|
} catch (e) {
|
||||||
|
// Simply silence the issue.
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -30,6 +30,7 @@ export default async function (ctx, inject) {
|
|||||||
const collapseEmptyDivs =
|
const collapseEmptyDivs =
|
||||||
config.collapseEmptyDivs ??
|
config.collapseEmptyDivs ??
|
||||||
'<%= options.collapseEmptyDivs || false %>' === 'true'
|
'<%= options.collapseEmptyDivs || false %>' === 'true'
|
||||||
|
const ethicalAds = config.ethicalAds === 'true'
|
||||||
const GeoEdgeId = config.GeoEdgeId ?? '<%= options.geoEdgeId %>'
|
const GeoEdgeId = config.GeoEdgeId ?? '<%= options.geoEdgeId %>'
|
||||||
const networkCode = config.networkCode ?? '<%= options.networkCode %>'
|
const networkCode = config.networkCode ?? '<%= options.networkCode %>'
|
||||||
const GPT_LIB_SCRIPT_ID = '<%= options.GPT_LIB_SCRIPT_ID %>'
|
const GPT_LIB_SCRIPT_ID = '<%= options.GPT_LIB_SCRIPT_ID %>'
|
||||||
@@ -53,6 +54,12 @@ export default async function (ctx, inject) {
|
|||||||
ctx.app.head.script.push(script)
|
ctx.app.head.script.push(script)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Vue.component('GptAd', {})
|
||||||
|
|
||||||
|
if (ethicalAds) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const noConsent = !isPersonalizedAdsOn(ctx)
|
const noConsent = !isPersonalizedAdsOn(ctx)
|
||||||
|
|
||||||
// GeoEdge support
|
// GeoEdge support
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
router: {
|
router: {
|
||||||
middleware: ['auth', 'ads_tracking'],
|
middleware: ['auth', 'analytics'],
|
||||||
},
|
},
|
||||||
/*
|
/*
|
||||||
** Global CSS
|
** Global CSS
|
||||||
@@ -114,18 +114,14 @@ export default {
|
|||||||
'@nuxtjs/style-resources',
|
'@nuxtjs/style-resources',
|
||||||
'cookie-universal-nuxt',
|
'cookie-universal-nuxt',
|
||||||
'~/modules/gpt-ads',
|
'~/modules/gpt-ads',
|
||||||
'~/modules/analytics',
|
// The analytics module is disabled, as we are using our own solution embedded in the middleware.
|
||||||
|
// '~/modules/analytics',
|
||||||
],
|
],
|
||||||
ads: {
|
ads: {
|
||||||
// Module options
|
// Module options
|
||||||
ghostMode: true,
|
ghostMode: true,
|
||||||
geoEdgeId: '',
|
geoEdgeId: '',
|
||||||
},
|
},
|
||||||
analytics: {
|
|
||||||
enabled: false,
|
|
||||||
script_url: '',
|
|
||||||
tracking_code: '',
|
|
||||||
},
|
|
||||||
robots: {
|
robots: {
|
||||||
Sitemap: 'https://modrinth.com/sitemap.xml',
|
Sitemap: 'https://modrinth.com/sitemap.xml',
|
||||||
},
|
},
|
||||||
@@ -176,11 +172,10 @@ export default {
|
|||||||
ghostMode: process.env.ENABLE_ADS == null,
|
ghostMode: process.env.ENABLE_ADS == null,
|
||||||
GeoEdgeId: process.env.GEOEDGE_ID,
|
GeoEdgeId: process.env.GEOEDGE_ID,
|
||||||
networkCode: process.env.GAM_ID,
|
networkCode: process.env.GAM_ID,
|
||||||
|
ethicalAds: process.env.ETHICAL_ADS,
|
||||||
},
|
},
|
||||||
analytics: {
|
analytics: {
|
||||||
enabled: process.env.ENABLE_ANALYTICS,
|
base_url: process.env.ARIADNE_URL,
|
||||||
script_url: process.env.ANALYTICS_URL,
|
|
||||||
token: process.env.ANALYTICS_ID,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
17915
package-lock.json
generated
17915
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -19,10 +19,12 @@
|
|||||||
"@nuxtjs/robots": "^2.4.2",
|
"@nuxtjs/robots": "^2.4.2",
|
||||||
"@nuxtjs/sitemap": "^2.4.0",
|
"@nuxtjs/sitemap": "^2.4.0",
|
||||||
"@nuxtjs/style-resources": "^1.0.0",
|
"@nuxtjs/style-resources": "^1.0.0",
|
||||||
|
"axios": "^0.21.1",
|
||||||
"cookie-universal-nuxt": "^2.1.4",
|
"cookie-universal-nuxt": "^2.1.4",
|
||||||
"highlight.js": "^10.3.2",
|
"highlight.js": "^10.3.2",
|
||||||
"marked": "^2.0.0",
|
"marked": "^2.0.0",
|
||||||
"nuxt": "^2.15.5",
|
"nuxt": "^2.15.6",
|
||||||
|
"sass": "^1.32.12",
|
||||||
"v-tooltip": "^2.0.3",
|
"v-tooltip": "^2.0.3",
|
||||||
"vue-click-outside": "^1.1.0",
|
"vue-click-outside": "^1.1.0",
|
||||||
"vue-highlightjs": "^1.3.3",
|
"vue-highlightjs": "^1.3.3",
|
||||||
@@ -41,8 +43,10 @@
|
|||||||
"eslint-config-prettier": "^6.13.0",
|
"eslint-config-prettier": "^6.13.0",
|
||||||
"eslint-plugin-nuxt": "^1.0.0",
|
"eslint-plugin-nuxt": "^1.0.0",
|
||||||
"eslint-plugin-prettier": "^3.1.4",
|
"eslint-plugin-prettier": "^3.1.4",
|
||||||
"node-sass": "^4.14.1",
|
|
||||||
"prettier": "^2.1.2",
|
"prettier": "^2.1.2",
|
||||||
"sass-loader": "^10.1.1"
|
"sass-loader": "^10.1.1"
|
||||||
|
},
|
||||||
|
"optionalDependencies": {
|
||||||
|
"fsevents": "^2.3.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,6 +67,8 @@
|
|||||||
v-if="mod.status === 'approved' || mod.status === 'unlisted'"
|
v-if="mod.status === 'approved' || mod.status === 'unlisted'"
|
||||||
type="banner"
|
type="banner"
|
||||||
small-screen="square"
|
small-screen="square"
|
||||||
|
ethical-ads-small
|
||||||
|
ethical-ads-big
|
||||||
/>
|
/>
|
||||||
<div class="mod-navigation">
|
<div class="mod-navigation">
|
||||||
<div class="tabs">
|
<div class="tabs">
|
||||||
|
|||||||
@@ -64,7 +64,12 @@
|
|||||||
></pagination>
|
></pagination>
|
||||||
</section>
|
</section>
|
||||||
<div class="results column-grow-4">
|
<div class="results column-grow-4">
|
||||||
<Advertisement type="banner" small-screen="square" />
|
<Advertisement
|
||||||
|
type="banner"
|
||||||
|
small-screen="square"
|
||||||
|
ethical-ads-small
|
||||||
|
ethical-ads-big
|
||||||
|
/>
|
||||||
<div v-if="results === null" class="no-results">
|
<div v-if="results === null" class="no-results">
|
||||||
<p>Loading...</p>
|
<p>Loading...</p>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -55,7 +55,13 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<Advertisement type="square" small-screen="square" />
|
<Advertisement
|
||||||
|
type="square"
|
||||||
|
small-screen="square"
|
||||||
|
ethical-ads-big
|
||||||
|
ethical-ads-small
|
||||||
|
ethical-ad-type="image"
|
||||||
|
/>
|
||||||
<m-footer class="footer" hide-small />
|
<m-footer class="footer" hide-small />
|
||||||
</div>
|
</div>
|
||||||
<div class="content">
|
<div class="content">
|
||||||
|
|||||||
@@ -7,12 +7,13 @@ export default {
|
|||||||
based on the information stored in this cookie.`,
|
based on the information stored in this cookie.`,
|
||||||
default: true,
|
default: true,
|
||||||
},
|
},
|
||||||
/* analytics: {
|
analytics: {
|
||||||
title: 'Analytics',
|
title: 'Analytics',
|
||||||
description: `Modrinth uses in-house tools that allows us to get insights on how
|
description: `Modrinth uses in-house tools that allows us to get insights on how
|
||||||
each user is using the platform, to improve the experience for
|
each user is using the platform, to improve the experience for
|
||||||
everyone.`,
|
everyone.\n By enabling this toggle, you allow us to get information across requests,
|
||||||
|
disabling it will just remove all PII from now on.`,
|
||||||
default: true,
|
default: true,
|
||||||
}, */
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user