Skip to content
Snippets Groups Projects

Adding image pagination

Merged ChiWai Chan requested to merge chiwai.chan/ligo-scald:feature-image-pagination into master
3 files
+ 89
5
Compare changes
  • Side-by-side
  • Inline
Files
3
+ 30
1
@@ -294,6 +294,35 @@ class ImageGrid(Content):
return self
class ImagePagination(Content):
_type = 'image_pagination'
def __init__(self, title, footer=None, visible=True, **kwargs):
super(ImagePagination, self).__init__(**kwargs)
self.title = title
self.visible = visible
self.footer = footer
self.images = []
self.content.update({'title': self.title, 'images': self.images, 'visible': self.visible})
if self.footer:
self.content['footer'] = self.footer
self.content.update(kwargs)
def __iadd__(self, image):
self.images.append(image.content)
return self
def __len__(self):
return len(self.images)
def glob(self, glob_path):
for path in sorted(glob.glob(glob_path)):
self.images.append(Image(path=path).content)
self.images.sort(key = lambda x: x['path'])
return self
class Table(Content):
_type = 'table'
@@ -353,7 +382,7 @@ class Description(Content):
def save_content(webdir, config):
for content in config:
if 'image_grid' in content['name']:
if 'image_grid' in content['name'] or 'image_pagination' in content['name']:
for image in content['images']:
if 'path' in image.keys():
shutil.copy2(image['path'], os.path.join(webdir, 'images'))
Loading