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 snippets plugin that allows the user to insert dynamic snippets 
using pre-defined view hooks, also re-named a couple of the view hooks
eldiablo (author)
Sat Apr 12 11:27:39 -0700 2008
commit  24d287024b1771ce6417107c46249a12362ca5aa
tree    8e5e1d6f4c49195e6a47d451e47a7961cd280aa7
parent  9411a6633461f5cef1de4c316e3221d168155943
0
...
7
8
9
 
10
...
7
8
9
10
11
0
@@ -7,5 +7,6 @@
0
 feather-pings: this allows custom ping services to be contacted when new content is published
0
 feather-redirects: this allows custom redirects to be setup to maintain links and compatibility with previous blog services
0
 feather-sidebar: this allows the creation of generic sidebar items for your Feather blog
0
+feather-snippets: this allows custom and dynamic creation of snippets to add to the blog template
0
 feather-tagging: this provides tagging for articles, and a tag cloud for the blog sidebar
...
6
7
8
9
 
10
11
...
6
7
8
 
9
10
11
0
@@ -6,7 +6,7 @@
0
 end
0
 
0
 Hooks::View.register_view do
0
- [{ :name => "after_post", :partial => "comments" },
0
+ [{ :name => "after_article", :partial => "comments" },
0
   { :name => "meta_section", :partial => "comments" }]
0
 end
...
22
23
24
25
26
27
28
...
22
23
24
 
25
26
27
0
@@ -22,7 +22,6 @@
0
                         redirects:
0
                             .:
0
                                 - _form.html.erb
0
- - _redirect.html.erb
0
                                 - edit.html.erb
0
                                 - index.html.erb
0
                                 - new.html.erb
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
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
0
@@ -1 +1,53 @@
0
+module Admin
0
+ class Snippets < Base
0
+ include_plugin_views __FILE__
0
+
0
+ before :find_snippet, :only => %w(edit update delete show)
0
+
0
+ def index
0
+ @snippets = Snippet.all
0
+ display @snippets
0
+ end
0
+
0
+ def new
0
+ @snippet = Snippet.new
0
+ display @snippet
0
+ end
0
+
0
+ def create(snippet)
0
+ @snippet = Snippet.new(snippet)
0
+ if @snippet.save
0
+ redirect url(:admin_snippet)
0
+ else
0
+ render :new
0
+ end
0
+ end
0
+
0
+ def edit
0
+ display @snippet
0
+ end
0
+
0
+ def update(snippet)
0
+ if @snippet.update_attributes(snippet)
0
+ redirect url(:admin_snippet, @snippet)
0
+ else
0
+ render :edit
0
+ end
0
+ end
0
+
0
+ def delete
0
+ @snippet.destroy!
0
+ redirect url(:admin_snippets)
0
+ end
0
+
0
+ def show
0
+ display @snippet
0
+ end
0
+
0
+ private
0
+ def find_snippet
0
+ @snippet = Snippet[params[:id]]
0
+ end
0
+ end
0
+end
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
0
@@ -1 +1,17 @@
0
+require File.join(File.join(File.dirname(__FILE__), "controllers"), "snippets")
0
+require File.join(File.join(File.dirname(__FILE__), "models"), "snippet")
0
+
0
+Merb::Router.prepend do |r|
0
+ r.namespace :admin do |admin|
0
+ admin.resources :snippets
0
+ end
0
+end
0
+
0
+Hooks::Menu.add_menu_item do
0
+ {:text => "Snippets", :url => "/admin/snippets" }
0
+end
0
+
0
+Snippet.all.each do |snippet|
0
+ snippet.register_snippet
0
+end
...
 
...
1
0
@@ -1 +1,2 @@
0
+Database::migrate(Snippet)
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
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 +1,29 @@
0
+plugin:
0
+ name: feather-snippets
0
+ author: El Draper
0
+ version: 1.0
0
+ homepage: http://featherblog.com
0
+ about: This plugin adds the ability for the user to create and manage dynamic snippets
0
+ contents:
0
+ .:
0
+ - init.rb
0
+ - install.rb
0
+ controllers:
0
+ .:
0
+ - snippets.rb
0
+ models:
0
+ .:
0
+ - snippet.rb
0
+ views:
0
+ .:
0
+ admin:
0
+ .:
0
+ snippets:
0
+ .:
0
+ - _form.html.erb
0
+ - _snippet.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
13
14
15
16
17
0
@@ -1 +1,18 @@
0
+class Snippet < DataMapper::Base
0
+ property :content, :text, :nullable => false
0
+ property :location, :string, :nullable => false, :length => 255
0
+
0
+ after_save :register_snippet
0
+ before_destroy :deregister_snippet
0
+
0
+ def register_snippet
0
+ Hooks::View.register_view self.id do
0
+ { :name => self.location, :content => self.content }
0
+ end
0
+ end
0
+
0
+ def deregister_snippet
0
+ Hooks::View.deregister_view self.id
0
+ end
0
+end
...
 
 
...
1
2
0
@@ -1 +1,3 @@
0
+<%= select_control :location, :collection => ["article_form_fields", "before_article", "before_article_in_list", "after_article", "after_article_in_list", "meta_section", "head", "header", "before_layout", "after_layout", "sidebar", "footer"], :label => 'Location:' %>
0
+<%= text_area_control :content, :rows => 20, :cols => 100, :label => 'Snippet:' %>
...
 
 
 
 
...
1
2
3
4
0
@@ -1 +1,5 @@
0
+<tr>
0
+ <td><%= snippet.location %></td>
0
+ <td <%= link_to "Edit", url(:edit_admin_snippet, snippet) %> | <%= link_to 'Delete', url(:delete_admin_snippet, snippet), {: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 snippet.
0
+<% end %>
0
+
0
+<%= error_messages_for @snippet %>
0
+<h1>Edit snippet</h1>
0
+
0
+<% form_for :snippet, :action => url(:admin_snippet, @snippet), :method => :put do %>
0
+ <%= partial 'form' %>
0
+ <p><%= submit_button 'Save Snippet' %> or <%= link_to 'Cancel', url(:admin_snippets) %></p>
0
+<% end %>
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
0
@@ -1 +1,15 @@
0
+<% throw_content :right do %>
0
+ <h4>View Snippets</h4>
0
+ <p>
0
+ Snippets allow you to inject snippets within your blog at specified points.
0
+ </p>
0
+<% end %>
0
+
0
+<h1>View Snippets</h1>
0
+
0
+<table>
0
+ <%= partial('admin/snippets/snippet', :with => @snippets) %>
0
+</table>
0
+<br />
0
+<%= link_to "New Snippet", url(:new_admin_snippet) %>
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
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 snippet here.
0
+ </p>
0
+<% end %>
0
+
0
+<%= error_messages_for @snippet %>
0
+<h1>New Snippet</h1>
0
+
0
+<% form_for :snippet, :action => url(:admin_snippet, @snippet) do %>
0
+ <%= partial 'form' %>
0
+ <p><%= submit_button 'Save Snippet' %> or <%= link_to 'Cancel', url(:admin_snippets) %></p>
0
+<% end %>
0
+
0
+<%= link_to "Back to snippets", url(:admin_snippets) %>
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
0
@@ -1 +1,22 @@
0
+<% throw_content :right do %>
0
+ <h4>View Snippet</h4>
0
+ <p>
0
+ Here you can view the details of an existing snippet.
0
+ </p>
0
+<% end %>
0
+
0
+<h1>View Snippet</h1>
0
+
0
+<p>
0
+ Location: <%= @snippet.location %>
0
+</p>
0
+
0
+<p>
0
+ Content:
0
+ <br />
0
+ <%= @snippet.content %>
0
+</p>
0
+
0
+<%= link_to "Edit snippet", url(:edit_admin_snippet, @snippet) %> |
0
+<%= link_to "Back to snippets", url(:admin_snippets) %>

Comments

    No one has commented yet.