Sha256: e94bb15ec5ee957dd8071e09bf4bb13c7df0228e9f2252d8fd0836530fe594d1

Contents?: true

Size: 1.88 KB

Versions: 1

Compression:

Stored size: 1.88 KB

Contents

module Ubiquitously
  module Propeller
    class Account < Ubiquitously::Service::Account
      def login
        page = agent.get("http://www.propeller.com/signin/")
        form = page.forms.detect {|form| form.form_node["class"] == "ajax-form"}
        form["member_name"] = username
        form["password"]    = password
        form["submit"]      = "sign in" # require to get around the ajax
        page                = form.submit

        authorize!((page.body !~ /Invalid member name or password/i) && (page.body !~ /ajax-form/))
      end
    end
    
    class Post < Ubiquitously::Service::Post
      # title max == 150
      def tokenize
        super.merge(:tags => tags.taggify("_", " "))
      end
      
      def create
        # url
        page        = agent.get("http://www.propeller.com/story/submit/")
        form        = page.forms.detect {|form| form.form_node["method"].downcase == "post"}
        form["url"] = token[:url]
        
        # details
        # http://www.propeller.com/story/submit/content/
        page        = form.submit
        form        = page.forms.detect {|form| form.form_node["method"].downcase == "post"}

        form.radiobuttons_with(:name => "title_multi").each do |button|
          button.check if button.value == "-1"
        end
        
        form["title_multi_text"] = token[:title]
        form["description"]      = token[:description]
        # separate by space, multi words are underscored
        form["user_tags"]        = token[:tags]
        
        form.radiobuttons_with(:name => "category").each do |button|
          button.check if button.value.to_s == "18"
        end
        
        # http://www.propeller.com/story/submit/preview/
        page = form.submit

        # approve
        page.forms[1].submit
        
        unless debug?
          page = form.submit
        end
        
        true
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ubiquitously-0.1.0 lib/ubiquitously/services/propeller.rb