Merge lp:~vhata/ibid/feeds-747635 into lp:~ibid-core/ibid/old-trunk-1.6

Proposed by Jonathan Hitchcock
Status: Superseded
Proposed branch: lp:~vhata/ibid/feeds-747635
Merge into: lp:~ibid-core/ibid/old-trunk-1.6
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
Jonathan Hitchcock Needs Resubmitting
Stefano Rivera Needs Fixing
Max Rabkin Approve
Review via email: mp+56277@code.launchpad.net

This proposal has been superseded by a proposal from 2011-10-24.

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) :
review: Approve
Revision history for this message
Stefano Rivera (stefanor) wrote :

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 :

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

Unmerged revisions

1029. By Jonathan Hitchcock

Fix usage

1028. By Jonathan Hitchcock

More flexible feed syntax

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ibid/plugins/feeds.py'
2--- ibid/plugins/feeds.py 2010-11-07 15:10:58 +0000
3+++ ibid/plugins/feeds.py 2011-04-05 00:33:11 +0000
4@@ -225,7 +225,7 @@
5 broken_lock = Lock()
6
7 class Retrieve(Processor):
8- usage = u"""latest [ <count> ] articles from <name> [ starting at <number> ]
9+ usage = u"""latest [ <count> ] ( articles | headlines ) from <name> [ starting at <number> ]
10 article ( <number> | /<pattern>/ ) from <name>"""
11 features = ('feeds',)
12
13@@ -236,10 +236,16 @@
14 'The slowdown ratio to back off from broken feeds', 2.0)
15
16
17- @match(r'^(?:latest|last)\s+(?:(\d+)\s+)?articles\s+from\s+(.+?)'
18+ @match(r'^(?:latest|last)\s+(?:(\d+)\s+)?(article|headline)(s)?\s+from\s+(.+?)'
19 r'(?:\s+start(?:ing)?\s+(?:at\s+|from\s+)?(\d+))?$')
20- def list(self, event, number, name, start):
21- number = number and int(number) or 10
22+ def list(self, event, number, full, plurality, name, start):
23+ full = full == 'article'
24+ if number:
25+ number = int(number)
26+ elif not plurality:
27+ number = 1
28+ else:
29+ number = 10
30 start = start and int(start) or 0
31
32 feed = event.session.query(Feed).filter_by(name=name).first()
33@@ -254,10 +260,27 @@
34 return
35
36 articles = feed.entries[start:number+start]
37- articles = [u'%s: "%s"' % (feed.entries.index(entry) + 1,
38- html2text_file(entry.title, None).strip())
39- for entry in articles]
40- event.addresponse(u', '.join(articles))
41+ entries = []
42+ for article in articles:
43+ if full:
44+ if 'summary' in article:
45+ summary = html2text_file(article.summary, None)
46+ else:
47+ if article.content[0].type in \
48+ ('application/xhtml+xml', 'text/html'):
49+ summary = html2text_file(article.content[0].value, None)
50+ else:
51+ summary = article.content[0].value
52+
53+ entries.append(u'%(number)s: "%(title)s"%(link)s : %(summary)s' % {
54+ 'number': articles.index(article) + 1,
55+ 'title': html2text_file(article.title, None).strip(),
56+ 'link': get_link(article),
57+ 'summary': summary,
58+ })
59+ else:
60+ entries.append(u'%s: "%s"' % (feed.entries.index(article) + 1, html2text_file(article.title, None).strip()))
61+ event.addresponse(u', '.join(entries))
62
63 @match(r'^article\s+(?:(\d+)|/(.+?)/)\s+from\s+(.+?)$')
64 def article(self, event, number, pattern, name):
65@@ -269,7 +292,7 @@
66
67 feed.update()
68 if not feed.entries:
69- event.addresponse(u"I can't access that feed")
70+ event.addresponse(u"I can't find any articles in that feed")
71 return
72 article = None
73

Subscribers

People subscribed via source and target branches