Module: Impostor::Wwf79::Post
- Defined in:
- lib/impostor/wwf79.rb
Instance Method Summary collapse
-
#get_post_form(page) ⇒ Object
return the form used for posting a message from the reply page.
-
#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.
-
#get_reply_uri(forum, topic) ⇒ Object
return a uri used to fetch the reply page based on the forum, topic, and message.
-
#post(forum, topic, message) ⇒ Object
:nodoc:.
Instance Method Details
#get_post_form(page) ⇒ Object
return the form used for posting a message from the reply page
81 82 83 84 85 |
# File 'lib/impostor/wwf79.rb', line 81 def get_post_form(page) form = page.form('frmAddMessage') 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
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/impostor/wwf79.rb', line 91 def get_post_from_result(page) error = page.body =~ /Message Not Posted/ if error # throttled throttled = "You have exceeded the number of posts permitted in the time span" too_many = page.body =~ /#{throttled}/ raise Impostor::ThrottledError.new(throttled) if too_many # general error raise Impostor::PostError.new("There was an error making the post") 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
72 73 74 75 76 |
# File 'lib/impostor/wwf79.rb', line 72 def get_reply_uri(forum, topic) uri = URI.join(self.config.app_root, self.config.config(:forum_posts_page)) uri.query = "TID=#{topic}&TPN=10000" uri end |
#post(forum, topic, message) ⇒ Object
:nodoc:
63 64 65 66 |
# File 'lib/impostor/wwf79.rb', line 63 def post(forum, topic, ) # :nodoc: Impostor.not_tested("Impostor::Wwf79::Post", "post") super end |