diff --git a/.gitignore b/.gitignore index b6e4761..3d3e166 100644 --- a/.gitignore +++ b/.gitignore @@ -127,3 +127,7 @@ dmypy.json # Pyre type checker .pyre/ + + +config.json +debug diff --git a/kristofersxyz/settings.py b/kristofersxyz/settings.py index 40cd03a..50bfd16 100644 --- a/kristofersxyz/settings.py +++ b/kristofersxyz/settings.py @@ -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 diff --git a/kristofersxyz/urls.py b/kristofersxyz/urls.py index 7e36e69..0bfde44 100644 --- a/kristofersxyz/urls.py +++ b/kristofersxyz/urls.py @@ -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) diff --git a/requirements.txt b/requirements.txt index d50d127..a5e9457 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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 diff --git a/static/css/karbs.css b/static/karbs/css/karbs.css similarity index 100% rename from static/css/karbs.css rename to static/karbs/css/karbs.css diff --git a/static/css/index.css b/static/main/css/index.css similarity index 100% rename from static/css/index.css rename to static/main/css/index.css diff --git a/static/css/layout.css b/static/main/css/layout.css similarity index 100% rename from static/css/layout.css rename to static/main/css/layout.css diff --git a/static/css/lightsaber.css b/static/main/css/lightsaber.css similarity index 100% rename from static/css/lightsaber.css rename to static/main/css/lightsaber.css diff --git a/templates/karbs/instructions.html b/templates/karbs/instructions.html index b31fefb..30fcaf6 100644 --- a/templates/karbs/instructions.html +++ b/templates/karbs/instructions.html @@ -2,7 +2,7 @@ {% load static %} {% block title %} {{ title }} {% endblock %} {% block meta %} - + {% endblock %} {% block content %}

Kristofers Auto-Rice Bootsrapping Script (KARBS)


diff --git a/templates/layout.html b/templates/layout.html index 55fb623..066bc42 100644 --- a/templates/layout.html +++ b/templates/layout.html @@ -7,7 +7,7 @@ {% block title %}{% endblock %} - + {% block meta %}{% endblock %} @@ -26,16 +26,6 @@
{% block content %}{% endblock %}
- - - - - - - - - - diff --git a/templates/main/index.html b/templates/main/index.html index ae26875..eff99b3 100644 --- a/templates/main/index.html +++ b/templates/main/index.html @@ -2,7 +2,7 @@ {% load static %} {% block title %} {{ title }} {% endblock %} {% block meta %} - + {% endblock %} {% block content %}
diff --git a/templates/main/lightsaber.html b/templates/main/lightsaber.html index 6e6bf35..5aed57c 100644 --- a/templates/main/lightsaber.html +++ b/templates/main/lightsaber.html @@ -7,7 +7,7 @@ - +