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)
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)
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)
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'
def test_url_from_path(): assert utils.url_from_path(os.sep.join(['foo', 'bar'])) == 'foo/bar'
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'
def test_url_from_path(): assert utils.url_from_path(os.sep.join(['foo', 'bar'])) == 'foo/bar'