From c947e3bac787ce96d6a64165dc2b1c00212a0c57 Mon Sep 17 00:00:00 2001 From: Renarde-Dev Date: Wed, 1 May 2024 00:48:31 +0200 Subject: [PATCH] Refactor the project to remove JS and use php --- assets/css/styles.scss | 146 ----------------------------------------- assets/script.js | 29 -------- index.html | 78 ---------------------- index.php | 56 ++++++++++++++++ podcast.php | 62 +++++++++++++++++ 5 files changed, 118 insertions(+), 253 deletions(-) delete mode 100644 assets/css/styles.scss delete mode 100644 assets/script.js delete mode 100644 index.html create mode 100644 index.php create mode 100644 podcast.php diff --git a/assets/css/styles.scss b/assets/css/styles.scss deleted file mode 100644 index dd800a9..0000000 --- a/assets/css/styles.scss +++ /dev/null @@ -1,146 +0,0 @@ -@font-face { - font-family: "Cursive"; - src: url("/assets/fonts/Cursive\ standard.woff2"); -} - -@font-face { - font-family: "Cursive-bold"; - src: url("/assets/fonts/Cursive\ standard\ Bold.woff2"); -} - -// Colors - -:root { - --title-color: #63BAEE; - --bgd-color: #F7F6EE; - --text-color: #2A2A2A; -} - -@media (prefers-color-scheme: dark) { - :root { - --bgd-color: #2A2A2A; - --text-color: #F7F6EE; - } -} - -body { - font-family: "Cursive"; - display: flex; - flex-direction: column; - background-color: var(--bgd-color); - color: var(--text-color); - margin-left: 10%; - margin-right: 10%; - - - h1 { - font-family: "Cursive-bold"; - margin-left: auto; - margin-right: auto; - font-size: xxx-large; - color: var(--title-color); - text-align: center; - } - - .FeedDesc { - font-size: x-large; - text-align: center; - } - - .FollowMe { - display: flex; - flex-direction: row; - - align-items: center; - height: 10vh; - - font-size: x-large; - white-space: nowrap; - - a { - margin-left: 5%; - margin-right: 5%; - display: flex; - flex-direction: row; - text-decoration: none; - height: 100%; - align-items: center; - - p { - margin-left: 5%; - margin-right: 5%; - white-space: nowrap; - } - - img { - height: 25%; - } - } - } - - .listen-on { - display: flex; - flex-direction: row; - - align-items: center; - - font-size: x-large; - white-space: nowrap; - - height: 10vh; - - a { - display: flex; - flex-direction: row; - align-items: center; - margin-left: 5%; - margin-right: 5%; - height: 100%; - - font-family: Verdana, Geneva, Tahoma, sans-serif; - text-decoration: none; - - img { - height: 75%; - } - - .textRSS { - margin-left: 5%; - color: var(--text-color); - } - } - - .rss-listen { - padding-left: 1%; - padding-right: 1%; - - border-radius: 50px; - } - } - - hr { - width: 100%; - } - - .Podcasts { - .podcast { - - h3 { - font-size: xx-large; - } - - audio { - width: 90%; - background-color: #F7F6EE; - margin-left: 1%; - } - - .podcast-desc { - font-size: x-large; - } - } - - - } -} - diff --git a/assets/script.js b/assets/script.js deleted file mode 100644 index 488f8d2..0000000 --- a/assets/script.js +++ /dev/null @@ -1,29 +0,0 @@ -"use strict"; - -function removeAcastBranding(description,removeBR) { // Retire la mention "hébergé par Acast" - let desc = description.replace(/(

\n

).+(<\/p>)/g,""); - if (removeBR) { desc = desc.replace(/
/g,"") } - return desc -} - -async function fetchRSSfeed() { - const RSS_URL = "https://feeds.acast.com/public/shows/le-plus-beau-des-voyages"; - const RSS_API = "https://api.rss2json.com/v1/api.json?rss_url=" - const response = await fetch( RSS_API + RSS_URL); - return await response.json(); -} - -window.addEventListener("DOMContentLoaded", function () { - console.log( - "Hewo, c'est renarde 🦊, la créatrice de ce site.\nSi tu veux trouver le code source du site c'est par ici -> " - + 'https://forgejo.la-taniere-solidaire.gay/Renarde/site-web-le-plus-beau-des-voyages' - ); - - // fetchRSSfeed().then( rssData => { - // document.getElementById("FeedDesc").innerHTML = removeAcastBranding(rssData.feed.description,false); - // for (const episode of rssData.items) { - // const formatedEp = formatEpisodeIntoHTML(episode) - // this.document.getElementById("Podcasts").append(formatedEp) - // } - // }) -}) \ No newline at end of file diff --git a/index.html b/index.html deleted file mode 100644 index f49a715..0000000 --- a/index.html +++ /dev/null @@ -1,78 +0,0 @@ - - - - - - - - - - - - - - - Le plus beau des voyages - - - - - - - - - - -

-

Le plus beau des voyages

-

Animé par Pauline

-
-

- - -
-

Le dernier épisode :

-

- -

-
- - -
- - RSS - - - Apple podcast - - - Amazon Music - - - Google podcast - - - Spotify - -
- - - - - \ No newline at end of file diff --git a/index.php b/index.php new file mode 100644 index 0000000..5b76776 --- /dev/null +++ b/index.php @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + Le plus beau des voyages + + + + + + + + +
+

title ?>

+

Animé par Pauline

+
+

+ description ?> +

+
+ + +
+

Le dernier épisode :

+

latestEpTitle ?>

+ latestEpPublicationDate ?> + +

latestEpDescription ?>

+
+ + \ No newline at end of file diff --git a/podcast.php b/podcast.php new file mode 100644 index 0000000..626f6ce --- /dev/null +++ b/podcast.php @@ -0,0 +1,62 @@ + + * @link https://forgejo.la-taniere-solidaire.gay/Renarde/site-web-le-plus-beau-des-voyages + */ + +class Podcast +{ + public string $title; + public string $description; + + public string $latestEpTitle; + public string $latestEpDescription; + public string $latestEpPublicationDate; + public string $latestEpAudioData; + + /** + * @param string $url RSS feed URL + */ + function __construct($url) { + $data = file_get_contents($url); + /** + * TODO : Implement caching system + * + * file_put_contents("feed.rss", $FeedData); + */ + + $xml = simplexml_load_string($data,'SimpleXMLElement', LIBXML_NOCDATA); + $this->title = ucfirst(strtolower($xml->channel->title)); + // Remove acast branding + $this->description = preg_replace( + "/
.+<\/p>/", "", $xml->channel->description + ); + $this->latestEpTitle = $xml->channel->item[0]->title; + // Remove acast branding + $this->latestEpDescription = preg_replace( + "/
.+<\/p>/", "", $xml->channel->item[0]->description + ); + // Localize the date + $fmt = new \IntlDateFormatter('fr_FR', null, null); + $fmt->setPattern('d MMMM yyyy HH:mm'); + $cff = DateTime::createFromFormat( + DateTime::RFC7231, + $xml->channel->item[0]->pubDate + ); + $this->latestEpPublicationDate = $fmt->format($cff); + // Generate audio tags + $rawAudioData = $xml->channel->item[0]->enclosure->attributes(); + $this->latestEpAudioData = "src={$rawAudioData->url} " . + "type={$rawAudioData->type} " . + "length={$rawAudioData->length}"; + } +} +?> \ No newline at end of file