Better handling of album urls (quoting special caracters).
This commit is contained in:
@@ -12,6 +12,7 @@ if not PY2:
|
||||
strxfrm = locale.strxfrm
|
||||
|
||||
from http import server
|
||||
from urllib.parse import quote as url_quote
|
||||
import socketserver
|
||||
else:
|
||||
text_type = unicode # NOQA
|
||||
@@ -21,6 +22,7 @@ else:
|
||||
def strxfrm(s):
|
||||
return locale.strxfrm(s.encode('utf-8'))
|
||||
|
||||
from urllib import quote as url_quote
|
||||
import SimpleHTTPServer as server
|
||||
import SocketServer as socketserver
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ from os.path import isfile, join, splitext
|
||||
from PIL import Image as PILImage
|
||||
|
||||
from . import image, video
|
||||
from .compat import UnicodeMixin, strxfrm
|
||||
from .compat import UnicodeMixin, strxfrm, url_quote
|
||||
from .image import process_image, get_exif_tags
|
||||
from .log import colored, BLUE
|
||||
from .settings import get_thumb
|
||||
@@ -182,7 +182,6 @@ class Album(UnicodeMixin):
|
||||
|
||||
# optionally add index.html to the URLs
|
||||
self.url_ext = self.output_file if settings['index_in_url'] else ''
|
||||
self.url = self.name + '/' + self.url_ext
|
||||
|
||||
self.index_url = url_from_path(os.path.relpath(
|
||||
settings['destination'], self.dst_path)) + '/' + self.url_ext
|
||||
@@ -252,8 +251,7 @@ class Album(UnicodeMixin):
|
||||
self.meta = md.Meta.copy()
|
||||
else:
|
||||
# default: get title from directory name
|
||||
self.title = os.path.basename(self.path).replace('_', ' ')\
|
||||
.replace('-', ' ').capitalize()
|
||||
self.title = os.path.basename(self.path)
|
||||
self.description = ''
|
||||
self.meta = {}
|
||||
|
||||
@@ -292,6 +290,12 @@ class Album(UnicodeMixin):
|
||||
return [self.gallery.albums[join(root_path, path)]
|
||||
for path in self.subdirs]
|
||||
|
||||
@property
|
||||
def url(self):
|
||||
"""URL of the album, relative to its parent."""
|
||||
url = self.name.encode('utf-8')
|
||||
return url_quote(url) + '/' + self.url_ext
|
||||
|
||||
@property
|
||||
def thumbnail(self):
|
||||
"""Path to the thumbnail of the album."""
|
||||
|
||||
@@ -26,7 +26,7 @@ REF = {
|
||||
'flickr_jerquiaga_2394751088_cc-by-nc.jpg'],
|
||||
},
|
||||
'dir1/test2': {
|
||||
'title': 'Test2',
|
||||
'title': 'test2',
|
||||
'name': 'test2',
|
||||
'thumbnail': 'test2/thumbnails/21.tn.jpg',
|
||||
'subdirs': [],
|
||||
@@ -43,14 +43,14 @@ REF = {
|
||||
'm57_the_ring_nebula-587px.jpg'],
|
||||
},
|
||||
u'accentué': {
|
||||
'title': u'Accentué',
|
||||
'title': u'accentué',
|
||||
'name': u'accentué',
|
||||
'thumbnail': u'accentué/thumbnails/hélicoïde.tn.jpg',
|
||||
'subdirs': [],
|
||||
'medias': [u'hélicoïde.jpg', 'superdupont_source_wikipedia_en.jpg'],
|
||||
},
|
||||
'video': {
|
||||
'title': 'Video',
|
||||
'title': 'video',
|
||||
'name': 'video',
|
||||
'thumbnail': ('video/thumbnails/'
|
||||
'stallman software-freedom-day-low.tn.jpg'),
|
||||
|
||||
Reference in New Issue
Block a user