Skip to content

Commit

Permalink
make thumb size in folder contents listing adjustable/supressable
Browse files Browse the repository at this point in the history
  (uses site control panel settings: thumb_size_tables ...)
  clean up deprecated icon related code
  replace paperclip icon with mime type icons
  plone/Products.CMFPlone#1734
  • Loading branch information
fgrcon committed Mar 28, 2017
1 parent 9c220b2 commit b590c0a
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 5 deletions.
5 changes: 5 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ Breaking changes:
- *add item here*

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]

- Allow for easier overriding of some BaseVocabularyView settings
[Gagaro]
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 @@ -168,6 +170,7 @@ def ignored_columns(self):
'effective',
'expires',
'getIcon',
'getMimeIcon',
'getId',
'getRemoteUrl',
'in_response_to',
Expand Down Expand Up @@ -214,6 +217,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

def get_options(self):
site = get_top_site_from_url(self.context, self.request)
base_url = site.absolute_url()
Expand All @@ -233,7 +246,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': {
Expand All @@ -253,6 +266,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
18 changes: 18 additions & 0 deletions plone/app/content/browser/vocabulary.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# -*- coding: utf-8 -*-
import os
from AccessControl import getSecurityManager
from logging import getLogger
from plone import api
from plone.app.content.utils import json_dumps
from plone.app.content.utils import json_loads
from plone.app.layout.navigation.interfaces import INavigationRoot
Expand All @@ -12,6 +14,7 @@
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 +57,7 @@
'ExpirationDate',
'expires',
'getIcon',
'getMimeIcon',
'getId',
'getObjSize',
'getRemoteUrl',
Expand Down Expand Up @@ -233,8 +237,22 @@ def __call__(self):
_(safe_unicode(val)),
context=self.request
)

else:
item[key] = val
if key == 'getMimeIcon':
item[key] = None
if vocab_item.portal_type =='File':
#get mime type icon url from mimetype registry'
portal_url = api.portal.get().absolute_url()
mtt = api.portal.get_tool(
name='mimetypes_registry')
if vocab_item.getObject().file.contentType:
ctype = mtt.lookup(
vocab_item.getObject().file.contentType)
item[key] = os.path.join(
portal_url,
guess_icon_path(ctype[0]))
items.append(item)
else:
for item in results:
Expand Down

0 comments on commit b590c0a

Please sign in to comment.