From a2561f443fe3e012386fc9e346720ca51062055f Mon Sep 17 00:00:00 2001 From: Greg Thole Date: Fri, 2 Jul 2021 09:02:18 -0400 Subject: [PATCH] Some gentle UI updates --- Dockerfile | 2 +- asgi.py | 11 +++- docker-compose.yml | 4 +- gedgo/static/js/timeline.js | 6 +- gedgo/static/styles/style-default.css | 73 ++++++++++++++++++---- gedgo/static/styles/style-login.css | 11 +--- gedgo/templates/default/base.html | 2 +- gedgo/templates/default/blogpost_list.html | 12 ++-- gedgo/templates/default/documentaries.html | 2 +- gedgo/templates/default/gedcom.html | 2 +- gedgo/templates/default/person-card.html | 2 +- gedgo/templates/default/person.html | 26 ++++---- gedgo/views/blog.py | 15 ++++- reqs.pip | 1 + run.sh | 8 +++ 15 files changed, 122 insertions(+), 55 deletions(-) create mode 100755 run.sh diff --git a/Dockerfile b/Dockerfile index 1e85bd4..66dace6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,4 +17,4 @@ RUN mkdir -p /static && \ USER app -CMD uvicorn --host=0.0.0.0 asgi:application +CMD sh ./run.sh diff --git a/asgi.py b/asgi.py index 3c2ab47..d930b5d 100644 --- a/asgi.py +++ b/asgi.py @@ -1,8 +1,15 @@ import os +os.environ['DJANGO_SETTINGS_MODULE'] = 'settings' + +from django.conf import settings from django.core.asgi import get_asgi_application from django_simple_task import django_simple_task_middlware - -os.environ['DJANGO_SETTINGS_MODULE'] = 'settings' +from asgi_middleware_static_file import ASGIMiddlewareStaticFile app = get_asgi_application() +app = ASGIMiddlewareStaticFile( + app, + static_url=settings.STATIC_URL, + static_root_paths=[settings.STATIC_ROOT] +) application = django_simple_task_middlware(app) diff --git a/docker-compose.yml b/docker-compose.yml index c2def98..525806e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,8 +5,8 @@ services: image: 'gedgo_app' env_file: '.env' container_name: 'gedgo_app' - # command: ['python', 'manage.py', 'runserver', '0.0.0.0:8000'] - command: ['uvicorn', '--host=0.0.0.0', '--reload', 'asgi:application'] + command: ['python', 'manage.py', 'runserver', '0.0.0.0:8000'] + # command: ['uvicorn', '--host=0.0.0.0', '--reload', 'asgi:application'] ports: - '8000:8000' volumes: diff --git a/gedgo/static/js/timeline.js b/gedgo/static/js/timeline.js index 4670049..31d2110 100644 --- a/gedgo/static/js/timeline.js +++ b/gedgo/static/js/timeline.js @@ -36,7 +36,7 @@ .append("line") .attr("x1", w/2).attr("y1", 10) .attr("x2", w/2).attr("y2", h - 10) - .attr("stroke", "teal"); + .attr("stroke", "#004643"); svg.selectAll("circle") .data(events) @@ -45,9 +45,9 @@ .attr("cx", w/2) .attr("cy", (d) => scale(d.year)) .attr("r", 5) - .attr("fill", d => (d.year === birthyear || d.year === deathyear) ? "teal" : "white") + .attr("fill", d => (d.year === birthyear || d.year === deathyear) ? "#004643" : "#fffffe") .attr("stroke-width", 3) - .attr("stroke", d => (d.type === 'personal') ? "teal" : "orange"); + .attr("stroke", d => (d.type === 'personal') ? "#004643" : "#f9bc60"); svg.selectAll("text") .data(events) diff --git a/gedgo/static/styles/style-default.css b/gedgo/static/styles/style-default.css index 273e3bf..fb1486c 100644 --- a/gedgo/static/styles/style-default.css +++ b/gedgo/static/styles/style-default.css @@ -1,16 +1,23 @@ /* Move down content because we have a fixed navbar that is 50px tall */ body { - background-color: #d5dce0; + background-color: #abd1c6; font-family: Camphor, Open Sans, Segoe UI, sans-serif; text-rendering: optimizeLegibility; + color: #001e1d; } a { - color: #537484; + color: #004643; +} +a:hover { + color: #004643; } .navbar { - background-color: #538463 !important; + background-color: #004643; +} +.navbar.navbar-inverse { + border: none; } .navbar-nav li a { color: #fcfcfc !important; @@ -18,30 +25,55 @@ a { .navbar-nav .dropdown .footlist a { color: #666 !important; } + +a.dropdown-toggle { + margin-top: 3px; + padding-bottom: 0; +} +.navbar-nav .open .dropdown-toggle, .navbar-nav .active a { - background-color: #6e9b7d !important; + background-color: #004643 !important; + color: #f9bc60 !important; } -.navbar-nav .open .dropdown-toggle { - background-color: #6e9b7d !important; +.btn-primary { + border: none; + background-color: #f9bc60 !important; } .navbar-brand { color: #fff !important; + padding-bottom: 35px; } .main-container { margin-top: 65px; } +.main-container > .row > div { + padding: 0 5px; +} + +.blog .time { + color: #999; +} + +.documentary, +.blog { + padding: 20px 0; + border-bottom: 1px solid #eee; +} + +.documentary:first-child, +.blog:first-child { + padding-top: 0; +} + .main { margin: 5px; - color: #666; - background-color: #fff; + color: #001e1d; + background-color: #fffffe; padding: 20px; border-radius: 5px; - border-style: solid; - border-color: #d3d3d3; - border-width: 1px; } .section { margin-top: 35px; @@ -55,6 +87,7 @@ a { min-height: 100%; max-height: 100%; margin-bottom: 10px; + border: 1px solid #eee } .subsection-thumb { display: block; @@ -84,9 +117,23 @@ a { min-height: 64px; } -.comment-area { +textarea.comment-area.form-control { resize: none; + appearance: none; + box-shadow: none; + outline: none; + border-radius: 0; + border: none; + background-color: #eee; + border-bottom: 2px solid #004643; +} +textarea.comment-area.form-control:focus { + background-color: #fffffe; + border-top: 1px solid #004643; + border-left: 1px solid #004643; + border-right: 1px solid #004643; } + .card { margin-bottom: 5px; } @@ -106,7 +153,7 @@ a { rect { fill: white; - stroke: teal; + stroke: #004643; stroke-width: 2; } path { diff --git a/gedgo/static/styles/style-login.css b/gedgo/static/styles/style-login.css index 538604c..699e738 100644 --- a/gedgo/static/styles/style-login.css +++ b/gedgo/static/styles/style-login.css @@ -28,16 +28,11 @@ body { .form-signin .form-control:focus { z-index: 2; } -.form-signin input[type="email"] { - margin-bottom: -1px; +.form-signin input { + margin-bottom: 5px; border-bottom-left-radius: 0; border-bottom-right-radius: 0; } -.form-signin input[type="password"] { - margin-bottom: 10px; - border-top-left-radius: 0; - border-top-right-radius: 0; -} .pod { background-color: #FFFBFF; border-radius: 10px; @@ -45,4 +40,4 @@ body { margin: 0 auto; min-height: 80px; max-width: 380px; -} \ No newline at end of file +} diff --git a/gedgo/templates/default/base.html b/gedgo/templates/default/base.html index 4ac5275..fb6a02d 100644 --- a/gedgo/templates/default/base.html +++ b/gedgo/templates/default/base.html @@ -5,7 +5,7 @@ - + {% block headappend %}{% endblock %} diff --git a/gedgo/templates/default/blogpost_list.html b/gedgo/templates/default/blogpost_list.html index 37266c8..ed47ba8 100644 --- a/gedgo/templates/default/blogpost_list.html +++ b/gedgo/templates/default/blogpost_list.html @@ -20,10 +20,10 @@

Archive

{% if posts.object_list %} {% for post in posts.object_list %} -
+

{{ post.title }}

-
{{ post.body|linebreaks|truncatewords:200 }}
{{ post.created }}
+
{{ post.body|linebreaks|truncatewords:200 }}
{% endfor %} {% else %} @@ -31,13 +31,13 @@

Archive

No blog posts written yet.
{% endif %} - + {% if posts.object_list and posts.paginator.num_pages > 1 %}
{% if posts.has_previous %} - << newer entries + < newer {% endif %} @@ -45,8 +45,8 @@

Archive

{# post list #} {% if posts.has_next %} - older entries >> - {% endif %} + older > + {% endif %}
{% endif %} diff --git a/gedgo/templates/default/documentaries.html b/gedgo/templates/default/documentaries.html index 5ae3739..0104a30 100644 --- a/gedgo/templates/default/documentaries.html +++ b/gedgo/templates/default/documentaries.html @@ -21,7 +21,7 @@ {% block content %} {% if documentaries.exists %} {% for documentary in documentaries.iterator %} -
+
diff --git a/gedgo/templates/default/gedcom.html b/gedgo/templates/default/gedcom.html index aca2363..5cdef1d 100644 --- a/gedgo/templates/default/gedcom.html +++ b/gedgo/templates/default/gedcom.html @@ -6,7 +6,7 @@ {% for photo in gedcom.photo_sample %} {% endfor %} diff --git a/gedgo/templates/default/person-card.html b/gedgo/templates/default/person-card.html index 8834b8d..a68e134 100644 --- a/gedgo/templates/default/person-card.html +++ b/gedgo/templates/default/person-card.html @@ -2,7 +2,7 @@
+ class="thumb img-rounded" onerror="this.onerror=null;this.src='{{ STATIC_URL }}img/question.jpg';">

{{ somebody.full_name }}

diff --git a/gedgo/templates/default/person.html b/gedgo/templates/default/person.html index bb54125..e41de8f 100644 --- a/gedgo/templates/default/person.html +++ b/gedgo/templates/default/person.html @@ -6,7 +6,7 @@ {% for photo in photos %} {% empty %} @@ -23,7 +23,7 @@
@@ -97,8 +97,8 @@

Family Photos:

{% endfor %} @@ -108,7 +108,7 @@

Family Photos:

{% if family.children.exists %} -

Children:

+

Children

{% for somebody in family.ordered_children.iterator %}
@@ -123,7 +123,7 @@

Children:

{% if posts.exists %}
-

Related blog posts:

+

Related blog posts

{% for post in posts.iterator %} {{ post.title }}  ({{ post.created }})
{% endfor %} @@ -132,12 +132,12 @@

Related blog posts:

{% if photos %}
-

Photos:

+

Photos

{% for photo in photos %} {% endfor %} @@ -147,7 +147,7 @@

Photos:

{% if person.documentaries %}
-

Documentaries:

+

Documentaries

{% for doc in person.documentaries %} {{ doc.title }}
{% endfor %} @@ -156,7 +156,7 @@

Documentaries:

{% if person.notes.exists %}
-

Notes:

+

Notes

{% for note in person.notes.all %} {{ note.text|linebreaks }} {% endfor %} @@ -165,7 +165,7 @@

Notes:

{% if person.documents %}
-

Documents:

+

Documents

{% for doc in person.documents %}   {{ doc.docfile.name }} @@ -174,13 +174,13 @@

Documents:

{% endif %} {% if person.child_family %} {% endif %} diff --git a/gedgo/views/blog.py b/gedgo/views/blog.py index 8202289..c2ae1cb 100644 --- a/gedgo/views/blog.py +++ b/gedgo/views/blog.py @@ -1,11 +1,15 @@ from django.core.paginator import Paginator, InvalidPage, EmptyPage from django.shortcuts import get_object_or_404 from django.contrib.auth.decorators import login_required +from django.db.models.functions import Trunc from gedgo.models import BlogPost from gedgo.views.util import render, process_comments from datetime import datetime +from pytz import timezone + +eastern = timezone('US/Eastern') @login_required @@ -18,7 +22,7 @@ def blog(request, year, month): if month: posts = posts.filter(created__month=month) - paginator = Paginator(posts, 2) + paginator = Paginator(posts, 5) try: page = int(request.GET.get("page", '1')) @@ -30,9 +34,14 @@ def blog(request, year, month): except (InvalidPage, EmptyPage): posts = paginator.page(paginator.num_pages) - months = set( + months = ( (d.year, d.month, datetime(2012, d.month, 1).strftime('%B')) - for d in BlogPost.objects.values_list('created', flat=True)) + for d in BlogPost.objects \ + .annotate(group=Trunc('created', 'month', tzinfo=eastern)) \ + .order_by('-group') \ + .distinct() \ + .values_list('group', flat=True) + ) return render( request, diff --git a/reqs.pip b/reqs.pip index d10e30d..25b5803 100644 --- a/reqs.pip +++ b/reqs.pip @@ -8,3 +8,4 @@ flake8 anyjson dropbox==9.0.0 django-simple-task +ASGIMiddlewareStaticFile diff --git a/run.sh b/run.sh new file mode 100755 index 0000000..d314e86 --- /dev/null +++ b/run.sh @@ -0,0 +1,8 @@ +# /bin/sh +set -e + +# Apply any migrations before launching the listener +./manage.py migrate + +# Run the application +uvicorn --host=0.0.0.0 --workers=4 asgi:application