diff --git a/woodwind/models.py b/woodwind/models.py index fa49b67..99f492f 100644 --- a/woodwind/models.py +++ b/woodwind/models.py @@ -2,9 +2,12 @@ import bleach from .extensions import db -bleach.ALLOWED_TAGS += ['a', 'img', 'p', 'br', 'marquee', 'blink'] +bleach.ALLOWED_TAGS += ['a', 'img', 'p', 'br', 'marquee', 'blink', + 'audio', 'video'] bleach.ALLOWED_ATTRIBUTES.update({ - 'img': ['src', 'alt', 'title'] + 'img': ['src', 'alt', 'title'], + 'audio': ['preload', 'controls', 'src'], + 'video': ['preload', 'controls', 'src'], }) diff --git a/woodwind/views.py b/woodwind/views.py index 227d251..f35509b 100644 --- a/woodwind/views.py +++ b/woodwind/views.py @@ -171,15 +171,22 @@ def find_possible_feeds(origin): resp = requests.get(origin) feeds = [] + xml_feed_types = [ 'application/rss+xml', 'application/atom+xml', 'application/rdf+xml', + 'application/xml', + ] + xml_mime_types = xml_feed_types + [ + 'text/xml', + 'text/rss+xml', + 'text/atom+xml', ] content_type = resp.headers['content-type'] content_type = content_type.split(';', 1)[0].strip() - if content_type in xml_feed_types: + if content_type in xml_mime_types: feeds.append({ 'origin': origin, 'feed': origin, @@ -191,15 +198,19 @@ def find_possible_feeds(origin): soup = bs4.BeautifulSoup(resp.text) for link in soup.find_all('link', {'rel': 'alternate'}): if link.get('type') in xml_feed_types: + feed_url = urllib.parse.urljoin(origin, link.get('href')) feeds.append({ 'origin': origin, - 'feed': link.get('href'), + 'feed': feed_url, 'type': 'xml', }) - feeds.append({ - 'origin': origin, - 'feed': origin, - 'type': 'html', - }) + + hfeed = mf2util.interpret_feed(mf2py.parse(doc=resp.text), origin) + if hfeed.get('entries'): + feeds.append({ + 'origin': origin, + 'feed': origin, + 'type': 'html', + }) return feeds