Class: Foliokit::ManifestArticle

Inherits:
Manifest
  • Object
show all
Defined in:
lib/foliokit/manifest_article.rb

Instance Method Summary collapse

Methods inherited from Manifest

#content_stack_ids, #content_stacks, #device_height, #device_width, element_base, #narrow_dimension, #overlay_ids, #referenced_ids, #subfolios, #target_dimension, #valid_overlay_id?, #valid_referenced_id?, #wide_dimension

Constructor Details

#initialize(file, package) ⇒ ManifestArticle

Returns a new instance of ManifestArticle.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/foliokit/manifest_article.rb', line 6

def initialize(file, package)
  article = Nokogiri::XML(file.read).css("article").first
  # article["smoothScrolling"] = true
  article.css("content page rendition").each do |rendition|
    rendition.name = "assetRendition"
    rendition["source"] = rendition.remove_attribute("href")
  end
  article.css("content page").each do |page|
    page.name = "asset"
  end

  # build manifest
  root_manifest = package.root_package.manifest
  xml = Nokogiri::XML::Builder.new do |b|
    b.folio(id: file.dir.name, version: root_manifest.version, targetViewer: root_manifest.target_viewer, lastUpdated: root_manifest.last_updated, date: root_manifest.date, bindingDirection: root_manifest.binding_direction, orientation: root_manifest.orientation, layout: article["layout"]) do
      b. do
        b.description root_manifest.description
        b.magazineTitle root_manifest.title
        b.folioNumber root_manifest.title
      end
      b.targetDimensions do
        b.targetDimension(wideDimension: root_manifest.wide_dimension, narrowDimension: root_manifest.narrow_dimension)
      end
      b.contentStacks do
        b.contentStack(id: file.dir.name, version: article["version"], lastUpdated: article["lastUpdated"], smoothScrolling: article["smoothScrolling"], layout: article["layout"], alwaysDisplayOverlays: article["alwaysDisplayOverlays"], orientation: article["orientation"]) do
          b.content do
            b.regions do
              b.region do
                b.bounds do
                  b.rectangle(x: 0, y: 0, width: article[:width], height: article[:height])
                end
              end
            end
            b.assets do |assets_node|
              article.css("content asset").each do |asset|
                b.parent << asset
              end
            end
            if file.dir.file("Overlays.xml").exists?
              b.parent << Nokogiri::XML(file.dir.file("Overlays.xml").read).css("overlays").first
            end
          end
        end
      end
    end
  end
  super(xml.doc.root, package)
end