Skip to content

Commit 0b09a80

Browse files
committed
Moved css pattern outside css generation view (css.IconifiedCategory) so it is reusable by an external package.
See DLIBBDC-4124
1 parent 5ded2d2 commit 0b09a80

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

CHANGES.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ Changelog
1212
[chris-adam]
1313
- Added page reload possibility
1414
[sgeulette]
15+
- Moved css pattern outside css generation view (`css.IconifiedCategory`)
16+
so it is reusable by an external package.
17+
[gbastien]
1518

1619
0.69 (2025-06-23)
1720
-----------------

src/collective/iconifiedcategory/browser/css.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@
1010
from collective.iconifiedcategory import utils
1111
from Products.Five import BrowserView
1212

13+
css_pattern = (u".{0} {{ padding-left: 1.4em; background: "
14+
u"transparent url('{1}') no-repeat top left; "
15+
u"background-size: contain; }}")
1316

1417
class IconifiedCategory(BrowserView):
1518

1619
def __call__(self, *args, **kwargs):
1720
self.request.response.setHeader('Content-Type', 'text/css')
1821
content = []
19-
css = (u".{0} {{ padding-left: 1.4em; background: "
20-
u"transparent url('{1}') no-repeat top left; "
21-
u"background-size: contain; }}")
2222
if utils.has_config_root(self.context) is False:
2323
return ''
2424
# sort_on=None to avoid useless sort_on="getObjPositionInParent"
@@ -29,5 +29,6 @@ def __call__(self, *args, **kwargs):
2929
obj = category._unrestrictedGetObject()
3030
category_id = utils.calculate_category_id(obj)
3131
url = u'{0}/@@download'.format(obj.absolute_url())
32-
content.append(css.format(utils.format_id_css(category_id), url))
32+
content.append(css_pattern.format(
33+
utils.format_id_css(category_id), url))
3334
return ' '.join(content)

0 commit comments

Comments
 (0)