editorial_logic 1.1.6 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Gemfile CHANGED
@@ -9,6 +9,7 @@ gem 'mongoid'
9
9
  gem 'rails', '>= 3.0.1'
10
10
  gem 'scaffold_logic'#, :path => '~/Documents/projects/scaffold_logic'
11
11
  gem 'SystemTimer'
12
+ gem 'tanker'
12
13
 
13
14
  group :development do
14
15
  gem 'jeweler'
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.6
1
+ 1.3.0
@@ -2,12 +2,16 @@ class ManagedContent
2
2
  include EditorialLogic::Base
3
3
  include Mongoid::Document
4
4
  include Mongoid::Timestamps
5
+ include Tanker
5
6
 
6
- store_in :documents
7
- mount_uploader :document, DocumentUploader, :mount_on => :document_filename
7
+ # Constants ======================================================================================
8
+ STATES = ['draft', 'published']
8
9
 
9
- # Mongo Config ===================================================================================
10
+ # Scopes ===================================================================================
11
+ scope :drafts, :where => {:state => 'draft'}
12
+ scope :published, :where => {:state => 'published'}
10
13
 
14
+ # Mongo Config ===================================================================================
11
15
  field :author
12
16
  field :headline # used as: (1) title element of page; (2) link text of links in FAQ index page - Corey was using this as the header of the page as well. - THIS IS THE QUESTION
13
17
  field :subheader
@@ -18,7 +22,7 @@ class ManagedContent
18
22
  field :state, :default => 'draft'
19
23
  field :publication_date, :type => Date
20
24
  field :revision_date, :type => Date
21
- field :summary # used as: (1) meta description of page (2) link title attribute of any link pointing to that page
25
+ field :summary # used as: (1) meta description of page (2) link title attribute of any link pointing to that page
22
26
  field :related_contents, :type => Array, :default => []
23
27
  field :kind
24
28
 
@@ -30,31 +34,36 @@ class ManagedContent
30
34
  index :state, :unique => false
31
35
  index :kind
32
36
 
33
- # Constants ======================================================================================
34
- STATES = ['draft', 'published']
35
-
36
- # Scopes ===================================================================================
37
- scope :drafts, :where => {:state => 'draft'}
38
- scope :published, :where => {:state => 'published'}
39
-
40
- # Relationships ==================================================================================
41
- embeds_many :sections
42
37
  embedded_in :publication, :inverse_of => :managed_contents
38
+ embeds_many :sections
43
39
 
44
40
  # Behavior =======================================================================================
45
41
  alias_method :answer, :content
46
42
  alias_method :definition, :content
47
- alias_method :term, :headline
48
43
  alias_method :question, :headline
44
+ alias_method :term, :headline
49
45
  attr_accessor :desired_slug
50
46
  has_slug :desired_slug
47
+ mount_uploader :document, DocumentUploader, :mount_on => :document_filename
48
+ store_in :documents
49
+
50
+ # Tanker =========================================================================================
51
+ tankit 'idx' do
52
+ indexes :author
53
+ indexes :content
54
+ indexes :headline
55
+ indexes :keywords
56
+ indexes :summary
57
+ end
51
58
 
52
- # Custom Validators ==============================================================================
59
+ after_destroy :delete_tank_indexes
60
+ after_save :update_tank_indexes
53
61
 
62
+ # Validations ====================================================================================
54
63
  class DesiredSlugPresenceValidator < ActiveModel::EachValidator
55
64
  def validate_each(object, attribute, value)
56
65
  unless object.desired_slug || object.slug
57
- object.errors[attribute] << (options[:message] || " cannot be blank.")
66
+ object.errors[attribute] << (options[:message] || ' cannot be blank.')
58
67
  end
59
68
  end
60
69
  end
@@ -63,7 +72,7 @@ class ManagedContent
63
72
  def validate_each(object, attribute, value)
64
73
  unless object.kind == 'Multiple Pages' || object.kind == 'Document'
65
74
  if value.blank?
66
- object.errors[attribute] << (options[:message] || " cannot be blank.")
75
+ object.errors[attribute] << (options[:message] || ' cannot be blank.')
67
76
  end
68
77
  end
69
78
  end
@@ -73,22 +82,18 @@ class ManagedContent
73
82
  def validate_each(object, attribute, value)
74
83
  if object.kind == 'Document'
75
84
  if value.blank?
76
- object.errors[attribute] << (options[:message] || " file attachment cannot be blank.")
85
+ object.errors[attribute] << (options[:message] || ' file attachment cannot be blank.')
77
86
  end
78
87
  end
79
88
  end
80
89
  end
81
90
 
82
- # Validations ====================================================================================
83
- validates_uniqueness_of :slug
84
- validates_presence_of :headline
85
- validates :desired_slug, :desired_slug_presence => true
86
91
  validates :content, :content_presence => true
87
-
88
- # Class methods ==================================================================================
92
+ validates :desired_slug, :desired_slug_presence => true
93
+ validates_presence_of :headline
94
+ validates_uniqueness_of :slug
89
95
 
90
96
  # Instance methods ===============================================================================
91
-
92
97
  def add_related_content(content_id)
93
98
  self.related_contents ||= []
94
99
  self.related_contents << content_id unless self.related_contents.include?(content_id)
@@ -104,19 +109,19 @@ class ManagedContent
104
109
  end
105
110
 
106
111
  def has_sections?
107
- self.kind == "Multiple Pages"
112
+ self.kind == 'Multiple Pages'
108
113
  end
109
114
 
110
115
  def humanize_path
111
- if kind == "Document"
112
- self.document_url
113
- else
114
- "/#{self.publication.slug}/#{self.slug}/".gsub('//','/')
115
- end
116
+ self.path
117
+ end
118
+
119
+ def path
120
+ kind == 'Document' ? self.document_url : "/#{self.publication.slug}/#{self.slug}/".gsub('//', '/')
116
121
  end
117
122
 
118
123
  def publish!
119
- self.update_attributes(:state => 'published', :publication_date => Time.zone.now)
124
+ self.update_attributes :state => 'published', :publication_date => Time.zone.now
120
125
  end
121
126
 
122
127
  def related_content
@@ -135,6 +140,14 @@ class ManagedContent
135
140
  self.save
136
141
  end
137
142
 
143
+ def search_description
144
+ self.summary.gsub(/<\/?[^>]*>/, '')[0..199].html_safe
145
+ end
146
+
147
+ def search_title
148
+ self.headline
149
+ end
150
+
138
151
  def state=(state)
139
152
  self[:state] = state.downcase
140
153
  end
@@ -32,4 +32,8 @@ EditorialLogic::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
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{editorial_logic}
8
- s.version = "1.1.6"
8
+ s.version = "1.3.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 enabling managed content, including articles, blogs, FAQs and glossaries.}
14
14
  s.email = %q{corey@seologic.com}
15
15
  s.files = [
@@ -827,6 +827,7 @@ Gem::Specification.new do |s|
827
827
  s.add_runtime_dependency(%q<rails>, [">= 3.0.1"])
828
828
  s.add_runtime_dependency(%q<scaffold_logic>, [">= 0"])
829
829
  s.add_runtime_dependency(%q<SystemTimer>, [">= 0"])
830
+ s.add_runtime_dependency(%q<tanker>, [">= 0"])
830
831
  s.add_development_dependency(%q<jeweler>, [">= 0"])
831
832
  s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
832
833
  else
@@ -838,6 +839,7 @@ Gem::Specification.new do |s|
838
839
  s.add_dependency(%q<rails>, [">= 3.0.1"])
839
840
  s.add_dependency(%q<scaffold_logic>, [">= 0"])
840
841
  s.add_dependency(%q<SystemTimer>, [">= 0"])
842
+ s.add_dependency(%q<tanker>, [">= 0"])
841
843
  s.add_dependency(%q<jeweler>, [">= 0"])
842
844
  s.add_dependency(%q<rspec>, [">= 1.2.9"])
843
845
  end
@@ -850,6 +852,7 @@ Gem::Specification.new do |s|
850
852
  s.add_dependency(%q<rails>, [">= 3.0.1"])
851
853
  s.add_dependency(%q<scaffold_logic>, [">= 0"])
852
854
  s.add_dependency(%q<SystemTimer>, [">= 0"])
855
+ s.add_dependency(%q<tanker>, [">= 0"])
853
856
  s.add_dependency(%q<jeweler>, [">= 0"])
854
857
  s.add_dependency(%q<rspec>, [">= 1.2.9"])
855
858
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: editorial_logic
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
- - 1
9
- - 6
10
- version: 1.1.6
8
+ - 3
9
+ - 0
10
+ version: 1.3.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
@@ -133,7 +133,7 @@ dependencies:
133
133
  type: :runtime
134
134
  version_requirements: *id008
135
135
  - !ruby/object:Gem::Dependency
136
- name: jeweler
136
+ name: tanker
137
137
  prerelease: false
138
138
  requirement: &id009 !ruby/object:Gem::Requirement
139
139
  none: false
@@ -144,12 +144,26 @@ dependencies:
144
144
  segments:
145
145
  - 0
146
146
  version: "0"
147
- type: :development
147
+ type: :runtime
148
148
  version_requirements: *id009
149
149
  - !ruby/object:Gem::Dependency
150
- name: rspec
150
+ name: jeweler
151
151
  prerelease: false
152
152
  requirement: &id010 !ruby/object:Gem::Requirement
153
+ none: false
154
+ requirements:
155
+ - - ">="
156
+ - !ruby/object:Gem::Version
157
+ hash: 3
158
+ segments:
159
+ - 0
160
+ version: "0"
161
+ type: :development
162
+ version_requirements: *id010
163
+ - !ruby/object:Gem::Dependency
164
+ name: rspec
165
+ prerelease: false
166
+ requirement: &id011 !ruby/object:Gem::Requirement
153
167
  none: false
154
168
  requirements:
155
169
  - - ">="
@@ -161,7 +175,7 @@ dependencies:
161
175
  - 9
162
176
  version: 1.2.9
163
177
  type: :development
164
- version_requirements: *id010
178
+ version_requirements: *id011
165
179
  description: An engine for enabling managed content, including articles, blogs, FAQs and glossaries.
166
180
  email: corey@seologic.com
167
181
  executables: []