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 Oct 14, 2016
1 parent ac1275f commit 0d6f73f
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 5 deletions.
5 changes: 5 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,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]

- *add item here*

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.Five import BrowserView
Expand Down Expand Up @@ -201,6 +203,7 @@ def ignored_columns(self):
'effective',
'expires',
'getIcon',
'getMimeIcon',
'getId',
'getRemoteUrl',
'in_response_to',
Expand Down Expand Up @@ -247,6 +250,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 @@ -266,7 +279,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 @@ -286,6 +299,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
17 changes: 17 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 @@ -171,6 +174,7 @@ def __call__(self):
'ExpirationDate',
'expires',
'getIcon',
'getMimeIcon',
'getId',
'getObjSize',
'getRemoteUrl',
Expand Down Expand Up @@ -226,6 +230,19 @@ def __call__(self):
_(safe_unicode(val)),
context=self.request
)
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]))
else:
item[key] = val
items.append(item)
Expand Down

0 comments on commit 0d6f73f

Please sign in to comment.