Ejemplo n.º 1
0
  def get(self, *args):
    self.response.headers.add_header('Content-Type', 'application/xml')
    
    # <?xml version="1.0" encoding="UTF-8" ?>
    # <rss version="2.0">
    # <channel>
    #         <title>RSS Title</title>
    #         <description>This is an example of an RSS feed</description>
    #         <link>http://www.someexamplerssdomain.com/main.html</link>
    #         <lastBuildDate>Mon, 06 Sep 2010 00:01:00 +0000 </lastBuildDate>
    #         <pubDate>Mon, 06 Sep 2009 16:45:00 +0000 </pubDate>
    # 
    #         <item>
    #                 <title>Example entry</title>
    #                 <description>Here is some text containing an interesting description.</description>
    #                 <link>http://www.wikipedia.org/</link>
    #                 <guid>unique string per item</guid>
    #                 <pubDate>Mon, 06 Sep 2009 16:45:00 +0000 </pubDate>
    #         </item>
    # 
    # </channel>
    # </rss>    
    try:
      gists = Gists.fetch_by_user(args[0])
    
      feed = []
      feed.append('<?xml version="1.0" encoding="UTF-8" ?>')
      feed.append('<rss version="2.0">')
      feed.append('<channel>')
      feed.append('<title>Girsst for %s</title>' % args[0])
      feed.append('<description>Girsst converts your gists to RSS</description>')
      
      feed.append('<link>http://girsst.appspot.com</link>')

      for gist in gists:
        feed.append('<item>')
        feed.append('<link>http://gist.github.com/%s</link>' % gist.id)
        feed.append('<title>%s</title>' % gist.description)
        feed.append('<pubDate>%s</pubDate>' % gist.created_at)
        feed.append('<author>%s</author>' % gist.owner)
        
        if len(gist.filenames) == 1:
          feed.append('<description><![CDATA[ %s ]]></description>' % gist.files[gist.filenames[0]].getvalue())
        else:
          feed.append('<description>Snippit in %d files: %s</description>' % (len(gist.filenames), ', '.join(gist.filenames)))
          feed.append('<files>')
          for file in gist.files:
            feed.append('<file><![CDATA[ %s ]]></file>' % gist.files[file].getvalue())
          feed.append('</files>')
        
        feed.append('</item>')

      feed.append('</channel>')
      feed.append('</rss>')
      
      #self.response.out.write(feed.join)
      self.response.out.write(''.join(feed))
    except Exception:
      self.response.out.write('<error>Invalid username, or GitHub is being a bitch.</error>') 
Ejemplo n.º 2
0
    def test_gist_search(self):
        r1 = Gists.fetch_by_user('kennethreitz')[-1].description
        r2 = u'My .bashrc configuration'

        self.assertEqual(r1, r2)
Ejemplo n.º 3
0
    def test_gist_search(self):
        r1 = Gists.fetch_by_user('kennethreitz')[-1].description
        r2 = u'My .bashrc configuration'

        self.assertEqual(r1, r2)
Ejemplo n.º 4
0
    def get(self, *args):
        self.response.headers.add_header('Content-Type', 'application/xml')

        # <?xml version="1.0" encoding="UTF-8" ?>
        # <rss version="2.0">
        # <channel>
        #         <title>RSS Title</title>
        #         <description>This is an example of an RSS feed</description>
        #         <link>http://www.someexamplerssdomain.com/main.html</link>
        #         <lastBuildDate>Mon, 06 Sep 2010 00:01:00 +0000 </lastBuildDate>
        #         <pubDate>Mon, 06 Sep 2009 16:45:00 +0000 </pubDate>
        #
        #         <item>
        #                 <title>Example entry</title>
        #                 <description>Here is some text containing an interesting description.</description>
        #                 <link>http://www.wikipedia.org/</link>
        #                 <guid>unique string per item</guid>
        #                 <pubDate>Mon, 06 Sep 2009 16:45:00 +0000 </pubDate>
        #         </item>
        #
        # </channel>
        # </rss>
        try:
            gists = Gists.fetch_by_user(args[0])

            feed = []
            feed.append('<?xml version="1.0" encoding="UTF-8" ?>')
            feed.append('<rss version="2.0">')
            feed.append('<channel>')
            feed.append('<title>Girsst for %s</title>' % args[0])
            feed.append(
                '<description>Girsst converts your gists to RSS</description>')

            feed.append('<link>http://girsst.appspot.com</link>')

            for gist in gists:
                feed.append('<item>')
                feed.append('<link>http://gist.github.com/%s</link>' % gist.id)
                feed.append('<title>%s</title>' % gist.description)
                feed.append('<pubDate>%s</pubDate>' % gist.created_at)
                feed.append('<author>%s</author>' % gist.owner)

                if len(gist.filenames) == 1:
                    feed.append('<description><![CDATA[ %s ]]></description>' %
                                gist.files[gist.filenames[0]].getvalue())
                else:
                    feed.append(
                        '<description>Snippit in %d files: %s</description>' %
                        (len(gist.filenames), ', '.join(gist.filenames)))
                    feed.append('<files>')
                    for file in gist.files:
                        feed.append('<file><![CDATA[ %s ]]></file>' %
                                    gist.files[file].getvalue())
                    feed.append('</files>')

                feed.append('</item>')

            feed.append('</channel>')
            feed.append('</rss>')

            #self.response.out.write(feed.join)
            self.response.out.write(''.join(feed))
        except Exception:
            self.response.out.write(
                '<error>Invalid username, or GitHub is being a bitch.</error>')