rich 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/README.rdoc +14 -5
  2. data/lib/rich.rb +24 -6
  3. data/lib/rich/version.rb +1 -1
  4. metadata +4 -4
@@ -187,9 +187,17 @@ Set <tt>:allow_embeds</tt> to <tt>true</tt> to enable an extra button on the CKE
187
187
 
188
188
  === Scoping (filtering in the file manager)
189
189
 
190
- It is possible to scope any files available in the file manager to the current object you are editing. This works by associating your objects type and its <tt>id</tt> with any uploaded files.
190
+ It is possible to limit the files available in the file manager to a more relevant subset. This subset can either be comprised of collection of your choosing, or be tied to the current object you are editing (this works by associating your objects type and its <tt>id</tt> with any uploaded files).
191
191
 
192
- To enable scoping for a Rich editor or picker, simply pass in the <tt>:scoped</tt> option and set it to <tt>true</tt>. A Rails Admin example:
192
+ To scope the file manager to a collection of your choosing, pass the collection name into the <tt>:scoped</tt> configuration option. This collection name is just a string; pick anything you like. In Rails Admin:
193
+
194
+ field :cover_images, :rich_editor do
195
+ config({
196
+ :scoped => "book covers"
197
+ })
198
+ end
199
+
200
+ To scope the filemanager to a specific object, simply pass in <tt>true</tt>. Again for Rails Admin:
193
201
 
194
202
  field :body, :rich_editor do
195
203
  config({
@@ -197,11 +205,11 @@ To enable scoping for a Rich editor or picker, simply pass in the <tt>:scoped</t
197
205
  })
198
206
  end
199
207
 
200
- Note that it is up to you to determine if scoping is possible. For example, a new object has no id yet, so there is nothing to scope to (yet). You could hide Rich in that case, until the object has been saved. If you do enable Rich but there is no id to scope to, Rich will disable scoping until an id has been set. This will effectively hide any files previously uploaded (before the save), which is most likely not what you want. So think twice about using this option, and implement it correctly when you do.
208
+ In the latter example (scoping to an object), it is up to you to determine if scoping is possible. For example, a new object has no id yet, so there is nothing to scope to (yet). You could hide Rich in that case, until the object has been saved. If you do enable Rich but there is no id to scope to, Rich will disable scoping until an id has been set. This will effectively hide any files previously uploaded (before the save), which is most likely not what you want. So think twice about using this option, and implement it correctly when you do.
201
209
 
202
- Also note that this is not secure. At all. It is purely meant as a convenience to save you from wading through tons of irrelevant files. If need to hide files from prying eyes, you need something else.
210
+ Also note that none of this is secure. At all. It is purely meant as a convenience to save you from wading through tons of irrelevant files. If need to hide files from prying eyes, you need something else.
203
211
 
204
- == Planned features
212
+ == Planned features & ideas
205
213
 
206
214
  * drag & drop uploading
207
215
  * finding/filtering assets
@@ -222,6 +230,7 @@ Also note that this is not secure. At all. It is purely meant as a convenience t
222
230
  * Paperclip - https://github.com/thoughtbot/paperclip
223
231
  * Silk icons - http://www.famfamfam.com/lab/icons/silk/
224
232
  * Iconic icons - http://somerandomdude.com/work/iconic/
233
+ * Kaminari - https://github.com/amatsuda/kaminari
225
234
 
226
235
  == Contributing
227
236
 
@@ -91,13 +91,31 @@ module Rich
91
91
  end
92
92
 
93
93
  # object scoping
94
- if(editor_options[:scoped] == true)
95
- if(scope_type != nil && scope_id != nil)
96
- editor_options[:scope_type] = scope_type
97
- editor_options[:scope_id] = scope_id
94
+ # todo: support scoped=string to scope to collections, set id to 0
95
+ unless editor_options[:scoped] == nil
96
+
97
+ # true signifies object level scoping
98
+ if editor_options[:scoped] == true
99
+
100
+ if(scope_type != nil && scope_id != nil)
101
+ editor_options[:scope_type] = scope_type
102
+ editor_options[:scope_id] = scope_id
103
+ else
104
+ # cannot scope new objects
105
+ editor_options[:scoped] = false
106
+ end
107
+
98
108
  else
99
- # cannot scope new objects
100
- editor_options[:scoped] = false
109
+
110
+ # not true (but also not nil) signifies scoping to a collection
111
+ if(scope_type != nil)
112
+ editor_options[:scope_type] = editor_options[:scoped]
113
+ editor_options[:scope_id] = 0
114
+ editor_options[:scoped] = true
115
+ else
116
+ editor_options[:scoped] = false
117
+ end
118
+
101
119
  end
102
120
  end
103
121
 
@@ -1,3 +1,3 @@
1
1
  module Rich
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rich
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 1
10
- version: 1.0.1
9
+ - 2
10
+ version: 1.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Bastiaan Terhorst
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-02-08 00:00:00 Z
18
+ date: 2012-02-11 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: rails