Skip to content

Commit

Permalink
feat: add stations radiocut url (#178)
Browse files Browse the repository at this point in the history
  • Loading branch information
ramiroaisen authored Sep 21, 2023
2 parents 48475fd + 35c7bca commit 1451651
Show file tree
Hide file tree
Showing 27 changed files with 91 additions and 2 deletions.
1 change: 1 addition & 0 deletions defs/UserPublicStation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export type UserPublicStation = {
tiktok_url: string | null;
youtube_url: string | null;
spotify_url: string | null;
radiocut_url: string | null;
app_store_url: string | null;
google_play_url: string | null;
user_metadata: Metadata;
Expand Down
1 change: 1 addition & 0 deletions defs/api/stations/POST/Payload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export type Payload = {
twitch_url: string | null;
tiktok_url: string | null;
spotify_url: string | null;
radiocut_url: string | null;
google_play_url: string | null;
app_store_url: string | null;
frequency: StationFrequency | null;
Expand Down
1 change: 1 addition & 0 deletions defs/db/Station.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export type Station = {
twitch_url: string | null;
tiktok_url: string | null;
spotify_url: string | null;
radiocut_url: string | null;
google_play_url: string | null;
app_store_url: string | null;
user_metadata: Metadata;
Expand Down
1 change: 1 addition & 0 deletions defs/ops/StationPatch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export type StationPatch = {
twitch_url?: string | null;
tiktok_url?: string | null;
spotify_url?: string | null;
radiocut_url?: string | null;
google_play_url?: string | null;
app_store_url?: string | null;
external_relay_url?: string | null;
Expand Down
17 changes: 16 additions & 1 deletion front/app/src/lib/components/StationProfile.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<script lang="ts">
import {
mdiApple,
mdiContentCut,
mdiFacebook,
mdiGooglePlay,
mdiInstagram,
Expand Down Expand Up @@ -38,6 +39,7 @@
_google_play_url,
_tiktok_url,
_spotify_url,
_radiocut_url,
} from '$share/formy/validate';
import { VALIDATE_STATION_DESC_MAX_LEN, VALIDATE_STATION_EMAIL_MAX_LEN, VALIDATE_STATION_NAME_MAX_LEN, VALIDATE_STATION_NAME_MIN_LEN, VALIDATE_STATION_PHONE_MAX_LEN, VALIDATE_STATION_SLOGAN_MAX_LEN, VALIDATE_STATION_URLS_MAX_LEN, VALIDATE_STATION_WHATSAPP_MAX_LEN } from "$server/defs/constants";
import CountryField from '$share/Form/CountryField.svelte';
Expand Down Expand Up @@ -80,10 +82,11 @@
twitch_url: string | null;
tiktok_url: string | null;
spotify_url: string | null;
radiocut_url: string | null,
google_play_url: string | null;
app_store_url: string | null;
user_metadata: {
mob_app: {
base_color: string
Expand Down Expand Up @@ -411,6 +414,18 @@
<Validator value={current.spotify_url} fn={_spotify_url({ maxlen: VALIDATE_STATION_URLS_MAX_LEN })} />
</div>

<div class="field">
<NullTextField
type="url"
label={$locale.station_profile.labels.radiocut}
trim
maxlength={VALIDATE_STATION_URLS_MAX_LEN}
icon={mdiContentCut}
bind:value={current.radiocut_url}
/>
<Validator value={current.radiocut_url} fn={_radiocut_url({ maxlen: VALIDATE_STATION_URLS_MAX_LEN })} />
</div>


</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
twitch_url: data.station.twitch_url,
tiktok_url: data.station.tiktok_url,
spotify_url: data.station.spotify_url,
radiocut_url: data.station.radiocut_url,
google_play_url: data.station.google_play_url,
app_store_url: data.station.app_store_url,
picture_id: data.station.picture_id as string | null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
twitch_url: null as string | null,
tiktok_url: null as string | null,
spotify_url: null as string | null,
radiocut_url: null as string | null,
google_play_url: null as string | null,
app_store_url: null as string | null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const locale: import("./station-profile.locale").StationProfileLocale = {
"youtube": "URL ليوتيوب",
"twitch": "URL لتويتش",
"spotify": "URL لسبوتيفاي",
"radiocut": "URL لراديوكات",
"google_play": "URL لجوجل بلاي",
"app_store": "URL لمتجر التطبيقات",

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const locale: import("./station-profile.locale").StationProfileLocale = {
"youtube": "Youtube-URL",
"twitch": "Twitch-URL",
"spotify": "Spotify-URL",
"radiocut": "RadioCut-URL",
"google_play": "Google Play-URL",
"app_store": "App Store-URL",

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const locale = {
"youtube": "Youtube URL",
"twitch": "Twitch URL",
"spotify": "Spotify URL",
"radiocut": "RadioCut URL",
"google_play": "Google Play URL",
"app_store": "App Store URL",

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const locale: import("./station-profile.locale").StationProfileLocale = {
"youtube": "URL de Youtube",
"twitch": "URL de Twitch",
"spotify": "URL de Spotify",
"radiocut": "URL de RadioCut",
"google_play": "URL de Google Play",
"app_store": "URL de App Store",

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const locale: import("./station-profile.locale").StationProfileLocale = {
"youtube": "URL de Youtube",
"twitch": "URL de Twitch",
"spotify": "URL de Spotify",
"radiocut": "URL de RadioCut",
"google_play": "URL de Google Play",
"app_store": "URL de l'App Store",

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const locale: import("./station-profile.locale").StationProfileLocale = {
"youtube": "URL di Youtube",
"twitch": "URL di Twitch",
"spotify": "URL di Spotify",
"radiocut": "URL di RadioCut",
"google_play": "URL di Google Play",
"app_store": "URL di App Store",

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const locale: import("./station-profile.locale").StationProfileLocale = {
"youtube": "URL do Youtube",
"twitch": "URL do Twitch",
"spotify": "URL do Spotify",
"radiocut": "URL do RadioCut",
"google_play": "URL do Google Play",
"app_store": "URL da App Store",

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const locale: import("./station-profile.locale").StationProfileLocale = {
"youtube": "Youtube的URL",
"twitch": "Twitch的URL",
"spotify": "Spotify的URL",
"radiocut": "RadioCut的URL",
"google_play": "Google Play的URL",
"app_store": "App Store的URL",

Expand Down
1 change: 1 addition & 0 deletions front/server/src/locale/share/validate/validate.ar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const locale: import("./validate.locale").ValidateLocale = {
"twitch_url": "يجب أن يكون هذا الحقل عنوان URL لـ Twitch صالح، انتقل إلى صفحتك على Twitch وانسخ العنوان الكامل من هناك",
"tiktok_url": "يجب أن يكون هذا الحقل عنوان URL لـ TikTok صالح، انتقل إلى صفحتك على TikTok وانسخ العنوان الكامل من هناك",
"spotify_url": "يجب أن يكون هذا الحقل عنوان URL لـ Spotify صالح، انتقل إلى صفحتك على Spotify وانسخ العنوان الكامل من هناك",
"radiocut_url": "يجب أن يكون هذا الحقل عنوان URL لـ RadioCut صالح، انتقل إلى صفحتك على RadioCut وانسخ العنوان الكامل من هناك",
"google_play_url": "يجب أن يكون هذا الحقل عنوان URL لـ Google Play صالح، انتقل إلى صفحة التطبيق الخاص بك على Google Play وانسخ العنوان الكامل من هناك",
"app_store_url": "يجب أن يكون هذا الحقل عنوان URL لـ App Store صالح، انتقل إلى صفحة التطبيق الخاص بك على App Store وانسخ العنوان الكامل من هناك",
}
Expand Down
1 change: 1 addition & 0 deletions front/server/src/locale/share/validate/validate.de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const locale: import("./validate.locale").ValidateLocale = {
"twitch_url": "Dieses Feld muss eine gültige Twitch-URL sein, navigieren Sie zu Ihrer Twitch-Seite und kopieren Sie die vollständige URL von dort",
"tiktok_url": "Dieses Feld muss eine gültige TikTok-URL sein, navigieren Sie zu Ihrer TikTok-Seite und kopieren Sie die vollständige URL von dort",
"spotify_url": "Dieses Feld muss eine gültige Spotify-URL sein, navigieren Sie zu Ihrer Spotify-Seite und kopieren Sie die vollständige URL von dort",
"radiocut_url": "Dieses Feld muss eine gültige RadioCut-URL sein, navigieren Sie zu Ihrer RadioCut-Seite und kopieren Sie die vollständige URL von dort",
"google_play_url": "Dieses Feld muss eine gültige Google Play-URL sein, navigieren Sie zu Ihrer App-Seite auf Google Play und kopieren Sie die vollständige URL von dort",
"app_store_url": "Dieses Feld muss eine gültige App Store-URL sein, navigieren Sie zu Ihrer App-Seite im App Store und kopieren Sie die vollständige URL von dort",
}
Expand Down
2 changes: 2 additions & 0 deletions front/server/src/locale/share/validate/validate.en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ const locale = {
"twitch_url": "This field must be a valid Twitch URL, navigate to your Twitch page and copy the entire URL from there",
"tiktok_url": "This field must be a valid TikTok URL, navigate to your TikTok page and copy the entire URL from there",
"spotify_url": "This field must be a valid Spotify URL, navigate to your Spotify page and copy the entire URL from there",
"radiocut_url": "This field must be a valid RadioCut URL, navigate to your RadioCut page and copy the entire URL from there",
"google_play_url": "This field must be a valid Google Play URL, navigate to your app's page at Google Play and copy the entire URL from there",
"app_store_url": "This field must be a valid App Store URL, navigate to your app's page at App Store and copy the entire URL from there",

}

export default locale;
1 change: 1 addition & 0 deletions front/server/src/locale/share/validate/validate.es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const locale: import("./validate.locale").ValidateLocale = {
"twitch_url": "Este campo debe ser una URL de Twitch válida, navega hasta tu página de Twitch y copia la URL completa desde allí",
"tiktok_url": "Este campo debe ser una URL de TikTok válida, navega hasta tu página de TikTok y copia la URL completa desde allí",
"spotify_url": "Este campo debe ser una URL de Spotify válida, navega hasta tu página de Spotify y copia la URL completa desde allí",
"radiocut_url": "Este campo debe ser una URL de RadioCut válida, navega hasta tu página de RadioCut y copia la URL completa desde allí",
"google_play_url": "Este campo debe ser una URL de Google Play válida, navega hasta la página de tu aplicación en Google Play y copia la URL completa desde allí",
"app_store_url": "Este campo debe ser una URL de App Store válida, navega hasta la página de tu aplicación en App Store y copia la URL completa desde allí",
}
Expand Down
1 change: 1 addition & 0 deletions front/server/src/locale/share/validate/validate.fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const locale: import("./validate.locale").ValidateLocale = {
"twitch_url": "Ce champ doit être une URL Twitch valide, naviguez jusqu'à votre page Twitch et copiez l'URL complète à partir de là",
"tiktok_url": "Ce champ doit être une URL TikTok valide, naviguez jusqu'à votre page TikTok et copiez l'URL complète à partir de là",
"spotify_url": "Ce champ doit être une URL Spotify valide, naviguez jusqu'à votre page Spotify et copiez l'URL complète à partir de là",
"radiocut_url": "Ce champ doit être une URL RadioCut valide, naviguez jusqu'à votre page RadioCut et copiez l'URL complète à partir de là",
"google_play_url": "Ce champ doit être une URL Google Play valide, naviguez jusqu'à la page de votre application sur Google Play et copiez l'URL complète à partir de là",
"app_store_url": "Ce champ doit être une URL App Store valide, naviguez jusqu'à la page de votre application sur App Store et copiez l'URL complète à partir de là",
}
Expand Down
1 change: 1 addition & 0 deletions front/server/src/locale/share/validate/validate.it.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const locale: import("./validate.locale").ValidateLocale = {
"twitch_url": "Questo campo deve essere un URL di Twitch valido, vai alla tua pagina Twitch e copia l'URL completo da lì",
"tiktok_url": "Questo campo deve essere un URL di TikTok valido, vai alla tua pagina TikTok e copia l'URL completo da lì",
"spotify_url": "Questo campo deve essere un URL di Spotify valido, vai alla tua pagina Spotify e copia l'URL completo da lì",
"radiocut_url": "Questo campo deve essere un URL di RadioCut valido, vai alla tua pagina RadioCut e copia l'URL completo da lì",
"google_play_url": "Questo campo deve essere un URL di Google Play valido, vai alla pagina della tua app su Google Play e copia l'URL completo da lì",
"app_store_url": "Questo campo deve essere un URL di App Store valido, vai alla pagina della tua app su App Store e copia l'URL completo da lì",
}
Expand Down
1 change: 1 addition & 0 deletions front/server/src/locale/share/validate/validate.pt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const locale: import("./validate.locale").ValidateLocale = {
"twitch_url": "Este campo deve ser uma URL do Twitch válida, navegue até a sua página do Twitch e copie a URL completa de lá",
"tiktok_url": "Este campo deve ser uma URL do TikTok válida, navegue até a sua página do TikTok e copie a URL completa de lá",
"spotify_url": "Este campo deve ser uma URL do Spotify válida, navegue até a sua página do Spotify e copie a URL completa de lá",
"radiocut_url": "Este campo deve ser uma URL do RadioCut válida, navegue até a sua página do RadioCut e copie a URL completa de lá",
"google_play_url": "Este campo deve ser uma URL do Google Play válida, navegue até a página do seu aplicativo no Google Play e copie a URL completa de lá",
"app_store_url": "Este campo deve ser uma URL da App Store válida, navegue até a página do seu aplicativo na App Store e copie a URL completa de lá",
}
Expand Down
1 change: 1 addition & 0 deletions front/server/src/locale/share/validate/validate.zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const locale: import("./validate.locale").ValidateLocale = {
"twitch_url": "此字段必须是有效的Twitch URL,导航到你的Twitch页面并从那里复制完整的URL",
"tiktok_url": "此字段必须是有效的TikTok URL,导航到你的TikTok页面并从那里复制完整的URL",
"spotify_url": "此字段必须是有效的Spotify URL,导航到你的Spotify页面并从那里复制完整的URL",
"radiocut_url": "此字段必须是有效的RadioCut URL,导航到你的RadioCut页面并从那里复制完整的URL",
"google_play_url": "此字段必须是有效的Google Play URL,导航到你在Google Play的应用页面并从那里复制完整的URL",
"app_store_url": "此字段必须是有效的App Store URL,导航到你在App Store的应用页面并从那里复制完整的URL",
}
Expand Down
2 changes: 2 additions & 0 deletions front/share/src/formy/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const YOUTUBE = /^https:\/\/www\.youtube\.com\/.+/;
export const TWITCH = /^https:\/\/www\.twitch\.tv\/.+/;
export const TIKTOK = /^https:\/\/www\.tiktok\.com\/.+/;
export const SPOTIFY = /^https:\/\/open\.spotify\.com\/.+/;
export const RADIOCUT = /^https:\/\/radiocut\.fm\/.+/;
export const GOOGLE_PLAY = /^https:\/\/play\.google\.com\/.+/;
export const APP_STORE = /^https:\/\/apps\.apple\.com\/.+/;

Expand Down Expand Up @@ -330,5 +331,6 @@ export const _youtube_url = Pattern(YOUTUBE, () => get(locale).validate.youtube_
export const _twitch_url = Pattern(TWITCH, () => get(locale).validate.twitch_url);
export const _tiktok_url = Pattern(TIKTOK, () => get(locale).validate.tiktok_url);
export const _spotify_url = Pattern(SPOTIFY, () => get(locale).validate.spotify_url);
export const _radiocut_url = Pattern(RADIOCUT, () => get(locale).validate.radiocut_url);
export const _google_play_url = Pattern(GOOGLE_PLAY, () => get(locale).validate.google_play_url);
export const _app_store_url = Pattern(APP_STORE, () => get(locale).validate.app_store_url);
14 changes: 14 additions & 0 deletions rs/packages/api/src/routes/stations/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,18 @@ pub mod post {
)]
pub spotify_url: Option<String>,

#[modify(trim)]
#[validate(
url(message = "RadioCut URL is invalid"),
regex(path = "RADIOCUT", message = "RadioCut URL is invalid"),
length(
max = "VALIDATE_STATION_URLS_MAX_LEN",
message = "RadioCut URL is invalid"
),
non_control_character(message = "RadioCut URL cannot have control characters")
)]
pub radiocut_url: Option<String>,

//#[serde(skip_serializing_if = "Option::is_none")]
#[modify(trim)]
#[validate(
Expand Down Expand Up @@ -539,6 +551,7 @@ pub mod post {
twitch_url,
tiktok_url,
spotify_url,
radiocut_url,

google_play_url,
app_store_url,
Expand Down Expand Up @@ -596,6 +609,7 @@ pub mod post {
twitch_url,
tiktok_url,
spotify_url,
radiocut_url,

app_store_url,
google_play_url,
Expand Down
33 changes: 33 additions & 0 deletions rs/packages/db/src/models/station/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,18 @@ pub struct Station {
)]
pub spotify_url: Option<String>,

#[modify(trim)]
#[validate(
url(message = "RadioCut URL is invalid"),
regex(path = "RADIOCUT", message = "RadioCut URL is invalid"),
length(
max = "VALIDATE_STATION_URLS_MAX_LEN",
message = "RadioCut URL is invalid"
),
non_control_character(message = "RadioCut URL cannot have control characters")
)]
pub radiocut_url: Option<String>,

// app links
#[modify(trim)]
#[validate(
Expand Down Expand Up @@ -355,6 +367,7 @@ pub struct UserPublicStation {
pub tiktok_url: Option<String>,
pub youtube_url: Option<String>,
pub spotify_url: Option<String>,
pub radiocut_url: Option<String>,

// app links
pub app_store_url: Option<String>,
Expand Down Expand Up @@ -702,6 +715,24 @@ pub struct StationPatch {
)]
pub spotify_url: Option<Option<String>>,

#[ts(optional)]
#[serde(
default,
deserialize_with = "map_some",
skip_serializing_if = "Option::is_none"
)]
#[modify(trim)]
#[validate(
url(message = "RadioCut URL is invalid"),
regex(path = "RADIOCUT", message = "RadioCut URL is invalid"),
length(
max = "VALIDATE_STATION_URLS_MAX_LEN",
message = "RadioCut URL is invalid"
),
non_control_character(message = "RadioCut URL cannot have control characters")
)]
pub radiocut_url: Option<Option<String>>,

// app links
#[ts(optional)]
#[serde(
Expand Down Expand Up @@ -876,6 +907,7 @@ impl Station {
apply!(twitch_url);
apply!(tiktok_url);
apply!(spotify_url);
apply!(radiocut_url);

apply!(google_play_url);
apply!(app_store_url);
Expand Down Expand Up @@ -944,6 +976,7 @@ impl From<Station> for UserPublicStation {
tiktok_url: station.tiktok_url,
youtube_url: station.youtube_url,
spotify_url: station.spotify_url,
radiocut_url: station.radiocut_url,

app_store_url: station.app_store_url,
google_play_url: station.google_play_url,
Expand Down
3 changes: 2 additions & 1 deletion rs/packages/validate/src/url.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ pub mod patterns {
pub static THREADS: Lazy<Regex> = lazy_regex!(r#"^https://www\.threads\.net/.+"#);
pub static YOUTUBE: Lazy<Regex> = lazy_regex!(r#"^https://www\.youtube\.com/.+"#);
pub static TWITCH: Lazy<Regex> = lazy_regex!(r#"^https://www\.twitch\.tv/.+"#);
pub static SPOTIFY: Lazy<Regex> = lazy_regex!(r#"^https://open\.spotify\.com/.+"#);
pub static TIKTOK: Lazy<Regex> = lazy_regex!(r#"^https://www\.tiktok\.com/.+"#);
pub static SPOTIFY: Lazy<Regex> = lazy_regex!(r#"^https://open\.spotify\.com/.+"#);
pub static RADIOCUT: Lazy<Regex> = lazy_regex!(r#"^https://radiocut\.fm/.+"#);
pub static GOOGLE_PLAY: Lazy<Regex> = lazy_regex!(r#"^https://play\.google\.com/.+"#);
pub static APP_STORE: Lazy<Regex> = lazy_regex!(r#"^https://apps\.apple\.com/.+"#);
}

0 comments on commit 1451651

Please sign in to comment.