Class: EBPS::Conversion::Oebps::OpfFactory
- Inherits:
-
XmlFactory
- Object
- Factory
- XmlFactory
- EBPS::Conversion::Oebps::OpfFactory
- Defined in:
- lib/ebps/conversion/oebps.rb
Instance Attribute Summary
Attributes inherited from Factory
Instance Method Summary collapse
Methods inherited from XmlFactory
Methods inherited from Factory
Constructor Details
This class inherits a constructor from EBPS::Conversion::Oebps::XmlFactory
Instance Method Details
#guide ⇒ Object
330 331 332 333 334 335 |
# File 'lib/ebps/conversion/oebps.rb', line 330 def guide @builder.guide do |xml| xml.reference 'type' => 'toc', 'title' => EBPS.config.guide_index, 'href' => 'toc.html' end end |
#manifest ⇒ Object
336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 |
# File 'lib/ebps/conversion/oebps.rb', line 336 def manifest docs = imgs = 0 table = Hash[@ids.collect do |id| id[0,2] end] cover = File.basename EBPS.config.cover css = File.basename EBPS.config.stylesheet @builder.manifest do |xml| Dir.foreach @tmpdir do |file| file.force_encoding('utf-8') if match = /\.([^\.]+)$/.match(file) type = match[1] case type when /html?/ docs += 1 id = table[file] or raise "Unidentified Html-File '#{file}'" xml.item 'id' => id, 'href' => file, 'media-type' => 'application/xhtml+xml' when 'ncx' xml.item 'id' => 'toc', 'href' => file, 'media-type' => 'application/x-dtbncx+xml' when 'css' xml.item 'id' => 'css', 'href' => file, 'media-type' => 'text/css' else id = case file when cover 'cover' when css 'css' else imgs += 1 "image#{imgs}" end xml.item 'id' => id, 'href' => file, 'media-type' => "image/#{type.sub('jpg', 'jpeg')}" end end end end end |
#metadata ⇒ Object
375 376 377 378 379 380 381 382 383 384 385 386 387 |
# File 'lib/ebps/conversion/oebps.rb', line 375 def @builder. 'xmlns:dc' => 'http://purl.org/dc/elements/1.1/', 'xmlns:opf'=> 'http://www.idpf.org/2007/opf' do |xml| xml.dc :title, EBPS.config.title || @subject.first.title xml.dc :language, EBPS.config.language xml.dc :identifier, @uid, 'id' => 'uid' xml.dc :date, Date.today.strftime('%Y-%m-%d') if = EBPS.config. xml.dc :creator, end xml. 'name' => 'cover', 'content' => 'cover' end end |
#spine ⇒ Object
388 389 390 391 392 393 394 |
# File 'lib/ebps/conversion/oebps.rb', line 388 def spine @builder.spine 'toc' => 'toc' do |xml| @ids.each do |file, id| xml.itemref 'idref' => id if id end end end |
#to_opf ⇒ Object
395 396 397 398 399 400 401 402 403 404 |
# File 'lib/ebps/conversion/oebps.rb', line 395 def to_opf @builder.package 'version' => '2.0', 'xmlns' => 'http://www.idpf.org/2007/opf', 'unique-identifier' => 'uid' do |xml| manifest spine guide end end |