From d5664138641c2e8f9e88f357bf78a8efcd4dc7b9 Mon Sep 17 00:00:00 2001 From: Florian Brucker Date: Mon, 2 Oct 2017 17:17:50 +0200 Subject: [PATCH] [#68] Add FontAwesome 4 icon names Some FA 4 icon names had already been added in #51, but others were missed. --- ckanext/pages/plugin.py | 32 ++++++++++++++----- .../templates_main/ckanext_pages/blog.html | 2 +- .../ckanext_pages/blog_list.html | 2 +- .../ckanext_pages/group_page.html | 2 +- .../ckanext_pages/group_page_list.html | 2 +- .../ckanext_pages/organization_page.html | 2 +- .../ckanext_pages/organization_page_list.html | 2 +- .../templates_main/ckanext_pages/page.html | 2 +- .../ckanext_pages/pages_list.html | 2 +- 9 files changed, 32 insertions(+), 16 deletions(-) diff --git a/ckanext/pages/plugin.py b/ckanext/pages/plugin.py index bf61e681..4aa8cdb0 100644 --- a/ckanext/pages/plugin.py +++ b/ckanext/pages/plugin.py @@ -90,10 +90,26 @@ def get_recent_blog_posts(number=5, exclude=None): return new_list -def get_plus_icon(): +# Maps selected FontAwesome 4 icon names to FontAwesome 3 +_FA4_TO_FA3 = { + 'plus-square': 'plus-sign-alt', + 'pencil-square-o': 'edit', +} + + +def get_icon(name): + ''' + Get a FontAwesome icon name. + + Given the FontAwesome 4 icon name returns the appropriate icon name + for the current CKAN version. + + Raises a ``KeyError`` on CKAN versions prior to 2.7 if the + FontAwesome 3 name for the given icon is not known. + ''' if toolkit.check_ckan_version(min_version='2.7'): - return 'plus-square' - return 'plus-sign-alt' + return name + return _FA4_TO_FA3[name] class PagesPlugin(PagesPluginBase): @@ -131,7 +147,7 @@ def get_helpers(self): 'render_content': render_content, 'get_wysiwyg_editor': get_wysiwyg_editor, 'get_recent_blog_posts': get_recent_blog_posts, - 'pages_get_plus_icon': get_plus_icon + 'pages_get_icon': get_icon } def after_map(self, map): @@ -141,7 +157,7 @@ def after_map(self, map): map.connect('organization_pages_delete', '/organization/pages_delete/{id}{page:/.*|}', action='org_delete', ckan_icon='delete', controller=controller) map.connect('organization_pages_edit', '/organization/pages_edit/{id}{page:/.*|}', - action='org_edit', ckan_icon='edit', controller=controller) + action='org_edit', ckan_icon=get_icon('pencil-square-o'), controller=controller) map.connect('organization_pages_index', '/organization/pages/{id}', action='org_show', ckan_icon='file', controller=controller, highlight_actions='org_edit org_show', page='') map.connect('organization_pages', '/organization/pages/{id}{page:/.*|}', @@ -151,7 +167,7 @@ def after_map(self, map): map.connect('group_pages_delete', '/group/pages_delete/{id}{page:/.*|}', action='group_delete', ckan_icon='delete', controller=controller) map.connect('group_pages_edit', '/group/pages_edit/{id}{page:/.*|}', - action='group_edit', ckan_icon='edit', controller=controller) + action='group_edit', ckan_icon=get_icon('pencil-square-o'), controller=controller) map.connect('group_pages_index', '/group/pages/{id}', action='group_show', ckan_icon='file', controller=controller, highlight_actions='group_edit group_show', page='') map.connect('group_pages', '/group/pages/{id}{page:/.*|}', @@ -161,7 +177,7 @@ def after_map(self, map): map.connect('pages_delete', '/pages_delete{page:/.*|}', action='pages_delete', ckan_icon='delete', controller=controller) map.connect('pages_edit', '/pages_edit{page:/.*|}', - action='pages_edit', ckan_icon='edit', controller=controller) + action='pages_edit', ckan_icon=get_icon('pencil-square-o'), controller=controller) map.connect('pages_index', '/pages', action='pages_index', ckan_icon='file', controller=controller, highlight_actions='pages_edit pages_index pages_show') map.connect('pages_show', '/pages{page:/.*|}', @@ -172,7 +188,7 @@ def after_map(self, map): map.connect('blog_delete', '/blog_delete{page:/.*|}', action='blog_delete', ckan_icon='delete', controller=controller) map.connect('blog_edit', '/blog_edit{page:/.*|}', - action='blog_edit', ckan_icon='edit', controller=controller) + action='blog_edit', ckan_icon=get_icon('pencil-square-o'), controller=controller) map.connect('blog_index', '/blog', action='blog_index', ckan_icon='file', controller=controller, highlight_actions='blog_edit blog_index blog_show') map.connect('blog_show', '/blog{page:/.*|}', diff --git a/ckanext/pages/theme/templates_main/ckanext_pages/blog.html b/ckanext/pages/theme/templates_main/ckanext_pages/blog.html index 3b4e5c43..7e8e12a1 100644 --- a/ckanext/pages/theme/templates_main/ckanext_pages/blog.html +++ b/ckanext/pages/theme/templates_main/ckanext_pages/blog.html @@ -5,7 +5,7 @@ {% block primary_content %}
{% if h.check_access('ckanext_pages_update') %} - {% link_for _('Edit'), controller='ckanext.pages.controller:PagesController', action='blog_edit', page='/' + c.page.name, class_='btn btn-primary pull-right', icon='edit' %} + {% link_for _('Edit'), controller='ckanext.pages.controller:PagesController', action='blog_edit', page='/' + c.page.name, class_='btn btn-primary pull-right', icon=h.pages_get_icon('pencil-square-o') %} {% endif %}

{{ c.page.title }}

{% if c.page.publish_date %} diff --git a/ckanext/pages/theme/templates_main/ckanext_pages/blog_list.html b/ckanext/pages/theme/templates_main/ckanext_pages/blog_list.html index cf2aa63f..601456bf 100644 --- a/ckanext/pages/theme/templates_main/ckanext_pages/blog_list.html +++ b/ckanext/pages/theme/templates_main/ckanext_pages/blog_list.html @@ -2,7 +2,7 @@ {% block page_primary_action %} {% if h.check_access('ckanext_pages_update', {}) %} - {% link_for _('Add Article'), controller='ckanext.pages.controller:PagesController', action='blog_edit', page='', class_='btn btn-primary', icon=h.pages_get_plus_icon() %} + {% link_for _('Add Article'), controller='ckanext.pages.controller:PagesController', action='blog_edit', page='', class_='btn btn-primary', icon=h.pages_get_icon('plus-square') %} {% endif %} {% endblock %} diff --git a/ckanext/pages/theme/templates_main/ckanext_pages/group_page.html b/ckanext/pages/theme/templates_main/ckanext_pages/group_page.html index 330216c4..3cf1f380 100644 --- a/ckanext/pages/theme/templates_main/ckanext_pages/group_page.html +++ b/ckanext/pages/theme/templates_main/ckanext_pages/group_page.html @@ -3,7 +3,7 @@ {% block subtitle %}{{ _('Pages') }} - {{ c.group_dict.display_name }}{% endblock %} {% block primary_content_inner %} - {% link_for _('Edit page'), controller='ckanext.pages.controller:PagesController', action='group_edit', id=c.group_dict.name, page='/' + c.page.name, class_='btn btn-primary pull-right', icon='edit' %} + {% link_for _('Edit page'), controller='ckanext.pages.controller:PagesController', action='group_edit', id=c.group_dict.name, page='/' + c.page.name, class_='btn btn-primary pull-right', icon=h.pages_get_icon('pencil-square-o') %}

{{ c.page.title }}

{% if c.page.content %} {% set editor = h.get_wysiwyg_editor() %} diff --git a/ckanext/pages/theme/templates_main/ckanext_pages/group_page_list.html b/ckanext/pages/theme/templates_main/ckanext_pages/group_page_list.html index 5dda4a50..43bf743c 100644 --- a/ckanext/pages/theme/templates_main/ckanext_pages/group_page_list.html +++ b/ckanext/pages/theme/templates_main/ckanext_pages/group_page_list.html @@ -2,7 +2,7 @@ {% block page_primary_action %} {% if h.check_access('package_create', {'group_id': c.group_dict.id}) %} - {% link_for _('Add page'), controller='ckanext.pages.controller:PagesController', action='group_edit', id=c.group_dict.name, page='', class_='btn btn-primary', icon=h.pages_get_plus_icon() %} + {% link_for _('Add page'), controller='ckanext.pages.controller:PagesController', action='group_edit', id=c.group_dict.name, page='', class_='btn btn-primary', icon=h.pages_get_icon('plus-square') %} {% endif %} {% endblock %} diff --git a/ckanext/pages/theme/templates_main/ckanext_pages/organization_page.html b/ckanext/pages/theme/templates_main/ckanext_pages/organization_page.html index 02e61464..649d52e9 100644 --- a/ckanext/pages/theme/templates_main/ckanext_pages/organization_page.html +++ b/ckanext/pages/theme/templates_main/ckanext_pages/organization_page.html @@ -3,7 +3,7 @@ {% block subtitle %}{{ _('Pages') }} - {{ c.group_dict.display_name }}{% endblock %} {% block primary_content_inner %} - {% link_for _('Edit page'), controller='ckanext.pages.controller:PagesController', action='org_edit', id=c.group_dict.name, page='/' + c.page.name, class_='btn btn-primary pull-right', icon='edit' %} + {% link_for _('Edit page'), controller='ckanext.pages.controller:PagesController', action='org_edit', id=c.group_dict.name, page='/' + c.page.name, class_='btn btn-primary pull-right', icon=h.pages_get_icon('pencil-square-o') %}

{{ c.page.title }}

{% if c.page.content %} {% set editor = h.get_wysiwyg_editor() %} diff --git a/ckanext/pages/theme/templates_main/ckanext_pages/organization_page_list.html b/ckanext/pages/theme/templates_main/ckanext_pages/organization_page_list.html index 50dd4ebc..933dac97 100644 --- a/ckanext/pages/theme/templates_main/ckanext_pages/organization_page_list.html +++ b/ckanext/pages/theme/templates_main/ckanext_pages/organization_page_list.html @@ -2,7 +2,7 @@ {% block page_primary_action %} {% if h.check_access('package_create', {'group_id': c.group_dict.id}) %} - {% link_for _('Add page'), controller='ckanext.pages.controller:PagesController', action='org_edit', id=c.group_dict.name, page='', class_='btn btn-primary', icon=h.pages_get_plus_icon() %} + {% link_for _('Add page'), controller='ckanext.pages.controller:PagesController', action='org_edit', id=c.group_dict.name, page='', class_='btn btn-primary', icon=h.pages_get_icon('plus-square') %} {% endif %} {% endblock %} diff --git a/ckanext/pages/theme/templates_main/ckanext_pages/page.html b/ckanext/pages/theme/templates_main/ckanext_pages/page.html index c8cc40f4..08d5c1e6 100644 --- a/ckanext/pages/theme/templates_main/ckanext_pages/page.html +++ b/ckanext/pages/theme/templates_main/ckanext_pages/page.html @@ -5,7 +5,7 @@ {% block primary %}
{% if h.check_access('ckanext_pages_update') %} - {% link_for _('Edit'), controller='ckanext.pages.controller:PagesController', action='pages_edit', page='/' + c.page.name, class_='btn btn-primary pull-right', icon='edit' %} + {% link_for _('Edit'), controller='ckanext.pages.controller:PagesController', action='pages_edit', page='/' + c.page.name, class_='btn btn-primary pull-right', icon=h.pages_get_icon('pencil-square-o') %} {% endif %}

{{ c.page.title }}

{% if c.page.content %} diff --git a/ckanext/pages/theme/templates_main/ckanext_pages/pages_list.html b/ckanext/pages/theme/templates_main/ckanext_pages/pages_list.html index 35e8ddb4..9e593b74 100644 --- a/ckanext/pages/theme/templates_main/ckanext_pages/pages_list.html +++ b/ckanext/pages/theme/templates_main/ckanext_pages/pages_list.html @@ -2,7 +2,7 @@ {% block page_primary_action %} {% if h.check_access('ckanext_pages_update', {}) %} - {% link_for _('Add page'), controller='ckanext.pages.controller:PagesController', action='pages_edit', page='', class_='btn btn-primary', icon=h.pages_get_plus_icon() %} + {% link_for _('Add page'), controller='ckanext.pages.controller:PagesController', action='pages_edit', page='', class_='btn btn-primary', icon=h.pages_get_icon('plus-square') %} {% endif %} {% endblock %}