Example #1
0
	def set_tts(self, article):
		tts_util=TTSUtil()
		content=""
		tts_urls=[]
		# render the title	
		tts_urls.extend(tts_util.get_tts_url_from_html(article.title))
		# render the author
		tts_urls.extend(tts_util.get_tts_url_from_html("Escrito por " + article.author.nickname))
		# render the content
		tts_urls.extend(tts_util.get_tts_url_from_html(article.content))
		# get the stream
		content=tts_util.get_tts_stream_from_tts_urs(tts_urls) 
		
		# TODO Removed because fail ...
		#article.content_tts.tts_stream=content
		#article.content_tts.tts_urls=tts_urls
		
Example #2
0
 def set_tts(self, article):
     tts_util = TTSUtil()
     content = ""
     tts_urls = []
     # render the title
     tts_urls.extend(tts_util.get_tts_url_from_html(article.title))
     # render the author
     tts_urls.extend(
         tts_util.get_tts_url_from_html("Escrito por " +
                                        article.author.nickname))
     # render the content
     tts_urls.extend(tts_util.get_tts_url_from_html(article.content))
     # get the stream
     content = tts_util.get_tts_stream_from_tts_urs(tts_urls)
Example #3
0
	def execute(self): 
		
		url_path = self.request.path.split('/', 3)[3]
		article_id = self.request.path.split('/')[3]
		article = self.cache(article_id + '_article', self.get_article)
		
		if not article:
			self.not_found()
			return
		
		if article.url_path != url_path:
			self.redirect('/module/article/%s' % article.url_path, permanent=True)
			return

		if not article.author_nickname:
			article.author_nickname = article.author.nickname
			article.put()
		
		user = self.values['user']
		if article.deletion_date and (not user or (user.rol != 'admin' and article.author_nickname != user.nickname)):
			self.values['article'] = article
			self.error(404)
			self.render('templates/module/article/article-deleted.html')
			return
		
		self.values['tab'] = '/module/article.list'
		
		if article.draft and (not user or not user.nickname == article.author_nickname):
			self.not_found()
			return


		if user and user.nickname != article.author_nickname:
			vote = model.Vote.gql('WHERE user=:1 AND article=:2', user, article).get()
			if not vote:
				self.values['canvote'] = True
		if user:
			added = model.Favourite.gql('WHERE user=:1 AND article=:2',user,article).get()
			if not added:
				self.values['canadd'] = True
		if user:
			if user.email in article.subscribers:
				self.values['cansubscribe'] = False
			else:
				self.values['cansubscribe'] = True

		
		self.values['article'] = article
		results = 10
		app = self.get_application()
		if app.max_results_sublist:
			results = app.max_results_sublist
		query = model.Comment.all().filter('article =', article)
		comments = self.paging(query, results, 'creation_date', article.responses, 'creation_date')
		# migration
		i = 1
		for c in comments:
			if not c.author_nickname:
				c.author_nickname = c.author.nickname
				c.put()
			if not c.response_number:
				c.response_number = i
				c.put()
			i += 1
		# end migration
		self.values['comments'] = comments
		self.values['a'] = 'comments'
		self.values['keywords'] = ', '.join(article.tags)
		
		communities = model.CommunityArticle.all().filter('article', article).order('community_title')
		# communities = self.cache(str(article.key().id()) + '_communities', self.get_communities)
		self.values['communities'] = list(communities)
		
		if user and article.author_nickname == user.nickname:
			all_communities = list(model.CommunityUser.all().filter('user', user).order('community_title'))
			
			# TODO: this could be improved
			for g in communities:
				for gr in all_communities:
					if gr.community_url_path == g.community_url_path:
						all_communities.remove(gr)
				
			if all_communities:
				self.values['all_communities'] = all_communities

		self.values['content_html'] = self.cache(str(article.key().id()) + '_html', self.to_html)
		
		self.values['related'] = list(model.Recommendation.all().filter('article_from', article).order('-value').fetch(5))

		#self.render('templates/module/article/article-view.html')
		
		tts_util=TTSUtil()
		content=""
		tts_urls=[]
		# render the title	
		tts_urls.extend(tts_util.get_tts_url_from_html(article.title))
		# render the author
		tts_urls.extend(tts_util.get_tts_url_from_html("Escrito por " + article.author.nickname))
		# render the content
		tts_urls.extend(tts_util.get_tts_url_from_html(article.content))
		# get the stream
		content=tts_util.get_tts_stream_from_tts_urs(tts_urls) 
		self.response.headers['Content-Type'] = 'audio/x-mp3'
		self.response.out.write(content)
Example #4
0
    def execute(self):

        url_path = self.request.path.split('/', 3)[3]
        article_id = self.request.path.split('/')[3]
        article = self.cache(article_id + '_article', self.get_article)

        if not article:
            self.not_found()
            return

        if article.url_path != url_path:
            self.redirect('/module/article/%s' % article.url_path,
                          permanent=True)
            return

        if not article.author_nickname:
            article.author_nickname = article.author.nickname
            article.put()

        user = self.values['user']
        if article.deletion_date and (
                not user or (user.rol != 'admin'
                             and article.author_nickname != user.nickname)):
            self.values['article'] = article
            self.error(404)
            self.render('templates/module/article/article-deleted.html')
            return

        self.values['tab'] = '/module/article.list'

        if article.draft and (not user
                              or not user.nickname == article.author_nickname):
            self.not_found()
            return

        if user and user.nickname != article.author_nickname:
            vote = model.Vote.gql('WHERE user=:1 AND article=:2', user,
                                  article).get()
            if not vote:
                self.values['canvote'] = True
        if user:
            added = model.Favourite.gql('WHERE user=:1 AND article=:2', user,
                                        article).get()
            if not added:
                self.values['canadd'] = True
        if user:
            if user.email in article.subscribers:
                self.values['cansubscribe'] = False
            else:
                self.values['cansubscribe'] = True

        self.values['article'] = article
        results = 10
        app = self.get_application()
        if app.max_results_sublist:
            results = app.max_results_sublist
        query = model.Comment.all().filter('article =', article)
        comments = self.paging(query, results, 'creation_date',
                               article.responses, 'creation_date')
        # migration
        i = 1
        for c in comments:
            if not c.author_nickname:
                c.author_nickname = c.author.nickname
                c.put()
            if not c.response_number:
                c.response_number = i
                c.put()
            i += 1
        # end migration
        self.values['comments'] = comments
        self.values['a'] = 'comments'
        self.values['keywords'] = ', '.join(article.tags)

        communities = model.CommunityArticle.all().filter(
            'article', article).order('community_title')
        # communities = self.cache(str(article.key().id()) + '_communities', self.get_communities)
        self.values['communities'] = list(communities)

        if user and article.author_nickname == user.nickname:
            all_communities = list(model.CommunityUser.all().filter(
                'user', user).order('community_title'))

            # TODO: this could be improved
            for g in communities:
                for gr in all_communities:
                    if gr.community_url_path == g.community_url_path:
                        all_communities.remove(gr)

            if all_communities:
                self.values['all_communities'] = all_communities

        self.values['content_html'] = self.cache(
            str(article.key().id()) + '_html', self.to_html)

        self.values['related'] = list(model.Recommendation.all().filter(
            'article_from', article).order('-value').fetch(5))

        #self.render('templates/module/article/article-view.html')

        tts_util = TTSUtil()
        content = ""
        tts_urls = []
        # render the title
        tts_urls.extend(tts_util.get_tts_url_from_html(article.title))
        # render the author
        tts_urls.extend(
            tts_util.get_tts_url_from_html("Escrito por " +
                                           article.author.nickname))
        # render the content
        tts_urls.extend(tts_util.get_tts_url_from_html(article.content))
        # get the stream
        content = tts_util.get_tts_stream_from_tts_urs(tts_urls)
        self.response.headers['Content-Type'] = 'audio/x-mp3'
        self.response.out.write(content)