0
+class PingService < DataMapper::Base
0
+ property :name, :string, :nullable => false
0
+ property :url, :string, :nullable => false, :length => 255
0
+ property :extended, :boolean
0
+ validates_presence_of :name, :key => "uniq_ping_service_name"
0
+ validates_presence_of :url, :key => "uniq_ping_service_url"
0
+ # This executes the specific ping for the specified article
0
+ extended_ping(article)
0
+ standard_ping(article)
0
+ # This performs a standard ping for the specified article, and returns the result
0
+ def standard_ping(article)
0
+ res = XMLRPC::Client.new2(self.url).call("weblogUpdates.ping", article.title, article.permalink)
0
+ # Raise any errors found
0
+ raise res["message"] if res["error"] == true
0
+ # This performs an extended ping for the specified article, and returns the result
0
+ def extended_ping(article)
0
+ # Grab the feed url, but only if the plugin is installed and active, otherwise send nil through
0
+ feed_url = is_plugin_active("feather-feeds") ? "#{request.env['HTTP_HOST']}/articles.rss" : nil
0
+ res = XMLRPC::Client.new2(self.url).call("weblogUpdates.extendedPing", article.title, article.url, feed_url)
0
+ # Raise any errors found
0
+ raise res["message"] if res["error"] == true
Comments
No one has commented yet.