diff --git a/feedler/feedparser.py b/feedler/feedparser.py index ed83a1f..bc39f98 100644 --- a/feedler/feedparser.py +++ b/feedler/feedparser.py @@ -12,7 +12,7 @@ def parse(obj, raw, stream): # Date stamp handling ts = raw['published'] / 1000 - obj.published = datetime.utcfromtimestamp(ts) + obj.published = datetime.fromtimestamp(ts) # Authorship and title obj.title = raw['title'] @@ -32,6 +32,8 @@ def parse(obj, raw, stream): obj.visual = raw['enclosure'][0]['href'] elif 'visual' in raw and 'url' in raw['visual']: obj.visual = raw['visual']['url'] + if obj.visual.lower().strip() == 'none': + obj.visual = '' # Collect text in nested JSON content if 'content' in obj.raw: diff --git a/feedler/models/admin.py b/feedler/models/admin.py index 43c0298..604b92f 100644 --- a/feedler/models/admin.py +++ b/feedler/models/admin.py @@ -12,6 +12,7 @@ from django.core.mail import send_mail from wagtail.contrib.settings.models import BaseSetting, register_setting from .models import Entry, Stream +import feedler.feedparser as feedparser import logging logger = logging.getLogger('feedler') @@ -60,5 +61,5 @@ def handle_save_settings(sender, instance, *args, **kwargs): except Entry.DoesNotExist: logger.info("Adding entry '%s'" % eid) entry = Entry() - entry.parse(raw_entry, stream) + entry = feedparser.parse(entry, raw_entry, stream) entry.save() diff --git a/feedler/models/models.py b/feedler/models/models.py index bb256f9..8777e58 100644 --- a/feedler/models/models.py +++ b/feedler/models/models.py @@ -6,8 +6,6 @@ from wagtail.wagtailcore.models import Page, Orderable from wagtail.wagtailadmin.edit_handlers import FieldPanel from wagtail.wagtailcore.fields import RichTextField -import feedler.feedparser as feedparser - class Stream(models.Model): title = models.CharField(max_length=255) ident = models.CharField(max_length=255) @@ -38,10 +36,6 @@ class Entry(models.Model): class Meta: verbose_name_plural = 'Entries' - def parse(self, raw, stream): - # TODO: Exception handling - feedparser.parse(self, raw, stream) - class FeedPage(Page): intro = RichTextField(default='', blank=True) stream = models.ForeignKey(Stream, on_delete=models.PROTECT, diff --git a/feedler/templates/feedler/feed_page.html b/feedler/templates/feedler/feed_page.html index 392be5c..df5c33e 100644 --- a/feedler/templates/feedler/feed_page.html +++ b/feedler/templates/feedler/feed_page.html @@ -13,7 +13,9 @@

{{ page.title }}

-

{{ page.intro|richtext }}

+ {% if page.intro %} +

{{ page.intro|richtext }}

+ {% endif %}
@@ -23,15 +25,17 @@
{% for entry in feedentries %}
+ {% if entry.visual %}
- {% if entry.visual %} - - {% endif %} + + {% else %} +
+ {% endif %}
-

{{ entry.title }}

+

{{ entry.title|striptags|truncatewords_html:10 }}

- {{ entry.content|striptags|truncatewords_html:40 }} -
{{ entry.author }} + {{ entry.author }}

+ {{ entry.content|striptags|truncatewords_html:25 }}

diff --git a/publichealth/static/css/modules/_news.scss b/publichealth/static/css/modules/_news.scss index ea71ef4..b3edf6a 100644 --- a/publichealth/static/css/modules/_news.scss +++ b/publichealth/static/css/modules/_news.scss @@ -2,21 +2,13 @@ // News overview #news { - .panel-default { + .panel-default, .panel-fulltext { font-size: 90%; padding-top: 75%; /* 1:1 Aspect Ratio */ position: relative; /* If you want text inside of it */ overflow: hidden; background: lighten($brand-primary, 10%); - img { - position: absolute; - top: 0; - left: 0; - width: 100%; - height: 100%; - } - .panel-body { position: absolute; top: 0; @@ -24,10 +16,7 @@ width: 100%; height: 100%; padding: 0; - transform: translateY(60%); background-color: rgba($brand-primary, .8); - transition: transform .65s; - h3, p { color: white; } @@ -58,9 +47,6 @@ text-align: center; } } - &:hover .panel-body { - transform: rotateY(0); - } // expand link over the thumbnail a.fill { @@ -72,6 +58,23 @@ font-size: 0; } } + + .panel-default { + img { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: auto; + } + .panel-body { + transform: translateY(60%); + transition: transform .65s; + } + &:hover .panel-body { + transform: rotateY(0); + } + } } // News detail article