>> I'd also like to see the option of leaving
>> behind a redirect action to maintain cool uris.
I think it should be easy enough to write a tag for doing redirects...
(You don't need a special kind of "redirect" page, you can just create a
new page and insert this tag). Or perhaps this tag should actually be
provided by a custom page type...
Here's some snippets of code from my own hacked-up version of Radiant:
---in standard_page.rb---
#
# <r:redirect to_url="" />
#
define_tag 'redirect' do |tag|
to_url = tag.attr['to_url']
raise RedirectException.redirect_to(to_url);
end
------redirect_exception.rb---
class RedirectException < Exception
attr_accessor :redirect_to_url
def self.redirect_to(redirect_to_url)
new_exception = RedirectException.new("redirect");
new_exception.redirect_to_url = redirect_to_url;
return new_exception;
end
end
----in site_controller.rb----
def show_page
url = params[:url].to_s
@page = find_page(url)
if @page.nil?
render :template => 'site/not_found', :status => 404
else
begin
@page.process(request, response)
rescue RedirectException => e
redirect_to e.redirect_to_url;
end
@performed_render = true
end
rescue Page::MissingRootPageError
redirect_to(:controller => 'admin/welcome')
end
--
Posted via http://www.ruby-forum.com/.
_______________________________________________
Radiant mailing list
Post: [email protected]
Search: http://radiantcms.org/mailing-list/search/
Site: http://lists.radiantcms.org/mailman/listinfo/radiant