Skip to content

Commit

Permalink
create context processor for webpack manifest, re #11670
Browse files Browse the repository at this point in the history
  • Loading branch information
whatisgalen committed Jan 10, 2025
1 parent bf605e2 commit 32646be
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions arches/app/utils/context_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,17 @@
"""

import json
import logging
import os
from arches import __version__
from arches.app.models.models import GroupMapSettings, Language
from arches.app.models.system_settings import settings
from arches.app.utils.geo_utils import GeoUtils
from arches.app.utils.betterJSONSerializer import JSONSerializer
from django.utils.translation import get_language, get_language_bidi

logger = logging.getLogger(__name__)


def livereload(request):
return {
Expand Down Expand Up @@ -109,3 +113,21 @@ def app_settings(request=None):
"DEBUG": settings.DEBUG,
}
}


def webpack_manifest(request):
"""
Loads the webpack manifest.json and adds it to the template context.
"""
manifest_path = os.path.join(
settings.STATIC_ROOT, settings.STATIC_URL, "build", "manifest.json"
)
manifest = {}

if os.path.exists(manifest_path):
with open(manifest_path, "r") as f:
manifest = json.load(f)
else:
logger.warning("Webpack manifest not found at %s", manifest_path)

return {"webpack_manifest": manifest}

0 comments on commit 32646be

Please sign in to comment.