def preview(): # TODO: maybe unify with entries() somehow url = request.args['url'] # TODO: maybe redirect to the feed we have if we already have it # TODO: maybe cache stuff reader = current_app.config['READER_CONFIG'].make_reader( 'default', url=':memory:', plugin_loader=current_app.plugin_loader ) reader.add_feed(url) try: reader.update_feed(url) except ParseError as e: # give plugins a chance to intercept this got_preview_parse_error.send(e) # https://github.com/lemon24/reader/issues/172 # no plugin intercepted the response, so we show the feed; # feed.last_exception will be checked in the template, # and if there was a ParseError, it will be shown feed = reader.get_feed(url) entries = list(reader.get_entries()) # TODO: maybe limit return stream_template('entries.html', entries=entries, feed=feed, read_only=True)
def add(kwargs, url, update, verbose): """Add a new feed.""" setup_logging(verbose) reader = make_reader_with_plugins(**kwargs) reader.add_feed(url) if update: reader.update_feed(url)
def add(reader, url, update): """Add a new feed.""" reader.add_feed(url) if update: reader.update_feed(url)