Beispiel #1
0
    def list(self, page):
        try:
            int(page)
        except ValueError:
            abort(404)

        c.pages = list(self.db.view('galleries/count'))[0].value
        if c.pages % self.entries_per_page:
            c.pages += 1

        if int(page) <= c.pages:
            c.galleries = list(Gallery.by_date(
                    self.db,
                    descending=True,
                    limit=self.entries_per_page,
                    skip=self.entries_per_page * (int(page) - 1)
                    ))

            c.pages = list(self.db.view('galleries/count'))[0].value / self.entries_per_page
            if c.pages % self.entries_per_page == 0:
                c.pages += 1

            c.page = int(page)
            
            c.base_url = url(controller='gallery', action='list', page=0)[:-1]
            
            return render('/gallery/gallery_list.mako')
        else:
            abort(404)
Beispiel #2
0
    def show(self, slug):
        c.gallery = list(Gallery.by_slug(self.db, key=slug, limit=1))

        if not c.gallery or c.gallery[0].slug != slug:
            abort(404)
        else:
            c.gallery = c.gallery[0]
            
            return render('/gallery/show.mako')
Beispiel #3
0
    def all_images(self, tag=None):
        c.tag = tag
        if tag:
            c.galleries = list(Gallery.by_tag(
                    self.db,
                    descending=True,
                    startkey=[tag,{}],
                    endkey=[tag[:-1] + unichr(ord(tag[-1]) - 1)],
                    ))
        else:
            c.galleries = list(Gallery.by_date(self.db, descending=True))

        return render('/gallery/all_images.mako')
Beispiel #4
0
    def tag(self, tag, page=0):
        try:
            int(page)
        except ValueError:
            abort(404)

        c.pages = list(self.db.view('galleries/tag_count',
                                    group=True, key=tag))
        if c.pages:
            c.pages = c.pages[0].value
            c.pages = (c.pages % self.entries_per_page == 0) and \
                list(self.db.view('galleries/tag_count', group=True, key=tag))[0].value / self.entries_per_page or \
                list(self.db.view('galleries/tag_count', group=True, key=tag))[0].value / self.entries_per_page + 1
            page = int(page)
            if page <= c.pages:
                if page == 0:
                    redirect(url(controller='gallery', action='tag', tag=tag, page=1))
                else:
                    c.galleries = list(Gallery.by_tag(
                            self.db,
                            descending=True,
                            startkey=[tag,{}],
                            endkey=[tag[:-1] + unichr(ord(tag[-1]) - 1)],
                            skip=self.entries_per_page * (int(page) - 1),
                            limit=self.entries_per_page,
                            ))

                    c.page = page
                    c.base_url = url(controller='gallery', action='tag', tag=tag, page=0)[:-1]
                    
                    c.tag = tag
                    return render('/gallery/gallery_list.mako')
            else:
                abort(404)
        else:
            abort(404)
Beispiel #5
0
 def about(self):
     return render('/about.mako')
Beispiel #6
0
 def edit_gallery(self, id):
     c.gallery = Gallery.load(self.db, id)
     return render('/admin/edit_gallery.mako')
Beispiel #7
0
 def new_gallery(self):
     return render('/admin/new_gallery.mako')
Beispiel #8
0
    def galleries(self):
        c.galleries = Gallery.by_created(self.db, descending=True)

        return render('/admin/galleries.mako')
Beispiel #9
0
 def login(self):
     return render('/admin/login.mako')
Beispiel #10
0
 def images_delete_list(self, id):
     c.gallery = Gallery.load(self.db, id)
     
     return render('/admin/images_list.mako')