switch hardcoded websub hub to env variable
This commit is contained in:
@ -10,8 +10,8 @@ BASE_URL = 'https://moshingmammut.phlaym.net'
|
|||||||
VERBOSE = false
|
VERBOSE = false
|
||||||
DEBUG_LOG = false
|
DEBUG_LOG = false
|
||||||
IGNORE_USERS = @moshhead@metalhead.club
|
IGNORE_USERS = @moshhead@metalhead.club
|
||||||
WEBSUB_HUB = 'http://pubsubhubbub.superfeedr.com'
|
|
||||||
|
|
||||||
|
PUBLIC_WEBSUB_HUB = 'http://pubsubhubbub.superfeedr.com'
|
||||||
PUBLIC_REFRESH_INTERVAL = 10000
|
PUBLIC_REFRESH_INTERVAL = 10000
|
||||||
PUBLIC_MASTODON_INSTANCE_DISPLAY_NAME = 'Metalhead.club'
|
PUBLIC_MASTODON_INSTANCE_DISPLAY_NAME = 'Metalhead.club'
|
||||||
PORT = 3001
|
PORT = 3001
|
@ -19,7 +19,7 @@
|
|||||||
<meta name="theme-color" content="#17063b" media="(prefers-color-scheme: dark)" />
|
<meta name="theme-color" content="#17063b" media="(prefers-color-scheme: dark)" />
|
||||||
<meta name="theme-color" content="#BCB9B2" media="(prefers-color-scheme: light)" />
|
<meta name="theme-color" content="#BCB9B2" media="(prefers-color-scheme: light)" />
|
||||||
<link rel="alternate" type="application/atom+xml" href="/feed.xml" title="Atom Feed" />
|
<link rel="alternate" type="application/atom+xml" href="/feed.xml" title="Atom Feed" />
|
||||||
<link rel="hub" href="https://pubsubhubbub.superfeedr.com" />
|
<link rel="hub" href="%sveltekit.env.PUBLIC_WEBSUB_HUB%" />
|
||||||
%sveltekit.head%
|
%sveltekit.head%
|
||||||
<style>
|
<style>
|
||||||
body {
|
body {
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { BASE_URL, WEBSUB_HUB } from '$env/static/private';
|
import { BASE_URL } from '$env/static/private';
|
||||||
|
import { PUBLIC_WEBSUB_HUB } from '$env/static/public';
|
||||||
import { PUBLIC_MASTODON_INSTANCE_DISPLAY_NAME } from '$env/static/public';
|
import { PUBLIC_MASTODON_INSTANCE_DISPLAY_NAME } from '$env/static/public';
|
||||||
import type { Post } from '$lib//mastodon/response';
|
import type { Post } from '$lib//mastodon/response';
|
||||||
import { Logger } from '$lib/log';
|
import { Logger } from '$lib/log';
|
||||||
@ -10,7 +11,7 @@ const logger = new Logger('RSS');
|
|||||||
|
|
||||||
export function createFeed(posts: Post[]): Feed {
|
export function createFeed(posts: Post[]): Feed {
|
||||||
const baseUrl = BASE_URL.endsWith('/') ? BASE_URL : BASE_URL + '/';
|
const baseUrl = BASE_URL.endsWith('/') ? BASE_URL : BASE_URL + '/';
|
||||||
const hub = WEBSUB_HUB ? WEBSUB_HUB : undefined;
|
const hub = PUBLIC_WEBSUB_HUB ? PUBLIC_WEBSUB_HUB : undefined;
|
||||||
const feed = new Feed({
|
const feed = new Feed({
|
||||||
title: `${PUBLIC_MASTODON_INSTANCE_DISPLAY_NAME} music feed`,
|
title: `${PUBLIC_MASTODON_INSTANCE_DISPLAY_NAME} music feed`,
|
||||||
description: `Posts about music on ${PUBLIC_MASTODON_INSTANCE_DISPLAY_NAME}`,
|
description: `Posts about music on ${PUBLIC_MASTODON_INSTANCE_DISPLAY_NAME}`,
|
||||||
@ -51,15 +52,15 @@ export function createFeed(posts: Post[]): Feed {
|
|||||||
}
|
}
|
||||||
export async function saveAtomFeed(feed: Feed) {
|
export async function saveAtomFeed(feed: Feed) {
|
||||||
await fs.writeFile('feed.xml', feed.atom1(), { encoding: 'utf8' });
|
await fs.writeFile('feed.xml', feed.atom1(), { encoding: 'utf8' });
|
||||||
if (!WEBSUB_HUB || !PROD) {
|
if (!PUBLIC_WEBSUB_HUB || !PROD) {
|
||||||
logger.info('Skipping Websub publish. hub configured?', WEBSUB_HUB, 'Production?', PROD);
|
logger.info('Skipping Websub publish. hub configured?', PUBLIC_WEBSUB_HUB, 'Production?', PROD);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const param = new FormData();
|
const param = new FormData();
|
||||||
param.append('hub.mode', 'publish');
|
param.append('hub.mode', 'publish');
|
||||||
param.append('hub.url', `${BASE_URL}/feed.xml`);
|
param.append('hub.url', `${BASE_URL}/feed.xml`);
|
||||||
await fetch(WEBSUB_HUB, {
|
await fetch(PUBLIC_WEBSUB_HUB, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
||||||
body: param
|
body: param
|
||||||
|
Reference in New Issue
Block a user