From 0d00c900cf271f3340d17cae44d62e238fdefdcc Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 23 Oct 2009 10:25:13 -0600 Subject: [PATCH 1/3] IGN:MOBI Output: Add an empty element at the start of every article --- src/calibre/ebooks/mobi/writer.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/calibre/ebooks/mobi/writer.py b/src/calibre/ebooks/mobi/writer.py index d1b4076cd9..e5d6433f78 100644 --- a/src/calibre/ebooks/mobi/writer.py +++ b/src/calibre/ebooks/mobi/writer.py @@ -248,6 +248,7 @@ class Serializer(object): self.breaks.append(buffer.tell() - 1) self.id_offsets[item.href] = buffer.tell() for elem in item.data.find(XHTML('body')): + buffer.write('') self.serialize_elem(elem, item) if self.write_page_breaks_after_item: buffer.write('') From eac47f65fa990ee7453115b5bf2df6ca03bdfdd0 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 23 Oct 2009 10:26:00 -0600 Subject: [PATCH 2/3] IGN:Update pmlml.py correctly --- src/calibre/ebooks/pml/pmlml.py | 64 +++++++++++++++++---------------- 1 file changed, 33 insertions(+), 31 deletions(-) diff --git a/src/calibre/ebooks/pml/pmlml.py b/src/calibre/ebooks/pml/pmlml.py index 8cce91f8ac..7b1813256e 100644 --- a/src/calibre/ebooks/pml/pmlml.py +++ b/src/calibre/ebooks/pml/pmlml.py @@ -85,11 +85,11 @@ class PMLMLizer(object): def pmlmlize_spine(self): self.image_hrefs = {} self.link_hrefs = {} - output = u'' - output += self.get_cover_page() - output += u'ghji87yhjko0Caliblre-toc-placeholder-for-insertion-later8ujko0987yjk' - output += self.get_text() - output = output.replace(u'ghji87yhjko0Caliblre-toc-placeholder-for-insertion-later8ujko0987yjk', self.get_toc()) + output = [u''] + output.append(self.get_cover_page()) + output.append(u'ghji87yhjko0Caliblre-toc-placeholder-for-insertion-later8ujko0987yjk') + output.append(self.get_text()) + output = ''.join(output).replace(u'ghji87yhjko0Caliblre-toc-placeholder-for-insertion-later8ujko0987yjk', self.get_toc()) output = self.clean_text(output) return output @@ -104,29 +104,29 @@ class PMLMLizer(object): item = self.oeb_book.manifest.hrefs[href] if item.spine_position is None: stylizer = Stylizer(item.data, item.href, self.oeb_book, self.opts.output_profile) - output += self.dump_text(item.data.find(XHTML('body')), stylizer, item) + output += ''.join(self.dump_text(item.data.find(XHTML('body')), stylizer, item)) return output def get_toc(self): - toc = u'' + toc = [u''] if self.opts.inline_toc: self.log.debug('Generating table of contents...') - toc += u'\\X0%s\\X0\n\n' % _('Table of Contents:') + toc.append(u'\\X0%s\\X0\n\n' % _('Table of Contents:')) for item in self.oeb_book.toc: if item.href in self.link_hrefs.keys(): - toc += '* \\q="#%s"%s\\q\n' % (self.link_hrefs[item.href], item.title) + toc.append('* \\q="#%s"%s\\q\n' % (self.link_hrefs[item.href], item.title)) else: self.oeb.warn('Ignoring toc item: %s not found in document.' % item) - return toc + return ''.join(toc) def get_text(self): - text = u'' + text = [u''] for item in self.oeb_book.spine: self.log.debug('Converting %s to PML markup...' % item.href) stylizer = Stylizer(item.data, item.href, self.oeb_book, self.opts.output_profile) - text += self.add_page_anchor(item) + text.append(self.add_page_anchor(item)) text += self.dump_text(item.data.find(XHTML('body')), stylizer, item) - return text + return ''.join(text) def add_page_anchor(self, page): return self.get_anchor(page, '') @@ -171,14 +171,14 @@ class PMLMLizer(object): def dump_text(self, elem, stylizer, page, tag_stack=[]): if not isinstance(elem.tag, basestring) \ or namespace(elem.tag) != XHTML_NS: - return u'' + return [u''] - text = u'' + text = [u''] style = stylizer.style(elem) if style['display'] in ('none', 'oeb-page-head', 'oeb-page-foot') \ or style['visibility'] == 'hidden': - return u'' + return [u''] tag = barename(elem.tag) tag_count = 0 @@ -198,23 +198,25 @@ class PMLMLizer(object): self.image_hrefs[page.abshref(elem.attrib['src'])] = 'cover.png' else: self.image_hrefs[page.abshref(elem.attrib['src'])] = image_name('%s' % len(self.image_hrefs.keys()), self.image_hrefs.keys()).strip('\x00') + text.append('\\m="%s"' % self.image_hrefs[page.abshref(elem.attrib['src'])]) if tag == 'hr': - text += '\\w' + w = '\\w' width = elem.get('width') if width: - text += '="%s%%"' % width + w += '="%s%%"' % width else: - text += '="50%"' + w += '="50%"' + text.append(w) # Process style information that needs holds a single tag # Commented out because every page in an OEB book starts with this style #if style['page-break-before'] == 'always': - # text += '\\p' + # text.append('\\p') pml_tag = TAG_MAP.get(tag, None) if pml_tag and pml_tag not in tag_stack: tag_count += 1 - text += '\\%s' % pml_tag + text.append('\\%s' % pml_tag) tag_stack.append(pml_tag) # Special processing of tags that require an argument. @@ -229,27 +231,27 @@ class PMLMLizer(object): if href not in self.link_hrefs.keys(): self.link_hrefs[href] = 'calibre_link-%s' % len(self.link_hrefs.keys()) href = self.link_hrefs[href] - text += '\\q="#%s"' % href + text.append('\\q="#%s"' % href) tag_count += 1 tag_stack.append('q') # Anchor ids id_name = elem.get('id') if id_name: - text += self.get_anchor(page, id_name) + text.append(self.get_anchor(page, id_name)) # Processes style information for s in STYLES: style_tag = s[1].get(style[s[0]], None) if style_tag and style_tag not in tag_stack: tag_count += 1 - text += '\\%s' % style_tag + text.append('\\%s' % style_tag) tag_stack.append(style_tag) # margin # Proccess tags that contain text. if hasattr(elem, 'text') and elem.text != None and elem.text.strip() != '': - text += self.elem_text(elem, tag_stack) + text.append(self.elem_text(elem, tag_stack)) for item in elem: text += self.dump_text(item, stylizer, page, tag_stack) @@ -259,16 +261,16 @@ class PMLMLizer(object): close_tag_list.insert(0, tag_stack.pop()) text += self.close_tags(close_tag_list) if tag in SEPARATE_TAGS: - text += os.linesep + os.linesep + text.append(os.linesep + os.linesep) if 'block' not in tag_stack: - text += os.linesep + os.linesep + text.append(os.linesep + os.linesep) #if style['page-break-after'] == 'always': - # text += '\\p' + # text.append('\\p') if hasattr(elem, 'tail') and elem.tail != None and elem.tail.strip() != '': - text += self.elem_tail(elem, tag_stack) + text.append(self.elem_tail(elem, tag_stack)) return text @@ -286,10 +288,10 @@ class PMLMLizer(object): return text def close_tags(self, tags): - text = u'' + text = [u''] for i in range(0, len(tags)): tag = tags.pop() if tag != 'block': - text += '\\%s' % tag + text.append('\\%s' % tag) return text From 46b1bd1b64061a4182dcc4eff566a3d5a3b91ee5 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 23 Oct 2009 10:44:58 -0600 Subject: [PATCH 3/3] IGN:Preliminarywindows driver for the e-shinebook --- resources/recipes/uncrate.recipe | 10 ++++++++++ src/calibre/customize/builtins.py | 3 ++- src/calibre/devices/eb600/driver.py | 8 ++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/resources/recipes/uncrate.recipe b/resources/recipes/uncrate.recipe index 225bba9d71..df18475dec 100644 --- a/resources/recipes/uncrate.recipe +++ b/resources/recipes/uncrate.recipe @@ -36,6 +36,16 @@ class Uncrate(BasicNewsRecipe): remove_tags_after = dict(name='div', attrs={'class':'serif'}) remove_tags = [dict(name=['object','link','script','iframe','form'])] + extra_css = ''' + .serif{font-family:Georgia,Rockwell,'Times New Roman',Times,serif; font-weight:normal; font-size: x-small; } + .lefttext{font-family:Georgia,Rockwell,'Times New Roman',Times,serif; font-weight:normal; font-size: x-small; } + h1{ font-family:Verdana,Arial,Helvetica,sans-serif;font-size:x-large; font-weight:bold;} + .byline{ font-family:Verdana,Arial,Helvetica,sans-serif;font-size: x-small; color:#FF4000;} + .posted{ font-family:Verdana,Arial,Helvetica,sans-serif;font-size: x-small;} + .answer{ font-family:Verdana,Arial,Helvetica,sans-serif;font-size: x-small;} + a{color:#FF4000;} + ''' + feeds = [(u'Articles', u'http://feeds.feedburner.com/uncrate')] def preprocess_html(self, soup): diff --git a/src/calibre/customize/builtins.py b/src/calibre/customize/builtins.py index e52d693bb5..443db49c78 100644 --- a/src/calibre/customize/builtins.py +++ b/src/calibre/customize/builtins.py @@ -361,7 +361,7 @@ from calibre.customize.profiles import input_profiles, output_profiles from calibre.devices.bebook.driver import BEBOOK, BEBOOK_MINI from calibre.devices.blackberry.driver import BLACKBERRY from calibre.devices.cybookg3.driver import CYBOOKG3, CYBOOK_OPUS -from calibre.devices.eb600.driver import EB600, COOL_ER +from calibre.devices.eb600.driver import EB600, COOL_ER, ESHINEBOOK from calibre.devices.iliad.driver import ILIAD from calibre.devices.irexdr.driver import IREXDR1000 from calibre.devices.jetbook.driver import JETBOOK @@ -424,6 +424,7 @@ plugins += [ ANDROID, CYBOOK_OPUS, COOL_ER, + ESHINEBOOK, ESLICK ] plugins += [x for x in list(locals().values()) if isinstance(x, type) and \ diff --git a/src/calibre/devices/eb600/driver.py b/src/calibre/devices/eb600/driver.py index fdd033b33f..2195cb3cb6 100644 --- a/src/calibre/devices/eb600/driver.py +++ b/src/calibre/devices/eb600/driver.py @@ -67,3 +67,11 @@ class COOL_ER(EB600): OSX_MAIN_MEM = 'COOL-ER eReader Media' EBOOK_DIR_MAIN = 'my docs' + +class ESHINEBOOK(EB600): + + FORMATS = ['epub', 'pdf', 'txt'] + + VENDOR_NAME = 'LONGSHIN' + WINDOWS_MAIN_MEM = 'ESHINEBOOK' +