Merge lp:~vhata/ibid/feeds-747635 into lp:ibid

Proposed by Stefano Rivera
Status: Merged
Approved by: Stefano Rivera
Approved revision: 1029
Merged at revision: 1038
Proposed branch: lp:~vhata/ibid/feeds-747635
Merge into: lp:ibid
Diff against target: 72 lines (+32/-9)
1 file modified
ibid/plugins/feeds.py (+32/-9)
To merge this branch: bzr merge lp:~vhata/ibid/feeds-747635
Reviewer Review Type Date Requested Status
Keegan Carruthers-Smith Approve
Stefano Rivera Approve
Max Rabkin Pending
Jonathan Hitchcock Pending
Review via email: mp+80198@code.launchpad.net

This proposal supersedes a proposal from 2011-10-24.

Commit message

Make feeds syntax more intuitive/responsive.

Description of the change

Adds the ability to specify 'headlines' or 'articles' when fetching a bunch (and fixes the syntax so that if you just say 'latest article' it only fetches one).

To post a comment you must log in.
Revision history for this message
Max Rabkin (max-rabkin) : Posted in a previous version of this proposal
review: Approve
Revision history for this message
Stefano Rivera (stefanor) wrote : Posted in a previous version of this proposal

We don't use "starting at" any where else, we use "from" or "#".

Should we not standardise a bit?

Otherwise I quite like it. My initial response was that this should have been fixed by changing article(), but this does seem more user-friendly.

review: Needs Fixing
Revision history for this message
Jonathan Hitchcock (vhata) wrote : Posted in a previous version of this proposal

This syntax already has "from" in it - "latest articles from bbc from 3" is weird. Also, that's not how people speak, whether the other ibid plugins think so or not.

review: Needs Resubmitting
Revision history for this message
Stefano Rivera (stefanor) wrote :

ok, successfully convinced me.

review: Approve
Revision history for this message
Keegan Carruthers-Smith (keegan-csmith) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'ibid/plugins/feeds.py'
--- ibid/plugins/feeds.py 2010-11-07 15:10:58 +0000
+++ ibid/plugins/feeds.py 2011-10-24 11:29:27 +0000
@@ -225,7 +225,7 @@
225broken_lock = Lock()225broken_lock = Lock()
226226
227class Retrieve(Processor):227class Retrieve(Processor):
228 usage = u"""latest [ <count> ] articles from <name> [ starting at <number> ]228 usage = u"""latest [ <count> ] ( articles | headlines ) from <name> [ starting at <number> ]
229 article ( <number> | /<pattern>/ ) from <name>"""229 article ( <number> | /<pattern>/ ) from <name>"""
230 features = ('feeds',)230 features = ('feeds',)
231231
@@ -236,10 +236,16 @@
236 'The slowdown ratio to back off from broken feeds', 2.0)236 'The slowdown ratio to back off from broken feeds', 2.0)
237237
238238
239 @match(r'^(?:latest|last)\s+(?:(\d+)\s+)?articles\s+from\s+(.+?)'239 @match(r'^(?:latest|last)\s+(?:(\d+)\s+)?(article|headline)(s)?\s+from\s+(.+?)'
240 r'(?:\s+start(?:ing)?\s+(?:at\s+|from\s+)?(\d+))?$')240 r'(?:\s+start(?:ing)?\s+(?:at\s+|from\s+)?(\d+))?$')
241 def list(self, event, number, name, start):241 def list(self, event, number, full, plurality, name, start):
242 number = number and int(number) or 10242 full = full == 'article'
243 if number:
244 number = int(number)
245 elif not plurality:
246 number = 1
247 else:
248 number = 10
243 start = start and int(start) or 0249 start = start and int(start) or 0
244250
245 feed = event.session.query(Feed).filter_by(name=name).first()251 feed = event.session.query(Feed).filter_by(name=name).first()
@@ -254,10 +260,27 @@
254 return260 return
255261
256 articles = feed.entries[start:number+start]262 articles = feed.entries[start:number+start]
257 articles = [u'%s: "%s"' % (feed.entries.index(entry) + 1,263 entries = []
258 html2text_file(entry.title, None).strip())264 for article in articles:
259 for entry in articles]265 if full:
260 event.addresponse(u', '.join(articles))266 if 'summary' in article:
267 summary = html2text_file(article.summary, None)
268 else:
269 if article.content[0].type in \
270 ('application/xhtml+xml', 'text/html'):
271 summary = html2text_file(article.content[0].value, None)
272 else:
273 summary = article.content[0].value
274
275 entries.append(u'%(number)s: "%(title)s"%(link)s : %(summary)s' % {
276 'number': articles.index(article) + 1,
277 'title': html2text_file(article.title, None).strip(),
278 'link': get_link(article),
279 'summary': summary,
280 })
281 else:
282 entries.append(u'%s: "%s"' % (feed.entries.index(article) + 1, html2text_file(article.title, None).strip()))
283 event.addresponse(u', '.join(entries))
261284
262 @match(r'^article\s+(?:(\d+)|/(.+?)/)\s+from\s+(.+?)$')285 @match(r'^article\s+(?:(\d+)|/(.+?)/)\s+from\s+(.+?)$')
263 def article(self, event, number, pattern, name):286 def article(self, event, number, pattern, name):
@@ -269,7 +292,7 @@
269292
270 feed.update()293 feed.update()
271 if not feed.entries:294 if not feed.entries:
272 event.addresponse(u"I can't access that feed")295 event.addresponse(u"I can't find any articles in that feed")
273 return296 return
274 article = None297 article = None
275298

Subscribers

People subscribed via source and target branches