support signatures
This commit is contained in:
parent
1ee6a9a060
commit
c9252a855b
3 changed files with 17 additions and 2 deletions
|
|
@ -130,7 +130,8 @@ class DLFPBackend(BaseBackend, ICapMessages, ICapMessagesPost):
|
|||
date=com.date,
|
||||
parent=parent,
|
||||
content=com.body,
|
||||
signature='<br />'.join(['Score: %d' % com.score,
|
||||
signature=com.signature + \
|
||||
'<br />'.join(['Score: %d' % com.score,
|
||||
'URL: %s' % com.url]),
|
||||
children=[],
|
||||
flags=flags)
|
||||
|
|
|
|||
|
|
@ -65,6 +65,7 @@ class DLFP(BaseBrowser):
|
|||
|
||||
self.location(url)
|
||||
assert self.is_on_page(ContentPage)
|
||||
self.page.url = self.absurl(url)
|
||||
content = self.page.get_article()
|
||||
content.id = _id
|
||||
return content
|
||||
|
|
@ -121,6 +122,7 @@ class DLFP(BaseBrowser):
|
|||
self.location(url)
|
||||
|
||||
comment = None
|
||||
self.page.url = self.absurl(url)
|
||||
if self.is_on_page(CommentPage):
|
||||
comment = self.page.get_comment()
|
||||
elif self.is_on_page(ContentPage):
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ class Comment(object):
|
|||
self.username = None
|
||||
self.date = None
|
||||
self.body = u''
|
||||
self.signature = u''
|
||||
self.score = 0
|
||||
self.url = u''
|
||||
self.comments = []
|
||||
|
|
@ -52,7 +53,18 @@ class Comment(object):
|
|||
self.date = datetime.strptime(select(div.find('p'), 'time', 1).attrib['datetime'].split('+')[0],
|
||||
'%Y-%m-%dT%H:%M:%S')
|
||||
self.date = local2utc(self.date)
|
||||
self.body = self.browser.parser.tostring(div.find('div'))
|
||||
|
||||
content = div.find('div')
|
||||
try:
|
||||
signature = select(content, 'p.signature', 1)
|
||||
except SelectElementException:
|
||||
# No signature.
|
||||
pass
|
||||
else:
|
||||
content.remove(signature)
|
||||
self.signature = self.browser.parser.tostring(signature)
|
||||
self.body = self.browser.parser.tostring(content)
|
||||
|
||||
self.score = int(select(div.find('p'), 'span.score', 1).text)
|
||||
forms = select(div.find('footer'), 'form.button_to')
|
||||
if len(forms) == 0:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue