From: Mart Lubbers Date: Thu, 25 Sep 2014 11:07:39 +0000 (+0200) Subject: edit mode added X-Git-Url: https://git.martlubbers.net/?a=commitdiff_plain;h=92efec367f37fd85846e24a639978f84d402021c;p=bsc-thesis1415.git edit mode added --- diff --git a/program/everything/crawler.py b/program/everything/crawler.py index 52c3f2c..7d164cb 100644 --- a/program/everything/crawler.py +++ b/program/everything/crawler.py @@ -47,8 +47,8 @@ class Crawler(): def list_names(self): return self.entries.keys() - def add_entry(self, d): - if d['name'] in self.entries: + def add_entry(self, d, force=False): + if d['name'] in self.entries and not force: raise Exception('That name is already present') else: self.entries[d['name']] = d diff --git a/program/everything/index.py b/program/everything/index.py index 8254614..62bb377 100644 --- a/program/everything/index.py +++ b/program/everything/index.py @@ -45,17 +45,20 @@ def crawler_edit(req, args, apok): cr = crawler.Crawler() with open('/var/www/py/new.html.t', 'r') as f: data = f.read() + html_feed = '' + html_feed += '' + for i in cr.entries[args['name']]['content']: + html_feed += ('').format( + i[0].decode('utf-8').encode('ascii', 'xmlcharrefreplace'), + i[1].decode('utf-8').encode('ascii', 'xmlcharrefreplace')) params = { 'rssname': args['name'], 'url': cr.entries[args['name']]['url'], 'input_data': input_data(cr.entries[args['name']]), - 'feed_html': str(cr.entries[args['name']]['content'])} + 'feed_html': html_feed + } req.write(data.format(**params)) - # req.write('
TitleSummary
{}{}
') - # req.write(''.join( - # ''.format(a[0], a[1]) - # for a in cr.entries[args['name']]['content'])) - # req.write('
{}{}
') else: req.write('Unknown editing action: {}'.format(args['action'])) req.write('
Go back') @@ -105,15 +108,18 @@ def input_data(dictio): return ( '\t\tVenue: \n' - '\t\t\t\n' + '\t\t\t\n' '\t\tFrequency: \n' '\t\t\t\n' '\t\tDefault location name: \n' '\t\t\t\n' '\t\tAdress: \n' - '\t\t\t\n' + '\t\t\t\n' '\t\tWebsite: \n' - '\t\t\t\n' + '\t\t\t\n' '\t\tRSS URL: \n' '\t\t\t\n' '\t\t').format(**basicdict)