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

Implement collections/ endpoint

parent 77c97578
No related branches found
No related tags found
No related merge requests found
......@@ -4,6 +4,7 @@ from . import views
urlpatterns = [
path('_config.js', views.ConfigView.as_view(), name='config.js'),
path('collections/', views.CollectionsView.as_view(), name='collections'),
re_path(r'^(?P<collection>[A-Za-z0-9-]+)\.(?P<format_>js(on)?)', views.IconifyJSONView.as_view(), name='iconify_json'),
re_path(r'^(?P<collection>[A-Za-z0-9-]+)/(?P<name>[A-Za-z0-9-]+)\.svg', views.IconifySVGView.as_view(), name='iconify_svg'),
]
......@@ -49,6 +49,15 @@ class ConfigView(View):
return HttpResponse(f"var IconifyConfig = {config_json}", content_type="text/javascript")
class CollectionsView(BaseJSONView):
"""Retrieve the available collections with meta-data."""
def get_data(self, request: HttpRequest) -> dict:
collections_path = os.path.join(JSON_ROOT, "collections.json")
with open(collections_path, "r") as collections_file:
data = json.load(collections_file)
return data
class IconifyJSONView(BaseJSONView):
"""Serve the Iconify icon data retrieval API."""
def get_data(self, request: HttpRequest, collection: str) -> dict:
......
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