Skip to content

Commit

Permalink
Add <select> for multiple enclosures
Browse files Browse the repository at this point in the history
  • Loading branch information
lwindolf committed Jun 26, 2024
1 parent eb0ce63 commit 4793bb4
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 69 deletions.
30 changes: 2 additions & 28 deletions css/liferea.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @file liferea.css Liferea rendering stylesheet
*
* Copyright (C) 2004-2020 Lars Windolf <[email protected]>
* Copyright (C) 2004-2024 Lars Windolf <[email protected]>
* Copyright (C) 2004 delusional <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
Expand All @@ -19,32 +19,6 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

/*
Font Definitions:
=================
No style definition should set absolute font sizes,
font families or line heigth and spacing. This is to allow a GNOME
preference controlled default font size.
Color Definitions:
==================
To allow using GTK theme colors the following key words
will be replaced with the corresponding GTK theme color values:
GTK-COLOR-FG
GTK-COLOR-BG
GTK-COLOR-LIGHT
GTK-COLOR-DARK
GTK-COLOR-MID
GTK-COLOR-BASE
GTK-COLOR-TEXT
GTK-COLOR-NORMAL-LINK
GTK-COLOR-VISITED-LINK
*/

body {
background: #GTK-COLOR-BASE;
color: #GTK-COLOR-TEXT;
Expand Down Expand Up @@ -312,7 +286,7 @@ div.photoheader {
fill: #ddd;
}

div.enclosureVideo video {
#enclosureVideo video {
background: black;
min-width: 640px;
min-height: 480px;
Expand Down
17 changes: 0 additions & 17 deletions css/user.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,6 @@
instead (e.g. "1.2em" or "0.8em").
Color Definitions:
==================
Try to reuse GTK theme colors. Liferea uses the following definitions
and will be replace them on the fly:
GTK-COLOR-FG
GTK-COLOR-BG
GTK-COLOR-LIGHT
GTK-COLOR-DARK
GTK-COLOR-MID
GTK-COLOR-BASE
GTK-COLOR-TEXT
GTK-COLOR-NORMAL-LINK
GTK-COLOR-VISITED-LINK
Inspecting the HTML:
====================
Expand Down
12 changes: 11 additions & 1 deletion js/htmlview.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ function loadContent(readerEnabled, content) {
el.heigth = size[3] - size[1];
});

// Drop empty elements (to get rid of empty picture/video/iframe divs)
// Drop empty elements (to get rid of empty picture/video/iframe divs)
const emptyRegex = new RegExp("^\s*$");
document.getElementById('content')
.querySelectorAll(":only-child")
Expand All @@ -184,6 +184,16 @@ function loadContent(readerEnabled, content) {
el.parentNode.removeChild(el);
});

// Setup audio/video <select> handler
document.querySelector('#enclosureVideo select')?.addEventListener("change", (e) => {
document.querySelector('#enclosureVideo video').src = e.target.options[e.target.selectedIndex].value;
document.querySelector('#enclosureVideo video').play();
});
document.getElementById('#enclosureAudio select')?.addEventListener("change", (e) => {
document.querySelector('#enclosureAudio audio').src = e.target.options[e.target.selectedIndex].value;
document.querySelector('#enclosureVideo audio').play();
});

return true;
}

Expand Down
71 changes: 48 additions & 23 deletions xslt/item.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@
<div dir="{$txtDirection}">
<div class='content' id='content'>

<!-- the item's content -->
<!-- the item's text content -->
<p>
<!-- optional gravatar -->
<xsl:if test="attributes/attribute[ @name = 'gravatar' ]">
Expand All @@ -293,34 +293,58 @@
<!-- the real text content -->
<xsl:value-of select="description" disable-output-escaping='yes'/>
</p>
</div> <!-- end of content -->
</div> <!-- end of text content -->

<!-- all content below is not subject to Readability.js, this is intentional and prevents
unintended stripping -->

<!-- embed suitable enclosures -->
<xsl:for-each select="enclosures/enclosure[contains(@mime, 'audio/')]">
<div class='content enclosureAudio'>
<xsl:element name="audio">
<xsl:attribute name="class">enclosure</xsl:attribute>
<xsl:attribute name="controls">controls</xsl:attribute>
<xsl:attribute name="preload">none</xsl:attribute>
<xsl:attribute name="src"><xsl:value-of select="@url"/></xsl:attribute>
</xsl:element>
</div>
</xsl:for-each>
<div class='content'>

<xsl:for-each select="enclosures/enclosure[contains(@mime, 'video/')]">
<div class='content enclosureVideo'>
<xsl:element name="video">
<xsl:attribute name="class">enclosure</xsl:attribute>
<xsl:attribute name="controls">controls</xsl:attribute>
<xsl:attribute name="preload">none</xsl:attribute>
<xsl:attribute name="src"><xsl:value-of select="@url"/></xsl:attribute>
</xsl:element>
</div>
</xsl:for-each>
<!-- embed suitable enclosures -->

<div id='enclosureAudio'>
<xsl:if test="count(enclosures/enclosure[contains(@mime, 'audio/')]) > 1">
<select>
<xsl:for-each select="enclosures/enclosure[contains(@mime, 'audio/')]">
<xsl:element name="option">
<xsl:value-of select="@url"/>
</xsl:element>
</xsl:for-each>
</select>
</xsl:if>
<xsl:for-each select="enclosures/enclosure[contains(@mime, 'audio/')]">
<xsl:if test="position() = 1">
<xsl:element name="audio">
<xsl:attribute name="class">enclosure</xsl:attribute>
<xsl:attribute name="controls">controls</xsl:attribute>
<xsl:attribute name="preload">none</xsl:attribute>
<xsl:attribute name="src"><xsl:value-of select="@url"/></xsl:attribute>
</xsl:element>
</xsl:if>
</xsl:for-each>
</div>

<div id='enclosureVideo'>
<xsl:if test="count(enclosures/enclosure[contains(@mime, 'video/')]) > 1">
<select>
<xsl:for-each select="enclosures/enclosure[contains(@mime, 'video/')]">
<xsl:element name="option">
<xsl:value-of select="@url"/>
</xsl:element>
</xsl:for-each>
</select>
</xsl:if>
<xsl:for-each select="enclosures/enclosure[contains(@mime, 'video/')]">
<xsl:if test="position() = 1">
<xsl:element name="video">
<xsl:attribute name="class">enclosure</xsl:attribute>
<xsl:attribute name="controls">controls</xsl:attribute>
<xsl:attribute name="preload">none</xsl:attribute>
<xsl:attribute name="src"><xsl:value-of select="@url"/></xsl:attribute>
</xsl:element>
</xsl:if>
</xsl:for-each>
</div>

<!-- optional YouTube embed -->
<xsl:variable name="url"><xsl:value-of select="source"/></xsl:variable>
Expand Down Expand Up @@ -385,6 +409,7 @@
</p>
</xsl:if>
</div> <!-- end of comments -->
</div> <!-- end of content-->
</div> <!-- end of txtdirection div -->
</div> <!-- end of item -->

Expand Down

0 comments on commit 4793bb4

Please sign in to comment.