Keep every enclosure on an item, and view without downloading
The rss crate keeps at most one enclosure per item and, when a feed ships several, silently keeps the last -- so a two-file item lost its first file. enclosures_by_item reads them from the XML in document order, unescaping attributes so a URL's & survives. The row summarises the one you would act on and counts the rest; the pane below lists them all. Non-media enclosures gain a View link opening in a new tab: the publisher's URL, or the local copy once downloaded. A direct link, not a proxy, so the daemon does not become a fetch-anything relay. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AdXho5tTkjFLeUXKbEjKBh
This commit is contained in:
@@ -617,9 +617,13 @@ function renderEntries(){
|
||||
}
|
||||
}
|
||||
function epEl(e){
|
||||
const enc=e.enclosures[0];
|
||||
// An item may carry several files. The row summarises the one you would act on --
|
||||
// the playable one, else anything already downloaded, else the first -- and says how
|
||||
// many others there are; the pane below lists them all.
|
||||
const enc=e.enclosures.find(isPlayable) || e.enclosures.find(x=>x.path) || e.enclosures[0];
|
||||
const has=!!(enc&&enc.path);
|
||||
const playable=isPlayable(enc);
|
||||
const others=e.enclosures.length-1;
|
||||
const el=document.createElement('div');
|
||||
el.className='ep'+(e.read?' read':'')+(S.sel===e.guid?' sel':'')+
|
||||
(player.guid===e.guid?' playing':'');
|
||||
@@ -638,6 +642,7 @@ function epEl(e){
|
||||
${enc?`<span class="dot"></span><span class="chip ${esc(enc.state)}">${
|
||||
has?'downloaded':(enc.state==='skipped'?kindOf(enc):esc(enc.state))}</span>`:''}
|
||||
${enc&&enc.length?`<span>${mb(enc.length)}</span>`:''}
|
||||
${others>0?`<span class="dot"></span><span>+${others} more file${others===1?'':'s'}</span>`:''}
|
||||
${e.flagged?'<span class="dot"></span><span>★ kept</span>':''}
|
||||
</div>
|
||||
${enc&&!has?`<div class="dlbar" data-bar="${enc.id}"><i></i></div>`:''}
|
||||
@@ -751,10 +756,11 @@ function showDetail(e){
|
||||
function encBox(x){
|
||||
const size=x.length?mb(x.length):'';
|
||||
if(x.path && !isPlayable(x)){
|
||||
// On disk, but not audio or video: offer the file, not a player.
|
||||
// On disk, but not audio or video: view it, keep it, or remove it -- no player.
|
||||
return `<div class="encbox">
|
||||
<span class="chip done">${esc(kindOf(x))}</span>
|
||||
<span class="meta" style="flex:1">downloaded${size?' \u00b7 '+size:''}</span>
|
||||
<a class="btn" href="/media/${x.id}" target="_blank" rel="noopener noreferrer">View</a>
|
||||
<a class="btn" href="/media/${x.id}" download>Save</a>
|
||||
<button class="btn danger" data-a="del" data-enc="${x.id}">Delete file</button>
|
||||
</div>`;
|
||||
@@ -767,10 +773,15 @@ function encBox(x){
|
||||
<button class="btn danger" data-a="del" data-enc="${x.id}">Delete file</button>
|
||||
</div>`;
|
||||
}
|
||||
// Nothing on disk. For an image or a PDF you usually just want to look at it, so link
|
||||
// straight to the publisher's copy in a new tab -- no download, and nothing proxied
|
||||
// through here, which would make ipx a fetch-anything relay.
|
||||
const viewable = !isPlayable(x) && x.state !== 'pending';
|
||||
return `<div class="encbox">
|
||||
<span class="chip ${esc(x.state)}">${x.state==='skipped'?kindOf(x):esc(x.state)}</span>
|
||||
<span class="meta" style="flex:1">${esc(kindOf(x))}${size?' \u00b7 '+size:''}</span>
|
||||
${x.last_error?`<span class="err">${esc(x.last_error)}</span>`:''}
|
||||
${viewable?`<a class="btn" href="${esc(x.url)}" target="_blank" rel="noopener noreferrer">View</a>`:''}
|
||||
<button class="btn" data-a="get" data-enc="${x.id}">Download</button>
|
||||
</div>`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user