From 97f4570319053bdd1b1c027273fd2f94c360e0e7 Mon Sep 17 00:00:00 2001
From: Josh Brickner <15388+leftouterjoins@users.noreply.github.com>
Date: Tue, 17 Jun 2025 08:03:48 -0600
Subject: [PATCH 1/3] Add all episodes page
---
src/Brickner/Podsumer/State.php | 9 ++++++++
templates/base.html.php | 2 ++
templates/episodes.html.php | 32 +++++++++++++++++++++++++++
tests/Brickner/Podsumer/StateTest.php | 8 +++++++
www/index.php | 12 ++++++++++
5 files changed, 63 insertions(+)
create mode 100644 templates/episodes.html.php
diff --git a/src/Brickner/Podsumer/State.php b/src/Brickner/Podsumer/State.php
index aa1f142..3aaafa8 100755
--- a/src/Brickner/Podsumer/State.php
+++ b/src/Brickner/Podsumer/State.php
@@ -205,6 +205,15 @@ public function getFeedItems(int $feed_id): array
return (false === $result) ? [] : $result;
}
+ public function getAllItems(): array
+ {
+ $sql = 'SELECT items.name, items.feed_id, items.id, items.guid, items.audio_url, items.audio_file, COALESCE(items.image, feeds.image) AS image, items.size, items.published, items.description, items.playback_position, feeds.name AS feed_name FROM items JOIN feeds ON feeds.id = items.feed_id ORDER BY items.published DESC';
+
+ $result = $this->query($sql);
+
+ return (false === $result) ? [] : $result;
+ }
+
public function getFeedByHash(string $hash): array
{
$sql = 'SELECT id, name, last_update, url, description FROM feeds WHERE url_hash = :hash';
diff --git a/templates/base.html.php b/templates/base.html.php
index 7237788..abba0b3 100755
--- a/templates/base.html.php
+++ b/templates/base.html.php
@@ -11,6 +11,8 @@
Feeds
|
+ Episodes
+ |
OPML
|
= round($db_size/1024/1024/1024, 2) ?> GB
diff --git a/templates/episodes.html.php b/templates/episodes.html.php
new file mode 100644
index 0000000..98696c6
--- /dev/null
+++ b/templates/episodes.html.php
@@ -0,0 +1,32 @@
+
+ if (empty($items)): ?>
+
+
No Episodes
+
+ else: ?>
+ foreach ($items as $item): ?>
+
+
+
+
+
+ = $item['name'] ?>
+
+
+
+ = $item['feed_name'] ?>
+ |
+ = round($item['size'] / 1024 / 1024, 1) ?>MB
+ |
+ = date('m/d/Y', strtotime($item['published'])); ?>
+ if (!empty($item['audio_file'])) { ?>
+ |
+ Delete Audio
+ } ?>
+
+
+ = substr(strip_tags($item['description']), 0, 360); ?>
+
+ endforeach ?>
+ endif ?>
+
diff --git a/tests/Brickner/Podsumer/StateTest.php b/tests/Brickner/Podsumer/StateTest.php
index 553ca66..96ead8a 100644
--- a/tests/Brickner/Podsumer/StateTest.php
+++ b/tests/Brickner/Podsumer/StateTest.php
@@ -84,6 +84,14 @@ public function testGetFeedItems()
$this->assertEquals(4, count($items));
}
+ public function testGetAllItems()
+ {
+ $this->feed = new Feed(self::TEST_FEED_URL);
+ $this->state->addFeed($this->feed);
+ $items = $this->state->getAllItems();
+ $this->assertEquals(4, count($items));
+ }
+
public function testGetFeedByHash()
{
$this->feed = new Feed(self::TEST_FEED_URL);
diff --git a/www/index.php b/www/index.php
index 0550f78..3b6661a 100755
--- a/www/index.php
+++ b/www/index.php
@@ -40,6 +40,18 @@ function home(array $args): void
Template::render($main, 'home', $vars);
}
+#[Route('/episodes', 'GET', true)]
+function episodes(array $args): void
+{
+ global $main;
+
+ $vars = [
+ 'items' => $main->getState()->getAllItems()
+ ];
+
+ Template::render($main, 'episodes', $vars);
+}
+
/**
* Add new feed(s)
* Path: /add
From f45cf3be21698167c12734074e2a4c8e7957e30d Mon Sep 17 00:00:00 2001
From: Josh Brickner <15388+leftouterjoins@users.noreply.github.com>
Date: Tue, 17 Jun 2025 08:19:47 -0600
Subject: [PATCH 2/3] Fix image URL fallback
---
src/Brickner/Podsumer/State.php | 2 +-
templates/episodes.html.php | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/Brickner/Podsumer/State.php b/src/Brickner/Podsumer/State.php
index 222c1ba..9bb71e2 100755
--- a/src/Brickner/Podsumer/State.php
+++ b/src/Brickner/Podsumer/State.php
@@ -205,7 +205,7 @@ public function getFeedItems(int $feed_id): array
return (false === $result) ? [] : $result;
}
-
+ $sql = 'SELECT items.name, items.feed_id, items.id, items.guid, items.audio_url, items.audio_file, items.image AS item_image, feeds.image AS feed_image, COALESCE(items.image, feeds.image) AS image, items.size, items.published, items.description, items.playback_position, feeds.name AS feed_name FROM items JOIN feeds ON feeds.id = items.feed_id ORDER BY items.published DESC';
public function getAllItems(): array
{
$sql = 'SELECT items.name, items.feed_id, items.id, items.guid, items.audio_url, items.audio_file, COALESCE(items.image, feeds.image) AS image, items.size, items.published, items.description, items.playback_position, feeds.name AS feed_name FROM items JOIN feeds ON feeds.id = items.feed_id ORDER BY items.published DESC';
diff --git a/templates/episodes.html.php b/templates/episodes.html.php
index 98696c6..d07580d 100644
--- a/templates/episodes.html.php
+++ b/templates/episodes.html.php
@@ -7,7 +7,7 @@
foreach ($items as $item): ?>
-
+
= $item['name'] ?>
From 35846f6f9769b994a9fdbef947e28445a46db909 Mon Sep 17 00:00:00 2001
From: Josh Brickner
Date: Tue, 17 Jun 2025 08:23:00 -0600
Subject: [PATCH 3/3] Fix syntax error from bad merge
---
src/Brickner/Podsumer/State.php | 1 -
1 file changed, 1 deletion(-)
diff --git a/src/Brickner/Podsumer/State.php b/src/Brickner/Podsumer/State.php
index 9bb71e2..70e1d71 100755
--- a/src/Brickner/Podsumer/State.php
+++ b/src/Brickner/Podsumer/State.php
@@ -205,7 +205,6 @@ public function getFeedItems(int $feed_id): array
return (false === $result) ? [] : $result;
}
- $sql = 'SELECT items.name, items.feed_id, items.id, items.guid, items.audio_url, items.audio_file, items.image AS item_image, feeds.image AS feed_image, COALESCE(items.image, feeds.image) AS image, items.size, items.published, items.description, items.playback_position, feeds.name AS feed_name FROM items JOIN feeds ON feeds.id = items.feed_id ORDER BY items.published DESC';
public function getAllItems(): array
{
$sql = 'SELECT items.name, items.feed_id, items.id, items.guid, items.audio_url, items.audio_file, COALESCE(items.image, feeds.image) AS image, items.size, items.published, items.description, items.playback_position, feeds.name AS feed_name FROM items JOIN feeds ON feeds.id = items.feed_id ORDER BY items.published DESC';