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 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.wagtailcore.models import Page
|
||||||
from wagtail.wagtailadmin.edit_handlers import FieldPanel, StreamFieldPanel
|
from wagtail.wagtailadmin.edit_handlers import FieldPanel, StreamFieldPanel
|
||||||
from wagtail.wagtailimages.edit_handlers import ImageChooserPanel
|
from wagtail.wagtailimages.edit_handlers import ImageChooserPanel
|
||||||
|
|
|
@ -3,19 +3,35 @@ from wagtail.wagtailcore import blocks
|
||||||
from wagtail.wagtailimages.blocks import ImageChooserBlock
|
from wagtail.wagtailimages.blocks import ImageChooserBlock
|
||||||
from wagtail.wagtaildocs.blocks import DocumentChooserBlock
|
from wagtail.wagtaildocs.blocks import DocumentChooserBlock
|
||||||
from wagtailmarkdown.blocks import MarkdownBlock
|
from wagtailmarkdown.blocks import MarkdownBlock
|
||||||
|
from wagtail.wagtailembeds.blocks import EmbedBlock
|
||||||
|
|
||||||
|
|
||||||
def build_header_fields():
|
HEADING_CHOICES = [('h' + str(i), 'H' + str(i)) for i in range(1, 6)]
|
||||||
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"))
|
|
||||||
|
|
||||||
|
|
||||||
def build_fixed_fields():
|
class HeadingBlock(blocks.StructBlock):
|
||||||
return [
|
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")),
|
('ansi', blocks.TextBlock(template="blocks/ansi.html")),
|
||||||
('document', DocumentChooserBlock()),
|
('document', DocumentChooserBlock()),
|
||||||
('gist', blocks.CharBlock(icon="code", template="blocks/gist.html")),
|
('gist', blocks.CharBlock(icon="code", template="blocks/gist.html")),
|
||||||
|
('heading', HeadingBlock()),
|
||||||
('image', ImageChooserBlock()),
|
('image', ImageChooserBlock()),
|
||||||
('markdown', MarkdownBlock()),
|
('markdown', MarkdownBlock()),
|
||||||
('ol', blocks.ListBlock(blocks.CharBlock(label="List Item"), icon="list-ol", label="Ordered List", template='blocks/ordered-list.html')),
|
('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")),
|
('raw_html', blocks.RawHTMLBlock(label="Raw HTML")),
|
||||||
('secret', blocks.RichTextBlock(icon="password", template='blocks/secret.html')),
|
('secret', blocks.RichTextBlock(icon="password", template='blocks/secret.html')),
|
||||||
('ul', blocks.ListBlock(blocks.CharBlock(label="List Item"), icon="list-ul", label="Unordered List")),
|
('ul', blocks.ListBlock(blocks.CharBlock(label="List Item"), icon="list-ul", label="Unordered List")),
|
||||||
]
|
('video', VideoBlock())
|
||||||
|
])
|
||||||
|
|
||||||
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)
|
|
|
@ -1,8 +1,9 @@
|
||||||
from wagtail.wagtailcore.models import Page
|
from wagtail.wagtailcore.models import Page
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
from wagtailmetadata.models import MetadataPageMixin
|
||||||
|
|
||||||
|
|
||||||
class Entity(Page):
|
class Entity(MetadataPageMixin, Page):
|
||||||
is_home = False
|
is_home = False
|
||||||
|
|
||||||
created = models.DateTimeField(auto_now_add=True)
|
created = models.DateTimeField(auto_now_add=True)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
from django.db import models
|
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 project.common.models import Entity
|
||||||
from wagtail.wagtailcore.models import Page
|
from wagtail.wagtailcore.models import Page
|
||||||
from wagtail.wagtailcore.fields import RichTextField
|
from wagtail.wagtailcore.fields import RichTextField
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.core.exceptions import ValidationError
|
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.wagtailcore.models import Page
|
||||||
from wagtail.wagtaildocs.edit_handlers import DocumentChooserPanel
|
from wagtail.wagtaildocs.edit_handlers import DocumentChooserPanel
|
||||||
from wagtail.wagtailadmin.edit_handlers import FieldPanel, StreamFieldPanel
|
from wagtail.wagtailadmin.edit_handlers import FieldPanel, StreamFieldPanel
|
||||||
|
|
|
@ -41,6 +41,8 @@ INSTALLED_APPS = [
|
||||||
'django.contrib.messages',
|
'django.contrib.messages',
|
||||||
'django.contrib.staticfiles',
|
'django.contrib.staticfiles',
|
||||||
|
|
||||||
|
'wagtailmetadata',
|
||||||
|
|
||||||
'project.blog',
|
'project.blog',
|
||||||
'project.common',
|
'project.common',
|
||||||
'project.home',
|
'project.home',
|
||||||
|
@ -79,7 +81,7 @@ MIDDLEWARE = [
|
||||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||||
|
|
||||||
'wagtail.wagtailcore.middleware.SiteMiddleware',
|
'wagtail.wagtailcore.middleware.SiteMiddleware',
|
||||||
'wagtail.wagtailredirects.middleware.RedirectMiddleware',
|
'wagtail.wagtailredirects.middleware.RedirectMiddleware'
|
||||||
]
|
]
|
||||||
|
|
||||||
ROOT_URLCONF = 'project.urls'
|
ROOT_URLCONF = 'project.urls'
|
||||||
|
@ -163,3 +165,15 @@ WAGTAILSEARCH_BACKENDS = {
|
||||||
# e.g. in notification emails. Don't include '/admin' or a trailing slash
|
# e.g. in notification emails. Don't include '/admin' or a trailing slash
|
||||||
BASE_URL = 'https://theorangeone.net'
|
BASE_URL = 'https://theorangeone.net'
|
||||||
SITE_URL = BASE_URL
|
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
|
pygments-style-github==0.4
|
||||||
safety==0.5.1
|
safety==0.5.1
|
||||||
wagtail>=1.7,<1.8
|
wagtail>=1.7,<1.8
|
||||||
|
wagtail-metadata==0.3.0
|
||||||
git+https://github.com/RealOrangeOne/wagtail-markdown
|
git+https://github.com/RealOrangeOne/wagtail-markdown
|
||||||
waitress==1.0.1
|
waitress==1.0.1
|
||||||
whitenoise==3.2.2
|
whitenoise==3.2.2
|
||||||
|
|
|
@ -5,3 +5,14 @@
|
||||||
max-height: 100vh;
|
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>
|
<!DOCTYPE html>
|
||||||
<html lang="{{ django_settings.LANGUAGE_CODE }}">
|
<html lang="{{ django_settings.LANGUAGE_CODE }}">
|
||||||
|
@ -11,6 +11,8 @@
|
||||||
<meta name="superfish" content="nofish" />
|
<meta name="superfish" content="nofish" />
|
||||||
<meta name="application-name" content="{{ django_settings.WAGTAIL_SITE_NAME }}" />
|
<meta name="application-name" content="{{ django_settings.WAGTAIL_SITE_NAME }}" />
|
||||||
|
|
||||||
|
{% meta_tags %}
|
||||||
|
|
||||||
<link rel="stylesheet" type="text/css" href="{% static 'css/index.css' %}">
|
<link rel="stylesheet" type="text/css" href="{% static 'css/index.css' %}">
|
||||||
|
|
||||||
{% block extra_css %}{% endblock %}
|
{% 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