mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Merge from trunk
This commit is contained in:
commit
438accabe3
@ -1,23 +1,12 @@
|
|||||||
__license__ = 'GPL v3'
|
|
||||||
__copyright__ = '2009-2010, Darko Miletic <darko.miletic at gmail.com>'
|
|
||||||
'''
|
|
||||||
www.instapaper.com
|
|
||||||
'''
|
|
||||||
|
|
||||||
import urllib
|
|
||||||
from calibre import strftime
|
from calibre import strftime
|
||||||
from calibre.web.feeds.news import BasicNewsRecipe
|
from calibre.web.feeds.news import BasicNewsRecipe
|
||||||
|
|
||||||
class Instapaper(BasicNewsRecipe):
|
class AdvancedUserRecipe1299694372(BasicNewsRecipe):
|
||||||
title = 'Instapaper.com'
|
title = u'Instapaper'
|
||||||
__author__ = 'Darko Miletic'
|
__author__ = 'Darko Miletic'
|
||||||
description = '''Personalized news feeds. Go to instapaper.com to
|
|
||||||
setup up your news. Fill in your instapaper
|
|
||||||
username, and leave the password field
|
|
||||||
below blank.'''
|
|
||||||
publisher = 'Instapaper.com'
|
publisher = 'Instapaper.com'
|
||||||
category = 'news, custom'
|
category = 'info, custom, Instapaper'
|
||||||
oldest_article = 7
|
oldest_article = 365
|
||||||
max_articles_per_feed = 100
|
max_articles_per_feed = 100
|
||||||
no_stylesheets = True
|
no_stylesheets = True
|
||||||
use_embedded_content = False
|
use_embedded_content = False
|
||||||
@ -25,16 +14,9 @@ class Instapaper(BasicNewsRecipe):
|
|||||||
INDEX = u'http://www.instapaper.com'
|
INDEX = u'http://www.instapaper.com'
|
||||||
LOGIN = INDEX + u'/user/login'
|
LOGIN = INDEX + u'/user/login'
|
||||||
|
|
||||||
conversion_options = {
|
|
||||||
'comment' : description
|
|
||||||
, 'tags' : category
|
|
||||||
, 'publisher' : publisher
|
|
||||||
}
|
|
||||||
|
|
||||||
feeds = [
|
|
||||||
(u'Unread articles' , INDEX + u'/u' )
|
feeds = [(u'Instapaper Unread', u'http://www.instapaper.com/u'), (u'Instapaper Starred', u'http://www.instapaper.com/starred')]
|
||||||
,(u'Starred articles', INDEX + u'/starred')
|
|
||||||
]
|
|
||||||
|
|
||||||
def get_browser(self):
|
def get_browser(self):
|
||||||
br = BasicNewsRecipe.get_browser()
|
br = BasicNewsRecipe.get_browser()
|
||||||
@ -70,7 +52,3 @@ class Instapaper(BasicNewsRecipe):
|
|||||||
})
|
})
|
||||||
totalfeeds.append((feedtitle, articles))
|
totalfeeds.append((feedtitle, articles))
|
||||||
return totalfeeds
|
return totalfeeds
|
||||||
|
|
||||||
def print_version(self, url):
|
|
||||||
return self.INDEX + '/text?u=' + urllib.quote(url)
|
|
||||||
|
|
||||||
|
@ -6,6 +6,8 @@ __docformat__ = 'restructuredtext en'
|
|||||||
|
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
from PyQt4.Qt import QLineEdit, QTextEdit
|
||||||
|
|
||||||
from calibre.gui2.convert.search_and_replace_ui import Ui_Form
|
from calibre.gui2.convert.search_and_replace_ui import Ui_Form
|
||||||
from calibre.gui2.convert import Widget
|
from calibre.gui2.convert import Widget
|
||||||
from calibre.gui2 import error_dialog
|
from calibre.gui2 import error_dialog
|
||||||
@ -72,3 +74,13 @@ class SearchAndReplaceWidget(Widget, Ui_Form):
|
|||||||
_('Invalid regular expression: %s')%err, show=True)
|
_('Invalid regular expression: %s')%err, show=True)
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def get_vaule(self, g):
|
||||||
|
if isinstance(g, (QLineEdit, QTextEdit)):
|
||||||
|
func = getattr(g, 'toPlainText', getattr(g, 'text', None))()
|
||||||
|
ans = unicode(func)
|
||||||
|
if not ans:
|
||||||
|
ans = None
|
||||||
|
return ans
|
||||||
|
else:
|
||||||
|
return Widget.get_value(self, g)
|
||||||
|
@ -55,6 +55,10 @@ class BaseModel(QAbstractListModel):
|
|||||||
text = _('Choose library')
|
text = _('Choose library')
|
||||||
return QVariant(text)
|
return QVariant(text)
|
||||||
if role == Qt.DecorationRole:
|
if role == Qt.DecorationRole:
|
||||||
|
if hasattr(self._data[row], 'qaction'):
|
||||||
|
icon = self._data[row].qaction.icon()
|
||||||
|
if not icon.isNull():
|
||||||
|
return QVariant(icon)
|
||||||
ic = action[1]
|
ic = action[1]
|
||||||
if ic is None:
|
if ic is None:
|
||||||
ic = 'blank.png'
|
ic = 'blank.png'
|
||||||
|
@ -92,7 +92,8 @@ class SendEmail(QWidget, Ui_Form):
|
|||||||
pa = self.preferred_to_address()
|
pa = self.preferred_to_address()
|
||||||
to_set = pa is not None
|
to_set = pa is not None
|
||||||
if self.set_email_settings(to_set):
|
if self.set_email_settings(to_set):
|
||||||
if question_dialog(self, _('OK to proceed?'),
|
opts = smtp_prefs().parse()
|
||||||
|
if not opts.relay_password or question_dialog(self, _('OK to proceed?'),
|
||||||
_('This will display your email password on the screen'
|
_('This will display your email password on the screen'
|
||||||
'. Is it OK to proceed?'), show_copy_button=False):
|
'. Is it OK to proceed?'), show_copy_button=False):
|
||||||
TestEmail(pa, self).exec_()
|
TestEmail(pa, self).exec_()
|
||||||
@ -204,19 +205,32 @@ class SendEmail(QWidget, Ui_Form):
|
|||||||
username = unicode(self.relay_username.text()).strip()
|
username = unicode(self.relay_username.text()).strip()
|
||||||
password = unicode(self.relay_password.text()).strip()
|
password = unicode(self.relay_password.text()).strip()
|
||||||
host = unicode(self.relay_host.text()).strip()
|
host = unicode(self.relay_host.text()).strip()
|
||||||
if host and not (username and password):
|
enc_method = ('TLS' if self.relay_tls.isChecked() else 'SSL'
|
||||||
error_dialog(self, _('Bad configuration'),
|
if self.relay_ssl.isChecked() else 'NONE')
|
||||||
_('You must set the username and password for '
|
if host:
|
||||||
'the mail server.')).exec_()
|
# Validate input
|
||||||
return False
|
if ((username and not password) or (not username and password)):
|
||||||
|
error_dialog(self, _('Bad configuration'),
|
||||||
|
_('You must either set both the username <b>and</b> password for '
|
||||||
|
'the mail server or no username and no password at all.')).exec_()
|
||||||
|
return False
|
||||||
|
if not username and not password and enc_method != 'NONE':
|
||||||
|
error_dialog(self, _('Bad configuration'),
|
||||||
|
_('Please enter a username and password or set'
|
||||||
|
' encryption to None ')).exec_()
|
||||||
|
return False
|
||||||
|
if not (username and password) and not question_dialog(self,
|
||||||
|
_('Are you sure?'),
|
||||||
|
_('No username and password set for mailserver. Most '
|
||||||
|
' mailservers need a username and password. Are you sure?')):
|
||||||
|
return False
|
||||||
conf = smtp_prefs()
|
conf = smtp_prefs()
|
||||||
conf.set('from_', from_)
|
conf.set('from_', from_)
|
||||||
conf.set('relay_host', host if host else None)
|
conf.set('relay_host', host if host else None)
|
||||||
conf.set('relay_port', self.relay_port.value())
|
conf.set('relay_port', self.relay_port.value())
|
||||||
conf.set('relay_username', username if username else None)
|
conf.set('relay_username', username if username else None)
|
||||||
conf.set('relay_password', hexlify(password))
|
conf.set('relay_password', hexlify(password))
|
||||||
conf.set('encryption', 'TLS' if self.relay_tls.isChecked() else 'SSL'
|
conf.set('encryption', enc_method)
|
||||||
if self.relay_ssl.isChecked() else 'NONE')
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user