diff --git a/requirements.txt b/requirements.txt index 7729bf9996528f576430395f32202cb9fa49de27..763d3bb6fe7c19e7a3f749b59abc451752f66a89 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,6 +2,7 @@ certifi==2017.7.27.1 chardet==3.0.4 Django==1.11.6 djangorestframework==3.7.1 +django-webpack-loader==0.5.0 elasticsearch==5.4.0 idna==2.6 olefile==0.44 diff --git a/src/horae/settings.py b/src/horae/settings.py index 487f1f399abb4192223bb1f30b8bd91cf1ef4ec3..fa94fdbf89c32773c8df5f684d5315591ac64445 100644 --- a/src/horae/settings.py +++ b/src/horae/settings.py @@ -41,6 +41,7 @@ INSTALLED_APPS = [ # Tools 'rest_framework', + 'webpack_loader', # Our apps 'images', @@ -62,7 +63,9 @@ ROOT_URLCONF = 'horae.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', - 'DIRS': [], + 'DIRS': [ + os.path.join(BASE_DIR, 'templates'), + ], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ @@ -129,9 +132,22 @@ USE_TZ = True # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/1.11/howto/static-files/ +FRONTEND_DIR = os.path.join(BASE_DIR, '../../frontend') STATIC_URL = '/static/' STATIC_ROOT = os.environ.get('STATIC_ROOT') +STATICFILES_DIRS = [ + os.path.join(FRONTEND_DIR, 'bundles'), +] + +# Frontend +WEBPACK_LOADER = { + 'DEFAULT': { + 'BUNDLE_DIR_NAME': '', + 'STATS_FILE': os.path.join(FRONTEND_DIR, 'webpack-stats.json'), + } +} + # API REST_FRAMEWORK = { diff --git a/src/horae/urls.py b/src/horae/urls.py index 845b90f7be3ed3061972209ca902caa53e4c8c8a..418634f6bb04bc2dc04089db5ceaa38728f5467b 100644 --- a/src/horae/urls.py +++ b/src/horae/urls.py @@ -1,8 +1,11 @@ from django.conf.urls import url, include from django.contrib import admin from horae.api import urlpatterns as api +from horae.views import Home urlpatterns = [ url(r'^api/', include(api, namespace='api')), url(r'^admin/', admin.site.urls), + + url(r'^$', Home.as_view(), name='home'), ] diff --git a/src/horae/views.py b/src/horae/views.py new file mode 100644 index 0000000000000000000000000000000000000000..87d61974c65a14a4b5f82d57e0044283d49655f3 --- /dev/null +++ b/src/horae/views.py @@ -0,0 +1,7 @@ +from django.views.generic import TemplateView + +class Home(TemplateView): + """ + Project homepage + """ + template_name = 'home.html' diff --git a/src/templates/base.html b/src/templates/base.html new file mode 100644 index 0000000000000000000000000000000000000000..b51379442c8f75114a2cda217efee99b9ccaef59 --- /dev/null +++ b/src/templates/base.html @@ -0,0 +1,32 @@ +<!DOCTYPE html> +<html> + <head> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <title>ArkIndex</title> + {% load render_bundle from webpack_loader %} + {% render_bundle 'main' 'css' %} + <meta id="csrf" name="csrf" content="{{ csrf_token }}"> + </head> + <body> + + <nav class="navbar is-dark" role="navigation" aria-label="main navigation"> + <div class="navbar-brand"> + <a class="navbar-item" href="{% url 'home' %}"> + ArkIndex + </a> + </div> + + <div class="navbar-end"> + <div class="navbar-item"> + <p class="control"> + <a class="button is-primary" href="/admin">Admin</a> + </p> + </div> + </div> + </nav> + + {% block content %}{% endblock %} + {% render_bundle 'main' 'js' %} + </body> +</html> diff --git a/src/templates/home.html b/src/templates/home.html new file mode 100644 index 0000000000000000000000000000000000000000..f177a2f8e628d825c5c5c3074da5857e45d81ffc --- /dev/null +++ b/src/templates/home.html @@ -0,0 +1,7 @@ +{% extends 'base.html' %} + +{% block content %} +<div id="app"> + <Search /> +</div> +{% endblock %}