Add :callback for JSONP calls

master
pictuga 2014-06-28 00:59:57 +02:00
parent 226441d821
commit 484432d804
2 changed files with 4 additions and 1 deletions

View File

@ -50,6 +50,7 @@ The arguments are:
- `theforce`: force download the rss feed - `theforce`: force download the rss feed
- `silent`: don't output the final RSS (useless on its own, but can be nice when debugging) - `silent`: don't output the final RSS (useless on its own, but can be nice when debugging)
- http server only - http server only
- `callback=NAME`: for JSONP calls
- `cors`: allow Cross-origin resource sharing (allows XHR calls from other servers) - `cors`: allow Cross-origin resource sharing (allows XHR calls from other servers)
- `html`: changes the http content-type to html, so that python cgi erros (written in html) are readable in a web browser - `html`: changes the http content-type to html, so that python cgi erros (written in html) are readable in a web browser
- `txt`: changes the http content-type to txt (for faster "`view-source:`") - `txt`: changes the http content-type to txt (for faster "`view-source:`")

View File

@ -693,7 +693,9 @@ def After(rss, options):
if item.content: if item.content:
item.content = conv.handle(item.content) item.content = conv.handle(item.content)
if options.json: if re.match(r'^[a-zA-Z0-9\.]+$', options.callback) is not None:
return '%s(%s)' % (options.callback, rss.tojson())
elif options.json:
if options.indent: if options.indent:
return rss.tojson(indent=4) return rss.tojson(indent=4)
else: else: