Class: LibraryPage
- Inherits:
-
Page
- Object
- Page
- LibraryPage
- Includes:
- Library::LibraryTags, WillPaginate::ViewHelpers
- Defined in:
- app/models/library_page.rb
Defined Under Namespace
Classes: RedirectRequired
Instance Attribute Summary collapse
-
#requested_tags ⇒ Object
Returns the value of attribute requested_tags.
-
#strict_match ⇒ Object
Returns the value of attribute strict_match.
Instance Method Summary collapse
- #add_request_tags(tags = []) ⇒ Object
- #cache? ⇒ Boolean
- #find_by_url(url, live = true, clean = false) ⇒ Object
- #remove_request_tags(tags = []) ⇒ Object
-
#url_with_tags(tags = requested_tags) ⇒ Object
this isn’t very pleasing but it’s the best way to let the controller know of our real address once tags have been added and removed.
Methods included from Library::LibraryTags
#_default_library_find_options, #_get_assets, #_get_pages, #asset_find_options
Methods included from LibraryHelper
#clean_html, #strip_html, #truncate_words
Instance Attribute Details
#requested_tags ⇒ Object
Returns the value of attribute requested_tags.
11 12 13 |
# File 'app/models/library_page.rb', line 11 def @requested_tags end |
#strict_match ⇒ Object
Returns the value of attribute strict_match.
11 12 13 |
# File 'app/models/library_page.rb', line 11 def strict_match @strict_match end |
Instance Method Details
#add_request_tags(tags = []) ⇒ Object
32 33 34 35 36 37 |
# File 'app/models/library_page.rb', line 32 def (=[]) if .any? .collect! { |tag| Tag.find_by_title(Rack::Utils::unescape(tag)) } self. = (self. + .select{|t| !t.nil?}).uniq end end |
#cache? ⇒ Boolean
13 14 15 |
# File 'app/models/library_page.rb', line 13 def cache? true end |
#find_by_url(url, live = true, clean = false) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/models/library_page.rb', line 17 def find_by_url(url, live = true, clean = false) url = clean_url(url) if clean my_url = self.url return false unless url =~ /^#{Regexp.quote(my_url)}(.*)/ = $1.split('/') if slug_child = children.find_by_slug([0]) found = slug_child.find_by_url(url, live, clean) return found if found end , = .partition{|t| t.first == '-'} () () self end |
#remove_request_tags(tags = []) ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'app/models/library_page.rb', line 39 def (=[]) if .any? .collect! { |tag| tag.slice!(0) if tag.first == '-' Tag.find_by_title(Rack::Utils::unescape(tag)) } self. = (self. - .select{|t| !t.nil?}).uniq end end |
#url_with_tags(tags = requested_tags) ⇒ Object
this isn’t very pleasing but it’s the best way to let the controller know of our real address once tags have been added and removed.
56 57 58 |
# File 'app/models/library_page.rb', line 56 def ( = ) clean_url( + '/' + .uniq.map(&:clean_title).to_param ) end |