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 !
tidied up some of the plugin code, and attempted to use some common 
patterns across all the plugins; also updated the plugin manifests to 
include the proper feather blog url, and (hopefully) fixed the pings 
plugin now using the new after_publish_article_request event
eldiablo (author)
Fri Apr 25 17:34:55 -0700 2008
commit  170d2ba787620acf9e7998d70074b8983426595a
tree    a7faa7b17d97ec8c8bc20569298293a973fc9e23
parent  3027638e763ab5efaf3d150a7303c8fa1a525c51
...
1
2
3
4
 
 
5
6
7
8
9
 
10
11
12
13
14
 
15
16
17
18
19
20
21
22
 
 
 
 
 
23
24
...
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
0
@@ -1,25 +1,28 @@
0
 module Admin
0
   class CommentSettings < Base
0
     include_plugin_views __FILE__
0
-
0
+ before :find_comment_setting
0
+
0
     def show
0
- @comment_setting = CommentSetting.current
0
       display @comment_setting
0
     end
0
-
0
+
0
     def edit
0
- @comment_setting = CommentSetting.current
0
       display @comment_setting
0
     end
0
-
0
+
0
     def update(comment_setting)
0
- @comment_setting = CommentSetting.current
0
       if @comment_setting.update_attributes(comment_setting)
0
         redirect url(:admin_comment_settings, @comment_setting)
0
       else
0
         render :edit
0
       end
0
     end
0
+
0
+ private
0
+ def find_comment_setting
0
+ @comment_setting = CommentSetting.current
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
...
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
0
@@ -1,14 +1,13 @@
0
 module Admin
0
   class Comments < Base
0
     include_plugin_views __FILE__
0
-
0
     before :find_comment, :only => %w(edit update delete show)
0
 
0
     def index
0
       @comments = Comment.all
0
       display @comments
0
     end
0
-
0
+
0
     def update
0
       @comment.published = (params[:published] == "true" ? true : false) if params[:published]
0
       @comment.save
0
0
@@ -16,14 +15,14 @@
0
       expire_article(Article[@comment.article_id])
0
       render_js
0
     end
0
-
0
+
0
     def delete
0
       @comment.destroy!
0
       expire_index
0
       expire_article(Article[@comment.article_id])
0
       redirect url(:admin_comments)
0
     end
0
-
0
+
0
     def show
0
       display @comment
0
     end
...
6
7
8
 
9
10
 
11
12
13
...
6
7
8
9
10
11
12
13
14
15
0
@@ -6,8 +6,10 @@
0
       @comment.published = !CommentSetting.current.moderation
0
       session[:comment_error] = @comment.errors if !@comment.save
0
       article = Article[@comment.article_id]
0
+ # Expire the main article index, and the article page itself
0
       expire_index
0
       expire_article(article)
0
+ # Send e-mail notification if that setting is enabled
0
       if CommentSetting.current.email_notification
0
         email_params = { :from => CommentSetting.current.from_email, :to => CommentSetting.current.to_email, :subject => "New comment - RE: #{article.title}" }
0
         params = { :comment => @comment, :article => article, :request => request }
...
2
3
4
5
 
6
7
8
...
2
3
4
 
5
6
7
8
0
@@ -2,7 +2,7 @@
0
     name: feather-comments
0
     author: Michael Leung and El Draper
0
     version: 1.0
0
- homepage: http://featherblog.com
0
+ homepage: http://featherblog.org
0
     about: This plugin provides the base commenting system for feather.
0
     contents:
0
         .:
...
8
9
10
11
 
12
13
14
15
 
 
16
17
 
18
19
20
...
8
9
10
 
11
12
 
 
 
13
14
15
 
16
17
18
19
0
@@ -8,13 +8,12 @@
0
   property :formatter, :string, :default => "default"
0
   property :ip_address, :string, :default => "127.0.0.1"
0
   property :published, :boolean, :default => true
0
-
0
+
0
   validates_presence_of :name, :comment, :article_id
0
-
0
- belongs_to :article
0
-
0
+
0
+ belongs_to :article
0
   after_save :fire_after_comment_event
0
-
0
+
0
   def self.all_for_post(article_id, method = :all)
0
     self.send(method, {:article_id => article_id, :published => true, :order => "created_at"})
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
...
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
0
@@ -1,25 +1,28 @@
0
 module Admin
0
   class FeedSettings < Base
0
     include_plugin_views __FILE__
0
-
0
+ before :find_feed_setting
0
+
0
     def show
0
- @feed_setting = FeedSetting.current
0
       display @feed_setting
0
     end
0
-
0
+
0
     def edit
0
- @feed_setting = FeedSetting.current
0
       display @feed_setting
0
     end
0
-
0
+
0
     def update(feed_setting)
0
- @feed_setting = FeedSetting.current
0
       if @feed_setting.update_attributes(feed_setting)
0
         redirect url(:admin_feed_settings, @feed_setting)
0
       else
0
         render :edit
0
       end
0
     end
0
+
0
+ private
0
+ def find_feed_setting
0
+ @feed_setting = FeedSetting.current
0
+ end
0
   end
0
 end
...
1
 
 
2
3
 
4
5
6
7
...
24
25
26
27
 
28
29
 
30
31
32
...
54
55
56
57
58
59
60
 
 
 
 
 
 
 
 
 
 
61
...
1
2
3
4
 
5
6
7
8
9
...
26
27
28
 
29
30
 
31
32
33
34
...
56
57
58
 
 
 
 
59
60
61
62
63
64
65
66
67
68
69
0
@@ -1,6 +1,8 @@
0
 class Feeds < Application
0
+ before :find_feed_setting
0
+
0
   def articles
0
- @articles = Article.all(:published => true, :limit => FeedSetting.current.article_count, :order => "published_at DESC")
0
+ @articles = Article.all(:published => true, :limit => @feed_setting.article_count, :order => "published_at DESC")
0
     rss = ""
0
     xml = Builder::XmlMarkup.new(:target => rss)
0
     xml.instruct!
0
0
@@ -24,9 +26,9 @@
0
     end
0
     rss
0
   end
0
-
0
+
0
   def comments
0
- @comments = (defined?(Comment) && is_plugin_active("feather-comments")) ? Comment.all(:limit => FeedSetting.current.comment_count, :order => "created_at DESC") : []
0
+ @comments = (defined?(Comment) && is_plugin_active("feather-comments")) ? Comment.all(:limit => @feed_setting.comment_count, :order => "created_at DESC") : []
0
     rss = ""
0
     xml = Builder::XmlMarkup.new(:target => rss)
0
     xml.instruct!
0
@@ -54,9 +56,15 @@
0
     rss
0
   end
0
 
0
- # Returns the specified time in RFC822 format
0
- def rfc822(time)
0
- time.strftime("%a, %d %b %Y %H:%M:%S GMT")
0
- end
0
+ private
0
+ def find_feed_setting
0
+ @feed_setting = FeedSetting.current
0
+ end
0
+
0
+ ##
0
+ # This returns the specified time in RFC822 format
0
+ def rfc822(time)
0
+ time.strftime("%a, %d %b %Y %H:%M:%S GMT")
0
+ end
0
 end
...
2
3
4
5
 
6
7
8
...
2
3
4
 
5
6
7
8
0
@@ -2,7 +2,7 @@
0
     name: feather-feeds
0
     author: El Draper
0
     version: 1.0
0
- homepage: http://featherblog.com
0
+ homepage: http://featherblog.org
0
     about: This plugin provides an RSS feed for a Feather blog.
0
     contents:
0
         .:
...
2
3
4
5
 
6
7
8
...
2
3
4
 
5
6
7
8
0
@@ -2,7 +2,7 @@
0
   property :article_count, :integer
0
   property :comment_count, :integer
0
   property :external_feed_url, :string, :length => 255
0
-
0
+
0
   ##
0
   # This returns the current settings, creating them if they aren't found
0
   def self.current
...
2
3
4
5
 
6
7
8
...
2
3
4
 
5
6
7
8
0
@@ -2,7 +2,7 @@
0
     name: feather-formatters
0
     author: El Draper
0
     version: 1.0
0
- homepage: http://featherblog.com
0
+ homepage: http://featherblog.org
0
     about: This plugin provides different formatters to be used with Feather.
0
     contents:
0
         .:
...
1
2
3
4
 
5
6
7
...
74
75
76
77
 
78
79
80
...
1
2
3
 
4
5
6
7
...
74
75
76
 
77
78
79
80
0
@@ -1,7 +1,7 @@
0
 module Admin
0
   class Importer < Base
0
     include_plugin_views __FILE__
0
-
0
+
0
     def show
0
       render
0
     end
0
@@ -74,7 +74,7 @@
0
         # Return the list of processed comments
0
         processed
0
       end
0
-
0
+
0
       ##
0
       # This retrieves the content of the specified url
0
       def retrieve(url)
...
1
2
3
4
5
6
7
...
1
2
3
 
4
5
6
0
@@ -1,7 +1,6 @@
0
 require "net/http"
0
 require "hpricot"
0
 require "uri"
0
-
0
 require File.join(File.join(File.dirname(__FILE__), "controllers"), "importer")
0
 
0
 Merb::Router.prepend do |r|
...
2
3
4
5
 
6
7
8
...
2
3
4
 
5
6
7
8
0
@@ -2,7 +2,7 @@
0
     name: feather-import
0
     author: El Draper
0
     version: 1.0
0
- homepage: http://featherblog.com
0
+ homepage: http://featherblog.org
0
     about: This plugin provides a way for users to import existing content (posts and comments) from other sources using RSS
0
     contents:
0
         .:
...
1
2
3
4
5
6
7
8
9
10
11
 
12
13
14
15
16
 
17
18
19
...
27
28
29
30
 
31
32
33
34
...
36
37
38
39
 
40
41
42
43
44
 
45
46
47
...
1
2
3
 
4
5
6
7
8
9
 
10
11
12
13
14
 
15
16
17
18
...
26
27
28
 
29
30
31
32
33
...
35
36
37
 
38
39
40
41
42
 
43
44
45
46
0
@@ -1,19 +1,18 @@
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
+
0
     def new
0
       @ping_service = PingService.new
0
       display @ping_service
0
     end
0
-
0
+
0
     def create(ping_service)
0
       ping_service["extended"] = (ping_service["extended"] == "0" ? false : true)
0
       @ping_service = PingService.new(ping_service)
0
@@ -27,7 +26,7 @@
0
     def edit
0
       display @ping_service
0
     end
0
-
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
0
@@ -36,12 +35,12 @@
0
         render :edit
0
       end
0
     end
0
-
0
+
0
     def delete
0
       @ping_service.destroy!
0
       redirect url(:admin_ping_services)
0
     end
0
-
0
+
0
     def show
0
       display @ping_service
0
     end
...
13
14
15
16
 
17
18
19
20
21
 
22
23
24
...
13
14
15
 
16
17
18
19
20
 
21
22
23
24
0
@@ -13,12 +13,12 @@
0
 
0
 Hooks::Menu.add_menu_item "Ping Services", "/admin/ping_services"
0
 
0
-Hooks::Events.register_event(:after_publish_article) do |args|
0
+Hooks::Events.register_event(:after_publish_article_request) 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.message = ping.execute(args[0], args[1])
0
       log.successful = true
0
     rescue Exception => err
0
       log.message = err.message
...
2
3
4
5
 
6
7
8
...
2
3
4
 
5
6
7
8
0
@@ -2,7 +2,7 @@
0
     name: feather-pings
0
     author: El Draper
0
     version: 1.0
0
- homepage: http://featherblog.com
0
+ homepage: http://featherblog.org
0
     about: This plugin adds the ability for ping services to be contacted whenever a new post is published.
0
     contents:
0
         .:
...
5
6
7
8
 
9
10
11
...
5
6
7
 
8
9
10
11
0
@@ -5,7 +5,7 @@
0
   property :created_at, :datetime
0
 
0
   validates_presence_of :message, :key => "uniq_ping_log_message"
0
-
0
+
0
   def service
0
     @ping_service ||= PingService[self.ping_service_id]
0
   end
...
8
9
10
11
 
12
13
 
14
15
 
16
17
18
19
20
21
22
 
23
24
25
...
30
31
32
33
 
34
35
36
...
8
9
10
 
11
12
 
13
14
 
15
16
17
18
19
20
21
 
22
23
24
25
...
30
31
32
 
33
34
35
36
0
@@ -8,18 +8,18 @@
0
 
0
   ##
0
   # This executes the specific ping for the specified article
0
- def execute(article)
0
+ def execute(article, request)
0
     if self.extended
0
- extended_ping(article)
0
+ extended_ping(article, request)
0
     else
0
- standard_ping(article)
0
+ standard_ping(article, request)
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
+ def standard_ping(article, request)
0
       # Make the RPC call
0
       res = XMLRPC::Client.new2(self.url).call("weblogUpdates.ping", article.title, "http://#{request.env['HTTP_HOST']}#{article.permalink}")
0
       # Raise any errors found
0
@@ -30,7 +30,7 @@
0
 
0
     ##
0
     # This performs an extended ping for the specified article, and returns the result
0
- def extended_ping(article)
0
+ def extended_ping(article, request)
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") ? "http://#{request.env['HTTP_HOST']}/articles.rss" : nil
0
       # Make the RPC call
...
1
2
3
4
5
6
7
8
9
10
11
 
12
13
14
15
16
 
17
18
19
...
27
28
29
30
 
31
32
33
34
...
36
37
38
39
 
40
41
42
43
44
 
45
46
47
...
1
2
3
 
4
5
6
7
8
9
 
10
11
12
13
14
 
15
16
17
18
...
26
27
28
 
29
30
31
32
33
...
35
36
37
 
38
39
40
41
42
 
43
44
45
46
0
@@ -1,19 +1,18 @@
0
 module Admin
0
   class Redirects < Base
0
     include_plugin_views __FILE__
0
-
0
     before :find_redirect, :only => %w(edit update delete show)
0
 
0
     def index
0
       @redirects = Redirect.all
0
       display @redirects
0
     end
0
-
0
+
0
     def new
0
       @redirect = Redirect.new
0
       display @redirect
0
     end
0
-
0
+
0
     def create(redirect)
0
       redirect["permanent"] = (redirect["permanent"] == "0" ? false : true)
0
       @redirect = Redirect.new(redirect)
0
@@ -27,7 +26,7 @@
0
     def edit
0
       display @redirect
0
     end
0
-
0
+
0
     def update(redirect)
0
       redirect["permanent"] = (redirect["permanent"] == "0" ? false : true)
0
       if @redirect.update_attributes(redirect)
0
0
@@ -36,12 +35,12 @@
0
         render :edit
0
       end
0
     end
0
-
0
+
0
     def delete
0
       @redirect.destroy!
0
       redirect url(:admin_redirects)
0
     end
0
-
0
+
0
     def show
0
       display @redirect
0
     end
...
2
3
4
5
 
6
7
8
...
2
3
4
 
5
6
7
8
0
@@ -2,7 +2,7 @@
0
     name: feather-redirects
0
     author: El Draper
0
     version: 1.0
0
- homepage: http://featherblog.com
0
+ homepage: http://featherblog.org
0
     about: This plugin adds the ability for the user to setup custom redirects.
0
     contents:
0
         .:
...
2
3
4
5
 
6
7
8
...
2
3
4
 
5
6
7
8
0
@@ -2,7 +2,7 @@
0
   property :from_url, :string, :nullable => false, :length => 255
0
   property :to_url, :string, :nullable => false, :length => 255
0
   property :permanent, :boolean
0
-
0
+
0
   def validate(arg)
0
     super
0
     if self.from_url == self.to_url
...
1
2
3
4
5
6
7
8
9
10
11
 
12
13
14
15
16
 
17
18
19
...
27
28
29
30
 
31
32
33
34
...
36
37
38
39
 
40
41
42
43
44
45
 
46
47
48
...
51
52
53
54
55
56
...
1
2
3
 
4
5
6
7
8
9
 
10
11
12
13
14
 
15
16
17
18
...
26
27
28
 
29
30
31
32
33
...
35
36
37
 
38
39
40
41
42
43
 
44
45
46
47
...
50
51
52
 
53
54
0
@@ -1,19 +1,18 @@
0
 module Admin
0
   class SidebarGroups < Base
0
     include_plugin_views __FILE__
0
-
0
     before :find_sidebar_group, :only => %w(edit update delete show)
0
 
0
     def index
0
       @sidebar_groups = SidebarGroup.all
0
       display @sidebar_groups
0
     end
0
-
0
+
0
     def new
0
       @sidebar_group = SidebarGroup.new
0
       display @sidebar_group
0
     end
0
-
0
+
0
     def create(sidebar_group)
0
       @sidebar_group = SidebarGroup.new(sidebar_group)
0
       if @sidebar_group.save
0
@@ -27,7 +26,7 @@
0
     def edit
0
       display @sidebar_group
0
     end
0
-
0
+
0
     def update(sidebar_group)
0
       if @sidebar_group.update_attributes(sidebar_group)
0
         redirect url(:admin_sidebar_group, @sidebar_group)
0
0
@@ -36,13 +35,13 @@
0
       end
0
       expire_all_pages
0
     end
0
-
0
+
0
     def delete
0
       @sidebar_group.destroy!
0
       expire_all_pages
0
       redirect url(:admin_sidebar_groups)
0
     end
0
-
0
+
0
     def show
0
       display @article
0
     end
0
@@ -51,7 +50,6 @@
0
       def find_sidebar_group
0
         @sidebar_group = SidebarGroup[params[:id]]
0
       end
0
-
0
   end
0
 end
...
7
8
9
10
11
12
 
 
...
7
8
9
 
 
10
11
12
0
@@ -7,7 +7,7 @@
0
   end
0
 end
0
 
0
-Hooks::Menu.add_menu_item "Sidebar", "/admin/sidebar_groups"
0
-
0
 Hooks::View.register_partial_view "sidebar", "sidebar_groups"
0
+
0
+Hooks::Menu.add_menu_item "Sidebar", "/admin/sidebar_groups"
...
2
3
4
5
 
6
7
8
...
2
3
4
 
5
6
7
8
0
@@ -2,7 +2,7 @@
0
     name: feather-sidebar
0
     author: Michael Leung
0
     version: 1.0
0
- homepage: http://featherblog.com
0
+ homepage: http://featherblog.org
0
     about: This plugin provides the ability to create arbitrary sidebar links.
0
     contents:
0
         .: