Skip to content
Snippets Groups Projects

Fix config JS snippet to work with current Iconify

Merged Jonathan Weth requested to merge fix/config-js into master
All threads resolved!
2 files
+ 6
5
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 5
4
@@ -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):
Loading