Repository: ckan/ckan

Issue:
Remove built-in color themes
It's unclear how valuable they are for users, and they have created issues on the past (eg #4202, #2099). The last one I found was when running the `less` command with upgraded versions:

```
Missing argument value: gulpfile
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! ckan@1.0.0 build: `gulp build "-fuchsia"`
npm ERR! Exit status 1
```

Yes, this can be fixed in our command code, but it's just an example of a feature that causes problems and doesn't have clear value.

I have a PR ready if people is happy.



Discussion:

Resolving patch:
diff --git a/ckan/cli/less.py b/ckan/cli/less.py
--- a/ckan/cli/less.py
+++ b/ckan/cli/less.py
@@ -10,45 +10,6 @@
 from ckan.cli import error_shout
 
 
-_custom_css = {
-    u'fuchsia': u'''
-        @layoutLinkColor: #E73892;
-        @footerTextColor: mix(#FFF, @layoutLinkColor, 60%);
-        @footerLinkColor: @footerTextColor;
-        @mastheadBackgroundColor: @layoutLinkColor;
-        @btnPrimaryBackground: lighten(@layoutLinkColor, 10%);
-        @btnPrimaryBackgroundHighlight: @layoutLinkColor;
-        ''',
-
-    u'green': u'''
-        @layoutLinkColor: #2F9B45;
-        @footerTextColor: mix(#FFF, @layoutLinkColor, 60%);
-        @footerLinkColor: @footerTextColor;
-        @mastheadBackgroundColor: @layoutLinkColor;
-        @btnPrimaryBackground: lighten(@layoutLinkColor, 10%);
-        @btnPrimaryBackgroundHighlight: @layoutLinkColor;
-        ''',
-
-    u'red': u'''
-        @layoutLinkColor: #C14531;
-        @footerTextColor: mix(#FFF, @layoutLinkColor, 60%);
-        @footerLinkColor: @footerTextColor;
-        @mastheadBackgroundColor: @layoutLinkColor;
-        @btnPrimaryBackground: lighten(@layoutLinkColor, 10%);
-        @btnPrimaryBackgroundHighlight: @layoutLinkColor;
-        ''',
-
-    u'maroon': u'''
-        @layoutLinkColor: #810606;
-        @footerTextColor: mix(#FFF, @layoutLinkColor, 60%);
-        @footerLinkColor: @footerTextColor;
-        @mastheadBackgroundColor: @layoutLinkColor;
-        @btnPrimaryBackground: lighten(@layoutLinkColor, 10%);
-        @btnPrimaryBackgroundHighlight: @layoutLinkColor;
-        ''',
-}
-
-
 @click.command(
     name=u'less',
     short_help=u'Compile all root less documents into their CSS counterparts')
@@ -59,16 +20,6 @@ def less():
 
     root = os.path.join(os.path.dirname(__file__), u'..', public, u'base')
     root = os.path.abspath(root)
-    custom_less = os.path.join(root, u'less', u'custom.less')
-    for color in _custom_css:
-        f = open(custom_less, u'w')
-        f.write(_custom_css[color])
-        f.close()
-        _compile_less(root, command, color)
-    f = open(custom_less, u'w')
-    f.write(u'// This file is needed in order for `gulp build` to '
-            u'compile in less 1.3.1+\n')
-    f.close()
     _compile_less(root, command, u'main')
 
 
diff --git a/ckan/lib/app_globals.py b/ckan/lib/app_globals.py
--- a/ckan/lib/app_globals.py
+++ b/ckan/lib/app_globals.py
@@ -17,6 +17,8 @@
 log = logging.getLogger(__name__)
 
 
+DEFAULT_MAIN_CSS_FILE = '/base/css/main.css'
+
 # mappings translate between config settings and globals because our naming
 # conventions are not well defined and/or implemented
 mappings = {
@@ -168,7 +170,8 @@ def get_config_value(key, default=''):
         get_config_value(key)
 
     # custom styling
-    main_css = get_config_value('ckan.main_css', '/base/css/main.css')
+    main_css = get_config_value(
+        'ckan.main_css', DEFAULT_MAIN_CSS_FILE) or DEFAULT_MAIN_CSS_FILE
     set_main_css(main_css)
 
     if app_globals.site_logo:
diff --git a/ckan/views/admin.py b/ckan/views/admin.py
--- a/ckan/views/admin.py
+++ b/ckan/views/admin.py
@@ -26,23 +26,6 @@ def _get_sysadmins():
 
 
 def _get_config_options():
-    styles = [{
-        u'text': u'Default',
-        u'value': u'/base/css/main.css'
-    }, {
-        u'text': u'Red',
-        u'value': u'/base/css/red.css'
-    }, {
-        u'text': u'Green',
-        u'value': u'/base/css/green.css'
-    }, {
-        u'text': u'Maroon',
-        u'value': u'/base/css/maroon.css'
-    }, {
-        u'text': u'Fuchsia',
-        u'value': u'/base/css/fuchsia.css'
-    }]
-
     homepages = [{
         u'value': u'1',
         u'text': (u'Introductory area, search, featured'
@@ -56,7 +39,7 @@ def _get_config_options():
         u'text': u'Search, introductory area and stats'
     }]
 
-    return dict(styles=styles, homepages=homepages)
+    return dict(homepages=homepages)
 
 
 def _get_config_items():


Test patch:
diff --git a/ckan/tests/controllers/test_admin.py b/ckan/tests/controllers/test_admin.py
--- a/ckan/tests/controllers/test_admin.py
+++ b/ckan/tests/controllers/test_admin.py
@@ -49,22 +49,8 @@ def test_site_title(self, app, sysadmin_env):
         reset_index_response = app.get("/")
         assert "Welcome - CKAN" in reset_index_response
 
-    def test_main_css_list(self, app, sysadmin_env):
-        """Style list contains pre-configured styles"""
-
-        STYLE_NAMES = ["Default", "Red", "Green", "Maroon", "Fuchsia"]
-
-        url = url_for(u"admin.config")
-        config_response = app.get(url, environ_overrides=sysadmin_env)
-        config_response_html = BeautifulSoup(config_response.body)
-        style_select_options = config_response_html.select(
-            "#field-ckan-main-css option"
-        )
-        for option in style_select_options:
-            assert option.string in STYLE_NAMES
-
     def test_main_css(self, app, sysadmin_env):
-        """Select a colour style"""
+        """Define a custom css file"""
 
         # current style
         index_response = app.get("/")
@@ -72,10 +58,10 @@ def test_main_css(self, app, sysadmin_env):
 
         url = url_for(u"admin.config")
         # set new style css
-        form = {"ckan.main_css": "/base/css/red.css", "save": ""}
+        form = {"ckan.main_css": "/base/css/main-rtl.css", "save": ""}
         resp = app.post(url, data=form, environ_overrides=sysadmin_env)
 
-        assert "red.css" in resp or "red.min.css" in resp
+        assert "main-rtl.css" in resp or "main-rtl.min.css" in resp
         assert not helpers.body_contains(resp, "main.min.css")
 
     def test_tag_line(self, app, sysadmin_env):