Class: WTForum::Admin

Inherits:
Object
  • Object
show all
Defined in:
lib/wtforum/admin.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Admin

Returns a new instance of Admin.



7
8
9
10
# File 'lib/wtforum/admin.rb', line 7

def initialize attributes={}
  self.username = attributes[:username]
  self.password = attributes[:password]
end

Instance Attribute Details

#passwordObject

Returns the value of attribute password.



12
13
14
# File 'lib/wtforum/admin.rb', line 12

def password
  @password
end

#usernameObject

Returns the value of attribute username.



12
13
14
# File 'lib/wtforum/admin.rb', line 12

def username
  @username
end

Instance Method Details

#api_keyObject



14
15
16
17
# 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

#domainObject

visit “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



30
31
32
33
# 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) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
# 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_htmlObject



57
58
59
60
61
# 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) ⇒ Object



63
64
65
66
67
68
# 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

#skinObject



47
48
49
50
# 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) ⇒ Object



52
53
54
55
# 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