Example #1
0
  def get(self):
    #get trends
    trendsData = twitter.getTrendsData()
    #get the date key of the trends
    #timeKey = trendsData['trends'].keys()[0]
    #get the trends
    #trendsData = trendsData['trends'][timeKey]
    #DONT NEED
    #create a csv list of trend names for use in a js array
    #trendlist = ','.join(["'" + trend['name'] + "'" for trend in trends])
    #parse the trends
    trendCollection = picfallHelper.parseTrendsData(trendsData);
    #json trend names
    #trendsjson = simplejson.JSONEncoder().encode(trendCollection.trends);
    lenbefore = len(trendCollection.trends)
    trendsjson = TrendEncoder().encode(trendCollection.trends);
    lenafter = len(trendCollection.trends)
    
    #trendsHTML = self.getTrendsHTML()
    #setup template
    template_values = {
      'title': "Trending Topics",
      'time': trendCollection.twitterTime,
      'trends': trendCollection.trends,
#      'trendlist': trendlist,
      'trendsjson': trendsjson,
      'lenbefore': lenbefore,
      'lenafter': lenafter,
      'lendata': trendCollection.lendata,
      }

    path = os.path.join(os.path.dirname(__file__), 'trends.html')
    self.response.out.write(template.render(path, template_values))
Example #2
0
 def get(self):    
   #get the raw trends
   trendsData = twitter.getTrendsData()
   #parse the trends
   trendCollection = picfallHelper.parseTrendsData(trendsData);
   #save the trends
   trendCollection.save()
   
   self.response.out.write("Trends Saved")
   
Example #3
0
 def get(self):    
   #json encode
   jsonTrends = twitter.getTrendsJSON()
   self.response.out.write(jsonTrends)
   
   trendsData = twitter.getTrendsData()
   #get the date key of the trends
   timeKey = trendsData['trends'].keys()[0]
   trends = trendsData['trends'][timeKey]
   self.response.out.write("<ol>")
   import urllib
   for trend in trends:
       self.response.out.write("<li>" + trend['name'] + " - url encoded: " + urllib.quote_plus(trend['name'].encode('utf-8')) + "</li>")
   self.response.out.write("</ol>")