Created
February 23, 2011 20:40
-
-
Save pivotalcommon/841140 to your computer and use it in GitHub Desktop.
pulling legacy-js attributes from Body html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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