Module: Taggable::FacetedPage::InstanceMethods
- Defined in:
- lib/taggable/faceted_page.rb
Instance Method Summary collapse
-
#find_by_path(path, live = true, clean = false) ⇒ Object
(also: #find_by_url)
We override the normal Page#find_by_path mechanism and treat nonexistent child paths are understood as tag sets.
-
#path_with_tags(tags = requested_tags) ⇒ Object
The normal ‘path` method is extended to append the (sorted and deduped) tags attached to the page request.
-
#requested_tags ⇒ Object
The set of tags attached to the page request.
Instance Method Details
#find_by_path(path, live = true, clean = false) ⇒ Object Also known as: find_by_url
We override the normal Page#find_by_path mechanism and treat nonexistent child paths are understood as tag sets. Note that the extended site_controller will add to this set any tags that have been supplied in query string parameters. This may trigger a redirect to bring the request path into line with the consolidated tag set.
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/taggable/faceted_page.rb', line 29 def find_by_path(path, live = true, clean = false) path = clean_path(path) if clean return false unless path =~ /^#{Regexp.quote(self.path)}(.*)/ = $1.split('/') if slug_child = children.find_by_slug([0]) found = slug_child.find_by_url(path, live, clean) return found if found end , = .partition{|t| t.first == '-'} () () self end |
#path_with_tags(tags = requested_tags) ⇒ Object
The normal ‘path` method is extended to append the (sorted and deduped) tags attached to the page request
52 53 54 |
# File 'lib/taggable/faceted_page.rb', line 52 def ( = ) clean_path( + '/' + .uniq.compact.sort.map(&:clean_title).to_param ) end |
#requested_tags ⇒ Object
The set of tags attached to the page request.
46 47 48 |
# File 'lib/taggable/faceted_page.rb', line 46 def @requested_tags ||= [] end |