Class: Ubiquitously::Faves::Post
- Inherits:
-
Service::Post
- Object
- Base
- Service::Post
- Ubiquitously::Faves::Post
- Defined in:
- lib/ubiquitously/services/faves.rb
Instance Attribute Summary
Attributes inherited from Service::Post
#captcha, #categories, #description, #downvotes, #extension, #format, #image, #kind, #must_be_unique, #privacy, #rating, #remote, #service_id, #service_url, #slug, #source, #source_url, #state, #status, #tags, #title, #token, #upvotes, #url, #user, #vote
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Service::Post
Methods included from Loggable::Post
Methods included from Restful::Post
Methods included from Postable::Post
Methods included from Ownable::Post
Methods inherited from Base
Methods included from SubclassableCallbacks
Constructor Details
This class inherits a constructor from Ubiquitously::Service::Post
Class Method Details
.find(options = {}) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/ubiquitously/services/faves.rb', line 51 def find( = {}) result = [] user = [:user] user_url = "http://faves.com/users/#{user.username_for(self)}" html = Nokogiri::HTML(open(user_url).read) html.css(".userDotList li").each do |node| next if node["id"].blank? url = node.css(".note > a").first["href"] title = node.css(".note > p").first.text = [] node.xpath("a").each do |tag| << tag.text if tag["class"].blank? end record = new( :title => title, :url => url, :tags => ) if [:url] && [:url] == record.url return record end result << record end [:url] ? nil : result end |
Instance Method Details
#create ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/ubiquitously/services/faves.rb', line 17 def create page = agent.get("http://faves.com/createdot.aspx") form = page.form_with(:name => "createDotForm") form["noteText"] = description form["urlText"] = url form["subjectText"] = title form["tagsText"] = .join(", ") form.field_with(:name => "rateSelect")..each do |option| option.select if option.value.to_s == "5" end form.field_with(:name => "shareSelect")..each do |option| option.select if option.value.to_s.downcase == "public" end # hidden fields they fill out with javascript # form["imageUrl"] = "http://s3.amazonaws.com/github/ribbons/forkme_right_white_ffffff.png" # form["imageWidth"] = "149" # form["imageHeight"] = "149" # just before you submit the form they append the current time, so they have a range. # mimic the range of time :) form["authoringExpiry"] = form["authoringExpiry"] + "loadedtime=#{1.minute.ago.to_i * 1000}publishedtime=#{Time.now.to_i * 1000}" headers = { "Accept" => "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", "Keep-Alive" => "115", "Accept-Encoding" => "gzip,deflate" } unless debug? page = form.submit(nil, headers) end self end |