summaryrefslogtreecommitdiff
path: root/templates/google/searchresults.xsl
blob: 863d1d859e476306a3bd2873da9a0755fa88a72d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?xml version="1.0" encoding="ISO-8859-1"?>

<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:str="http://exslt.org/strings">

<xsl:template match="/">
<wvmenu>
  <title>Search results</title>

  <xsl:choose>
    <xsl:when test="not(//div[@class='rl-item'])">
      <textarea>
        <label>
          <xsl:text>Your search did not return any results.</xsl:text>
        </label>
      </textarea>
    </xsl:when>

    <xsl:otherwise>
      <xsl:for-each select="//div[@class='rl-item']">
        <xsl:choose>
          <xsl:when test="starts-with(div/@srcurl, 'http://www.youtube.com/')">
	    <link>
	      <label><xsl:value-of select="normalize-space(div/div/div[@class='rl-title']/a)" /></label>
	      <stream>wvt:///youtube/video.xsl?srcurl=<xsl:value-of select="str:encode-uri(div/@srcurl, true())"/></stream>
	      <ref>wvt:///youtube/description.xsl?srcurl=<xsl:value-of select="str:encode-uri(concat('http://gdata.youtube.com/feeds/api/videos/', substring-after(div/@srcurl, 'v='), '?v=2'), true())"/></ref>
	    </link>
          </xsl:when>

          <xsl:when test="starts-with(div/@srcurl, 'http://video.google.com/')">
	    <link>
	      <label><xsl:value-of select="normalize-space(div/div/div[@class='rl-title']/a)"/></label>
	      <stream>wvt:///google/video.xsl?srcurl=<xsl:value-of select="str:encode-uri(div/@srcurl, true())"/></stream>
	      <ref>wvt:///google/description.xsl?srcurl=<xsl:value-of select="str:encode-uri(div/@srcurl, true())"/></ref>
	    </link>
          </xsl:when>

          <xsl:when test="starts-with(div/@srcurl, 'http://www.metacafe.com/')">
	    <link>
	      <label><xsl:value-of select="normalize-space(div/div/div[@class='rl-title']/a)"/></label>
	      <stream>wvt:///metacafe/video.xsl?srcurl=<xsl:value-of select="str:encode-uri(div/@srcurl)"/></stream>
	      <ref>wvt:///metacafe/description.xsl?srcurl=<xsl:value-of select="str:encode-uri(div/@srcurl)"/></ref>
	    </link>
          </xsl:when>

          <xsl:when test="starts-with(div/@srcurl, 'http://vimeo.com/')">
	    <link>
	      <label><xsl:value-of select="normalize-space(div/div/div[@class='rl-title']/a)"/></label>
	      <stream>wvt:///vimeo/video.xsl?srcurl=http://www.vimeo.com/moogaloop/load/clip:<xsl:value-of select="substring-after(div/@srcurl, 'http://vimeo.com/')"/></stream>
	      <ref>wvt:///vimeo/description.xsl?srcurl=http://vimeo.com/api/v2/video/<xsl:value-of select="substring-after(div/@srcurl, 'http://vimeo.com/')"/>.xml</ref>
	    </link>
          </xsl:when>

          <xsl:when test="starts-with(div/@srcurl, 'http://svtplay.se/')">
	    <link>
	      <label><xsl:value-of select="normalize-space(div/div/div[@class='rl-title']/a)"/></label>
              <stream>wvt:///svtplay/video.xsl?srcurl=<xsl:value-of select="str:encode-uri(div/@srcurl, true())"/></stream>
              <ref>wvt:///svtplay/description.xsl?srcurl=<xsl:value-of select="str:encode-uri(div/@srcurl, true())"/></ref>
	    </link>
          </xsl:when>

        </xsl:choose>
      </xsl:for-each>

      <xsl:if test="//td[@class='prev']/a">
        <link>
          <label>Previous</label>
          <ref>wvt:///google/searchresults.xsl?srcurl=<xsl:value-of select="str:encode-uri(//td[@class='prev']/a/@href, true())"/></ref>
        </link>
      </xsl:if>

      <xsl:if test="//td[@class='next']/a">
        <link>
          <label>Next</label>
          <ref>wvt:///google/searchresults.xsl?srcurl=<xsl:value-of select="str:encode-uri(//td[@class='next']/a/@href, true())"/></ref>
        </link>
      </xsl:if>
    </xsl:otherwise>
  </xsl:choose>

</wvmenu>
</xsl:template>

</xsl:stylesheet>