diff --git a/Pipfile b/Pipfile index c30cb6f..5adefcb 100644 --- a/Pipfile +++ b/Pipfile @@ -46,6 +46,7 @@ gevent = "*" django-extensions = "*" python-magic = "*" pyup-django = "*" +"jinja2" = "*" [dev-packages] ptpython = "*" diff --git a/Pipfile.lock b/Pipfile.lock index a776fe0..5991b0b 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "7e1c8e47e62347ea8efb99864ab1630c617caf37856b1a339057556f9aa202f7" + "sha256": "a0fb5f4752579f5f354d4b55ffcf07ed67d716895e6f52b954c576b4424acaf5" }, "pipfile-spec": 6, "requires": { @@ -391,6 +391,14 @@ ], "version": "==0.6.0" }, + "jinja2": { + "hashes": [ + "sha256:74c935a1b8bb9a3947c50a54766a969d4846290e1e788ea44c1392163723c3bd", + "sha256:f84be1bb0040caca4cea721fcbbbbd61f9be9464ca236387158b0feea01914a4" + ], + "index": "pypi", + "version": "==2.10" + }, "lxml": { "hashes": [ "sha256:01c45df6d90497c20aa2a07789a41941f9a1029faa30bf725fc7f6d515b1afe9", @@ -432,6 +440,12 @@ "index": "pypi", "version": "==2.6.11" }, + "markupsafe": { + "hashes": [ + "sha256:a6be69091dac236ea9c6bc7d012beab42010fa914c459791d627dad4910eb665" + ], + "version": "==1.0" + }, "mf2py": { "hashes": [ "sha256:9231bc1317dd5d01973b78a60e52ecd76dd84089c132540e799e4a62aeff3436", diff --git a/lemonauth/jinja2/lemonauth/indie.html b/lemonauth/jinja2/lemonauth/indie.html new file mode 100644 index 0000000..1b55113 --- /dev/null +++ b/lemonauth/jinja2/lemonauth/indie.html @@ -0,0 +1,74 @@ +{% extends 'lemoncurry/layout.html' %} + +{% block styles %} + +{% endblock %} + +{% block main %} +
+
+

+ {% if app %} + + sign in to {{ app.name[0] }} ({{ params.client_id }})? + {% else %} + sign in to {{ params.client_id }}? + {% endif %} + {% if verified %} + + + + {% else %} + + + + {% endif %} +

+ +
+

do you want to confirm your identity, {{ me }}, with this app?

+ {% if params.response_type == 'code' %} +

additionally, this app is requesting the following scopes - you can edit the scopes that will be granted to the app, if you wish

+
+ {% for scope in scopes %} +
+ + +
+ {% endfor %} +
+ {% endif %} +

you will be redirected to {{ redirect_uri }} after authorising this app

+
+ + + + {{ csrf_input }} + + + + {% if params.state %} + + {% endif %} + +
+
+ + + +{% endblock %} + +{% block foot %} + +{% endblock %} diff --git a/lemonauth/jinja2/lemonauth/login.html b/lemonauth/jinja2/lemonauth/login.html new file mode 100644 index 0000000..c22fbdd --- /dev/null +++ b/lemonauth/jinja2/lemonauth/login.html @@ -0,0 +1,61 @@ +{% extends 'lemoncurry/layout.html' %} +{% block styles %} + +{% endblock %} + +{% block main %} +
+ {% if form.errors %} +

+ uh oh! your login details didn't match, please try again +

+ + {% elif next %} + {% if request.user.is_authenticated %} +

+ hang on! your account doesn't have access to this page :( to proceed, please log in to an account that does have access! +

+ {% else %} +

+ oops! please log in to see this page +

+ {% endif %} + + {% endif %} +
+
+
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+
+ + + + {{ csrf_input }} + +
+
+{% endblock %} diff --git a/lemoncurry/jinja2.py b/lemoncurry/jinja2.py new file mode 100644 index 0000000..25546af --- /dev/null +++ b/lemoncurry/jinja2.py @@ -0,0 +1,21 @@ +from django.contrib.staticfiles.storage import staticfiles_storage +from django.urls import reverse +from jinja2 import Environment +from compressor.contrib.jinja2ext import CompressorExtension + +from .utils import load_package_json + + +def environment(**options): + env = Environment( + extensions=[CompressorExtension], + trim_blocks=True, + lstrip_blocks=True, + **options + ) + env.globals.update({ + 'package': load_package_json(), + 'static': staticfiles_storage.url, + 'url': reverse, + }) + return env diff --git a/lemoncurry/jinja2/lemoncurry/layout.html b/lemoncurry/jinja2/lemoncurry/layout.html new file mode 100644 index 0000000..c46f232 --- /dev/null +++ b/lemoncurry/jinja2/lemoncurry/layout.html @@ -0,0 +1,67 @@ + + + + + + + {% if title %}{{ title }} ~ {% endif %}{{ request.site.name }} + + + + + + {% compress css %} + + {% block styles %}{% endblock %} + {% endcompress %} + + + + +
+ +
+ +
+ {% block main %} + {% endblock %} +
+ + + + + + + + + {% compress js %} + + {% block foot %} + {% endblock %} + {% endcompress %} + + diff --git a/lemoncurry/settings/base.py b/lemoncurry/settings/base.py index 8068b11..13e2cd7 100644 --- a/lemoncurry/settings/base.py +++ b/lemoncurry/settings/base.py @@ -124,9 +124,15 @@ ROOT_URLCONF = 'lemoncurry.urls' SESSION_ENGINE = 'django.contrib.sessions.backends.cached_db' TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.jinja2.Jinja2', + 'APP_DIRS': True, + 'OPTIONS': { + 'environment': 'lemoncurry.jinja2.environment', + }, + }, { 'BACKEND': 'django.template.backends.django.DjangoTemplates', - 'DIRS': [], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [