예제 #1
0
        def get(self):
                logging.info('category list handler ')
                self.redirect_perm()
                self.get_user()
                logging.info('category screen_name %s' %self.screen_name)
                if self.avatar is None:
                        self.avatar='/static/images/noavatar.png'

                memcache_key='category_list'
                cached_category=memcache.get(memcache_key)
                categories={}
                if cached_category is not None:
                        logging.info('picking up cats from cache')
                        categories=cached_category
                else:
                        logging.info('fetching trending cats' )
                        categories = LinkCategory.get_trending()
                        next_hour = datetime.datetime.now() + datetime.timedelta(hours=1)
                        next_hour_ts = time.mktime(next_hour.timetuple())
                        if categories is not None and len(categories) > 0:
                                memcache.set(memcache_key, categories, time = next_hour_ts)

		template_variables = []
                if categories is None:
                        categories = LinkCategory.get_trending(24)
                else:
                        logging.info("got %s categories" % len(categories))
                template_variables = {'page_footer': PageUtils.get_footer(), 'user':self.screen_name, 'logout_url':'/account/logout', 'avatar':self.avatar,'categories':LinkUtils.getCategoryListHTML(categories)}
		path= os.path.join(os.path.dirname(__file__), 'templates/category_list.html')
                self.response.headers["Content-Type"] = "text/html; charset=utf-8"
		self.response.out.write(template.render(path,template_variables))
예제 #2
0
	def get(self, url_hash, title):
                try:
                        self.redirect_perm()
                        self.get_user()
                        url_hash = urllib.unquote(url_hash)
		        logging.info('url hash: %s' % url_hash)
                        logging.info('category screen_name %s' %self.screen_name)
			category=None
                        if self.avatar is None:
                                self.avatar='/static/images/noavatar.png'

                        sessionModel = SessionModel.gql('where url_encode26 = :1', url_hash).get()
                        if sessionModel is None:
                                logging.info('not article with hash %s ... redirecting' % url_hash)
                                self.redirect('/')
                                return
                        generated_title =  LinkUtils.make_title(sessionModel.title)
                        if title != generated_title:
                                self.redirect('/article/'+url_hash+'/'+generated_title)
                                return
                        instaright_link =  LinkUtils.generate_instaright_link(url_hash, generated_title)
                        links = Links.gql('where url_hash = :1', url_hash).get()
			userUtil = UserUtils()
                        if links is not None:
                                category = links.categories
                        sessionTitle = LinkUtils.generateUrlTitle(sessionModel.title)
                        template_variables = {'page_footer': PageUtils.get_footer(), 'user':self.screen_name, 'logout_url':'/account/logout', 'avatar':self.avatar,'story_avatar': userUtil.getAvatar(sessionModel.instaright_account), 'story_user': sessionModel.instaright_account, 'domain': sessionModel.domain, 'title':sessionModel.title, 'link': sessionModel.url, 'updated':sessionModel.date, 'id': str(sessionModel.key()), 'instaright_link': instaright_link, 'category': LinkUtils.getLinkCategoryHTML(sessionModel), 'dd': LinkUtils.generate_domain_link(sessionModel.domain)}
		        path = os.path.join(os.path.dirname(__file__), 'templates/article.html')
                        self.response.headers["Content-Type"] = "text/html; charset=utf-8"
		        self.response.out.write(template.render(path, template_variables))
                except:
                        e,e0 = sys.exc_info()[0], sys.exc_info()[1]
                        logging.error('handled error : %s, %s ' %( e, e0 ))
		        self.redirect('/')
예제 #3
0
        def get(self):
                self.redirect_perm()
                self.get_user()
                logging.info('screen_name %s' %self.screen_name)
                if self.avatar is None:
                        self.avatar='/static/images/noavatar.png'
		template_variables = []
                template_variables = {'page_footer':PageUtils.get_footer(), 'user':self.screen_name, 'logout_url':'/account/logout', 'avatar':self.avatar, 'env': ENVIRONMENT}
		path= os.path.join(os.path.dirname(__file__), 'templates/tools.html')
                self.response.headers["Content-Type"]= "text/html"
		self.response.out.write(template.render(path,template_variables))
예제 #4
0
        def get(self,domain):
                crawler = self.request.get('_escaped_fragment_', None)
                if crawler is not None:
                        self.html_snapshot(domain,'domain')
                        return
                logging.info('domain handler ')
                self.redirect_perm()
                self.get_user()
                logging.info('domain screen_name %s' %self.screen_name)
                if self.avatar is None:
                        self.avatar='/static/images/noavatar.png'

		userMessager = UserMessager(str(self.user_uuid))
		channel_id = userMessager.create_channel()

		template_variables = []
                template_variables = {'page_footer': PageUtils.get_footer(), 'user':self.screen_name, 'logout_url':'/account/logout', 'avatar':self.avatar,'channel_id':channel_id,'domain':domain}
		path= os.path.join(os.path.dirname(__file__), 'templates/domain.html')
                self.response.headers["Content-Type"] = "text/html; charset=utf-8"
		self.response.out.write(template.render(path,template_variables))
예제 #5
0
        def get(self):
                self.redirect_perm()
		template_variables = { 'page_footer': PageUtils.get_footer() }
		path= os.path.join(os.path.dirname(__file__), '../templates/import_tool.html')
                self.response.headers["Content-Type"] = "text/html; charset=utf-8"
		self.response.out.write(template.render(path,template_variables))
예제 #6
0
        def get(self):
                template_variables = {'page_footer': PageUtils.get_footer() }
		path= os.path.join(os.path.dirname(__file__), 'templates/privacy_policy.html')
                self.response.headers["Content-Type"] = "text/html; charset=utf-8"
		self.response.out.write(template.render(path,template_variables))
예제 #7
0
	def get(self):
                crawler = self.request.get('_escaped_fragment_', None)
                redirect = self.request.get('redirect', None)
                show_login= self.request.get('show_login', None)
                if crawler is not None:
                        self.html_snapshot()
                        return
                logging.info('got redirect %s' % redirect)
                #redirect from appengine domain
                self.redirect_perm()
                self.get_user()

		userMessager = UserMessager(str(self.user_uuid))
		channel_id = userMessager.create_channel()
		login_url = users.create_login_url('/')	
                if self.avatar is None:
                        self.avatar='/static/images/noavatar.png'
                template_variables = {'user':self.screen_name, 'login_url':login_url, 'logout_url':'/account/logout', 'channel_id':channel_id, 'hotlinks': None,'avatar':self.avatar, 'page_footer': PageUtils.get_footer(),'show_login': show_login}
		path= os.path.join(os.path.dirname(__file__), 'templates/index.html')
                self.response.headers["Content-Type"] = "text/html; charset=utf-8"
		self.response.out.write(template.render(path,template_variables))