refinerycms-page-images 2.0.1 → 2.1.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.
- checksums.yaml +7 -0
- data/.travis.yml +20 -9
- data/Gemfile +22 -51
- data/Rakefile +2 -0
- data/app/assets/javascripts/refinery/page-image-picker.js.erb +173 -150
- data/app/assets/stylesheets/refinery/page-image-picker.css.scss +6 -0
- data/app/views/refinery/admin/pages/tabs/_images.html.erb +2 -1
- data/app/views/refinery/admin/pages/tabs/_images_field.html.erb +15 -3
- data/config/locales/bg.yml +1 -0
- data/config/locales/cs.yml +1 -0
- data/config/locales/de.yml +3 -1
- data/config/locales/en.yml +2 -0
- data/config/locales/es.yml +19 -0
- data/config/locales/fr.yml +1 -0
- data/config/locales/ja.yml +18 -0
- data/config/locales/nl.yml +1 -0
- data/config/locales/pt-BR.yml +1 -0
- data/config/locales/ru.yml +1 -0
- data/config/locales/sk.yml +1 -0
- data/lib/generators/refinery/templates/config/initializers/refinery/page_images.rb.erb +2 -0
- data/lib/refinery/page_images.rb +15 -2
- data/lib/refinery/page_images/configuration.rb +25 -1
- data/lib/refinery/page_images/engine.rb +17 -19
- data/lib/refinery/page_images/extension.rb +2 -2
- data/readme.md +48 -2
- data/refinerycms-page-images.gemspec +7 -8
- data/spec/factories/page-images.rb +2 -2
- data/spec/features/attach_page_images_spec.rb +58 -0
- data/spec/lib/refinery/initializer_spec.rb +42 -0
- data/spec/models/refinery/blog_spec.rb +3 -3
- data/spec/models/refinery/page_spec.rb +26 -16
- data/spec/spec_helper.rb +21 -46
- metadata +43 -82
- data/spec/requests/attach_page_images_spec.rb +0 -29
- data/spec/support/database_cleaner.rb +0 -17
- data/spec/support/devise.rb +0 -8
- data/spec/support/refinery.rb +0 -6
@@ -1,4 +1,5 @@
|
|
1
|
-
<div class='wym_skin_refinery page_part' id='page_image_picker'
|
1
|
+
<div class='wym_skin_refinery page_part' id='page_image_picker'
|
2
|
+
data-input-type="<%= Refinery::PageImages.config.wysiwyg ? 'wym' : 'textarea'%>">
|
2
3
|
<%= render '/refinery/admin/pages/tabs/images_bar', :f => f %>
|
3
4
|
<%= render '/refinery/admin/pages/tabs/images_field', :f => f %>
|
4
5
|
</div>
|
@@ -1,3 +1,13 @@
|
|
1
|
+
<% form_actions = capture do %>
|
2
|
+
<div class='form-actions'>
|
3
|
+
<div class='form-actions-left'>
|
4
|
+
<a class='button js-page-images-done'><%= I18n.t('refinery.js.admin.page_images.done') %></a>
|
5
|
+
</div>
|
6
|
+
</div>
|
7
|
+
<% end %>
|
8
|
+
|
9
|
+
<% modal_class = Refinery::PageImages.config.wysiwyg ? 'wym' : 'plain' %>
|
10
|
+
|
1
11
|
<div class='wym_box field images_field'>
|
2
12
|
<ul id='page_images' class='clearfix'>
|
3
13
|
<%= f.fields_for :images do |image_form| %>
|
@@ -7,25 +17,27 @@
|
|
7
17
|
<% index = image_form.object_name.split('[').last.split(']').first.to_i %>
|
8
18
|
<%= hidden_field_tag "#{f.object_name.demodulize}[images_attributes][#{index}][image_page_id]", f.object.image_page_id_for_image_index(index) %>
|
9
19
|
<% if Refinery::PageImages.captions %>
|
10
|
-
<div class='
|
20
|
+
<div class='page-images-caption-modal <%= modal_class %>'>
|
11
21
|
<%= text_area_tag "#{f.object_name.demodulize}[images_attributes][#{index}][caption]",
|
12
22
|
f.object.caption_for_image_index(index),
|
13
23
|
:style => 'display: none',
|
14
24
|
:id => "page_captions_#{index}",
|
15
25
|
:class => 'page_caption' %>
|
26
|
+
<%= raw form_actions %>
|
16
27
|
</div>
|
17
28
|
<% end %>
|
18
29
|
</li>
|
19
30
|
<% end %>
|
20
|
-
<li class='
|
31
|
+
<li class='js-page-images-template'>
|
21
32
|
<%= hidden_field_tag "#{f.object_name.demodulize}[images_attributes][#{f.object.images.size}][id]" %>
|
22
33
|
<% if Refinery::PageImages.captions %>
|
23
|
-
<div class='
|
34
|
+
<div class='page-images-caption-modal <%= modal_class %>'>
|
24
35
|
<%= text_area_tag "#{f.object_name.demodulize}[images_attributes][#{f.object.images.size}][caption]",
|
25
36
|
'',
|
26
37
|
:style => 'display: none',
|
27
38
|
:id => "page_captions_#{f.object.images.size}",
|
28
39
|
:class => 'page_caption' %>
|
40
|
+
<%= raw form_actions %>
|
29
41
|
</div>
|
30
42
|
<% end %>
|
31
43
|
</li>
|
data/config/locales/bg.yml
CHANGED
@@ -2,6 +2,7 @@ bg:
|
|
2
2
|
refinery:
|
3
3
|
plugins:
|
4
4
|
refinery_page_images:
|
5
|
+
tab_name: Изображения на страница
|
5
6
|
title: Изображения на страница
|
6
7
|
description: Чрез добавката "Изображения на страница" имате възможност да свържите едно или повече изображения с всяка страница в Refinery. Така лесно ще можете да създавате опростени галерии с изображения, които се отварят в изкачащ прозорец като при lightbox.
|
7
8
|
js:
|
data/config/locales/cs.yml
CHANGED
@@ -2,6 +2,7 @@ cs:
|
|
2
2
|
refinery:
|
3
3
|
plugins:
|
4
4
|
refinery_page_images:
|
5
|
+
tab_name: Obrázky stránek
|
5
6
|
title: Obrázky stránek
|
6
7
|
description: Obrázky stránek vám dovoli připojit jeden či více obrázků ke stránce v Refinery. Umožní tak jednoduše vytvářet například galerie s lightboxem na frontendu.
|
7
8
|
js:
|
data/config/locales/de.yml
CHANGED
@@ -2,7 +2,9 @@ de:
|
|
2
2
|
refinery:
|
3
3
|
plugins:
|
4
4
|
refinery_page_images:
|
5
|
-
|
5
|
+
tab_name: Seitenbilder
|
6
|
+
title: Seitenbilder
|
7
|
+
description: Das Seitenbilder-Plugin erlaubt dir ein oder mehrere Bilder einer Seite zuzuordnen. Damit ist es möglich Bildergalerien in der Frontendansicht darzustellen.
|
6
8
|
admin:
|
7
9
|
pages:
|
8
10
|
tabs:
|
data/config/locales/en.yml
CHANGED
@@ -2,7 +2,9 @@ en:
|
|
2
2
|
refinery:
|
3
3
|
plugins:
|
4
4
|
refinery_page_images:
|
5
|
+
tab_name: Page Images
|
5
6
|
title: Page Images
|
7
|
+
tab_name: Images
|
6
8
|
description: Page Images allows you to relate one or more images to any page in Refinery which makes it really easy for you to create simple image galleries with lightbox style popups on the front end page views.
|
7
9
|
js:
|
8
10
|
admin:
|
@@ -0,0 +1,19 @@
|
|
1
|
+
es:
|
2
|
+
refinery:
|
3
|
+
plugins:
|
4
|
+
refinery_page_images:
|
5
|
+
tab_name: Imágenes de Página
|
6
|
+
title: Imágenes de Página
|
7
|
+
tab_name: Imágenes
|
8
|
+
description: Imágenes de página te permite relacionar una o más imagenes a cualquier página en Refinery lo que hace realmente fácil crear galerías de imágenes con diferentes estilos
|
9
|
+
js:
|
10
|
+
admin:
|
11
|
+
page_images:
|
12
|
+
add_caption: Añadir Imagen
|
13
|
+
done: Hecho
|
14
|
+
admin:
|
15
|
+
pages:
|
16
|
+
tabs:
|
17
|
+
images_bar:
|
18
|
+
add: Añadir Imagen
|
19
|
+
|
data/config/locales/fr.yml
CHANGED
@@ -2,6 +2,7 @@ fr:
|
|
2
2
|
refinery:
|
3
3
|
plugins:
|
4
4
|
refinery_page_images:
|
5
|
+
tab_name: Page Images
|
5
6
|
title: Page Images
|
6
7
|
description: "Page Images vous permet de lier une ou plusieurs images à n'importe quelle page dans Refinery, cela vous permet de créer très facilement des galeries d'images qui peuvent s'afficher dans une lightbox ou popups pour le front end"
|
7
8
|
js:
|
@@ -0,0 +1,18 @@
|
|
1
|
+
ja:
|
2
|
+
refinery:
|
3
|
+
plugins:
|
4
|
+
refinery_page_images:
|
5
|
+
tab_name: ページ画像
|
6
|
+
title: ページ画像
|
7
|
+
tab_name: 画像
|
8
|
+
description: 一つのページに対して、複数または一つの画像を設定することが出来ます。
|
9
|
+
js:
|
10
|
+
admin:
|
11
|
+
page_images:
|
12
|
+
add_caption: キャプションを追加
|
13
|
+
done: 保存
|
14
|
+
admin:
|
15
|
+
pages:
|
16
|
+
tabs:
|
17
|
+
images_bar:
|
18
|
+
add: 画像を追加
|
data/config/locales/nl.yml
CHANGED
data/config/locales/pt-BR.yml
CHANGED
@@ -2,6 +2,7 @@ pt-BR:
|
|
2
2
|
refinery:
|
3
3
|
plugins:
|
4
4
|
refinery_page_images:
|
5
|
+
tab_name: Imagens da Página
|
5
6
|
title: Imagens da Página
|
6
7
|
description: Imagens da Página te permite relacionar uma ou mais imagens a qualquer página no Refinery, tornando muito simples a criação de galerias de imagem no front end com popus no estilo lightbox.
|
7
8
|
js:
|
data/config/locales/ru.yml
CHANGED
@@ -2,6 +2,7 @@ ru:
|
|
2
2
|
refinery:
|
3
3
|
plugins:
|
4
4
|
refinery_page_images:
|
5
|
+
tab_name: Изображения страницы
|
5
6
|
title: Изображения страницы
|
6
7
|
description: Плагин работы с изображениями страницы "Page Images" позволяет связывать одно или несколько изображений с любой страницей в Refinery. С помощью плагина можно с легкостью создавать простые галереи изображений с поддержкой всплывающих полноразмерных изображений в стиле lightbox.
|
7
8
|
admin:
|
data/config/locales/sk.yml
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
refinery:
|
3
3
|
plugins:
|
4
4
|
refinery_page_images:
|
5
|
+
tab_name: Obrázky stránok
|
5
6
|
title: Obrázky stránok
|
6
7
|
description: Obrázky stránok vám umožnia pridať jeden alebo viac obrázkov k stránke v Refinery. Umožnia vám tak jednoducho vytvárať napríklad galérie v spojení s lightboxom.
|
7
8
|
js:
|
data/lib/refinery/page_images.rb
CHANGED
@@ -13,10 +13,23 @@ module Refinery
|
|
13
13
|
def factory_paths
|
14
14
|
@factory_paths ||= [ root.join('spec', 'factories').to_s ]
|
15
15
|
end
|
16
|
+
|
17
|
+
def attach!
|
18
|
+
require 'refinery/page'
|
19
|
+
require 'refinery/page_images/extension'
|
20
|
+
|
21
|
+
config.enabled_models.each do |model_class_name|
|
22
|
+
unless (model_class = model_class_name.safe_constantize)
|
23
|
+
Rails.logger.warn "PageImages is unable to find model class: #{model_class_name}"
|
24
|
+
next
|
25
|
+
end
|
26
|
+
model_class.send :has_many_page_images
|
27
|
+
end
|
28
|
+
|
29
|
+
Refinery::Image.send :has_many, :image_pages, :dependent => :destroy
|
30
|
+
end
|
16
31
|
end
|
17
32
|
|
18
|
-
require 'refinery/page_images/configuration'
|
19
33
|
require 'refinery/page_images/engine'
|
20
|
-
require 'refinery/page_images/extension'
|
21
34
|
end
|
22
35
|
end
|
@@ -2,8 +2,32 @@ module Refinery
|
|
2
2
|
module PageImages
|
3
3
|
include ActiveSupport::Configurable
|
4
4
|
|
5
|
-
config_accessor :captions
|
5
|
+
config_accessor :captions, :enable_for, :wysiwyg
|
6
6
|
|
7
7
|
self.captions = false
|
8
|
+
self.wysiwyg = true
|
9
|
+
self.enable_for = [
|
10
|
+
{ :model => 'Refinery::Page', :tab => 'Refinery::Pages::Tab' },
|
11
|
+
]
|
12
|
+
|
13
|
+
if defined?(Refinery::Blog)
|
14
|
+
self.enable_for << { :model => 'Refinery::Blog::Post', :tab => 'Refinery::Blog::Tab' }
|
15
|
+
end
|
16
|
+
|
17
|
+
config.instance_eval do
|
18
|
+
def enabled_tabs
|
19
|
+
extract_enabled_option(:tab)
|
20
|
+
end
|
21
|
+
|
22
|
+
def enabled_models
|
23
|
+
extract_enabled_option(:model)
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
def extract_enabled_option(key)
|
28
|
+
enable_for.map { |enable_for| enable_for[key] }.compact
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
8
32
|
end
|
9
33
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'refinery/page_images/configuration'
|
2
|
+
|
1
3
|
module Refinery
|
2
4
|
module PageImages
|
3
5
|
class Engine < Rails::Engine
|
@@ -8,10 +10,20 @@ module Refinery
|
|
8
10
|
engine_name :refinery_page_images
|
9
11
|
|
10
12
|
def self.register(tab)
|
11
|
-
tab.name =
|
13
|
+
tab.name = ::I18n.t(:'refinery.plugins.refinery_page_images.tab_name')
|
12
14
|
tab.partial = "/refinery/admin/pages/tabs/images"
|
13
15
|
end
|
14
16
|
|
17
|
+
def self.initialize_tabs!
|
18
|
+
PageImages.config.enabled_tabs.each do |tab_class_name|
|
19
|
+
unless (tab_class = tab_class_name.safe_constantize)
|
20
|
+
Rails.logger.warn "PageImages is unable to find tab class: #{tab_class_name}"
|
21
|
+
next
|
22
|
+
end
|
23
|
+
tab_class.register { |tab| register tab }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
15
27
|
initializer "register refinery_page_images plugin" do
|
16
28
|
Refinery::Plugin.register do |plugin|
|
17
29
|
plugin.name = "page_images"
|
@@ -20,27 +32,13 @@ module Refinery
|
|
20
32
|
end
|
21
33
|
|
22
34
|
config.to_prepare do
|
23
|
-
|
24
|
-
Refinery::Page.send :has_many_page_images
|
25
|
-
Refinery::Blog::Post.send :has_many_page_images if defined?(::Refinery::Blog)
|
26
|
-
Refinery::Image.module_eval do
|
27
|
-
has_many :image_pages, :dependent => :destroy
|
28
|
-
end
|
35
|
+
Refinery::PageImages.attach!
|
29
36
|
end
|
30
37
|
|
31
38
|
config.after_initialize do
|
32
|
-
|
33
|
-
|
34
|
-
end
|
35
|
-
|
36
|
-
if defined?(Refinery::Blog::Tab)
|
37
|
-
Refinery::Blog::Tab.register do |tab|
|
38
|
-
register tab
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
Refinery.register_engine(Refinery::PageImages)
|
39
|
+
initialize_tabs!
|
40
|
+
Refinery.register_engine Refinery::PageImages
|
43
41
|
end
|
44
42
|
end
|
45
43
|
end
|
46
|
-
end
|
44
|
+
end
|
@@ -2,8 +2,8 @@ module Refinery
|
|
2
2
|
module PageImages
|
3
3
|
module Extension
|
4
4
|
def has_many_page_images
|
5
|
-
has_many :image_pages, :as => :page, :order => 'position ASC'
|
6
|
-
has_many :images, :through => :image_pages, :order => 'position ASC'
|
5
|
+
has_many :image_pages, :as => :page, :class_name => 'Refinery::ImagePage', :order => 'position ASC'
|
6
|
+
has_many :images, :through => :image_pages, :class_name => 'Refinery::Image', :order => 'position ASC'
|
7
7
|
# accepts_nested_attributes_for MUST come before def images_attributes=
|
8
8
|
# this is because images_attributes= overrides accepts_nested_attributes_for.
|
9
9
|
|
data/readme.md
CHANGED
@@ -32,6 +32,24 @@ rake db:migrate
|
|
32
32
|
|
33
33
|
Now when you start up your Refinery application, edit a page and there should be a new "Images" tab.
|
34
34
|
|
35
|
+
# Deploying to Heroku
|
36
|
+
|
37
|
+
In order to properly precompile assets on Heroku, config vars be present in the environment during slug compilation.
|
38
|
+
|
39
|
+
```bash
|
40
|
+
heroku labs:enable user-env-compile -a myapp
|
41
|
+
```
|
42
|
+
|
43
|
+
otherwise you may experience the following error:
|
44
|
+
```
|
45
|
+
could not connect to server: Connection refused
|
46
|
+
Is the server running on host "127.0.0.1" and accepting
|
47
|
+
TCP/IP connections on port 5432?
|
48
|
+
```
|
49
|
+
|
50
|
+
|
51
|
+
["More Details"](https://devcenter.heroku.com/articles/labs-user-env-compile)
|
52
|
+
|
35
53
|
## Enable Captions
|
36
54
|
|
37
55
|
You can enable captions using an initializer containing the following configuration:
|
@@ -40,16 +58,44 @@ You can enable captions using an initializer containing the following configurat
|
|
40
58
|
Refinery::PageImages.captions = true
|
41
59
|
```
|
42
60
|
|
61
|
+
By default, captions are WYM editors. Prefer `textarea`s ? Gotcha :
|
62
|
+
|
63
|
+
```ruby
|
64
|
+
Refinery::PageImages.wysiwyg = false
|
65
|
+
```
|
66
|
+
|
43
67
|
## Usage
|
44
68
|
|
45
69
|
`app/views/refinery/pages/show.html.erb`
|
46
70
|
|
71
|
+
If you don't have this file then Refinery will be using its default. You can override this with
|
72
|
+
|
73
|
+
```bash
|
74
|
+
rake refinery:override view=refinery/pages/show
|
75
|
+
```
|
76
|
+
|
77
|
+
```erb
|
78
|
+
<% content_for :body_content_right do %>
|
79
|
+
<ul id='gallery'>
|
80
|
+
<% @page.images.each do |image| %>
|
81
|
+
<li>
|
82
|
+
<%= link_to image_tag(image.thumbnail("200x200#c").url), image.thumbnail("900x600").url %>
|
83
|
+
</li>
|
84
|
+
<% end %>
|
85
|
+
</ul>
|
86
|
+
<% end %>
|
87
|
+
<%= render :partial => "/refinery/content_page" %>
|
88
|
+
```
|
89
|
+
|
90
|
+
If you have enabled captions, you can show them like this
|
91
|
+
|
47
92
|
```erb
|
48
93
|
<% content_for :body_content_right do %>
|
49
94
|
<ul id='gallery'>
|
50
|
-
<% @page.images.
|
95
|
+
<% @page.images.each_with_index do |image, index| %>
|
51
96
|
<li>
|
52
|
-
<%= link_to image_tag(
|
97
|
+
<%= link_to image_tag(image.thumbnail("200x200#c").url), image.thumbnail("900x600").url %>
|
98
|
+
<span class='caption'><%=raw @page.caption_for_image_index(index) %></span>
|
53
99
|
</li>
|
54
100
|
<% end %>
|
55
101
|
</ul>
|
@@ -1,17 +1,16 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = %q{refinerycms-page-images}
|
3
|
-
s.version = %q{2.0
|
4
|
-
s.description = %q{
|
5
|
-
s.
|
6
|
-
s.
|
7
|
-
s.
|
8
|
-
s.homepage = %q{http://github.com/resolve/refinerycms-page-images}
|
3
|
+
s.version = %q{2.1.0}
|
4
|
+
s.description = %q{Attach images to pages ins Refinery CMS}
|
5
|
+
s.summary = %q{Page Images extension for Refinery CMS}
|
6
|
+
s.email = %q{info@refinerycms.com}
|
7
|
+
s.homepage = %q{http://github.com/refinery/refinerycms-page-images}
|
9
8
|
s.authors = ['Philip Arndt', 'David Jones']
|
10
9
|
s.require_paths = %w(lib)
|
10
|
+
s.license = %q{MIT}
|
11
11
|
|
12
12
|
s.files = `git ls-files`.split("\n")
|
13
13
|
s.test_files = `git ls-files -- spec/*`.split("\n")
|
14
14
|
|
15
|
-
s.add_dependency 'refinerycms-pages', '~> 2.
|
16
|
-
s.add_development_dependency 'refinerycms-testing', '~> 2.0.0'
|
15
|
+
s.add_dependency 'refinerycms-pages', '~> 2.1.0'
|
17
16
|
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
FactoryGirl.define do
|
2
2
|
factory :page_with_image, :parent => :page do
|
3
|
-
|
3
|
+
after(:create) { |p| p.images << FactoryGirl.create(:image) }
|
4
4
|
end
|
5
5
|
|
6
6
|
factory :blog_post_with_image, :parent => :blog_post do
|
7
|
-
|
7
|
+
after(:create) { |b| b.images << FactoryGirl.create(:image) }
|
8
8
|
end if defined? Refinery::Blog::Post
|
9
9
|
end
|