hermitage 0.0.2.1 → 0.0.3
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/CHANGELOG.md +10 -0
- data/README.md +41 -24
- data/app/assets/javascripts/hermitage.js.coffee +332 -182
- data/hermitage.gemspec +2 -2
- data/lib/generators/hermitage/templates/hermitage.rb +2 -2
- data/lib/hermitage/defaults.rb +6 -3
- data/lib/hermitage/version.rb +1 -1
- data/lib/hermitage/view_helpers.rb +5 -4
- data/spec/dummy/app/models/dummy.rb +5 -0
- data/spec/features/bottom_panel_spec.rb +28 -0
- data/spec/features/navigation_spec.rb +48 -20
- data/spec/features/resize_spec.rb +51 -0
- data/spec/features/scale_spec.rb +11 -11
- data/spec/features/viewer_customization_spec.rb +44 -78
- data/spec/features/viewer_spec.rb +1 -1
- data/spec/features_helper.rb +1 -1
- data/spec/lib/hermitage/defaults_spec.rb +3 -2
- data/spec/lib/hermitage/view_helpers_spec.rb +8 -2
- metadata +9 -5
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
### 0.0.3 ###
|
2
|
+
|
3
|
+
* *Attention*! In this version some options were renamed: attribute_full_size -> original, attribute_thumbnail -> thumbnail.
|
4
|
+
* Added more viewer customization options
|
5
|
+
* Ability to set any custom CSS for any viewer element
|
6
|
+
* Ability to enable or disable looped navigation
|
7
|
+
* More neat navigation buttons
|
8
|
+
* Adjust viewer on window resize
|
9
|
+
* Bottom panel added. Now you can set image descriptions by passing `title` option to `render_gallery_for` method or config.
|
10
|
+
|
1
11
|
### 0.0.2.1 ###
|
2
12
|
|
3
13
|
* Fixed conflict with Twitter Bootstrap in Firefox and Opera.
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
[](https://travis-ci.org/ImmaculatePine/hermitage)
|
4
4
|
|
5
|
-
Ruby library for generation of image galleries (thumbnails and
|
5
|
+
Ruby library for generation of image galleries (thumbnails and original images viewer).
|
6
6
|
|
7
7
|
## Requirements
|
8
8
|
|
@@ -60,13 +60,13 @@ You can pass options hash to `render_gallery_for` method if you want to customiz
|
|
60
60
|
E.g. your `Photo` model has methods `image_full` and `image_thumb` that return path to full image and its thumbnail, respectively.
|
61
61
|
Then you can write in your view file:
|
62
62
|
|
63
|
-
render_gallery_for @photos,
|
63
|
+
render_gallery_for @photos, original: 'image_full', thumbnail: 'image_thumb'
|
64
64
|
|
65
65
|
Then Hermitage will use the specified methods to get paths to your images and thumbnails.
|
66
66
|
|
67
67
|
If the only method returns both paths according to passed parameters you can specify it like this:
|
68
68
|
|
69
|
-
render_gallery_for @posts,
|
69
|
+
render_gallery_for @posts, original: 'attachment(:full)', thumbnail: 'attachment(:thumbnail)'
|
70
70
|
|
71
71
|
#### Markup
|
72
72
|
|
@@ -80,7 +80,7 @@ Hermitage renders markup that will look nice with Twitter Bootstrap by default:
|
|
80
80
|
</li>
|
81
81
|
</ul>
|
82
82
|
|
83
|
-
You can configure any element of this markup by overwriting `list_tag`, `item_tag`, `list_class`, `item_class`, `link_class` and `
|
83
|
+
You can configure any element of this markup by overwriting `list_tag`, `item_tag`, `list_class`, `item_class`, `link_class`, `image_class` and `title` properties.
|
84
84
|
|
85
85
|
For example this line of code:
|
86
86
|
|
@@ -96,6 +96,21 @@ will render the following markup:
|
|
96
96
|
</p>
|
97
97
|
</div>
|
98
98
|
|
99
|
+
#### Specify Image Title
|
100
|
+
|
101
|
+
You can add `title` attribute to generated links by passing `title` option to `render_gallery_for` method:
|
102
|
+
|
103
|
+
render_gallery_for @images, title: 'description' # assuming that image.description returns some text
|
104
|
+
|
105
|
+
It will render something like that:
|
106
|
+
|
107
|
+
<div class="thumbnails">
|
108
|
+
...
|
109
|
+
<a href="/path/to/full/image" class="thumbnail" rel="hermitage" title="This is photo of my cat.">
|
110
|
+
...
|
111
|
+
|
112
|
+
If the link has title attribute there will be bottom panel with this text when you open the gallery.
|
113
|
+
|
99
114
|
#### Slicing
|
100
115
|
|
101
116
|
If you are using Twitter Bootstrap framework and your gallery is inside `.row-fluid` block the markup above will not look awesome.
|
@@ -124,8 +139,8 @@ You can overwrite :default config. These changes will be applied to all the gall
|
|
124
139
|
Uncoment the following lines in config/initializers/hermitage.rb file and make some changes here:
|
125
140
|
|
126
141
|
Hermitage.configs[:default].merge!({
|
127
|
-
|
128
|
-
|
142
|
+
original: 'image.url(:medium)',
|
143
|
+
thumbnail: 'image.url(:small)'
|
129
144
|
})
|
130
145
|
|
131
146
|
Now Hermitage will use `image.url` method with :medium or :small argument to get images for the gallery.
|
@@ -155,13 +170,13 @@ Then your config/initializers/hermitage.rb could looks like this:
|
|
155
170
|
# Some rules for :default config if needed...
|
156
171
|
|
157
172
|
Hermitage.configs[:pictures] = {
|
158
|
-
|
159
|
-
|
173
|
+
original: 'image_path',
|
174
|
+
thumbnail: 'image_path(:small)'
|
160
175
|
}
|
161
176
|
|
162
177
|
Hermitage.configs[:posts] = {
|
163
|
-
|
164
|
-
|
178
|
+
original: 'attachment',
|
179
|
+
thumbnail: 'attachment(:tiny)',
|
165
180
|
list_tag: :div,
|
166
181
|
item_tag: div,
|
167
182
|
list_class: 'posts',
|
@@ -184,30 +199,32 @@ So, Hermitage looks for parameters with the following priority:
|
|
184
199
|
You can customize appearance of Hermitage image viewer. All you need is to add to any of your .js or .coffee files lines like this:
|
185
200
|
|
186
201
|
hermitage.darkening.opacity = 0
|
187
|
-
hermitage.
|
202
|
+
hermitage.navigationButtons.styles = { color: '#faeedd' }
|
188
203
|
|
189
|
-
In the example above the darkening will be disabled and navigation buttons will change their color.
|
204
|
+
In the example above the darkening will be disabled and both navigation buttons will change their color.
|
190
205
|
|
191
206
|
You can customize the following parameters:
|
192
207
|
|
193
|
-
* `
|
208
|
+
* `looped` - set it to false if after the last image the first should not be shown
|
194
209
|
* `darkening.opacity` - opacity of darkening layer (0 if it should be disabled)
|
195
|
-
* `darkening.
|
196
|
-
* `
|
197
|
-
* `
|
198
|
-
* `
|
199
|
-
* `
|
200
|
-
* `
|
210
|
+
* `darkening.styles` - any custom CSS for darkening layer
|
211
|
+
* `navigationButtons.enabled` - are there navigation buttons
|
212
|
+
* `navigationButtons.styles` - any custom CSS for both navigation buttons
|
213
|
+
* `navigationButtons.next.styles` - any custom CSS for next navigation button
|
214
|
+
* `navigationButtons.previous.styles` - any custom CSS for previous navigation button
|
215
|
+
* `navigationButtons.next.text` - text for next navigation button
|
216
|
+
* `navigationButtons.previous.text` - text for previous navigation button
|
201
217
|
* `closeButton.enabled` - is there close button
|
202
218
|
* `closeButton.text` - close button's text
|
203
|
-
* `closeButton.
|
204
|
-
* `
|
205
|
-
* `
|
206
|
-
* `
|
219
|
+
* `closeButton.styles` - any custom CSS for close button
|
220
|
+
* `image.styles` - any custom CSS for current image
|
221
|
+
* `bottomPanel.styles` - any custom CSS for bottom panel
|
222
|
+
* `bottomPanel.text.styles` - any custom CSS for text block of bottom panel
|
207
223
|
* `minimumSize.width` - minimum width of scaled image, px
|
208
224
|
* `minimumSize.height` - minimum height of scaled image, px
|
209
225
|
* `animationDuration` - duration of UI animations, ms
|
210
|
-
|
226
|
+
* `resizeTimeout` - timeout before moving elements to the proper places after resizing, ms
|
227
|
+
|
211
228
|
## Contributing
|
212
229
|
|
213
230
|
1. Fork it
|