Logo Search packages:      
Sourcecode: calibre version File versions

def calibre::web::feeds::news::BasicNewsRecipe::default_cover (   self,
  cover_file 
)

Create a generic cover for recipes that dont have a cover

Definition at line 806 of file news.py.

00806                                        :
        '''
        Create a generic cover for recipes that dont have a cover
        '''
        from calibre.gui2 import is_ok_to_use_qt
        if not is_ok_to_use_qt():
            return False
        img_data = open(I('library.png'), 'rb').read()
        tdir = PersistentTemporaryDirectory('_default_cover')
        img = os.path.join(tdir, 'logo.png')
        with open(img, 'wb') as g:
            g.write(img_data)
        img = os.path.basename(img)
        html= u'''\
        <html>
            <head>
                <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
                <style type="text/css">
                    body {
                        background: white no-repeat fixed center center;
                        text-align: center;
                        vertical-align: center;
                        overflow: hidden;
                        font-size: 18px;
                    }
                    h1 { font-family: serif; }
                    h2, h4 { font-family: monospace; }
                </style>
            </head>
            <body>
                <h1>%(title)s</h1>
                <br/><br/>
                <div style="position:relative">
                    <div style="position: absolute; left: 0; top: 0; width:100%%; height:100%%; vertical-align:center">
                        <img src="%(img)s" alt="calibre" style="opacity:0.3"/>
                    </div>
                    <div style="position: absolute; left: 0; top: 0; width:100%%; height:100%%; vertical-align:center">
                        <h2>%(date)s</h2>
                        <br/><br/><br/><br/><br/>
                        <h3>%(author)s</h3>
                        <br/><br/></br/><br/><br/><br/><br/><br/><br/>
                        <h4>Produced by %(app)s</h4>
                    </div>
                </div>
            </body>
        </html>
        '''%dict(title=self.title if isinstance(self.title, unicode) else self.title.decode(preferred_encoding, 'replace'),
                 author=self.__author__ if isinstance(self.__author__, unicode) else self.__author__.decode(preferred_encoding, 'replace'),
                 date=strftime(self.timefmt),
                 app=__appname__ +' '+__version__,
                 img=img)
        hf = os.path.join(tdir, 'cover.htm')
        with open(hf, 'wb') as f:
            f.write(html.encode('utf-8'))
        renderer = render_html(hf)
        if renderer.tb is not None:
            self.log.warning('Failed to render default cover')
            self.log.debug(renderer.tb)
        else:
            cover_file.write(renderer.data)
            cover_file.flush()
        return True


    def create_opf(self, feeds, dir=None):


Generated by  Doxygen 1.6.0   Back to index