Meeskond "Sepad"

From ICO wiki
Revision as of 18:09, 26 February 2011 by Sbaikov (talk | contribs) (→‎XSLT)
Jump to navigationJump to search

Kompanjonid

  • Sander Baikov
  • Karl Männil

Teema

Tekkis mõte teha kodune töö sel teemal mis oli ette valitud teemade hulgas. Mõtlesime et oleks vahva koguda RSS voogusid ning neid grupeerida. Noh vähemalt idee on selline, mis üldmõttes saab eks näis

XML fail

<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="xmlv1.xsl"?>
<groups>
  <group orderNr="0" minimized="false">
    <groupTitle>Ajalehed</groupTitle>
    <groupColor>LemonChiffon</groupColor> <!-- http://en.wikipedia.org/wiki/Web_colors#X11_color_names teenus pakub väiksemat arvu värve, värvid tõlgitakse rakenduse poolt-->
    <streams>
      <stream minimized="false">
        <streamTitle>Postimees.ee uudised</streamTitle>
        <streamRSSLink>http://www.postimees.ee/rss/</streamRSSLink>
        <streamSite>http://www.postimees.ee</streamSite>
        <description>Uudised, Sport, Ilm</description>
        <unreadNews>1</unreadNews>
        <items>
          <item status="unread">
            <id>a001</id>
            <title><![CDATA[Endine Tottenhami jalgpallur suri 36-aastaselt]]></title>
            <link>http://sport.postimees.ee/?id=394365</link>
            <description><![CDATA[Tottenham Hotspuri jalgpalliklubi teatas oma koduleheküljel, et nende endine mängumees Dean Richards suri täna hommikul raske haiguse tagajärjel. Richards oli alles 36-aastane.]]>
            </description>
            <pubDate>Sat, 26 Feb 2011 17:15:06 +0200</pubDate>
          </item>
          <item status="read">
            <id>a002</id>
            <title><![CDATA[Gorbatšov eitab jutte Leedu «müümisest»]]></title>
            <link>http://www.postimees.ee/?id=393271</link>
            <description>
              <![CDATA[Nõukogude Liidu ekspresident Mihhail Gorbatšov lükkab ümber meedias liikuva kuulujutu sellest, nagu oleks ta Leedult Nõukogude Liidust lahkumise eest küsinud 21 miljardit rubla.]]>
            </description>
            <pubDate>Thu, 24 Feb 2011 11:40:28 +0200</pubDate>
          </item>
        </items>
      </stream>
      <stream minimized="false">
        <streamTitle>Eesti Päevaleht Online</streamTitle>
        <streamRSSLink>http://www.epl.ee/rss/</streamRSSLink>
        <streamSite>http://www.epl.ee</streamSite>
        <description>Päevalehe artiklite rss voog.</description>
        <unreadNews>0</unreadNews>
        <items>
          <item status="read">
            <id>b002</id>
            <title><![CDATA[Verhofstadt ja Ojuland: Kremlile kollane kaart!]]></title>
            <link>http://www.epl.ee/artikkel/593251</link>
            <description>
              <![CDATA[Euroopa Liberaalide ja Demokraatide Liidu fraktsiooni esimees Guy Verhofstadt ja kõneisik Venemaa küsimustes Kristiina Ojuland avaldasid täna ajalehes European Voice avaliku kirja Venemaa peaminister Vladimir Putinile, kes viibib visiidil Brüsselis.]]>
            </description>
            <pubDate>Thu, 24 Feb 2011 11:21:00 +0200</pubDate>
          </item>
        </items>
      </stream>
    </streams>
  </group>
  <group orderNr="1" minimized="false">
    <groupTitle>Blogid</groupTitle>
    <groupColor>LightCyan</groupColor>
    <streams>
      <stream minimized="false">
        <streamTitle>Ars Technica</streamTitle>
        <streamRSSLink>http://feeds.arstechnica.com/arstechnica/everything</streamRSSLink>
        <streamSite>http://arstechnica.com/index.php</streamSite>
        <description>The Art of Technology</description>
        <unreadNews>1</unreadNews>
        <items>
          <item status="unread">
            <id>i0001</id>
            <title><![CDATA[Colbert Report features Ars Anonymous/HBGary coverage]]></title>
            <link>http://feeds.arstechnica.com/~r/arstechnica/everything/~3/jMUOaOUlnHw/our-anonymous-hbgary-coverage-on-colbert-report.ars</link>
            <description>
                <![CDATA[Last night, comedian Stephen Colbert featured the HBGary Federal/Anonymous hacking debacle in a long segment on his show, The Colbert Report—and Ars was proud to be featured twice in the segment. Does this make us an official "friend of the show"?
Colbert twice showed clips from our investigative piece Spy games: Inside the convoluted plot to bring down WikiLeaks as he described the behavior of HBGary Federal CEO Aaron Barr. (The show used a copy of the piece that ran on our sister publication, Wired.com, for the image.) Barr's decision to unmask the leaders of Anonymous was described in a particularly… evocative metaphor.]]>
              </description>
            <pubDate>Fri, 25 Feb 2011 16:35:56 -0600</pubDate>
          </item>
        </items>
      </stream>
    </streams>
  </group>
</groups>

XML Schema

<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="groups">
    <xs:complexType>
      <xs:sequence>
        <xs:element maxOccurs="unbounded" name="group">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="groupTitle" type="xs:string" />
              <xs:element name="groupColor" type="xs:string" />
              <xs:element name="streams">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element maxOccurs="unbounded" name="stream">
                      <xs:complexType>
                        <xs:sequence>
                          <xs:element name="streamTitle" type="xs:string" />
                          <xs:element name="streamRSSLink" type="xs:string" />
                          <xs:element name="streamSite" type="xs:string" />
                          <xs:element name="description" type="xs:string" />
                          <xs:element name="unreadNews" type="xs:unsignedByte" />
                          <xs:element name="items">
                            <xs:complexType>
                              <xs:sequence>
                                <xs:element maxOccurs="unbounded" name="item">
                                  <xs:complexType>
                                    <xs:sequence>
                                      <xs:element name="id" type="xs:string" />
                                      <xs:element name="title" type="xs:string" />
                                      <xs:element name="link" type="xs:string" />
                                      <xs:element name="description" type="xs:string" />
                                      <xs:element name="pubDate" type="xs:string" />
                                    </xs:sequence>
                                    <xs:attribute name="status" type="xs:string" use="required" />
                                  </xs:complexType>
                                </xs:element>
                              </xs:sequence>
                            </xs:complexType>
                          </xs:element>
                        </xs:sequence>
                        <xs:attribute name="minimized" type="xs:boolean" use="required" />
                      </xs:complexType>
                    </xs:element>
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
            </xs:sequence>
            <xs:attribute name="orderNr" type="xs:unsignedByte" use="required" />
            <xs:attribute name="minimized" type="xs:boolean" use="required" />
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

XSLT

Esialgne versioon

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:template match="/">
    <html>
      <head>
        <style>
          h1,h2,h3
          {
          font-family:Tahoma, Geneva, sans-serif;
          margin:0;
          }
          h1
          {
          text-transform:uppercase;
          font-size:1em;
          border-bottom:1px dotted black;
          }
          h2
          {
          font-size:0.95em;
          font-weight:normal;
          }
          h3
          {
          font-size:0.9em;
          font-weight:inherit;
          }
          p
          {
          padding:0 15px;
          margin:0;
          font-family:Georgia, serif;
          font-size:0.875em;
          width:600px; /*TODO: temporary*/
          }
          .unread
          {font-weight:bold;}
          .read
          {font-weight:normal;}
          .stream
          {padding-left:5px;}
          .items
          {
          padding-left:15px;
          border-left:1px dotted black;
          }
        </style>
        <script type="text/javascript">
          function minmax (elem)
          {
            elem = document.getElementById(elem);
              if(elem.style.display == 'none'){
                elem.style.display = 'block';
              }else{
                elem.style.display = 'none';
              }
          }
        </script>
      </head>
      <body>
        <xsl:for-each select="groups/group">
          <div style="background-color:{groupColor}">
            <div id="{@ordernr}"><h1><xsl:value-of select="groupTitle"/></h1>
            </div>
            <xsl:if test="@minimized = 'false'">
              <xsl:for-each select="streams/stream">
                <xsl:if test="@minimized = 'false'">
                <div class="stream">
                  <div>
                    <h2><xsl:value-of select="streamTitle"/></h2>
                  </div>
                  <xsl:for-each select="items/item">
                    <div id="{id}" class="items">
                      <div class="{@status}" onclick="minmax('{id}desc');">
                        <xsl:value-of select="title"/>
                      </div>
                      <p id="{id}desc" style="display:none;">
                        <xsl:value-of select="description"/>&#32;
                        <a href="{link}" target="_blank">(Loe edasi)</a>
                      </p>
                    </div>
                  </xsl:for-each>
                </div>
                </xsl:if>
              </xsl:for-each>
            </xsl:if>
          </div>
        </xsl:for-each>
      </body>
    </html>
  </xsl:template>
</xsl:stylesheet>

XSLT tulemus

Meilid

  • sbaikov@itcollege.ee
  • kmannil@itcollege.ee