From 40c058f6ed4283b701185fd358a59c87f9da9f17 Mon Sep 17 00:00:00 2001
From: Jonathan Weth <git@jonathanweth.de>
Date: Sat, 19 Mar 2022 18:11:42 +0100
Subject: [PATCH] Fix config JS snippet to work with current Iconify and bump
 version

cf. https://docs.iconify.design/api/config.html#using-iconifyproviders
---
 dj_iconify/views.py | 9 +++++----
 pyproject.toml      | 2 +-
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/dj_iconify/views.py b/dj_iconify/views.py
index 166a059..f609de3 100644
--- a/dj_iconify/views.py
+++ b/dj_iconify/views.py
@@ -68,15 +68,16 @@ class ConfigView(View):
     def get(self, request: HttpRequest) -> HttpResponse:
         # Guess the base URL by reverse-mapping the URL for a fake icon set
         rev = reverse("iconify_json", kwargs={"collection": "prefix", "format_": "js"})
-        # Iconify SVG Framework expects placeholders {prefix} and {icons} in API URL
-        api_pattern = rev[:-9] + "{prefix}.js?icons={icons}"
+
+        # Iconify SVG Framework expects just the base path to the API
+        api_base = rev[:-10]
 
         # Put together configuration as dict and output as JSON
         config = {
-            "defaultAPI": api_pattern,
+            "resources": api_base,
         }
         config_json = json.dumps(config)
-        return HttpResponse(f"var IconifyConfig = {config_json}", content_type="text/javascript")
+        return HttpResponse("var IconifyProviders = {'': " + config_json + "}", content_type="text/javascript")
 
 
 class CollectionView(BaseJSONView):
diff --git a/pyproject.toml b/pyproject.toml
index 9488950..e89ba92 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,6 +1,6 @@
 [tool.poetry]
 name = "django-iconify"
-version = "0.1.1"
+version = "0.2"
 description = "Iconify API implementation and tools for Django projects"
 authors = ["Dominik George <dominik.george@teckids.org>"]
 license = "Apache-2.0"
-- 
GitLab