예제 #1
0
파일: media_page.py 프로젝트: dbw9580/sigal
    def write(self, album, media_group):
        """Generate the media page and save it"""

        from sigal import __url__ as sigal_link

        ctx = {
            "album": album,
            "media": media_group[0],
            "previous_media": media_group[-1],
            "next_media": media_group[1],
            "index_title": self.index_title,
            "settings": self.settings,
            "sigal_link": sigal_link,
            "theme": {
                "name": os.path.basename(self.theme),
                "url": url_from_path(os.path.relpath(self.theme_path, album.dst_path)),
            },
        }
        page = self.template.render(ctx)

        file_path = os.path.join(album.dst_path, media_group[0].dst_filename)
        output_file = f"{file_path}.html"

        with open(output_file, "w", encoding="utf-8") as f:
            f.write(page)
예제 #2
0
파일: media_page.py 프로젝트: uchit66/sigal
    def write(self, album, media_group):
        ''' Generate the media page and save it '''

        from sigal import __url__ as sigal_link
        file_path = os.path.join(album.dst_path, media_group[0].filename)

        page = self.template.render({
            'album': album,
            'media': media_group[0],
            'previous_media': media_group[-1],
            'next_media': media_group[1],
            'index_title': self.index_title,
            'settings': self.settings,
            'sigal_link': sigal_link,
            'theme': {
                'name':
                os.path.basename(self.theme),
                'url':
                url_from_path(os.path.relpath(self.theme_path, album.dst_path))
            },
        })

        output_file = "%s.html" % file_path

        with open(output_file, 'w', encoding='utf-8') as f:
            f.write(page)
예제 #3
0
파일: media_page.py 프로젝트: matze/sigal
    def write(self, album, media_group):
        ''' Generate the media page and save it '''

        file_path = os.path.join(album.dst_path, media_group[0].filename)

        page = self.template.render({
            'album': album,
            'media': media_group[0],
            'previous_media': media_group[-1],
            'next_media': media_group[1],
            'index_title': self.index_title,
            'settings': self.settings,
            'sigal_link': sigal_link,
            'theme': {'name': os.path.basename(self.theme),
                      'url': url_from_path(os.path.relpath(self.theme_path,
                                                           album.dst_path))},
        })

        output_file = "%s.html" % file_path

        with codecs.open(output_file, 'w', 'utf-8') as f:
            f.write(page)
예제 #4
0
def test_url_from_windows_path(monkeypatch):
    monkeypatch.setattr('os.sep', "\\")
    path = os.sep.join(['foo', 'bar'])
    assert path == r'foo\bar'
    assert utils.url_from_path(path) == 'foo/bar'
예제 #5
0
def test_url_from_path():
    assert utils.url_from_path(os.sep.join(['foo', 'bar'])) == 'foo/bar'
예제 #6
0
def test_url_from_windows_path(monkeypatch):
    monkeypatch.setattr('os.sep', "\\")
    path = os.sep.join(['foo', 'bar'])
    assert path == r'foo\bar'
    assert utils.url_from_path(path) == 'foo/bar'
예제 #7
0
def test_url_from_path():
    assert utils.url_from_path(os.sep.join(['foo', 'bar'])) == 'foo/bar'