From 0811936382a1836e6669bd5a8245914c8b2c1510 Mon Sep 17 00:00:00 2001 From: Livvy Mackintosh Date: Fri, 16 Jun 2017 18:06:22 +0200 Subject: [PATCH] Update lots of things --- Dockerfile | 1 + apps/map/admin.py | 6 +- apps/map/forms.py | 25 +++ apps/map/models.py | 3 +- apps/map/static/map/ojuso-logo-white.png | Bin 0 -> 5081 bytes apps/map/templates/map/_nav.html | 15 ++ apps/map/templates/map/base.html | 67 ++++++++ .../templates/map/base_with_container.html | 34 ++++ apps/map/templates/map/base_with_jumbo.html | 30 ++++ apps/map/templates/map/form.html | 24 +++ apps/map/templates/map/index.html | 161 ++++++++++++------ apps/map/urls.py | 3 +- apps/map/views.py | 7 + bin/create-discourse | 50 +++--- bin/sri-hash | 23 +++ environment.sh | 45 +++++ ojusomap/settings.py | 26 +++ ojusomap/urls.py | 4 +- requirements.txt | 4 + .../en_GB/LC_MESSAGES/django.po | 0 support/locale/es/LC_MESSAGES/django.po | 51 ++++++ support/nginx/directives/gzip.directive | 56 ++++++ support/nginx/nginx.template | 28 +-- 23 files changed, 557 insertions(+), 106 deletions(-) create mode 100644 apps/map/forms.py create mode 100644 apps/map/static/map/ojuso-logo-white.png create mode 100644 apps/map/templates/map/_nav.html create mode 100644 apps/map/templates/map/base.html create mode 100644 apps/map/templates/map/base_with_container.html create mode 100644 apps/map/templates/map/base_with_jumbo.html create mode 100644 apps/map/templates/map/form.html create mode 100755 bin/sri-hash create mode 100755 environment.sh rename support/{locales => locale}/en_GB/LC_MESSAGES/django.po (100%) create mode 100644 support/locale/es/LC_MESSAGES/django.po create mode 100644 support/nginx/directives/gzip.directive diff --git a/Dockerfile b/Dockerfile index fdb7d5e..fa24edf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,6 +16,7 @@ SHELL ["/bin/bash","-ex","-c"] ENV DEBIAN_FRONTEND noninteractive RUN apt-get update && apt-get install -y\ build-essential\ + closure-compiler\ cron\ locales\ libgdal-dev\ diff --git a/apps/map/admin.py b/apps/map/admin.py index 10af6a2..30248af 100644 --- a/apps/map/admin.py +++ b/apps/map/admin.py @@ -1,4 +1,6 @@ from django.contrib import admin -from apps.map.models import CaseStudy +from leaflet.admin import LeafletGeoAdmin -admin.site.register(CaseStudy) +from .models import CaseStudy + +admin.site.register(CaseStudy, LeafletGeoAdmin) diff --git a/apps/map/forms.py b/apps/map/forms.py new file mode 100644 index 0000000..8b85f8a --- /dev/null +++ b/apps/map/forms.py @@ -0,0 +1,25 @@ +from django import forms +from crispy_forms.helper import FormHelper +from crispy_forms.layout import Submit +from leaflet.forms.widgets import LeafletWidget + +from .models import CaseStudy + + +class CaseStudyForm(forms.ModelForm): + + def __init__(self, *args, **kwargs): + super(CaseStudyForm, self).__init__(*args, **kwargs) + self.helper = FormHelper() + self.helper.form_id = 'case-study-form' + self.helper.form_class = 'form-horizontal' + self.helper.form_method = 'post' + self.helper.form_action = 'submit' + self.helper.label_class = 'col-lg-2' + self.helper.field_class = 'col-lg-8' + self.helper.add_input(Submit('submit', 'Submit')) + + class Meta: + model = CaseStudy + fields = '__all__' + widgets = {'location': LeafletWidget()} diff --git a/apps/map/models.py b/apps/map/models.py index 134d346..3c1ce2e 100644 --- a/apps/map/models.py +++ b/apps/map/models.py @@ -25,10 +25,9 @@ class CaseStudy(models.Model): editable=False ) + project_name = models.CharField(max_length=128) # Location of map pin location = models.PointField() - - project_name = models.CharField(max_length=128) supply_chain = models.CharField( max_length=1, choices=SUPPLY_CHAIN_CHOICES diff --git a/apps/map/static/map/ojuso-logo-white.png b/apps/map/static/map/ojuso-logo-white.png new file mode 100644 index 0000000000000000000000000000000000000000..0276cb12ec237c069899dc0e9fb1566e537bd0e1 GIT binary patch literal 5081 zcmV;~6DI75P)004R> z004l5008;`004mK004C`008P>0026e000+ooVrmw00006VoOIv0RI600RN!9r;`8x z010qNS#tmYE+YT{E+YYWr9XB6000McNliru;RPH4F9g?6lal}d6FNymK~#9!?VNdh zRMpwXzvtdbCVL>P0s#RcfS%@a3kf)q-rN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~ILI{N0wTGmxO#FA$ka;rO96VtBxheuz`+b@M48mcWY$PHXtDMbi?C z;7qhTDb20UavW>Mp?A_=LB%BYM4?f7{?AML;t#hSjgNA@D6k42I#0jkp0ZZ+Vd=vuKY>@wT)+Z^>ny`YWyHP!rjGkpw2-abgn^m$?YxUPF+4kqOAlY84Id`ac(q zPb@Y6gy(u-5XxHBI#ThY^GiQEQ6qsvW%I3~CtF3Z`K_sYs7$9kwXHg5g7RgQ8-$eB zx2zo6agEZfLv)1#nl{}r>iF7eKKn6*>PvS1(%^UkiHXn)WerB_J74^8_LlQYKfF4k z?6F9c6Cl?qSGOGfB=lff*T`_RUUvWfewK|M7q3I5>9w(U?&z=mt@sy~tJ?t|HkJAO zWh8{Uph?6~s*YIG_q_VVr)y`nKc{T#3lU{c#`pTDvbbc=^Eszs>3cU-wO&}EL$?w? z0tPd62@3G%<^;{Y!jiCkgK$CEm$~Uel+?C#;Ta^kOLGmYptp?3LJ>U8LyvtAN zY@wGC5El1A9SvL6CobAvrRtSx(t^f7lMu`9wD#3iD)c9kA3o~lYFh2C`n1GJeYh@t vD-APOkAOz_2R|)nK?_>Yf)=#kKL-B>L%PD1 +
+ + +
+ + diff --git a/apps/map/templates/map/base.html b/apps/map/templates/map/base.html new file mode 100644 index 0000000..f789084 --- /dev/null +++ b/apps/map/templates/map/base.html @@ -0,0 +1,67 @@ +{% spaceless %} +{% load bootstrap3 %} +{% load compress %} +{% load i18n %} +{% load leaflet_tags %} + + + + + + {# Metadata #} + + + + {% trans "Ojuso Platform Map" %} + + + + {# CDN Stylesheets #} + + + + + {# Additional Stylesheets #} + {% compress css %} + {% block stylesheets %} + + {% endblock %} + {% endcompress %} + + + + + {# Main Markup #} + {% block body %}{% endblock %} + + {# CDN Javascript #} + + + + {# Additional Scripts #} + {% block scripts %}{% endblock %} + + + +{% endspaceless %} diff --git a/apps/map/templates/map/base_with_container.html b/apps/map/templates/map/base_with_container.html new file mode 100644 index 0000000..435ad0e --- /dev/null +++ b/apps/map/templates/map/base_with_container.html @@ -0,0 +1,34 @@ +{% extends "map/base.html" %} + +{% block stylesheets %} + {{ block.super }} + +{% endblock %} + +{% block body %} + + {% include "map/_nav.html" %} + {% block nav_links %} +
  • Case Studies
  • + {% endblock %} + +
    + +
    +

    {% block title %}{% endblock %}

    +

    {% block description %}{% endblock %}

    +
    + + {% block content %} + {% endblock %} + +
    +{% endblock %} diff --git a/apps/map/templates/map/base_with_jumbo.html b/apps/map/templates/map/base_with_jumbo.html new file mode 100644 index 0000000..d6dec46 --- /dev/null +++ b/apps/map/templates/map/base_with_jumbo.html @@ -0,0 +1,30 @@ +{% extends "map/base.html" %} + +{% block stylesheets %} + {{ block.super }} + +{% endblock %} + +{% block body %} + + {% include "map/_nav.html" %} + +
    + + {% block content %} + {% endblock %} + +
    +{% endblock %} diff --git a/apps/map/templates/map/form.html b/apps/map/templates/map/form.html new file mode 100644 index 0000000..3cfd697 --- /dev/null +++ b/apps/map/templates/map/form.html @@ -0,0 +1,24 @@ +{% extends "map/base_with_container.html" %} +{% load compress %} +{% load crispy_forms_tags %} +{% load i18n %} +{% load leaflet_tags %} + + +{% block stylesheets %} + {{ block.super }} + {% leaflet_css %} + +{% endblock %} + + +{% block title %}{% trans "Submit a Case Study" %}{% endblock %} +{% block description %}{% trans "Here you can submit a case study for review and it will be added to the map." %}{% endblock %} + +{% block content %} + {% crispy form %} +{% endblock %} + +{% block scripts %} + {% leaflet_js %} +{% endblock %} diff --git a/apps/map/templates/map/index.html b/apps/map/templates/map/index.html index 8c6072a..584ebfb 100644 --- a/apps/map/templates/map/index.html +++ b/apps/map/templates/map/index.html @@ -1,56 +1,113 @@ +{% extends "map/base_with_jumbo.html" %} {% load bootstrap3 %} +{% load compress %} {% load i18n %} {% load leaflet_tags %} - - - - - {% trans "Ojuso Platform Map" %} - - {% bootstrap_css %} - {% leaflet_js %} - {% leaflet_css %} - - - -

    Ojuso Platform Map

    - {% leaflet_map "main" callback="main_app_init" %} -
    - - {% bootstrap_javascript %} - - - + +{% block stylesheets %} + {{ block.super }} + {% leaflet_css %} + +{% endblock %} + + +{% block title %}{% trans "Ojuso Platform Map" %}{% endblock %} + + +{% block content %} +
    +
    +{% endblock %} + + +{% block scripts %} + {% leaflet_map "main" callback="main_app_init" creatediv=False %} + {% leaflet_js %} + +{% endblock %} diff --git a/apps/map/urls.py b/apps/map/urls.py index 920c96b..b0a8da8 100644 --- a/apps/map/urls.py +++ b/apps/map/urls.py @@ -8,5 +8,6 @@ urlpatterns = [ url(r'^$', views.index, name='index'), url(r'^data.geojson$', GeoJSONLayerView.as_view(model=CaseStudy, geometry_field='location'), - name='data') + name='data'), + url(r'^case-study/add', views.form, name='form') ] diff --git a/apps/map/views.py b/apps/map/views.py index cc0ea94..60dee31 100644 --- a/apps/map/views.py +++ b/apps/map/views.py @@ -1,5 +1,12 @@ from django.shortcuts import render +from .forms import CaseStudyForm + def index(request): return render(request, 'map/index.html') + + +def form(request): + form = CaseStudyForm + return render(request, 'map/form.html', {'form': form}) diff --git a/bin/create-discourse b/bin/create-discourse index b064b4b..f80001f 100755 --- a/bin/create-discourse +++ b/bin/create-discourse @@ -1,27 +1,27 @@ #!/bin/bash # Create Discourse -docker run -d --restart=always - -e LANG=en_US.UTF-8 \ - -e RAILS_ENV=production \ - -e UNICORN_WORKERS=4 \ - -e UNICORN_SIDEKIQS=1 \ - -e RUBY_GLOBAL_METHOD_CACHE_SIZE=131072 \ - -e RUBY_GC_HEAP_GROWTH_MAX_SLOTS=40000 \ - -e RUBY_GC_HEAP_INIT_SLOTS=400000 \ - -e RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR=1.5 \ - -e DISCOURSE_DB_SOCKET=/var/run/postgresql \ - -e LETSENCRYPT_DIR=/shared/letsencrypt \ - -e DISCOURSE_HOSTNAME=forum.ojuso.org \ - -e DISCOURSE_DEVELOPER_EMAILS=admin@ojuso.org \ - -e DISCOURSE_SMTP_ADDRESS=mail.gandi.net \ - -e DISCOURSE_SMTP_PORT=587 \ - -e DISCOURSE_SMTP_USER_NAME=admin@ojuso.org \ - -e DISCOURSE_SMTP_PASSWORD=QN7yosrnch1le474H56mesVR1SRw6sfO3izJDZnJ6T62Cj9I57CplW6UYZY6VXsq7lLr868bIK3kSXGyWiSrAyWK \ - -e LETSENCRYPT_ACCOUNT_EMAIL=admin@ojuso.org -h energy-app \ - -e DOCKER_HOST_IP=172.17.0.1 \ - --name app \ - -t -p 80:80 -p 443:443 \ - -v /var/discourse/shared/standalone:/shared \ - -v /var/discourse/shared/standalone/log/var-log:/var/log \ - --mac-address 02:2d:a6:d4:85:4a \ - local_discourse/app /sbin/boot +docker run -d --restart=always \ +-e LANG=en_US.UTF-8 \ +-e RAILS_ENV=production \ +-e UNICORN_WORKERS=4 \ +-e UNICORN_SIDEKIQS=1 \ +-e RUBY_GLOBAL_METHOD_CACHE_SIZE=131072 \ +-e RUBY_GC_HEAP_GROWTH_MAX_SLOTS=40000 \ +-e RUBY_GC_HEAP_INIT_SLOTS=400000 \ +-e RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR=1.5 \ +-e DISCOURSE_DB_SOCKET=/var/run/postgresql \ +-e LETSENCRYPT_DIR=/shared/letsencrypt \ +-e DISCOURSE_HOSTNAME=forum.ojuso.org \ +-e DISCOURSE_DEVELOPER_EMAILS=admin@ojuso.org \ +-e DISCOURSE_SMTP_ADDRESS=mail.gandi.net \ +-e DISCOURSE_SMTP_PORT=587 \ +-e DISCOURSE_SMTP_USER_NAME=admin@ojuso.org \ +-e DISCOURSE_SMTP_PASSWORD=QN7yosrnch1le474H56mesVR1SRw6sfO3izJDZnJ6T62Cj9I57CplW6UYZY6VXsq7lLr868bIK3kSXGyWiSrAyWK \ +-e LETSENCRYPT_ACCOUNT_EMAIL=admin@ojuso.org -h energy-app \ +-e DOCKER_HOST_IP=172.17.0.1 \ +--name app \ +-p 80:80 -p 443:443 \ +-v /var/discourse/shared/standalone:/shared \ +-v /var/discourse/shared/standalone/log/var-log:/var/log \ +--mac-address 02:2d:a6:d4:85:4a \ +local_discourse/app /sbin/boot diff --git a/bin/sri-hash b/bin/sri-hash new file mode 100755 index 0000000..b2446f5 --- /dev/null +++ b/bin/sri-hash @@ -0,0 +1,23 @@ +#!/bin/bash +usage="Usage: $(basename "$0") URL +Generate the subresource integrity hash (SRI) of URL. + + --help display this help and exit" + +seed=42 +while getopts ':hs-help:' option; do + case "$option" in + h) echo "$usage" + exit + ;; + :) printf "missing argument for -%s\n" "$OPTARG" >&2 + echo "$usage" >&2 + exit 1 + ;; + \?) printf "illegal option: -%s\n" "$OPTARG" >&2 + echo "$usage" >&2 + exit 1 + ;; + esac +done +echo sha384-$(curl -s $1 | openssl dgst -sha384 -binary | openssl enc -base64 -A) diff --git a/environment.sh b/environment.sh new file mode 100755 index 0000000..ae0007c --- /dev/null +++ b/environment.sh @@ -0,0 +1,45 @@ +#!/bin/bash -e +export DEBUG=0 +export ALLOWED_HOSTS=map.ojuso.org +export DATABASE_HOST=localhost +export DATABASE_NAME=postgres +export DATABASE_PASSWORD=2xXKKS9zdrBX9QJaV5Z5NPTiiW8LtTiR4vAGSACddqFTrBdhgwZHKYnLqjJedAi3 +export EMAIL_HOST=mail.gandi.net +export EMAIL_HOST_USER=admin@ojuso.org +export EMAIL_HOST_PASSWORD=QN7yosrnch1le474H56mesVR1SRw6sfO3izJDZnJ6T62Cj9I57CplW6UYZY6VXsq7lLr868bIK3kSXGyWiSrAyWK +export EMAIL_PORT=587 +export EMAIL_USE_TLS=1 +export SECRET_KEY=a3DfjSmWkSffsPscRscqaxGv6HsBN8VKL8Q4EU4QcdEckB8scogrMP4tv7Eo7LZw +export SERVER_EMAIL=Ojuso\ Platform\ Notification\ \ +export POSTGRES_USER=postgres +export POSTGRES_PASSWORD=2xXKKS9zdrBX9QJaV5Z5NPTiiW8LtTiR4vAGSACddqFTrBdhgwZHKYnLqjJedAi3 +export DISCOURSE_DB_SOCKET=/var/run/postgresql +export DISCOURSE_DEVELOPER_EMAILS=admin@ojuso.org +export DISCOURSE_HOSTNAME=forum.ojuso.org +export DISCOURSE_SMTP_ADDRESS=mail.gandi.net +export DISCOURSE_SMTP_PASSWORD=QN7yosrnch1le474H56mesVR1SRw6sfO3izJDZnJ6T62Cj9I57CplW6UYZY6VXsq7lLr868bIK3kSXGyWiSrAyWK +export DISCOURSE_SMTP_PORT=587 +export DISCOURSE_SMTP_USER_NAME=admin@ojuso.org +export DOCKER_HOST_IP=172.17.0.1 +export LANG=en_US.UTF-8 +export RAILS_ENV=production +export RUBY_GC_HEAP_GROWTH_MAX_SLOTS=40000 +export RUBY_GC_HEAP_INIT_SLOTS=400000 +export RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR=1.5 +export RUBY_GLOBAL_METHOD_CACHE_SIZE=131072 +export UNICORN_SIDEKIQS=1 +export UNICORN_WORKERS=4 +export WEBLATE_DEBUG=0 +export WEBLATE_LOGLEVEL=DEBUG +export WEBLATE_SITE_TITLE=Ojuso\ Weblate +export WEBLATE_ADMIN_NAME=Weblate\ Admin +export WEBLATE_ADMIN_EMAIL=admin@ojuso.org +export WEBLATE_ADMIN_PASSWORD=zPFPtHLsRRFAAcApeGd23aV6Hg66KpTkWs2becsMMoL9dTeKLNt3PfH5Bzhyna8q +export WEBLATE_SERVER_EMAIL=noreply@ojuso.org +export WEBLATE_DEFAULT_FROM_EMAIL=noreply@ojuso.org +export WEBLATE_ALLOWED_HOSTS=* +export WEBLATE_REGISTRATION_OPEN=1 +export WEBLATE_GITHUB_USERNAME=livmackintosh +export WEBLATE_EMAIL_HOST=mail.gandi.net +export WEBLATE_EMAIL_USER=admin@ojuso.org +export WEBLATE_EMAIL_PASSWORD=QN7yosrnch1le474H56mesVR1SRw6sfO3izJDZnJ6T62Cj9I57CplW6UYZY6VXsq7lLr868bIK3kSXGyWiSrAyWK diff --git a/ojusomap/settings.py b/ojusomap/settings.py index e5b9e8b..3dad794 100644 --- a/ojusomap/settings.py +++ b/ojusomap/settings.py @@ -45,6 +45,7 @@ INSTALLED_APPS = [ 'django.contrib.gis', 'bootstrap3', 'cas_server', + 'compressor', 'crispy_forms', 'django_extensions', 'leaflet', @@ -158,6 +159,13 @@ LOCALE_PATHS = [ STATIC_ROOT = os.path.join(BASE_DIR, 'static/') STATIC_URL = os.getenv("STATIC_URL", '/static/') +STATICFILES_FINDERS = [ + 'django.contrib.staticfiles.finders.FileSystemFinder', + 'django.contrib.staticfiles.finders.AppDirectoriesFinder', + 'compressor.finders.CompressorFinder', +] + + # Cache # https://docs.djangoproject.com/en/1.11/topics/cache/ @@ -191,3 +199,21 @@ REST_FRAMEWORK = { 'rest_framework.parsers.JSONParser', ) } + +# Django Crispy Forms +# http://django-crispy-forms.readthedocs.io/en/latest/ + +CRISPY_TEMPLATE_PACK = 'bootstrap3' + +# Django-Leaflet +# https://django-leaflet.readthedocs.io/en/latest/ + +LEAFLET_CONFIG = { + 'MIN_ZOOM': 3, + 'MAX_ZOOM': 16, + 'PLUGINS': { + 'forms': { + 'auto-include': True + } + }, +} diff --git a/ojusomap/urls.py b/ojusomap/urls.py index 7c98f74..38e32f3 100644 --- a/ojusomap/urls.py +++ b/ojusomap/urls.py @@ -17,7 +17,6 @@ from django.conf.urls import include, url from django.contrib import admin from django.contrib.auth.models import User from apps.map.models import CaseStudy -from django.views.generic.base import RedirectView from rest_framework import routers, serializers, viewsets from rest_framework_gis import serializers as gis_serializers @@ -48,9 +47,8 @@ apirouter.register(r'users', UserViewSet) apirouter.register(r'case-studies', CaseStudyViewSet) urlpatterns = [ - url(r'^$', RedirectView.as_view(url="/beta/")), + url(r'', include('apps.map.urls'), name="map"), url(r'api/', include(apirouter.urls)), - url(r'^beta/', include('apps.map.urls'), name="beta"), url(r'^admin/', admin.site.urls), url(r'^cas/', include('cas_server.urls', namespace='cas_server')), ] diff --git a/requirements.txt b/requirements.txt index 27b6662..d364449 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,9 @@ appdirs==1.4.3 Django==1.10.7 +django-appconf==1.0.2 django-bootstrap3==8.2.3 django-cas-server==0.8.0 +django-compressor==2.1.1 django-countries==4.5 django-crispy-forms==1.6.1 django-extensions==1.7.9 @@ -18,6 +20,8 @@ psycopg2==2.7.1 pyparsing==2.2.0 python-memcached==1.58 pytz==2017.2 +rcssmin==1.0.6 requests==2.14.2 requests-futures==0.9.7 +rjsmin==1.0.12 six==1.10.0 diff --git a/support/locales/en_GB/LC_MESSAGES/django.po b/support/locale/en_GB/LC_MESSAGES/django.po similarity index 100% rename from support/locales/en_GB/LC_MESSAGES/django.po rename to support/locale/en_GB/LC_MESSAGES/django.po diff --git a/support/locale/es/LC_MESSAGES/django.po b/support/locale/es/LC_MESSAGES/django.po new file mode 100644 index 0000000..7f6a27d --- /dev/null +++ b/support/locale/es/LC_MESSAGES/django.po @@ -0,0 +1,51 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-06-16 16:05+0000\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +#: apps/map/templates/map/base.html:15 apps/map/templates/map/index.html:15 +msgid "Ojuso Platform Map" +msgstr "" + +#: apps/map/templates/map/form.html:15 apps/map/templates/map/index.html:108 +msgid "Submit a Case Study" +msgstr "" + +#: apps/map/templates/map/form.html:16 +msgid "" +"Here you can submit a case study for review and it will be added to the map." +msgstr "" + +#: apps/map/templates/map/index.html:51 +msgid "Quick View" +msgstr "" + +#: apps/map/templates/map/index.html:58 apps/map/templates/map/index.html:89 +msgid "Close" +msgstr "" + +#: apps/map/templates/map/index.html:92 +msgid "Save changes" +msgstr "" + +#: ojusomap/settings.py:149 +msgid "English" +msgstr "" + +#: ojusomap/settings.py:150 +msgid "Spanish" +msgstr "" diff --git a/support/nginx/directives/gzip.directive b/support/nginx/directives/gzip.directive new file mode 100644 index 0000000..e5bd46e --- /dev/null +++ b/support/nginx/directives/gzip.directive @@ -0,0 +1,56 @@ + # Enable gzip compression. + # Default: off + gzip on; + + # Compression level (1-9). + # 5 is a perfect compromise between size and CPU usage, offering about + # 75% reduction for most ASCII files (almost identical to level 9). + # Default: 1 + gzip_comp_level 5; + + # Don't compress anything that's already small and unlikely to shrink much + # if at all (the default is 20 bytes, which is bad as that usually leads to + # larger files after gzipping). + # Default: 20 + gzip_min_length 256; + + # Compress data even for clients that are connecting to us via proxies, + # identified by the "Via" header (required for CloudFront). + # Default: off + gzip_proxied any; + + # Tell proxies to cache both the gzipped and regular version of a resource + # whenever the client's Accept-Encoding capabilities header varies; + # Avoids the issue where a non-gzip capable client (which is extremely rare + # today) would display gibberish if their proxy gave them the gzipped version. + # Default: off + gzip_vary on; + + # Compress all output labeled with one of the following MIME-types. + # text/html is always compressed by gzip module. + # Default: text/html + gzip_types + application/atom+xml + application/javascript + application/json + application/ld+json + application/manifest+json + application/rss+xml + application/vnd.geo+json + application/vnd.ms-fontobject + application/x-font-ttf + application/x-web-app-manifest+json + application/xhtml+xml + application/xml + font/opentype + image/bmp + image/svg+xml + image/x-icon + text/cache-manifest + text/css + text/plain + text/vcard + text/vnd.rim.location.xloc + text/vtt + text/x-component + text/x-cross-domain-policy; diff --git a/support/nginx/nginx.template b/support/nginx/nginx.template index f3d23f3..01c0a0e 100644 --- a/support/nginx/nginx.template +++ b/support/nginx/nginx.template @@ -6,8 +6,9 @@ server { alias /web/acme; } - return 301 https://$host$request_uri; - + location / { + return 301 https://$host$request_uri; + } } server { @@ -66,12 +67,12 @@ server { server { listen 443 ssl http2; listen [::]:443 ssl http2; - server_name energy.ojuso.org; + server_name i18n.ojuso.org; - ssl_certificate /web/certs/energy.ojuso.org/fullchain.pem; - ssl_certificate_key /web/certs/energy.ojuso.org/privkey.pem; + ssl_certificate /web/certs/i18n.ojuso.org/fullchain.pem; + ssl_certificate_key /web/certs/i18n.ojuso.org/privkey.pem; ssl_dhparam /web/certs/dhparam.pem; - ssl_trusted_certificate /web/certs/energy.ojuso.org/chain.pem; + ssl_trusted_certificate /web/certs/i18n.ojuso.org/chain.pem; include directives/*; @@ -79,21 +80,6 @@ server { root /web/weblate/data/static; - gzip on; - gzip_proxied any; - gzip_types text/plain - application/atom+xml - application/rss+xml - application/javascript - text/xml - text/css - application/xml - application/json - image/svg+xml - font/opentype - application/x-font-ttf - application/vnd.ms-fontobject; - location /favicon.ico { alias /web/weblate/data/static/favicon.ico; expires 30d;