From 8feadf5087ddf14fcca4232f85c246044caa8c89 Mon Sep 17 00:00:00 2001 From: Mart Lubbers Date: Mon, 5 May 2014 15:45:22 +0200 Subject: [PATCH] working thing --- program/hypfront/hyper.py | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/program/hypfront/hyper.py b/program/hypfront/hyper.py index 4405580..e773f86 100644 --- a/program/hypfront/hyper.py +++ b/program/hypfront/hyper.py @@ -2,8 +2,9 @@ # -*- coding: utf-8 -*- import feedparser -import HTMLParser -import feed2html +import urllib +import pprint +import re from mod_python import apache @@ -11,7 +12,8 @@ def req_pre(req): req.log_error('handler') req.content_type = 'text/html' req.send_http_header() - req.write(""" + req.write("""\ + HyperFrontend RSS feed input @@ -20,12 +22,27 @@ def req_pre(req): def req_post(req): - req.write(""" + req.write("""\ """) +def feed2html(req, url, name): + url = urllib.unquote(url) + url = url if re.match('https?://', url) else 'http://{}'.format(url) + req.write('\tLoading "{}" as "{}"
\n'.format(url, name)) + feed = feedparser.parse(url) + channel = feed.feed + req.write('\t\n') + req.write('\t\t\n') + for i in feed.entries: + req.write('\t\t\n'. + format(i['title'].encode('ascii', 'xmlcharrefreplace'))) + + req.write('\t
Title...
{}...
\n') + + def handler(req): req_pre(req) args = dict(filter(lambda x: x[1], @@ -35,6 +52,6 @@ def handler(req): req.write('Something went wrong, empty fields?
') req.write('back') else: - req.write(str(args)) + feed2html(req, args['url'], args['name']) req_post(req) return apache.OK -- 2.20.1