Class: Ubiquitously::Diigo::Post

Inherits:
Service::Post show all
Defined in:
lib/ubiquitously/services/diigo.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

#access_token, #initialize

Methods included from Loggable::Post

included

Methods included from Restful::Post

included

Methods included from Postable::Post

included

Methods included from Ownable::Post

included

Methods inherited from Base

#apply, #debug?

Methods included from SubclassableCallbacks

included, override

Constructor Details

This class inherits a constructor from Ubiquitously::Service::Post

Class Method Details

.find(options = {}) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/ubiquitously/services/diigo.rb', line 41

def find(options = {})
  records = []
  user = options[:user]
  user_url = "http://secure.diigo.com/rss/user/#{user.username_for(self)}"
  xml = Nokogiri::XML(open(user_url).read)
  
  urls = url_permutations(options[:url])
  
  xml.css("item").each do |node|
    title = node.css("title").first.text
    url   = node.css("link").first.text
    description = node.css("description").first.text
    record = new(
      :title => title,
      :url => url,
      :description => description,
      :user => user
    )
    return record if urls.include?(record.url)
    records << record
  end
  
  options[:url] ? nil : records
end

Instance Method Details

#createObject



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/ubiquitously/services/diigo.rb', line 26

def create
  page = agent.get("https://secure.diigo.com/item/new/bookmark")
  form = page.forms.detect { |form| form.form_node["id"] == "newBookmarkForm" }
  form["url"] = token[:url]
  form["title"] = token[:title]
  form["description"] = token[:description]
  # tags are space separated. Use " " for tag with multiple words.
  form["tags"] = token[:tags]
  
  unless debug?
    page = form.submit
  end
end

#tokenizeObject

tags are space separated. Use “ ” for tag with multiple words.



22
23
24
# File 'lib/ubiquitously/services/diigo.rb', line 22

def tokenize
  super.merge(:tags => tags.taggify(" ", " "))
end