Пример #1
0
    def testExifPageVariables(self):
        """exif page template variables"""
        self._setTemplate("group basic;\n" \
                'page(gallery, css, js, class, tmpl, rootdir, copyright,' \
                '           album, photo, prev, next) ::=' \
                ' "\'$gallery.title$\'' \
                ' $css$' \
                ' $js$' \
                ' $class$' \
                ' $tmpl$' \
                ' $rootdir$' \
                ' $copyright$' \
                ' p:$prev.title$' \
                ' n:$next.title$' \
                ' $album.title$' \
                ' $photo.exif: {e | n:$e.name$v:$e.value$}$"')

        f = StringIO()
        album = Album()
        album.title = 'a title'
        album.dir = 'a/b/c'
        parent = self.tmpl.gallery
        parent.subalbums.append(album)

        p1 = Photo()
        p1.title = 'p1'
        p1.name = 'n1'
        p1.album = album

        p1.exif.append(Exif('ea', 'ev'))
        p1.exif.append(Exif('ez', 'eq'))

        p2 = Photo()
        p2.title = 'p2'
        p2.name = 'n2'
        p2.album = album

        album.photos.extend([p1, p2])

        self.tmpl.photoPage(f, p1)

        expected = '\'danlann title test\'' \
                ' css/danlann.css' \
                ' js/jquery.jsjs/danlann.js' \
                ' photo' \
                ' basic/photo' \
                ' ../../..' \
                ' (cc)' \
                ' p:' \
                ' n:p2' \
                ' a title' \
                ' n:eav:evn:ezv:eq\n'
        self.assertEquals(expected, f.getvalue())
Пример #2
0
    def get_album(self, node):
        """
        Create an album object for specified directory.

        If album is not found in reference hashtable nor in store, then new
        album is created.
        """
        dir = os.path.normpath(node.data[0])
        if dir in self.references:
            album = self.references[dir]
        elif dir in self.store:
            album = self.store[dir]
        else:
            album = Album()
            album.dir = dir
            album.gallery = self.gallery

            # add every album to root albums by default;
            # n_subalbum method removes an album from gallery subalbums
            # if an album becomes subalbum
            self.gallery.subalbums.append(album)
        return album
Пример #3
0
    def testAlbumPageVairables(self):
        """album page template variables"""
        self._setTemplate('group basic;\n' \
                'page(gallery, css, js, class, tmpl, rootdir, copyright,' \
                '           album, parent, prev, next) ::=' \
                ' "\'$gallery.title$\'' \
                ' $css$' \
                ' $js$' \
                ' $class$' \
                ' $tmpl$' \
                ' $rootdir$' \
                ' $copyright$' \
                ' p:$prev.title$' \
                ' n:$next.title$' \
                ' $parent.title$"')

        f = StringIO()
        a1 = Album()
        a1.title = 'a 1 title'
        a1.dir = 'a/b/c'
        a2 = Album()
        a2.title = 'a 2 title'
        a2.dir = 'a/b/d'
        parent = self.tmpl.gallery
        parent.subalbums.extend([a1, a2])

        self.tmpl.albumPage(f, a1, parent)

        expected = '\'danlann title test\'' \
                ' css/danlann.css' \
                ' js/jquery.jsjs/danlann.js' \
                ' album' \
                ' album' \
                ' ../../..' \
                ' (cc)' \
                ' p:' \
                ' n:a 2 title' \
                ' danlann title test\n'
        self.assertEquals(expected, f.getvalue())