site_logic 1.6.10 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -10,6 +10,7 @@ gem 'rails', '>= 3.0.1'
10
10
  gem 'rmagick', '2.12.2' # version compatible with heroku
11
11
  gem 'scaffold_logic', '>= 1.0.3'
12
12
  gem 'SystemTimer'
13
+ gem 'tanker'
13
14
 
14
15
  group :development do
15
16
  gem 'jeweler'
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.6.10
1
+ 1.7.0
data/app/models/page.rb CHANGED
@@ -1,11 +1,20 @@
1
1
  class Page
2
-
3
2
  include Mongoid::Document
4
3
  include Mongoid::Timestamps
5
4
  include SiteLogic::Base
5
+ include Tanker
6
6
 
7
- # Attributes =====================================================================================
7
+ # Constants ======================================================================================
8
+ STATES = ['draft', 'published']
9
+
10
+ # Scopes =========================================================================================
11
+ scope :drafts, :where => {:state => 'draft'}
12
+ scope :for_sitemap, :where => {:sitemap => true}
13
+ scope :indexed, :where => {:noindex => false}
14
+ scope :noindex, :where => {:noindex => true}
15
+ scope :published, :where => {:state => 'published'}
8
16
 
17
+ # Mongoid ========================================================================================
9
18
  field :slug
10
19
  field :sitemap, :type => Boolean
11
20
  field :noindex, :type => Boolean
@@ -17,44 +26,34 @@ class Page
17
26
  field :state
18
27
  field :publication_date, :type => DateTime
19
28
 
20
- # Indices ========================================================================================
21
29
  index :slug, :unique => false
22
30
  index :state, :unique => false
23
31
 
24
- # Constants ======================================================================================
25
- STATES = ['draft', 'published']
26
-
27
- # Scopes ===================================================================================
28
- scope :drafts, :where => {:state => 'draft'}
29
- scope :published, :where => {:state => 'published'}
30
- scope :noindex, :where => {:noindex => true}
31
- scope :indexed, :where => {:noindex => false}
32
- scope :for_sitemap, :where => {:sitemap => true}
33
-
34
- # Relationships ==================================================================================
35
32
  embedded_in :site, :inverse_of => :pages
36
33
 
37
34
  # Behavior =======================================================================================
38
- attr_accessor :desired_slug
39
35
  attr_accessor :create_navigation_item
36
+ attr_accessor :desired_slug
40
37
  has_slug :desired_slug
41
38
 
42
- # Callbacks ======================================================================================
39
+ # Tanker =========================================================================================
40
+ tankit 'idx' do
41
+ indexes :content
42
+ indexes :meta_description
43
+ indexes :meta_keywords
44
+ indexes :page_title
45
+ end
43
46
 
44
- # Validations ====================================================================================
47
+ after_destroy :delete_tank_indexes
48
+ after_save :update_tank_indexes
45
49
 
50
+ # Validations ====================================================================================
46
51
  class DesiredSlugPresenceAndUniquenessValidator < ActiveModel::EachValidator
47
52
  def validate_each(object, attribute, value)
48
53
  return unless object.desired_slug
49
54
  if object.site && object.site.pages.map{|p| p.slug unless p == object}.include?(object.desired_slug)
50
- object.errors[attribute] << (options[:message] || "must be unique.")
55
+ object.errors[attribute] << (options[:message] || 'must be unique.')
51
56
  end
52
-
53
- # if object.desired_slug.nil? && object.slug.nil?
54
- # object.errors[attribute] << (options[:message] || "cannot be blank.")
55
- # elsif object.site && object.site.pages.map{|p| p.slug unless p == object}.include?(object.desired_slug)
56
- # object.errors[attribute] << (options[:message] || "must be unique.")
57
- # end
58
57
  end
59
58
  end
60
59
 
@@ -62,24 +61,21 @@ class Page
62
61
  validates_presence_of :page_title
63
62
  validates_presence_of :content
64
63
 
65
- # Class methods ==================================================================================
66
-
67
64
  # Instance methods ===============================================================================
68
-
69
65
  def draft?
70
66
  self.state == 'draft' || self.state.nil?
71
67
  end
72
68
 
73
69
  def humanize_path
74
- if self.slug == ''
75
- "/"
76
- else
77
- "/#{self.slug}/".gsub(/\/\//,'/').gsub(/\/\//,'/')
78
- end
70
+ self.path
71
+ end
72
+
73
+ def path
74
+ self.slug == '' ? '/' : "/#{self.slug}/".gsub(/\/\//,'/').gsub(/\/\//,'/')
79
75
  end
80
76
 
81
77
  def publish!
82
- self.update_attributes(:state => 'published', :publication_date => Time.zone.now)
78
+ self.update_attributes :state => 'published', :publication_date => Time.zone.now
83
79
  end
84
80
 
85
81
  def published?
@@ -87,7 +83,15 @@ class Page
87
83
  end
88
84
 
89
85
  def unpublish!
90
- self.update_attributes(:state => 'draft', :publication_date => nil)
86
+ self.update_attributes :state => 'draft', :publication_date => nil
87
+ end
88
+
89
+ def search_description
90
+ self.meta_description.blank? ? self.content.gsub(/<\/?[^>]*>/, '')[0..199].html_safe : self.meta_description
91
+ end
92
+
93
+ def search_title
94
+ self.window_title
91
95
  end
92
96
 
93
97
  def sitemap
@@ -101,5 +105,4 @@ class Page
101
105
  def window_title
102
106
  self[:window_title] || self.page_title
103
107
  end
104
-
105
- end
108
+ end
@@ -32,4 +32,8 @@ SiteLogic::Application.configure do
32
32
 
33
33
  # Print deprecation notices to the stderr
34
34
  config.active_support.deprecation = :stderr
35
+
36
+ # tanker gem
37
+ config.index_tank_url = 'http://:PctyyJitroN8iv@82wog.api.indextank.com'
38
+ config.tanker_pagination_backend = :kaminari
35
39
  end
data/site_logic.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{site_logic}
8
- s.version = "1.6.10"
8
+ s.version = "1.7.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Bantik"]
12
- s.date = %q{2011-08-31}
12
+ s.date = %q{2011-09-01}
13
13
  s.description = %q{An engine for search-engine-optimized content management.}
14
14
  s.email = %q{corey@seologic.com}
15
15
  s.extra_rdoc_files = [
@@ -835,6 +835,7 @@ Gem::Specification.new do |s|
835
835
  s.add_runtime_dependency(%q<rmagick>, ["= 2.12.2"])
836
836
  s.add_runtime_dependency(%q<scaffold_logic>, [">= 1.0.3"])
837
837
  s.add_runtime_dependency(%q<SystemTimer>, [">= 0"])
838
+ s.add_runtime_dependency(%q<tanker>, [">= 0"])
838
839
  s.add_development_dependency(%q<jeweler>, [">= 0"])
839
840
  s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
840
841
  else
@@ -847,6 +848,7 @@ Gem::Specification.new do |s|
847
848
  s.add_dependency(%q<rmagick>, ["= 2.12.2"])
848
849
  s.add_dependency(%q<scaffold_logic>, [">= 1.0.3"])
849
850
  s.add_dependency(%q<SystemTimer>, [">= 0"])
851
+ s.add_dependency(%q<tanker>, [">= 0"])
850
852
  s.add_dependency(%q<jeweler>, [">= 0"])
851
853
  s.add_dependency(%q<rspec>, [">= 1.2.9"])
852
854
  end
@@ -860,6 +862,7 @@ Gem::Specification.new do |s|
860
862
  s.add_dependency(%q<rmagick>, ["= 2.12.2"])
861
863
  s.add_dependency(%q<scaffold_logic>, [">= 1.0.3"])
862
864
  s.add_dependency(%q<SystemTimer>, [">= 0"])
865
+ s.add_dependency(%q<tanker>, [">= 0"])
863
866
  s.add_dependency(%q<jeweler>, [">= 0"])
864
867
  s.add_dependency(%q<rspec>, [">= 1.2.9"])
865
868
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: site_logic
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 11
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
- - 6
9
- - 10
10
- version: 1.6.10
8
+ - 7
9
+ - 0
10
+ version: 1.7.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Bantik
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-08-31 00:00:00 -05:00
18
+ date: 2011-09-01 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -155,7 +155,7 @@ dependencies:
155
155
  type: :runtime
156
156
  version_requirements: *id009
157
157
  - !ruby/object:Gem::Dependency
158
- name: jeweler
158
+ name: tanker
159
159
  prerelease: false
160
160
  requirement: &id010 !ruby/object:Gem::Requirement
161
161
  none: false
@@ -166,12 +166,26 @@ dependencies:
166
166
  segments:
167
167
  - 0
168
168
  version: "0"
169
- type: :development
169
+ type: :runtime
170
170
  version_requirements: *id010
171
171
  - !ruby/object:Gem::Dependency
172
- name: rspec
172
+ name: jeweler
173
173
  prerelease: false
174
174
  requirement: &id011 !ruby/object:Gem::Requirement
175
+ none: false
176
+ requirements:
177
+ - - ">="
178
+ - !ruby/object:Gem::Version
179
+ hash: 3
180
+ segments:
181
+ - 0
182
+ version: "0"
183
+ type: :development
184
+ version_requirements: *id011
185
+ - !ruby/object:Gem::Dependency
186
+ name: rspec
187
+ prerelease: false
188
+ requirement: &id012 !ruby/object:Gem::Requirement
175
189
  none: false
176
190
  requirements:
177
191
  - - ">="
@@ -183,7 +197,7 @@ dependencies:
183
197
  - 9
184
198
  version: 1.2.9
185
199
  type: :development
186
- version_requirements: *id011
200
+ version_requirements: *id012
187
201
  description: An engine for search-engine-optimized content management.
188
202
  email: corey@seologic.com
189
203
  executables: []