Class: RhetButler::Stasis::HTMLTransform

Inherits:
DocumentTransform show all
Defined in:
lib/rhet-butler/stasis/html-transform.rb

Constant Summary collapse

%w[
  //a/@href
  //applet/@codebase
  //area/@href
  //base/@href
  //body/@background
  //frame/@longdesc
  //frame/@src
  //iframe/@longdesc
  //iframe/@src
  //img/@longdesc
  //img/@src
  //input/@src
  //link/@href
  //object/@codebase
  //object/@data
  //script/@src
  //audio/@src
  //command/@icon
  //embed/@src
  //html/@manifest
  //source/@src
  //video/@poster
  //video/@src
]

Instance Attribute Summary

Attributes inherited from DocumentTransform

#document, #queue, #target_path

Instance Method Summary collapse

Methods inherited from DocumentTransform

#document_source, #get_link_translation, #process, register, #save_document

Instance Method Details

#parse_documentObject



34
35
36
# File 'lib/rhet-butler/stasis/html-transform.rb', line 34

def parse_document
  @parsed = Nokogiri::HTML(document.body)
end

#render_documentObject



46
47
48
# File 'lib/rhet-butler/stasis/html-transform.rb', line 46

def render_document
  @parsed.to_html
end


38
39
40
41
42
43
44
# File 'lib/rhet-butler/stasis/html-transform.rb', line 38

def translate_links
  NAV_AND_EMBED.each do |xpath|
    @parsed.xpath(xpath).each do |attr|
      attr.value = get_link_translation(attr.value)
    end
  end
end