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 !
this adds the redirects plugin, allowing custom redirects to be setup
eldiablo (author)
Sat Apr 12 10:41:07 -0700 2008
commit  9411a6633461f5cef1de4c316e3221d168155943
tree    029553c9b0877c4a82c5104dff27e9d0df26b916
parent  bdb1bb8b25686c86a80d1d5da5a6377f08486814
0
...
4
5
6
 
 
7
 
...
4
5
6
7
8
9
10
0
@@ -4,5 +4,8 @@
0
 feather-feeds: this adds RSS feeds to Feather, and if the comment plugin is present, also adds a comment feed
0
 feather-formatters: this adds textile, markdown and smartypants formatting for articles, and if the sidebar plugin is present, sidebar groups too
0
 feather-import: this allows RSS importing of articles, and if the comment plugin is present, comments too
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-tagging: this provides tagging for articles, and a tag cloud for the blog sidebar
...
 
 
 
 
 
 
...
1
2
3
4
5
6
0
@@ -1 +1,7 @@
0
+class Redirector < Application
0
+ def show(id)
0
+ @redirect = Redirect[id]
0
+ [@redirect.permanent ? 301 : 302, redirect(@redirect.to_url), []]
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 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
+ def new
0
+ @redirect = Redirect.new
0
+ display @redirect
0
+ end
0
+
0
+ def create(redirect)
0
+ redirect["permanent"] = (redirect["permanent"] == "0" ? false : true)
0
+ @redirect = Redirect.new(redirect)
0
+ if @redirect.save
0
+ redirect url(:admin_redirect)
0
+ else
0
+ render :new
0
+ end
0
+ end
0
+
0
+ def edit
0
+ display @redirect
0
+ end
0
+
0
+ def update(redirect)
0
+ redirect["permanent"] = (redirect["permanent"] == "0" ? false : true)
0
+ if @redirect.update_attributes(redirect)
0
+ redirect url(:admin_redirect, @redirect)
0
+ else
0
+ render :edit
0
+ end
0
+ end
0
+
0
+ def delete
0
+ @redirect.destroy!
0
+ redirect url(:admin_redirects)
0
+ end
0
+
0
+ def show
0
+ display @redirect
0
+ end
0
+
0
+ private
0
+ def find_redirect
0
+ @redirect = Redirect[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
0
@@ -1 +1,21 @@
0
+require File.join(File.join(File.dirname(__FILE__), "controllers"), "redirector")
0
+require File.join(File.join(File.dirname(__FILE__), "controllers"), "redirects")
0
+require File.join(File.join(File.dirname(__FILE__), "models"), "redirect")
0
+
0
+Merb::Router.prepend do |r|
0
+ # This deferred route allows redirects to be handled
0
+ r.match("").defer_to do |request, path_match|
0
+ unless (redirect = Redirect.find_by_from_url(request.uri.to_s.chomp("/"))).nil?
0
+ {:controller => "redirector", :action => "show", :id => redirect.id}
0
+ end
0
+ end
0
+
0
+ r.namespace :admin do |admin|
0
+ admin.resources :redirects
0
+ end
0
+end
0
+
0
+Hooks::Menu.add_menu_item do
0
+ {:text => "Redirects", :url => "/admin/redirects" }
0
+end
...
 
...
1
0
@@ -1 +1,2 @@
0
+Database::migrate(Redirect)
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
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
0
@@ -1 +1,30 @@
0
+plugin:
0
+ name: feather-redirects
0
+ author: El Draper
0
+ version: 1.0
0
+ homepage: http://featherblog.com
0
+ about: This plugin adds the ability for the user to setup custom redirects.
0
+ contents:
0
+ .:
0
+ - init.rb
0
+ - install.rb
0
+ controllers:
0
+ .:
0
+ - redirector.rb
0
+ - redirects.rb
0
+ models:
0
+ .:
0
+ - redirect.rb
0
+ views:
0
+ .:
0
+ admin:
0
+ .:
0
+ redirects:
0
+ .:
0
+ - _form.html.erb
0
+ - _redirect.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
0
@@ -1 +1,10 @@
0
+class Redirect < DataMapper::Base
0
+ property :from_url, :string, :nullable => false, :length => 255
0
+ property :to_url, :string, :nullable => false, :length => 255
0
+ property :permanent, :boolean
0
+
0
+ def self.find_by_from_url(from_url)
0
+ self.first(:from_url => from_url)
0
+ end
0
+end
...
 
 
 
 
...
1
2
3
4
0
@@ -1 +1,5 @@
0
+<%= text_control :from_url, :size => 50, :label => 'From URL:' %>
0
+<%= text_control :to_url, :size => 50, :label => 'To URL:' %>
0
+<br />
0
+<b>Permanent?</b> <%= checkbox_control :permanent %>
...
 
 
 
 
 
 
 
 
 
 
 
...
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 redirect.
0
+<% end %>
0
+
0
+<%= error_messages_for @redirect %>
0
+<h1>Edit redirect</h1>
0
+
0
+<% form_for :redirect, :action => url(:admin_redirect, @redirect), :method => :put do %>
0
+ <%= partial 'form' %>
0
+ <p><%= submit_button 'Save Redirect' %> or <%= link_to 'Cancel', url(:admin_redirects) %></p>
0
+<% end %>
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
0
@@ -1 +1,21 @@
0
+<% throw_content :right do %>
0
+ <h4>View Redirects</h4>
0
+ <p>
0
+ Redirects allow you to setup urls that'll be redirected elsewhere on the blog, so as to maintain compatibility with old links. You can configure them to be temporary (302), or permanent (301) redirects.
0
+ </p>
0
+<% end %>
0
+
0
+<h1>View Redirects</h1>
0
+
0
+<table>
0
+ <% @redirects.each do |redirect| %>
0
+ <tr>
0
+ <td>From <%= redirect.from_url %> to <%= redirect.to_url %></td>
0
+ <td>(<%= redirect.permanent ? "Permanent" : "Temporary" %>)</td>
0
+ <td <%= link_to "Edit", url(:edit_admin_redirect, redirect) %> | <%= link_to 'Delete', url(:delete_admin_redirect, redirect), {:method => :delete, :onclick => "return confirm('Are you sure?')"} %></td>
0
+ </tr>
0
+ <% end %>
0
+</table>
0
+<br />
0
+<%= link_to "New Redirect", url(:new_admin_redirect) %>
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
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 redirect here - simply enter the url to be redirected, the url to be redirected to, and whether it is temporary, or permanent.
0
+ </p>
0
+<% end %>
0
+
0
+<%= error_messages_for @redirect %>
0
+<h1>New Redirect</h1>
0
+
0
+<% form_for :redirect, :action => url(:admin_redirect, @redirect) do %>
0
+ <%= partial 'form' %>
0
+ <p><%= submit_button 'Save Redirect' %> or <%= link_to 'Cancel', url(:admin_redirects) %></p>
0
+<% end %>
0
+
0
+<%= link_to "Back to redirects", url(:admin_redirects) %>
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
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 Redirect</h4>
0
+ <p>
0
+ Here you can view the details of an existing redirect.
0
+ </p>
0
+<% end %>
0
+
0
+<h1>View Redirect</h1>
0
+
0
+<p>
0
+ From: <%= @redirect.from_url %>
0
+</p>
0
+
0
+<p>
0
+ To: <%= @redirect.to_url %>
0
+</p>
0
+
0
+<p>
0
+ Permanent? <%= @redirect.permanent %>
0
+</p>
0
+
0
+<%= link_to "Edit redirect", url(:edit_admin_redirect, @redirect) %> |
0
+<%= link_to "Back to redirects", url(:admin_redirects) %>

Comments

    No one has commented yet.