Podcasts shelf: your podcasts as their artwork (#474)
A place beside Up Next listing every feed with audio or video as a grid of its artwork, with how many episodes are new, as Overcast's home screen does. It is drawn from the feed list the page already holds; the feed list gains `podcast`, an EXISTS per subscription over enclosures, which stops at a podcast's first episode and is one index probe for a feed with no files. Its cost on production's database is not measured: the EXPLAIN was not run. The iOS app's generated messages (ios/Sources/Wire) are not regenerated: there is no protoc here. Nothing in the app reads the new fields, and a proto3 reader skips a field it does not know. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
### Added
|
||||
|
||||
- A feed in `/api/feeds` says whether it has audio or video (`podcast`), for the page's Podcasts shelf (#474).
|
||||
- Up Next, a queue of episodes kept per account so every device shares it: `GET /api/queue` lists it in order, `PUT /api/queue` sets it, and an episode leaves it once it is 90% played (#473).
|
||||
- The API answers in protobuf as well as JSON: a client that sends `Accept: application/x-protobuf` gets protobuf, and one that sends `Content-Type: application/x-protobuf` may send its body so; JSON stays the default for a client that does not ask, and an answer of null stays JSON. The messages are in `crates/wire/proto/ipx.proto`. ipx's own calls to the directory and ipx-play go in protobuf too, so both need their protobuf releases first. Answers and those calls go through structs generated from the `.proto` files, about four times quicker to read than the JSON (#465, #470).
|
||||
- Sharing an episode gives a link to its page on ipx-play, which anyone can open and play, set up in Admin, Directory, Sharing episodes; private and paid feeds still share their own address (#447).
|
||||
|
||||
@@ -611,6 +611,16 @@ impl Db {
|
||||
),
|
||||
vec![user_id.into(), one()],
|
||||
);
|
||||
// Whether a feed has any audio or video, for the Podcasts shelf (#474). EXISTS, so a podcast
|
||||
// stops at its first episode, and a feed with no files is one probe of enclosures_entry.
|
||||
let media = counts(
|
||||
"media",
|
||||
"SELECT sub.feed_id, CAST(1 AS BIGINT) AS n FROM subscriptions sub
|
||||
WHERE sub.user_id = $1 AND (CAST($2 AS TEXT) IS NULL OR sub.feed_id = $2)
|
||||
AND EXISTS (SELECT 1 FROM enclosures x WHERE x.feed_id = sub.feed_id
|
||||
AND (lower(x.mime) LIKE 'audio/%' OR lower(x.mime) LIKE 'video/%'))",
|
||||
vec![user_id.into(), one()],
|
||||
);
|
||||
let blocked = Instrument::instrument(
|
||||
blocklists::Entity::find().filter(blocklists::Column::UserId.eq(user_id)).all(&self.orm),
|
||||
step("blocked"),
|
||||
@@ -620,10 +630,11 @@ impl Db {
|
||||
rows = rows.filter(feeds::Column::Id.eq(id));
|
||||
}
|
||||
let rows = Instrument::instrument(rows.all(&self.orm), step("feeds"));
|
||||
let (entries, downloaded, unread, blocked, rows) = tokio::try_join!(
|
||||
let (entries, downloaded, unread, media, blocked, rows) = tokio::try_join!(
|
||||
entries,
|
||||
downloaded,
|
||||
unread,
|
||||
media,
|
||||
async { blocked.await.map_err(anyhow::Error::from) },
|
||||
async { rows.await.map_err(anyhow::Error::from) },
|
||||
)?;
|
||||
@@ -649,6 +660,7 @@ impl Db {
|
||||
ttl_mins: f.ttl_mins.map(|t| t.max(0) as u64),
|
||||
blocked: blocked.remove(&id).unwrap_or_default(),
|
||||
unread: unread.get(&id).copied().unwrap_or(0),
|
||||
podcast: media.contains_key(&id),
|
||||
};
|
||||
(id, listing)
|
||||
})
|
||||
@@ -663,6 +675,8 @@ pub struct FeedListing {
|
||||
pub ttl_mins: Option<u64>,
|
||||
pub blocked: Vec<String>,
|
||||
pub unread: i64,
|
||||
/// It has an audio or video file, so it is on the Podcasts shelf (#474).
|
||||
pub podcast: bool,
|
||||
}
|
||||
|
||||
/// Everything `fetch` needs to decide whether to poll a feed, and how.
|
||||
@@ -3639,12 +3653,15 @@ mod tests {
|
||||
INSERT INTO entries (feed_id, guid, first_seen) VALUES ('f','a',0),('f','b',0),('f','c',0),('g','d',0),('h','e',0);
|
||||
INSERT INTO entry_state (user_id, feed_id, guid, read) VALUES (1,'f','a',true),(2,'f','b',true);
|
||||
INSERT INTO hidden (user_id, feed_id, guid) VALUES (1,'f','c');
|
||||
INSERT INTO enclosures (id, feed_id, guid, url, path, state) VALUES
|
||||
(1,'f','a','u1','/tmp/a','done'),(2,'f','b','u2',null,'pending');
|
||||
INSERT INTO enclosures (id, feed_id, guid, url, path, state, mime) VALUES
|
||||
(1,'f','a','u1','/tmp/a','done','Audio/MPEG'),(2,'f','b','u2',null,'pending',null),
|
||||
(3,'g','d','u3',null,'skipped','image/jpeg');
|
||||
INSERT INTO blocklists (user_id, feed_id, words) VALUES (1,'g','[\"spoiler\"]');",
|
||||
).await
|
||||
.unwrap();
|
||||
let list = db.feed_list(1, None).await.unwrap();
|
||||
// On the Podcasts shelf by having sound, whatever the case of its type; a picture is not (#474).
|
||||
assert!(list["f"].podcast && !list["g"].podcast);
|
||||
let g = db.feed_list(1, Some("g")).await.unwrap();
|
||||
assert_eq!(g.keys().collect::<Vec<_>>(), ["g"]);
|
||||
assert_eq!(
|
||||
|
||||
@@ -1004,6 +1004,8 @@ struct FeedRow {
|
||||
private: bool,
|
||||
/// Private whatever it is marked, for a login or an address with a key in it.
|
||||
private_by_address: bool,
|
||||
/// Has an audio or video file: on the Podcasts shelf (#474).
|
||||
podcast: bool,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
@@ -1052,7 +1054,8 @@ async fn feed_rows(state: &WebState, user: &crate::db::User, only: Option<&str>)
|
||||
let up = feed.group.as_deref().and_then(|g| mine.get(g));
|
||||
let Some(mine) = mine.get(id) else { continue };
|
||||
// A feed not scanned yet has no row: blank, as feed_summary gave it.
|
||||
let crate::db::FeedListing { summary: s, ttl_mins, blocked, unread } = listed.remove(id).unwrap_or_default();
|
||||
let crate::db::FeedListing { summary: s, ttl_mins, blocked, unread, podcast } =
|
||||
listed.remove(id).unwrap_or_default();
|
||||
out.push(FeedRow {
|
||||
private: feed.private,
|
||||
private_by_address: crate::directory::looks_private(&crate::config::Feed {
|
||||
@@ -1115,6 +1118,7 @@ async fn feed_rows(state: &WebState, user: &crate::db::User, only: Option<&str>)
|
||||
kept: kept.contains(id),
|
||||
hide_from_all: hidden.contains(id),
|
||||
hide_from_signals: quiet.contains(id),
|
||||
podcast,
|
||||
});
|
||||
}
|
||||
Ok(out)
|
||||
|
||||
@@ -134,6 +134,8 @@ message FeedRow {
|
||||
bool hide_from_signals = 32;
|
||||
bool private = 33;
|
||||
bool private_by_address = 34;
|
||||
// Has an audio or video file: on the Podcasts shelf (#474).
|
||||
bool podcast = 35;
|
||||
}
|
||||
|
||||
// GET /api/feeds.
|
||||
|
||||
@@ -462,6 +462,19 @@ test('Up Next lines episodes up, moves them, and plays the next when one ends (#
|
||||
await page.evaluate(() => api('/api/entries/test-show/ui-2/position', { method: 'POST', body: JSON.stringify({ secs: 0 }) }));
|
||||
});
|
||||
|
||||
test('the Podcasts shelf shows the feeds with episodes, as their artwork, and opens one (#474)', async ({ page }) => {
|
||||
await page.locator('#feedlist .place', { hasText: 'Podcasts' }).click();
|
||||
const shows = page.locator('#content .shelf .show');
|
||||
await expect(shows.filter({ hasText: 'Test Show' })).toBeVisible();
|
||||
// A blog of pictures has files, and no episodes.
|
||||
await expect(shows.filter({ hasText: 'Picture Blog' })).toHaveCount(0);
|
||||
await page.locator('#epSearch').fill('multi');
|
||||
await expect(shows).toHaveText([/Multi Show/]);
|
||||
await page.locator('#epSearch').fill('');
|
||||
await shows.filter({ hasText: 'Test Show' }).click();
|
||||
await expect(page.locator('#eps .ep', { hasText: 'First Episode' })).toBeVisible();
|
||||
});
|
||||
|
||||
test('a player nobody has played since it last saved does not save again', async ({ page }) => {
|
||||
// A tab left paused at 41:15 saved that as it reloaded, over the 32:48 another had reached,
|
||||
// and the episode dropped out of Currently Listening. The fixture audio does not decode, so
|
||||
|
||||
@@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
### Added
|
||||
|
||||
- Podcasts: your podcasts as a shelf of their artwork, each with how many episodes are new; the search box narrows it, and a tap opens one (#474).
|
||||
- Up Next: line episodes up with the list button on a row or in the reader (`q`, or `Shift Q` to play one next), move them by their handles, and each plays when the one before it ends. The player has a Next button while something is lined up, and the lock screen's next-track button does the same (#473).
|
||||
- The page reads ipx's answers in protobuf, with a decoder of its own and no library, and in JSON from a server that has none; offline, a kept answer still shows what was read offline (#470).
|
||||
- On a phone, back and the item's actions (read, pin, open, share) float over the text as it scrolls, so they are at hand anywhere in a long post without scrolling back to the top; pressing one there keeps your place (#456).
|
||||
|
||||
@@ -696,6 +696,14 @@ body.scan-this .fhead [data-a=scan] .i,body.scan-any .fhead [data-a=scanall] .i,
|
||||
#listening .txt small .fd{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
||||
#listening .txt small .left{flex:none;color:var(--dim)}
|
||||
#listening .childrow:not(.now) .eq{display:none}
|
||||
/* The Podcasts shelf (#474): the artwork is the podcast, as on a shelf of records, so nothing
|
||||
frames it: no card, no shadow, the name and its new episodes under it. */
|
||||
.shelf{display:grid;grid-template-columns:repeat(auto-fill,minmax(112px,1fr));gap:20px 14px;padding:4px 2px 24px}
|
||||
.shelf .show{display:flex;flex-direction:column;gap:6px;min-width:0;text-align:left;cursor:pointer;border-radius:10px}
|
||||
.shelf .show .art{width:100%;height:auto;aspect-ratio:1;border-radius:10px;font-size:26px}
|
||||
.shelf .show b{font-weight:500;font-size:13px;line-height:1.3;color:var(--fg);display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
|
||||
.shelf .show small{color:var(--dim);font-size:11.5px;min-height:1em;margin-top:-3px}
|
||||
@media (hover:hover){.shelf .show:hover .art{outline:2px solid var(--accent);outline-offset:2px}}
|
||||
/* Up Next's handle: dragged, it takes the pointer, so the list does not scroll under the finger. */
|
||||
#listening .grip{width:22px;margin-left:-4px;color:var(--faint);cursor:grab;touch-action:none}
|
||||
#listening .grip svg{width:12px;height:12px}
|
||||
|
||||
@@ -310,6 +310,7 @@ async function renderListed(v: {title: string, icon: string, url?: string, blurb
|
||||
await renderDirectory(v.url!,$('#directory'),n=>{ if(VIEWS[S.feed ?? '']===v) $('#count').textContent=`${v.title}: ${plural(n,'feed')}`; });
|
||||
return;
|
||||
}
|
||||
if(v===VIEWS[':podcasts']){ drawShelf(box); return; }
|
||||
$<HTMLInputElement>('#epSearch').setAttribute('aria-label','Search items');
|
||||
box.innerHTML=`
|
||||
<div class="fhead slim">
|
||||
@@ -324,6 +325,25 @@ async function renderListed(v: {title: string, icon: string, url?: string, blurb
|
||||
n=>{ if(VIEWS[S.feed ?? '']===v) $('#count').textContent=`${v.title}: ${plural(n,'episode')}`; });
|
||||
}
|
||||
|
||||
/// The Podcasts shelf (#474): every feed with audio or video, as its artwork, with how many of its
|
||||
/// episodes are new. A tap opens it. The search box narrows it by name.
|
||||
function drawShelf(box: HTMLElement){
|
||||
$<HTMLInputElement>('#epSearch').setAttribute('aria-label','Search podcasts');
|
||||
const q=S.q.trim().toLowerCase();
|
||||
const shows=S.feeds.filter(f=>f.podcast&&(!q||(f.title||f.id).toLowerCase().includes(q)));
|
||||
$('#count').textContent=`Podcasts: ${plural(shows.length,'podcast')}`;
|
||||
box.innerHTML=shows.length?'<div class="shelf"></div>'
|
||||
:`<p class="hint">${q?`No podcast is called “${esc(S.q)}”.`:'No podcasts yet. Add a feed with episodes in it, and it shows here.'}</p>`;
|
||||
const shelf=$('.shelf',box);
|
||||
for(const f of shows){
|
||||
const name=f.title||f.id, b=document.createElement('button');
|
||||
b.type='button'; b.className='show';
|
||||
b.innerHTML=`${artHTML(f.image,name)}<b>${esc(name)}</b><small>${f.unread?`${f.unread} new`:''}</small>`;
|
||||
b.onclick=()=>selectFeed(f.id);
|
||||
shelf.appendChild(b);
|
||||
}
|
||||
}
|
||||
|
||||
/// Currently Listening: episodes you started and have not finished, across every feed you
|
||||
/// subscribe to. A row resumes the episode in the player bar on click -- a shortcut back to
|
||||
/// where you left off, not another way to browse. The one in the player pauses instead.
|
||||
@@ -410,7 +430,7 @@ $<HTMLInputElement>('#epSearch').oninput=(ev: Event)=>{ clearTimeout(searchT);
|
||||
// server (#126, #127).
|
||||
searchT=setTimeout(()=>{ S.q=(ev.target as HTMLInputElement).value; S.offset=0;
|
||||
if(S.feed===':directory'){ dirShow=null; drawDirectory(); }
|
||||
else if(S.feed===':listening') renderListed(VIEWS[':listening']);
|
||||
else if(S.feed===':listening'||S.feed===':podcasts') renderListed(VIEWS[S.feed]);
|
||||
else loadEntries(); },250); };
|
||||
// Crossing the phone breakpoint moves the files between their pane and the text.
|
||||
window.matchMedia?.('(max-width:820px)')?.addEventListener?.('change',()=>{ const e=cur(); if(e) showDetail(e); });
|
||||
|
||||
@@ -36,6 +36,8 @@ const VIEWS: Record<string,{title: string, icon: string, url?: string, blurb?: s
|
||||
blurb:'Episodes you started and have not finished, across every feed you subscribe to. Pick one up where you left off.'},
|
||||
':upnext':{title:'Up Next',icon:ICON.queue,url:'/api/queue',
|
||||
blurb:'Episodes lined up to play, in order. Each one plays when the one before it ends.'},
|
||||
// Drawn from the feed list the page already has; the address is only what marks it a place.
|
||||
':podcasts':{title:'Podcasts',icon:ICON.podcasts,url:'/api/feeds'},
|
||||
':all':{title:'All Subscriptions',icon:ICON.all},
|
||||
};
|
||||
/// Whether a feed's items are in All Subscriptions, or in Signals: not when it, or the OPML or
|
||||
|
||||
@@ -43,6 +43,8 @@ interface Feed {
|
||||
hide_from_signals: boolean;
|
||||
private: boolean;
|
||||
private_by_address: boolean;
|
||||
/** Has an audio or video file: on the Podcasts shelf (#474). */
|
||||
podcast: boolean;
|
||||
}
|
||||
|
||||
/// An item, in a page of `/api/entries` (db.rs EntryRow).
|
||||
|
||||
@@ -94,6 +94,8 @@ const ICON: Record<string,string>={
|
||||
// shape. Drawn here, so the two are the same list and differ only in that mark.
|
||||
queue:fa('0 0 512 512','<path fill="currentColor" d="M32 96a32 32 0 0 1 32-32h384a32 32 0 0 1 0 64H64a32 32 0 0 1-32-32zm0 160a32 32 0 0 1 32-32h384a32 32 0 0 1 0 64H64a32 32 0 0 1-32-32zm32 128h160a32 32 0 0 1 0 64H64a32 32 0 0 1 0-64zm320-64a32 32 0 0 1 32 32v48h48a32 32 0 0 1 0 64h-48v48a32 32 0 0 1-64 0v-48h-48a32 32 0 0 1 0-64h48v-48a32 32 0 0 1 32-32z"/>'),
|
||||
queued:fa('0 0 512 512','<path fill="currentColor" d="M32 96a32 32 0 0 1 32-32h384a32 32 0 0 1 0 64H64a32 32 0 0 1-32-32zm0 160a32 32 0 0 1 32-32h384a32 32 0 0 1 0 64H64a32 32 0 0 1-32-32zm32 128h160a32 32 0 0 1 0 64H64a32 32 0 0 1 0-64z"/><path fill="none" stroke="currentColor" stroke-width="60" stroke-linecap="round" stroke-linejoin="round" d="M300 404l54 54 116-116"/>'),
|
||||
// Font Awesome's podcast, for the Podcasts shelf (#474).
|
||||
podcasts:fa('0 0 448 512','<path fill="currentColor" d="M319.4 372c48.5-31.3 80.6-85.9 80.6-148 0-97.2-78.8-176-176-176S48 126.8 48 224c0 62.1 32.1 116.6 80.6 148 1.2 17.3 4 38 7.2 57.1l.2 1C56 395.8 0 316.5 0 224 0 100.3 100.3 0 224 0S448 100.3 448 224c0 92.5-56 171.9-136 206.1l.2-1.1c3.1-19.2 6-39.8 7.2-57zm-2.3-38.1c-1.6-5.7-3.9-11.1-7-16.2-5.8-9.7-13.5-17-21.9-22.4 19.5-17.6 31.8-43 31.8-71.3 0-53-43-96-96-96s-96 43-96 96c0 28.3 12.3 53.8 31.8 71.3-8.4 5.4-16.1 12.7-21.9 22.4-3.1 5.1-5.4 10.5-7 16.2C99.8 307.5 80 268 80 224c0-79.5 64.5-144 144-144s144 64.5 144 144c0 44-19.8 83.5-50.9 109.9zM224 312c32.9 0 64 8.6 64 43.8 0 33-12.9 104.1-20.6 132.9-5.1 19-24.5 23.4-43.4 23.4s-38.2-4.4-43.4-23.4c-7.8-28.5-20.6-99.7-20.6-132.8 0-35.1 31.1-43.8 64-43.8zm0-144a56 56 0 1 1 0 112 56 56 0 1 1 0-112z"/>'),
|
||||
next:fa('0 0 320 512','<path fill="currentColor" d="M52.5 440.6c-9.5 7.9-22.8 9.7-34.1 4.4S0 428.4 0 416V96c0-12.4 7.2-23.7 18.4-29s24.5-3.6 34.1 4.4l192 160L256 241V96c0-17.7 14.3-32 32-32s32 14.3 32 32v320c0 17.7-14.3 32-32 32s-32-14.3-32-32V271l-11.5 9.6-192 160z"/>'),
|
||||
grip:fa('0 0 320 512','<path fill="currentColor" d="M40 352a40 40 0 1 1 0 80 40 40 0 1 1 0-80zm240 0a40 40 0 1 1 0 80 40 40 0 1 1 0-80zM40 216a40 40 0 1 1 0 80 40 40 0 1 1 0-80zm240 0a40 40 0 1 1 0 80 40 40 0 1 1 0-80zM40 80a40 40 0 1 1 0 80 40 40 0 1 1 0-80zm240 0a40 40 0 1 1 0 80 40 40 0 1 1 0-80z"/>'),
|
||||
subbed:fa('0 0 512 512','<path fill="currentColor" d="M256 512a256 256 0 1 1 0-512 256 256 0 1 1 0 512zM374 145.7c-10.7-7.8-25.7-5.4-33.5 5.3L221.1 315.2 169 263.1c-9.4-9.4-24.6-9.4-33.9 0s-9.4 24.6 0 33.9l72 72c5 5 11.8 7.5 18.8 7s13.4-4.1 17.5-9.8L379.3 179.2c7.8-10.7 5.4-25.7-5.3-33.5z"/>'), // solid/circle-check
|
||||
|
||||
Reference in New Issue
Block a user