public
Description: This contains various plugins for Feather
Clone URL: git://github.com/eldiablo/feather-plugins.git
Search Repo:
Click here to lend your support to: feather-plugins and make a donation at www.pledgie.com !
added a pings plugin, to allow 3rd party services to be pinged when new 
content is published
eldiablo (author)
Fri Apr 11 13:08:49 -0700 2008
commit  c13fac480847a2153ba23f2c6f28473bc99b319d
tree    322265da0367b82584e7bb88e92b56a1de98a315
parent  10f6a7fe500a9d9cdb9ba091258893db525d6c8f
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
0
@@ -1 +1,16 @@
0
+module Admin
0
+ class PingLogs < Base
0
+ include_plugin_views __FILE__
0
+
0
+ def index
0
+ @ping_logs = PingLog.all
0
+ display @ping_logs
0
+ end
0
+
0
+ def show
0
+ @ping_log = PingLog[params[:id]]
0
+ display @ping_log
0
+ end
0
+ end
0
+end
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
0
@@ -1 +1,55 @@
0
+module Admin
0
+ class PingServices < Base
0
+ include_plugin_views __FILE__
0
+
0
+ before :find_ping_service, :only => %w(edit update delete show)
0
+
0
+ def index
0
+ @ping_services = PingService.all
0
+ display @ping_services
0
+ end
0
+
0
+ def new
0
+ @ping_service = PingService.new
0
+ display @ping_service
0
+ end
0
+
0
+ def create(ping_service)
0
+ ping_service["extended"] = (ping_service["extended"] == "0" ? false : true)
0
+ @ping_service = PingService.new(ping_service)
0
+ if @ping_service.save
0
+ redirect url(:admin_ping_services)
0
+ else
0
+ render :new
0
+ end
0
+ end
0
+
0
+ def edit
0
+ display @ping_service
0
+ end
0
+
0
+ def update(ping_service)
0
+ ping_service["extended"] = (ping_service["extended"] == "0" ? false : true)
0
+ if @ping_service.update_attributes(ping_service)
0
+ redirect url(:admin_ping_service, @ping_service)
0
+ else
0
+ render :edit
0
+ end
0
+ end
0
+
0
+ def delete
0
+ @ping_service.destroy!
0
+ redirect url(:admin_ping_services)
0
+ end
0
+
0
+ def show
0
+ display @ping_service
0
+ end
0
+
0
+ private
0
+ def find_ping_service
0
+ @ping_service = PingService[params[:id]]
0
+ end
0
+ end
0
+end
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
0
@@ -1 +1,32 @@
0
+require "xmlrpc/client"
0
+require File.join(File.join(File.dirname(__FILE__), "controllers"), "ping_logs")
0
+require File.join(File.join(File.dirname(__FILE__), "controllers"), "ping_services")
0
+require File.join(File.join(File.dirname(__FILE__), "models"), "ping_log")
0
+require File.join(File.join(File.dirname(__FILE__), "models"), "ping_service")
0
+
0
+Merb::Router.prepend do |r|
0
+ r.namespace :admin do |admin|
0
+ admin.resources :ping_logs
0
+ admin.resources :ping_services
0
+ end
0
+end
0
+
0
+Hooks::Menu.add_menu_item do
0
+ {:text => "Ping Services", :url => "/admin/ping_services" }
0
+end
0
+
0
+Hooks::Events.register_event(:after_publish_article) do |args|
0
+ PingService.all.each do |ping|
0
+ log = PingLog.new
0
+ log.ping_service_id = ping.id
0
+ begin
0
+ log.message = ping.execute(args.first)
0
+ log.successful = true
0
+ rescue Exception => err
0
+ log.message = err.message
0
+ log.successful = false
0
+ end
0
+ log.save
0
+ end
0
+end
...
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
0
@@ -1 +1,11 @@
0
+Database::migrate(PingService)
0
+Database::migrate(PingLog)
0
+
0
+PingService.create(:name => "Twingly", :url => "http://rpc.twingly.com/", :extended => false)
0
+PingService.create(:name => "Technorati", :url => "http://rpc.technorati.com/rpc/ping", :extended => false)
0
+PingService.create(:name => "Weblogs", :url => "http://rpc.weblogs.com/RPC2", :extended => false)
0
+PingService.create(:name => "Pingomatic", :url => "http://rpc.pingomatic.com", :extended => false)
0
+PingService.create(:name => "IceRocket", :url => "http://rpc.icerocket.com:10080", :extended => false)
0
+PingService.create(:name => "Syndic8", :url => "http://ping.syndic8.com/xmlrpc.php", :extended => false)
0
+PingService.create(:name => "Feedster", :url => "http://api.feedster.com/ping", :extended => false)
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
0
@@ -1 +1,36 @@
0
+plugin:
0
+ name: feather-pings
0
+ author: El Draper
0
+ version: 1.0
0
+ homepage: http://featherblog.com
0
+ about: This plugin adds the ability for ping services to be contacted whenever a new post is published.
0
+ contents:
0
+ .:
0
+ - init.rb
0
+ - install.rb
0
+ controllers:
0
+ .:
0
+ - ping_logs.rb
0
+ - ping_services.rb
0
+ models:
0
+ .:
0
+ - ping_log.rb
0
+ - ping_service.rb
0
+ views:
0
+ .:
0
+ admin:
0
+ .:
0
+ ping_logs:
0
+ .:
0
+ - _ping_log.html.erb
0
+ - index.html.erb
0
+ - show.html.erb
0
+ ping_services:
0
+ .:
0
+ - _form.html.erb
0
+ - _ping_service.html.erb
0
+ - edit.html.erb
0
+ - index.html.erb
0
+ - new.html.erb
0
+ - show.html.erb
...
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
0
@@ -1 +1,13 @@
0
+class PingLog < DataMapper::Base
0
+ property :ping_service_id, :integer
0
+ property :message, :string, :nullable => false, :length => 255
0
+ property :successful, :boolean
0
+ property :created_at, :datetime
0
+
0
+ validates_presence_of :message, :key => "uniq_ping_log_message"
0
+
0
+ def service
0
+ @ping_service ||= PingService[self.ping_service_id]
0
+ end
0
+end
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
0
@@ -1 +1,44 @@
0
+class PingService < DataMapper::Base
0
+ property :name, :string, :nullable => false
0
+ property :url, :string, :nullable => false, :length => 255
0
+ property :extended, :boolean
0
+
0
+ validates_presence_of :name, :key => "uniq_ping_service_name"
0
+ validates_presence_of :url, :key => "uniq_ping_service_url"
0
+
0
+ ##
0
+ # This executes the specific ping for the specified article
0
+ def execute(article)
0
+ if self.extended
0
+ extended_ping(article)
0
+ else
0
+ standard_ping(article)
0
+ end
0
+ end
0
+
0
+ private
0
+ ##
0
+ # This performs a standard ping for the specified article, and returns the result
0
+ def standard_ping(article)
0
+ # Make the RPC call
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
+ # Return the result
0
+ res
0
+ end
0
+
0
+ ##
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
+ # Make the RPC call
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
0
+ # Return the result
0
+ res
0
+ end
0
+end
...
 
 
 
 
 
 
...
1
2
3
4
5
6
0
@@ -1 +1,7 @@
0
+<tr>
0
+  <td><%= link_to ping_log.service.name, url(:admin_ping_service, ping_log.service) %></td>
0
+  <td><%= ping_log.successful %></td>
0
+  <td><%= render_relative_date(ping_log.created_at) %></td>
0
+  <td><%= link_to "View", url(:admin_ping_log, ping_log) %></td>
0
+</tr>
...
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
0
@@ -1 +1,14 @@
0
+<% throw_content :right do %>
0
+ <h4>View Ping Logs</h4>
0
+ <p>
0
+   This contains the log entries letting you know whether pings to external services when publishing posts was successful or not.
0
+ </p>
0
+<% end %>
0
+
0
+<h1>View Ping Logs</h1>
0
+
0
+<table>
0
+ <%= partial('admin/ping_logs/ping_log', :with => @ping_logs) %>
0
+</table>
0
+<br />
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
0
@@ -1 +1,31 @@
0
+<% throw_content :right do %>
0
+ <h4>View Ping Log</h4>
0
+ <p>
0
+   Here you can view the details of a ping log.
0
+ </p>
0
+<% end %>
0
+
0
+<h1>View Ping Log</h1>
0
+
0
+<p>
0
+  Service: <%= @ping_log.service.name %>
0
+</p>
0
+
0
+<p>
0
+  Service URL: <%= @ping_log.service.url %>
0
+</p>
0
+
0
+<p>
0
+  Successful? <%= @ping_log.successful %>
0
+</p>
0
+
0
+<p>
0
+  Message: <%= @ping_log.message %>
0
+</p>
0
+
0
+<p>
0
+  When? <%= render_relative_date(@ping_log.created_at) %>
0
+</p>
0
+
0
+<%= link_to "Back to ping logs", url(:admin_ping_logs) %>
...
 
 
 
 
...
1
2
3
4
0
@@ -1 +1,5 @@
0
+<%= text_control :name, :size => 50, :label => 'Name:' %>
0
+<%= text_control :url, :size => 50, :label => 'URL:' %>
0
+<br />
0
+<b>Extended ping?</b> <%= checkbox_control :extended %>
...
 
 
 
 
...
1
2
3
4
0
@@ -1 +1,5 @@
0
+<tr>
0
+  <td><%= link_to ping_service.name, url(:admin_ping_service, ping_service) %></td>
0
+  <td <%= link_to "Edit", url(:edit_admin_ping_service, ping_service) %> | <%= link_to 'Delete', url(:delete_admin_ping_service, ping_service), {:method => :delete, :onclick => "return confirm('Are you sure?')"} %></td>
0
+</tr>
...
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
0
@@ -1 +1,12 @@
0
+<% throw_content :right do %>
0
+  Edit the settings for the ping service.
0
+<% end %>
0
+
0
+<%= error_messages_for @ping_service %>
0
+<h1>Edit <%= @ping_service.name %></h1>
0
+
0
+<% form_for :ping_service, :action => url(:admin_ping_service, @ping_service), :method => :put do %>
0
+ <%= partial 'form' %>
0
+ <p><%= submit_button 'Save Ping Service' %> or <%= link_to 'Cancel', url(:admin_ping_services) %></p>
0
+<% end %>
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
0
@@ -1 +1,20 @@
0
+<% throw_content :right do %>
0
+ <h4>View Ping Services</h4>
0
+ <p>
0
+   Ping services are services that will be notified when you publish new content, so that they can index your articles.
0
+ </p>
0
+
0
+ <p>
0
+   You can also view the <%= link_to "logs", url(:admin_ping_logs) %> for the ping services, to ensure they are working correctly.
0
+ </p>
0
+<% end %>
0
+
0
+<h1>View Ping Services</h1>
0
+
0
+<table>
0
+ <%= partial('admin/ping_services/ping_service', :with => @ping_services) %>
0
+</table>
0
+<br />
0
+<%= link_to "New Ping Service", url(:new_admin_ping_service) %> |
0
+<%= link_to "View Ping Logs", url(:admin_ping_logs) %>
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
0
@@ -1 +1,16 @@
0
+<% throw_content :right do %>
0
+ <p>
0
+  Setup a new ping service here - just give it a name, type in the url to the service, and select whether it uses standard, or extended ping.
0
+ </p>
0
+<% end %>
0
+
0
+<%= error_messages_for @ping_service %>
0
+<h1>New Ping Service</h1>
0
+
0
+<% form_for :ping_service, :action => url(:admin_ping_service, @ping_service) do %>
0
+ <%= partial 'form' %>
0
+ <p><%= submit_button 'Save Ping Service' %> or <%= link_to 'Cancel', url(:admin_ping_services) %></p>
0
+<% end %>
0
+
0
+<%= link_to "Back to ping services", url(:admin_ping_services) %>
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
0
@@ -1 +1,24 @@
0
+<% throw_content :right do %>
0
+ <h4>View Ping Service</h4>
0
+ <p>
0
+   Here you can view an existing ping service.
0
+ </p>
0
+<% end %>
0
+
0
+<h1>View Ping Service</h1>
0
+
0
+<p>
0
+  Name: <%= @ping_service.name %>
0
+</p>
0
+
0
+<p>
0
+  URL: <%= @ping_service.url %>
0
+</p>
0
+
0
+<p>
0
+  Extended? <%= @ping_service.extended %>
0
+</p>
0
+
0
+<%= link_to "Edit ping service", url(:edit_admin_ping_service, @ping_service) %> |
0
+<%= link_to "Back to ping services", url(:admin_ping_services) %>

Comments

    No one has commented yet.