blog_logic 1.4.5 → 1.4.6

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -2,32 +2,29 @@ source 'http://rubygems.org'
2
2
 
3
3
  gem 'bson_ext'
4
4
  gem 'carrierwave-mongoid', :require => 'carrierwave/mongoid'
5
- gem 'ckeditor', :git => 'git://github.com/Bantik/rails-ckeditor.git', :branch => 'rails3_mongoid'
5
+ gem 'ckeditor'
6
6
  gem 'kaminari'
7
+ gem 'mini_magick'
7
8
  gem 'mongoid-tree', :require => 'mongoid/tree'
8
9
  gem 'rails', '3.0.10'
9
- gem 'rmagick', '2.12.2' # version compatible with heroku
10
+ gem 'rmagick', '2.12.2'# version compatible with heroku
10
11
  gem 'scaffold_logic'
11
12
  gem 'stringex'
12
13
  gem 'tanker'
13
14
 
14
15
  group :development do
15
16
  gem 'jeweler'
16
- gem 'nokogiri'
17
17
  end
18
18
 
19
19
  group :test do
20
20
  gem 'be_valid_asset'
21
- gem 'capybara'
22
21
  gem 'cucumber-rails'
23
22
  gem 'database_cleaner'
24
23
  gem 'faker'
25
- gem 'gherkin'
26
24
  gem 'launchy'
27
25
  gem 'machinist_mongo', :require => 'machinist/mongoid'
28
26
  gem 'metric_fu'
29
27
  gem 'mocha'
30
- gem 'rcov'
31
28
  gem 'rspec-rails'
32
29
  gem 'yard'
33
30
  end
data/Gemfile.local CHANGED
@@ -2,32 +2,29 @@ source 'http://rubygems.org'
2
2
 
3
3
  gem 'bson_ext'
4
4
  gem 'carrierwave-mongoid', :require => 'carrierwave/mongoid'
5
- gem 'ckeditor', :git => 'git://github.com/Bantik/rails-ckeditor.git', :branch => 'rails3_mongoid'
5
+ gem 'ckeditor'
6
6
  gem 'kaminari'
7
+ gem 'mini_magick'
7
8
  gem 'mongoid-tree', :require => 'mongoid/tree'
8
9
  gem 'rails', '3.0.10'
9
- gem 'rmagick', '2.12.2' # version compatible with heroku
10
+ gem 'rmagick', '2.12.2'# version compatible with heroku
10
11
  gem 'scaffold_logic', :path => '~/Documents/projects/scaffold_logic'
11
12
  gem 'stringex'
12
13
  gem 'tanker'
13
14
 
14
15
  group :development do
15
16
  gem 'jeweler'
16
- gem 'nokogiri'
17
17
  end
18
18
 
19
19
  group :test do
20
20
  gem 'be_valid_asset'
21
- gem 'capybara'
22
21
  gem 'cucumber-rails'
23
22
  gem 'database_cleaner'
24
23
  gem 'faker'
25
- gem 'gherkin'
26
24
  gem 'launchy'
27
25
  gem 'machinist_mongo', :require => 'machinist/mongoid'
28
26
  gem 'metric_fu'
29
27
  gem 'mocha'
30
- gem 'rcov'
31
28
  gem 'rspec-rails'
32
29
  gem 'yard'
33
30
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.4.5
1
+ 1.4.6
@@ -1,99 +1,7 @@
1
- require 'mime/types'
2
-
3
1
  class Ckeditor::Asset
4
- include Mongoid::Document
5
- include Mongoid::Timestamps
6
-
7
- field :data
8
- field :data_file_name
9
- field :data_content_type
10
- field :data_file_size, :type => Integer
11
- field :assetable_id, :type => String
12
- field :assetable_type
13
- field :kind
14
- field :guid
15
- field :locale, :default => 0, :type => Integer
16
-
17
- mount_uploader :data, BlogImageUploader
18
-
19
- before_validation :make_content_type
20
- before_create :make_dimensions
21
-
22
- def url(*args)
23
- data.url(*args)
24
- end
25
-
26
- alias :public_filename :url
27
-
28
- def filename
29
- data_file_name
30
- end
31
-
32
- def content_type
33
- data_content_type
34
- end
35
-
36
- def size
37
- data_file_size
38
- end
39
-
40
- def path
41
- data.path
42
- end
43
-
44
- def styles
45
- data.styles
46
- end
47
-
48
- def format_created_at
49
- I18n.l(self.created_at, :format=>"%d.%m.%Y %H:%M")
50
- end
51
-
52
- def to_xml(options = {})
53
- builder = options[:builder] ||= Nokogiri::XML::Builder.new(options)
54
-
55
- builder.send(self.type.to_s.downcase) do |xml|
56
- xml.id_ self.id
57
- xml.filename self.filename
58
- xml.size self.size
59
- xml.path self.url
60
-
61
- xml.styles do
62
- self.styles.each do |style|
63
- xml.send(style.first, self.url(style.first))
64
- end
65
- end unless self.styles.empty?
66
- end
67
-
68
- builder.to_xml
69
- end
70
-
71
- def has_dimensions?
72
- self.respond_to?(:width) && self.respond_to?(:height)
73
- end
74
-
75
- def image?
76
- ["image/jpeg", "image/tiff", "image/png", "image/gif", "image/bmp"].include?(self.data_content_type)
77
- end
78
-
79
- def geometry
80
- @geometry ||= Paperclip::Geometry.from_file(data.to_file)
81
- @geometry
82
- end
83
-
84
- private
85
-
86
- def make_dimensions
87
- if image? && has_dimensions?
88
- self.width = geometry.width
89
- self.height = geometry.height
90
- end
91
- end
92
-
93
- def make_content_type
94
- if data_content_type == "application/octet-stream"
95
- content_types = MIME::Types.type_for(filename)
96
- self.data_content_type = content_types.first.to_s unless content_types.empty?
97
- end
98
- end
2
+ include Ckeditor::Orm::Mongoid::AssetBase
3
+
4
+ delegate :url, :current_path, :size, :content_type, :filename, :to => :data
5
+
6
+ validates_presence_of :data
99
7
  end
@@ -1,35 +1,10 @@
1
1
  class Ckeditor::AttachmentFile < Ckeditor::Asset
2
-
3
- def url(*args)
4
- if [:thumb, :content].include?(args.first)
5
- send("url_#{args.first}")
6
- else
7
- data.url(*args)
8
- end
9
- end
10
-
11
- def url_content
12
- data.url
13
- end
14
-
2
+ mount_uploader :data, CkeditorAttachmentFileUploader, :mount_on => :data_file_name
3
+
15
4
  def url_thumb
16
- extname = File.extname(filename)
17
-
18
- case extname.to_s
19
- when '.swf' then '/javascripts/ckeditor/images/swf.gif'
20
- when '.pdf' then '/javascripts/ckeditor/images/pdf.gif'
21
- when '.doc', '.txt' then '/javascripts/ckeditor/images/doc.gif'
22
- when '.mp3' then '/javascripts/ckeditor/images/mp3.gif'
23
- when '.rar', '.zip', '.tg' then '/javascripts/ckeditor/images/rar.gif'
24
- when '.xls' then '/javascripts/ckeditor/images/xls.gif'
25
- else '/javascripts/ckeditor/images/ckfnothumb.gif'
26
- end
5
+ @url_thumb ||= begin
6
+ extname = File.extname(filename).gsub(/^\./, '')
7
+ "/javascripts/ckeditor/filebrowser/images/thumbs/#{extname}.gif"
8
+ end
27
9
  end
28
-
29
- def to_json(options = {})
30
- options[:methods] ||= []
31
- options[:methods] << :url_content
32
- options[:methods] << :url_thumb
33
- super options
34
- end
35
10
  end
@@ -1,17 +1,7 @@
1
1
  class Ckeditor::Picture < Ckeditor::Asset
2
-
2
+ mount_uploader :data, CkeditorPictureUploader, :mount_on => :data_file_name
3
+
3
4
  def url_content
4
5
  url(:content)
5
6
  end
6
-
7
- def url_thumb
8
- url(:thumb)
9
- end
10
-
11
- def to_json(options = {})
12
- options[:methods] ||= []
13
- options[:methods] << :url_content
14
- options[:methods] << :url_thumb
15
- super options
16
- end
17
7
  end
@@ -0,0 +1,42 @@
1
+ # encoding: utf-8
2
+ class CkeditorAttachmentFileUploader < CarrierWave::Uploader::Base
3
+ include Ckeditor::Backend::CarrierWave
4
+
5
+ # Include RMagick or ImageScience support:
6
+ # include CarrierWave::RMagick
7
+ # include CarrierWave::MiniMagick
8
+ # include CarrierWave::ImageScience
9
+
10
+ # Choose what kind of storage to use for this uploader:
11
+ storage :file
12
+
13
+ # Override the directory where uploaded files will be stored.
14
+ # This is a sensible default for uploaders that are meant to be mounted:
15
+ def store_dir
16
+ "ckeditor_assets/attachments/#{model.id}"
17
+ end
18
+
19
+ # Provide a default URL as a default if there hasn't been a file uploaded:
20
+ # def default_url
21
+ # "/images/fallback/" + [version_name, "default.png"].compact.join('_')
22
+ # end
23
+
24
+ # Process files as they are uploaded:
25
+ # process :scale => [200, 300]
26
+ #
27
+ # def scale(width, height)
28
+ # # do something
29
+ # end
30
+
31
+ # Add a white list of extensions which are allowed to be uploaded.
32
+ # For images you might use something like this:
33
+ def extension_white_list
34
+ Ckeditor.attachment_file_types
35
+ end
36
+
37
+ # Override the filename of the uploaded files:
38
+ # Avoid using model.id or version_name here, see uploader/store.rb for details.
39
+ # def filename
40
+ # "something.jpg" if original_filename
41
+ # end
42
+ end
@@ -0,0 +1,53 @@
1
+ # encoding: utf-8
2
+ class CkeditorPictureUploader < CarrierWave::Uploader::Base
3
+ include Ckeditor::Backend::CarrierWave
4
+
5
+ # Include RMagick or ImageScience support:
6
+ # include CarrierWave::RMagick
7
+ include CarrierWave::MiniMagick
8
+ # include CarrierWave::ImageScience
9
+
10
+ # Choose what kind of storage to use for this uploader:
11
+ storage :file
12
+
13
+ # Override the directory where uploaded files will be stored.
14
+ # This is a sensible default for uploaders that are meant to be mounted:
15
+ def store_dir
16
+ "ckeditor_assets/pictures/#{model.id}"
17
+ end
18
+
19
+ # Provide a default URL as a default if there hasn't been a file uploaded:
20
+ # def default_url
21
+ # "/images/fallback/" + [version_name, "default.png"].compact.join('_')
22
+ # end
23
+
24
+ # Process files as they are uploaded:
25
+ # process :scale => [200, 300]
26
+ #
27
+ # def scale(width, height)
28
+ # # do something
29
+ # end
30
+
31
+ process :read_dimensions
32
+
33
+ # Create different versions of your uploaded files:
34
+ version :thumb do
35
+ process :resize_to_fill => [118, 100]
36
+ end
37
+
38
+ version :content do
39
+ process :resize_to_limit => [800, 800]
40
+ end
41
+
42
+ # Add a white list of extensions which are allowed to be uploaded.
43
+ # For images you might use something like this:
44
+ def extension_white_list
45
+ Ckeditor.image_file_types
46
+ end
47
+
48
+ # Override the filename of the uploaded files:
49
+ # Avoid using model.id or version_name here, see uploader/store.rb for details.
50
+ # def filename
51
+ # "something.jpg" if original_filename
52
+ # end
53
+ end
data/blog_logic.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "blog_logic"
8
- s.version = "1.4.5"
8
+ s.version = "1.4.6"
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 = "2011-11-22"
12
+ s.date = "2011-11-28"
13
13
  s.description = "An engine for search-engine-optimized blog management."
14
14
  s.email = "corey@seologic.com"
15
15
  s.extra_rdoc_files = [
@@ -36,6 +36,8 @@ Gem::Specification.new do |s|
36
36
  "app/models/ckeditor/picture.rb",
37
37
  "app/models/post.rb",
38
38
  "app/uploaders/blog_image_uploader.rb",
39
+ "app/uploaders/ckeditor_attachment_file_uploader.rb",
40
+ "app/uploaders/ckeditor_picture_uploader.rb",
39
41
  "app/views/admin/blog_categories/_blog_category.html.erb",
40
42
  "app/views/admin/blog_categories/_form.html.erb",
41
43
  "app/views/admin/blog_categories/edit.html.erb",
@@ -72,6 +74,7 @@ Gem::Specification.new do |s|
72
74
  "config/environments/development.rb",
73
75
  "config/environments/production.rb",
74
76
  "config/environments/test.rb",
77
+ "config/initializers/ckeditor.rb",
75
78
  "config/initializers/formats.rb",
76
79
  "config/initializers/metric_fu.rb",
77
80
  "config/initializers/secret_token.rb",
@@ -123,6 +126,7 @@ Gem::Specification.new do |s|
123
126
  s.add_runtime_dependency(%q<carrierwave-mongoid>, [">= 0"])
124
127
  s.add_runtime_dependency(%q<ckeditor>, [">= 0"])
125
128
  s.add_runtime_dependency(%q<kaminari>, [">= 0"])
129
+ s.add_runtime_dependency(%q<mini_magick>, [">= 0"])
126
130
  s.add_runtime_dependency(%q<mongoid-tree>, [">= 0"])
127
131
  s.add_runtime_dependency(%q<rails>, ["= 3.0.10"])
128
132
  s.add_runtime_dependency(%q<rmagick>, ["= 2.12.2"])
@@ -130,13 +134,13 @@ Gem::Specification.new do |s|
130
134
  s.add_runtime_dependency(%q<stringex>, [">= 0"])
131
135
  s.add_runtime_dependency(%q<tanker>, [">= 0"])
132
136
  s.add_development_dependency(%q<jeweler>, [">= 0"])
133
- s.add_development_dependency(%q<nokogiri>, [">= 0"])
134
137
  s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
135
138
  else
136
139
  s.add_dependency(%q<bson_ext>, [">= 0"])
137
140
  s.add_dependency(%q<carrierwave-mongoid>, [">= 0"])
138
141
  s.add_dependency(%q<ckeditor>, [">= 0"])
139
142
  s.add_dependency(%q<kaminari>, [">= 0"])
143
+ s.add_dependency(%q<mini_magick>, [">= 0"])
140
144
  s.add_dependency(%q<mongoid-tree>, [">= 0"])
141
145
  s.add_dependency(%q<rails>, ["= 3.0.10"])
142
146
  s.add_dependency(%q<rmagick>, ["= 2.12.2"])
@@ -144,7 +148,6 @@ Gem::Specification.new do |s|
144
148
  s.add_dependency(%q<stringex>, [">= 0"])
145
149
  s.add_dependency(%q<tanker>, [">= 0"])
146
150
  s.add_dependency(%q<jeweler>, [">= 0"])
147
- s.add_dependency(%q<nokogiri>, [">= 0"])
148
151
  s.add_dependency(%q<rspec>, [">= 1.2.9"])
149
152
  end
150
153
  else
@@ -152,6 +155,7 @@ Gem::Specification.new do |s|
152
155
  s.add_dependency(%q<carrierwave-mongoid>, [">= 0"])
153
156
  s.add_dependency(%q<ckeditor>, [">= 0"])
154
157
  s.add_dependency(%q<kaminari>, [">= 0"])
158
+ s.add_dependency(%q<mini_magick>, [">= 0"])
155
159
  s.add_dependency(%q<mongoid-tree>, [">= 0"])
156
160
  s.add_dependency(%q<rails>, ["= 3.0.10"])
157
161
  s.add_dependency(%q<rmagick>, ["= 2.12.2"])
@@ -159,7 +163,6 @@ Gem::Specification.new do |s|
159
163
  s.add_dependency(%q<stringex>, [">= 0"])
160
164
  s.add_dependency(%q<tanker>, [">= 0"])
161
165
  s.add_dependency(%q<jeweler>, [">= 0"])
162
- s.add_dependency(%q<nokogiri>, [">= 0"])
163
166
  s.add_dependency(%q<rspec>, [">= 1.2.9"])
164
167
  end
165
168
  end
@@ -0,0 +1,6 @@
1
+ if Object.const_defined?('Ckeditor')
2
+ Ckeditor.setup do |config|
3
+ require 'ckeditor/orm/mongoid'
4
+ config.path = 'public/javascripts'
5
+ end
6
+ end
@@ -30,7 +30,7 @@ Feature: Post to blog
30
30
  Then I should see "Create a New Post"
31
31
  And I fill in "post_title" with "My First Post"
32
32
  And I select "Draft" from "post_state"
33
- And I fill in "content_field" with "Blah blah blah"
33
+ And I fill in "post_content" with "Blah blah blah"
34
34
  And I press "Save"
35
35
  Then I should see "About This Post"
36
36
  And I should see "My First Post"
@@ -73,4 +73,4 @@ Feature: Post to blog
73
73
  And I follow "Manage Posts"
74
74
  And I press "" within "[@class='crud_links']"
75
75
  Then I should see "Blog Posts"
76
- And I should not see "Foo"
76
+ And I should not see "Foo"
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blog_logic
3
3
  version: !ruby/object:Gem::Version
4
- hash: 13
4
+ hash: 11
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 4
9
- - 5
10
- version: 1.4.5
9
+ - 6
10
+ version: 1.4.6
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-11-22 00:00:00 Z
18
+ date: 2011-11-28 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: bson_ext
@@ -74,7 +74,7 @@ dependencies:
74
74
  type: :runtime
75
75
  version_requirements: *id004
76
76
  - !ruby/object:Gem::Dependency
77
- name: mongoid-tree
77
+ name: mini_magick
78
78
  prerelease: false
79
79
  requirement: &id005 !ruby/object:Gem::Requirement
80
80
  none: false
@@ -88,53 +88,53 @@ dependencies:
88
88
  type: :runtime
89
89
  version_requirements: *id005
90
90
  - !ruby/object:Gem::Dependency
91
- name: rails
91
+ name: mongoid-tree
92
92
  prerelease: false
93
93
  requirement: &id006 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
- - - "="
96
+ - - ">="
97
97
  - !ruby/object:Gem::Version
98
- hash: 19
98
+ hash: 3
99
99
  segments:
100
- - 3
101
100
  - 0
102
- - 10
103
- version: 3.0.10
101
+ version: "0"
104
102
  type: :runtime
105
103
  version_requirements: *id006
106
104
  - !ruby/object:Gem::Dependency
107
- name: rmagick
105
+ name: rails
108
106
  prerelease: false
109
107
  requirement: &id007 !ruby/object:Gem::Requirement
110
108
  none: false
111
109
  requirements:
112
110
  - - "="
113
111
  - !ruby/object:Gem::Version
114
- hash: 59
112
+ hash: 19
115
113
  segments:
116
- - 2
117
- - 12
118
- - 2
119
- version: 2.12.2
114
+ - 3
115
+ - 0
116
+ - 10
117
+ version: 3.0.10
120
118
  type: :runtime
121
119
  version_requirements: *id007
122
120
  - !ruby/object:Gem::Dependency
123
- name: scaffold_logic
121
+ name: rmagick
124
122
  prerelease: false
125
123
  requirement: &id008 !ruby/object:Gem::Requirement
126
124
  none: false
127
125
  requirements:
128
- - - ">="
126
+ - - "="
129
127
  - !ruby/object:Gem::Version
130
- hash: 3
128
+ hash: 59
131
129
  segments:
132
- - 0
133
- version: "0"
130
+ - 2
131
+ - 12
132
+ - 2
133
+ version: 2.12.2
134
134
  type: :runtime
135
135
  version_requirements: *id008
136
136
  - !ruby/object:Gem::Dependency
137
- name: stringex
137
+ name: scaffold_logic
138
138
  prerelease: false
139
139
  requirement: &id009 !ruby/object:Gem::Requirement
140
140
  none: false
@@ -148,7 +148,7 @@ dependencies:
148
148
  type: :runtime
149
149
  version_requirements: *id009
150
150
  - !ruby/object:Gem::Dependency
151
- name: tanker
151
+ name: stringex
152
152
  prerelease: false
153
153
  requirement: &id010 !ruby/object:Gem::Requirement
154
154
  none: false
@@ -162,7 +162,7 @@ dependencies:
162
162
  type: :runtime
163
163
  version_requirements: *id010
164
164
  - !ruby/object:Gem::Dependency
165
- name: jeweler
165
+ name: tanker
166
166
  prerelease: false
167
167
  requirement: &id011 !ruby/object:Gem::Requirement
168
168
  none: false
@@ -173,10 +173,10 @@ dependencies:
173
173
  segments:
174
174
  - 0
175
175
  version: "0"
176
- type: :development
176
+ type: :runtime
177
177
  version_requirements: *id011
178
178
  - !ruby/object:Gem::Dependency
179
- name: nokogiri
179
+ name: jeweler
180
180
  prerelease: false
181
181
  requirement: &id012 !ruby/object:Gem::Requirement
182
182
  none: false
@@ -234,6 +234,8 @@ files:
234
234
  - app/models/ckeditor/picture.rb
235
235
  - app/models/post.rb
236
236
  - app/uploaders/blog_image_uploader.rb
237
+ - app/uploaders/ckeditor_attachment_file_uploader.rb
238
+ - app/uploaders/ckeditor_picture_uploader.rb
237
239
  - app/views/admin/blog_categories/_blog_category.html.erb
238
240
  - app/views/admin/blog_categories/_form.html.erb
239
241
  - app/views/admin/blog_categories/edit.html.erb
@@ -270,6 +272,7 @@ files:
270
272
  - config/environments/development.rb
271
273
  - config/environments/production.rb
272
274
  - config/environments/test.rb
275
+ - config/initializers/ckeditor.rb
273
276
  - config/initializers/formats.rb
274
277
  - config/initializers/metric_fu.rb
275
278
  - config/initializers/secret_token.rb