refinerycms-page-images 2.1.1 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b6fc2bbd624edbc3cc8c6a79788d6dd8088cae31
4
- data.tar.gz: 7dc2219f661feb71369a946280e1d795b298b4ab
3
+ metadata.gz: b72ed8ac7a3c5ba5dbf01e1bfd4fc8870d09da8a
4
+ data.tar.gz: 826b59b4d21371ec72c9d04eaaf84dd4700d6bc4
5
5
  SHA512:
6
- metadata.gz: 815969fd574b909a7f13487dd8adfe6fff6a750971e13f12016add64cafea2ddc471573034932b41987c85e993f4866b9b76a83ef1b42ad422a655c384ca3874
7
- data.tar.gz: 9b2067631165952b8925fd9f4aaf18b376cae84257f57ca045744896828f707df777dc03dd88008fc9cc79cc4387ac471ccc1fdf18beda590adb4b9929e23c43
6
+ metadata.gz: d1c3445b8c2d4ad216714df2cd6711ac5c781a024ba6551f57f2a8f2eff85c065c626e783f255b52f94c2043838e8394d83802668a234178cf2da956d85e2d6d
7
+ data.tar.gz: 496669b11429333ba1a3a5276ad8af71df969d7dddaa299063e0da611263f210c1dd7018838e0294e9fcbd1b860005cad465f1ff5cd7f4a436246723aea5d57d
data/.gitignore CHANGED
@@ -1,2 +1,6 @@
1
1
  Gemfile.lock
2
2
  spec/dummy/
3
+
4
+ .project
5
+
6
+ *.log
@@ -1,10 +1,9 @@
1
1
  language: ruby
2
+ cache: bundler
3
+ sudo: false
2
4
  bundler_args: --without development
3
- before_script:
4
- - "sh -e /etc/init.d/xvfb start"
5
- - "bundle exec rake refinery:testing:dummy_app"
6
- script:
7
- - "DISPLAY=:99.0 bundle exec rspec spec"
5
+ before_script: "bin/rake refinery:testing:dummy_app"
6
+ script: "bin/rspec spec"
8
7
  notifications:
9
8
  email: true
10
9
  irc:
@@ -17,11 +16,11 @@ notifications:
17
16
  on_failure: always
18
17
  rooms:
19
18
  - secure: "X5X39BTgXacSdc32F8mIjJKPqm5dZzmgZfJ14qYpJeMETTdA5JfByt2uCfU8\njJkkxT+XGWta0bSSlRIHQJO6pK26U94A95VYDX0jNuneKEnsoAsqJ6U0VY6v\nH5oxXMAZ2perP/FH9ZsPNR+ulyFfbMQCeGPJw5AXKZQqzf6qPOI="
19
+ webhooks:
20
+ - https://webhooks.gitter.im/e/b5d48907cdc89864b874
20
21
  env:
21
22
  - DB=postgresql
22
23
  - DB=mysql
23
24
  rvm:
24
- - 2.0.0
25
- - 1.9.3
26
- - rbx-19mode
27
- - jruby-19mode
25
+ - 2.3.1
26
+ - 2.2.5
data/Gemfile CHANGED
@@ -2,8 +2,19 @@ source "http://rubygems.org"
2
2
 
3
3
  gemspec
4
4
 
5
- gem 'refinerycms', '~> 2.1.0'
6
- gem 'refinerycms-testing', '~> 2.1.0', :group => :test
5
+ git 'https://github.com/refinery/refinerycms', branch: '3-0-stable' do
6
+ gem 'refinerycms'
7
+
8
+ group :development, :test do
9
+ gem 'refinerycms-testing'
10
+ end
11
+ end
12
+
13
+ gem 'refinerycms-wymeditor', '~> 1.0.0'
14
+
15
+ group :test do
16
+ gem 'poltergeist'
17
+ end
7
18
 
8
19
  # Database Configuration
9
20
  unless ENV['TRAVIS']
@@ -22,18 +33,9 @@ if !ENV['TRAVIS'] || ENV['DB'] == 'postgresql'
22
33
  gem 'pg', :platform => :ruby
23
34
  end
24
35
 
25
- gem 'jruby-openssl', :platform => :jruby
26
-
27
- group :test do
28
- gem 'poltergeist'
29
- end
30
-
31
36
  # Refinery/rails should pull in the proper versions of these
32
- group :assets do
33
- gem 'sass-rails'
34
- gem 'coffee-rails'
35
- gem 'uglifier'
36
- end
37
+ gem 'sass-rails', '~> 4.0.0'
38
+ gem 'coffee-rails', '~> 4.0.0'
37
39
 
38
40
  # Load local gems according to Refinery developer preference.
39
41
  if File.exist? local_gemfile = File.expand_path('../.gemfile', __FILE__)
data/Rakefile CHANGED
@@ -13,7 +13,6 @@ if File.exists?(APP_RAKEFILE)
13
13
  end
14
14
 
15
15
  require "refinerycms-testing"
16
- Refinery::Testing::Railtie.load_tasks
17
16
  Refinery::Testing::Railtie.load_dummy_tasks(ENGINE_PATH)
18
17
 
19
18
  load File.expand_path('../tasks/rspec.rake', __FILE__)
@@ -0,0 +1,10 @@
1
+ if defined?(Refinery::Blog)
2
+ Refinery::Blog::Admin::PostsController.prepend(
3
+ Module.new do
4
+ def permitted_post_params
5
+ params[:post][:images_attributes]={} if params[:post][:images_attributes].nil?
6
+ super << [images_attributes: [:id, :caption, :image_page_id]]
7
+ end
8
+ end
9
+ )
10
+ end
@@ -0,0 +1,8 @@
1
+ Refinery::Admin::PagesController.prepend(
2
+ Module.new do
3
+ def permitted_page_params
4
+ params[:page][:images_attributes]={} if params[:page][:images_attributes].nil?
5
+ super << [images_attributes: [:id, :caption, :image_page_id]]
6
+ end
7
+ end
8
+ )
@@ -0,0 +1,16 @@
1
+ require 'ostruct'
2
+
3
+ Refinery::Page.class_eval do
4
+ attr_accessor :images_with_captions
5
+
6
+ def images_with_captions
7
+ @images_with_captions = image_pages.map do |ref|
8
+ OpenStruct.new(
9
+ {
10
+ image: Refinery::Image.find(ref.image_id),
11
+ caption: ref.caption || ''
12
+ }
13
+ )
14
+ end
15
+ end
16
+ end
@@ -2,12 +2,8 @@ module Refinery
2
2
  class ImagePage < Refinery::Core::BaseModel
3
3
 
4
4
  belongs_to :image
5
- belongs_to :page, :polymorphic => true
6
-
7
- translates :caption if self.respond_to?(:translates)
8
-
9
- attr_accessible :image_id, :position, :locale
10
- self.translation_class.send :attr_accessible, :locale
5
+ belongs_to :page, polymorphic: true, touch: true
11
6
 
7
+ translates :caption
12
8
  end
13
9
  end
@@ -9,7 +9,6 @@
9
9
  <% modal_class = Refinery::PageImages.config.wysiwyg ? 'wym' : 'plain' %>
10
10
 
11
11
  <div class='wym_box field images_field'>
12
- <%= hidden_field_tag "#{f.object_name.demodulize}[images_attributes][-1]", "" %>
13
12
  <ul id='page_images' class='clearfix'>
14
13
  <%= f.fields_for :images do |image_form| %>
15
14
  <li id='image_<%= image_form.object.id %>'>
@@ -30,17 +29,17 @@
30
29
  </li>
31
30
  <% end %>
32
31
  <li class='js-page-images-template'>
33
- <%= hidden_field_tag "#{f.object_name.demodulize}[images_attributes][#{f.object.images.size}][id]" %>
32
+ <%= hidden_field_tag "#{f.object_name.demodulize}[images_attributes][#{f.object.images.length}][id]" %>
34
33
  <% if Refinery::PageImages.captions %>
35
34
  <div class='page-images-caption-modal <%= modal_class %>'>
36
- <%= text_area_tag "#{f.object_name.demodulize}[images_attributes][#{f.object.images.size}][caption]",
35
+ <%= text_area_tag "#{f.object_name.demodulize}[images_attributes][#{f.object.images.length}][caption]",
37
36
  '',
38
37
  :style => 'display: none',
39
- :id => "page_captions_#{f.object.images.size}",
38
+ :id => "page_captions_#{f.object.images.length}",
40
39
  :class => 'page_caption' %>
41
40
  <%= raw form_actions %>
42
41
  </div>
43
42
  <% end %>
44
43
  </li>
45
44
  </ul>
46
- </div>
45
+ </div>
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'rake' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('rake', 'rake')
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'rspec' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('rspec-core', 'rspec')
@@ -4,7 +4,7 @@ cs:
4
4
  refinery_page_images:
5
5
  tab_name: Obrázky stránek
6
6
  title: Obrázky stránek
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
+ description: Obrázky stránek vám dovolí 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.
8
8
  js:
9
9
  admin:
10
10
  page_images:
@@ -0,0 +1,17 @@
1
+ da:
2
+ refinery:
3
+ plugins:
4
+ refinery_page_images:
5
+ title: Sidebilleder
6
+ tab_name: Billeder
7
+ description: Sidebilleder tillader dig at relatere et eller flere billeder til en hvilken som helst side i Refinery, der gør det nemt for dig at oprette simple gallerier med lightbox style popups på frontend siderne.
8
+ js:
9
+ admin:
10
+ page_images:
11
+ add_caption: Tilføj billedtekst
12
+ done: Færdig
13
+ admin:
14
+ pages:
15
+ tabs:
16
+ images_bar:
17
+ add: Tilføj billede
@@ -2,7 +2,6 @@ en:
2
2
  refinery:
3
3
  plugins:
4
4
  refinery_page_images:
5
- tab_name: Page Images
6
5
  title: Page Images
7
6
  tab_name: Images
8
7
  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.
@@ -0,0 +1,17 @@
1
+ it:
2
+ refinery:
3
+ plugins:
4
+ refinery_page_images:
5
+ title: Immagini delle Pagine
6
+ tab_name: Immagini
7
+ description: Immagini delle Pagine ti permette di associare una o più immagini ad ogni pagina di Refinery rendendo molto semplice creare semplici gallerie di immagini con diversi stili.
8
+ js:
9
+ admin:
10
+ page_images:
11
+ add_caption: Aggiungi Didascalia
12
+ done: Fatto
13
+ admin:
14
+ pages:
15
+ tabs:
16
+ images_bar:
17
+ add: Aggiungi Immagine
@@ -5,6 +5,11 @@ ru:
5
5
  tab_name: Изображения страницы
6
6
  title: Изображения страницы
7
7
  description: Плагин работы с изображениями страницы "Page Images" позволяет связывать одно или несколько изображений с любой страницей в Refinery. С помощью плагина можно с легкостью создавать простые галереи изображений с поддержкой всплывающих полноразмерных изображений в стиле lightbox.
8
+ js:
9
+ admin:
10
+ page_images:
11
+ add_caption: Добавить подпись
12
+ done: Готово
8
13
  admin:
9
14
  pages:
10
15
  tabs:
@@ -0,0 +1,18 @@
1
+ zh-CN:
2
+ refinery:
3
+ plugins:
4
+ refinery_page_images:
5
+ tab_name: 页面图片
6
+ title: 页面图片
7
+ tab_name: 图片
8
+ description: 页面图片让您关连一幅或多幅图片至系统中任何页面。让您能非常简易建立简单的图片库,并加上如lightbox 的跳出视窗。
9
+ js:
10
+ admin:
11
+ page_images:
12
+ add_caption: 新增说明
13
+ done: 完成
14
+ admin:
15
+ pages:
16
+ tabs:
17
+ images_bar:
18
+ add: 新增图片
@@ -0,0 +1,18 @@
1
+ zh-TW:
2
+ refinery:
3
+ plugins:
4
+ refinery_page_images:
5
+ tab_name: 頁面圖片
6
+ title: 頁面圖片
7
+ tab_name: 圖片
8
+ description: 頁面圖片讓您關連一幅或多幅圖片至系統中任何頁面。讓您能非常簡易建立簡單的圖片庫,並加上如 lightbox 的跳出視窗。
9
+ js:
10
+ admin:
11
+ page_images:
12
+ add_caption: 新增說明
13
+ done: 完成
14
+ admin:
15
+ pages:
16
+ tabs:
17
+ images_bar:
18
+ add: 新增圖片
@@ -1,4 +1,5 @@
1
1
  require 'refinerycms-core'
2
+ require 'globalize'
2
3
 
3
4
  module Refinery
4
5
  autoload :PageImagesGenerator, 'generators/refinery/page_images_generator'
@@ -24,15 +24,17 @@ module Refinery
24
24
  end
25
25
  end
26
26
 
27
- initializer "register refinery_page_images plugin" do
27
+ before_inclusion do
28
28
  Refinery::Plugin.register do |plugin|
29
- plugin.name = "page_images"
29
+ plugin.name = 'page_images'
30
+ plugin.pathname = root
30
31
  plugin.hide_from_menu = true
31
32
  end
32
33
  end
33
34
 
34
35
  config.to_prepare do
35
36
  Refinery::PageImages.attach!
37
+ Rails.application.config.assets.precompile += %w(refinery/page-image-picker.js refinery/page-image-picker.css)
36
38
  end
37
39
 
38
40
  config.after_initialize do
@@ -2,26 +2,23 @@ module Refinery
2
2
  module PageImages
3
3
  module Extension
4
4
  def has_many_page_images
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'
5
+ has_many :image_pages, proc { order('position ASC') }, :as => :page, :class_name => 'Refinery::ImagePage'
6
+ has_many :images, proc { order('position ASC') }, :through => :image_pages, :class_name => 'Refinery::Image'
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
 
10
10
  accepts_nested_attributes_for :images, :allow_destroy => false
11
-
12
11
  # need to do it this way because of the way accepts_nested_attributes_for
13
12
  # deletes an already defined images_attributes
14
13
  module_eval do
15
14
  def images_attributes=(data)
16
- data = data.reject {|key, data| data.blank?}
17
- ids_to_keep = data.map{|i, d| d['image_page_id']}.compact
15
+ data = data.reject {|_, data| data.blank?}
16
+ ids_to_keep = data.map{|_, d| d['image_page_id']}.compact
18
17
 
19
18
  image_pages_to_delete = if ids_to_keep.empty?
20
19
  self.image_pages
21
20
  else
22
- self.image_pages.where(
23
- Refinery::ImagePage.arel_table[:id].not_in(ids_to_keep)
24
- )
21
+ self.image_pages.where.not(:id => ids_to_keep)
25
22
  end
26
23
 
27
24
  image_pages_to_delete.destroy_all
@@ -46,8 +43,6 @@ module Refinery
46
43
  end
47
44
 
48
45
  include Refinery::PageImages::Extension::InstanceMethods
49
-
50
- attr_accessible :images_attributes
51
46
  end
52
47
 
53
48
  module InstanceMethods
data/readme.md CHANGED
@@ -1,25 +1,29 @@
1
1
  # Page Images Engine for Refinery CMS
2
2
 
3
+ [![Build Status](https://travis-ci.org/refinery/refinerycms-page-images.svg?branch=master)](https://travis-ci.org/refinery/refinerycms-page-images)
4
+
3
5
  ## About
4
6
 
5
7
  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.
6
8
 
7
9
  ## Requirements
8
10
 
9
- * refinerycms >= 2.0.0
11
+ * refinerycms >= 3.0.0
10
12
 
11
13
  ## Features
12
14
 
13
- * Ability to select one or more images from the image picker and relate them to a page
15
+ * Ability to select one or more images from the image picker and assign them to a page
16
+ * An image can be assigned to more than one page
14
17
  * Reordering support, simply drag into order
15
- * Optionally include captions with each image.
18
+ * An image assigned to a page can have a caption.
19
+ * An image's caption can be different for different pages
16
20
 
17
21
  ## Install
18
22
 
19
- Add this line to your applications `Gemfile`
23
+ Add this line to your application's `Gemfile`
20
24
 
21
25
  ```ruby
22
- gem 'refinerycms-page-images', '~> 2.0.0'
26
+ gem 'refinerycms-page-images', '~> 3.0.0', github: "refinery/refinerycms-page-images", branch: "master"
23
27
  ```
24
28
 
25
29
  Next run
@@ -34,7 +38,9 @@ Now when you start up your Refinery application, edit a page and there should be
34
38
 
35
39
  # Deploying to Heroku
36
40
 
37
- In order to properly precompile assets on Heroku, config vars be present in the environment during slug compilation.
41
+ Note: the following information about assets on Heroku might be out of date.
42
+
43
+ In order to properly precompile assets on Heroku, config vars must be present in the environment during slug compilation.
38
44
 
39
45
  ```bash
40
46
  heroku labs:enable user-env-compile -a myapp
@@ -48,22 +54,29 @@ TCP/IP connections on port 5432?
48
54
  ```
49
55
 
50
56
 
51
- ["More Details"](https://devcenter.heroku.com/articles/labs-user-env-compile)
57
+ [More Details](https://devcenter.heroku.com/articles/labs-user-env-compile)
52
58
 
53
59
  ## Enable Captions
54
60
 
55
61
  You can enable captions using an initializer containing the following configuration:
56
62
 
57
63
  ```ruby
64
+ # app/config/initializers/refinery/page-images.rb
58
65
  Refinery::PageImages.captions = true
59
66
  ```
60
67
 
61
- By default, captions are WYM editors. Prefer `textarea`s ? Gotcha :
68
+ By default, captions are WYM editors. Prefer `textarea`s? Gotcha :
62
69
 
63
70
  ```ruby
64
71
  Refinery::PageImages.wysiwyg = false
65
72
  ```
66
73
 
74
+ Note that WYMeditor support requires that you have the extension in your Gemfile:
75
+
76
+ ```ruby
77
+ gem 'refinerycms-wymeditor', '~> 1.0.0'
78
+ ```
79
+
67
80
  ## Usage
68
81
 
69
82
  `app/views/refinery/pages/show.html.erb`
@@ -74,12 +87,19 @@ If you don't have this file then Refinery will be using its default. You can ove
74
87
  rake refinery:override view=refinery/pages/show
75
88
  ```
76
89
 
90
+ If images have been assigned to a page several objects are available for showing on the page. They are
91
+
92
+ * `@page.images`: A collection of images assigned to the page.
93
+ * `@page.caption_for_image_index(i)` will return the caption (if any) for the i<sup>th</sup> image in @page.images
94
+ * `@page.images_with_captions`: A collection of image_with_caption objects with the attributes image: and caption:
95
+
77
96
  ```erb
78
97
  <% content_for :body_content_right do %>
79
98
  <ul id='gallery'>
80
99
  <% @page.images.each do |image| %>
81
100
  <li>
82
- <%= link_to image_tag(image.thumbnail("200x200#c").url), image.thumbnail("900x600").url %>
101
+ <%= link_to image_tag(image.thumbnail(geometry: "200x200#c").url),
102
+ image.thumbnail(geometry: "900x600").url %>
83
103
  </li>
84
104
  <% end %>
85
105
  </ul>
@@ -91,11 +111,48 @@ If you have enabled captions, you can show them like this
91
111
 
92
112
  ```erb
93
113
  <% content_for :body_content_right do %>
94
- <ul id='gallery'>
114
+ <section id='gallery'>
95
115
  <% @page.images.each_with_index do |image, index| %>
116
+ <figure>
117
+ <%= link_to image_tag(image.thumbnail(geometry: "200x200#c").url),
118
+ image.thumbnail(geometry: "900x600").url %>
119
+ <figcaption><%=raw @page.caption_for_image_index(index) %></figcaption>
120
+ </figure>
121
+ <% end %>
122
+ </section>
123
+ <% end %>
124
+ <%= render :partial => "/refinery/content_page" %>
125
+ ```
126
+ or like this
127
+ ```erb
128
+ <% content_for :body_content_right do %>
129
+ <section id='gallery'>
130
+ <% @page.images_with_captions.each do |iwc| %>
131
+ <figure>
132
+ <%= link_to image_tag(iwc.image.thumbnail(geometry: "200x200#c").url),
133
+ iwc.image.thumbnail(geometry: "900x600").url %>
134
+ <figcaption><%=raw iwc.caption %></figcaption>
135
+ </figure>
136
+ <% end %>
137
+ </section>
138
+ <% end %>
139
+ <%= render :partial => "/refinery/content_page" %>
140
+ ```
141
+ ## Refinerycms-blog support
142
+
143
+ Contrary to its name, `refinerycms-page-images` also works with `refinerycms-blog` and adds the functionality to link images to blog posts.
144
+
145
+ If `refinerycms-blog` is installed on your rails app, `refinerycms-page-images` will automatically detect it and perform the adequate initialization. PageImages are assigned to a polymorph "page" object, wich can be a `Refinery::Page` or a `Blog::Post`.
146
+
147
+ Thus, once installed, you can simply call a blog post's images the same way you'd call them for a page, like this
148
+
149
+ ```erb
150
+ <% @blog_posts.each do |blog_post| %>
151
+ <ul id='gallery'>
152
+ <% blog_post.images.each do |image| %>
96
153
  <li>
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>
154
+ <%= link_to image_tag(image.thumbnail(geometry: "200x200#c").url),
155
+ image.thumbnail(geometry: "900x600").url %>
99
156
  </li>
100
157
  <% end %>
101
158
  </ul>
@@ -103,6 +160,7 @@ If you have enabled captions, you can show them like this
103
160
  <%= render :partial => "/refinery/content_page" %>
104
161
  ```
105
162
 
163
+
106
164
  ## Screenshot
107
165
 
108
166
  ![Refinery CMS Page Images Screenshot](http://refinerycms.com/system/images/0000/1736/refinerycms-page-images.png)
@@ -1,10 +1,10 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = %q{refinerycms-page-images}
3
- s.version = %q{2.1.1}
4
- s.description = %q{Attach images to pages in Refinery CMS}
3
+ s.version = %q{3.0.0}
4
+ s.description = %q{Attach images to pages ins Refinery CMS}
5
5
  s.summary = %q{Page Images extension for Refinery CMS}
6
6
  s.email = %q{info@refinerycms.com}
7
- s.homepage = %q{https://github.com/refinery/refinerycms-page-images}
7
+ s.homepage = %q{http://github.com/refinery/refinerycms-page-images}
8
8
  s.authors = ['Philip Arndt', 'David Jones']
9
9
  s.require_paths = %w(lib)
10
10
  s.license = %q{MIT}
@@ -12,5 +12,7 @@ Gem::Specification.new do |s|
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.1.0'
15
+ s.add_dependency 'refinerycms-pages', '~> 3.0.0'
16
+ s.add_dependency 'decorators', '~> 2.0.0'
17
+ s.add_dependency 'globalize', '~> 5.0'
16
18
  end
@@ -1,6 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
- #!/usr/bin/env ruby
3
2
  # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
4
3
 
5
4
  ENGINE_PATH = File.expand_path('../..', __FILE__)
6
- load File.expand_path('../../spec/dummy/script/rails', __FILE__)
5
+ load File.expand_path('../../spec/dummy/bin/rails', __FILE__)
@@ -1,9 +1,14 @@
1
1
  FactoryGirl.define do
2
- factory :page_with_image, :parent => :page do
3
- after(:create) { |p| p.images << FactoryGirl.create(:image) }
2
+ factory :page_with_image, :parent => :page_with_page_part do
3
+ after(:create) { |p| p.image_pages.create(image: FactoryGirl.create(:image)) }
4
4
  end
5
5
 
6
6
  factory :blog_post_with_image, :parent => :blog_post do
7
- after(:create) { |b| b.images << FactoryGirl.create(:image) }
7
+ after(:create) { |b| b.image_pages.create(image: FactoryGirl.create(:image)) }
8
8
  end if defined? Refinery::Blog::Post
9
+
10
+ factory :image_page, class: Refinery::ImagePage do
11
+ image
12
+ page
13
+ end
9
14
  end
@@ -0,0 +1,76 @@
1
+ require "spec_helper"
2
+
3
+ describe "page images", type: :feature do
4
+ refinery_login
5
+
6
+ let(:configure) {}
7
+ let(:page_for_images) { FactoryGirl.create(:page_with_page_part) }
8
+ let(:image) { FactoryGirl.create(:image) }
9
+ let(:navigate_to_edit) { visit refinery.edit_admin_page_path(page_for_images) }
10
+ let(:page_images_tab_id) { "#custom_#{::I18n.t(:'refinery.plugins.refinery_page_images.tab_name')}_tab" }
11
+
12
+ let(:setup_and_visit) do
13
+ configure
14
+ page_for_images
15
+ navigate_to_edit
16
+ end
17
+
18
+ # Regression test for #100 and #102
19
+ it "can add a page image to the db", js: true do
20
+
21
+ image
22
+ setup_and_visit
23
+
24
+ expect(page_for_images.images.count).to eq 0
25
+
26
+ page.find("#{page_images_tab_id} a").click
27
+
28
+ # Add the first Image
29
+ click_link "Add Image"
30
+
31
+ expect(page).to have_selector 'iframe#dialog_iframe'
32
+ page.within_frame('dialog_iframe') do
33
+ find(:css, "#existing_image_area img#image_#{image.id}").click
34
+ click_button ::I18n.t('button_text', scope: 'refinery.admin.images.existing_image')
35
+ end
36
+
37
+ # image should be visable on the page
38
+ expect(page).to have_selector("#page_images li#image_#{image.id}")
39
+
40
+ click_button "Save"
41
+
42
+ # image should be in the db
43
+ expect(page_for_images.images.count).to eq 1
44
+
45
+ end
46
+
47
+ context "with images" do
48
+
49
+ let(:page_for_images) { FactoryGirl.create(:page_with_image) }
50
+
51
+ # Regression test for #100 and #102
52
+ it "can remove a page image to the db", js: true do
53
+
54
+ setup_and_visit
55
+
56
+ expect(page_for_images.images.count).to eq 1
57
+
58
+ page.find("#{page_images_tab_id} a").click
59
+
60
+ expect(page).to have_selector("#page_images li#image_#{page_for_images.images.first.id}")
61
+
62
+ image_li_tag = page.find("#page_images li:first-child")
63
+ image_li_tag.hover
64
+ within(image_li_tag) { page.find('img:first-child').click }
65
+
66
+ expect(page).not_to have_selector("#page_images li#image_#{page_for_images.images.first.id}")
67
+
68
+ click_button "Save"
69
+
70
+ expect(page_for_images.images.count).to eq 0
71
+
72
+ end
73
+ end
74
+
75
+ end
76
+
@@ -1,11 +1,11 @@
1
1
  require "spec_helper"
2
2
 
3
- describe "attach page images" do
4
- refinery_login_with :refinery_user
3
+ describe "attach page images", type: :feature do
4
+ refinery_login
5
5
 
6
6
  # No-op block : use default configuration by default
7
7
  let(:configure) {}
8
- let(:create_page) { FactoryGirl.create(:page) }
8
+ let(:create_page) { FactoryGirl.create(:page_with_page_part) }
9
9
  let(:navigate_to_edit) { click_link "Edit this page" }
10
10
  let(:page_images_tab_id) { "#custom_#{::I18n.t(:'refinery.plugins.refinery_page_images.tab_name')}_tab" }
11
11
 
@@ -19,7 +19,7 @@ describe "attach page images" do
19
19
  it "shows images tab" do
20
20
  setup_and_visit
21
21
  within page_images_tab_id do
22
- page.should have_content("Images")
22
+ expect(page).to have_content("Images")
23
23
  end
24
24
  end
25
25
 
@@ -31,7 +31,7 @@ describe "attach page images" do
31
31
  click_link "Images"
32
32
  end
33
33
 
34
- page.should have_content("Add Image")
34
+ expect(page).to have_content("Add Image")
35
35
  end
36
36
 
37
37
  context "with caption and WYSIWYG disabled" do
@@ -51,7 +51,7 @@ describe "attach page images" do
51
51
  image_li_tag.hover
52
52
  within(image_li_tag) { page.find('img.caption').click }
53
53
 
54
- page.find('.ui-dialog textarea').should be_visible
54
+ expect(page.find('.ui-dialog textarea')).to be_visible
55
55
  end
56
56
  end
57
57
 
@@ -13,7 +13,7 @@ describe Refinery::PageImages::Engine do
13
13
  end
14
14
 
15
15
  before(:each) do
16
- Refinery::PageImages.config.stub(:enable_for).and_return(enable_for_config)
16
+ allow(Refinery::PageImages.config).to receive(:enable_for).and_return(enable_for_config)
17
17
  end
18
18
 
19
19
  def enable_for_config
@@ -23,18 +23,18 @@ describe Refinery::PageImages::Engine do
23
23
 
24
24
  describe "attach initializer" do
25
25
  it "calls attach on all configured model" do
26
- Refinery::PageImages.config.stub(:enable_for).and_return(enable_for_config)
26
+ allow(Refinery::PageImages.config).to receive(:enable_for).and_return(enable_for_config)
27
27
 
28
- Refinery::PageImages::EnableForMock::Model.should_receive(:has_many_page_images).once
29
- Refinery::Page.should_not_receive(:has_many_page_images)
28
+ expect(Refinery::PageImages::EnableForMock::Model).to receive(:has_many_page_images).once
29
+ expect(Refinery::Page).not_to receive(:has_many_page_images)
30
30
  ActionDispatch::Reloader.prepare!
31
31
  end
32
32
  end
33
33
 
34
34
  describe "attach_initialize_tabs!" do
35
35
  it "registers tabs for all configured engine" do
36
- Refinery::PageImages::EnableForMock::Tab.should_receive(:register).once
37
- Refinery::Pages::Tab.should_not_receive(:register)
36
+ expect(Refinery::PageImages::EnableForMock::Tab).to receive(:register).once
37
+ expect(Refinery::Pages::Tab).not_to receive(:register)
38
38
  Refinery::PageImages::Engine.initialize_tabs!
39
39
  end
40
40
  end
@@ -1,15 +1,17 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  module Refinery
4
- describe BlogPost do
5
- it "should not have images" do
6
- blog = FactoryGirl.create(:blog_post)
7
- blog.images.count.should == 0
8
- end
4
+ module Blog
5
+ describe Post, type: :model do
6
+ it "should not have images" do
7
+ blog = FactoryGirl.create(:blog_post)
8
+ expect(blog.images.count).to eq(0)
9
+ end
9
10
 
10
- it "should have images" do
11
- blog = FactoryGirl.create(:blog_post_with_image)
12
- blog.images.count.should == 1
11
+ it "should have images" do
12
+ blog = FactoryGirl.create(:blog_post_with_image)
13
+ expect(blog.images.count).to eq(1)
14
+ end
13
15
  end
14
16
  end
15
17
  end if defined?(Refinery::Blog::Post)
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+
3
+ module Refinery
4
+ describe ImagePage, type: :model do
5
+ let!(:image_page) { FactoryGirl.create(:image_page) }
6
+
7
+ describe "touching" do
8
+ let(:original_updated_at) { 1.day.ago }
9
+ let(:page) { image_page.page }
10
+
11
+ before { page.update_column(:updated_at, original_updated_at) }
12
+
13
+ it "updates a page" do
14
+ expect { image_page.touch }.to change { page.reload.updated_at }
15
+ .to be_within(3.seconds).of(Time.current)
16
+ end
17
+ end
18
+ end
19
+ end
@@ -1,78 +1,88 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  module Refinery
4
- describe Page do
4
+ describe Page, type: :model do
5
+ let!(:page) { FactoryGirl.create :page }
5
6
  it "can have images added" do
6
- page = FactoryGirl.create(:page)
7
- page.images.count.should eq(0)
7
+ expect {
8
+ page.image_pages.create(image: FactoryGirl.build(:image))
9
+ }.to change{page.images.count}.from(0).to(1)
10
+ end
11
+
12
+ describe '#images_with_captions' do
13
+ it 'returns an images_with_captions collection' do
14
+ expect {
15
+ page.image_pages.create(image: FactoryGirl.build(:image))
16
+ }.to change{page.images_with_captions.count}.from(0).to(1)
17
+ end
18
+
19
+ it 'returns an image and a caption' do
20
+ expect(page.images_with_captions.count).to eq(0)
21
+
22
+ page.image_pages.create(image: FactoryGirl.build(:image))
23
+ expect(page.images_with_captions.first[:image]).to be_a(Refinery::Image)
24
+ expect(page.images_with_captions.first[:caption]).to be_a(String)
25
+ end
8
26
 
9
- page.images << FactoryGirl.create(:image)
10
- page.images.count.should eq(1)
11
27
  end
12
28
 
13
29
  describe "#images_attributes=" do
14
30
  it "adds images" do
15
- page = FactoryGirl.create(:page)
16
31
  image = FactoryGirl.create(:image)
17
32
 
18
- page.images.count.should == 0
19
- page.update_attributes({:images_attributes => {"0" => {"id" => image.id}}})
20
-
21
- page.images.count.should == 1
33
+ expect {
34
+ page.update_attributes({:images_attributes => {"0" => {"id" => image.id}}})
35
+ }.to change { page.images.count }.from(0).to(1)
22
36
  end
23
37
 
24
- it "deletes specific images" do
25
- page = FactoryGirl.create(:page)
26
- images = [FactoryGirl.create(:image), FactoryGirl.create(:image)]
27
- page.images = images
28
-
29
- page_image_to_keep = page.image_pages.find do |image_page|
30
- image_page.image_id == images.first.id
38
+ context 'with images' do
39
+ let!(:images) { [FactoryGirl.create(:image), FactoryGirl.create(:image)] }
40
+ before do
41
+ images.each do |image|
42
+ page.image_pages.create(image: image)
43
+ end
31
44
  end
32
- page.update_attributes(:images_attributes => {
33
- "0" => {
34
- "id" => page_image_to_keep.image_id.to_s,
35
- "image_page_id" => page_image_to_keep.id
36
- },
37
- })
45
+ it "deletes specific images" do
46
+ page_image_to_keep = page.image_pages.find do |image_page|
47
+ image_page.image_id == images.first.id
48
+ end
49
+ page.update_attributes(:images_attributes => {
50
+ "0" => {
51
+ "id" => page_image_to_keep.image_id.to_s,
52
+ "image_page_id" => page_image_to_keep.id
53
+ },
54
+ })
38
55
 
39
- page.images.should eq([images.first])
40
- end
56
+ expect(page.images).to eq([images.first])
57
+ end
41
58
 
42
- it "deletes all images" do
43
- page = FactoryGirl.create(:page)
44
- images = [FactoryGirl.create(:image), FactoryGirl.create(:image)]
45
- page.images = images
59
+ it "deletes all images" do
60
+ page.update_attributes(:images_attributes => {"0" => {"id"=>""}})
46
61
 
47
- page.update_attributes(:images_attributes => {"0" => {"id"=>""}})
62
+ expect(page.images).to be_empty
63
+ end
48
64
 
49
- page.images.should be_empty
50
- end
65
+ it "reorders images" do
66
+ first_page_image = page.image_pages.find do |image_page|
67
+ image_page.image_id == images.first.id
68
+ end
69
+ second_page_image = page.image_pages.find do |image_page|
70
+ image_page.image_id == images.second.id
71
+ end
51
72
 
52
- it "reorders images" do
53
- page = FactoryGirl.create(:page)
54
- images = [FactoryGirl.create(:image), FactoryGirl.create(:image)]
55
- page.images = images
73
+ page.update_attributes(:images_attributes => {
74
+ "0" => {
75
+ "id" => second_page_image.image_id,
76
+ "image_page_id" => second_page_image.id,
77
+ },
78
+ "1" => {
79
+ "id" => first_page_image.image_id,
80
+ "image_page_id" => first_page_image.id,
81
+ },
82
+ })
56
83
 
57
- first_page_image = page.image_pages.find do |image_page|
58
- image_page.image_id == images.first.id
84
+ expect(page.images).to eq([images.second, images.first])
59
85
  end
60
- second_page_image = page.image_pages.find do |image_page|
61
- image_page.image_id == images.second.id
62
- end
63
-
64
- page.update_attributes(:images_attributes => {
65
- "0" => {
66
- "id" => second_page_image.image_id,
67
- "image_page_id" => second_page_image.id,
68
- },
69
- "1" => {
70
- "id" => first_page_image.image_id,
71
- "image_page_id" => first_page_image.id,
72
- },
73
- })
74
-
75
- page.images.should eq([images.second, images.first])
76
86
  end
77
87
  end
78
88
  end
@@ -7,13 +7,11 @@ require File.expand_path("../dummy/config/environment", __FILE__)
7
7
 
8
8
  require 'rspec/rails'
9
9
  require 'capybara/rspec'
10
- require 'factory_girl_rails'
11
10
 
12
11
  Rails.backtrace_cleaner.remove_silencers!
13
12
 
14
13
  RSpec.configure do |config|
15
14
  config.mock_with :rspec
16
- config.treat_symbols_as_metadata_keys_with_true_values = true
17
15
  config.filter_run :focus => true
18
16
  config.run_all_when_everything_filtered = true
19
17
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: refinerycms-page-images
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Philip Arndt
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-06-18 00:00:00.000000000 Z
12
+ date: 2018-03-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: refinerycms-pages
@@ -17,15 +17,43 @@ dependencies:
17
17
  requirements:
18
18
  - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: 2.1.0
20
+ version: 3.0.0
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
- version: 2.1.0
28
- description: Attach images to pages in Refinery CMS
27
+ version: 3.0.0
28
+ - !ruby/object:Gem::Dependency
29
+ name: decorators
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: 2.0.0
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: 2.0.0
42
+ - !ruby/object:Gem::Dependency
43
+ name: globalize
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: '5.0'
49
+ type: :runtime
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: '5.0'
56
+ description: Attach images to pages ins Refinery CMS
29
57
  email: info@refinerycms.com
30
58
  executables: []
31
59
  extensions: []
@@ -36,22 +64,31 @@ files:
36
64
  - Gemfile
37
65
  - Rakefile
38
66
  - app/assets/javascripts/refinery/page-image-picker.js.erb
39
- - app/assets/stylesheets/refinery/page-image-picker.css.scss
67
+ - app/assets/stylesheets/refinery/page-image-picker.scss
68
+ - app/decorators/controllers/refinery/admin/blogposts_controller_decorator.rb
69
+ - app/decorators/controllers/refinery/admin/pages_controller_decorator.rb
70
+ - app/decorators/models/refinery/page_images_page_decorator.rb
40
71
  - app/models/refinery/image_page.rb
41
72
  - app/views/refinery/admin/pages/tabs/_images.html.erb
42
73
  - app/views/refinery/admin/pages/tabs/_images_bar.html.erb
43
74
  - app/views/refinery/admin/pages/tabs/_images_field.html.erb
75
+ - bin/rake
76
+ - bin/rspec
44
77
  - config/locales/bg.yml
45
78
  - config/locales/cs.yml
79
+ - config/locales/da.yml
46
80
  - config/locales/de.yml
47
81
  - config/locales/en.yml
48
82
  - config/locales/es.yml
49
83
  - config/locales/fr.yml
84
+ - config/locales/it.yml
50
85
  - config/locales/ja.yml
51
86
  - config/locales/nl.yml
52
87
  - config/locales/pt-BR.yml
53
88
  - config/locales/ru.yml
54
89
  - config/locales/sk.yml
90
+ - config/locales/zh-CN.yml
91
+ - config/locales/zh-TW.yml
55
92
  - db/migrate/20101014230041_create_page_images.rb
56
93
  - db/migrate/20101014230042_add_caption_to_image_pages.rb
57
94
  - db/migrate/20110511215016_translate_page_image_captions.rb
@@ -67,13 +104,15 @@ files:
67
104
  - refinerycms-page-images.gemspec
68
105
  - script/rails
69
106
  - spec/factories/page-images.rb
107
+ - spec/features/admin/page_images_spec.rb
70
108
  - spec/features/attach_page_images_spec.rb
71
109
  - spec/lib/refinery/initializer_spec.rb
72
110
  - spec/models/refinery/blog_spec.rb
111
+ - spec/models/refinery/image_page_spec.rb
73
112
  - spec/models/refinery/page_spec.rb
74
113
  - spec/spec_helper.rb
75
114
  - tasks/rspec.rake
76
- homepage: https://github.com/refinery/refinerycms-page-images
115
+ homepage: http://github.com/refinery/refinerycms-page-images
77
116
  licenses:
78
117
  - MIT
79
118
  metadata: {}
@@ -93,15 +132,16 @@ required_rubygems_version: !ruby/object:Gem::Requirement
93
132
  version: '0'
94
133
  requirements: []
95
134
  rubyforge_project:
96
- rubygems_version: 2.2.2
135
+ rubygems_version: 2.6.13
97
136
  signing_key:
98
137
  specification_version: 4
99
138
  summary: Page Images extension for Refinery CMS
100
139
  test_files:
101
140
  - spec/factories/page-images.rb
141
+ - spec/features/admin/page_images_spec.rb
102
142
  - spec/features/attach_page_images_spec.rb
103
143
  - spec/lib/refinery/initializer_spec.rb
104
144
  - spec/models/refinery/blog_spec.rb
145
+ - spec/models/refinery/image_page_spec.rb
105
146
  - spec/models/refinery/page_spec.rb
106
147
  - spec/spec_helper.rb
107
- has_rdoc: