Sha256: 09b24471de9287a395f2045efb54799e691ea45a629ba87e6e198b26691ff685

Contents?: true

Size: 1.28 KB

Versions: 18

Compression:

Stored size: 1.28 KB

Contents

module Verku
  module TOC
    class Epub
      attr_accessor :navigation

      def initialize(navigation)
        @navigation = navigation
      end

      def to_html
        ERB.new(template).result OpenStruct.new(:navigation => navigation).instance_eval{ binding }
      end

      def template
        <<-HTML.strip_heredoc.force_encoding("utf-8")
          <?xml version="1.0" encoding="utf-8" ?>
          <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
          <html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
            <head>
              <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
              <link rel="stylesheet" type="text/css" href="epub.css"/>
              <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />
              <title>Table of Contents</title>
            </head>
            <body>
              <div id="toc">
                <ul>
                  <% navigation.each do |nav| %>
                    <li>
                      <a href="<%= nav[:content] %>"><%= nav[:label] %></a>
                    </li>
                  <% end %>
                </ul>
              </div>
            </body>
          </html>
        HTML
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
verku-0.16.10 lib/verku/toc/epub.rb
verku-0.16.9 lib/verku/toc/epub.rb
verku-0.16.8 lib/verku/toc/epub.rb
verku-0.16.7 lib/verku/toc/epub.rb
verku-0.16.6 lib/verku/toc/epub.rb
verku-0.16.5 lib/verku/toc/epub.rb
verku-0.16.4 lib/verku/toc/epub.rb
verku-0.16.3 lib/verku/toc/epub.rb
verku-0.16.2 lib/verku/toc/epub.rb
verku-0.16.1 lib/verku/toc/epub.rb
verku-0.16.0 lib/verku/toc/epub.rb
verku-0.15.0 lib/verku/toc/epub.rb
verku-0.14.1 lib/verku/toc/epub.rb
verku-0.14.0 lib/verku/toc/epub.rb
verku-0.10.1 lib/verku/toc/epub.rb
verku-0.10.0 lib/verku/toc/epub.rb
verku-0.8.1.0 lib/verku/toc/epub.rb
verku-0.8.0.p lib/verku/toc/epub.rb