Ejemplo n.º 1
0
    def root(self, request, **kwargs):

        try:
            offset = int(kwargs.get('page'))
            if offset <= 0:
                offset = 1
        except (ValueError, TypeError):
            offset = 1

        session = request.getSession()
        session.referer = '{}?page={}'.format(
            request.prePathURL(), kwargs.get('page', 1)
        )

        controller.toggle_menu(controller.BLOG)
        template_args = controller.template_args

        limit = config.Application().blog['posts_limit']
        posts, total = yield Post().get_posts(offset, limit)
        if offset > total:
            defer.returnValue(
                Ok(self.template.render(**template_args).encode('utf8')))

        template_args['posts'] = posts
        template_args['pagination'] = self.generate_pagination(
            offset, limit, total
        )

        defer.returnValue(
            Ok(self.template.render(**template_args).encode('utf8')))
Ejemplo n.º 2
0
    def root(self, request, **kwargs):
        """Renders downloads main page
        """

        controller.toggle_menu(controller.DOWNLOAD)
        template_args = controller.template_args

        template_args['releases'] = yield self.generate_releases()
        template_args['old_releases'] = yield self.generate_old_releases()

        defer.returnValue(
            Ok(self.template.render(**template_args).encode('utf-8')))
Ejemplo n.º 3
0
    def read(self, request, post_id, **kwargs):
        """Read an specific post
        """

        session = request.getSession()
        controller.toggle_menu(controller.BLOG)
        template_args = controller.template_args

        template_args['referer'] = session.__dict__.get('referer', '')
        template_args['post'] = yield Post().read(post_id)
        defer.returnValue(
            Ok(self.template.render(**template_args).encode('utf8')))
Ejemplo n.º 4
0
    def root(self, request, **kwargs):
        controller.toggle_menu(controller.CONTACT)
        template_args = controller.template_args

        return Ok(self.template.render(**template_args).encode("utf-8"))