Skip to content

Commit

Permalink
fixed crop method text passing, updated bootstrap grid system
Browse files Browse the repository at this point in the history
  • Loading branch information
santonelli committed Jan 26, 2016
1 parent 680b89a commit 0d8b44c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
26 changes: 15 additions & 11 deletions src/operun/gallery/browser/gallery.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
from plone import api

import logging

logger = logging.getLogger(__name__)

class GalleryView(BrowserView):

Expand All @@ -16,26 +19,27 @@ def __call__(self):

return self.template()

def crop(self, text, count):
def crop(self, text="", count=0):
"""
Crop given text to given count.
"""
cropped_text = ' '.join((text[0:count].strip()).split(' ')[:-1])

strips = ['.', ',', ':', ';']
for s in strips:
cropped_text = cropped_text.strip(s)

if len(text) > count:
return cropped_text + u'…'
if text:
cropped_text = ' '.join((text[0:count].strip()).split(' ')[:-1])
strips = ['.', ',', ':', ';']
for s in strips:
cropped_text = cropped_text.strip(s)
if len(text) > count:
return cropped_text + u'…'
else:
return text
else:
return text
return ''

def images(self):
"""
Check if folder contains images and return images
"""
brains = api.content.find(portal_type='Image')
brains = api.content.find(context=self.context, portal_type='Image', depth=1)

items = []
for item in brains:
Expand Down
2 changes: 1 addition & 1 deletion src/operun/gallery/browser/templates/gallery.pt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
tal:attributes="class python: toc and 'pat-autotoc' or ''" />

<div class="row" id="image-gallery" tal:define="images view/images" tal:condition="images">
<div class="col-xs-4 col-sm-3 gallery-image-wrapper" tal:repeat="image images">
<div class="col-xs-6 col-sm-4 col-md-4 col-lg-3 gallery-image-wrapper" tal:repeat="image images">
<div class="gallery-image">
<a href="" data-lightbox="" data-title="" tal:attributes="href image/url;
data-lightbox context/id;
Expand Down

0 comments on commit 0d8b44c

Please sign in to comment.