Merge pull request #30 from loleg/blog-revision

Blog revision
This commit is contained in:
datalets 2020-02-18 16:55:05 +01:00 committed by GitHub
commit 066c3e60a4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 442 additions and 237 deletions

View file

@ -69,14 +69,18 @@ django-shell:
logs: logs:
docker-compose logs -f --tail=500 docker-compose logs -f --tail=500
backup: backup-data:
docker-compose start postgres
docker-compose exec web ./manage.py dumpdata --natural-foreign -e auth.permission -e contenttypes -e wagtailcore.GroupCollectionPermission -e wagtailimages.rendition -e sessions -e feedler.feedlysettings > ~/publichealth.home.json docker-compose exec web ./manage.py dumpdata --natural-foreign -e auth.permission -e contenttypes -e wagtailcore.GroupCollectionPermission -e wagtailimages.rendition -e sessions -e feedler.feedlysettings > ~/publichealth.home.json
zip ~/publichealth.home.json.`date +"%d%m%Y-%H%M"`.zip ~/publichealth.home.json zip ~/publichealth.home.json.`date +"%d%m%Y-%H%M"`.zip ~/publichealth.home.json
rm ~/publichealth.home.json rm ~/publichealth.home.json
backup-images:
echo "Backing up images ..." echo "Backing up images ..."
sudo chown -R ansible media
zip -ruq ~/media.zip media zip -ruq ~/media.zip media
backup: backup-data backup-images
django-loaddata: django-loaddata:
gunzip ~/publichealth.home.json.gz gunzip ~/publichealth.home.json.gz
docker-compose exec web ./manage.py loaddata ~/publichealth.home.json docker-compose exec web ./manage.py loaddata ~/publichealth.home.json

View file

@ -21,3 +21,9 @@ django_secret_key: "{{ vault_django_secret_key }}"
# Default: postgres://postgres:@postgres:5432/postgres # Default: postgres://postgres:@postgres:5432/postgres
django_postgres_url: "{{ vault_django_postgres_url }}" django_postgres_url: "{{ vault_django_postgres_url }}"
# Default: http://elasticsearch:9200
django_elasticsearch_url: "{{ vault_django_elasticsearch_url }}"
# Default: redis://redis:6379
django_redis_url: "{{ vault_django_redis_url }}"

View file

@ -1,32 +1,46 @@
$ANSIBLE_VAULT;1.1;AES256 $ANSIBLE_VAULT;1.1;AES256
39613133383630663164333437633037383936663266623861313565663964346232643666653332 31623061306338643731643236656264313365323238383734373466653131336263653365396337
6165666665373661643663323337656163373631366135620a663164653335333166333865383139 3864346638623236343833646264393366666230396662300a623038333531393836356163623731
34633364623536663564363536333737316638353266316261393530386330633963336233346336 38633239636431653935633763316639383562366332346531316632616666346532326239313933
6336383237646233630a656337626566373165313264386438636230646438353131623663666236 6135323639373465300a343438306338653633633465363938363865333530343663383838653738
62633739623431656535383166343862646133396630306264636563643536373562363163316135 62663439333565343565666434646438346566633933333863303361373166616339626630623930
38373966323162653330316135333333643637323732663530336432383066316636303231653534 66646162353034623439653262386130656564613962373234633234346138386132323362323839
37333765313830646662663761376266386262323437373230333231616162393961396162383732 66656533333537303165336634346666306436626236343561343336343135346665666539643232
62633431343062316365316361343432373261623439656533393331383735646639646662653133 65613166373464373035373666646533316365383931623966353939393765343062306230363963
36303039383339353961336664343436653066626561393761383733656664663939333233396134 34306538383064336137313034633764316130653536353035323030326533633431633866646463
63393361396334666330376362643732326266336263393730623464333436336436313639613635 39376234373437313334386465623837613362666337326562396364626332356463313165653661
64646237333739373137356262373666356631356632323466383363356366366366666330646230 32333266396261306565333061323138646531376639666264353366633033646366396634623863
63386232663430386139393864626333326331323031313231346630326133353137373565326538 61653030353061656666326561613736356461363032333937623362363734656466323032303661
36633032653637316531353131653235613331333436316365316661313835373563646534353239 35633635353638613632653639643232313932353232386531353737663436396531396334313837
38623338373365623066613832623836626135326235623538396538366663306365666135633264 63633333393632356166656266643165373238333237363930333132643962636263346466366130
34306464663230616538343539653663326339333437303762323066343933326634633530653565 62343731353939336330316363613238363136366436343732353762626263663736383863356365
34663963353562363132396338623435646165393431303364623834636266373164663933633339 61343361303933346239323165353365626431623938326464396438316332633563663465653337
32346536363330303539373461376631613863656366646437343165633464623064396231346137 63323862393063633965383932393930326266323237643839366231666166636265623637346264
30643261346465303137306161613036336339326530306162393165363766353839316262363263 66326662363735373638343561643239626265643630356239653536623930313564316636303130
38303236633436323830356461653234666534646363336463313064386230663763323632313563 65383661633130323138323330633161386138646564306636643835666333316535636665626464
35396233363933333463326333633737333962353830336135386339613564343237363932306362 37663531646130376564346261363064323434373864663939353835376262346130393338303833
31333535376630363739653433663865366566356132633032666562653234373938633031323139 63626539633332383930373862316237363966363566383735383162396165363662363764366530
61306539376464666664316461303966613231646136623937643965326139303461616366333631 34646135353534306237393233383764376330313234323364363834623438363537386331343934
39323638633661623064623334333864633235646131353237663361343839303537306261656131 63343464353862616339326565626134353661353134306431326666643635383165633964353936
66656331316264636261643165643861376330633035386165626166313133376538656166353136 30646437616436363539346433646463666535303530653533653062376633306332366237373434
31303433633134323532646132386130616431383065363832326533653535663763623733353764 32303964633532336430343662373731356365326366383431616631373132636136653539323037
63383061653062353263383739643366363763363635663165353761623832366139643065396565 64366334386637623436316161613535636130363162363264663033623531633932623462343331
31363435613761623538383237346431613335346437616538643462316665656337343832633937 31343232333064623063326666323038663839643439353166346366663934353565653433366362
33663266663163306461626462626132613961626238333538666233613934346631346231363833 33363432383533663263663761633762366633363563623237636636386337626338653238386533
36633138656563643262393764663331333237386164626230383562396663336564663134356632 33326632646562386134343138663937346464643733616339316162653566323865643633376537
39386137343662666166326131363633353536326130396361376138363132363861313832303262 36343636396263353037316631333933313739316135343766666432373633363166373866333632
326364356331366330393435346330373561 62623734653863303566643331303462363137346233636130333830323333323863356538356139
37303231663966623034323138666664326236626439383638666664363531303433636662666561
39626265323136313037383164646636653265373832663931356237343138396638376135346636
66666536616135386666666464303539616135333064636135346430383431303037393036353435
65306131333532663038306136303930636661373764343736383364303266356330333661386635
34666539636239656637353131333330346563386334306535643230353439623762343932303361
65353163346535396563383862653963326261386531363934356266653461313437633661313035
33643766613366643065663637663733363563663633393238623633653664386630376637643464
61316135633961636337303735656365356437653730373965343933333433386132633061363064
37376337356262613136633431343461333237333063623834616165643637366362393137373339
37363430393939663734303364343064666533653363656633303966613334356363316436326438
30336236343731656566656631323737346630363538663361303734613738303462366238386563
31623135633062666566346561386438663031383232376562623533656437333665376439653932
66373134303762356238323962343339386161333038353038393936306434643739396464323532
3236

View file

@ -5,39 +5,39 @@ web:
volumes: volumes:
- ./:/usr/src/app - ./:/usr/src/app
- {{ django_log_dir }}:/var/log/wagtail - {{ django_log_dir }}:/var/log/wagtail
links: #links:
- redis # - redis
- postgres # - postgres
- elasticsearch # - elasticsearch
ports: ports:
- "5000:5000" - "5000:5000"
environment: environment:
- DJANGO_SETTINGS_MODULE={{ django_project_name }}.settings.production - DJANGO_SETTINGS_MODULE={{ django_project_name }}.settings.production
- ALLOWED_HOSTS=www.{{ allowed_domains|join(',www.') }},{{ allowed_domains }},{{ ipv4_addresses|join(':5000,') }} - ALLOWED_HOSTS=www.{{ allowed_domains|join(',www.') }},{{ allowed_domains|join(',') }},{{ ipv4_addresses|join(':5000,') }}
- SECRET_KEY={{ django_secret_key }} - SECRET_KEY={{ django_secret_key }}
- MAILGUN_KEY={{ django_email_key }} - MAILGUN_KEY={{ django_email_key }}
- MAILGUN_DOMAIN={{ django_email_domain }} - MAILGUN_DOMAIN={{ django_email_domain }}
- MAILGUN_FROM={{ django_email_from }} - MAILGUN_FROM={{ django_email_from }}
- DATABASE_URL={{ django_postgres_url }} - DATABASE_URL={{ django_postgres_url }}
- ELASTICSEARCH_URL=http://elasticsearch:9200 - REDIS_URL={{ django_redis_url }}
- REDIS_URL=redis://redis:6379 - ELASTICSEARCH_URL={{ django_elasticsearch_url }}
- LOG_DIR=/var/log/wagtail - LOG_DIR=/var/log/wagtail
redis: # elasticsearch:
image: redis # image: elasticsearch:5
command: ["redis-server", "--appendonly", "yes"] # ports:
restart: on-failure # - "9200:9200"
volumes: # environment:
- {{ redis_data_dir }}:/data # - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
ports: # mem_limit: 1g
- "6379:6379" # redis:
postgres: # image: redis
image: postgres # command: ["redis-server", "--appendonly", "yes"]
ports: # restart: on-failure
- "5432:5432" # volumes:
elasticsearch: # - {{ redis_data_dir }}:/data
image: elasticsearch:5 # ports:
ports: # - "6379:6379"
- "9200:9200" # postgres:
environment: # image: postgres
- "ES_JAVA_OPTS=-Xms512m -Xmx512m" # ports:
mem_limit: 1g # - "5432:5432"

View file

@ -6,20 +6,13 @@ upstream wagtail-site {
server localhost:5000; server localhost:5000;
} }
server { server {
listen 80 default_server;
server_name _; server_name _;
listen 80 default_server;
location / { return 301 https://$host$request_uri;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://wagtail-site;
}
} }
server { server {
listen 443 ssl default_server;
server_name _; server_name _;
listen 443 ssl default_server;
ssl on; ssl on;
ssl_certificate /etc/certs/public-health.ch/cloudflare.pem; ssl_certificate /etc/certs/public-health.ch/cloudflare.pem;
@ -39,7 +32,7 @@ server {
access_log off; expires 36000; access_log off; expires 36000;
alias {{ release_dir }}/static/; alias {{ release_dir }}/static/;
add_header Cache-Control "public"; add_header Cache-Control "public";
add_header Access-Control-Allow-Origin https://{{ domain }}; add_header Access-Control-Allow-Origin *; #https://{{ domain }};
} }
# Set a longer expiry for CACHE/, because the filenames are unique. # Set a longer expiry for CACHE/, because the filenames are unique.
@ -54,18 +47,30 @@ server {
alias {{ release_dir }}/static/images/favicon.ico; alias {{ release_dir }}/static/images/favicon.ico;
} }
# Only serve /media/images by default, not e.g. original_images/. # Directly serve media with max caching
location /media/images { location /media {
alias {{ release_dir }}/media/images; root {{ release_dir }};
access_log off; expires max; autoindex off;
access_log off;
expires max;
add_header Cache-Control "public"; add_header Cache-Control "public";
} }
# Only serve media by default, not e.g. original_images/.
#location ~* ^/media {
# alias {{ release_dir }}/media;
#}
# Disable English home page (for now) # Disable English home page (for now)
if ($host = 'public-health.ch') { if ($host !~* 'sphc.ch') {
rewrite ^/en/$ $scheme://$host/de/; rewrite ^/en/$ $scheme://$host/de/;
} }
# Redirect French home page as appropriate
if ($host = 'manifestesante.ch') {
rewrite ^/$ $scheme://$host/fr/;
}
location / { location / {
proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

View file

@ -0,0 +1,31 @@
from django.core.management.base import BaseCommand
from django.contrib.auth.models import User
from django.test import Client
from wagtail.core.models import Page
from wagtail.admin.views.pages import edit
# Scans for broken editors, via
# https://github.com/wagtail/wagtail/issues/4602
class Command(BaseCommand):
def handle(self, **options):
invalid_page_ids = []
pages = Page.objects.all()
client = Client()
# use any existing super user account
user = User.objects.get(username='oleg')
client.force_login(user)
for page in pages:
id = page.id
# print statement to assure the script is running
print(id)
url = f'/cms/pages/{id}/edit/'
try:
response = client.get(url)
except:
invalid_pages.append(id)
print(invalid_page_ids)

View file

@ -0,0 +1,25 @@
# Generated by Django 2.1.12 on 2019-10-17 15:15
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('wagtailimages', '0001_squashed_0021'),
('home', '0026_auto_20190625_1521'),
]
operations = [
migrations.AddField(
model_name='contact',
name='color',
field=models.CharField(blank=True, default='', max_length=40),
),
migrations.AddField(
model_name='contact',
name='logo',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='wagtailimages.Image'),
),
]

View file

@ -0,0 +1,18 @@
# Generated by Django 2.1.13 on 2019-10-21 18:09
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('home', '0027_auto_20191017_1715'),
]
operations = [
migrations.AddField(
model_name='contact',
name='style',
field=models.TextField(blank=True, default=''),
),
]

View file

@ -7,6 +7,7 @@ from django.db import models
from wagtail.snippets.models import register_snippet from wagtail.snippets.models import register_snippet
from wagtail.core.models import Page from wagtail.core.models import Page
from wagtail.images.edit_handlers import ImageChooserPanel
from wagtail.admin.edit_handlers import FieldPanel, PageChooserPanel from wagtail.admin.edit_handlers import FieldPanel, PageChooserPanel
from .forms import ContactForm from .forms import ContactForm
@ -63,11 +64,21 @@ class Contact(models.Model):
'title_fr', 'title_fr',
'title_en', 'title_en',
) )
address = models.TextField(default="", blank=True) address = models.TextField(default="", blank=True)
phone = models.CharField(max_length=40, blank=True, default="") phone = models.CharField(max_length=40, blank=True, default="")
email = models.EmailField(max_length=100, blank=True, default="") email = models.EmailField(max_length=100, blank=True, default="")
www = models.URLField(null=True, blank=True) www = models.URLField(null=True, blank=True)
style = models.TextField(default="", blank=True)
color = models.CharField(max_length=40, blank=True, default="")
logo = models.ForeignKey(
'wagtailimages.Image',
null=True, blank=True,
on_delete=models.SET_NULL,
related_name='+'
)
map_url = models.URLField(null=True, blank=True, map_url = models.URLField(null=True, blank=True,
help_text="Optional link of address to mapping provider") help_text="Optional link of address to mapping provider")
analytics = models.CharField(max_length=60, default="", blank=True, analytics = models.CharField(max_length=60, default="", blank=True,
@ -95,6 +106,9 @@ class Contact(models.Model):
FieldPanel('phone'), FieldPanel('phone'),
FieldPanel('email'), FieldPanel('email'),
FieldPanel('www'), FieldPanel('www'),
ImageChooserPanel('logo'),
FieldPanel('color'),
FieldPanel('style'),
FieldPanel('map_url'), FieldPanel('map_url'),
FieldPanel('analytics'), FieldPanel('analytics'),
PageChooserPanel('contact_form', 'home.ContactForm'), PageChooserPanel('contact_form', 'home.ContactForm'),

View file

@ -24,9 +24,17 @@
<meta name="twitter:card" content="summary_large_image" /> <meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:title" content="{{ blog_page.title }}" /> <meta name="twitter:title" content="{{ blog_page.title }}" />
<meta name="twitter:description" content="{{ blog_page.description }}" /> <meta name="twitter:description" content="{{ blog_page.description }}" />
<link rel="alternate" type="application/rss+xml"
title="{{ blog_page.title }}" href="{% feeds_url blog_page %}">
{% endblock social_share %} {% endblock social_share %}
{% block blog_content %} {% block blog_content %}
<section id="blog">
<div class="container">
<div class="row">
{% with per_page=blog_page.num_entries_page %} {% with per_page=blog_page.num_entries_page %}
{# 'paginate' tag cannot render dotted variables, so we need to create a context var #} {# 'paginate' tag cannot render dotted variables, so we need to create a context var #}
{% paginate per_page entries %} {% paginate per_page entries %}
@ -44,44 +52,39 @@
{% endif %} {% endif %}
{% endfor %} {% endfor %}
{% endif %} {% endif %}
<article class="box page-content blog_grid"> {% if forloop.counter0|divisibleby:3 %}
<section> </div><div class="row">
{% endif %}
<!-- Blog post {{ entry.id }} -->
<div class="col-md-4 blog-entry">
<a href="{{ post_url }}">
<div class="panel panel-default">
{% if entry.header_image %} {% if entry.header_image %}
<span class="img-responsive"><a href="{{ post_url }}"> {% image entry.header_image fill-360x270 %}
{% image entry.header_image fill-800x240 as header_image %}
<img alt="{{ entry.header_image.title }}" src="{{ header_image.url }}">
</a></span>
{% endif %} {% endif %}
<!--{% include 'puput/entry_links.html' %}--> <div class="panel-body">
</section> {% for category in entry.categories.all %}
<section class="article"> <div class="entry-category">{{ category.name }}</div>
<h4><a href="{{ post_url }}">{{ entry.title }}</a></h4> {% endfor %}
<h3 class="entry-title">{{ entry.title }}</h3>
<p>
{% if entry.excerpt %} {% if entry.excerpt %}
{{ entry.excerpt|richtext }} {{ entry.excerpt|safe }}
{% else %} {% else %}
{{ entry.body|richtext|truncatewords_html:70 }} {{ entry.body|striptags|truncatewords_html:40 }}
{% endif %} {% endif %}
<div class="row"> </p>
<ul class="social-share col-md-9">
<li class="social-item"> <span class="entry-meta">
{% post_to_facebook post_url '<span><i class="fa fa-facebook"></i></span>' %} {{ entry.date|date:"d.m.Y" }}
</li> </span>
<li class="social-item"> </div><!-- -/panel-body -->
{% post_to_twitter entry.title post_url '<span><i class="fa fa-twitter"></i></span>' %} </div><!-- -/panel -->
</li> </a>
<li class="social-item"> </div><!-- /blog-entry -->
{% post_to_linkendin post_url '<span><i class="fa fa-linkedin"></i></span>' %}
</li>
<li class="social-item">
{% post_to_gplus post_url '<span><i class="fa fa-google-plus"></i></span>' %}
</li>
</ul>
<div class="col-md-3">
<a class="blog_btn continue" href="{{ post_url }}">/{{ entry.slug|truncatechars:25 }} &raquo;</a>
</div>
</div>
</section>
</article>
{% empty %} {% empty %}
<span>{% trans 'No results found.' %}</span> <span>{% trans 'No results found.' %}</span>
{% endfor %} {% endfor %}
@ -89,5 +92,15 @@
<div class="pagination"> <div class="pagination">
{% show_paginator %} {% show_paginator %}
</div> </div>
<div class="rss-sitemap">
<a href="{% feeds_url blog_page %}" target="_blank" title="RSS">
<i class="fa fa-rss-square"></i> <span>RSS</span>
</a>
</div>
{% endwith %} {% endwith %}
</div><!-- /row -->
</div><!-- /container -->
</section>
{% endblock blog_content %} {% endblock blog_content %}

View file

@ -1,5 +1,5 @@
{% extends "puput/base.html" %} {% extends "puput/base.html" %}
{% load i18n wagtailcore_tags wagtailimages_tags puput_tags social_share %} {% load i18n wagtailcore_tags wagtailimages_tags puput_tags wagtailroutablepage_tags social_share %}
{% block title %} {% block title %}
{{ self.title }} | {{ blog_page.title }} {{ self.title }} | {{ blog_page.title }}
@ -43,25 +43,48 @@
{% block blog_content %} {% block blog_content %}
<div class="entry-categories">
{% categories_list self.categories %}
</div>
<h1 class="title">{{ self.title }}</h1>
<ul class="links">
<li>
{{ self.date|date:"d.m.Y" }}
</li>
{% if self.tags.count > 0 %}
<li>
<i class="fa fa-tag"></i> &nbsp;
{% tags_list blog_page.num_tags_entry_header self.tags %}
</li>
{% endif %}
{% if blog_page.display_comments %}
<li>
<i class="fa fa-comments"></i>
{{ self.num_comments }}
</li>
{% endif %}
</ul>
<p class="excerpt">
{{ self.excerpt|safe }}
</p>
{% if self.header_image %} {% if self.header_image %}
<div class="image"> <div class="image">
{% image self.header_image fill-940x400 class="img-responsive" %} {% image self.header_image fill-940x400 class="img-responsive" %}
</div> </div>
{% endif %} {% endif %}
<h1 class="title">{{ self.title }}</h1>
<article class="box page-content" <article class="box page-content"
{% if self.id %}data-entry-page-update-comments-url="{% url 'entry_page_update_comments' self.id %}{% endif %}"> {% if self.id %}data-entry-page-update-comments-url="{% url 'entry_page_update_comments' self.id %}{% endif %}">
{% include 'puput/entry_links.html' with entry=self %}
<section> <section>
{{ self.body|richtext}} {{ self.body|richtext}}
<div class="row"> <div class="row">
<div class="col-md-2"> <div class="col-md-2">
<a href="{% pageurl blog_page %}" class="blog_btn back"> <a href="{% pageurl blog_page %}" class="blog_btn back">
<i class="fa fa-angle-left"></i> <i class="fa fa-home"></i>
<i class="fa fa-angle-left"></i>
<i class="fa fa-angle-left"></i>
</a> </a>
</div> </div>
{% entry_url self blog_page as post_url %} {% entry_url self blog_page as post_url %}

View file

@ -1,3 +1,5 @@
{% load wagtailimages_tags %}
<address> <address>
<p> <p>
{% if contact.map_url %} {% if contact.map_url %}
@ -19,6 +21,25 @@
{% endfor %} {% endfor %}
</div> </div>
<style type="text/css">
{{ contact.style }}
{% if contact.color %}
footer#footer, .navbar-pre {
background-color: {{ contact.color }};
}
{% endif %}
{% if contact.logo %}
{% image contact.logo original as contact_logo %}
.navbar-brand {
background-size: contain !important;
background-repeat: no-repeat;
background-image: url('{{ contact_logo.url }}');
padding-left: 80px;
}
.navbar-brand img { display: none !important; }
{% endif %}
</style>
{% if contact.is_google_analytics %} {% if contact.is_google_analytics %}
<!-- Global site tag (gtag.js) - Google Analytics --> <!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id={{ contact.analytics }}"></script> <script async src="https://www.googletagmanager.com/gtag/js?id={{ contact.analytics }}"></script>

View file

@ -6,23 +6,22 @@ from ..models.snippets import Contact, SocialContact
register = template.Library() register = template.Library()
def get_contacts(site_root): def get_contacts(the_site):
if not site_root: return {} if not the_site: return {}
site = site_root.get_site()
# Selected or default contact snippet # Selected or default contact snippet
top_contact = Contact.objects.filter(home_site=site) top_contact = Contact.objects.filter(home_site=the_site)
if top_contact.exists(): if top_contact.exists():
top_contact = top_contact.last() top_contact = top_contact.first()
else: else:
default_contact = Contact.objects.filter(home_site=None) default_contact = Contact.objects.filter(home_site=None)
if default_contact.exists(): if default_contact.exists():
top_contact = default_contact.last() top_contact = default_contact.first()
else: else:
top_contact = Contact.objects.last() top_contact = Contact.objects.first()
# Selected or default social contact snippet # Selected or default social contact snippet
social_contacts = SocialContact.objects.filter(home_site=site) social_contacts = SocialContact.objects.filter(home_site=the_site)
if social_contacts.exists(): if social_contacts.exists():
social_contacts = social_contacts.all() social_contacts = social_contacts.all()
else: else:
@ -38,24 +37,24 @@ def get_contacts(site_root):
# Contact information (footer) # Contact information (footer)
@register.inclusion_tag('tags/contact_info.html') @register.inclusion_tag('tags/contact_info.html')
def contact_info(site_root): def contact_info(the_site):
return get_contacts(site_root) return get_contacts(the_site)
# Contact form (footer) # Contact form (footer)
@register.inclusion_tag('tags/footer_form.html') @register.inclusion_tag('tags/footer_form.html')
def footer_form(site_root): def footer_form(the_site):
cc = get_contacts(site_root) cc = get_contacts(the_site)
if cc['contact']: if cc['contact']:
return { 'form': cc['contact'].contact_form } return { 'form': cc['contact'].contact_form }
return None return None
# Contact links (header) # Contact links (header)
@register.inclusion_tag('tags/contact_links.html') @register.inclusion_tag('tags/contact_links.html')
def contact_links(site_root): def contact_links(the_site):
return get_contacts(site_root) return get_contacts(the_site)
# Styled contact name (header) # Styled contact name (header)
@register.inclusion_tag('tags/contact_name.html') @register.inclusion_tag('tags/contact_name.html')
def contact_name(site_root, html=True): def contact_name(the_site, html=True):
contactname = get_contacts(site_root)['contact'] contactname = get_contacts(the_site)['contact']
return { 'contact': contactname, 'html': html } return { 'contact': contactname, 'html': html }

View file

@ -33,11 +33,15 @@ def language_switcher(context):
'request': context['request'], 'request': context['request'],
} }
@register.simple_tag(takes_context=True)
def get_site(context):
return context['request'].site
@register.simple_tag(takes_context=True) @register.simple_tag(takes_context=True)
def get_site_root(context): def get_site_root(context):
# NB this returns a core.Page, not the implementation-specific model used # NB this returns a core.Page, not the implementation-specific model used
# so object-comparison to self will return false as objects would differ # so object-comparison to self will return false as objects would differ
return context['request'].site.root_page return get_site(context).root_page
def has_menu_children(page): def has_menu_children(page):
return page.get_children().live().in_menu().exists() return page.get_children().live().in_menu().exists()

View file

@ -198,6 +198,12 @@ COMPRESS_PRECOMPILERS = [
WAGTAIL_SITE_NAME = "Public Health Schweiz" WAGTAIL_SITE_NAME = "Public Health Schweiz"
WAGTAILADMIN_RICH_TEXT_EDITORS = {
'default': {
'WIDGET': 'wagtail.admin.rich_text.HalloRichTextArea'
}
}
# Puput settings # Puput settings
PUPUT_AS_PLUGIN = True PUPUT_AS_PLUGIN = True

View file

@ -56,35 +56,74 @@ $slider-nav: 200px;
.language-nav a[lang='en'] { display: none; } .language-nav a[lang='en'] { display: none; }
// Disable metas and override blog styles // Disable metas and override blog styles
.blog-page .sidebar .meta { display: none; } .blog-page {
.blog-page section { padding: 0; } padding-top: 1em;
.blog-page .blog-tags ul { padding: 0; }
.blog-page ul.sidebar { background: transparent; } .sidebar .meta { display: none; }
.blog-page .searchTerm { ul.sidebar { background: transparent; }
section { padding: 0; }
.blog-tags ul { padding: 0; }
.searchTerm {
text-transform: uppercase; text-transform: uppercase;
font-weight: bold; font-weight: bold;
background: #fff; // background: #fff;
margin-bottom: 0px; margin-bottom: 0px;
} }
.blog-page .searchDescription { .searchDescription {
background: #fff; // background: #fff;
margin-bottom: 20px; margin-bottom: 20px;
padding: 0 20px 20px; padding: 0 20px 20px;
line-height: normal; line-height: normal;
color: #555; color: #555;
} }
.blog-page .social-item { .social-item {
font-size: 70%; font-size: 70%;
background: #2643A9 !important; background: #2643A9 !important;
} }
.blog-header a {
h1.title {
margin-bottom: 0;
}
ul.links {
margin: 0; padding: 0;
display: block;
text-align: center;
}
.blog-entry {
a {
text-decoration: none;
color: black;
}
.panel img {
width: 100%; height: auto;
}
.entry-category, .entry-meta {
font-size: 80%;
color: #777;
text-transform: uppercase;
}
}
}
.blog-header {
a {
color: white !important; color: white !important;
text-shadow: 1px 1px 2px black; text-shadow: 1px 1px 2px black;
text-decoration: none; text-decoration: none;
} }
.blog-header .lead { .lead {
color: white; color: white;
font-size: 100%; font-size: 100%;
} }
}
.blog .entry-categories {
text-align: center;
text-transform: uppercase;
a { color: #555; font-weight: bold; }
li { list-style: none; margin: 0; padding: 0; }
ul { list-style: none; margin: 0; padding: 1em 0 0; }
}
@import "subsites"; @import "subsites";

View file

@ -149,7 +149,5 @@
padding: 1em; padding: 1em;
margin: 0em; margin: 0em;
list-style-type: none; list-style-type: none;
li:first-child { display: none; }
} }
} }

View file

@ -1,3 +1,5 @@
// TODO: delete this file and references to it once styles are migrated.
// Only show news on the main home page // Only show news on the main home page
#news { display: none; } #news { display: none; }
.site-home #news { display: block; } .site-home #news { display: block; }
@ -20,25 +22,6 @@
#carousel-banner .carousel-caption > * { display: none; } #carousel-banner .carousel-caption > * { display: none; }
#carousel-banner .carousel-caption { display: none; } #carousel-banner .carousel-caption { display: none; }
/*
#carousel-banner .carousel-caption {
width: 13em;
background: rgba(0,0,50,0.4);
border: 6px solid white;
font-size: 155%;
padding: 1em 1em;
left: 50%;
margin-left: -6.5em;
bottom: 2em;
}
#carousel-banner .carousel-caption:before {
content: 'SPHC 2018'; display: block;
}
#carousel-banner .carousel-caption:after {
content: 'Better Health Faster';
}
*/
} }
// -site-sphc // -site-sphc

View file

@ -1,11 +1,12 @@
{% load compress static wagtailuserbar navigation information %} {% load compress static wagtailuserbar navigation information %}
{% get_site_root as site_root %} {% get_site_root as site_root %}
{% get_site as the_site %}
<!DOCTYPE html> <!DOCTYPE html>
<html lang="{% language_cur %}"> <html lang="{% language_cur %}">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>{% block title %}{% if self.seo_title %}{{ self.seo_title }}{% else %}{% if page.trans_title %}{{ page.trans_title }} - {% endif %}{% contact_name site_root=site_root html=False %}{% endif %}{% endblock %}{% block title_suffix %}{% endblock %}</title> <title>{% block title %}{% if self.seo_title %}{{ self.seo_title }}{% else %}{% if page.trans_title %}{{ page.trans_title }} - {% endif %}{% contact_name the_site=the_site html=False %}{% endif %}{% endblock %}{% block title_suffix %}{% endblock %}</title>
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="{% block description %}{% endblock %}"> <meta name="description" content="{% block description %}{% endblock %}">
@ -29,13 +30,13 @@
{% include 'footer.html' %} {% include 'footer.html' %}
{% block extra_js %}
<script src="{% static 'libs/jquery/dist/jquery.js' %}"></script> <script src="{% static 'libs/jquery/dist/jquery.js' %}"></script>
<script src="{% static 'libs/bootstrap-sass/assets/javascripts/bootstrap.min.js' %}"></script> <script src="{% static 'libs/bootstrap-sass/assets/javascripts/bootstrap.min.js' %}"></script>
<script src="{% static 'libs/slick-carousel/slick/slick.min.js' %}"></script> <script src="{% static 'libs/slick-carousel/slick/slick.min.js' %}"></script>
<script src="{% static 'libs/slick-lightbox/dist/slick-lightbox.js' %}"></script> <script src="{% static 'libs/slick-lightbox/dist/slick-lightbox.js' %}"></script>
<script src="{% static 'libs/cookieconsent/build/cookieconsent.min.js' %}"></script> <script src="{% static 'libs/cookieconsent/build/cookieconsent.min.js' %}"></script>
{% endblock %}
{% block extra_js %}{% endblock %}
{% compress js %} {% compress js %}
<script type="text/javascript" src="{% static 'js/main.js' %}"></script> <script type="text/javascript" src="{% static 'js/main.js' %}"></script>

View file

@ -1,5 +1,5 @@
{% load static wagtailcore_tags navigation information %} {% load static wagtailcore_tags navigation information %}
{% get_site_root as site_root %} {% get_site as the_site %}
<!-- Footer --> <!-- Footer -->
<footer id="footer"> <footer id="footer">
@ -20,18 +20,18 @@
<a name="contact-info"></a> <a name="contact-info"></a>
<div class="col-md-4" id="contact-info"> <div class="col-md-4" id="contact-info">
{% contact_info site_root=site_root %} {% contact_info the_site=the_site %}
</div> </div>
<div class="col-md-4" id="contact-form"> <div class="col-md-4" id="contact-form">
{% footer_form site_root=site_root %} {% footer_form the_site=the_site %}
</div> </div>
</div><!-- /row --> </div><!-- /row -->
</div><!-- /container --> </div><!-- /container -->
</footer> </footer>
<div class="copyright"> <div class="copyright">
{% contact_name site_root=site_root %} {% contact_name the_site=the_site %}
&copy; 2019 &copy; 2020
&bull; <a href="/privacy/">Privacy</a> &bull; <a href="/privacy/">Privacy</a>
&bull; <a href="/impressum/">Impressum</a> &bull; <a href="/impressum/">Impressum</a>
</div> </div>

View file

@ -1,5 +1,6 @@
{% load static wagtailcore_tags navigation information %} {% load static wagtailcore_tags navigation information %}
{% get_site_root as site_root %} {% get_site_root as site_root %}
{% get_site as the_site %}
<nav class="navbar-pre navbar-fixed-top"> <nav class="navbar-pre navbar-fixed-top">
<div class="container"> <div class="container">
@ -9,7 +10,7 @@
<span class="glyphicon glyphicon-user" aria-hidden="true"></span> <span class="glyphicon glyphicon-user" aria-hidden="true"></span>
<span class="sr-only">Contact</span> <span class="sr-only">Contact</span>
</a> </a>
{% contact_links site_root=site_root %} {% contact_links the_site=the_site %}
</span> </span>
<span class="language-nav"> <span class="language-nav">
{% language_switcher %} {% language_switcher %}
@ -28,7 +29,7 @@
</button> </button>
<a class="navbar-brand" href="{% pageurl site_root %}"> <a class="navbar-brand" href="{% pageurl site_root %}">
<img src="{% static 'images/public-health-logo-sign.png' %}" alt="[logo]"> <img src="{% static 'images/public-health-logo-sign.png' %}" alt="[logo]">
<span class="hidden-xs">{% contact_name site_root=site_root %}</span></a> <span class="hidden-xs">{% contact_name the_site=the_site %}</span></a>
</div> </div>
{% block menu %} {% block menu %}

View file

@ -1,12 +1,12 @@
# Updated: 9.9.2019 # Updated: 21.10.2019
# Core # Core
wagtail==2.6.1 wagtail==2.6.2
Django==2.1.12 Django==2.1.13
elasticsearch>=5.0.0,<6.0.0 elasticsearch>=5.0.0,<6.0.0
# Database # Database
psycopg2-binary==2.8.3 psycopg2-binary==2.8.4
dj-database-url==0.5.0 dj-database-url==0.5.0
# Content # Content
@ -22,15 +22,15 @@ django-el-pagination==3.2.4
django-libsass==0.7 django-libsass==0.7
django-social-share==1.3.2 django-social-share==1.3.2
libsass==0.19.2 libsass==0.19.2
Pillow==6.1.0 Pillow==6.2.1
# Development tools # Development tools
stellar==0.4.5 stellar==0.4.5
# Production dependencies # Production dependencies
gunicorn==19.9.0 gunicorn==19.9.0
whitenoise==4.1.3 whitenoise==4.1.4
ConcurrentLogHandler==0.9.1 ConcurrentLogHandler==0.9.1
django-anymail==7.0.0 django-anymail==7.0.0
django-crispy-forms==1.7.2 django-crispy-forms==1.8.0
python-dotenv==0.10.3 python-dotenv==0.10.3