module RailsConnector module FopOnRails module Document # :nodoc: all module Images def self.absolutize_src_attrs(xml, url) @url = URI.parse(url) xml.elements.each('//img') do |img| url = URI.parse(img.attributes['src']) unless (url.host == @url.host) url = @url.merge(url) end img.attributes['src'] = url.to_s end xml end def self.dump_images(xml) xml.elements.each('//img') do |img| unless URI.parse(src = img.attributes['src']).absolute? if relative_url_root = ActionController::Base.config.relative_url_root src.sub!(/\A#{relative_url_root}/i, '') end params = Rails.application.routes.recognize_path(src) if params[:controller] == 'rails_connector/cms_dispatch' and params[:id] img.attributes['src'] = Obj.find(params[:id]).body_data_path end end end xml end end end end end