瀏覽代碼

Remove bootswatch themes (#640)

To support the custom navbar, and therefore simplify the settings, we
are removing the Bootswatch theme picker.

The theme dropdown was an ill-thought-out feature. We are now going in
the direction of simplifying the built-in navbar/settings, and
encouraging site builders to use custom sass and navbars. There's really
no reason a site admin should need to change the theme on the fly. That
is a nightmare that can remain relegated to WordPress.

"Themes" will be better served as a separate django app/package which
overrides templates. Using a dropdown of a limited number of pre-built
colorized Bootstrap builds is not really helpful in this regard.

For existing sites that want to continue using Bootswatch, it's pretty
easy to accomplish:

In your local project, edit
`website/templates/coderedcms/pages/base.html` and add/edit the
following block:

```jinja
{% block frontend_assets %}
<link rel="stylesheet" href="your bootswatch theme here">
{% endblock %}
```

The appropriate href for the `<link>` tag can be found here:
https://cdnjs.com/libraries/bootswatch
Vince Salvino 10 月之前
父節點
當前提交
39bd3655a3

+ 17 - 0
coderedcms/migrations/0041_remove_layoutsettings_frontend_theme.py

@@ -0,0 +1,17 @@
+# Generated by Django 4.2 on 2024-05-29 19:24
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ("coderedcms", "0040_remove_analyticssettings_ga_tracking_id"),
+    ]
+
+    operations = [
+        migrations.RemoveField(
+            model_name="layoutsettings",
+            name="frontend_theme",
+        ),
+    ]

+ 0 - 17
coderedcms/models/wagtailsettings_models.py

@@ -114,13 +114,6 @@ class LayoutSettings(ClusterableModel, BaseSiteSetting):
         verbose_name=_("Search box"),
         help_text=_("Show search box in navbar"),
     )
-    frontend_theme = models.CharField(
-        blank=True,
-        max_length=50,
-        choices=None,
-        default="",
-        verbose_name=_("Theme variant"),
-    )
     from_email_address = models.CharField(
         blank=True,
         max_length=255,
@@ -187,12 +180,6 @@ class LayoutSettings(ClusterableModel, BaseSiteSetting):
             ],
             heading=_("Branding"),
         ),
-        MultiFieldPanel(
-            [
-                FieldPanel("frontend_theme"),
-            ],
-            heading=_("Theming"),
-        ),
         MultiFieldPanel(
             [
                 FieldPanel("from_email_address"),
@@ -221,9 +208,6 @@ class LayoutSettings(ClusterableModel, BaseSiteSetting):
         """
         super().__init__(*args, **kwargs)
         # Set choices dynamically.
-        self._meta.get_field("frontend_theme").choices = (
-            crx_settings.CRX_FRONTEND_THEME_CHOICES
-        )
         self._meta.get_field("navbar_collapse_mode").choices = (
             crx_settings.CRX_FRONTEND_NAVBAR_COLLAPSE_MODE_CHOICES
         )
@@ -235,7 +219,6 @@ class LayoutSettings(ClusterableModel, BaseSiteSetting):
         )
         # Set default dynamically.
         if not self.id:
-            self.frontend_theme = crx_settings.CRX_FRONTEND_THEME_DEFAULT
             self.navbar_class = crx_settings.CRX_FRONTEND_NAVBAR_CLASS_DEFAULT
             self.navbar_collapse_mode = (
                 crx_settings.CRX_FRONTEND_NAVBAR_COLLAPSE_MODE_DEFAULT

+ 0 - 30
coderedcms/settings.py

@@ -112,36 +112,6 @@ class _DefaultSettings:
         ),
     ]
 
-    CRX_FRONTEND_THEME_DEFAULT = ""
-    CRX_FRONTEND_THEME_CHOICES = [
-        ("", "Default - Classic Bootstrap"),
-        ("cerulean", "Cerulean - A calm blue sky"),
-        ("cosmo", "Cosmo - An ode to Metro"),
-        ("cyborg", "Cyborg - Jet black and electric blue"),
-        ("darkly", "Darkly - Flatly in night mode"),
-        ("flatly", "Flatly - Flat and modern"),
-        ("journal", "Journal - Crisp like a new sheet of paper"),
-        ("litera", "Litera - The medium is the message"),
-        ("lumen", "Lumen - Light and shadow"),
-        ("lux", "Lux - A touch of class"),
-        ("materia", "Materia - Material is the metaphor"),
-        ("minty", "Minty - A fresh feel"),
-        ("morph", "Morph - A neumorphic layer"),
-        ("pulse", "Pulse - A trace of purple"),
-        ("quartz", "Quartz - A glassmorphic layer"),
-        ("sandstone", "Sandstone - A touch of warmth"),
-        ("simplex", "Simplex - Mini and minimalist"),
-        ("sketchy", "Sketchy - A hand-drawn look for mockups and mirth"),
-        ("slate", "Slate - Shades of gunmetal gray"),
-        ("solar", "Solar - A dark spin on Solarized"),
-        ("spacelab", "Spacelab - Silvery and sleek"),
-        ("superhero", "Superhero - The brave and the blue"),
-        ("united", "United - Ubuntu orange and unique font"),
-        ("vapor", "Vapor - A cyberpunk aesthetic"),
-        ("yeti", "Yeti - A friendly foundation"),
-        ("zephyr", "Zephyr - Breezy and beautiful"),
-    ]
-
     CRX_FRONTEND_TEMPLATES_BLOCKS = {
         "cardblock": [
             (

+ 0 - 4
coderedcms/templates/coderedcms/pages/base.html

@@ -54,11 +54,7 @@
   {% include "wagtailseo/meta.html" %}
 
   {% block frontend_assets %}
-  {% if settings.coderedcms.LayoutSettings.frontend_theme %}
-  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/5.3.2/{{settings.coderedcms.LayoutSettings.frontend_theme}}/bootstrap.min.css">
-  {% else %}
   <link rel="stylesheet" href="{% static 'coderedcms/vendor/bootstrap/dist/css/bootstrap.min.css' %}?v={% coderedcms_version %}">
-  {% endif %}
   {% endblock %}
 
   {% block coderedcms_assets %}