forked from Kieran/snort
Merge pull request #112 from ivanacostarubio/issues/98
feat: soundcloud embed
This commit is contained in:
commit
0f5364a7be
@ -8,7 +8,7 @@
|
|||||||
<meta name="theme-color" content="#000000" />
|
<meta name="theme-color" content="#000000" />
|
||||||
<meta name="description" content="Fast nostr web ui" />
|
<meta name="description" content="Fast nostr web ui" />
|
||||||
<meta http-equiv="Content-Security-Policy"
|
<meta http-equiv="Content-Security-Policy"
|
||||||
content="default-src 'self'; child-src 'none'; worker-src 'self'; frame-src youtube.com www.youtube.com https://platform.twitter.com https://embed.tidal.com; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; connect-src wss://* 'self' https://*; img-src * data:; font-src https://fonts.gstatic.com; media-src *; script-src 'self' https://static.cloudflareinsights.com https://platform.twitter.com https://embed.tidal.com;" />
|
content="default-src 'self'; child-src 'none'; worker-src 'self'; frame-src youtube.com www.youtube.com https://platform.twitter.com https://embed.tidal.com https://w.soundcloud.com; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; connect-src wss://* 'self' https://*; img-src * data:; font-src https://fonts.gstatic.com; media-src *; script-src 'self' https://static.cloudflareinsights.com https://platform.twitter.com https://embed.tidal.com;" />
|
||||||
|
|
||||||
<link rel="apple-touch-icon" href="%PUBLIC_URL%/nostrich_512.png" />
|
<link rel="apple-touch-icon" href="%PUBLIC_URL%/nostrich_512.png" />
|
||||||
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
|
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
|
||||||
|
@ -88,4 +88,10 @@ export const HashtagRegex = /(#[^\s!@#$%^&*()=+.\/,\[{\]};:'"?><]+)/;
|
|||||||
/**
|
/**
|
||||||
* Tidal share link regex
|
* Tidal share link regex
|
||||||
*/
|
*/
|
||||||
export const TidalRegex = /tidal\.com\/(?:browse\/)?(\w+)\/([a-z0-9-]+)/i;
|
export const TidalRegex = /tidal\.com\/(?:browse\/)?(\w+)\/([a-z0-9-]+)/i;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SoundCloud regex
|
||||||
|
*/
|
||||||
|
|
||||||
|
export const SoundCloudRegex = /soundcloud\.com\/(?!live)([a-zA-Z0-9]+)\/([a-zA-Z0-9-]+)/
|
||||||
|
14
src/Element/SoundCloudEmded.tsx
Normal file
14
src/Element/SoundCloudEmded.tsx
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
const SoundCloudEmbed = ({link}: {link: string}) => {
|
||||||
|
|
||||||
|
return(
|
||||||
|
<iframe
|
||||||
|
width="100%"
|
||||||
|
height="166"
|
||||||
|
scrolling="no"
|
||||||
|
allow="autoplay"
|
||||||
|
src={`https://w.soundcloud.com/player/?url=${link}`}>
|
||||||
|
</iframe>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default SoundCloudEmbed;
|
@ -4,7 +4,7 @@ import { Link } from "react-router-dom";
|
|||||||
import ReactMarkdown from "react-markdown";
|
import ReactMarkdown from "react-markdown";
|
||||||
import { TwitterTweetEmbed } from "react-twitter-embed";
|
import { TwitterTweetEmbed } from "react-twitter-embed";
|
||||||
|
|
||||||
import { UrlRegex, FileExtensionRegex, MentionRegex, InvoiceRegex, YoutubeUrlRegex, TweetUrlRegex, HashtagRegex, TidalRegex } from "Const";
|
import { UrlRegex, FileExtensionRegex, MentionRegex, InvoiceRegex, YoutubeUrlRegex, TweetUrlRegex, HashtagRegex, TidalRegex, SoundCloudRegex } from "Const";
|
||||||
import { eventLink, hexToBech32 } from "Util";
|
import { eventLink, hexToBech32 } from "Util";
|
||||||
import Invoice from "Element/Invoice";
|
import Invoice from "Element/Invoice";
|
||||||
import Hashtag from "Element/Hashtag";
|
import Hashtag from "Element/Hashtag";
|
||||||
@ -16,6 +16,7 @@ import TidalEmbed from "Element/TidalEmbed";
|
|||||||
import { useSelector } from 'react-redux';
|
import { useSelector } from 'react-redux';
|
||||||
import { RootState } from 'State/Store';
|
import { RootState } from 'State/Store';
|
||||||
import { UserPreferences } from 'State/Login';
|
import { UserPreferences } from 'State/Login';
|
||||||
|
import SoundCloudEmbed from 'Element/SoundCloudEmded'
|
||||||
|
|
||||||
function transformHttpLink(a: string, pref: UserPreferences) {
|
function transformHttpLink(a: string, pref: UserPreferences) {
|
||||||
try {
|
try {
|
||||||
@ -26,6 +27,7 @@ function transformHttpLink(a: string, pref: UserPreferences) {
|
|||||||
const youtubeId = YoutubeUrlRegex.test(a) && RegExp.$1;
|
const youtubeId = YoutubeUrlRegex.test(a) && RegExp.$1;
|
||||||
const tweetId = TweetUrlRegex.test(a) && RegExp.$2;
|
const tweetId = TweetUrlRegex.test(a) && RegExp.$2;
|
||||||
const tidalId = TidalRegex.test(a) && RegExp.$1;
|
const tidalId = TidalRegex.test(a) && RegExp.$1;
|
||||||
|
const soundcloundId = SoundCloudRegex.test(a) && RegExp.$1;
|
||||||
const extension = FileExtensionRegex.test(url.pathname.toLowerCase()) && RegExp.$1;
|
const extension = FileExtensionRegex.test(url.pathname.toLowerCase()) && RegExp.$1;
|
||||||
if (extension) {
|
if (extension) {
|
||||||
switch (extension) {
|
switch (extension) {
|
||||||
@ -71,6 +73,8 @@ function transformHttpLink(a: string, pref: UserPreferences) {
|
|||||||
)
|
)
|
||||||
} else if (tidalId) {
|
} else if (tidalId) {
|
||||||
return <TidalEmbed link={a} />
|
return <TidalEmbed link={a} />
|
||||||
|
} else if (soundcloundId){
|
||||||
|
return <SoundCloudEmbed link={a} />
|
||||||
} else {
|
} else {
|
||||||
return <a href={a} onClick={(e) => e.stopPropagation()} target="_blank" rel="noreferrer" className="ext">{a}</a>
|
return <a href={a} onClick={(e) => e.stopPropagation()} target="_blank" rel="noreferrer" className="ext">{a}</a>
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user