From 6e216c0c150595f0be23fe0af6ef1d9b87b09eea Mon Sep 17 00:00:00 2001 From: Kyle Mahan Date: Sat, 31 Jan 2015 16:35:47 +0000 Subject: [PATCH] support for Atom feeds with updated but not published timestamp --- LICENSE | 28 ++++++++++++++++++++++++++++ README.md | 6 ++++++ woodwind/models.py | 3 ++- woodwind/tasks.py | 17 +++++++++++------ woodwind/templates/feed.jinja2 | 4 ++-- 5 files changed, 49 insertions(+), 9 deletions(-) create mode 100644 LICENSE create mode 100644 README.md diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..e34b4d0 --- /dev/null +++ b/LICENSE @@ -0,0 +1,28 @@ +Simplifed BSD License + +Copyright (c) 2015, Kyle Mahan +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the + distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..9236acb --- /dev/null +++ b/README.md @@ -0,0 +1,6 @@ +Woodwind +======== + +A minimum viable stream-style feed reader. + +Supports mf2 h-feed and xml feeds (thanks to Universal Feed Parser). diff --git a/woodwind/models.py b/woodwind/models.py index 99f492f..3abef97 100644 --- a/woodwind/models.py +++ b/woodwind/models.py @@ -3,11 +3,12 @@ from .extensions import db bleach.ALLOWED_TAGS += ['a', 'img', 'p', 'br', 'marquee', 'blink', - 'audio', 'video'] + 'audio', 'video', 'table', 'tbody', 'td', 'tr'] bleach.ALLOWED_ATTRIBUTES.update({ 'img': ['src', 'alt', 'title'], 'audio': ['preload', 'controls', 'src'], 'video': ['preload', 'controls', 'src'], + 'td': ['colspan'], }) diff --git a/woodwind/tasks.py b/woodwind/tasks.py index 032e897..d23cf30 100644 --- a/woodwind/tasks.py +++ b/woodwind/tasks.py @@ -104,12 +104,17 @@ def process_xml_feed_for_new_entries(session, feed): if not uid or uid in preexisting: continue - updated = datetime.datetime.fromtimestamp( - time.mktime(p_entry.updated_parsed) - ) if 'updated_parsed' in p_entry else None - published = datetime.datetime.fromtimestamp( - time.mktime(p_entry.published_parsed) - ) if 'published_parsed' in p_entry else now + if 'updated_parsed' in p_entry: + updated = datetime.datetime.fromtimestamp( + time.mktime(p_entry.updated_parsed)) + else: + updated = None + + if 'published_parsed' in p_entry: + published = datetime.datetime.fromtimestamp( + time.mktime(p_entry.published_parsed)) + else: + published = updated or now title = p_entry.get('title') diff --git a/woodwind/templates/feed.jinja2 b/woodwind/templates/feed.jinja2 index d8b982a..005c99e 100644 --- a/woodwind/templates/feed.jinja2 +++ b/woodwind/templates/feed.jinja2 @@ -62,14 +62,14 @@ $(attachListeners);