improve templates

readwriteweb
Jaap Joris Vens 2019-04-02 14:05:14 +02:00
rodzic d4ae47a746
commit 49ced2791e
12 zmienionych plików z 150 dodań i 109 usunięć

Wyświetl plik

@ -6,4 +6,4 @@ class PageForm(forms.ModelForm):
model = Page
fields = '__all__'
SectionFormSet = forms.inlineformset_factory(Page, Section, exclude='__all__', extra=0)
SectionFormSet = forms.inlineformset_factory(Page, Section, exclude='__all__', extra=1)

Wyświetl plik

@ -12,7 +12,7 @@ div.wrapper {
margin: auto;
}
header {
header, section, footer {
padding: 1rem;
}
@ -106,13 +106,6 @@ nav {
}
}
article {
section {
padding: 1rem;
}
}
div.edit {
position: fixed;
left: 1em;
@ -142,21 +135,49 @@ a.edit {
color: red !important;
}
div.video {
padding: 0;
margin: -10px 0;
article {
section {
div.image {
img {
width: 100%;
}
}
div.iframe {
width: 100%;
padding-bottom: 56%;
position: relative;
div.title {
font-size: 2em;
text-align: center;
}
iframe {
position: absolute;
width: 100%;
height: 100%;
left: 0;
top: 0;
div.content {
}
div.video {
div.iframe {
width: 100%;
padding-bottom: 56%;
position: relative;
iframe {
position: absolute;
width: 100%;
height: 100%;
left: 0;
top: 0;
}
}
}
div.button {
text-align: center;
a {
text-decoration: none;
background: black;
color: white;
padding: 5px 15px;
font-size: 1.5em;
border-radius: 3px;
display: inline-block;
}
}
}
}
@ -164,6 +185,15 @@ div.video {
/* Form elements */
form {
div.global_error {
border: 2px dotted red;
padding: 10px;
margin: 1em -10px;
background: #f001;
color: red;
font-weight: bold;
}
fieldset {
padding: 2em;
margin-bottom: 2em;
@ -185,11 +215,10 @@ form {
font-size: 1rem;
}
div.formfield.error {
border: 1px solid red;
border-radius: 10px;
div.errors ul li:before {
content: "Oeps! ";
}
border: 2px dotted red;
padding: 10px;
margin: 0 -10px;
background: #f001;
}
div.formfield.required {
div.label {
@ -258,6 +287,7 @@ form {
ul.errorlist {
margin: 0;
margin-bottom: 1em;
padding: 0;
list-style: none;
color: red;

Wyświetl plik

@ -7,7 +7,7 @@ div.wrapper {
max-width: 700px;
margin: auto; }
header {
header, section, footer {
padding: 1rem; }
@media (min-width: 500px) {
@ -74,9 +74,6 @@ header {
nav ul#menu.visible {
transform: translatex(0); } }
article section {
padding: 1rem; }
div.edit {
position: fixed;
left: 1em;
@ -99,21 +96,44 @@ div.edit {
a.edit {
color: red !important; }
div.video {
padding: 0;
margin: -10px 0; }
div.video div.iframe {
article section div.image img {
width: 100%; }
article section div.title {
font-size: 2em;
text-align: center; }
article section div.video div.iframe {
width: 100%;
padding-bottom: 56%;
position: relative; }
article section div.video div.iframe iframe {
position: absolute;
width: 100%;
padding-bottom: 56%;
position: relative; }
div.video div.iframe iframe {
position: absolute;
width: 100%;
height: 100%;
left: 0;
top: 0; }
height: 100%;
left: 0;
top: 0; }
article section div.button {
text-align: center; }
article section div.button a {
text-decoration: none;
background: black;
color: white;
padding: 5px 15px;
font-size: 1.5em;
border-radius: 3px;
display: inline-block; }
/* Form elements */
form div.global_error {
border: 2px dotted red;
padding: 10px;
margin: 1em -10px;
background: #f001;
color: red;
font-weight: bold; }
form fieldset {
padding: 2em;
margin-bottom: 2em;
@ -131,10 +151,10 @@ form div.formfield > * {
font-size: 1rem; }
form div.formfield.error {
border: 1px solid red;
border-radius: 10px; }
form div.formfield.error div.errors ul li:before {
content: "Oeps! "; }
border: 2px dotted red;
padding: 10px;
margin: 0 -10px;
background: #f001; }
form div.formfield.required div.label {
font-weight: 700; }
@ -191,6 +211,7 @@ form div.filefield {
form ul.errorlist {
margin: 0;
margin-bottom: 1em;
padding: 0;
list-style: none;
color: red;

File diff suppressed because one or more lines are too long

Wyświetl plik

@ -18,34 +18,30 @@
{% block main %}
<header>
<div class="wrapper">
{% block header %}
{% endblock %}
</div>
{% block header %}
{% endblock %}
</header>
<nav>
<div class="wrapper">
{% block nav %}
<ul id="menu">
{% for p in pages %}
{% if p.slug %}
<li><a href="{% url 'cms:page' p.slug %}" {% if p.pk == object.pk %}class="current"{% endif %}>{{p.title}}</a></li>
{% else %}
<li><a href="{% url 'cms:homepage' %}" {% if p.pk == object.pk %}class="current"{% endif %}>{{p.title}}</a></li>
{% endif %}
{% endfor %}
{% if user.is_staff %}
<li><a class="edit" href="{% url 'cms:createpage' %}">+ {% trans 'new page' %}</a></li>
{% block nav %}
<ul id="menu">
{% for p in pages %}
{% if p.slug %}
<li><a href="{% url 'cms:page' p.slug %}" {% if p.pk == object.pk %}class="current"{% endif %}>{{p.title}}</a></li>
{% else %}
<li><a href="{% url 'cms:homepage' %}" {% if p.pk == object.pk %}class="current"{% endif %}>{{p.title}}</a></li>
{% endif %}
</ul>
{% endblock %}
</div>
<button class="hamburger hamburger--collapse" id='hamburger'>
<span class="hamburger-box">
<span class="hamburger-inner"></span>
</span>
</button>
{% endfor %}
{% if user.is_staff %}
<li><a class="edit" href="{% url 'cms:createpage' %}">+ {% trans 'new page' %}</a></li>
{% endif %}
</ul>
<button class="hamburger hamburger--collapse" id='hamburger'>
<span class="hamburger-box">
<span class="hamburger-inner"></span>
</span>
</button>
{% endblock %}
</nav>
<article>
@ -54,10 +50,8 @@
</article>
<footer>
<div class="wrapper">
{% block footer %}
{% endblock %}
</div>
{% block footer %}
{% endblock %}
</footer>
{% endblock %}

Wyświetl plik

@ -7,6 +7,13 @@
{{form.media}}
<div class="wrapper">
{% if form.errors or formset.errors %}
<div class="global_error">
{% blocktrans %}
Please correct the errors below and save again
{% endblocktrans %}
</div>
{% endif %}
{% for field in form %}
{% include 'cms/formfield.html' with field=field %}
{% endfor %}

Wyświetl plik

@ -1,7 +1,7 @@
{% load thumbnail embed_video_tags %}
{% if section.image %}
<div class="photo">
<div class="image">
<img alt="" src="{% thumbnail section.image 800x800 %}">
</div>
{% endif %}
@ -25,3 +25,9 @@
</div>
</div>
{% endif %}
{% if section.button_text and section.button_link %}
<div class="button">
<a href="{{section.button_link}}">{{section.button_text}}</a>
</div>
{% endif %}

Wyświetl plik

@ -1,22 +0,0 @@
{% load thumbnail %}
<ul>
{% for p in pages %}
{% if p.slug %}
<li>
<a href="{{p.get_absolute_url}}">
<div class="image" {% if p.image %}style="background-image: url('{% thumbnail p.image 500x500 %}')"{% endif %}></div>
</a>
<div class="text">
<h1>{{p.title}}</h1>
{{p.content|safe}}
{% if user.is_staff %}
<a class="edit" href="{% url 'updatepage' p.slug %}">[ bewerken ]</a>
{% endif %}
<a class="readmore" href="{{p.get_absolute_url}}">Lees meer &raquo;</a>
</div>
</li>
{% endif %}
{% endfor %}
</ul>

Wyświetl plik

@ -1 +0,0 @@
{% extends 'cms/sections/base.html' %}

Wyświetl plik

@ -1 +0,0 @@
{% extends 'cms/sections/base.html' %}

Wyświetl plik

@ -1,16 +1,23 @@
{% extends "base.html" %}
{% load i18n %}
{% block nav %}
{% endblock %}
{% block content %}
<form method="post">
{% csrf_token %}
<fieldset>
<legend>{% trans 'Log in' %}</legend>
<section>
{{form.non_field_errors}}
{% for field in form %}
{% include 'cms/formfield.html' with field=field %}
{% endfor %}
</fieldset>
<input type="submit" value="{% trans 'Log in' %}">
<div class="wrapper">
<h1>{% trans 'Log in' %}</h1>
{% for field in form %}
{% include 'cms/formfield.html' with field=field %}
{% endfor %}
<button>{% trans 'Log in' %}</button>
</div>
</section>
</form>
{% endblock %}

Wyświetl plik

@ -33,7 +33,7 @@ class EditPageMixin:
def post(self, request, *args, **kwargs):
self.object = self.get_object()
form = self.get_form()
formset = SectionFormSet(request.POST, instance=self.object)
formset = SectionFormSet(request.POST, request.FILES, instance=self.object)
if form.is_valid() and formset.is_valid():
return self.form_valid(form, formset)
else: