From 8a8196aa09181d6d20e68430ef54139b4f0a7cb1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E3=81=BE=E3=81=A3=E3=81=A1=E3=82=83=E3=81=A8=E3=83=BC?=
=?UTF-8?q?=E3=81=AB=E3=82=85?=
<17376330+u1-liquid@users.noreply.github.com>
Date: Thu, 28 Dec 2023 10:30:20 +0900
Subject: [PATCH] =?UTF-8?q?enhance(AD):=20=E8=A1=A8=E7=A4=BA=E3=81=95?=
=?UTF-8?q?=E3=82=8C=E3=82=8B=E5=BA=83=E5=91=8A=E3=81=AE=E9=81=B8=E5=AE=9A?=
=?UTF-8?q?=E6=9D=A1=E4=BB=B6=E3=82=92=E5=A4=89=E6=9B=B4=E3=80=81=E7=B8=A6?=
=?UTF-8?q?=E3=81=AB=E9=95=B7=E3=81=84=E3=82=BF=E3=82=A4=E3=83=97=E3=82=92?=
=?UTF-8?q?=E8=A8=AD=E5=AE=9A=E3=81=A7=E3=81=8D=E3=82=8B=E3=82=88=E3=81=86?=
=?UTF-8?q?=E3=81=AB=20(MisskeyIO#293)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../backend/src/server/api/endpoints/meta.ts | 1 +
.../src/components/MkDateSeparatedList.vue | 2 +-
.../frontend/src/components/global/MkAd.vue | 25 +++++++++++--------
packages/frontend/src/pages/admin/ads.vue | 1 +
packages/frontend/src/pages/flash/flash.vue | 2 +-
packages/frontend/src/pages/gallery/post.vue | 2 +-
packages/frontend/src/pages/page.vue | 2 +-
packages/misskey-js/src/autogen/types.ts | 7 +++---
8 files changed, 25 insertions(+), 17 deletions(-)
diff --git a/packages/backend/src/server/api/endpoints/meta.ts b/packages/backend/src/server/api/endpoints/meta.ts
index b36605c38f..b3e9a54614 100644
--- a/packages/backend/src/server/api/endpoints/meta.ts
+++ b/packages/backend/src/server/api/endpoints/meta.ts
@@ -178,6 +178,7 @@ export const meta = {
place: {
type: 'string',
optional: false, nullable: false,
+ enum: ['square', 'horizontal', 'horizontal-big', 'vertical'],
},
ratio: {
type: 'number',
diff --git a/packages/frontend/src/components/MkDateSeparatedList.vue b/packages/frontend/src/components/MkDateSeparatedList.vue
index 0a71b689fe..6ee65e2b69 100644
--- a/packages/frontend/src/components/MkDateSeparatedList.vue
+++ b/packages/frontend/src/components/MkDateSeparatedList.vue
@@ -95,7 +95,7 @@ export default defineComponent({
if (props.ad && item._shouldInsertAd_) {
return [h(MkAd, {
key: item.id + ':ad',
- prefer: ['horizontal', 'horizontal-big'],
+ prefer: [],
}), el];
} else {
return el;
diff --git a/packages/frontend/src/components/global/MkAd.vue b/packages/frontend/src/components/global/MkAd.vue
index 3ef5db3fe3..97feb40db5 100644
--- a/packages/frontend/src/components/global/MkAd.vue
+++ b/packages/frontend/src/components/global/MkAd.vue
@@ -63,24 +63,28 @@ const choseAd = (): Ad | null => {
ratio: 0,
} : ad);
- let ads = allAds.filter(ad => props.prefer.includes(ad.place));
+ const valuableAds = allAds.filter(ad => ad.ratio !== 0);
+ const lowPriorityAds = allAds.filter(ad => ad.ratio === 0);
- if (ads.length === 0) {
- ads = allAds.filter(ad => ad.place === 'square');
+ let ads: Ad[];
+ const preferredAds = valuableAds.filter(ad => props.prefer.includes(ad.place));
+ if (preferredAds.length !== 0) {
+ ads = preferredAds;
+ } else {
+ ads = lowPriorityAds.filter(ad => props.prefer.includes(ad.place));
}
- const lowPriorityAds = ads.filter(ad => ad.ratio === 0);
- ads = ads.filter(ad => ad.ratio !== 0);
-
if (ads.length === 0) {
- if (lowPriorityAds.length !== 0) {
- return lowPriorityAds[Math.floor(Math.random() * lowPriorityAds.length)];
+ const nonPreferredAds = valuableAds.filter(ad => !props.prefer.includes(ad.place));
+ if (nonPreferredAds.length !== 0) {
+ ads = nonPreferredAds;
} else {
- return null;
+ ads = lowPriorityAds.filter(ad => !props.prefer.includes(ad.place));
}
}
const totalFactor = ads.reduce((a, b) => a + b.ratio, 0);
+ if (totalFactor === 0) return ads[Math.floor(Math.random() * ads.length)];
const r = Math.random() * totalFactor;
let stackedFactor = 0;
@@ -148,7 +152,8 @@ function reduceFrequency(): void {
&.form_vertical {
> .link,
> .link > .img {
- max-width: min(100px, 100%);
+ max-width: min(300px, 100%);
+ max-height: 450px;
}
}
}
diff --git a/packages/frontend/src/pages/admin/ads.vue b/packages/frontend/src/pages/admin/ads.vue
index 5884ac74b5..f911181c1f 100644
--- a/packages/frontend/src/pages/admin/ads.vue
+++ b/packages/frontend/src/pages/admin/ads.vue
@@ -29,6 +29,7 @@ SPDX-License-Identifier: AGPL-3.0-only
+