This repository has been archived on 2024-03-16. You can view files and clone it, but cannot push or open issues or pull requests.
orbit-4-1/lib/parsers/parser_layout.rb

32 lines
1.0 KiB
Ruby

module ParserLayout
require 'nokogiri'
def parse_body(layout)
body = Nokogiri::HTML(layout.body)
body.css('.page_content').each do |content|
layout.layout_parts.build(:name => content['name'])
end
body.css('.page_menu').each do |menu|
layout.build_menu(:levels => 0, :values => {}) unless layout.menu
layout.menu.levels = i = menu['level'].to_i
layout.menu.values.merge!({'home' => menu['home']}) if i == 1
layout.menu.values.merge!({"id_#{i}" => menu['id'], "class_#{i}" => menu['class'], "li_class_#{i}" => menu['li_class'], "li_incremental_#{i}" => menu['li_incremental']})
end
end
def parse_body_for_images(design)
body = Nokogiri::HTML(design.layout.body)
body.css('.page_image').each do |page_image|
image = design.images.where( file: File.basename(page_image['src']))[0]
image.update_attributes(:name => File.basename(page_image['src']), :html_id => page_image['id'], :html_class => page_image['class']) if image
end
end
end