Prepearing for production

This commit is contained in:
Kristofers Solo 2022-08-19 15:00:45 +03:00
parent a6dc255279
commit 2a3b5bccbf
12 changed files with 29 additions and 27 deletions

4
.gitignore vendored
View File

@ -127,3 +127,7 @@ dmypy.json
# Pyre type checker
.pyre/
config.json
debug

View File

@ -10,26 +10,32 @@ For the full list of settings and their values, see
https://docs.djangoproject.com/en/4.0/ref/settings/
"""
import os
import json
from pathlib import Path
from dotenv import load_dotenv
load_dotenv()
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
if Path(BASE_DIR, 'debug').is_file(): # if `debug` files exists
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
with open(Path(BASE_DIR, 'config.json'), 'r', encoding='UTF-8') as config_file:
config = json.load(config_file)
else:
DEBUG = False
with open('/etc/config.json', 'r', encoding='UTF-8') as config_file:
config = json.load(config_file)
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = str(os.getenv('SECURITY_KEY'))
SECRET_KEY = config['SECRET_KEY']
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
ALLOWED_HOSTS = config['ALLOWED_HOSTS']
# Application definition
@ -42,6 +48,7 @@ INSTALLED_APPS = [
'django.contrib.messages',
'django.contrib.staticfiles',
'main',
'karbs',
]
MIDDLEWARE = [
@ -59,7 +66,7 @@ ROOT_URLCONF = 'kristofersxyz.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': ['templates'],
'DIRS': [Path.joinpath(BASE_DIR, 'templates')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
@ -121,11 +128,9 @@ USE_TZ = True
# https://docs.djangoproject.com/en/4.0/howto/static-files/
STATIC_URL = '/static/'
STATIC_ROOT = Path.joinpath(BASE_DIR, 'static')
STATICFILES_DIRS = (
Path.joinpath(BASE_DIR, 'static'),
)
# Default primary key field type
# https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field

View File

@ -22,4 +22,6 @@ urlpatterns = [
path('admin/', admin.site.urls),
path('', include('main.urls')),
path('karbs.sh/', include('karbs.urls')),
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
]
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)

View File

@ -1,4 +1,5 @@
asgiref==3.5.2
Django==4.1
python-dotenv==0.20.0
pycodestyle==2.9.1
sqlparse==0.4.2
toml==0.10.2

View File

@ -2,7 +2,7 @@
{% load static %}
{% block title %} {{ title }} {% endblock %}
{% block meta %}
<link rel="stylesheet" href="{% static 'css/karbs.css' %}" />
<link rel="stylesheet" type="text/css" href="{% static 'karbs/css/karbs.css' %}" />
{% endblock %}
{% block content %}
<h1>Kristofers Auto-Rice Bootsrapping Script (KARBS)</h1><hr>

View File

@ -7,7 +7,7 @@
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0" />
<title>{% block title %}{% endblock %}</title>
<link rel="stylesheet" href="{% static 'css/layout.css' %}" />
<link rel="stylesheet" type="text/css" href="{% static 'main/css/layout.css' %}" />
{% block meta %}{% endblock %}
</head>
@ -26,16 +26,6 @@
<main>{% block content %}{% endblock %}</main>
<!-- <footer> -->
<!-- <p class="footer"> -->
<!-- Copyright &copy -->
<!-- <script> -->
<!-- document.write(new Date().getFullYear()); -->
<!-- </script> -->
<!-- Kristofers Solo -->
<!-- </p> -->
<!-- </footer> -->
</div>
</div>
</body>

View File

@ -2,7 +2,7 @@
{% load static %}
{% block title %} {{ title }} {% endblock %}
{% block meta %}
<link rel="stylesheet" href="{% static 'css/index.css' %}" />
<link rel="stylesheet" type="text/css" href="{% static 'main/css/index.css' %}" />
{% endblock %}
{% block content %}
<div class="center">

View File

@ -7,7 +7,7 @@
<link rel="preconnect" href="https://fonts.gstatic.com" />
<link href="https://fonts.googleapis.com/css2?family=Source+Sans+Pro:wght@900&display=swap" rel="stylesheet" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css" />
<link rel="stylesheet" href="{% static 'css/lightsaber.css' %}" />
<link rel="stylesheet" type="text/css" href="{% static 'main/css/lightsaber.css' %}" />
</head>
<body>
<label for="green">Green</label>