require 'nokogiri' module RailsConnector class ContentConversion def self.convert_html_links(input, request_host, request_port) doc = Nokogiri::HTML.parse("
#{input}
") doc.css('body a').each do |a_tag| if href = a_tag.attributes['href'] link = Link.parse(href.value, request_host, request_port) href.value = link.to_cms_api_html_url end end doc.css('body img').each do |img_tag| if src = img_tag.attributes['src'] link = Link.parse(src.value, request_host, request_port) src.value = link.to_cms_api_html_url end end new_html = doc.css('body div.internal_jump_point').inner_html nbsp = Nokogiri::HTML(" ").text new_html.gsub(nbsp, " ") end def self.convert_linklist_urls(linklist, request_host, request_port) linklist.map do |link_data| if link_data.has_key?(:url) link_data.delete(:obj_id) url = link_data.delete(:url) link = Link.parse(url, request_host, request_port) link_data.merge!(link.to_cms_api_linklist_params) end link_data end end end end