NEWS: add release notes for the v1.2.0 release
[tweeper.git] / src / rss_converter_instagram.com.xsl
index e869d7d..a2de8b3 100644 (file)
 
     <xsl:variable name="user-name" select="//ProfilePage/user/username"/>
 
-    <!-- Some users do not specify the full name -->
+    <!--
+         NOTE: some users do not specify the full name.
+
+         Remember to handle this case when using it and fall-back to the plain
+         user name when appropriate.
+    -->
     <xsl:variable name="full-name" select="//ProfilePage/user/full_name"/>
+
+    <xsl:variable name="location-name" select="//LocationsPage/location/name"/>
+
     <xsl:variable name="screen-name">
         <xsl:choose>
+            <xsl:when test="$location-name != ''">
+                <xsl:variable name="location-latitude" select="//LocationsPage/location/lat"/>
+                <xsl:variable name="location-longitude" select="//LocationsPage/location/lng"/>
+                <xsl:value-of select="concat($location-name, ' (', $location-latitude, ', ', $location-longitude, ')')"/>
+            </xsl:when>
             <xsl:when test="$full-name != ''">
                 <xsl:value-of select="$full-name"/>
             </xsl:when>
@@ -47,7 +60,7 @@
         </xsl:choose>
     </xsl:variable>
 
-    <xsl:template match="//ProfilePage/user/media/nodes">
+    <xsl:template match="//media/nodes">
         <xsl:variable name="item-content-image" select="./display_src"/>
         <xsl:variable name="item-content-caption" select="./caption"/>
         <xsl:variable name="item-permalink" select="concat($BaseURL, '/p/', ./code, '/')"/>
@@ -75,7 +88,7 @@
             </guid>
             <pubDate>
                 <xsl:variable name="timestamp" select="./date"/>
-                <xsl:value-of select="php:functionString('Tweeper::epochToRssDate', $timestamp)"/>
+                <xsl:value-of select="php:functionString('Tweeper\Tweeper::epochToRssDate', $timestamp)"/>
             </pubDate>
             <description>
                 <xsl:text disable-output-escaping="yes">&lt;![CDATA[</xsl:text>
                 <xsl:text disable-output-escaping="yes">]]&gt;</xsl:text>
             </description>
             <xsl:if test="$generate-enclosure = 1">
-                <xsl:copy-of select="php:functionString('Tweeper::generateEnclosure', $item-content-image)"/>
+                <xsl:copy-of select="php:functionString('Tweeper\Tweeper::generateEnclosure', $item-content-image)"/>
             </xsl:if>
         </item>
     </xsl:template>
 
     <xsl:template match="/">
+
         <xsl:variable name="channel-title" select="concat('Instagram / ', $screen-name)"/>
-        <xsl:variable name="channel-link" select="concat($BaseURL, '/', $user-name)"/>
+        <xsl:variable name="channel-link">
+            <xsl:choose>
+                <xsl:when test="$location-name != ''">
+                    <xsl:variable name="location-id" select="//LocationsPage/location/id"/>
+                    <xsl:value-of select="concat($BaseURL, '/explore/locations/', $location-id)"/>
+                </xsl:when>
+                <xsl:otherwise>
+                    <xsl:value-of select="concat($BaseURL, '/', $user-name)"/>
+                </xsl:otherwise>
+            </xsl:choose>
+        </xsl:variable>
+        <xsl:variable name="channel-image" select="//ProfilePage/user/profile_pic_url"/>
 
         <rss version="2.0">
             <xsl:attribute name="xml:base"><xsl:value-of select="$BaseURL" /></xsl:attribute>
                     </xsl:if>
                     <xsl:text disable-output-escaping="yes">]]&gt;</xsl:text>
                 </description>
-                <image>
-                    <title>
-                        <xsl:value-of select="$channel-title"/>
-                    </title>
-                    <link>
-                        <xsl:value-of select="$channel-link"/>
-                    </link>
-                    <url>
-                        <xsl:value-of select="//ProfilePage/user/profile_pic_url"/>
-                    </url>
-                </image>
-                <xsl:apply-templates select="//ProfilePage/user/media/nodes"/>
+                <xsl:if test="$channel-image != ''">
+                    <image>
+                        <title>
+                            <xsl:value-of select="$channel-title"/>
+                        </title>
+                        <link>
+                            <xsl:value-of select="$channel-link"/>
+                        </link>
+                        <url>
+                            <xsl:value-of select="$channel-image"/>
+                        </url>
+                    </image>
+                </xsl:if>
+                <xsl:apply-templates select="//ProfilePage/user/media/nodes|//LocationsPage/location/media/nodes"/>
             </channel>
         </rss>
     </xsl:template>