mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix #2074 (Clicking "table of contents" on a "lit")
This commit is contained in:
parent
570a9eaeac
commit
04f0e389af
@ -118,11 +118,17 @@ class EbookIterator(object):
|
|||||||
self.spine = [SpineItem(i.path) for i in self.opf.spine]
|
self.spine = [SpineItem(i.path) for i in self.opf.spine]
|
||||||
|
|
||||||
cover = self.opf.cover
|
cover = self.opf.cover
|
||||||
if os.path.splitext(self.pathtoebook)[1].lower() in ('.lit', '.mobi', '.prc') and cover:
|
if os.path.splitext(self.pathtoebook)[1].lower() in \
|
||||||
|
('.lit', '.mobi', '.prc') and cover:
|
||||||
cfile = os.path.join(os.path.dirname(self.spine[0]), 'calibre_ei_cover.html')
|
cfile = os.path.join(os.path.dirname(self.spine[0]), 'calibre_ei_cover.html')
|
||||||
open(cfile, 'wb').write(TITLEPAGE%cover)
|
open(cfile, 'wb').write(TITLEPAGE%cover)
|
||||||
self.spine[0:0] = [SpineItem(cfile)]
|
self.spine[0:0] = [SpineItem(cfile)]
|
||||||
|
|
||||||
|
if self.opf.path_to_html_toc is not None and \
|
||||||
|
self.opf.path_to_html_toc not in self.spine:
|
||||||
|
self.spine.append(SpineItem(self.opf.path_to_html_toc))
|
||||||
|
|
||||||
|
|
||||||
sizes = [i.character_count for i in self.spine]
|
sizes = [i.character_count for i in self.spine]
|
||||||
self.pages = [math.ceil(i/float(self.CHARACTERS_PER_PAGE)) for i in sizes]
|
self.pages = [math.ceil(i/float(self.CHARACTERS_PER_PAGE)) for i in sizes]
|
||||||
for p, s in zip(self.pages, self.spine):
|
for p, s in zip(self.pages, self.spine):
|
||||||
|
@ -444,6 +444,7 @@ class OPF(object):
|
|||||||
if not hasattr(stream, 'read'):
|
if not hasattr(stream, 'read'):
|
||||||
stream = open(stream, 'rb')
|
stream = open(stream, 'rb')
|
||||||
self.basedir = self.base_dir = basedir
|
self.basedir = self.base_dir = basedir
|
||||||
|
self.path_to_html_toc = None
|
||||||
raw, self.encoding = xml_to_unicode(stream.read(), strip_encoding_pats=True, resolve_entities=True)
|
raw, self.encoding = xml_to_unicode(stream.read(), strip_encoding_pats=True, resolve_entities=True)
|
||||||
raw = raw[raw.find('<'):]
|
raw = raw[raw.find('<'):]
|
||||||
self.root = etree.fromstring(raw, self.PARSER)
|
self.root = etree.fromstring(raw, self.PARSER)
|
||||||
@ -495,6 +496,7 @@ class OPF(object):
|
|||||||
if f:
|
if f:
|
||||||
self.toc.read_ncx_toc(f[0])
|
self.toc.read_ncx_toc(f[0])
|
||||||
else:
|
else:
|
||||||
|
self.path_to_html_toc = toc
|
||||||
self.toc.read_html_toc(toc)
|
self.toc.read_html_toc(toc)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<ui version="4.0">
|
<ui version="4.0">
|
||||||
<class>MetadataSingleDialog</class>
|
<class>MetadataSingleDialog</class>
|
||||||
<widget class="QDialog" name="MetadataSingleDialog">
|
<widget class="QDialog" name="MetadataSingleDialog">
|
||||||
@ -10,7 +11,7 @@
|
|||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy vsizetype="MinimumExpanding" hsizetype="MinimumExpanding" >
|
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
@ -51,7 +52,7 @@
|
|||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QWidget" native="1" name="central_widget" >
|
<widget class="QWidget" name="central_widget" native="true">
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>800</width>
|
<width>800</width>
|
||||||
@ -92,7 +93,7 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item rowspan="2" row="0" column="2" >
|
<item row="0" column="2" rowspan="2">
|
||||||
<widget class="QToolButton" name="swap_button">
|
<widget class="QToolButton" name="swap_button">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Swap the author and title</string>
|
<string>Swap the author and title</string>
|
||||||
@ -226,7 +227,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QLineEdit" name="tags">
|
<widget class="QLineEdit" name="tags">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Tags categorize the book. This is particularly useful while searching. <br><br>They can be any words or phrases, separated by commas.</string>
|
<string>Tags categorize the book. This is particularly useful while searching. <br><br>They can be any words or phrases, separated by commas.</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -270,7 +271,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QComboBox" name="series">
|
<widget class="QComboBox" name="series">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy vsizetype="Fixed" hsizetype="MinimumExpanding" >
|
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
@ -374,7 +375,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="fetch_metadata_button">
|
<widget class="QPushButton" name="fetch_metadata_button">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Fetch metadata from server</string>
|
<string>&Fetch metadata from server</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -385,7 +386,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="af_group_box">
|
<widget class="QGroupBox" name="af_group_box">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy vsizetype="Minimum" hsizetype="Preferred" >
|
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
@ -396,10 +397,10 @@
|
|||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
<item>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item rowspan="3" row="0" column="0" >
|
<item row="0" column="0" rowspan="3">
|
||||||
<widget class="QListWidget" name="formats">
|
<widget class="QListWidget" name="formats">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy vsizetype="Minimum" hsizetype="Minimum" >
|
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
@ -487,7 +488,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="bc_box">
|
<widget class="QGroupBox" name="bc_box">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy vsizetype="Expanding" hsizetype="Preferred" >
|
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
<verstretch>10</verstretch>
|
<verstretch>10</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
@ -499,7 +500,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="ImageView" name="cover">
|
<widget class="ImageView" name="cover">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy vsizetype="Expanding" hsizetype="Expanding" >
|
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
@ -588,7 +589,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="fetch_cover_button">
|
<widget class="QPushButton" name="fetch_cover_button">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Fetch cover image from server</string>
|
<string>Fetch &cover image from server</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -598,7 +599,7 @@
|
|||||||
<string>Change the username and/or password for your account at LibraryThing.com</string>
|
<string>Change the username and/or password for your account at LibraryThing.com</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Change password</string>
|
<string>Change &password</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -177,11 +177,11 @@ else:
|
|||||||
compatibility='%s works on OS X Tiger and above.'%(__appname__,),
|
compatibility='%s works on OS X Tiger and above.'%(__appname__,),
|
||||||
path=MOBILEREAD+file, app=__appname__,
|
path=MOBILEREAD+file, app=__appname__,
|
||||||
note=Markup(\
|
note=Markup(\
|
||||||
'''
|
u'''
|
||||||
<ol>
|
<ol>
|
||||||
<li>Before trying to use the command line tools, you must run the app at least once. This will ask you for you password and then setup the symbolic links for the command line tools.</li>
|
<li>Before trying to use the command line tools, you must run the app at least once. This will ask you for you password and then setup the symbolic links for the command line tools.</li>
|
||||||
<li>The app cannot be run from within the dmg. You must drag it to a folder on your filesystem (The Desktop, Applications, wherever).</li>
|
<li>The app cannot be run from within the dmg. You must drag it to a folder on your filesystem (The Desktop, Applications, wherever).</li>
|
||||||
<li>In order for localization of the user interface in your language, select your language in the configuration dialog (by clicking the hammer icon next to the search bar) and select your language.</li>
|
<li>In order for localization of the user interface in your language, select your language in the preferences (by pressing u\2318+P) and select your language.</li>
|
||||||
</ol>
|
</ol>
|
||||||
'''))
|
'''))
|
||||||
return 'binary.html', data, None
|
return 'binary.html', data, None
|
||||||
|
Loading…
x
Reference in New Issue
Block a user