src/rss_converter_instagram.com.xsl: add support for Instagram.com tags
authorAntonio Ospite <ao2@ao2.it>
Wed, 6 Jun 2018 12:57:10 +0000 (14:57 +0200)
committerAntonio Ospite <ao2@ao2.it>
Wed, 6 Jun 2018 12:57:10 +0000 (14:57 +0200)
Supporting Instagram tags is quite easy, so let's do it and while at it
refactor how the channel description is set depending of the kind of
page.

src/rss_converter_instagram.com.xsl

index 2d54f3d..c714b1b 100644 (file)
 
     <xsl:variable name="location-name" select="//LocationsPage/graphql/location/name"/>
 
 
     <xsl:variable name="location-name" select="//LocationsPage/graphql/location/name"/>
 
+    <xsl:variable name="hashtag-name" select="//TagPage/graphql/hashtag/name"/>
+
     <xsl:variable name="screen-name">
         <xsl:choose>
             <xsl:when test="$location-name != ''">
                 <xsl:value-of select="$location-name"/>
             </xsl:when>
     <xsl:variable name="screen-name">
         <xsl:choose>
             <xsl:when test="$location-name != ''">
                 <xsl:value-of select="$location-name"/>
             </xsl:when>
+            <xsl:when test="$hashtag-name != ''">
+                <xsl:value-of select="$hashtag-name"/>
+            </xsl:when>
             <xsl:when test="$full-name != ''">
                 <xsl:value-of select="$full-name"/>
             </xsl:when>
             <xsl:when test="$full-name != ''">
                 <xsl:value-of select="$full-name"/>
             </xsl:when>
                     <xsl:variable name="location-id" select="//LocationsPage/graphql/location/id"/>
                     <xsl:value-of select="concat($BaseURL, '/explore/locations/', $location-id)"/>
                 </xsl:when>
                     <xsl:variable name="location-id" select="//LocationsPage/graphql/location/id"/>
                     <xsl:value-of select="concat($BaseURL, '/explore/locations/', $location-id)"/>
                 </xsl:when>
+                <xsl:when test="$hashtag-name != ''">
+                    <xsl:value-of select="concat($BaseURL, '/explore/tags/', $hashtag-name)"/>
+                </xsl:when>
                 <xsl:otherwise>
                     <xsl:value-of select="concat($BaseURL, '/', $user-name)"/>
                 </xsl:otherwise>
             </xsl:choose>
         </xsl:variable>
                 <xsl:otherwise>
                     <xsl:value-of select="concat($BaseURL, '/', $user-name)"/>
                 </xsl:otherwise>
             </xsl:choose>
         </xsl:variable>
-        <xsl:variable name="channel-image" select="//ProfilePage/graphql/user/profile_pic_url"/>
+        <xsl:variable name="channel-image" select="//profile_pic_url"/>
 
         <rss version="2.0">
             <xsl:attribute name="xml:base"><xsl:value-of select="$BaseURL" /></xsl:attribute>
 
         <rss version="2.0">
             <xsl:attribute name="xml:base"><xsl:value-of select="$BaseURL" /></xsl:attribute>
                 </link>
                 <description>
                     <xsl:text disable-output-escaping="yes">&lt;![CDATA[</xsl:text>
                 </link>
                 <description>
                     <xsl:text disable-output-escaping="yes">&lt;![CDATA[</xsl:text>
-                    <xsl:value-of select="normalize-space(concat($screen-name, '. ', //user/biography))"/>
-                    <xsl:if test="$location-name != ''">
-                        <xsl:variable name="location-latitude" select="//LocationsPage/graphql/location/lat"/>
-                        <xsl:variable name="location-longitude" select="//LocationsPage/graphql/location/lng"/>
-                        <xsl:value-of select="concat(' (', $location-latitude, ', ', $location-longitude, ')')"/>
-                    </xsl:if>
-                    <xsl:variable name="external-url" select="//user/external_url"/>
-                    <xsl:if test="$external-url != ''">
-                        <xsl:text> </xsl:text><a href="{$external-url}"><xsl:value-of select="$external-url"/></a>
-                    </xsl:if>
+                    <xsl:choose>
+                        <xsl:when test="$location-name != ''">
+                            <xsl:variable name="location-latitude" select="//LocationsPage/graphql/location/lat"/>
+                            <xsl:variable name="location-longitude" select="//LocationsPage/graphql/location/lng"/>
+                            <xsl:value-of select="concat($location-name, ' (', $location-latitude, ', ', $location-longitude, ')')"/>
+                        </xsl:when>
+                        <xsl:when test="$hashtag-name != ''">
+                            <xsl:value-of select="concat('#', $hashtag-name)"/>
+                        </xsl:when>
+                        <xsl:otherwise>
+                            <xsl:value-of select="normalize-space(concat($screen-name, '. ', //user/biography))"/>
+                            <xsl:variable name="external-url" select="//user/external_url"/>
+                            <xsl:if test="$external-url != ''">
+                                <xsl:text> </xsl:text><a href="{$external-url}"><xsl:value-of select="$external-url"/></a>
+                            </xsl:if>
+                        </xsl:otherwise>
+                    </xsl:choose>
                     <xsl:text disable-output-escaping="yes">]]&gt;</xsl:text>
                 </description>
                 <xsl:if test="$channel-image != ''">
                     <xsl:text disable-output-escaping="yes">]]&gt;</xsl:text>
                 </description>
                 <xsl:if test="$channel-image != ''">
                         </url>
                     </image>
                 </xsl:if>
                         </url>
                     </image>
                 </xsl:if>
-                <xsl:apply-templates select="//ProfilePage/graphql/user/edge_owner_to_timeline_media/edges/node|//LocationsPage/graphql/location/edge_location_to_media/edges/node"/>
+                <xsl:apply-templates select="//ProfilePage/graphql/user/edge_owner_to_timeline_media/edges/node|//LocationsPage/graphql/location/edge_location_to_media/edges/node|//TagPage/graphql/hashtag/edge_hashtag_to_media/edges/node"/>
             </channel>
         </rss>
     </xsl:template>
             </channel>
         </rss>
     </xsl:template>