Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add playlist RSS #609

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion audit-ci.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
"GHSA-pxg6-pf52-xh8x|@lhci/cli>*", // Used by lighthouse CI, not at runtime
"GHSA-pxg6-pf52-xh8x|@lhci/utils>*", // Used by lighthouse CI, not at runtime
"GHSA-pxg6-pf52-xh8x|express>cookie", // Used by lighthouse CI, not at runtime
"GHSA-3xgq-45jj-v275" // cross-spawn is used by @next/eslint-plugin-next, audit-ci, cross-env, eslint, and jest. It is not used at runtime
"GHSA-3xgq-45jj-v275", // cross-spawn is used by @next/eslint-plugin-next, audit-ci, cross-env, eslint, and jest. It is not used at runtime
"GHSA-7gfc-8cq8-jh5f", // If your Next.js application is hosted on Vercel, this vulnerability has been automatically mitigated, regardless of Next.js version
"GHSA-mwcw-c2x4-8c55" // Not used at runtime
]
}
16 changes: 9 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions src/containers/library/playlist/detail.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,16 @@ query getPlaylistPageData($id: ID!) {
}
}
}

query getPlaylistFeedData($id: ID!) {
playlist(id: $id) {
id
title
summary
recordings(offset: 0, first: 1500) {
nodes {
...generateFeed
}
}
}
}
4 changes: 4 additions & 0 deletions src/containers/library/playlist/detail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ function PlaylistDetail({ playlist }: Must<IPlaylistDetailProps>): JSX.Element {
) : (
<ButtonShare
shareUrl={`https://audioverse.org/${languageRoute}/playlists/${id}`}
rssUrl={root
.lang(languageRoute)
.playlists.playlist(id)
.feed.get()}
backgroundColor={BaseColors.CREAM}
light={true}
contentType="PLAYLIST"
Expand Down
5 changes: 4 additions & 1 deletion src/containers/sponsor/detail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,10 @@ function SponsorDetail({ sponsor }: Must<SponsorDetailProps>): JSX.Element {
emailSubject={title}
light
triggerClassName={styles.iconButton}
rssUrl={root.lang(languageRoute).sponsors.id(id).feed.get()}
rssUrl={root
.lang(languageRoute)
.sponsors.id(id)
.teachings.feed.get()}
contentType={CatalogEntityType.Sponsor}
id={id}
title={title}
Expand Down
5 changes: 4 additions & 1 deletion src/containers/sponsor/teachings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ function SponsorTeachings({
return (
<SponsorPivot {...{ sponsor }}>
<RssAlternate
url={root.lang(languageRoute).sponsors.id(sponsor.id).feed.get()}
url={root
.lang(languageRoute)
.sponsors.id(sponsor.id)
.teachings.feed.get()}
/>
<LineHeading color={BaseColors.RED}>
<FormattedMessage
Expand Down
1 change: 1 addition & 0 deletions src/lib/routes/playlists.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import node from './primatives/node';
const playlists = (r: string) => ({
playlist: (playlistId: string | number) =>
node(`${r}/${playlistId}`, (r) => ({
feed: node(`${r}/feed.xml`),
items: (canonicalPath: string) =>
node(`${r}/items/${canonicalPath.split('/').slice(3).join('/')}`),
})),
Expand Down
5 changes: 3 additions & 2 deletions src/lib/routes/sponsors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ import paginatedNode from './primatives/paginatedNode';
const sponsors = (r: string) => ({
id: (sponsorId: Scalars['ID']['output']) =>
node(`${r}/${sponsorId}`, (r) => ({
feed: node(`${r}/feed.xml`),
teachings: paginatedNode(`${r}/teachings`),
teachings: paginatedNode(`${r}/teachings`, (r) => ({
feed: node(`${r}/feed.xml`),
})),
conferences: paginatedNode(`${r}/conferences`),
series: paginatedNode(`${r}/series`),
})),
Expand Down
50 changes: 50 additions & 0 deletions src/pages/[language]/playlists/[playlist]/feed.xml/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { GetServerSidePropsContext, GetServerSidePropsResult } from 'next';

import { generateFeed, sendRSSHeaders } from '~lib/generateFeed';
import { getPlaylistFeedData } from '~src/containers/library/playlist/__generated__/detail';
import root from '~src/lib/routes';

export default (): void => void 0;

export async function getServerSideProps({
params,
res,
}: GetServerSidePropsContext<{ language: string; playlist: string }>): Promise<
GetServerSidePropsResult<Record<string, unknown>>
> {
const id = params?.playlist as string;
const languageRoute = params?.language as string;

const { playlist } = await getPlaylistFeedData({
id,
}).catch(() => ({
playlist: null,
}));

if (!playlist) {
return {
notFound: true,
};
}

if (res) {
sendRSSHeaders(res);

const feed = await generateFeed(
languageRoute,
{
link: root.lang(languageRoute).playlists.playlist(id).get(),
title: playlist.title,
description: playlist.summary,
},
playlist.recordings.nodes || [],
);
res.write(feed);

res.end();
}

return {
props: {},
};
}
Loading