Repository: ckan/ckan

Issue:
cookiecutter template "fanstatic" should be "assets"
**CKAN version**
2.9

**Describe the bug**
When creating a new extension using ``ckan generate extension``, a "fanstatic" directory is created.

**Expected behavior**
According to https://docs.ckan.org/en/2.9/theming/webassets.html, it should be "assets".

A fix would be to rename the "fanstatic" directory in https://github.com/ckan/ckan/tree/master/contrib/cookiecutter/ckan_extension/%7B%7Bcookiecutter.project%7D%7D/ckanext/%7B%7Bcookiecutter.project_shortname%7D%7D


Discussion:
Also, the "assets" directory should probably contain an empty "webassets.yml" (took me some time to figure out this file is needed in CKAN 2.9).
@paulmueller @Zharktas @amercader , I have analyze this issue.  When executing the command "ckan generate extension" , a new extension is created with "Fanstatic "directory is created in it. While the document https://docs.ckan.org/en/2.9/theming/webassets.html is for adding CSS and JavaScript to themes using Webassets in which "assets" directory is to be created by user as mentioned in step 1 and step 2 is for registering "assets" directory with CKAN. Please confirm my understanding.
@Gauravp-NEC I can confirm this.

Also, the Manifest.in file should have a *.yml in it, otherwise the assets will not be read by CKAN when the extension is installed with pip.
@paulmueller , I understood that Manifest.in file should have a *.yml in it. I am confused why "Fanstatic" should be "assets"? Fanstatic directory is created by CLI command "ckan generate extension" when creating a new extension while assets directory is to be created by user when adding CSS and JavaScript to themes using Webassets as mentioned in https://docs.ckan.org/en/2.9/theming/webassets.html .
As far as I understood it, webassets is the successor of fanstatic (compare to https://docs.ckan.org/en/2.8/theming/fanstatic.html).
Yes, fanstatic was replaced by webassets in ckan 2.9 as part of the effort of modernizing the codebase.
@paulmueller , I think fix to rename "fanstatic" directory is required in following locations as well:     
1) https://github.com/ckan/ckan/tree/master/ckanext/example_theme_docs/v16_initialize_a_javascript_module
2) https://github.com/ckan/ckan/tree/master/ckanext/example_theme_docs/v17_popover    
3) https://github.com/ckan/ckan/tree/master/ckanext/example_theme_docs/v18_snippet_api
4) https://github.com/ckan/ckan/tree/master/ckanext/example_theme_docs/v19_01_error
5) https://github.com/ckan/ckan/tree/master/ckanext/example_theme_docs/v19_02_error_handling
6) https://github.com/ckan/ckan/tree/master/ckanext/example_theme_docs/v20_pubsub
7) https://github.com/ckan/ckan/tree/master/ckanext/example_theme_docs/v21_custom_jquery_plugin
8) https://github.com/ckan/ckan/tree/master/ckanext/example_theme_docs/v22_fanstatic_and_webassets

Please let me know your opinion
@Zharktas I agree. These plugins have already been migrated to webassets in https://github.com/ckan/ckan/commit/645828f1385f282e8c6ff782fa1bcbec75c51447.

But renaming the "fanstatic" directories and updating the ``add_resource`` entries in the plugin.py files would put these examples in line with the current documentation.
@paulmueller , Directories can be rename by using the terminal. Below are the steps:

1) Clone your repository that you website is hosted on.

2) cd “repositoryname”

3) git mv “directoryname” “newdirectoryname”

4) git add .

5) git commit -m “message”

6) git push

Resolving patch:
diff --git a/ckanext/example_theme_docs/v16_initialize_a_javascript_module/plugin.py b/ckanext/example_theme_docs/v16_initialize_a_javascript_module/plugin.py
--- a/ckanext/example_theme_docs/v16_initialize_a_javascript_module/plugin.py
+++ b/ckanext/example_theme_docs/v16_initialize_a_javascript_module/plugin.py
@@ -13,4 +13,4 @@ class ExampleThemePlugin(plugins.SingletonPlugin):
     def update_config(self, config):
 
         toolkit.add_template_directory(config, 'templates')
-        toolkit.add_resource('fanstatic', 'example_theme')
+        toolkit.add_resource('assets', 'example_theme')
diff --git a/ckanext/example_theme_docs/v22_fanstatic_and_webassets/plugin.py b/ckanext/example_theme_docs/v22_fanstatic_and_webassets/plugin.py
--- a/ckanext/example_theme_docs/v22_fanstatic_and_webassets/plugin.py
+++ b/ckanext/example_theme_docs/v22_fanstatic_and_webassets/plugin.py
@@ -37,12 +37,12 @@ def update_config(self, config):
         # that CKAN will use this plugin's custom static files.
         toolkit.add_public_directory(config, u'public')
 
-        # Register this plugin's fanstatic directory with CKAN.
-        # Here, 'fanstatic' is the path to the fanstatic directory
+        # Register this plugin's assets directory with CKAN.
+        # Here, 'assets' is the path to the webassets directory
         # (relative to this plugin.py file), and 'example_theme' is the name
         # that we'll use to refer to this fanstatic directory from CKAN
         # templates.
-        toolkit.add_resource(u'fanstatic', u'example_theme')
+        toolkit.add_resource(u'assets', u'example_theme')
 
     def get_helpers(self):
         u'''Register the most_popular_groups() function above as a template
diff --git a/contrib/cookiecutter/ckan_extension/{{cookiecutter.project}}/ckanext/{{cookiecutter.project_shortname}}/plugin.py b/contrib/cookiecutter/ckan_extension/{{cookiecutter.project}}/ckanext/{{cookiecutter.project_shortname}}/plugin.py
--- a/contrib/cookiecutter/ckan_extension/{{cookiecutter.project}}/ckanext/{{cookiecutter.project_shortname}}/plugin.py
+++ b/contrib/cookiecutter/ckan_extension/{{cookiecutter.project}}/ckanext/{{cookiecutter.project_shortname}}/plugin.py
@@ -10,5 +10,5 @@ class {{ cookiecutter.plugin_class_name }}(plugins.SingletonPlugin):
     def update_config(self, config_):
         toolkit.add_template_directory(config_, 'templates')
         toolkit.add_public_directory(config_, 'public')
-        toolkit.add_resource('fanstatic',
+        toolkit.add_resource('assets',
             '{{ cookiecutter.project_shortname }}')


Test patch: