diff --git a/.isort.cfg b/.isort.cfg index eb80b51e45c418feda298120198438578b6cd6ff..7fe5b8ee9826724dc124cca258dc1efab3a5b268 100644 --- a/.isort.cfg +++ b/.isort.cfg @@ -4,4 +4,4 @@ line_length = 88 multi_line_output = 3 default_sectiont = "THIRDPARTY" include_trailing_comma = true -known_third_party = arrow,django,environ,faker,ics,modelcluster,nbconvert,pirates,pytest,pytz,requests,sentry_sdk,snapshottest,taggit,traitlets,wagtail,wagtailmetadata +known_third_party = arrow,django,environ,faker,ics,markdown,modelcluster,nbconvert,pirates,pytest,pytz,requests,sentry_sdk,snapshottest,taggit,traitlets,wagtail,wagtailmetadata diff --git a/district/templates/shared/article.html b/district/templates/shared/article.html new file mode 100644 index 0000000000000000000000000000000000000000..d3a0e74929cbe65d84d4c615fdfc60262fee5cee --- /dev/null +++ b/district/templates/shared/article.html @@ -0,0 +1,83 @@ +{% extends "district/base.html" %} +{% load wagtailcore_tags wagtailimages_tags shared_filters %} + +{% block content %} + +<div class="container container--default py-8 lg:py-24"> + + <article itemtype="http://schema.org/BlogPosting" itemscope=""> + + <header> + <link itemprop="mainEntityOfPage" href="{{ page.url }}"> + <meta itemprop="datePublished" content="{{ page.last_published_at }}"> + <meta itemprop="dateModified" content=""> + + <h1 itemprop="headline" class="head-alt-md md:head-alt-lg max-w-5xl mb-4">{{ page.title }}</h1> + + <div class="flex flex-col md:flex-row md:items-center"> + + <div class="inline-flex divide-x flex-grow"> + <span class="pr-2">{{ page.last_published_at|date:"SHORT_DATE_FORMAT" }}</span> + <span class="pl-2" itemprop="author" itemtype="http://schema.org/Person" itemscope=""> + <span itemprop="name"> + <a href="#">{{ page.author }}</a> + </span> + </span> + </div> + + <div class="my-4"> + {% for tag in page.tags.all %} + <a href="/tags/#{{ tag}}" class="btn btn--grey-125 btn--condensed" ><div class="btn__body ">{{ tag }}</div></a> + {% endfor %} + </div> + + </div> + + <figure class="figure"> + {% image page.image width-2000 as img %} + <img src="{{ img.url }}" alt="{{ page.title }}" /> + </figure> + + </header> + + <div class="lg:flex mt-8 lg:space-x-16"> + + <div class="lg:w-2/3"> + <div itemprop="description" class="w-full content-block"> + <p><strong>{{ page.perex }}</strong></p> + {{ page.text|markdown }} + </div> + </div> + + <div class="pt-8 lg:w-1/3 md:pt-0"> + <div class="space-y-8"> + <div class="sharebox md:card md:elevation-10 "> + <div class="md:card__body"> + <span class="head-alt-base md:head-alt-md">Sdílení je aktem lásky</span> + <div class="flex w-full space-x-4 pt-4 md:pt-8 text-center text-white"> + <a + href="https://www.facebook.com/sharer/sharer.php?u={{ page.url }}" + onclick="window.open(this.href, 'pop-up', 'left=20,top=20,width=500,height=500,toolbar=1,resizable=0'); return false;" + class="bg-brands-facebook px-8 py-3 text-2xl w-full" + ><i class="ico--facebook"></i></a> + <a + href="https://twitter.com/intent/tweet?text={{ page.title }}&url={{ page.url }}" + onclick="window.open(this.href, 'pop-up', 'left=20,top=20,width=500,height=500,toolbar=1,resizable=0'); return false;" + class="bg-brands-twitter px-8 py-3 text-2xl w-full" + ><i class="ico--twitter"></i></a> + </div> + </div> + <div class="h-52 overflow-hidden hidden md:block"> + <img src="https://styleguide.pir-test.eu/latest//images/flag.png" alt="Pirátská strana" class="w-80 object-cover m-auto" /> + </div> + </div> + + </div> + </div> + + </div> + </article> + +</div> + +{% endblock %} diff --git a/requirements/base.in b/requirements/base.in index c106afce04f1470d569cfbc3d35b708768b26c1b..03f31a2c797712722fc137235ce4d21d90d94226 100644 --- a/requirements/base.in +++ b/requirements/base.in @@ -14,3 +14,4 @@ arrow sentry-sdk nbconvert traitlets +Markdown diff --git a/shared/models.py b/shared/models.py index 5b2e5b9cbc279dbf3e90d82f71825bba714acab2..4239110ad29e6d10926eb2fc3969e516dea43660 100644 --- a/shared/models.py +++ b/shared/models.py @@ -2,7 +2,7 @@ from django.db import models from modelcluster.contrib.taggit import ClusterTaggableManager from modelcluster.fields import ParentalKey from taggit.models import TaggedItemBase -from wagtail.admin.edit_handlers import FieldPanel +from wagtail.admin.edit_handlers import FieldPanel, HelpPanel from wagtail.core.models import Page from wagtail.images.edit_handlers import ImageChooserPanel from wagtailmetadata.models import MetadataPageMixin @@ -34,6 +34,9 @@ class Article(MetadataPageMixin, Page): content_panels = Page.content_panels + [ FieldPanel("perex"), FieldPanel("text"), + HelpPanel( + """Text článku lze formátovat s použitím <a href="https://www.markdownguide.org/basic-syntax/">markdown</a>""" + ), FieldPanel("author"), ImageChooserPanel("image"), FieldPanel("tags"), diff --git a/shared/templatetags/__init__.py b/shared/templatetags/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/shared/templatetags/shared_filters.py b/shared/templatetags/shared_filters.py new file mode 100644 index 0000000000000000000000000000000000000000..94a59b897384d709e72ab30b2655f13ef390c016 --- /dev/null +++ b/shared/templatetags/shared_filters.py @@ -0,0 +1,11 @@ +import markdown as md +from django import template +from django.utils.safestring import mark_safe + +register = template.Library() + + +@register.filter +def markdown(value): + """ Prekonvertuje vstupni text na markdown, necekane """ + return mark_safe(md.markdown(value))