Class: Ubiquitously::Tweako::Post

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

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

Instance Method Details

#createObject



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/ubiquitously/services/tweako.rb', line 32

def create
  page = agent.get("http://www.tweako.com/node/add/storylink")
  form = page.forms.detect { |form| form.form_node["id"] == "node-form" }
  
  form["edit[title]"] = token[:title]
  form["edit[vote_storylink_url]"] = token[:url]
  form.field_with(:name => "edit[taxonomy][1]").options.each do |option|
    option.select if option.value.to_s == "11"
  end
  form["edit[taxonomy][tags][2]"] = token[:tags]
  form["edit[body]"] = token[:description]
  form["op"] = "Submit"
  
  unless debug?
    page = form.submit
  end
  
  true
end

#tokenizeObject

Either your first 400 characters will be used, or you can determine where the teaser ends by starting a new paragraph before the first 400 characters. Make sure there is no text formatting or images in the teasers!

A comma-separated list of terms describing this content. Example: photoshop, free software. Limit the amount of terms to a maximum of 6. Please choose relevent and descriptive terms. Enter tags in ALL lower-case letters, and ensure spelling is correct.



25
26
27
28
29
30
# File 'lib/ubiquitously/services/tweako.rb', line 25

def tokenize
  super.merge(
    :description => self.description[0..400],
    :tags => self.tags[0..6].taggify(" ", ", ")
  )
end