Class: ComatosePage
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- ComatosePage
- Defined in:
- lib/comatose_page.rb
Overview
ComatosePage attributes
- parent_id
- title
- full_path
- slug
- keywords
- body
-
- filter_type
- position
- version
- updated_on
- created_on
Class Method Summary collapse
-
.find_by_path(path) ⇒ Object
Returns a Page with a matching path.
- .record_timestamps ⇒ Object
Instance Method Summary collapse
-
#has_keyword?(keyword) ⇒ Boolean
Check if a page has a selected keyword…
-
#record_timestamps ⇒ Object
I don’t want the AR magic timestamping support for this class…
-
#to_html(options = {}) ⇒ Object
Returns the page’s content, transformed and filtered…
-
#uri ⇒ Object
Returns a pages URI dynamically, based on the active mount point.
Class Method Details
.find_by_path(path) ⇒ Object
Returns a Page with a matching path.
92 93 94 95 96 |
# File 'lib/comatose_page.rb', line 92 def self.find_by_path( path ) path = path.split('.')[0] unless path.empty? # Will ignore file extension... path = path[1..-1] if path.starts_with? "/" find( :first, :conditions=>[ 'full_path = ?', path ] ) end |
.record_timestamps ⇒ Object
104 105 106 |
# File 'lib/comatose_page.rb', line 104 def self. false end |
Instance Method Details
#has_keyword?(keyword) ⇒ Boolean
Check if a page has a selected keyword… NOT case sensitive. So the keyword McCray is the same as mccray
73 74 75 76 77 78 |
# File 'lib/comatose_page.rb', line 73 def has_keyword?(keyword) @key_list ||= (self.keywords || '').downcase.split(',').map {|k| k.strip } @key_list.include? keyword.to_s.downcase rescue false end |
#record_timestamps ⇒ Object
I don’t want the AR magic timestamping support for this class…
101 102 103 |
# File 'lib/comatose_page.rb', line 101 def false end |
#to_html(options = {}) ⇒ Object
Returns the page’s content, transformed and filtered…
81 82 83 84 85 86 87 |
# File 'lib/comatose_page.rb', line 81 def to_html(={}) #version = options.delete(:version) text = self.body binding = Comatose::ProcessingContext.new(self, ) filter_type = self.filter_type || Comatose.config.default_filter TextFilters.transform(text, binding, filter_type, Comatose.config.default_processor) end |
#uri ⇒ Object
Returns a pages URI dynamically, based on the active mount point
59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/comatose_page.rb', line 59 def uri if full_path == '' active_mount_info[:root] else page_path = (full_path || '').split('/') idx_path = active_mount_info[:index].split('/') uri_root = active_mount_info[:root].split('/') uri_path = ( uri_root + (page_path - idx_path) ).flatten.delete_if {|i| i == "" } ['',uri_path].join('/') end end |