WebSite module reworked

This commit is contained in:
erwanlr
2012-12-19 17:49:56 +01:00
parent 052721a8a2
commit 38c81384e8
4 changed files with 75 additions and 82 deletions

View File

@@ -18,9 +18,18 @@
module WebSite
# Checks if the remote website is up.
def online?
Browser.instance.get(@uri.to_s).code != 0
end
def has_basic_auth?
Browser.instance.get(@uri.to_s).code == 401
end
# check if the remote website is
# actually running wordpress.
def is_wordpress?
def wordpress?
wordpress = false
response = Browser.instance.get(
@@ -32,8 +41,8 @@ module WebSite
wordpress = true
else
response = Browser.instance.get(
xml_rpc_url,
{:follow_location => true, :max_redirects => 2}
xml_rpc_url,
{:follow_location => true, :max_redirects => 2}
)
if response.body =~ %r{XML-RPC server accepts POST requests only}i
@@ -44,6 +53,10 @@ module WebSite
wordpress
end
def has_xml_rpc?
!xml_rpc_url.nil?
end
def xml_rpc_url
unless @xmlrpc_url
headers = Browser.instance.get(@uri.to_s).headers_hash
@@ -57,19 +70,6 @@ module WebSite
@xmlrpc_url
end
def has_xml_rpc?
!xml_rpc_url.nil?
end
# Checks if the remote website is up.
def is_online?
Browser.instance.get(@uri.to_s).code != 0
end
def has_basic_auth?
Browser.instance.get(@uri.to_s).code == 401
end
# see if the remote url returns 30x redirect
# return a string with the redirection or nil
def redirection(url = nil)