Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix static error on production #9

Merged
merged 1 commit into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading