diff --git a/resources/default_tweaks.py b/resources/default_tweaks.py index 40b3d2fa32..d2f2667222 100644 --- a/resources/default_tweaks.py +++ b/resources/default_tweaks.py @@ -72,9 +72,9 @@ gui_pubdate_display_format = 'MMM yyyy' # without changing anything is sufficient to change the sort. title_series_sorting = 'library_order' -# Apple iDevice -# Control whether Series name is used as Category/Genre in iTunes/iBooks -# If set to 'True', a Book's Series name will be used as the Category/Genre +# Apple iTunes/iDevice +# Control whether Series name is used as Genre in iTunes/iBooks +# If set to 'True', a Book's Series name will be used as the Genre # If set to 'False', the book's first tag beginning with an alpha character will -# be used as the Category/Genre -iDevice_use_series_as_category = True +# be used as the Genre +ITUNES_use_series_as_category = True diff --git a/resources/quick_start.epub b/resources/quick_start.epub index 7dd8d7e91c..d5aeec5457 100644 Binary files a/resources/quick_start.epub and b/resources/quick_start.epub differ diff --git a/resources/recipes/london_free_press.recipe b/resources/recipes/london_free_press.recipe new file mode 100644 index 0000000000..82f6a2abc9 --- /dev/null +++ b/resources/recipes/london_free_press.recipe @@ -0,0 +1,38 @@ +from calibre.web.feeds.news import BasicNewsRecipe + +class LondonFreePress(BasicNewsRecipe): + title = u'London Free Press' + __author__ = 'rty' + oldest_article = 4 + max_articles_per_feed = 100 + + pubisher = 'lfpress.com' + description = 'Ontario Canada Newspaper' + category = 'News, Ontario, Canada' + remove_javascript = True + use_embedded_content = False + no_stylesheets = True + language = 'en_CA' + encoding = 'utf-8' + conversion_options = {'linearize_tables':True} + + feeds = [ + (u'News', u'http://www.lfpress.com/news/rss.xml'), + (u'Comment', u'http://www.lfpress.com/comment/rss.xml'), + (u'Entertainment', u'http://www.lfpress.com/entertainment/rss.xml '), + (u'Money', u'http://www.lfpress.com/money/rss.xml '), + (u'Life', u'http://www.lfpress.com/life/rss.xml '), + (u'Sports', u'http://www.lfpress.com/sports/rss.xml ') + ] + + keep_only_tags = [ + dict(name='div', attrs={'id':'article'}), + ] + remove_tags = [ + dict(name='div', attrs={'id':'commentsBottom'}), + dict(name='div', attrs={'class':['leftBox','bottomBox clear']}), + dict(name='ul', attrs={'class':'tabs dl contentSwap'}), + ] + remove_tags_after = [ + dict(name='div', attrs={'class':'bottomBox clear'}), + ] diff --git a/resources/recipes/losservatoreromano_it.recipe b/resources/recipes/losservatoreromano_it.recipe new file mode 100644 index 0000000000..19a579d3ff --- /dev/null +++ b/resources/recipes/losservatoreromano_it.recipe @@ -0,0 +1,48 @@ +__license__ = 'GPL v3' +__copyright__ = '2010, Darko Miletic ' +''' +www.vatican.va/news_services/or/or_quo +''' + + +from calibre.web.feeds.news import BasicNewsRecipe + +class LOsservatoreRomano_it(BasicNewsRecipe): + title = "L'Osservatore Romano" + __author__ = 'Darko Miletic' + description = 'Quiornale quotidiano, politico, religioso del Vaticano' + publisher = 'La Santa Sede' + category = 'news, politics, religion, Vatican' + no_stylesheets = True + INDEX = 'http://www.vatican.va' + FEEDPAGE = INDEX + '/news_services/or/or_quo/index.html' + CONTENTPAGE = INDEX + '/news_services/or/or_quo/text.html' + use_embedded_content = False + encoding = 'cp1252' + language = 'it' + publication_type = 'newspaper' + + + conversion_options = { + 'comment' : description + , 'tags' : category + , 'publisher' : publisher + , 'language' : language + , 'linearize_tables' : True + } + + def parse_index(self): + articles = [] + articles.append({ + 'title' :self.title + ,'date' :'' + ,'url' :self.CONTENTPAGE + ,'description':'' + }) + return [(self.title, articles)] + + def preprocess_html(self, soup): + for item in soup.findAll(style=True): + del item['style'] + return self.adeify_images(soup) + diff --git a/resources/recipes/people_daily.recipe b/resources/recipes/people_daily.recipe new file mode 100644 index 0000000000..4dec2452e2 --- /dev/null +++ b/resources/recipes/people_daily.recipe @@ -0,0 +1,57 @@ +from calibre.web.feeds.news import BasicNewsRecipe + +class AdvancedUserRecipe1277129332(BasicNewsRecipe): + title = u'People Daily - China' + oldest_article = 2 + max_articles_per_feed = 100 + __author__ = 'rty' + + pubisher = 'people.com.cn' + description = 'People Daily Newspaper' + language = 'zh' + category = 'News, China' + remove_javascript = True + use_embedded_content = False + no_stylesheets = True + encoding = 'GB2312' + conversion_options = {'linearize_tables':True} + + feeds = [(u'\u56fd\u5185\u65b0\u95fb', u'http://www.people.com.cn/rss/politics.xml'), + (u'\u56fd\u9645\u65b0\u95fb', u'http://www.people.com.cn/rss/world.xml'), + (u'\u7ecf\u6d4e\u65b0\u95fb', u'http://www.people.com.cn/rss/finance.xml'), + (u'\u4f53\u80b2\u65b0\u95fb', u'http://www.people.com.cn/rss/sports.xml'), + (u'\u53f0\u6e7e\u65b0\u95fb', u'http://www.people.com.cn/rss/haixia.xml')] + keep_only_tags = [ + dict(name='div', attrs={'class':'left_content'}), + ] + remove_tags = [ + dict(name='table', attrs={'class':'title'}), + ] + remove_tags_after = [ + dict(name='table', attrs={'class':'bianji'}), + ] + + def append_page(self, soup, appendtag, position): + pager = soup.find('img',attrs={'src':'/img/next_b.gif'}) + if pager: + nexturl = self.INDEX + pager.a['href'] + soup2 = self.index_to_soup(nexturl) + texttag = soup2.find('div', attrs={'class':'left_content'}) + #for it in texttag.findAll(style=True): + # del it['style'] + newpos = len(texttag.contents) + self.append_page(soup2,texttag,newpos) + texttag.extract() + appendtag.insert(position,texttag) + + + def preprocess_html(self, soup): + mtag = '\n' + soup.head.insert(0,mtag) + for item in soup.findAll(style=True): + del item['form'] + self.append_page(soup, soup.body, 3) + #pager = soup.find('a',attrs={'class':'ab12'}) + #if pager: + # pager.extract() + return soup diff --git a/src/calibre/devices/apple/driver.py b/src/calibre/devices/apple/driver.py index 2efe2b553f..91cfba98f1 100644 --- a/src/calibre/devices/apple/driver.py +++ b/src/calibre/devices/apple/driver.py @@ -163,7 +163,7 @@ class ITUNES(DevicePlugin): sources = None update_msg = None update_needed = False - use_series_as_category = tweaks['iDevice_use_series_as_category'] + use_series_as_category = tweaks['ITUNES_use_series_as_category'] # Public methods def add_books_to_metadata(self, locations, metadata, booklists): diff --git a/src/calibre/ebooks/metadata/__init__.py b/src/calibre/ebooks/metadata/__init__.py index 690cca511a..4d126fda9d 100644 --- a/src/calibre/ebooks/metadata/__init__.py +++ b/src/calibre/ebooks/metadata/__init__.py @@ -282,7 +282,7 @@ class MetaInformation(object): for attr in ('author_sort', 'title_sort', 'category', 'publisher', 'series', 'series_index', 'rating', 'isbn', 'application_id', 'manifest', 'spine', 'toc', - 'cover', 'language', 'guide', 'book_producer', + 'cover', 'guide', 'book_producer', 'timestamp', 'lccn', 'lcc', 'ddc', 'pubdate', 'rights', 'publication_type', 'uuid'): if hasattr(mi, attr): @@ -314,6 +314,11 @@ class MetaInformation(object): if len(other_comments.strip()) > len(my_comments.strip()): self.comments = other_comments + other_lang = getattr(mi, 'language', None) + if other_lang and other_lang.lower() != 'und': + self.language = other_lang + + def format_series_index(self): try: x = float(self.series_index) diff --git a/src/calibre/ebooks/metadata/opf2.py b/src/calibre/ebooks/metadata/opf2.py index 46924cad1f..579398d3b0 100644 --- a/src/calibre/ebooks/metadata/opf2.py +++ b/src/calibre/ebooks/metadata/opf2.py @@ -18,7 +18,7 @@ from calibre.constants import __appname__, __version__, filesystem_encoding from calibre.ebooks.metadata.toc import TOC from calibre.ebooks.metadata import MetaInformation, string_to_authors from calibre.utils.date import parse_date, isoformat - +from calibre.utils.localization import get_lang class Resource(object): ''' @@ -1069,7 +1069,7 @@ class OPFCreator(MetaInformation): dc_attrs={'id':__appname__+'_id'})) if getattr(self, 'pubdate', None) is not None: a(DC_ELEM('date', self.pubdate.isoformat())) - a(DC_ELEM('language', self.language if self.language else 'UND')) + a(DC_ELEM('language', self.language if self.language else get_lang())) if self.comments: a(DC_ELEM('description', self.comments)) if self.publisher: @@ -1184,7 +1184,6 @@ def metadata_to_opf(mi, as_string=True): factory(DC('contributor'), mi.book_producer, __appname__, 'bkp') if hasattr(mi.pubdate, 'isoformat'): factory(DC('date'), isoformat(mi.pubdate)) - factory(DC('language'), mi.language) if mi.category: factory(DC('type'), mi.category) if mi.comments: @@ -1195,6 +1194,7 @@ def metadata_to_opf(mi, as_string=True): factory(DC('identifier'), mi.isbn, scheme='ISBN') if mi.rights: factory(DC('rights'), mi.rights) + factory(DC('language'), mi.language if mi.language and mi.language.lower() != 'und' else get_lang()) if mi.tags: for tag in mi.tags: factory(DC('subject'), tag) diff --git a/src/calibre/manual/conf.py b/src/calibre/manual/conf.py index b00a454237..3866008f1f 100644 --- a/src/calibre/manual/conf.py +++ b/src/calibre/manual/conf.py @@ -100,9 +100,8 @@ html_use_smartypants = True html_title = 'calibre User Manual' html_short_title = 'Start' html_logo = 'resources/logo.png' -epub_titlepage = 'resources/titlepage.html' -epub_logo = 'resources/logo.png' epub_author = 'Kovid Goyal' +epub_cover = 'resources/epub_cover.jpg' # Custom sidebar templates, maps document names to template names. #html_sidebars = {} diff --git a/src/calibre/manual/custom.py b/src/calibre/manual/custom.py index 38486cc67a..917b927086 100644 --- a/src/calibre/manual/custom.py +++ b/src/calibre/manual/custom.py @@ -304,9 +304,8 @@ def auto_member(dirname, arguments, options, content, lineno, return list(node) def setup(app): - app.add_config_value('epub_titlepage', None, False) + app.add_config_value('epub_cover', None, False) app.add_config_value('epub_author', '', False) - app.add_config_value('epub_logo', None, False) app.add_builder(CustomBuilder) app.add_builder(CustomQtBuild) app.add_builder(EPUBHelpBuilder) diff --git a/src/calibre/manual/epub.py b/src/calibre/manual/epub.py index 4635e334c0..d54eb99a8d 100644 --- a/src/calibre/manual/epub.py +++ b/src/calibre/manual/epub.py @@ -50,6 +50,7 @@ OPF = '''\ {uid} {date} + {manifest} @@ -71,6 +72,29 @@ CONTAINER='''\ ''' + +SVG_TEMPLATE = '''\ + + + + + Cover + + + + + + + + +''' + class TOC(list): def __init__(self, title=None, href=None): @@ -151,8 +175,6 @@ class EPUBHelpBuilder(StandaloneHTMLBuilder): spine = [' '*8+''%quoteattr(x) for x in self.spine] spine = '\n'.join(spine) guide = '' - if self.conf.epub_titlepage: - guide = ' '*8 + '' opf = OPF.format(title=escape(self.conf.html_title), author=escape(self.conf.epub_author), uid=str(uuid.uuid4()), @@ -162,18 +184,15 @@ class EPUBHelpBuilder(StandaloneHTMLBuilder): self.manifest['content.opf'] = ('application/oebps-package+xml', 'opf') def create_titlepage(self): - if self.conf.epub_titlepage: - img = '' - if self.conf.epub_logo: - img = '_static/epub_logo'+os.path.splitext(self.conf.epub_logo)[1] - shutil.copyfile(self.conf.epub_logo, - os.path.join(self.html_outdir, *img.split('/'))) - raw = open(self.conf.epub_titlepage, 'rb').read() - raw = raw%dict(title=self.conf.html_title, - version=self.conf.version, - img=img.split('/')[-1], - author=self.conf.epub_author) - open(os.path.join(self.html_outdir, '_static', 'titlepage.html'), 'wb').write(raw) + self.cover_image_url = None + if self.conf.epub_cover: + img = '_static/'+os.path.basename(self.conf.epub_cover) + shutil.copyfile(self.conf.epub_cover, os.path.join(self.html_outdir, + *img.split('/'))) + self.cover_image_url = img + tp = SVG_TEMPLATE%img.split('/')[-1] + open(os.path.join(self.html_outdir, '_static', 'titlepage.html'), + 'wb').write(tp) def generate_manifest(self): self.manifest = {} @@ -190,8 +209,12 @@ class EPUBHelpBuilder(StandaloneHTMLBuilder): self.manifest[url] = 'application/octet-stream' if self.manifest[url] == 'text/html': self.manifest[url] = 'application/xhtml+xml' - self.manifest[url] = (self.manifest[url], 'id'+str(id)) - id += 1 + if self.cover_image_url and url.endswith(self.cover_image_url): + id_ = 'cover' + else: + id_ = 'id'+str(id) + id += 1 + self.manifest[url] = (self.manifest[url], id_) def isdocnode(self, node): if not isinstance(node, nodes.list_item): @@ -227,7 +250,7 @@ class EPUBHelpBuilder(StandaloneHTMLBuilder): open('toc.ncx', 'wb').write(ncx) self.manifest['toc.ncx'] = ('application/x-dtbncx+xml', 'ncx') self.spine.insert(0, self.manifest[self.conf.master_doc+'.html'][1]) - if self.conf.epub_titlepage: + if self.conf.epub_cover: self.spine.insert(0, self.manifest['_static/titlepage.html'][1]) def add_to_spine(self, href): diff --git a/src/calibre/manual/faq.rst b/src/calibre/manual/faq.rst index d04e414717..a7968fc4e1 100644 --- a/src/calibre/manual/faq.rst +++ b/src/calibre/manual/faq.rst @@ -160,7 +160,7 @@ Alternative for the iPad As of |app| version 0.7.0, you can plugin your iPad into the computer using its charging cable, and |app| will detect it and show you a list of books on the iPad. You can then use the Send to device button to send books directly to iBooks on the iPad. This method only works on Windows XP and higher and OS X 10.5 and higher. Linux is not supported (iTunes is not available in linux) and OS X 10.4 is not supported. For more details, see -`this forum post http://www.mobileread.com/forums/showpost.php?p=944079&postcount=1`_. +`this forum post `_. How do I use |app| with my Android phone? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -190,11 +190,16 @@ The most likely cause of this is your antivirus program. Try temporarily disabli Why is my device not detected in linux? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -|app| uses something called SYSFS to detect devices in linux. The linux kernel can export two version of SYSFS, one of which is deprecated. Some linux distributions still ship with kernels that support the deprecated version of SYSFS, even though it was deprecated a long time ago. In this case, device detection in |app| will not work. You can check what version of SYSFS is exported by your kernel with the following command:: +|app| needs your linux kernel to have been setup correctly to detect devices. If your devices are not detected, perform the following tests:: grep SYSFS_DEPRECATED /boot/config-`uname -r` -You should see something like ``CONFIG_SYSFS_DEPRECATED_V2 is not set``. If you don't you have to either recompile your kernel with the correct setting, or upgrade your linux distro to a more modern version, where this will not be set. +You should see something like ``CONFIG_SYSFS_DEPRECATED_V2 is not set``. +Also, :: + + grep CONFIG_SCSI_MULTI_LUN /boot/config-`uname -r` + +must return ``CONFIG_SCSI_MULTI_LUN=y``. If you don't see either, you have to recompile your kernel with the correct settings. Library Management ------------------ diff --git a/src/calibre/manual/resources/epub_cover.jpg b/src/calibre/manual/resources/epub_cover.jpg new file mode 100644 index 0000000000..d5aa42e775 Binary files /dev/null and b/src/calibre/manual/resources/epub_cover.jpg differ diff --git a/src/calibre/manual/resources/titlepage.html b/src/calibre/manual/resources/titlepage.html deleted file mode 100644 index 08f7ddf1cc..0000000000 --- a/src/calibre/manual/resources/titlepage.html +++ /dev/null @@ -1,29 +0,0 @@ - - - %(title)s - - - -

%(title)s

-

%(version)s

-
- -
-

%(author)s

- - -