From a88e0cda7ffdba5fabdca6d0707c5c68881b6d22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olav=20Sundf=C3=B8r?= Date: Wed, 30 Apr 2025 16:21:25 +0200 Subject: [PATCH] Add a second promo text to the front. (#40) * Add a second promo text to the front. NRSS does not have enough supporters to break even and thus costs me quite a bit every month. However, it seems to have a stable and high user base, most of whom presumably could pay. As earlier, I'd like to avoid shoving the service behind a paywall - that feels totally wrong for what this project is supposed to be. This PR introduces another, shorter link to donations _before_ the episode description in the hopes of attracting more paid users. Let's see if it works :) --- lib/rss.test.ts | 18 ++++++++++++++++-- lib/rss.ts | 19 ++++++------------- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/lib/rss.test.ts b/lib/rss.test.ts index fead2fb..2247bf1 100644 --- a/lib/rss.test.ts +++ b/lib/rss.test.ts @@ -1,4 +1,4 @@ -import { assertEquals, assertExists } from "$std/assert/mod.ts"; +import { assertEquals, assertExists, assertLess } from "$std/assert/mod.ts"; import { testUtils } from "./test-utils.ts"; import { rss } from "./rss.ts"; import { forTestingOnly } from "./rss.ts"; @@ -30,6 +30,20 @@ Deno.test("generated rss contains promo with link to donations page", () => { const series = testUtils.generateSeries(); const feed = rss.assembleFeed(series); - console.log(feed); feed.includes("Vurder å støtte utviklingen via Vipps"); }); + +Deno.test("generated rss contains promo with link to donations page", () => { + const series = testUtils.generateSeries(); + const feed = rss.assembleFeed(series); + + const indexOfFirstPromotion = feed.indexOf( + "NRSS er avhengig av din Vipps-støtte", + ); + const indexOfSecondPromotion = feed.indexOf("Vurder å støtte utviklingen"); + assertLess( + indexOfFirstPromotion, + indexOfSecondPromotion, + "First promotion should come before the second", + ); +}); diff --git a/lib/rss.ts b/lib/rss.ts index 3124649..812ac11 100644 --- a/lib/rss.ts +++ b/lib/rss.ts @@ -27,16 +27,11 @@ function assembleFeed(series: Series): string { tag("itunes:name", "NRK"), tag("itunes:email", "nrkpodcast@nrk.no"), ]), - tag( - "description", - series.subtitle || "", - ), + tag("description", series.subtitle || ""), tag("ttl", "60"), //60 minutes ...(series.imageUrl ? [ - tag("itunes:image", "", [ - ["href", series.imageUrl], - ]), + tag("itunes:image", "", [["href", series.imageUrl]]), tag("image", [ tag("url", series.imageUrl), tag("title", series.title), @@ -58,10 +53,11 @@ function assembleFeed(series: Series): string { } function descriptionWithDonationPromotion(description: string): string { - const promotion = + const firstPromotion = `⬇️NRSS er avhengig av din Vipps-støtte⬇️`; + const secondPromotion = `Takk for at du bruker NRSS 🙏🌟 Vurder å støtte utviklingen via Vipps med omtrent det samme som prisen på en kaffekopp. Se mer på https://nrss.deno.dev/`; - return `${description}\n\n${promotion}`; + return `${firstPromotion}\n\n${description}\n\n${secondPromotion}`; } function assembleEpisode(episode: Episode, seriesId: Series["id"]): Tag { @@ -76,10 +72,7 @@ function assembleEpisode(episode: Episode, seriesId: Series["id"]): Tag { tag("pubDate", new Date(episode.date).toUTCString()), tag("itunes:duration", episode.durationInSeconds.toString()), tag("podcast:chapters", "", [ - [ - "url", - `${getHostUrl()}/api/feeds/${seriesId}/${episode.id}/chapters`, - ], + ["url", `${getHostUrl()}/api/feeds/${seriesId}/${episode.id}/chapters`], ["type", "application/json+chapters"], ]), tag("enclosure", "", [