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

LB-1585: Add Syndication Feeds to ListenBrainz #2962

Open
wants to merge 40 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
47753bc
implement playlist feed
ericd23 Jul 22, 2024
c737067
typos
ericd23 Jul 22, 2024
533ec5b
implement recommendation feed
ericd23 Jul 24, 2024
300c3ac
format and add template
ericd23 Jul 24, 2024
bcd811f
add test for playlist
ericd23 Jul 26, 2024
a5ea863
syndication feed modal component
ericd23 Aug 7, 2024
a95b521
add button to subscribe to listen feed
ericd23 Aug 9, 2024
2991df7
implement stats art feed
ericd23 Aug 15, 2024
ebea01f
add stat art template
ericd23 Aug 15, 2024
907a3fe
restyle feed modal
ericd23 Aug 15, 2024
19121f4
use feed icon and move it to the bottom
ericd23 Aug 15, 2024
81a1cea
feed modal supports numbers, default value and alternative displaying…
ericd23 Aug 16, 2024
7c7082f
add feed icon for user stats
ericd23 Aug 16, 2024
51346b9
add feed button for fresh releases
ericd23 Aug 17, 2024
715268a
fix freshreleases test
ericd23 Aug 18, 2024
316dd20
add feed button for stats art
ericd23 Aug 18, 2024
06c7330
add feed button for playlist
ericd23 Aug 19, 2024
c0d4420
add feed button for recommendation
ericd23 Aug 19, 2024
73653d1
use HTMLInputTypeAttribute
ericd23 Aug 21, 2024
1558e42
use global context to access current user
ericd23 Aug 21, 2024
9c16f77
restyle feed button
ericd23 Aug 21, 2024
28d8232
capitalize "Explore" in fresh_releases.html
ericd23 Aug 21, 2024
e30400c
add tooltip to explain feed options
ericd23 Aug 21, 2024
553a36f
feed for latest activity
ericd23 Aug 25, 2024
dd54ea9
feed button for latest activity
ericd23 Aug 25, 2024
e1894ce
use baseUrl to construct feed URLs
ericd23 Aug 25, 2024
873119c
add tool tips
ericd23 Aug 25, 2024
1d7753f
format
ericd23 Aug 25, 2024
60d4ea9
remove stale code
ericd23 Aug 26, 2024
b9bd566
no trailing ? for feed URL when there's no option
ericd23 Aug 26, 2024
d254ca6
load recordings in recommendation feed
ericd23 Aug 28, 2024
8ab64ac
commented out latest activity feed for now
ericd23 Aug 31, 2024
d49423f
Merge branch 'metabrainz:master' into syndication-feed
ericd23 Sep 18, 2024
928f641
rename time range option for stats
ericd23 Sep 18, 2024
b64aee6
unifying tooltime for minutes (time range) options
ericd23 Sep 18, 2024
e52686b
reposition feed button
ericd23 Sep 19, 2024
de9ad29
add lb suffix to playlist feed title
ericd23 Sep 19, 2024
e6fae66
avoid using events in title
ericd23 Sep 19, 2024
ceff7ac
Merge branch 'master' into syndication-feed
MonkeyDo Oct 21, 2024
7ede901
Lint less file
MonkeyDo Oct 21, 2024
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
53 changes: 53 additions & 0 deletions frontend/js/src/explore/fresh-releases/FreshReleases.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,19 @@ import { toast } from "react-toastify";
import { Helmet } from "react-helmet";
import { useQuery } from "@tanstack/react-query";
import { useNavigate } from "react-router-dom";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faRss, faSquareRss } from "@fortawesome/free-solid-svg-icons";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

faSquareRss seems unused here

import NiceModal from "@ebay/nice-modal-react";
import GlobalAppContext from "../../utils/GlobalAppContext";
import { ToastMsg } from "../../notifications/Notifications";
import ReleaseFilters from "./components/ReleaseFilters";
import ReleaseTimeline from "./components/ReleaseTimeline";
import Pill from "../../components/Pill";
import ReleaseCardsGrid from "./components/ReleaseCardsGrid";
import { COLOR_LB_ORANGE } from "../../utils/constants";
import { useMediaQuery } from "./utils";
import SyndicationFeedModal from "../../components/SyndicationFeedModal";
import { getBaseUrl } from "../../utils/utils";

export enum DisplaySettingsPropertiesEnum {
releaseTitle = "Release Title",
Expand Down Expand Up @@ -370,6 +376,53 @@ export default function FreshReleases() {
))}
</select>
</div>
<button
type="button"
className="btn btn-icon btn-info btn-sm"
style={{
width: "24px",
height: "24px",
display: "flex",
alignItems: "center",
justifyContent: "center",
}}
data-toggle="modal"
data-target="#SyndicationFeedModal"
onClick={() => {
if (pageType === PAGE_TYPE_SITEWIDE) {
NiceModal.show(SyndicationFeedModal, {
feedTitle: `Site-wide Fresh Releases`,
options: [
{
label: "Days",
key: "days",
type: "number",
values: [
{ id: "3", value: "3" },
{ id: "7", value: "7" },
{ id: "14", value: "14" },
{ id: "30", value: "30" },
],
defaultIndex: 0,
tooltip:
"Select how many days of past releases to include in the feed, starting from today. Only releases that have already been published will be included.",
},
],
baseUrl: `${getBaseUrl()}/syndication-feed/fresh-releases`,
});
} else if (pageType === PAGE_TYPE_USER) {
NiceModal.show(SyndicationFeedModal, {
feedTitle: `User-specific Fresh Releases`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be customized?

`${currentUser.name}'s Fresh Releases`

options: [],
baseUrl: `${getBaseUrl()}/syndication-feed/user/${
currentUser.name
}/fresh-releases`,
});
}
}}
>
<FontAwesomeIcon icon={faRss} size="xs" />
</button>
</div>
</div>
{isLoading ? (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,17 @@
import * as React from "react";
import {
faChevronDown,
faChevronUp,
faSquareRss,
} from "@fortawesome/free-solid-svg-icons";
import { faChevronDown, faChevronUp } from "@fortawesome/free-solid-svg-icons";
import { faCircleXmark } from "@fortawesome/free-regular-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import * as _ from "lodash";
import NiceModal from "@ebay/nice-modal-react";
import Switch from "../../../components/Switch";
import SideBar from "../../../components/Sidebar";
import type {
DisplaySettingsPropertiesEnum,
DisplaySettings,
filterRangeOption,
} from "../FreshReleases";
import {
PAGE_TYPE_SITEWIDE,
PAGE_TYPE_USER,
filterRangeOptions,
} from "../FreshReleases";
import SyndicationFeedModal from "../../../components/SyndicationFeedModal";
import { PAGE_TYPE_SITEWIDE, filterRangeOptions } from "../FreshReleases";
import GlobalAppContext from "../../../utils/GlobalAppContext";
import { getBaseUrl } from "../../../utils/utils";

const VARIOUS_ARTISTS_MBID = "89ad4ac3-39f7-470e-963a-56509c546377";

Expand Down Expand Up @@ -235,45 +224,6 @@ export default function ReleaseFilters(props: ReleaseFiltersProps) {
Check out all releases worldwide, or just from artists you&apos;ve
listened to before, with &apos;for you&apos;.
</p>
<FontAwesomeIcon
role="button"
icon={faSquareRss}
size="lg"
data-toggle="modal"
data-target="#SyndicationFeedModal"
onClick={() => {
if (pageType === PAGE_TYPE_SITEWIDE) {
NiceModal.show(SyndicationFeedModal, {
feedTitle: `Site-wide Fresh Releases`,
options: [
{
label: "Days",
key: "days",
type: "number",
values: [
{ id: "3", value: "3" },
{ id: "7", value: "7" },
{ id: "14", value: "14" },
{ id: "30", value: "30" },
],
defaultIndex: 0,
tooltip:
"Select how many days of past releases to include in the feed, starting from today. Only releases that have already been published will be included.",
},
],
baseUrl: `${getBaseUrl()}/syndication-feed/fresh-releases`,
});
} else if (pageType === PAGE_TYPE_USER) {
NiceModal.show(SyndicationFeedModal, {
feedTitle: `User-specific Fresh Releases`,
options: [],
baseUrl: `${getBaseUrl()}/syndication-feed/user/${
currentUser.name
}/fresh-releases`,
});
}
}}
/>
</div>
<div className="sidenav-content-grid">
<div
Expand Down
87 changes: 50 additions & 37 deletions frontend/js/src/playlists/Playlist.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -337,51 +337,64 @@ export default function PlaylistPage() {
<h1 className="title">
<div>
{playlist.title}
<span className="dropdown pull-right">
<button
className="btn btn-info dropdown-toggle"
type="button"
id="playlistOptionsDropdown"
data-toggle="dropdown"
aria-haspopup="true"
aria-expanded="true"
<div className="pull-right">
<div
style={{
display: "flex",
alignItems: "center",
}}
>
<FontAwesomeIcon icon={faCog as IconProp} title="Options" />
&nbsp;Options
</button>
<PlaylistMenu
playlist={playlist}
onPlaylistSaved={onPlaylistSave}
onPlaylistDeleted={onDeletePlaylist}
disallowEmptyPlaylistExport
/>
</span>
<span className="dropdown">
<button
className="btn btn-info dropdown-toggle"
type="button"
id="playlistOptionsDropdown"
data-toggle="dropdown"
aria-haspopup="true"
aria-expanded="true"
>
<FontAwesomeIcon
icon={faCog as IconProp}
title="Options"
/>
&nbsp;Options
</button>
<PlaylistMenu
playlist={playlist}
onPlaylistSaved={onPlaylistSave}
onPlaylistDeleted={onDeletePlaylist}
disallowEmptyPlaylistExport
/>
</span>
{customFields?.public && (
<FontAwesomeIcon
role="button"
icon={faSquareRss}
size="2xs"
className="feed-button"
data-toggle="modal"
data-target="#SyndicationFeedModal"
style={{ marginLeft: "10px", color: "#353070" }}
onClick={() => {
NiceModal.show(SyndicationFeedModal, {
feedTitle: `Playlist`,
options: [],
baseUrl: `${getBaseUrl()}/syndication-feed/playlist/${getPlaylistId(
playlist
)}`,
});
}}
/>
)}
</div>
</div>
</div>
<small>
{customFields?.public ? "Public " : "Private "}
playlist by{" "}
<Link to={sanitizeUrl(`/user/${playlist.creator}/playlists/`)}>
{playlist.creator}
</Link>
{customFields?.public && (
<FontAwesomeIcon
icon={faSquareRss}
size="lg"
className="feed-button"
data-toggle="modal"
data-target="#SyndicationFeedModal"
style={{ marginLeft: "10px" }}
onClick={() => {
NiceModal.show(SyndicationFeedModal, {
feedTitle: `Playlist`,
options: [],
baseUrl: `${getBaseUrl()}/syndication-feed/playlist/${getPlaylistId(
playlist
)}`,
});
}}
/>
)}
</small>
</h1>
<div className="info">
Expand Down
21 changes: 14 additions & 7 deletions frontend/js/src/user-feed/UserFeed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
faComments,
faPaperPlane,
faSquareRss,
faRss,
} from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { IconProp } from "@fortawesome/fontawesome-svg-core";
Expand Down Expand Up @@ -567,11 +568,16 @@ export default function UserFeedPage() {
<div className="listen-header">
<h3 className="header-with-line">Latest activity</h3>
{/* Commented out as new OAuth is not merged yet. */}
{/*
<FontAwesomeIcon
role="button"
icon={faSquareRss}
size="2x"
{/* <button
type="button"
className="btn btn-icon btn-info btn-sm"
style={{
width: "24px",
height: "24px",
display: "flex",
alignItems: "center",
justifyContent: "center",
}}
data-toggle="modal"
data-target="#SyndicationFeedModal"
onClick={() => {
Expand Down Expand Up @@ -623,8 +629,9 @@ export default function UserFeedPage() {
}/events`,
});
}}
/>
*/}
>
<FontAwesomeIcon icon={faRss} size="xs" />
</button> */}
</div>
<div className="row">
<div className="col-md-7 col-xs-12">
Expand Down
Loading