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
|
# File 'lib/library/site_controller.rb', line 4
def self.included(base)
base.class_eval {
def find_page_with_tags(url)
url = clean_url(url)
page = find_page_without_tags(url)
return page unless page.is_a?(LibraryPage)
page.add_request_tags(Tag.in_this_list(params[:tag])) if params[:tag]
raise LibraryPage::RedirectRequired, page.url unless page.url == url page
end
alias_method_chain :find_page, :tags
def show_page_with_tags
show_page_without_tags
rescue LibraryPage::RedirectRequired => e
redirect_to e.message
end
alias_method_chain :show_page, :tags
protected
def clean_url(url)
"/#{ url.strip }/".gsub(%r{//+}, '/')
end
}
end
|