Skip to content

Commit

Permalink
rss tile: expose published date (#115)
Browse files Browse the repository at this point in the history
* rss tile: expose published date

And I think I deserve a special award for one of the shortest commits:
* evil whitespace
  • Loading branch information
ksuess committed Mar 17, 2021
1 parent 8345b9a commit 00ca8ef
Show file tree
Hide file tree
Showing 42 changed files with 1,218 additions and 1,300 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Changelog
[djay]
- CI with Github actions: Python 2 / Python 3 and os version
[ksuess]
- rss tile: expose published date
[ksuess]

2.3.2 (2019-12-05)
------------------
Expand Down
2 changes: 1 addition & 1 deletion plone/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# -*- coding: utf-8 -*-
__import__('pkg_resources').declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__)
2 changes: 1 addition & 1 deletion plone/app/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# -*- coding: utf-8 -*-
__import__('pkg_resources').declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__)
2 changes: 1 addition & 1 deletion plone/app/standardtiles/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
from zope.i18nmessageid import MessageFactory


PloneMessageFactory = MessageFactory('plone')
PloneMessageFactory = MessageFactory("plone")

_PMF = PloneMessageFactory
28 changes: 12 additions & 16 deletions plone/app/standardtiles/attachment.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,8 @@ class IAttachmentTile(Schema):

widget(files=MultiFileFieldWidget)
files = schema.List(
title=_(u'Upload files'),
value_type=NamedBlobFile(
title=_(u"Please upload a file"),
required=True
)
title=_(u"Upload files"),
value_type=NamedBlobFile(title=_(u"Please upload a file"), required=True),
)


Expand Down Expand Up @@ -55,17 +52,15 @@ def update(self):
pass

def file_size(self, file_):
"""Returns the file-size of the `file_` in KB.
"""
"""Returns the file-size of the `file_` in KB."""
if INamed.providedBy(file_):
return file_.getSize() / 1024
else:
return 0

def get_icon_for(self, file_):
"""Returns the best icon for the `file_`
"""
mtr = getToolByName(self.context, 'mimetypes_registry', None)
"""Returns the best icon for the `file_`"""
mtr = getToolByName(self.context, "mimetypes_registry", None)
if mtr is None:
return self.context.getIcon()
lookup = mtr.lookup(file_.contentType)
Expand All @@ -79,7 +74,7 @@ def get_icon_for(self, file_):
return self.context.getIcon()

def lookupMime(self, name):
mtr = getToolByName(self.context, 'mimetypes_registry', None)
mtr = getToolByName(self.context, "mimetypes_registry", None)
if mtr is None:
return name
try:
Expand All @@ -92,8 +87,10 @@ def lookupMime(self, name):
return name


deprecated(AttachmentTile, 'AttachmentTile is now deprecated and will be '
'completely removed in 3.0.0')
deprecated(
AttachmentTile,
"AttachmentTile is now deprecated and will be " "completely removed in 3.0.0",
)


@implementer(IPublishTraverse)
Expand All @@ -113,12 +110,11 @@ def publishTraverse(self, request, name):

def __call__(self):
"""Render the file to the browser."""
files = self.context.data.get('files', ())
files = self.context.data.get("files", ())

try:
file_ = files[int(self.index)]
except KeyError:
raise NotFound(self, self.index, self.request)
set_headers(file_, self.request.response,
filename=file_.filename)
set_headers(file_, self.request.response, filename=file_.filename)
return stream_data(file_)
Loading

0 comments on commit 00ca8ef

Please sign in to comment.