[silva.core.interfaces][Sylvain Viollon] Review icon story.
[email protected] Tue, 27 Aug 2013 18:22:12 +0200
| Newsgroups | gmane.comp.web.zope.silva.cvs |
|---|---|
| Message-ID | <[email protected]> |
author: Sylvain Viollon
date: Tue Aug 27 18:22:07 2013 +0200
revision: 244:0b4acff173e6 in silva.core.interfaces
branch: 2.4
details: https://hg.infrae.com/silva.core.interfaces?cmd=changeset;node=0b4acff173e6
modified: src/silva/core/interfaces/adapters.py src/silva/core/interfaces/registry.py
added:
removed:
log: Review icon story.
diffstat:
src/silva/core/interfaces/adapters.py | 18 ++++++++++++++++--
src/silva/core/interfaces/registry.py | 17 +++++++----------
2 files changed, 23 insertions(+), 12 deletions(-)
diffs (71 lines):
diff -r 87bcf4fd06f5 -r 0b4acff173e6 src/silva/core/interfaces/adapters.py
--- a/src/silva/core/interfaces/adapters.py Thu May 23 17:17:28 2013 +0200
+++ b/src/silva/core/interfaces/adapters.py Tue Aug 27 18:22:07 2013 +0200
@@ -458,9 +458,23 @@
"""
+class IIcon(Interface):
+ """An icon for a content type.
+ """
+ icon = Attribute('Icon')
+ template = Attribute('Template of a tag to render the icon')
+
+ def get_url(view, content):
+ """Return the URL of the icon for the given content.
+ """
+
+
class IIconResolver(Interface):
"""Adapt a Zope request to return a content icon.
"""
+ sprite = Attribute('Sprite being used to lookup icons')
+
+ root_url = Attribute('URL of the site')
def get_tag(content=None, identifier=None):
"""Return a tag that generate an icon associated to the
@@ -468,12 +482,12 @@
"""
def get_identifier(identifier):
- """Return the icon path associated to the given meta_type
+ """Return the icon associated to the given meta_type
identifier.
"""
def get_content(content):
- """Return the icon path associated to the given Zope content.
+ """Return the icon associated to the given Zope content.
"""
def get_identifier_url(identifier):
diff -r 87bcf4fd06f5 -r 0b4acff173e6 src/silva/core/interfaces/registry.py
--- a/src/silva/core/interfaces/registry.py Thu May 23 17:17:28 2013 +0200
+++ b/src/silva/core/interfaces/registry.py Tue Aug 27 18:22:07 2013 +0200
@@ -35,18 +35,15 @@
"""A registry which contains icons.
"""
- def get_icon(content):
- """Get the icon associated with the content.
+ def get(identifier, default):
+ """Get the icon associated with the identifier. If it is not
+ found and a default is provided, return the default, or raise
+ ``ValueError``.
"""
- def get_icon_by_identifier(identifier):
- """Get the icon associated with the identifier, which can by a
- meta_type or a mime type.
- """
-
- def register(identifier, icon_url):
- """Register the given icon url for the identifier (meta_type,
- or mime type).
+ def register(identifier, icon):
+ """Register the given icon sub-url to the identifier
+ (meta_type, or mime type).
"""