diff --git a/ckanext/example_theme/v14_initialize_a_javascript_module/__init__.py b/ckanext/example_theme/v14_initialize_a_javascript_module/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/ckanext/example_theme/v14_initialize_a_javascript_module/fanstatic/favorite.js b/ckanext/example_theme/v14_initialize_a_javascript_module/fanstatic/favorite.js new file mode 100644 index 00000000000..a3a142210e5 --- /dev/null +++ b/ckanext/example_theme/v14_initialize_a_javascript_module/fanstatic/favorite.js @@ -0,0 +1,8 @@ +ckan.module('favorite', function (jQuery, _) { + return { + initialize: function () { + console.log("I've been initialized for element: %o", this.el); + } + }; +}); + diff --git a/ckanext/example_theme/v14_initialize_a_javascript_module/plugin.py b/ckanext/example_theme/v14_initialize_a_javascript_module/plugin.py new file mode 100644 index 00000000000..803fb73181a --- /dev/null +++ b/ckanext/example_theme/v14_initialize_a_javascript_module/plugin.py @@ -0,0 +1,14 @@ +import ckan.plugins as plugins +import ckan.plugins.toolkit as toolkit + + +class ExampleThemePlugin(plugins.SingletonPlugin): + '''An example theme plugin. + + ''' + plugins.implements(plugins.IConfigurer) + + def update_config(self, config): + + toolkit.add_template_directory(config, 'templates') + toolkit.add_resource('fanstatic', 'example_theme') diff --git a/ckanext/example_theme/v14_initialize_a_javascript_module/templates/home/index.html b/ckanext/example_theme/v14_initialize_a_javascript_module/templates/home/index.html new file mode 100644 index 00000000000..4b534a2fe2b --- /dev/null +++ b/ckanext/example_theme/v14_initialize_a_javascript_module/templates/home/index.html @@ -0,0 +1,15 @@ +{% ckan_extends %} + + +{% block content %} + + {{ super() }} + + {# Use Fanstatic to include our custom JavaScript module. #} + {% resource 'example_theme/favorite.js' %} + +
+ +
+ +{% endblock %} diff --git a/ckanext/example_theme/v14_initialize_a_javascript_module/templates/snippets/package_item.html b/ckanext/example_theme/v14_initialize_a_javascript_module/templates/snippets/package_item.html new file mode 100644 index 00000000000..078659c9165 --- /dev/null +++ b/ckanext/example_theme/v14_initialize_a_javascript_module/templates/snippets/package_item.html @@ -0,0 +1,22 @@ +{% ckan_extends %} + +{% block package_item_content %} + {{ super() }} + + {# Use Fanstatic to include our custom JavaScript module. + A