mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 10:44:09 -04:00
Sync to trunk.
This commit is contained in:
commit
9e645af067
@ -328,6 +328,7 @@ class HTMLInput(InputFormatPlugin):
|
|||||||
|
|
||||||
|
|
||||||
filelist = get_filelist(htmlpath, basedir, opts, log)
|
filelist = get_filelist(htmlpath, basedir, opts, log)
|
||||||
|
filelist = [f for f in filelist if not f.is_binary]
|
||||||
htmlfile_map = {}
|
htmlfile_map = {}
|
||||||
for f in filelist:
|
for f in filelist:
|
||||||
path = f.path
|
path = f.path
|
||||||
@ -336,6 +337,7 @@ class HTMLInput(InputFormatPlugin):
|
|||||||
id, href = oeb.manifest.generate(id='html', href=bname)
|
id, href = oeb.manifest.generate(id='html', href=bname)
|
||||||
htmlfile_map[path] = href
|
htmlfile_map[path] = href
|
||||||
item = oeb.manifest.add(id, href, 'text/html')
|
item = oeb.manifest.add(id, href, 'text/html')
|
||||||
|
item.html_input_href = bname
|
||||||
oeb.spine.add(item, True)
|
oeb.spine.add(item, True)
|
||||||
|
|
||||||
self.added_resources = {}
|
self.added_resources = {}
|
||||||
@ -409,8 +411,9 @@ class HTMLInput(InputFormatPlugin):
|
|||||||
if not islinux:
|
if not islinux:
|
||||||
link = link.lower()
|
link = link.lower()
|
||||||
if link not in self.added_resources:
|
if link not in self.added_resources:
|
||||||
|
bhref = os.path.basename(link)
|
||||||
id, href = self.oeb.manifest.generate(id='added',
|
id, href = self.oeb.manifest.generate(id='added',
|
||||||
href=os.path.basename(link))
|
href=bhref)
|
||||||
self.oeb.log.debug('Added', link)
|
self.oeb.log.debug('Added', link)
|
||||||
self.oeb.container = self.DirContainer(os.path.dirname(link),
|
self.oeb.container = self.DirContainer(os.path.dirname(link),
|
||||||
self.oeb.log)
|
self.oeb.log)
|
||||||
@ -418,7 +421,9 @@ class HTMLInput(InputFormatPlugin):
|
|||||||
guessed = self.guess_type(href)[0]
|
guessed = self.guess_type(href)[0]
|
||||||
media_type = guessed or self.BINARY_MIME
|
media_type = guessed or self.BINARY_MIME
|
||||||
|
|
||||||
self.oeb.manifest.add(id, href, media_type).data
|
item = self.oeb.manifest.add(id, href, media_type)
|
||||||
|
item.html_input_href = bhref
|
||||||
|
item.data
|
||||||
self.added_resources[link] = href
|
self.added_resources[link] = href
|
||||||
|
|
||||||
nlink = self.added_resources[link]
|
nlink = self.added_resources[link]
|
||||||
|
@ -790,10 +790,10 @@ class Manifest(object):
|
|||||||
data = first_pass(data)
|
data = first_pass(data)
|
||||||
# Force into the XHTML namespace
|
# Force into the XHTML namespace
|
||||||
if barename(data.tag) != 'html':
|
if barename(data.tag) != 'html':
|
||||||
self.log.warn('File %r does not appear to be (X)HTML'%self.href)
|
self.oeb.log.warn('File %r does not appear to be (X)HTML'%self.href)
|
||||||
nroot = etree.fromstring('<html></html>')
|
nroot = etree.fromstring('<html></html>')
|
||||||
for child in list(data):
|
for child in list(data):
|
||||||
child.getparent.remove(child)
|
child.getparent().remove(child)
|
||||||
nroot.append(child)
|
nroot.append(child)
|
||||||
data = nroot
|
data = nroot
|
||||||
elif not namespace(data.tag):
|
elif not namespace(data.tag):
|
||||||
@ -927,7 +927,8 @@ class Manifest(object):
|
|||||||
if data is None:
|
if data is None:
|
||||||
if self._loader is None:
|
if self._loader is None:
|
||||||
return None
|
return None
|
||||||
data = self._loader(self.href)
|
data = self._loader(getattr(self, 'html_input_href',
|
||||||
|
self.href))
|
||||||
if not isinstance(data, basestring):
|
if not isinstance(data, basestring):
|
||||||
pass # already parsed
|
pass # already parsed
|
||||||
elif self.media_type.lower() in OEB_DOCS:
|
elif self.media_type.lower() in OEB_DOCS:
|
||||||
|
@ -45,6 +45,9 @@
|
|||||||
<property name="alignment">
|
<property name="alignment">
|
||||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="buddy">
|
||||||
|
<cstring>authors</cstring>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="2" column="0">
|
||||||
@ -55,6 +58,9 @@
|
|||||||
<property name="alignment">
|
<property name="alignment">
|
||||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="buddy">
|
||||||
|
<cstring>author_sort</cstring>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="1" colspan="2">
|
<item row="2" column="1" colspan="2">
|
||||||
@ -104,6 +110,9 @@
|
|||||||
<property name="alignment">
|
<property name="alignment">
|
||||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="buddy">
|
||||||
|
<cstring>publisher</cstring>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="5" column="0">
|
<item row="5" column="0">
|
||||||
@ -262,6 +271,19 @@
|
|||||||
<header>widgets.h</header>
|
<header>widgets.h</header>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
|
<tabstops>
|
||||||
|
<tabstop>authors</tabstop>
|
||||||
|
<tabstop>auto_author_sort</tabstop>
|
||||||
|
<tabstop>author_sort</tabstop>
|
||||||
|
<tabstop>rating</tabstop>
|
||||||
|
<tabstop>publisher</tabstop>
|
||||||
|
<tabstop>tag_editor_button</tabstop>
|
||||||
|
<tabstop>tags</tabstop>
|
||||||
|
<tabstop>remove_tags</tabstop>
|
||||||
|
<tabstop>series</tabstop>
|
||||||
|
<tabstop>remove_format</tabstop>
|
||||||
|
<tabstop>button_box</tabstop>
|
||||||
|
</tabstops>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="../images.qrc"/>
|
<include location="../images.qrc"/>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -844,14 +844,15 @@ class OnDeviceSearch(SearchQueryParser):
|
|||||||
def get_matches(self, location, query):
|
def get_matches(self, location, query):
|
||||||
location = location.lower().strip()
|
location = location.lower().strip()
|
||||||
query = query.lower().strip()
|
query = query.lower().strip()
|
||||||
if location not in ('title', 'authors', 'tags', 'all'):
|
if location not in ('title', 'author', 'tag', 'all', 'format'):
|
||||||
return set([])
|
return set([])
|
||||||
matches = set([])
|
matches = set([])
|
||||||
locations = ['title', 'authors', 'tags'] if location == 'all' else [location]
|
locations = ['title', 'author', 'tag', 'format'] if location == 'all' else [location]
|
||||||
q = {
|
q = {
|
||||||
'title' : lambda x : getattr(x, 'title').lower(),
|
'title' : lambda x : getattr(x, 'title').lower(),
|
||||||
'authors': lambda x: getattr(x, 'authors').lower(),
|
'author': lambda x: getattr(x, 'authors').lower(),
|
||||||
'tags':lambda x: ','.join(getattr(x, 'tags')).lower()
|
'tag':lambda x: ','.join(getattr(x, 'tags')).lower(),
|
||||||
|
'format':lambda x: os.path.splitext(x.path)[1].lower()
|
||||||
}
|
}
|
||||||
for i, v in enumerate(locations):
|
for i, v in enumerate(locations):
|
||||||
locations[i] = q[v]
|
locations[i] = q[v]
|
||||||
@ -870,7 +871,7 @@ class DeviceBooksModel(BooksModel):
|
|||||||
self.db = []
|
self.db = []
|
||||||
self.map = []
|
self.map = []
|
||||||
self.sorted_map = []
|
self.sorted_map = []
|
||||||
self.unknown = str(self.trUtf8('Unknown'))
|
self.unknown = _('Unknown')
|
||||||
self.marked_for_deletion = {}
|
self.marked_for_deletion = {}
|
||||||
self.search_engine = OnDeviceSearch(self)
|
self.search_engine = OnDeviceSearch(self)
|
||||||
self.editable = True
|
self.editable = True
|
||||||
|
Loading…
x
Reference in New Issue
Block a user