Module: Impostor::Wwf80::Post

Defined in:
lib/impostor/wwf80.rb

Instance Method Summary collapse

Instance Method Details

#get_post_form(page) ⇒ Object

return the form used for posting a message from the reply page



79
80
81
82
83
# File 'lib/impostor/wwf80.rb', line 79

def get_post_form(page)
  form = page.form('frmMessageForm')
  raise Impostor::PostError.new("unknown reply page format") unless form
  form
end

#get_post_from_result(page) ⇒ Object

get post id from the result of posting the message form FIXME this validation is copied into topic module as well



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/impostor/wwf80.rb', line 89

def get_post_from_result(page)
  error = page.search("//table[@class='errorTable']")
  if error
    msgs = error.search("//td")

    # throttled
    too_many = msgs.last && msgs.last.text && msgs.last.text =~ /You have exceeded the number of posts permitted in the time span/
    raise ThrottledError.new(msgs.last.text.gsub(/\s+/m,' ').strip) if too_many

    # general error
    had_error = error.last && error.last.text && error.last.text =~ /Error: Message Not Posted/
    raise Impostor::PostError.new(error.last.text.gsub(/\s+/m,' ').strip) if had_error
  end

  kv = page.links.collect{ |l| l.uri }.compact.
                  collect{ |l| l.query }.compact.
                  collect{ |q| q.split('&')}.flatten.
                  detect{|kv| kv =~ /^PID=/ }
  postid = URI.unescape(kv).split('#').first.split('=').last.to_i
  raise Impostor::PostError.new("Message did not post.") if postid.zero?
  postid
end

#get_reply_uri(forum, topic) ⇒ Object

return a uri used to fetch the reply page based on the forum, topic, and message



70
71
72
73
74
# File 'lib/impostor/wwf80.rb', line 70

def get_reply_uri(forum, topic)
  uri = URI.join(self.config.app_root, self.config.config(:new_reply_page))
  uri.query = "TID=#{topic}"
  uri
end

#post(forum, topic, message) ⇒ Object

:nodoc:



61
62
63
64
# File 'lib/impostor/wwf80.rb', line 61

def post(forum, topic, message) # :nodoc:
  Impostor.not_tested("Impostor::Wwf80::Post", "post")
  super
end