Skip to content

Commit

Permalink
Fix static error on production (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
meomancer authored Jul 12, 2024
1 parent d41fd41 commit cf773ff
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<meta charset="utf-8">
<title>Maputnik</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="manifest" href="{% static "/cloud_native_gis/manifest-BrZzkYP9.json" %}">
<link rel="icon" href="{% static "/cloud_native_gis/favicon-DBn6BKLx.ico" %}" type="image/x-icon" />
<link rel="manifest" href="{% static "cloud_native_gis/manifest-BrZzkYP9.json" %}">
<link rel="icon" href="{% static "cloud_native_gis/favicon-DBn6BKLx.ico" %}" type="image/x-icon" />
<style>
html {
background-color: rgb(28, 31, 36);
Expand Down Expand Up @@ -38,8 +38,8 @@
}

</style>
<script type="module" crossorigin src="{% static "/cloud_native_gis/index-DRZ64yjZ.js" %}"></script>
<link rel="stylesheet" crossorigin href="{% static "/cloud_native_gis/index-DW0d2Ij5.css" %}">
<script type="module" crossorigin src="{% static "cloud_native_gis/index-DRZ64yjZ.js" %}"></script>
<link rel="stylesheet" crossorigin href="{% static "cloud_native_gis/index-DW0d2Ij5.css" %}">

<script>
window.csrfmiddlewaretoken = '{{ csrf_token }}';
Expand Down
2 changes: 1 addition & 1 deletion django_project/core/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
# Don't forget to use absolute paths, not relative paths.
absolute_path('core', 'static'),
absolute_path('frontend', 'bundles'),
absolute_path('cloud_native_gis', 'templates', 'cloud_native_gis'),
absolute_path('cloud_native_gis', 'static'),
)

# Every cache key will get prefixed with this value - here we set it to
Expand Down
12 changes: 9 additions & 3 deletions maputnik_html_to_django.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ def maputnik_html_to_django():
r'href="{% static "\1" %}"',
filedata
)
filedata = filedata.replace('/maputnik', '')
filedata = filedata.replace('/static', '')
filedata = filedata.replace('/maputnik/static/', '')
filedata = filedata.replace('/static/static/', '')
filedata = filedata.replace(
'</head>',
'''
Expand All @@ -41,7 +41,13 @@ def maputnik_html_to_django():
file.write(filedata)

# Move static file
static_folder = os.path.join(folder, 'cloud_native_gis', 'static')
static_folder = os.path.join(
folder, 'cloud_native_gis', 'static', 'cloud_native_gis'
)
shutil.rmtree(
'django_project/cloud_native_gis/static/cloud_native_gis',
ignore_errors=True
)
shutil.move(static_folder, 'django_project/cloud_native_gis/static')
shutil.move(
path, os.path.join(folder, 'cloud_native_gis/maputnik.html')
Expand Down

0 comments on commit cf773ff

Please sign in to comment.