Skip to content

Commit

Permalink
Creating an import directory. Writing an importer to pull speaker pro…
Browse files Browse the repository at this point in the history
…files, and making modifications to Speakers as needed.
  • Loading branch information
knowtheory committed Mar 7, 2011
1 parent 779dbf0 commit 8d10b56
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/confoosed/speaker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ class Speaker
property :id, Serial
property :name, String, :length => 255
property :url, String, :length => 255, :format => :url
property :photo_url, String, :length => 255, :format => :url
property :profile, Text
property :twitter, String, :length => 255

has n, :sessions, :through => Resource
end
end

File renamed without changes.
18 changes: 18 additions & 0 deletions lib/import/speaker_profiles.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
require 'net/http'
require 'nokogiri'
require 'date'

Net::HTTP.start("confoo.ca") do |confoo|
Confoosed::Speaker.all.each do |speaker|
puts "Fetching profile for #{speaker.name}"
response = confoo.get(speaker.url)
speaker_page = Nokogiri::HTML(response.body)
container = speaker_page.css('div.speakers')
speaker.headshot = "http://confoo.ca" + container.css('img:first-child').first.attributes['src'].text
speaker.profile = container.children[container.children.index(container.css('img:first-child').first) + 1].text
container.css('div.social-medias ul li.twitter').map do |li|
speaker.twitter = li.css("a").attributes["href"].split("/").last
end
speaker.save
end
end

0 comments on commit 8d10b56

Please sign in to comment.