Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new behavior: IThumbIconHandling, supress thumbs /icons, adjust thumb… #368

Merged
merged 4 commits into from
Jun 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,16 @@ Breaking changes:

- *add item here*


New features:

- New metadata catalog column MimeType
https://github.com/plone/Products.CMFPlone/issues/1995
[fgrcon]

- new behavior: IThumbIconHandling, supress thumbs /icons, adjust thumb size, templates adapted
https://github.com/plone/Products.CMFPlone/issues/1734 (PLIP)

Bug fixes:

- Fix test for checking if TinyMCE is loaded which broke after https://github.com/plone/Products.CMFPlone/pull/2059
Expand Down
7 changes: 7 additions & 0 deletions plone/app/contenttypes/behaviors/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@
marker=".richtext.IRichText"
/>

<plone:behavior
name="plone.thumb_icon"
title="Thumbs and icon handling"
description="Options to suppress thumbs and/or icons and to override thumb size in listings, tables etc."
provides=".thumb_icon.IThumbIconHandling"
/>

<browser:page
name="getText"
for=".richtext.IRichText"
Expand Down
87 changes: 87 additions & 0 deletions plone/app/contenttypes/behaviors/thumb_icon.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# -*- coding: utf-8 -*-
from plone.app.contenttypes import _
from plone.autoform import directives
from plone.autoform.interfaces import IFormFieldProvider
from plone.supermodel import model
from z3c.form.interfaces import IAddForm
from z3c.form.interfaces import IEditForm
from zope import schema
from zope.interface import provider


@provider(IFormFieldProvider)
class IThumbIconHandling(model.Schema):

model.fieldset(
'settings',
label=_(u'Settings'),
fields=['ov_thumbsize_list',
'ov_thumbsize_table',
'ov_thumbsize_summary',
'suppress_icons',
'suppress_thumbs'
]
)

ov_thumbsize_list = schema.TextLine(
title=_(u'Override thumb size for list view'),
description=_(u'<br><ul><li> valid size '
u'(see `Image Handling` control panel)'
u' e.g. icon, tile, thumb, mini, preview, ... </li>'
u'<li>leave empty to use default'
u'(see `Site` control panel)</li></ul>'),
required=False,
default=u'')

ov_thumbsize_table = schema.TextLine(
title=_(u'Override thumb size for table view'),
description=_(u'<br><ul><li> valid size '
u'(see `Image Handling` control panel)'
u' e.g. icon, tile, thumb, mini, preview, ... , </li>'
u'<li>leave empty to use default '
u'(see `Site` control panel)</li></ul>'),
required=False,
default=u'')

ov_thumbsize_summary = schema.TextLine(
title=_(u'Override thumb size for summary view'),
description=_(u'<br><ul><li> valid size '
u'(see `Image Handling` control panel)'
u' e.g. icon, tile, thumb, mini, preview, ... , </li>'
u'<li>leave empty to use default '
u'(see `Site` control panel)</li></ul>'),
required=False,
default=u'')

suppress_icons = schema.Bool(
title=_(u'Suppress icons in list, table or summary view'),
description=_(u''),
required=False,
default=False,
)

suppress_thumbs = schema.Bool(
title=_(u'Suppress thumbs in list, table or summary view'),
description=_(u''),
required=False,
default=False,
)

directives.omitted('ov_thumbsize_list',
'ov_thumbsize_table',
'ov_thumbsize_summary',
'suppress_icons',
'suppress_thumbs'
)
directives.no_omit(IEditForm, 'ov_thumbsize_list',
'ov_thumbsize_table',
'ov_thumbsize_summary',
'suppress_icons',
'suppress_thumbs'
)
directives.no_omit(IAddForm, 'ov_thumbsize_list',
'ov_thumbsize_table',
'ov_thumbsize_summary',
'suppress_icons',
'suppress_thumbs'
)
46 changes: 46 additions & 0 deletions plone/app/contenttypes/browser/folder.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
from Acquisition import aq_base
from Acquisition import aq_inner
from Products.CMFPlone.interfaces import ISiteSchema
from plone.app.contenttypes import _
from plone.app.contenttypes.interfaces import IFolder
from plone.app.contenttypes.interfaces import IImage
Expand Down Expand Up @@ -221,3 +222,48 @@ def no_items_message(self):
'description_no_items_in_folder',
default=u'There are currently no items in this folder.'
)

@memoize
def get_thumbSize_table(self):
if getattr(self.context, 'suppress_thumbs', False):
return 'none'
thsize = getattr(self.context, 'ov_thumbsize_table', '')
if thsize > '':
return thsize
registry = getUtility(IRegistry)
settings = registry.forInterface(
ISiteSchema, prefix='plone', check=False)
if settings.no_thumbs_tables:
return 'none'
return settings.thumb_size_table

@memoize
def get_thumbSize_list(self):
if getattr(self.context, 'suppress_thumbs', False):
return 'none'
thsize = getattr(self.context, 'ov_thumbsize_list', '')
if thsize > '':
return thsize
registry = getUtility(IRegistry)
settings = registry.forInterface(
ISiteSchema, prefix='plone', check=False)
if settings.no_thumbs_lists:
return 'none'
return settings.thumb_size_listing

@memoize
def get_thumbSize_summary(self):
if getattr(self.context, 'suppress_thumbs', False):
return 'none'
thsize = getattr(self.context, 'ov_thumbsize_summary', '')
if thsize > '':
return thsize
registry = getUtility(IRegistry)
settings = registry.forInterface(
ISiteSchema, prefix='plone', check=False)
if settings.no_thumbs_summary:
return 'none'
return settings.thumb_size_summary

def show_icons(self):
return not getattr(self.context, 'suppress_icons', False)
35 changes: 23 additions & 12 deletions plone/app/contenttypes/browser/templates/listing.pt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@
</div>

<metal:listingmacro define-macro="listing">
<tal:results define="batch view/batch">
<tal:results define="batch view/batch;
thumb_size_list python:view.get_thumbSize_list();
thumb_size_table python:view.get_thumbSize_table();
thumb_size_summary python:view.get_thumbSize_summary();
img_class python:'image-%s pull-right' % thumb_size_list;
showicons view/show_icons ;">
<tal:listing condition="batch">
<div class="entries" metal:define-slot="entries"
tal:define="portal context/@@plone_portal_state/portal;
Expand All @@ -33,29 +38,35 @@
item_type item/PortalType;
item_modified item/ModificationDate;
item_created item/CreationDate;
item_type_class python:'contenttype-' + view.normalizeString(item_type);
item_wf_state item/review_state;
item_wf_state_class python:'state-' + view.normalizeString(item_wf_state);
item_creator item/Creator;
item_link python:item_type in view.use_view_action and item_url+'/view' or item_url;
item_is_event python:view.is_event(obj);
item_has_image python:item.getIcon">
item_has_image python:item.getIcon;
item_type_class python:('contenttype-' + view.normalizeString(item_type)) if showicons else '' ;
">
<metal:block define-slot="entry">
<article class="entry">
<header metal:define-macro="listitem" tal:attributes="class python:'vevent' if item_is_event else None">
<span class="summary" tal:attributes="title item_type">
<a tal:attributes="href item_link">
<img tal:condition="item_has_image"
tal:replace="structure python:image_scale.tag(item, 'image', scale='tile', css_class='image-tile')">
<a tal:condition="python:item_type == 'File' and showicons"
tal:attributes="href item_link;
class string:$item_type_class $item_wf_state_class url;
title item_type">
<img class="mime-icon"
tal:attributes="src item/MimeTypeIcon">
</a>
<a tal:attributes="href item_link;
class string:$item_type_class $item_wf_state_class url;
title item_type"
tal:content="item_title">

Item Title
class string:$item_type_class $item_wf_state_class url;
title item_type"
tal:content="item_title">Item Title
</a>
<a tal:attributes="href item_link;"
tal:condition="python: item_has_image and (thumb_size_list!='none')">
<img tal:replace="structure python:image_scale.tag(item, 'image', scale=thumb_size_list, css_class=img_class)" />
</a>
</span>
</span>
<metal:block metal:define-macro="document_byline">
<div class="documentByLine">
<tal:event condition="item_is_event">
Expand Down
8 changes: 5 additions & 3 deletions plone/app/contenttypes/browser/templates/listing_summary.pt
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@

<div metal:use-macro="context/@@listing_view/macros/document_byline"></div>

<div class="tileImage"
tal:condition="item_has_image"
<div tal:define="thumb_url python:item_url +'/@@images/image/'+thumb_size_summary;"
tal:condition="python: item_has_image and not thumb_size_summary=='none'"
tal:attributes="class python: 'tileImage' if item_description else 'tileImageNoFloat'">
<a tal:attributes="href item_link">
<img tal:replace="structure python:image_scale.tag(item, 'image', scale='thumb')" />
<img tal:condition="python: item_has_image and (thumb_size_summary!='none')"
tal:replace="structure python:image_scale.tag(item, 'image', scale=thumb_size_summary, css_class='image-'+thumb_size_summary)" />

</a>
</div>

Expand Down
36 changes: 25 additions & 11 deletions plone/app/contenttypes/browser/templates/listing_tabular.pt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@

<div metal:use-macro="context/batch_macros/macros/navigation" />
<div class="has-table">
<table class="listing"
<table
tal:define="thumb_size_table python:view.get_thumbSize_table();
img_class python:'image-%s pull-right' % thumb_size_table;
showicons view/show_icons;
"
class="listing"
summary="Content listing"
i18n:attributes="summary summary_content_listing;">
<thead>
Expand All @@ -42,11 +47,13 @@
item_title item/Title;
item_description item/Description;
item_type item/PortalType;
item_type_class python:'contenttype-' + view.normalizeString(item_type);
item_type_class python:'contenttype-' + view.normalizeString(item_type) if showicons else '';
item_wf_state item/review_state;
item_wf_state_class python:'state-' + view.normalizeString(item_wf_state);
item_creator item/Creator;
item_link python:item_type in view.use_view_action and item_url+'/view' or item_url">
item_has_image python:item.getIcon;
item_link python:item_type in view.use_view_action and item_url+'/view' or item_url;
">
<tr metal:define-macro="listitem"
tal:define="oddrow repeat/item/odd;"
tal:attributes="class python: oddrow and 'even' or 'odd'">
Expand All @@ -57,14 +64,21 @@
<tal:block tal:replace="field_data/value" />
</td>
<td tal:condition="python:field == 'Title'">
<img tal:condition="python: item.getIcon"
tal:replace="structure python:image_scale.tag(item, 'image', scale='icon', css_class='image-icon')">
<a href="#"
tal:attributes="href item_link;
class string:$item_wf_state_class $item_type_class;
title item_description;"
tal:content="item_title">
Item Title
<a tal:condition="python:item_type == 'File' and showicons"
tal:attributes="href item_link;
class string:$item_type_class $item_wf_state_class url;
title item_type">
<img class="mime-icon"
tal:attributes="src item/MimeTypeIcon">
</a>
<a tal:attributes="href item_link;
class string:$item_type_class $item_wf_state_class url;
title item_type"
tal:content="item_title">Item Title
</a>
<a tal:condition="python: item_has_image and (thumb_size_table!='none')">
<img tal:attributes="href item_link;"
tal:replace="structure python:image_scale.tag(item, 'image', scale=thumb_size_table, css_class=img_class)" />
</a>
</td>
<td tal:condition="python:field == 'Creator'"
Expand Down