Class: Kiosk::WordPress::Page

Inherits:
Resource
  • Object
show all
Defined in:
lib/kiosk/word_press/page.rb

Instance Method Summary collapse

Methods inherited from Resource

all, collection_path, #content, #content_document, #destroy, element_path, element_path_by_slug, #excerpt, find, find_by_associated, find_by_slug, instantiate_collection, instantiate_record, #raw_content, #raw_excerpt, #save, #to_param, with_parameters

Methods included from Cacheable::Resource

#expire

Instance Method Details

#sectionObject

Returns the leading portion of the slug.



25
26
27
# File 'lib/kiosk/word_press/page.rb', line 25

def section
  (s = slug.to_s).empty? ? nil : s.split('/').first
end

#slugObject

Returns the full page slug. This differs in cases where the page is a child of another in the hierarchy. E.g. where a parent page has slug ‘p1’ and the child page has slug ‘c1’, ‘p1/c1’ would be returned, not simply ‘c1’.



34
35
36
37
38
39
40
41
42
43
44
# File 'lib/kiosk/word_press/page.rb', line 34

def slug
  begin
    uri = URI.parse(url)
    # get the route from the original site uri
    route = uri.route_from(Kiosk.origin.site_uri)
    # return just the path without any trailing /
    route.path.sub(/\/$/, '')
  rescue
    attributes[:slug]
  end
end