Skip to content
Snippets Groups Projects
Commit e297b238 authored by Nik | Klampfradler's avatar Nik | Klampfradler
Browse files

Merge branch 'fix/config-js' into 'master'

Fix config JS snippet to work with current Iconify

See merge request !5
parents 5c01e7bb 40c058f6
Branches main
No related tags found
1 merge request!5Fix config JS snippet to work with current Iconify
...@@ -68,15 +68,16 @@ class ConfigView(View): ...@@ -68,15 +68,16 @@ class ConfigView(View):
def get(self, request: HttpRequest) -> HttpResponse: def get(self, request: HttpRequest) -> HttpResponse:
# Guess the base URL by reverse-mapping the URL for a fake icon set # Guess the base URL by reverse-mapping the URL for a fake icon set
rev = reverse("iconify_json", kwargs={"collection": "prefix", "format_": "js"}) 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 # Put together configuration as dict and output as JSON
config = { config = {
"defaultAPI": api_pattern, "resources": api_base,
} }
config_json = json.dumps(config) 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): class CollectionView(BaseJSONView):
......
[tool.poetry] [tool.poetry]
name = "django-iconify" name = "django-iconify"
version = "0.1.1" version = "0.2"
description = "Iconify API implementation and tools for Django projects" description = "Iconify API implementation and tools for Django projects"
authors = ["Dominik George <dominik.george@teckids.org>"] authors = ["Dominik George <dominik.george@teckids.org>"]
license = "Apache-2.0" license = "Apache-2.0"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment