예제 #1
0
    def sitemaps(self):
        header = u'''<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
        xmlns:image="http://www.sitemaps.org/schemas/sitemap-image/1.1"
        xmlns:video="http://www.sitemaps.org/schemas/sitemap-video/1.1">\n'''
        footer = u'''</urlset>'''

        model = u'''<url><loc>%s</loc><changefreq>daily</changefreq></url>\n'''
        xmls = u''
        
        xmls += u"\n<!-- HOME -->\n"
        xmls += model%(u'http://renatopp.com')

        xmls += u"\n<!-- POSTS AND PAGES -->\n"
        posts = Session.query(Post).filter(Post.status=='Published').order_by(desc(Post.id)).all()
        for post in posts:
            if post.type == 'page':
                xmls += model%url('page', self.request, alias=post.alias)
            else:
                xmls += model%url('blog_entry', self.request, id=post.id, alias=post.alias)

        xmls += u"\n<!-- SNIPPETS -->\n"
        snippets = Session.query(Snippet).order_by(desc(Snippet.id)).all()
        for snippet in snippets:
            xmls += model%url('snippet_entry', self.request, id=snippet.id, alias=snippet.alias)
        
        return Response(header + xmls + footer)
예제 #2
0
    def sitemaps(self):
        header = u'''<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
        xmlns:image="http://www.sitemaps.org/schemas/sitemap-image/1.1"
        xmlns:video="http://www.sitemaps.org/schemas/sitemap-video/1.1">\n'''
        footer = u'''</urlset>'''

        model = u'''<url><loc>%s</loc><changefreq>daily</changefreq></url>\n'''
        xmls = u''

        xmls += u"\n<!-- HOME -->\n"
        xmls += model % (u'http://renatopp.com')

        xmls += u"\n<!-- POSTS AND PAGES -->\n"
        posts = Session.query(Post).filter(
            Post.status == 'Published').order_by(desc(Post.id)).all()
        for post in posts:
            if post.type == 'page':
                xmls += model % url('page', self.request, alias=post.alias)
            else:
                xmls += model % url(
                    'blog_entry', self.request, id=post.id, alias=post.alias)

        xmls += u"\n<!-- SNIPPETS -->\n"
        snippets = Session.query(Snippet).order_by(desc(Snippet.id)).all()
        for snippet in snippets:
            xmls += model % url('snippet_entry',
                                self.request,
                                id=snippet.id,
                                alias=snippet.alias)

        return Response(header + xmls + footer)
예제 #3
0
    def articles(self):
        feed = feedgenerator.Rss201rev2Feed(
            title="Renatopp's - Feed dos Artigos",
            link=self.request.host_url,
            description="Artigos do super ultra hyper mega site http://renatopp.com",
            author_name=self.author
        )

        posts = Session.query(Post).order_by(desc(Post.id)).filter(Post.type=='article').filter(Post.status=='Published').limit(10).all()
        for post in posts:
            summary = post.content[:200].replace('\n', '<br>')
            categorys = ', '.join([c.name for c in post.categorys]) or 'Sem Categoria'
            description = u"""
            %s (...)<br><br>
            Categorias: %s<br>
            Visite <a href="http://renatopp.com">renatopp.com</a>
            """ % (summary, categorys)

            feed.add_item(
                title=post.title,
                link=url('blog_entry', self.request, id=post.id, alias=post.alias), 
                description=description,
                author_name=self.author
            )
        return Response(feed.writeString('utf-8'))
예제 #4
0
    def snippets(self):
        feed = feedgenerator.Rss201rev2Feed(
            title="Renatopp's - Feed dos Snippets",
            link=self.request.host_url,
            description="Snippets do super ultra hyper mega site http://renatopp.com",
            author_name=self.author
        )

        snippets = Session.query(Snippet).order_by(desc(Snippet.id)).limit(10).all()
        for snippet in snippets:
            summary = snippet.summary or u'Sem descrição'
            language = snippet.language
            category = ', '.join([c.name for c in snippet.categorys]) or 'Sem Categoria'

            description = u"""
            %s<br>
            <br>
            Linguagem: %s <br>
            Categorias: %s <br>
            Visite o site para mais informações - 
            <a href="http://renatopp.com">renatopp.com</a>.
            """ % (summary, language, category)

            feed.add_item(
                title=snippet.title,
                link=url('snippet_entry', self.request, id=snippet.id, alias=snippet.alias), 
                description=description,
                author_name="Renato Pereira"
            )

        return Response(feed.writeString('utf-8'))
예제 #5
0
    def articles(self):
        feed = feedgenerator.Rss201rev2Feed(
            title="Renatopp's - Feed dos Artigos",
            link=self.request.host_url,
            description=
            "Artigos do super ultra hyper mega site http://renatopp.com",
            author_name=self.author)

        posts = Session.query(Post).order_by(desc(
            Post.id)).filter(Post.type == 'article').filter(
                Post.status == 'Published').limit(10).all()
        for post in posts:
            summary = post.content[:200].replace('\n', '<br>')
            categorys = ', '.join([c.name
                                   for c in post.categorys]) or 'Sem Categoria'
            description = u"""
            %s (...)<br><br>
            Categorias: %s<br>
            Visite <a href="http://renatopp.com">renatopp.com</a>
            """ % (summary, categorys)

            feed.add_item(title=post.title,
                          link=url('blog_entry',
                                   self.request,
                                   id=post.id,
                                   alias=post.alias),
                          description=description,
                          author_name=self.author)
        return Response(feed.writeString('utf-8'))
예제 #6
0
    def snippets(self):
        feed = feedgenerator.Rss201rev2Feed(
            title="Renatopp's - Feed dos Snippets",
            link=self.request.host_url,
            description=
            "Snippets do super ultra hyper mega site http://renatopp.com",
            author_name=self.author)

        snippets = Session.query(Snippet).order_by(desc(
            Snippet.id)).limit(10).all()
        for snippet in snippets:
            summary = snippet.summary or u'Sem descrição'
            language = snippet.language
            category = ', '.join([c.name for c in snippet.categorys
                                  ]) or 'Sem Categoria'

            description = u"""
            %s<br>
            <br>
            Linguagem: %s <br>
            Categorias: %s <br>
            Visite o site para mais informações - 
            <a href="http://renatopp.com">renatopp.com</a>.
            """ % (summary, language, category)

            feed.add_item(title=snippet.title,
                          link=url('snippet_entry',
                                   self.request,
                                   id=snippet.id,
                                   alias=snippet.alias),
                          description=description,
                          author_name="Renato Pereira")

        return Response(feed.writeString('utf-8'))
예제 #7
0
    def login(self):
        form = FieldSet(User, data=self.request.POST if self.request.POST else None)
        form.configure(
            include=[form.email, form.password],
            options=[
                form.password.password()
            ]
        )

        if self.request.POST:
            user = Session.query(User).filter(
                (User.email==self.request.POST['User--email']) &
                (User.password==User.get_pass_hash(self.request.POST['User--password']))
            ).first()

            if user is not None:
                session = self.request.session
                session['user_id'] = user.id
                session['user_name'] = user.nickname
                session['user_email'] = user.email

                return HTTPFound(location=self.request.GET.get('back_to', url('post', self.request)))
        
        print '\n\n\n\n\n'
        return dict(form=form)
예제 #8
0
    def login(self):
        form = FieldSet(User,
                        data=self.request.POST if self.request.POST else None)
        form.configure(include=[form.email, form.password],
                       options=[form.password.password()])

        if self.request.POST:
            user = Session.query(User).filter(
                (User.email == self.request.POST['User--email'])
                & (User.password == User.get_pass_hash(
                    self.request.POST['User--password']))).first()

            if user is not None:
                session = self.request.session
                session['user_id'] = user.id
                session['user_name'] = user.nickname
                session['user_email'] = user.email

                return HTTPFound(location=self.request.GET.get(
                    'back_to', url('post', self.request)))

        print '\n\n\n\n\n'
        return dict(form=form)