class WTForum::Admin
Attributes
password[RW]
username[RW]
Public Class Methods
new(attributes={})
click to toggle source
# File lib/wtforum/admin.rb, line 7 def initialize attributes={} self.username = attributes[:username] self.password = attributes[:password] end
Public Instance Methods
api_key()
click to toggle source
# File lib/wtforum/admin.rb, line 14 def api_key page = authorized_agent.get("http://www.websitetoolbox.com/cgi/members/mboard.cgi?action=showmbsettings&tab=Single+Sign+On") page.form_with(name: "posts").field_with(name: "apikey").value end
domain()
click to toggle source
visit "http://www.websitetoolbox.com/tool/members/mb/addusers" fill_in "member", with: attributes[:username] fill_in "pw", with: attributes[:password] fill_in "email", with: attributes[:email] select "Administrators", from: "usergroupid" click_button "Register New User"
end
# File lib/wtforum/admin.rb, line 30 def domain page = authorized_agent.get("http://www.websitetoolbox.com/cgi/members/main.cgi") page.at(".heading h2 span").text.split("//").last end
domain=(full_domain)
click to toggle source
# File lib/wtforum/admin.rb, line 35 def domain= full_domain domain_parts = full_domain.split(".") subdomain = domain_parts.shift domain = domain_parts.join(".") page = authorized_agent.get("http://www.websitetoolbox.com/tool/members/domain?tool=mb&action=custom_domain_type&dashboard=1") form = page.form_with(action: "domain") form.field_with(name: "domain_sub_domain").value = subdomain form.field_with(name: "domain").value = domain form.submit end
head_html()
click to toggle source
# File lib/wtforum/admin.rb, line 57 def head_html page = authorized_agent.get("http://www.websitetoolbox.com/cgi/members/hf.cgi?tool=mb") form = page.form_with(name: "hfform") form.field_with(name: "head").value end
head_html=(html)
click to toggle source
# File lib/wtforum/admin.rb, line 63 def head_html= html page = authorized_agent.get("http://www.websitetoolbox.com/cgi/members/hf.cgi?tool=mb") form = page.form_with(name: "hfform") form.field_with(name: "head").value = html form.submit end
skin()
click to toggle source
# File lib/wtforum/admin.rb, line 47 def skin page = authorized_agent.get("http://www.websitetoolbox.com/tool/members/mb/skins") page.at(".skin_title").text.sub(/[[:space:]]+Customize.+$/m, '') end
skin=(skin_name)
click to toggle source
# File lib/wtforum/admin.rb, line 52 def skin= skin_name skin_id = skins.fetch(skin_name) authorized_agent.get("http://www.websitetoolbox.com/tool/members/mb/skins?action=install_skin&subaction=skins&skin_id=#{skin_id}&search_skin=&sorted=") end
Private Instance Methods
admin_session()
click to toggle source
# File lib/wtforum/admin.rb, line 72 def admin_session visit "http://www.websitetoolbox.com/tool/members/login" fill_in "username", with: course.admin_username fill_in "password", with: course.admin_password click_button "Login" end
agent()
click to toggle source
# File lib/wtforum/admin.rb, line 98 def agent Mechanize.new end
skins()
click to toggle source
# File lib/wtforum/admin.rb, line 79 def skins { "Soft Gray" => 21, "Elegance" => 50, } end