return None
return url[len(self._base_url):]
- def _url(self, path):
+ def _url(self, path, query=None):
relpath = _os_path.relpath(
_os_path.join(self._base_path, path), self._base_path)
if relpath == '.':
relpath = ''
elif path.endswith('/'):
relpath += '/'
+ if query:
+ relpath = '{}?{}'.format(relpath, _urllib_parse.urlencode(query))
return '{}{}'.format(self._base_url, relpath)
def _label(self, path):
dirname,base = _os_path.split(dirname)
return base.replace('_', ' ').title()
- def _link(self, path, text=None):
+ def _link(self, path, query=None, text=None):
if text is None:
text = self._label(path)
- return '<a href="{}">{}</a>'.format(self._url(path), text)
+ return '<a href="{}">{}</a>'.format(
+ self._url(path=path, query=query), text)
def _subdirs(self, path):
try:
def _directory_page_navigation(self, path, page, pages):
if pages <= 1:
return []
- prev_page = path + '?pp={:d}'.format((page - 1) % pages + 1)
- next_page = path + '?pp={:d}'.format((page + 1) % pages + 1)
+ prev_query = {'pp': (page - 1) % pages + 1}
+ next_query = {'pp': (page + 1) % pages + 1}
return [
'<div style="text-align: center;">',
'<p>',
- self._link(prev_page, 'previous'),
+ self._link(path=path, query=prev_query, text='previous'),
'({:d} of {:d})'.format(page+1, pages),
- self._link(next_page, 'next'),
+ self._link(path=path, query=next_query, text='next'),
'</p>',
'</div>',
]
for image in images:
page = self._image_page(image)
img = self._image(image, max_width=300, max_height=300)
- link = self._link(page, img)
+ link = self._link(path=page, text=img)
if column == 0:
content.append(' <tr>')
content.extend([
images_per_page = self._rows * self._columns
i = images.index(path)
page = i // images_per_page
- gallery_page = '{}/?pp={:d}'.format(gallery, page + 1)
+ gallery_page = '{}/'.format(gallery)
prev_page = self._image_page(images[i - 1])
next_page = self._image_page(images[(i + 1) % len(images)])
content = []
content.extend([
'<div style="text-align: center;">',
'<p>',
- self._link(prev_page, 'previous'),
- self._link(gallery_page, 'all'),
- self._link(next_page, 'next'),
+ self._link(path=prev_page, text='previous'),
+ self._link(
+ path=gallery_page, query={'pp': page+1}, text='all'),
+ self._link(path=next_page, text='next'),
'</p>',
])
content.extend(self._captioned_video(path))