Class: Epuber::Compiler::OPFGenerator

Inherits:
Generator
  • Object
show all
Defined in:
lib/epuber/compiler/opf_generator.rb

Constant Summary collapse

EPUB2_NAMESPACES =
{
  'xmlns' => 'http://www.idpf.org/2007/opf',
  'xmlns:dc' => 'http://purl.org/dc/elements/1.1/',
  'xmlns:opf' => 'http://www.idpf.org/2007/opf',
}.freeze
EPUB3_NAMESPACES =
{
  'prefix' => 'rendition: http://www.idpf.org/vocab/rendition/',
  'xmlns:epub' => 'http://www.idpf.org/2007/ops',
}.freeze
IBOOKS_NAMESPACES =
{
  'prefix' => 'rendition: http://www.idpf.org/vocab/rendition/# ibooks: http://vocabulary.itunes.apple.com/rdf/ibooks/vocabulary-extensions-1.0/',
  'xmlns:ibooks' => 'http://apple.com/ibooks/html-extensions',
}.freeze
LANDMARKS_MAP =
{

  # my favorite
  landmark_cover: 'cover',
  landmark_start_page: 'text',
  landmark_copyright: 'copyright-page',
  landmark_toc: 'toc',

  # others
  landmark_title: 'title-page',
  landmark_index: 'index',
  landmark_glossary: 'glossary',
  landmark_acknowledgements: 'acknowledgements',
  landmark_bibliography: 'bibliography',
  landmark_colophon: 'colophon',
  landmark_dedication: 'dedication',
  landmark_epigraph: 'epigraph',
  landmark_foreword: 'foreword',
  landmark_list_of_illustrations: 'loi',
  landmark_list_of_tables: 'lot',
  landmark_notes: 'notes',
  landmark_preface: 'preface',

}.freeze
PROPERTIES_MAP =
{
  cover_image: 'cover-image',
  navigation: 'nav',
  scripted: 'scripted',
  remote_resources: 'remote-resources',
  mathml: 'mathml',
}.freeze
OPF_UNIQUE_ID =
'bookid'

Instance Attribute Summary

Attributes inherited from Generator

#compilation_context

Instance Method Summary collapse

Methods inherited from Generator

#initialize

Constructor Details

This class inherits a constructor from Epuber::Compiler::Generator

Instance Method Details

#generate_opfNokogiri::XML::Document

Generates XML for opf document

Use method #to_s to generate nice string from XML document

Returns:

  • (Nokogiri::XML::Document)


72
73
74
75
76
77
78
79
80
81
# File 'lib/epuber/compiler/opf_generator.rb', line 72

def generate_opf
  generate_xml do |xml|
    xml.package(package_namespaces, :version => @target.epub_version, 'unique-identifier' => OPF_UNIQUE_ID) do
      
      generate_manifest
      generate_spine
      generate_guide
    end
  end
end