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

make thumb size in folder contents listing adjustable/supressable #106

Merged
merged 4 commits into from
Jun 1, 2017
Merged
Show file tree
Hide file tree
Changes from 3 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
7 changes: 7 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ Breaking changes:

New features:

- make thumbsize in folder contents listing adjustable/supressable
(uses site control panel settings: thumb_size_tables ...)
clean up deprecated icon related code
replace paperclip icon with mime type icons
https://github.com/plone/Products.CMFPlone/issues/1734
[fgrcon]

- Folder Contents: Construct the list of sortable indexes from the available catalog indexes, using a blacklist and a default set - likewise as it's done with metadata columns.
[thet]

Expand Down
16 changes: 15 additions & 1 deletion plone/app/content/browser/contents/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
from plone.app.content.utils import json_dumps
from plone.app.content.utils import json_loads
from plone.protect.postonly import check as checkpost
from plone.registry.interfaces import IRegistry
from plone.uuid.interfaces import IUUID
from Products.CMFCore.utils import getToolByName
from Products.CMFPlone.interfaces.controlpanel import ISiteSchema
from Products.CMFPlone import PloneMessageFactory as _
from Products.CMFPlone import utils
from Products.CMFPlone.utils import get_top_site_from_url
Expand Down Expand Up @@ -170,6 +172,7 @@ def ignored_columns(self):
'effective',
'expires',
'getIcon',
'getMimeIcon',
'getId',
'getRemoteUrl',
'in_response_to',
Expand Down Expand Up @@ -216,6 +219,16 @@ def get_columns(self):
columns[column] = translate(_(column), context=self.request)
return columns

def get_thumbSize(self):
registry = getUtility(IRegistry)
settings = registry.forInterface(
ISiteSchema, prefix="plone", check=False)
if settings.no_thumbs_tables:
# thumbs to be supressed
return 'none'
thumb_size_table = settings.thumb_size_table
return thumb_size_table

@property
def ignored_indexes(self):
ignored = [
Expand Down Expand Up @@ -290,7 +303,7 @@ def get_options(self):
'contextInfoUrl': '%s{path}/@@fc-contextInfo' % base_url,
'setDefaultPageUrl': '%s{path}/@@fc-setDefaultPage' % base_url,
'availableColumns': columns,
'attributes': ['Title', 'path', 'getURL', 'getIcon', 'portal_type'] + columns.keys(), # noqa
'attributes': ['Title', 'path', 'getURL', 'getIcon', 'getMimeIcon', 'portal_type'] + columns.keys(), # noqa
'buttons': self.get_actions(),
'rearrange': {
'properties': self.get_indexes(),
Expand All @@ -303,6 +316,7 @@ def get_options(self):
'initialFolder': IUUID(self.context, None),
'useTus': TUS_ENABLED
},
'thumbSize' : self.get_thumbSize(),
}
return options

Expand Down
4 changes: 0 additions & 4 deletions plone/app/content/browser/templates/select_default_page.pt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
<body>

<metal:main fill-slot="main">

<h1 class="documentFirstHeading"
i18n:translate="heading_select_default_page">Select default page</h1>

Expand All @@ -36,14 +35,11 @@
<dl>
<tal:item repeat="item items">
<dt tal:define="normalized_type python:plone_view.normalizeString(item.portal_type);
item_icon python:plone_layout.getIcon(item);
item_id python:'(%s)' % item.getId if (portal_visible_ids and member_visible_ids) else ''">
<input type="radio" name="objectId" value=""
tal:attributes="value item/getId;
id item/getId;
checked python: (n_items==1 or item.getId==cur_page) and 'checked' or None;"/>
<img tal:condition="nocall:item_icon"
tal:replace="structure item_icon/html_tag" />
<label tal:attributes="for item/getId;
class string:contenttype-${normalized_type}"
tal:content="string:${item/pretty_title_or_id} $item_id">
Expand Down
22 changes: 20 additions & 2 deletions plone/app/content/browser/vocabulary.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# -*- coding: utf-8 -*-
import os
from AccessControl import getSecurityManager
from Acquisition import aq_base
from logging import getLogger
from plone.app.content.utils import json_dumps
from plone.app.content.utils import json_loads
Expand All @@ -9,9 +11,11 @@
from plone.app.widgets.interfaces import IFieldPermissionChecker
from plone.autoform.interfaces import WRITE_PERMISSIONS_KEY
from plone.supermodel.utils import mergedTaggedValueDict
from Products.CMFCore.utils import getToolByName
from Products.CMFPlone import PloneMessageFactory as _
from Products.CMFPlone.utils import safe_unicode
from Products.Five import BrowserView
from Products.MimetypesRegistry.MimeTypeItem import guess_icon_path
from types import FunctionType
from zope.component import getUtility
from zope.component import queryAdapter
Expand Down Expand Up @@ -54,6 +58,7 @@
'ExpirationDate',
'expires',
'getIcon',
'getMimeIcon',
'getId',
'getObjSize',
'getRemoteUrl',
Expand Down Expand Up @@ -144,7 +149,7 @@ def __call__(self):

try:
vocabulary = self.get_vocabulary()
except VocabLookupException, e:
except VocabLookupException as e:
return json_dumps({'error': e.message})

results_are_brains = False
Expand Down Expand Up @@ -235,6 +240,19 @@ def __call__(self):
)
else:
item[key] = val
if key == 'getMimeIcon':
item[key] = None
# get mime type icon url from mimetype registry'
navroot = self.get_base_path(vocab_item)
contenttype = aq_base(
getattr(vocab_item, 'mime_type', None))
if contenttype:
mtt = getToolByName(
self.context, 'mimetypes_registry')
ctype = mtt.lookup(contenttype)
item[key] = os.path.join(
navroot,
guess_icon_path(ctype[0]))
items.append(item)
else:
for item in results:
Expand Down Expand Up @@ -321,7 +339,7 @@ def get_vocabulary(self):
# generation of vocabularies created for plone.app.widgets,
# which take the (unparsed) query as a parameter of the vocab
# factory rather than as a separate search method.
if type(factory) is FunctionType:
if isinstance(factory, FunctionType):
factory_spec = inspect.getargspec(factory)
else:
factory_spec = inspect.getargspec(factory.__call__)
Expand Down