mirror of
				https://github.com/kovidgoyal/calibre.git
				synced 2025-11-03 19:17:02 -05:00 
			
		
		
		
	output improvements
This commit is contained in:
		
							parent
							
								
									eadf98bfd0
								
							
						
					
					
						commit
						c98887eddb
					
				@ -5,20 +5,45 @@ ${head_content}$
 | 
			
		||||
</head>
 | 
			
		||||
<body>
 | 
			
		||||
 | 
			
		||||
<div class="meta">
 | 
			
		||||
  <div class="metaTitle">
 | 
			
		||||
  ${pos1=1}$
 | 
			
		||||
  ${for title in meta.titles():}$
 | 
			
		||||
    ${if pos1:}$
 | 
			
		||||
    <h1>${print title}$</h1>
 | 
			
		||||
    ${:else:}$
 | 
			
		||||
    <div class="metaSubtitle">${print title}$</div>
 | 
			
		||||
    ${:endif}$
 | 
			
		||||
    ${pos1=0}$
 | 
			
		||||
  ${:endfor}$
 | 
			
		||||
  </div>
 | 
			
		||||
  <div class="metaAuthor">
 | 
			
		||||
    ${print ', '.join(meta.creators())}$
 | 
			
		||||
  </div>
 | 
			
		||||
</div>
 | 
			
		||||
 | 
			
		||||
<div class="toc">
 | 
			
		||||
  Table of contents
 | 
			
		||||
  <h2>Table of contents</h2>
 | 
			
		||||
  ${print toc()}$
 | 
			
		||||
</div>
 | 
			
		||||
 | 
			
		||||
${ebookContent}$
 | 
			
		||||
<div class="ebookContent">
 | 
			
		||||
 | 
			
		||||
  ${ebookContent}$
 | 
			
		||||
 | 
			
		||||
  <div class="ebookNavigation">
 | 
			
		||||
    ${if prevLink:}$
 | 
			
		||||
      <a href="${prevLink}$">previous page</a>
 | 
			
		||||
    ${:endif}$
 | 
			
		||||
 | 
			
		||||
    ${if nextLink:}$
 | 
			
		||||
      <a href="${nextLink}$">next page</a>
 | 
			
		||||
    ${:endif}$
 | 
			
		||||
  </div>
 | 
			
		||||
 | 
			
		||||
</div>
 | 
			
		||||
 | 
			
		||||
${if prevLink:}$
 | 
			
		||||
<a href="${prevLink}$">previous page</a>
 | 
			
		||||
${:endif}$
 | 
			
		||||
 | 
			
		||||
${if nextLink:}$
 | 
			
		||||
<a href="${nextLink}$">next page</a>
 | 
			
		||||
${:endif}$
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
</body>
 | 
			
		||||
 | 
			
		||||
@ -14,14 +14,30 @@ ${:endfor}$
 | 
			
		||||
</head>
 | 
			
		||||
<body>
 | 
			
		||||
 | 
			
		||||
${for title in meta.titles():}$
 | 
			
		||||
  <h1>${print title}$</h1>
 | 
			
		||||
${:endfor}$
 | 
			
		||||
<div class="meta">
 | 
			
		||||
  <div class="metaTitle">
 | 
			
		||||
  ${pos1=1}$
 | 
			
		||||
  ${for title in meta.titles():}$
 | 
			
		||||
    ${if pos1:}$
 | 
			
		||||
    <h1>${print title}$</h1>
 | 
			
		||||
    ${:else:}$
 | 
			
		||||
    <div class="metaSubtitle">${print title}$</div>
 | 
			
		||||
    ${:endif}$
 | 
			
		||||
    ${pos1=0}$
 | 
			
		||||
  ${:endfor}$
 | 
			
		||||
  </div>
 | 
			
		||||
  <div class="metaAuthor">
 | 
			
		||||
    ${print ', '.join(meta.creators())}$
 | 
			
		||||
  </div>
 | 
			
		||||
</div>
 | 
			
		||||
 | 
			
		||||
${print ', '.join(meta.creators())}$
 | 
			
		||||
<h2>Table of contents</h2>
 | 
			
		||||
 | 
			
		||||
<h1>Table of contents</h1>
 | 
			
		||||
${toc}$
 | 
			
		||||
<div class="ebookContent">
 | 
			
		||||
 | 
			
		||||
  ${toc}$
 | 
			
		||||
 | 
			
		||||
</div>
 | 
			
		||||
 | 
			
		||||
</body>
 | 
			
		||||
</html>
 | 
			
		||||
 | 
			
		||||
@ -60,6 +60,7 @@ class HTMLOutput(OutputFormatPlugin):
 | 
			
		||||
        self.opts = opts
 | 
			
		||||
        output_file = output_path
 | 
			
		||||
        output_dir = re.sub(r'\.html', '', output_path)+'_files'
 | 
			
		||||
        meta=EasyMeta(oeb_book.metadata)
 | 
			
		||||
        if not exists(output_dir):
 | 
			
		||||
            os.makedirs(output_dir)
 | 
			
		||||
 | 
			
		||||
@ -68,7 +69,7 @@ class HTMLOutput(OutputFormatPlugin):
 | 
			
		||||
            html_toc = self.generate_html_toc(oeb_book, output_file, output_dir)
 | 
			
		||||
            templite = Templite(P('templates/html_export_default_index.tmpl', data=True))
 | 
			
		||||
            print oeb_book.metadata.items
 | 
			
		||||
            t = templite.render(toc=html_toc, meta=EasyMeta(oeb_book.metadata))
 | 
			
		||||
            t = templite.render(toc=html_toc, meta=meta)
 | 
			
		||||
            f.write(t)
 | 
			
		||||
 | 
			
		||||
        with CurrentDir(output_dir):
 | 
			
		||||
@ -118,7 +119,7 @@ class HTMLOutput(OutputFormatPlugin):
 | 
			
		||||
                # render template
 | 
			
		||||
                templite = Templite(P('templates/html_export_default.tmpl', data=True))
 | 
			
		||||
                toc = lambda: self.generate_html_toc(oeb_book, path, output_dir)
 | 
			
		||||
                t = templite.render(ebookContent=ebook_content, prevLink=prevLink, nextLink=nextLink, toc=toc, head_content=head_content)
 | 
			
		||||
                t = templite.render(ebookContent=ebook_content, prevLink=prevLink, nextLink=nextLink, toc=toc, head_content=head_content, meta=meta)
 | 
			
		||||
 | 
			
		||||
                # write html to file
 | 
			
		||||
                with open(path, 'wb') as f:
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user