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
c2efafc1fd
@ -1,6 +1,5 @@
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2008-2010, Darko Miletic <darko.miletic at gmail.com>'
|
||||
__copyright__ = '2008-2011, Darko Miletic <darko.miletic at gmail.com>'
|
||||
'''
|
||||
arstechnica.com
|
||||
'''
|
||||
@ -9,19 +8,26 @@ import re
|
||||
from calibre.web.feeds.news import BasicNewsRecipe
|
||||
from calibre.ebooks.BeautifulSoup import BeautifulSoup, Tag
|
||||
|
||||
class ArsTechnica2(BasicNewsRecipe):
|
||||
class ArsTechnica(BasicNewsRecipe):
|
||||
title = u'Ars Technica'
|
||||
language = 'en'
|
||||
__author__ = 'Darko Miletic and Sujata Raman'
|
||||
__author__ = 'Darko Miletic, Sujata Raman, Alexis Rohou'
|
||||
description = 'The art of technology'
|
||||
publisher = 'Ars Technica'
|
||||
category = 'news, IT, technology'
|
||||
oldest_article = 2
|
||||
oldest_article = 5
|
||||
max_articles_per_feed = 100
|
||||
no_stylesheets = True
|
||||
encoding = 'utf-8'
|
||||
use_embedded_content = False
|
||||
extra_css = ' body {font-family: Arial,Helvetica,sans-serif} .title{text-align: left} .byline{font-weight: bold; line-height: 1em; font-size: 0.625em; text-decoration: none} '
|
||||
extra_css = '''
|
||||
body {font-family: Arial,Helvetica,sans-serif}
|
||||
.title{text-align: left}
|
||||
.byline{font-weight: bold; line-height: 1em; font-size: 0.625em; text-decoration: none}
|
||||
.news-item-figure-caption-text{font-size:small; font-style:italic}
|
||||
.news-item-figure-caption-byline{font-size:small; font-style:italic; font-weight:bold}
|
||||
'''
|
||||
ignoreEtcArticles = True # Etc feed items can be ignored, as they're not real stories
|
||||
|
||||
conversion_options = {
|
||||
'comments' : description
|
||||
@ -31,10 +37,10 @@ class ArsTechnica2(BasicNewsRecipe):
|
||||
}
|
||||
|
||||
|
||||
preprocess_regexps = [
|
||||
(re.compile(r'<div class="news-item-figure', re.DOTALL|re.IGNORECASE),lambda match: '<div class="news-item-figure"')
|
||||
,(re.compile(r'</title>.*?</head>', re.DOTALL|re.IGNORECASE),lambda match: '</title></head>')
|
||||
]
|
||||
#preprocess_regexps = [
|
||||
# (re.compile(r'<div class="news-item-figure', re.DOTALL|re.IGNORECASE),lambda match: '<div class="news-item-figure"')
|
||||
# ,(re.compile(r'</title>.*?</head>', re.DOTALL|re.IGNORECASE),lambda match: '</title></head>')
|
||||
# ]
|
||||
|
||||
keep_only_tags = [dict(name='div', attrs={'id':['story','etc-story']})]
|
||||
|
||||
@ -42,7 +48,7 @@ class ArsTechnica2(BasicNewsRecipe):
|
||||
dict(name=['object','link','embed'])
|
||||
,dict(name='div', attrs={'class':'read-more-link'})
|
||||
]
|
||||
remove_attributes=['width','height']
|
||||
#remove_attributes=['width','height']
|
||||
|
||||
feeds = [
|
||||
(u'Infinite Loop (Apple content)' , u'http://feeds.arstechnica.com/arstechnica/apple/' )
|
||||
@ -56,6 +62,7 @@ class ArsTechnica2(BasicNewsRecipe):
|
||||
,(u'Law & Disorder (Tech policy content)' , u'http://feeds.arstechnica.com/arstechnica/tech-policy/')
|
||||
]
|
||||
|
||||
# This deals with multi-page stories
|
||||
def append_page(self, soup, appendtag, position):
|
||||
pager = soup.find('div',attrs={'class':'pager'})
|
||||
if pager:
|
||||
@ -81,6 +88,7 @@ class ArsTechnica2(BasicNewsRecipe):
|
||||
|
||||
|
||||
def preprocess_html(self, soup):
|
||||
# Adds line breaks near the byline (not sure why this is needed)
|
||||
ftag = soup.find('div', attrs={'class':'byline'})
|
||||
if ftag:
|
||||
brtag = Tag(soup,'br')
|
||||
@ -88,12 +96,33 @@ class ArsTechnica2(BasicNewsRecipe):
|
||||
ftag.insert(4,brtag)
|
||||
ftag.insert(5,brtag2)
|
||||
|
||||
# Remove style items
|
||||
for item in soup.findAll(style=True):
|
||||
del item['style']
|
||||
|
||||
# Remove id
|
||||
for item in soup.findAll(id=True):
|
||||
del item['id']
|
||||
|
||||
# For some reason, links to authors don't have the domainname
|
||||
a_author = soup.find('a',{'href':re.compile("^/author")})
|
||||
if a_author:
|
||||
a_author['href'] = 'http://arstechnica.com'+a_author['href']
|
||||
|
||||
# within div class news-item-figure, we need to grab images
|
||||
|
||||
# Deal with multi-page stories
|
||||
self.append_page(soup, soup.body, 3)
|
||||
|
||||
return soup
|
||||
|
||||
def get_article_url(self, article):
|
||||
# If the article title starts with Etc:, don't return it
|
||||
if self.ignoreEtcArticles:
|
||||
article_title = article.get('title',None)
|
||||
if re.match('Etc: ',article_title) is not None:
|
||||
return None
|
||||
|
||||
# The actual article is in a guid tag
|
||||
return article.get('guid', None).rpartition('?')[0]
|
||||
|
||||
|
@ -21,17 +21,54 @@ class SeattleTimes(BasicNewsRecipe):
|
||||
encoding = 'cp1252'
|
||||
language = 'en'
|
||||
|
||||
|
||||
html2lrf_options = [
|
||||
'--comment' , description
|
||||
, '--category' , category
|
||||
, '--publisher', publisher
|
||||
feeds = [
|
||||
(u'Top Stories',
|
||||
u'http://seattletimes.nwsource.com/rss/home.xml'),
|
||||
#(u'Articles', u'http://seattletimes.nwsource.com/rss/seattletimes.xml')
|
||||
(u'Business & Technology',
|
||||
u'http://seattletimes.nwsource.com/rss/businesstechnology.xml'),
|
||||
(u'Personal Technology',
|
||||
u'http://seattletimes.nwsource.com/rss/personaltechnology.xml'),
|
||||
(u'Entertainment & the Arts',
|
||||
u'http://seattletimes.nwsource.com/rss/artsentertainment.xml'),
|
||||
(u'Health',
|
||||
u'http://seattletimes.nwsource.com/rss/health.xml'),
|
||||
(u'Living',
|
||||
u'http://seattletimes.nwsource.com/rss/living.xml'),
|
||||
(u'Local News',
|
||||
u'http://seattletimes.nwsource.com/rss/localnews.xml'),
|
||||
(u'Nation & World',
|
||||
u'http://seattletimes.nwsource.com/rss/nationworld.xml'),
|
||||
(u'Opinion',
|
||||
u'http://seattletimes.nwsource.com/rss/opinion.xml'),
|
||||
(u'Politics',
|
||||
u'http://seattletimes.nwsource.com/rss/politics.xml'),
|
||||
(u'Sports',
|
||||
u'http://seattletimes.nwsource.com/rss/sports.xml'),
|
||||
(u'Nicole Brodeur',
|
||||
u'http://seattletimes.nwsource.com/rss/nicolebrodeur.xml'),
|
||||
(u'Danny Westneat',
|
||||
u'http://seattletimes.nwsource.com/rss/dannywestneat.xml'),
|
||||
(u'Jerry Large',
|
||||
u'http://seattletimes.nwsource.com/rss/jerrylarge.xml'),
|
||||
(u'Ron Judd',
|
||||
u'http://seattletimes.nwsource.com/rss/ronjudd.xml'),
|
||||
(u'Education',
|
||||
u'http://seattletimes.nwsource.com/rss/education.xml'),
|
||||
(u'Letters to the Editor',
|
||||
u'http://seattletimes.nwsource.com/rss/northwestvoices.xml'),
|
||||
(u'Travel',
|
||||
u'http://seattletimes.nwsource.com/rss/travel.xml'),
|
||||
(u'Outdoors',
|
||||
u'http://seattletimes.nwsource.com/rss/outdoors.xml'),
|
||||
(u'Steve Kelley',
|
||||
u'http://seattletimes.nwsource.com/rss/stevekelley.xml'),
|
||||
(u'Jerry Brewer',
|
||||
u'http://seattletimes.nwsource.com/rss/jerrybrewer.xml'),
|
||||
(u'Most Read Articles',
|
||||
u'http://seattletimes.nwsource.com/rss/mostreadarticles.xml'),
|
||||
]
|
||||
|
||||
html2epub_options = 'publisher="' + publisher + '"\ncomments="' + description + '"\ntags="' + category + '"'
|
||||
|
||||
feeds = [(u'Articles', u'http://seattletimes.nwsource.com/rss/seattletimes.xml')]
|
||||
|
||||
remove_tags = [
|
||||
dict(name=['object','link','script'])
|
||||
,dict(name='p', attrs={'class':'permission'})
|
||||
|
@ -178,7 +178,7 @@ class INVESBOOK(EB600):
|
||||
|
||||
class BOOQ(EB600):
|
||||
name = 'Booq Device Interface'
|
||||
gui_name = 'Booq'
|
||||
gui_name = 'bq Reader'
|
||||
|
||||
FORMATS = ['epub', 'mobi', 'prc', 'fb2', 'pdf', 'doc', 'rtf', 'txt', 'html']
|
||||
|
||||
|
@ -33,8 +33,8 @@ class PALMPRE(USBMS):
|
||||
|
||||
class AVANT(USBMS):
|
||||
name = 'Booq Avant Device Interface'
|
||||
gui_name = 'Avant'
|
||||
description = _('Communicate with the Booq Avant')
|
||||
gui_name = 'bq Avant'
|
||||
description = _('Communicate with the Bq Avant')
|
||||
author = 'Kovid Goyal'
|
||||
supported_platforms = ['windows', 'osx', 'linux']
|
||||
|
||||
|
@ -34,7 +34,7 @@ class TXTInput(InputFormatPlugin):
|
||||
'starts a paragraph.'
|
||||
'* unformatted: Most lines have hard line breaks, few/no blank lines or indents.')),
|
||||
OptionRecommendation(name='formatting_type', recommended_value='auto',
|
||||
choices=['auto', 'none', 'heuristic', 'markdown'],
|
||||
choices=['auto', 'none', 'heuristic', 'textile', 'markdown'],
|
||||
help=_('Formatting used within the document.'
|
||||
'* auto: Automatically decide which formatting processor to use.\n'
|
||||
'* none: Do not process the document formatting. Everything is a '
|
||||
|
@ -593,6 +593,11 @@ class Editor(QWidget): # {{{
|
||||
def code_dirtied(self, *args):
|
||||
self.source_dirty = True
|
||||
|
||||
def hide_toolbars(self):
|
||||
self.toolbar1.setVisible(False)
|
||||
self.toolbar2.setVisible(False)
|
||||
self.toolbar3.setVisible(False)
|
||||
|
||||
# }}}
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -18,6 +18,7 @@ from calibre.ebooks.metadata.opf2 import metadata_to_opf
|
||||
from calibre.ptempfile import PersistentTemporaryFile
|
||||
from calibre.gui2.convert import Widget
|
||||
from calibre.utils.icu import sort_key
|
||||
from calibre.library.comments import comments_to_html
|
||||
|
||||
def create_opf_file(db, book_id):
|
||||
mi = db.get_metadata(book_id, index_is_id=True)
|
||||
@ -57,6 +58,7 @@ class MetadataWidget(Widget, Ui_Form):
|
||||
self.initialize_metadata_options()
|
||||
self.initialize_options(get_option, get_help, db, book_id)
|
||||
self.connect(self.cover_button, SIGNAL("clicked()"), self.select_cover)
|
||||
self.comment.hide_toolbars()
|
||||
|
||||
def deduce_author_sort(self, *args):
|
||||
au = unicode(self.author.currentText())
|
||||
@ -79,7 +81,7 @@ class MetadataWidget(Widget, Ui_Form):
|
||||
self.author_sort.setText(mi.author_sort if mi.author_sort else '')
|
||||
self.tags.setText(', '.join(mi.tags if mi.tags else []))
|
||||
self.tags.update_items_cache(self.db.all_tags())
|
||||
self.comment.setPlainText(mi.comments if mi.comments else '')
|
||||
self.comment.html = comments_to_html(mi.comments) if mi.comments else ''
|
||||
if mi.series:
|
||||
self.series.setCurrentIndex(self.series.findText(mi.series))
|
||||
if mi.series_index is not None:
|
||||
@ -154,7 +156,7 @@ class MetadataWidget(Widget, Ui_Form):
|
||||
author_sort = unicode(self.author_sort.text()).strip()
|
||||
if author_sort:
|
||||
mi.author_sort = author_sort
|
||||
comments = unicode(self.comment.toPlainText()).strip()
|
||||
comments = self.comment.html
|
||||
if comments:
|
||||
mi.comments = comments
|
||||
mi.series_index = float(self.series_index.value())
|
||||
|
@ -20,30 +20,6 @@
|
||||
<string>Book Cover</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="_2">
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout" name="_3">
|
||||
<item>
|
||||
<widget class="ImageView" name="cover" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QCheckBox" name="opt_prefer_metadata_cover">
|
||||
<property name="text">
|
||||
<string>Use cover from &source file</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<layout class="QVBoxLayout" name="_4">
|
||||
<property name="spacing">
|
||||
@ -95,6 +71,30 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QCheckBox" name="opt_prefer_metadata_cover">
|
||||
<property name="text">
|
||||
<string>Use cover from &source file</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout" name="_3">
|
||||
<item>
|
||||
<widget class="ImageView" name="cover" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
<zorder>opt_prefer_metadata_cover</zorder>
|
||||
<zorder></zorder>
|
||||
@ -264,35 +264,7 @@
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>200</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Comments</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="_8">
|
||||
<item row="0" column="0">
|
||||
<widget class="QTextEdit" name="comment">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>180</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="Editor" name="comment" native="true"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
@ -325,6 +297,12 @@
|
||||
<header>calibre/gui2/widgets.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>Editor</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>calibre/gui2/comments_editor.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>title</tabstop>
|
||||
@ -334,7 +312,6 @@
|
||||
<tabstop>tags</tabstop>
|
||||
<tabstop>series</tabstop>
|
||||
<tabstop>series_index</tabstop>
|
||||
<tabstop>comment</tabstop>
|
||||
<tabstop>cover_path</tabstop>
|
||||
<tabstop>cover_button</tabstop>
|
||||
<tabstop>opt_prefer_metadata_cover</tabstop>
|
||||
|
@ -196,6 +196,12 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
|
||||
def modify_plugin(self, op=''):
|
||||
index = self.plugin_view.currentIndex()
|
||||
if index.isValid():
|
||||
if not index.parent().isValid():
|
||||
name = unicode(index.data().toString())
|
||||
return error_dialog(self, _('Error'), '<p>'+
|
||||
_('Select an actual plugin under <b>%s</b> to customize')%name,
|
||||
show=True, show_copy_button=False)
|
||||
|
||||
plugin = self._plugin_model.index_to_plugin(index)
|
||||
if op == 'toggle':
|
||||
if not plugin.can_be_disabled:
|
||||
|
@ -485,7 +485,8 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{
|
||||
if 'calibre.ebooks.DRMError' in job.details:
|
||||
if not minz:
|
||||
from calibre.gui2.dialogs.drm_error import DRMErrorMessage
|
||||
d = DRMErrorMessage(self, job.description.split(':')[-1])
|
||||
d = DRMErrorMessage(self, _('Cannot convert') + ' ' +
|
||||
job.description.split(':')[-1].partition('(')[-1][:-1])
|
||||
d.setModal(False)
|
||||
d.show()
|
||||
self._modeless_dialogs.append(d)
|
||||
|
@ -111,7 +111,7 @@ class Kobo(Device):
|
||||
id = 'kobo'
|
||||
|
||||
class Booq(Device):
|
||||
name = 'Booq Reader'
|
||||
name = 'bq Classic'
|
||||
manufacturer = 'Booq'
|
||||
output_profile = 'sony'
|
||||
output_format = 'EPUB'
|
||||
@ -125,7 +125,18 @@ class TheBook(Device):
|
||||
id = 'thebook'
|
||||
|
||||
class Avant(Booq):
|
||||
name = 'Booq Avant'
|
||||
name = 'bq Avant'
|
||||
|
||||
class AvantXL(Booq):
|
||||
name = 'bq Avant XL'
|
||||
output_profile = 'ipad'
|
||||
|
||||
class BooqPocketPlus(Booq):
|
||||
name = 'bq Pocket Plus'
|
||||
output_profile = 'sony300'
|
||||
|
||||
class BooqCervantes(Booq):
|
||||
name = 'bq Cervantes'
|
||||
|
||||
class Sony300(Sony505):
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user