def get(self): ua = self.request.headers.get('User-Agent', 'bot') path = get_path(ua, 'douban_dashboard.html') rdic = {} source = self.request.get('from', None) message = '' if source: session = Session(self) message = session.get('message','') session.delete('message') rdic['message'] = message qs = dbs.Vigo.get('oauth_douban') if not qs: return self.redirect('/god/douban/login') api = pydouban.Api() api.set_qs_oauth(config.douban_key, config.douban_secret, qs) profile = memcache.get('douban/profile') if profile is None: profile = api.get_profile() memcache.set('douban/profile', profile, day) rdic['profile'] = profile miniblogs = memcache.get('douban/miniblogs') if miniblogs is None: miniblogs = api.get_contacts_miniblog() for i in range(len(miniblogs.entry)): miniblogs.entry[i].published.t = datetime.datetime.strptime( miniblogs.entry[i].published.t, '%Y-%m-%dT%H:%M:%S+08:00') miniblogs.entry[i].published.t -= datetime.timedelta(hours=8) memcache.set('douban/miniblogs', miniblogs, 240) rdic['miniblogs'] = miniblogs return self.response.out.write(render(path, rdic))
def get(self): rdic = {} source = self.request.get('from', None) message = '' if source: session = Session(self) message = session.get('message','') session.delete('message') rdic['message'] = message comments = memcache.get('disqus$comments') ua = self.request.headers.get('User-Agent', 'bot') path = get_path(ua, 'dashboard.html') rdic['notes'] = dbs.Note.getten() if comments is not None: rdic['comments'] = comments return self.response.out.write(render(path,rdic)) disqus_key = dbs.Vigo.get('disqus_key') disqus_forumid = dbs.Vigo.get('disqus_forumid') mydisqus = Disqus(disqus_key) mydisqus.get_forum_posts_rpc(disqus_forumid) result = mydisqus.get_forum_posts_result() comments = mydisqus.parse_data(result) memcache.set('god$comments', comments, 10800) # 3 hours rdic['comments'] = comments return self.response.out.write(render(path,rdic))
def get(self): source = self.request.get('from', None) message = '' if source: session = Session(self) message = session.get('message','') session.delete('message') status = self.request.get('filter', 'none') rdic = {} rdic['message'] = message data = self.get_filter(status) p = self.request.get('p',1) rdic['mvdata'] = Paginator(data, count, p) ua = self.request.headers.get('User-Agent', 'bot') path = get_path(ua, 'melody.html') return self.response.out.write(render(path,rdic))
def get(self): source = self.request.get('from', None) message = '' if source: session = Session(self) message = session.get('message','') session.delete('message') rdic = {} action = self.request.get('action', 'none').lower() key = self.request.get('key', 'none') status = self.request.get('draft', '2') if 'draft' == action or 'post' == action: art = db.get(key) if art and 'draft' == action: art.draft = True art.put() memcache.delete('a/' + art.slug) memcache.delete('a$ten') elif art and 'post' == action: art.draft = False art.put() memcache.delete('a/' + art.slug) memcache.delete('a$ten') else: session = Session(self) session['message'] = "Can't find the article" return self.redirect('/god/article?from='+action) if 'filter' == action: data = self.get_filter(status) elif 'find' == action: data = self.get_find(key) else: data = dbs.Article.gql('ORDER BY created DESC') rdic['message'] = message p = self.request.get('p',1) rdic['mvdata'] = Paginator(data, count, p) ua = self.request.headers.get('User-Agent', 'bot') path = get_path(ua, 'article.html') return self.response.out.write(render(path,rdic))
def get(self): ua = self.request.headers.get('User-Agent', 'bot') path = get_path(ua, 'twitter_dashboard.html') rdic = {} source = self.request.get('from', None) message = '' if source: session = Session(self) message = session.get('message','') session.delete('message') rdic['message'] = message qs = dbs.Vigo.get('oauth_twitter') if not qs: return self.redirect('/god/twitter/login') api = Twitter().set_qs_api(qs) statuses = memcache.get('twitter$home') if statuses is None: statuses = api.GetFriendsTimeline(count=30, retweets=True) for i in range(len(statuses)): statuses[i].datetime = datetime.datetime.\ fromtimestamp(time.mktime(time.strptime(statuses[i].created_at, '%a %b %d %H:%M:%S +0000 %Y'))) memcache.set('twitter$home', statuses, 120) rdic['statuses'] = statuses return self.response.out.write(render(path, rdic))