aslakjo-comatose 2.0.5.9 → 2.0.5.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/comatose.gemspec +1 -1
  2. data/lib/comatose_page.rb +29 -25
  3. metadata +1 -1
data/comatose.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  # Generated on Tue May 20 20:13:12 -0500 2008
2
2
  Gem::Specification.new do |s|
3
3
  s.name = "aslakjo-comatose"
4
- s.version = "2.0.5.9"
4
+ s.version = "2.0.5.10"
5
5
  s.date = "2008-10-31" # 2008-05-20
6
6
  s.summary = "Micro CMS designed for being embedded into existing Rails applications"
7
7
  s.email = "matt@elucidata.net"
data/lib/comatose_page.rb CHANGED
@@ -24,7 +24,6 @@ class ComatosePage < ActiveRecord::Base
24
24
 
25
25
  acts_as_list :scope => :parent_id
26
26
 
27
- #before_create :create_full_path
28
27
  before_save :cache_full_path, :create_full_path
29
28
  after_save :update_children_full_path, :after_save_hook
30
29
 
@@ -32,7 +31,9 @@ class ComatosePage < ActiveRecord::Base
32
31
  before_validation do |record|
33
32
  # Create slug from title
34
33
  if record.slug.blank? and !record.title.blank?
35
- record.slug = record.title.downcase.lstrip.rstrip.gsub( /[^-a-z0-9~\s\.:;+=_]/, '').gsub(/[\s\.:;=_+]+/, '-').gsub(/[\-]{2,}/, '-').to_s
34
+ striped_title = record.title.downcase.lstrip.rstrip
35
+ ComatosePage.slugize_foreign_leters(striped_title)
36
+ record.slug = striped_title.gsub( /[^-a-z0-9~\s\.:;+=_]/, '').gsub(/[\s\.:;=_+]+/, '-').gsub(/[\-]{2,}/, '-').to_s
36
37
  end
37
38
  end
38
39
 
@@ -72,11 +73,11 @@ class ComatosePage < ActiveRecord::Base
72
73
  # Check if a page has a selected keyword... NOT case sensitive.
73
74
  # So the keyword McCray is the same as mccray
74
75
  def has_keyword?(keyword)
75
- @key_list ||= (self.keywords || '').downcase.split(',').map {|k| k.strip }
76
- @key_list.include? keyword.to_s.downcase
77
- rescue
78
- false
79
- end
76
+ @key_list ||= (self.keywords || '').downcase.split(',').map {|k| k.strip }
77
+ @key_list.include? keyword.to_s.downcase
78
+ rescue
79
+ false
80
+ end
80
81
 
81
82
  # Returns the page's content, transformed and filtered...
82
83
  def to_html(options={})
@@ -87,16 +88,16 @@ class ComatosePage < ActiveRecord::Base
87
88
  TextFilters.transform(text, binding, filter_type, Comatose.config.default_processor)
88
89
  end
89
90
 
90
- # Static helpers...
91
+ # Static helpers...
91
92
 
92
93
  # Returns a Page with a matching path.
93
94
  def self.find_by_path( path )
94
- path = path.split('.')[0] unless path.empty? # Will ignore file extension...
95
- path = path[1..-1] if path.starts_with? "/"
96
- find( :first, :conditions=>[ 'full_path = ?', path ] )
95
+ path = path.split('.')[0] unless path.empty? # Will ignore file extension...
96
+ path = path[1..-1] if path.starts_with? "/"
97
+ find( :first, :conditions=>[ 'full_path = ?', path ] )
97
98
  end
98
99
 
99
- # Overrides...
100
+ # Overrides...
100
101
 
101
102
  # I don't want the AR magic timestamping support for this class...
102
103
  def record_timestamps
@@ -106,26 +107,29 @@ class ComatosePage < ActiveRecord::Base
106
107
  def self.record_timestamps
107
108
  false
108
109
  end
109
-
110
- protected
111
110
 
111
+ def self.slugize_foreign_leters(title)
112
+ title.gsub("æ","ae").gsub("Æ","ae").gsub("å","a").gsub("Å","a").gsub("ø","o").gsub("Ø","o")
113
+ end
114
+
115
+ protected
112
116
  def after_save_hook
113
117
  instance_eval &Comatose.config.after_page_save
114
118
  end
115
119
 
116
- # Creates a URI path based on the Page tree
117
120
  def create_full_path
118
- if parent_node = self.parent
119
- # Build URI Path
120
- path = "#{parent_node.full_path}/#{self.slug}"
121
- # strip leading space, if there is one...
122
- path = path[1..-1] if path.starts_with? "/"
123
- self.full_path = path || ""
124
- else
125
- # I'm the root -- My path is blank
126
- self.full_path = ""
127
- end
121
+ if parent_node = self.parent
122
+ # Build URI Path
123
+ path = "#{parent_node.full_path}/#{self.slug}"
124
+ # strip leading space, if there is one...
125
+ path = path[1..-1] if path.starts_with? "/"
126
+ self.full_path = path || ""
127
+ else
128
+ # I'm the root -- My path is blank
129
+ self.full_path = ""
130
+ end
128
131
  end
132
+
129
133
  def create_full_path!
130
134
  create_full_path
131
135
  save
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aslakjo-comatose
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.5.9
4
+ version: 2.0.5.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - M@ McCray