Add metatags and more fields
This commit is contained in:
parent
5253b2838c
commit
8c8c05981f
12 changed files with 70 additions and 24 deletions
|
@ -1,5 +1,5 @@
|
|||
from django.db import models
|
||||
from project.common.fields import build_stream_field
|
||||
from project.common.blocks import build_stream_field
|
||||
from wagtail.wagtailcore.models import Page
|
||||
from wagtail.wagtailadmin.edit_handlers import FieldPanel, StreamFieldPanel
|
||||
from wagtail.wagtailimages.edit_handlers import ImageChooserPanel
|
||||
|
|
|
@ -3,19 +3,35 @@ from wagtail.wagtailcore import blocks
|
|||
from wagtail.wagtailimages.blocks import ImageChooserBlock
|
||||
from wagtail.wagtaildocs.blocks import DocumentChooserBlock
|
||||
from wagtailmarkdown.blocks import MarkdownBlock
|
||||
from wagtail.wagtailembeds.blocks import EmbedBlock
|
||||
|
||||
|
||||
def build_header_fields():
|
||||
for i in range(6):
|
||||
h_tag = "h" + str(i + 1)
|
||||
yield (h_tag, blocks.CharBlock(classname=h_tag, label=h_tag.upper(), icon="title"))
|
||||
HEADING_CHOICES = [('h' + str(i), 'H' + str(i)) for i in range(1, 6)]
|
||||
|
||||
|
||||
def build_fixed_fields():
|
||||
return [
|
||||
class HeadingBlock(blocks.StructBlock):
|
||||
size = blocks.ChoiceBlock(choices=HEADING_CHOICES)
|
||||
value = blocks.CharBlock()
|
||||
|
||||
class Meta:
|
||||
icon = 'title'
|
||||
template = 'blocks/heading.html'
|
||||
|
||||
|
||||
class VideoBlock(blocks.StructBlock):
|
||||
video = EmbedBlock()
|
||||
caption = blocks.CharBlock()
|
||||
|
||||
class Meta:
|
||||
template = 'blocks/video.html'
|
||||
|
||||
|
||||
def build_stream_field():
|
||||
return StreamField([
|
||||
('ansi', blocks.TextBlock(template="blocks/ansi.html")),
|
||||
('document', DocumentChooserBlock()),
|
||||
('gist', blocks.CharBlock(icon="code", template="blocks/gist.html")),
|
||||
('heading', HeadingBlock()),
|
||||
('image', ImageChooserBlock()),
|
||||
('markdown', MarkdownBlock()),
|
||||
('ol', blocks.ListBlock(blocks.CharBlock(label="List Item"), icon="list-ol", label="Ordered List", template='blocks/ordered-list.html')),
|
||||
|
@ -23,15 +39,5 @@ def build_fixed_fields():
|
|||
('raw_html', blocks.RawHTMLBlock(label="Raw HTML")),
|
||||
('secret', blocks.RichTextBlock(icon="password", template='blocks/secret.html')),
|
||||
('ul', blocks.ListBlock(blocks.CharBlock(label="List Item"), icon="list-ul", label="Unordered List")),
|
||||
]
|
||||
|
||||
|
||||
def build_stream_field():
|
||||
fields = []
|
||||
for field_builder in [
|
||||
build_header_fields,
|
||||
build_fixed_fields
|
||||
]:
|
||||
for field in field_builder():
|
||||
fields.append(field)
|
||||
return StreamField(fields)
|
||||
('video', VideoBlock())
|
||||
])
|
|
@ -1,8 +1,9 @@
|
|||
from wagtail.wagtailcore.models import Page
|
||||
from django.db import models
|
||||
from wagtailmetadata.models import MetadataPageMixin
|
||||
|
||||
|
||||
class Entity(Page):
|
||||
class Entity(MetadataPageMixin, Page):
|
||||
is_home = False
|
||||
|
||||
created = models.DateTimeField(auto_now_add=True)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
from django.db import models
|
||||
from project.common.fields import build_stream_field
|
||||
from project.common.blocks import build_stream_field
|
||||
from project.common.models import Entity
|
||||
from wagtail.wagtailcore.models import Page
|
||||
from wagtail.wagtailcore.fields import RichTextField
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from django.db import models
|
||||
from django.core.exceptions import ValidationError
|
||||
from project.common.fields import build_stream_field
|
||||
from project.common.blocks import build_stream_field
|
||||
from wagtail.wagtailcore.models import Page
|
||||
from wagtail.wagtaildocs.edit_handlers import DocumentChooserPanel
|
||||
from wagtail.wagtailadmin.edit_handlers import FieldPanel, StreamFieldPanel
|
||||
|
|
|
@ -41,6 +41,8 @@ INSTALLED_APPS = [
|
|||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
|
||||
'wagtailmetadata',
|
||||
|
||||
'project.blog',
|
||||
'project.common',
|
||||
'project.home',
|
||||
|
@ -79,7 +81,7 @@ MIDDLEWARE = [
|
|||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||
|
||||
'wagtail.wagtailcore.middleware.SiteMiddleware',
|
||||
'wagtail.wagtailredirects.middleware.RedirectMiddleware',
|
||||
'wagtail.wagtailredirects.middleware.RedirectMiddleware'
|
||||
]
|
||||
|
||||
ROOT_URLCONF = 'project.urls'
|
||||
|
@ -163,3 +165,15 @@ WAGTAILSEARCH_BACKENDS = {
|
|||
# e.g. in notification emails. Don't include '/admin' or a trailing slash
|
||||
BASE_URL = 'https://theorangeone.net'
|
||||
SITE_URL = BASE_URL
|
||||
|
||||
|
||||
# Password policy settings
|
||||
SESSION_SERIALIZER = 'django.contrib.sessions.serializers.PickleSerializer'
|
||||
PASSWORD_CHECK_ONLY_AT_LOGIN = True
|
||||
PASSWORD_MIN_LENGTH = 7
|
||||
PASSWORD_MAX_LENGTH = 25
|
||||
PASSWORD_HISTORY_COUNT = 6
|
||||
PASSWORD_MIN_LETTERS = 1
|
||||
PASSWORD_MIN_NUMBERS = 1
|
||||
PASSWORD_MIN_SYMBOLS = 1
|
||||
PASSWORD_DIFFERENCE_DISTANCE = 3
|
||||
|
|
|
@ -9,6 +9,7 @@ psycopg2==2.6.2
|
|||
pygments-style-github==0.4
|
||||
safety==0.5.1
|
||||
wagtail>=1.7,<1.8
|
||||
wagtail-metadata==0.3.0
|
||||
git+https://github.com/RealOrangeOne/wagtail-markdown
|
||||
waitress==1.0.1
|
||||
whitenoise==3.2.2
|
||||
|
|
|
@ -5,3 +5,14 @@
|
|||
max-height: 100vh;
|
||||
}
|
||||
}
|
||||
|
||||
.block-video {
|
||||
iframe {
|
||||
width: 100%;
|
||||
height: 50vh;
|
||||
}
|
||||
|
||||
span {
|
||||
font-style: italic;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{% load static wagtailuserbar %}
|
||||
{% load static wagtailuserbar wagtailmetadata_tags %}
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="{{ django_settings.LANGUAGE_CODE }}">
|
||||
|
@ -11,6 +11,8 @@
|
|||
<meta name="superfish" content="nofish" />
|
||||
<meta name="application-name" content="{{ django_settings.WAGTAIL_SITE_NAME }}" />
|
||||
|
||||
{% meta_tags %}
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="{% static 'css/index.css' %}">
|
||||
|
||||
{% block extra_css %}{% endblock %}
|
||||
|
|
1
templates/blocks/heading.html
Normal file
1
templates/blocks/heading.html
Normal file
|
@ -0,0 +1 @@
|
|||
<{{ value.size }}>{{ value.value }}</{{ value.size }}>
|
9
templates/blocks/video.html
Normal file
9
templates/blocks/video.html
Normal file
|
@ -0,0 +1,9 @@
|
|||
{% load wagtailcore_tags %}
|
||||
|
||||
{% include_block value.video %}
|
||||
|
||||
{% if value.caption %}
|
||||
<span>
|
||||
{% include_block value.caption %}
|
||||
</span>
|
||||
{% endif %}
|
1
templates/wagtailembeds/embed_frontend.html
Normal file
1
templates/wagtailembeds/embed_frontend.html
Normal file
|
@ -0,0 +1 @@
|
|||
{{ embed.html|safe }}
|
Reference in a new issue