Custom news page
This commit is contained in:
parent
b536af96ab
commit
118603a760
2 changed files with 62 additions and 0 deletions
|
@ -13,6 +13,8 @@ from wagtail.wagtailimages.blocks import ImageChooserBlock
|
|||
from wagtail.wagtailimages.edit_handlers import ImageChooserPanel
|
||||
from wagtail.wagtailsearch import index
|
||||
|
||||
from puput.models import EntryPage, BlogPage
|
||||
|
||||
from .util import TranslatedField
|
||||
|
||||
class ArticleIndexPage(Page):
|
||||
|
@ -123,6 +125,15 @@ class ArticleRelatedLink(Orderable):
|
|||
FieldPanel('url'),
|
||||
]
|
||||
|
||||
class NewsEntryPage(EntryPage):
|
||||
video_url = models.URLField()
|
||||
content_panels = EntryPage.content_panels + [
|
||||
FieldPanel('video_url')
|
||||
]
|
||||
class Meta:
|
||||
verbose_name = "News"
|
||||
BlogPage.subpage_types = NewsEntryPage
|
||||
|
||||
class InfoBlock(blocks.StructBlock):
|
||||
title = blocks.CharBlock(required=True)
|
||||
photo = ImageChooserBlock()
|
||||
|
|
51
publichealth/home/templates/home/news_page.html
Normal file
51
publichealth/home/templates/home/news_page.html
Normal file
|
@ -0,0 +1,51 @@
|
|||
{% extends "base.html" %}
|
||||
{% load wagtailcore_tags wagtailimages_tags puput_tags %}
|
||||
|
||||
{% block body_class %}template-{{ self.get_verbose_name|slugify }}{% endblock %}
|
||||
|
||||
{% block title %}{{ self.title }} | {{ blog_page.title }}{% endblock title %}
|
||||
{% block meta_title %}{% if self.seo_title %}{{ self.seo_title }}{% else %}{{ self.title }}{% endif %}{% endblock meta_title %}
|
||||
{% block meta_description %}{% if self.search_description %}{{ self.search_description }}{% else %}{{ self.body|striptags|truncatewords:20 }}{% endif %}{% endblock meta_description %}
|
||||
{% block canonical %}{% canonical_url entry=self %}{% endblock canonical %}
|
||||
{% block social_share %}
|
||||
{% image self.header_image fill-800x450 as share_image %}
|
||||
<meta property="og:title" content="{{ self.title }}" />
|
||||
<meta property="og:description" content="{% if self.excerpt %}{{ self.excerpt|striptags }}{% else %}{{ self.body|striptags|truncatewords:20 }}{% endif %}" />
|
||||
<meta property="og:url" content="{% canonical_url entry=self %}" />
|
||||
{% if self.header_image %}
|
||||
<meta property="og:image" content="{% image_url share_image.url %}" />
|
||||
<meta property="og:image:width" content="800" />
|
||||
<meta property="og:image:height" content="450" />
|
||||
<meta name="twitter:image" content="{% image_url share_image.url %}" />
|
||||
{% endif %}
|
||||
<meta name="twitter:card" content="summary_large_image" />
|
||||
<meta name="twitter:title" content="{{ self.title }}" />
|
||||
<meta name="twitter:description" content="{% if self.excerpt %}{{ self.excerpt|striptags }}{% else %}{{ self.body|striptags|truncatewords:20 }}{% endif %}" />
|
||||
{% endblock social_share %}
|
||||
|
||||
{% block content %}
|
||||
<div class="container">
|
||||
<article class="box page-content"
|
||||
{%if self.id %}data-entry-page-update-comments-url="{% url 'entry_page_update_comments' self.id %}{% endif %}">
|
||||
{% include 'puput/entry_page_header.html' with entry=self %}
|
||||
{% if self.header_image %}
|
||||
<section>
|
||||
<span class="image featured">
|
||||
{% image self.header_image fill-800x450 as header_image %}
|
||||
<img alt="{{ self.header_image.title }}" src="{{ header_image.url }}">
|
||||
</span>
|
||||
</section>
|
||||
{% endif %}
|
||||
<section>
|
||||
{{ self.body|richtext}}
|
||||
</section>
|
||||
{% show_comments %}
|
||||
</article>
|
||||
</div>
|
||||
{% endblock content %}
|
||||
|
||||
{% block extra_content %}
|
||||
{% if self.has_related %}
|
||||
{% include 'puput/related_entries.html' with entry=self %}
|
||||
{% endif %}
|
||||
{% endblock extra_content %}
|
Loading…
Reference in a new issue