Method: Creng::FileProcessor.processBackgroundPage

Defined in:
lib/creng/file_processor.rb

.processBackgroundPage(path, manifest_text) ⇒ Object



147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
# File 'lib/creng/file_processor.rb', line 147

def self.processBackgroundPage path, manifest_text

  if File.file? "#{path}/build/html/background.html"
    background_page = "#{path}/build/html/background.html"
    background_persistent = false
  elsif File.file? "#{path}/build/html/background_persistent.html"
    background_page = "#{path}/build/html/background_persistent.html"
    #renaming to default
    File.rename background_page, "#{path}/build/html/background.html"
    background_persistent = true
  else
    background_page = nil
    background_persistent = nil
  end

  unless background_page.nil?
    manifest_text = manifest_text.gsub(/(\"persistent\")\s?\:\s?(true|false)/, "\"persistent\": #{background_persistent}")
  else
    manifest_text = manifest_text.gsub(/(\"background\")\s?\:\s?(\{(.|\n)*\}\,)/, "")
   
  end 
   

    puts "    processed html/background.html"
    manifest_text

end