rss_converter_twitter.com.xsl: explain why the style attribute is removed
[tweeper.git] / src / rss_converter_twitter.com.xsl
index d1514c5..06ae70a 100644 (file)
     <!-- Identity transform -->
     <xsl:template match="@*|node()">
         <xsl:copy>
+            <!--
+                Strip the style attribute while copying elements because it may be
+                dangerous, see:
+                https://validator.w3.org/feed/docs/warning/DangerousStyleAttr.html
+            -->
             <xsl:apply-templates select="@*[not(name() = 'style')]|node()"/>
         </xsl:copy>
     </xsl:template>
@@ -84,7 +89,7 @@
             <xsl:attribute name="href">
                 <xsl:value-of select="concat(@data-image-url, ':orig')"/>
             </xsl:attribute>
-            <img>
+            <img style="max-width: 100%">
                 <xsl:attribute name="src">
                     <xsl:value-of select="@data-image-url"/>
                 </xsl:attribute>
         <xsl:copy>
             <xsl:apply-templates select="@*"/>
             <xsl:attribute name="style">
-                <xsl:value-of select="concat(@style, '; background-repeat: no-repeat')"/>
+                <xsl:value-of select="concat(@style, '; background-repeat: no-repeat; background-size: 100% auto')"/>
             </xsl:attribute>
             <xsl:apply-templates select="node()"/>
         </xsl:copy>
         <xsl:variable name="item-permalink" select="concat($BaseURL, .//div[@data-permalink-path]/@data-permalink-path)"/>
 
         <xsl:variable name="item-has-video" select="$item-media//*[contains(@class, 'PlayableMedia--video')]"/>
+        <xsl:variable name="item-has-gif" select="$item-media//*[contains(@class, 'PlayableMedia--gif')]"/>
         <item>
             <title>
                 <xsl:value-of select="concat($user-name, ': ')"/>
                     <xsl:text> (Video)</xsl:text>
                     <xsl:element name="br"/>
                 </xsl:if>
+                <xsl:if test="$item-has-gif">
+                    <xsl:text> (GIF)</xsl:text>
+                    <xsl:element name="br"/>
+                </xsl:if>
                 <xsl:element name="span">
                     <xsl:attribute name="style">white-space: pre-wrap;</xsl:attribute>
                     <xsl:apply-templates select="$item-content/node()"/>