Skip to content

Instantly share code, notes, and snippets.

@pivotalcommon
Created February 23, 2011 20:40
Show Gist options
  • Save pivotalcommon/841140 to your computer and use it in GitHub Desktop.
Save pivotalcommon/841140 to your computer and use it in GitHub Desktop.
pulling legacy-js attributes from Body html
Thread.current[:current_site] = Site.find 8
include Rails.application.routes.url_helpers, LocationsHelper
def path_for_body(body)
page = body.pages.first
if page.is_a?(MiniPage)
mini_page_path_helper(page, page.location)
elsif page.is_a?(ContentPage)
content_page_path_helper(page)
else
page.id
end
end
bodies = PageBody.all.select { |b| !Nokogiri::HTML.parse(b.body).search("[data-legacy-js]").empty? }
legacy_js = bodies.map { |b| [ path_for_body(b), Nokogiri::HTML.parse(b.body).search("[data-legacy-js]").map { |n| n['data-legacy-js'] }] }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment