Module: Taggable::FacetedPage::InstanceMethods
- Defined in:
- lib/taggable/faceted_page.rb
Instance Method Summary collapse
-
#cache? ⇒ Boolean
Faceted pages map nicely onto urls and are cacheable.
-
#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
#cache? ⇒ Boolean
Faceted pages map nicely onto urls and are cacheable. There can be redundancy if tags are specified in varying order, but the site controller tries to normalize everything.
29 30 31 |
# File 'lib/taggable/faceted_page.rb', line 29 def cache? true end |
#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.
38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/taggable/faceted_page.rb', line 38 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
61 62 63 |
# File 'lib/taggable/faceted_page.rb', line 61 def ( = ) clean_path( + '/' + .uniq.compact.sort.map(&:clean_title).to_param ) end |
#requested_tags ⇒ Object
The set of tags attached to the page request.
55 56 57 |
# File 'lib/taggable/faceted_page.rb', line 55 def @requested_tags ||= [] end |