Skip to content

Commit 555632d

Browse files
committed
feat: set up the gist django app
1 parent dc0824f commit 555632d

File tree

6 files changed

+55
-3
lines changed

6 files changed

+55
-3
lines changed

apps/generic/__init__.py

Whitespace-only changes.

apps/generic/utils.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
def get_css_and_js_link_from_vite_assets(type):
2+
"""
3+
We read the vite diretory bath of the build from the manifest
4+
file and then use that to find our static assets to load the
5+
react application
6+
"""
7+
css_links = []
8+
js_links = []
9+
main_js_links = []
10+
asset_manifest = open("static/js/" + type + "/build/manifest.json").read()
11+
asset_manifest_dict = json.loads(asset_manifest)
12+
for key, value in asset_manifest_dict.items():
13+
if key == "index.html":
14+
"""
15+
{'index.css': {'file': 'static/css/main.272c5c26.css', 'src': 'index.css'},
16+
'index.html': {'css': ['static/css/main.272c5c26.css'],
17+
'file': 'static/js/main.0e6a838c.js', 'isEntry': True, 'src': 'index.html'}}
18+
"""
19+
js_file = value.get("file")
20+
full_js_link = "js/" + type + "/build/" + js_file
21+
js_links = [full_js_link]
22+
main_js_links = [full_js_link]
23+
css_file = "js/" + type + "/build/" + "static/css/main.css";
24+
css_links = [css_file]
25+
return css_links, js_links, main_js_links

apps/gist/cms_apps.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from cms.app_base import CMSApp
2+
from cms.apphook_pool import apphook_pool
3+
4+
5+
@apphook_pool.register
6+
class GistApphook(CMSApp):
7+
app_name = "gist"
8+
name = "Gist Application"
9+
10+
def get_urls(self, page=None, language=None, **kwargs):
11+
return ["apps.gist.urls"]

apps/gist/urls.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from django.urls import re_path
2+
from .views import GistView
3+
4+
app_name = "gist"
5+
6+
urlpatterns = [
7+
re_path("", JobView.as_view(), name="gist-list"),
8+
]

apps/gist/views.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1-
from django.shortcuts import render
1+
from django.views.generic import TemplateView
2+
from apps.generic.utils import get_css_and_js_link_from_vite_assets
23

3-
# Create your views here.
4+
5+
class GistView(TemplateView):
6+
def get_context_data(self, **kwargs):
7+
context = super().get_context_data(**kwargs)
8+
css_links, js_links, main_js_links = get_css_and_js_link_from_vite_assets("gist")
9+
context["css_links"] = css_links
10+
context["js_lnks"] = js_links
11+
return context

backend/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
INSTALLED_APPS = [
2929
'backend',
30-
'src.gist',
30+
'apps.gist',
3131

3232
# optional, but used in most projects
3333
'djangocms_admin_style',

0 commit comments

Comments
 (0)