From d44132be0c77042b38d04992776b60c36aacf7fd Mon Sep 17 00:00:00 2001 From: John Martin Date: Wed, 24 Jul 2013 17:20:17 +0100 Subject: [PATCH] [#1126] First working version of row/column based homepage off of simple JSON config --- ckan/templates/home/index.html | 95 +------------------ ckanext/content_module/__init__.py | 0 ckanext/content_module/plugin.py | 18 ++++ .../theme/templates/admin/base.html | 6 ++ .../templates/content_module/carousel.html | 3 + .../theme/templates/content_module/intro.html | 3 + .../templates/content_module/search.html | 20 ++++ .../theme/templates/home/index.html | 42 ++++++++ setup.py | 1 + 9 files changed, 97 insertions(+), 91 deletions(-) create mode 100644 ckanext/content_module/__init__.py create mode 100644 ckanext/content_module/plugin.py create mode 100644 ckanext/content_module/theme/templates/admin/base.html create mode 100644 ckanext/content_module/theme/templates/content_module/carousel.html create mode 100644 ckanext/content_module/theme/templates/content_module/intro.html create mode 100644 ckanext/content_module/theme/templates/content_module/search.html create mode 100644 ckanext/content_module/theme/templates/home/index.html diff --git a/ckan/templates/home/index.html b/ckan/templates/home/index.html index 2508f8b8508..d2434b37c9f 100644 --- a/ckan/templates/home/index.html +++ b/ckan/templates/home/index.html @@ -3,98 +3,11 @@ {% block subtitle %}{{ _("Welcome") }}{% endblock %} {% block maintag %}{% endblock %} +{% block toolbar %}{% endblock %} {% block content %} -
-
- {{ self.flash() }} - {{ self.primary_content() }} -
-
-
-
- {{ self.secondary_content() }} -
-
-{% endblock %} - -{% block primary_content %} -
-
- {% block home_primary %} -
- {% if g.site_intro_text %} - {{ h.render_markdown(g.site_intro_text) }} - {% else %} - {% block home_primary_content %} -

{% block home_primary_heading %}{{ _("Welcome to CKAN") }}{% endblock %}

-

- {% block home_primary_text %} - {% trans %}This is a nice introductory paragraph about CKAN or the site - in general. We don't have any copy to go here yet but soon we will - {% endtrans %} - {% endblock %} -

- {% endblock %} - {% endif %} -
- {% endblock %} - - {% block home_image %} - - {% endblock %} -
-
-
-
- {% block home_secondary_content %} -
- {% block home_search %} -
-

{{ _("Search Your Data") }}

-
- - -
-
- {% endblock %} - {% block home_tags %} -
-

{{ _('Popular Tags') }}

- {% set tags = h.get_facet_items_dict('tags', limit=3) %} - {% for tag in tags %} - {{ h.truncate(tag.display_name, 22) }} - {% endfor %} -
- {% endblock %} -
- {% endblock %} -
+
+ {{ self.flash() }} + {% block primary_content %}{% endblock %}
{% endblock %} - -{% block secondary_content %} -
- {% for group in c.group_package_stuff %} -
-
- {% snippet 'snippets/group_item.html', group=group.group_dict, truncate=50, truncate_title=35 %} -
-
- {% endfor %} -
-{% endblock %} - -{# Remove the toolbar. #} - -{% block toolbar %}{% endblock %} diff --git a/ckanext/content_module/__init__.py b/ckanext/content_module/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/ckanext/content_module/plugin.py b/ckanext/content_module/plugin.py new file mode 100644 index 00000000000..798c5b20b86 --- /dev/null +++ b/ckanext/content_module/plugin.py @@ -0,0 +1,18 @@ +import logging + +import ckan.plugins as p + +log = logging.getLogger(__name__) + +class ContentModulePlugin(p.SingletonPlugin): + p.implements(p.IConfigurer, inherit=True) + p.implements(p.IConfigurable, inherit=True) + + def update_config(self, config): + p.toolkit.add_template_directory(config, 'theme/templates') + + # def get_helpers(self): + # return { + # 'featured_organizations': self.featured_orgs, + # 'featured_groups': self.featured_groups, + # } diff --git a/ckanext/content_module/theme/templates/admin/base.html b/ckanext/content_module/theme/templates/admin/base.html new file mode 100644 index 00000000000..68d93c8051b --- /dev/null +++ b/ckanext/content_module/theme/templates/admin/base.html @@ -0,0 +1,6 @@ +{% ckan_extends %} + +{% block content_primary_nav %} + {{ super() }} + {{ h.build_nav_icon('ckanadmin_homepage', _('Homepage')) }} +{% endblock %} diff --git a/ckanext/content_module/theme/templates/content_module/carousel.html b/ckanext/content_module/theme/templates/content_module/carousel.html new file mode 100644 index 00000000000..a5029992967 --- /dev/null +++ b/ckanext/content_module/theme/templates/content_module/carousel.html @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/ckanext/content_module/theme/templates/content_module/intro.html b/ckanext/content_module/theme/templates/content_module/intro.html new file mode 100644 index 00000000000..2d1cda5bbd5 --- /dev/null +++ b/ckanext/content_module/theme/templates/content_module/intro.html @@ -0,0 +1,3 @@ +
+ {{ module.config.message }} +
diff --git a/ckanext/content_module/theme/templates/content_module/search.html b/ckanext/content_module/theme/templates/content_module/search.html new file mode 100644 index 00000000000..915fa3c0ea7 --- /dev/null +++ b/ckanext/content_module/theme/templates/content_module/search.html @@ -0,0 +1,20 @@ +
+
+

{{ module.config.title }}

+ {{ config }} +
+ + +
+
+
+

{{ _('Popular Tags') }}

+ {% set tags = h.get_facet_items_dict('tags', limit=module.config.limit) %} + {% for tag in tags %} + {{ h.truncate(tag.display_name, 22) }} + {% endfor %} +
+
diff --git a/ckanext/content_module/theme/templates/home/index.html b/ckanext/content_module/theme/templates/home/index.html new file mode 100644 index 00000000000..ee63052d52e --- /dev/null +++ b/ckanext/content_module/theme/templates/home/index.html @@ -0,0 +1,42 @@ +{% ckan_extends %} + +{# imagine this is set via the controller really... #} +{% set content_bands = [ + { + "type": "hero", + "columns": [ + [ + { "type": "intro", "config": { "message": g.site_intro_text or "Test" } }, + { "type": "carousel", "config": false }, + ], + [ + { "type": "search", "config": { + "limit": 3, + "title": _("Search Your Data"), + "placeholder": _("eg. Gold Prices") + } }, + ] + ] + }, +] %} + +{% block primary_content %} + + {% for band in content_bands %} +
+
+
+ {% for column in band.columns %} + {% set column_size = ( 12 / loop.length )|int %} +
+ {% for module in column %} + {% snippet 'content_module/'~module.type~'.html', module=module %} + {% endfor %} +
+ {% endfor %} +
+
+
+ {% endfor %} + +{% endblock %} diff --git a/setup.py b/setup.py index 23aa5558711..01ff8f233f9 100644 --- a/setup.py +++ b/setup.py @@ -173,6 +173,7 @@ [ckan.system_plugins] domain_object_mods = ckan.model.modification:DomainObjectModificationExtension + content_module = ckanext.content_module.plugin:ContentModulePlugin [babel.extractors] ckan = ckan.lib.extract:extract_ckan