Class: Pagelime::Clients::XmlProcessor

Inherits:
Object
  • Object
show all
Defined in:
lib/pagelime/clients/xml_processor.rb

Constant Summary collapse

EDITABLE_REGION_CSS_SELECTOR =
".cms-editable"
SHARED_REGION_CSS_SELECTOR =
".cms-shared"

Instance Method Summary collapse

Instance Method Details

#process_document(storage, html, page_path = false) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/pagelime/clients/xml_processor.rb', line 10

def process_document(storage, html, page_path = false)
  Pagelime.logger.debug "PAGELIME CMS RACK PLUGIN: Document HTML: #{html.inspect}"
  
  doc = Nokogiri::HTML::Document.parse(html)
  
  # return original HTML if nil returned
  output = parse_document(storage, doc, page_path) || html
  
  if html == output
    Pagelime.logger.debug "PAGELIME CMS RACK PLUGIN: Document output: UNCHANGED!"
  else
    Pagelime.logger.debug "PAGELIME CMS RACK PLUGIN: Document output: #{output.inspect}"
  end
  
  output
end

#process_fragment(storage, html, page_path = false) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/pagelime/clients/xml_processor.rb', line 27

def process_fragment(storage, html, page_path = false)
  Pagelime.logger.debug "PAGELIME CMS RACK PLUGIN: Fragment HTML: #{html.inspect}"
  
  doc = Nokogiri::HTML::DocumentFragment.parse(html)
  
  # return original HTML if nil returned
  output = parse_document(storage, doc, page_path) || html
  
  if html == output
    Pagelime.logger.debug "PAGELIME CMS RACK PLUGIN: Fragment output: UNCHANGED!"
  else
    Pagelime.logger.debug "PAGELIME CMS RACK PLUGIN: Fragment output: #{output.inspect}"
  end
  
  output
end