From a926043fa61c465d4229d701ca412047ccb81d80 Mon Sep 17 00:00:00 2001 From: Cyrus Hiatt Date: Sat, 25 Jan 2025 06:50:32 -0800 Subject: [PATCH 1/2] Adds rascoll search component at standalone endpoint, #14 --- afrc/media/js/views/rascoll-search.js | 6 ++++ afrc/templates/views/rascoll-search.htm | 39 +++++++++++++++++++++++++ afrc/urls.py | 2 ++ afrc/views/rascoll_search.py | 9 ++++++ 4 files changed, 56 insertions(+) create mode 100644 afrc/media/js/views/rascoll-search.js create mode 100644 afrc/templates/views/rascoll-search.htm create mode 100644 afrc/views/rascoll_search.py diff --git a/afrc/media/js/views/rascoll-search.js b/afrc/media/js/views/rascoll-search.js new file mode 100644 index 0000000..becd9ab --- /dev/null +++ b/afrc/media/js/views/rascoll-search.js @@ -0,0 +1,6 @@ +import SearchPage from '@/afrc/Search/SearchPage.vue'; +import createVueApplication from 'arches/arches/app/media/js/utils/create-vue-application'; + +createVueApplication(SearchPage).then(vueApp => { + vueApp.mount('#rascoll-search-container'); +}); \ No newline at end of file diff --git a/afrc/templates/views/rascoll-search.htm b/afrc/templates/views/rascoll-search.htm new file mode 100644 index 0000000..4a3eb49 --- /dev/null +++ b/afrc/templates/views/rascoll-search.htm @@ -0,0 +1,39 @@ +{% extends "base-root.htm" %} + +{% load static %} +{% load webpack_static from webpack_loader %} + +{% block head %} + + + {% block title %}{% endblock title %} + + + + + + + + + + + + + + + + {% block css %} + + + + + {% endblock css %} + +{% endblock head %} + + + {% block body %} +
+ {% endblock body %} \ No newline at end of file diff --git a/afrc/urls.py b/afrc/urls.py index 62a24fd..5c84d37 100644 --- a/afrc/urls.py +++ b/afrc/urls.py @@ -10,6 +10,7 @@ GeoJSONBoundsAPI, ReferenceCollectionMVT, ) +from afrc.views.rascoll_search import RascollSearchView urlpatterns = [ # project-level urls @@ -23,6 +24,7 @@ ReferenceCollectionMVT.as_view(), name="api-reference-collection-mvt", ), + re_path(r"^rascoll-search$", RascollSearchView.as_view(), name="rascoll-search"), ] # Ensure Arches core urls are superseded by project-level urls diff --git a/afrc/views/rascoll_search.py b/afrc/views/rascoll_search.py new file mode 100644 index 0000000..b0a03d7 --- /dev/null +++ b/afrc/views/rascoll_search.py @@ -0,0 +1,9 @@ +from django.shortcuts import render +from arches.app.views.base import BaseManagerView +from django.utils.translation import gettext_lazy as _ + +class RascollSearchView(BaseManagerView): + def get(self, request, graphid=None, resourceid=None): + context = self.get_context_data(main_script="views/rascoll-search") + context['page_title'] = _("RASCOLL Search") + return render(request, "views/rascoll-search.htm", context) \ No newline at end of file From 3b37d4bac711b1f2bfda01cc7dedd50bf9ec9f8e Mon Sep 17 00:00:00 2001 From: Cyrus Hiatt Date: Mon, 27 Jan 2025 16:14:31 -0800 Subject: [PATCH 2/2] Add django-csp, allow admin to uncomment middleware --- afrc/settings.py | 1 + pyproject.toml | 1 + 2 files changed, 2 insertions(+) diff --git a/afrc/settings.py b/afrc/settings.py index 4f5c315..745033b 100644 --- a/afrc/settings.py +++ b/afrc/settings.py @@ -167,6 +167,7 @@ "django.middleware.clickjacking.XFrameOptionsMiddleware", "arches.app.utils.middleware.SetAnonymousUser", # "silk.middleware.SilkyMiddleware", + # "csp.middleware.CSPMiddleware", ] MIDDLEWARE.insert( # this must resolve to first MIDDLEWARE entry diff --git a/pyproject.toml b/pyproject.toml index eef52f7..11e9e4c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -25,6 +25,7 @@ classifiers = [ requires-python = ">=3.10" dependencies = [ "arches>=7.6.2,<7.7.0", + "django_csp==3.8", ] version = "0.0.1"