tools (common/template): new icon_from_client method:
this method is available from template, and returns the name of the icon to use according to disco client data.
This commit is contained in:
parent
234bbcbdd5
commit
205bd5cdb4
1 changed files with 16 additions and 0 deletions
|
|
@ -911,6 +911,21 @@ class Renderer(object):
|
|||
' <use href="#{name}"/>'
|
||||
'</svg>\n'.format(name=name, cls=(" " + cls) if cls else ""))
|
||||
|
||||
def _icon_from_client(self, client):
|
||||
"""Get icon name to represent a disco client"""
|
||||
if client is None:
|
||||
return 'desktop'
|
||||
elif 'pc' in client:
|
||||
return 'desktop'
|
||||
elif 'phone' in client:
|
||||
return 'mobile'
|
||||
elif 'web' in client:
|
||||
return 'globe'
|
||||
elif 'console' in client:
|
||||
return 'terminal'
|
||||
else:
|
||||
return 'desktop'
|
||||
|
||||
def render(self, template, site=None, theme=None, locale=C.DEFAULT_LOCALE,
|
||||
media_path="", css_files=None, css_inline=False, **kwargs):
|
||||
"""Render a template
|
||||
|
|
@ -963,6 +978,7 @@ class Renderer(object):
|
|||
|
||||
kwargs["icon_defs"] = self._icon_defs
|
||||
kwargs["icon"] = self._icon_use
|
||||
kwargs["icon_from_client"] = self._icon_from_client
|
||||
|
||||
if css_inline:
|
||||
css_contents = []
|
||||
|
|
|
|||
Loading…
Reference in a new issue