refinerycms-page-images 1.0.4 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/.travis.yml +16 -0
- data/Gemfile +70 -0
- data/Rakefile +19 -0
- data/{public/javascripts/page-image-picker.js → app/assets/javascripts/refinery/page-image-picker.js.erb} +21 -28
- data/app/assets/stylesheets/refinery/page-image-picker.css.scss +57 -0
- data/app/models/refinery/image_page.rb +13 -0
- data/app/views/refinery/admin/pages/tabs/_images.html.erb +12 -0
- data/app/views/{admin → refinery/admin}/pages/tabs/_images_bar.html.erb +2 -2
- data/app/views/{admin → refinery/admin}/pages/tabs/_images_field.html.erb +7 -6
- data/config/locales/bg.yml +16 -0
- data/config/locales/cs.yml +16 -0
- data/config/locales/de.yml +10 -0
- data/config/locales/en.yml +15 -9
- data/config/locales/fr.yml +16 -0
- data/config/locales/nl.yml +11 -10
- data/config/locales/pt-BR.yml +16 -0
- data/config/locales/ru.yml +11 -0
- data/config/locales/sk.yml +16 -0
- data/db/migrate/20101014230041_create_page_images.rb +5 -11
- data/db/migrate/20101014230042_add_caption_to_image_pages.rb +2 -6
- data/db/migrate/20110511215016_translate_page_image_captions.rb +22 -0
- data/db/migrate/20110527052435_change_page_to_polymorphic.rb +5 -0
- data/lib/generators/refinery/page_images_generator.rb +15 -0
- data/lib/generators/refinery/templates/config/initializers/refinery/page_images.rb.erb +3 -0
- data/lib/refinery/page_images/configuration.rb +9 -0
- data/lib/refinery/page_images/engine.rb +46 -0
- data/lib/refinery/page_images/extension.rb +66 -0
- data/lib/refinery/page_images.rb +22 -0
- data/lib/refinerycms-page-images.rb +1 -54
- data/readme.md +29 -35
- data/refinerycms-page-images.gemspec +17 -0
- data/spec/factories/page-images.rb +9 -0
- data/spec/models/refinery/blog_spec.rb +15 -0
- data/spec/models/refinery/page_spec.rb +69 -0
- data/spec/requests/attach_page_images_spec.rb +29 -0
- data/spec/spec_helper.rb +56 -0
- data/spec/support/database_cleaner.rb +17 -0
- data/spec/support/devise.rb +8 -0
- data/spec/support/refinery.rb +6 -0
- data/tasks/rspec.rake +4 -0
- metadata +84 -21
- data/app/models/image_page.rb +0 -10
- data/app/views/admin/pages/tabs/_images.html.erb +0 -12
- data/features/attach_page_images.feature +0 -17
- data/lib/gemspec.rb +0 -29
- data/lib/generators/refinerycms_page_images_generator.rb +0 -6
- data/public/stylesheets/page-image-picker.css +0 -62
data/.gitignore
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
before_script:
|
2
|
+
- "bundle exec rake refinery:testing:dummy_app > /dev/null"
|
3
|
+
script: "bundle exec rspec ./spec"
|
4
|
+
notifications:
|
5
|
+
email:
|
6
|
+
- parndt@gmail.com
|
7
|
+
- ugis.ozolss@gmail.com
|
8
|
+
env:
|
9
|
+
- DB=postgresql
|
10
|
+
- DB=mysql
|
11
|
+
rvm:
|
12
|
+
- 1.8.7
|
13
|
+
- 1.9.2
|
14
|
+
- 1.9.3
|
15
|
+
- rbx
|
16
|
+
- jruby
|
data/Gemfile
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
|
3
|
+
gemspec
|
4
|
+
|
5
|
+
gem 'refinerycms', '~> 2.0.1'
|
6
|
+
|
7
|
+
group :development, :test do
|
8
|
+
gem 'refinerycms-testing', '~> 2.0.0'
|
9
|
+
end
|
10
|
+
|
11
|
+
group :development, :test do
|
12
|
+
require 'rbconfig'
|
13
|
+
|
14
|
+
platforms :jruby do
|
15
|
+
gem 'activerecord-jdbcsqlite3-adapter'
|
16
|
+
gem 'activerecord-jdbcmysql-adapter'
|
17
|
+
gem 'activerecord-jdbcpostgresql-adapter'
|
18
|
+
gem 'jruby-openssl'
|
19
|
+
end
|
20
|
+
|
21
|
+
unless defined?(JRUBY_VERSION)
|
22
|
+
gem 'sqlite3'
|
23
|
+
gem 'mysql2'
|
24
|
+
gem 'pg'
|
25
|
+
end
|
26
|
+
|
27
|
+
platforms :mswin, :mingw do
|
28
|
+
gem 'win32console'
|
29
|
+
gem 'rb-fchange', '~> 0.0.5'
|
30
|
+
gem 'rb-notifu', '~> 0.0.4'
|
31
|
+
end
|
32
|
+
|
33
|
+
platforms :ruby do
|
34
|
+
gem 'spork', '0.9.0.rc9'
|
35
|
+
gem 'guard-spork'
|
36
|
+
|
37
|
+
unless ENV['TRAVIS']
|
38
|
+
if RbConfig::CONFIG['target_os'] =~ /darwin/i
|
39
|
+
gem 'rb-fsevent', '>= 0.3.9'
|
40
|
+
gem 'growl', '~> 1.0.3'
|
41
|
+
end
|
42
|
+
if RbConfig::CONFIG['target_os'] =~ /linux/i
|
43
|
+
gem 'rb-inotify', '>= 0.5.1'
|
44
|
+
gem 'libnotify', '~> 0.1.3'
|
45
|
+
gem 'therubyracer', '~> 0.9.9'
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
platforms :jruby do
|
51
|
+
unless ENV['TRAVIS']
|
52
|
+
if RbConfig::CONFIG['target_os'] =~ /darwin/i
|
53
|
+
gem 'growl', '~> 1.0.3'
|
54
|
+
end
|
55
|
+
if RbConfig::CONFIG['target_os'] =~ /linux/i
|
56
|
+
gem 'rb-inotify', '>= 0.5.1'
|
57
|
+
gem 'libnotify', '~> 0.1.3'
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
# Refinery/rails should pull in the proper versions of these
|
64
|
+
group :assets do
|
65
|
+
gem 'sass-rails'
|
66
|
+
gem 'coffee-rails'
|
67
|
+
gem 'uglifier'
|
68
|
+
end
|
69
|
+
|
70
|
+
gem 'jquery-rails'
|
data/Rakefile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
begin
|
3
|
+
require 'bundler/setup'
|
4
|
+
rescue LoadError
|
5
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
|
+
end
|
7
|
+
|
8
|
+
ENGINE_PATH = File.dirname(__FILE__)
|
9
|
+
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
10
|
+
|
11
|
+
if File.exists?(APP_RAKEFILE)
|
12
|
+
load 'rails/tasks/engine.rake'
|
13
|
+
end
|
14
|
+
|
15
|
+
require "refinerycms-testing"
|
16
|
+
Refinery::Testing::Railtie.load_tasks
|
17
|
+
Refinery::Testing::Railtie.load_dummy_tasks(ENGINE_PATH)
|
18
|
+
|
19
|
+
load File.expand_path('../tasks/rspec.rake', __FILE__)
|
@@ -57,7 +57,7 @@ reset_functionality = function() {
|
|
57
57
|
if (e.type == 'mouseenter' || e.type == 'mouseover') {
|
58
58
|
if ((image_actions = $(this).find('.image_actions')).length == 0) {
|
59
59
|
image_actions = $("<div class='image_actions'></div>");
|
60
|
-
img_delete = $("<img src='/
|
60
|
+
img_delete = $("<img src='/assets/refinery/icons/delete.png' width='16' height='16' />");
|
61
61
|
img_delete.appendTo(image_actions);
|
62
62
|
img_delete.click(function() {
|
63
63
|
$(this).parents('li').first().remove();
|
@@ -65,7 +65,7 @@ reset_functionality = function() {
|
|
65
65
|
});
|
66
66
|
|
67
67
|
if ($(this).find('textarea.page_caption').length > 0) {
|
68
|
-
img_caption = $("<img src='/
|
68
|
+
img_caption = $("<img src='/assets/refinery/icons/user_comment.png' width='16' height='16' class='caption' />");
|
69
69
|
img_caption.appendTo(image_actions);
|
70
70
|
img_caption.click(open_image_caption);
|
71
71
|
} else {
|
@@ -87,7 +87,7 @@ reset_functionality = function() {
|
|
87
87
|
image_added = function(image) {
|
88
88
|
new_list_item = (current_list_item = $('li.empty')).clone();
|
89
89
|
image_id = $(image).attr('id').replace('image_', '');
|
90
|
-
current_list_item.find('input:hidden').val(image_id);
|
90
|
+
current_list_item.find('input:hidden:first').val(image_id);
|
91
91
|
|
92
92
|
$("<img />").attr({
|
93
93
|
title: $(image).attr('title')
|
@@ -106,15 +106,15 @@ open_image_caption = function(e) {
|
|
106
106
|
(list_item = $(this).parents('li').first()).addClass('current_caption_list_item');
|
107
107
|
textarea = list_item.find('.textarea_wrapper_for_wym > textarea');
|
108
108
|
|
109
|
-
textarea.after($("<div class='form-actions'><div class='form-actions-left'><a class='button'
|
109
|
+
textarea.after($("<div class='form-actions'><div class='form-actions-left'><a class='button'><%= I18n.t('refinery.js.admin.page_images.done') %></a></div></div>"));
|
110
110
|
textarea.parent().dialog({
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
111
|
+
title: "<%= I18n.t('refinery.js.admin.page_images.add_caption') %>"
|
112
|
+
, modal: true
|
113
|
+
, resizable: false
|
114
|
+
, autoOpen: true
|
115
|
+
, width: 928
|
116
|
+
, height: 530
|
117
|
+
});
|
118
118
|
|
119
119
|
$('.ui-dialog:visible .ui-dialog-titlebar-close, .ui-dialog:visible .form-actions a.button')
|
120
120
|
.bind('click',
|
@@ -153,22 +153,15 @@ reindex_images = function() {
|
|
153
153
|
$(input).attr('id', $(input).attr('id').replace(/_\d/, '_' + i));
|
154
154
|
$(input).attr('data-old-id', $(input).attr('data-old-id').replace(/_\d_/, '_'+i+'_').replace(/_\d/, '_' + i));
|
155
155
|
});
|
156
|
-
$('#page_images li
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
// make the image's name consistent with its position.
|
167
|
-
parts = $(input).attr('name').split(']');
|
168
|
-
parts[1] = ('[' + i);
|
169
|
-
$(input).attr('name', parts.join(']'));
|
170
|
-
|
171
|
-
// make the image's id consistent with its position.
|
172
|
-
$(input).attr('id', $(input).attr('id').replace(/_\d_/, '_'+i+'_').replace(/_\d/, '_'+i));
|
156
|
+
$('#page_images li').each(function(i, li){
|
157
|
+
$('input:hidden', li).each(function() {
|
158
|
+
// make the image's name consistent with its position.
|
159
|
+
parts = $(this).attr('name').split(']');
|
160
|
+
parts[1] = ('[' + i);
|
161
|
+
$(this).attr('name', parts.join(']'));
|
162
|
+
|
163
|
+
// make the image's id consistent with its position.
|
164
|
+
$(this).attr('id', $(this).attr('id').replace(/_\d_/, '_'+i+'_').replace(/_\d/, '_'+i));
|
165
|
+
});
|
173
166
|
});
|
174
167
|
}
|
@@ -0,0 +1,57 @@
|
|
1
|
+
#page_images {
|
2
|
+
margin: 0;
|
3
|
+
padding: 0;
|
4
|
+
width: 280px;
|
5
|
+
width: 100%;
|
6
|
+
li {
|
7
|
+
position: relative;
|
8
|
+
list-style: none;
|
9
|
+
float: left;
|
10
|
+
margin: 10px 20px 20px 0;
|
11
|
+
* {
|
12
|
+
cursor: move;
|
13
|
+
}
|
14
|
+
&.odd {
|
15
|
+
margin-right: 18px;
|
16
|
+
}
|
17
|
+
.image_actions {
|
18
|
+
background: white;
|
19
|
+
position: absolute;
|
20
|
+
padding: 3px;
|
21
|
+
left: 0;
|
22
|
+
top: 0;
|
23
|
+
width: 135px;
|
24
|
+
* {
|
25
|
+
cursor: pointer;
|
26
|
+
}
|
27
|
+
&.no_captions {
|
28
|
+
background: transparent;
|
29
|
+
}
|
30
|
+
}
|
31
|
+
}
|
32
|
+
> li .image_actions img.caption {
|
33
|
+
position: absolute;
|
34
|
+
right: 3px;
|
35
|
+
top: 3px;
|
36
|
+
}
|
37
|
+
}
|
38
|
+
|
39
|
+
#content {
|
40
|
+
ul.ui-sortable li {
|
41
|
+
border: 0;
|
42
|
+
background: none !important;
|
43
|
+
}
|
44
|
+
#page_images.ui-sortable li.placeholder {
|
45
|
+
width: 135px;
|
46
|
+
height: 135px;
|
47
|
+
}
|
48
|
+
}
|
49
|
+
|
50
|
+
a#add_image_link {
|
51
|
+
margin-top: 0;
|
52
|
+
line-height: 29px;
|
53
|
+
padding-left: 20px;
|
54
|
+
display: inline;
|
55
|
+
border-bottom: 0;
|
56
|
+
background: image-url('refinery/icons/add.png') no-repeat 0px 6px;
|
57
|
+
}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Refinery
|
2
|
+
class ImagePage < Refinery::Core::BaseModel
|
3
|
+
|
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
|
11
|
+
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
<div class='wym_skin_refinery page_part' id='page_image_picker'>
|
2
|
+
<%= render :partial => '/refinery/admin/pages/tabs/images_bar', :locals => {:f => f} %>
|
3
|
+
<%= render :partial => '/refinery/admin/pages/tabs/images_field', :locals => {:f => f} %>
|
4
|
+
</div>
|
5
|
+
|
6
|
+
<% content_for :stylesheets do %>
|
7
|
+
<%= stylesheet_link_tag 'refinery/page-image-picker' %>
|
8
|
+
<% end %>
|
9
|
+
|
10
|
+
<% content_for :javascripts do %>
|
11
|
+
<%= javascript_include_tag 'refinery/page-image-picker' %>
|
12
|
+
<% end %>
|
@@ -1,9 +1,9 @@
|
|
1
1
|
<div class='wym_area_top'>
|
2
2
|
<span class='clearfix label_inline_with_link'>
|
3
|
-
<%= link_to t('.add'),
|
3
|
+
<%= link_to t('.add'), refinery.insert_admin_images_path({
|
4
4
|
:dialog => true, :width => 950, :height => 510,
|
5
5
|
:callback => "image_added"
|
6
6
|
}),
|
7
7
|
:id => "add_image_link" %>
|
8
8
|
</span>
|
9
|
-
</div>
|
9
|
+
</div>
|
@@ -4,10 +4,11 @@
|
|
4
4
|
<li id='image_<%= image_form.object.id %>'>
|
5
5
|
<%= image_form.hidden_field :id %>
|
6
6
|
<%= image_fu image_form.object, '135x135#c' %>
|
7
|
-
<%
|
7
|
+
<% index = image_form.object_name.split('[').last.split(']').first.to_i %>
|
8
|
+
<%= hidden_field_tag "#{f.object_name.demodulize}[images_attributes][#{index}][image_page_id]", f.object.image_page_id_for_image_index(index) %>
|
9
|
+
<% if Refinery::PageImages.captions %>
|
8
10
|
<div class='textarea_wrapper_for_wym'>
|
9
|
-
|
10
|
-
<%= text_area_tag "#{f.object_name}[images_attributes][#{index}][caption]",
|
11
|
+
<%= text_area_tag "#{f.object_name.demodulize}[images_attributes][#{index}][caption]",
|
11
12
|
f.object.caption_for_image_index(index),
|
12
13
|
:style => 'display: none',
|
13
14
|
:id => "page_captions_#{index}",
|
@@ -17,10 +18,10 @@
|
|
17
18
|
</li>
|
18
19
|
<% end %>
|
19
20
|
<li class='empty'>
|
20
|
-
<%= hidden_field_tag "#{f.
|
21
|
-
<% if
|
21
|
+
<%= hidden_field_tag "#{f.object_name.demodulize}[images_attributes][#{f.object.images.size}][id]" %>
|
22
|
+
<% if Refinery::PageImages.captions %>
|
22
23
|
<div class='textarea_wrapper_for_wym'>
|
23
|
-
<%= text_area_tag "#{f.object_name}[images_attributes][#{f.object.images.size}][caption]",
|
24
|
+
<%= text_area_tag "#{f.object_name.demodulize}[images_attributes][#{f.object.images.size}][caption]",
|
24
25
|
'',
|
25
26
|
:style => 'display: none',
|
26
27
|
:id => "page_captions_#{f.object.images.size}",
|
@@ -0,0 +1,16 @@
|
|
1
|
+
bg:
|
2
|
+
refinery:
|
3
|
+
plugins:
|
4
|
+
refinery_page_images:
|
5
|
+
title: Изображения на страница
|
6
|
+
description: Чрез добавката "Изображения на страница" имате възможност да свържите едно или повече изображения с всяка страница в Refinery. Така лесно ще можете да създавате опростени галерии с изображения, които се отварят в изкачащ прозорец като при lightbox.
|
7
|
+
js:
|
8
|
+
admin:
|
9
|
+
page_images:
|
10
|
+
add_caption: Добавяне на заглавие
|
11
|
+
done: Готово
|
12
|
+
admin:
|
13
|
+
pages:
|
14
|
+
tabs:
|
15
|
+
images_bar:
|
16
|
+
add: Добавяне на изображение
|
@@ -0,0 +1,16 @@
|
|
1
|
+
cs:
|
2
|
+
refinery:
|
3
|
+
plugins:
|
4
|
+
refinery_page_images:
|
5
|
+
title: Obrázky stránek
|
6
|
+
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
|
+
js:
|
8
|
+
admin:
|
9
|
+
page_images:
|
10
|
+
add_caption: Přidat titulek
|
11
|
+
done: Hotovo
|
12
|
+
admin:
|
13
|
+
pages:
|
14
|
+
tabs:
|
15
|
+
images_bar:
|
16
|
+
add: Přidat obrázek
|
@@ -0,0 +1,10 @@
|
|
1
|
+
de:
|
2
|
+
refinery:
|
3
|
+
plugins:
|
4
|
+
refinery_page_images:
|
5
|
+
title: Das Seitenbilder-Plugin erlaubt dir ein oder mehrere Bilder einer Seite zuzuordnen. Damit ist es möglich Bildergalerien in der Frontendansicht darzustellen.
|
6
|
+
admin:
|
7
|
+
pages:
|
8
|
+
tabs:
|
9
|
+
images_bar:
|
10
|
+
add: Bild hinzufügen
|
data/config/locales/en.yml
CHANGED
@@ -1,10 +1,16 @@
|
|
1
1
|
en:
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
2
|
+
refinery:
|
3
|
+
plugins:
|
4
|
+
refinery_page_images:
|
5
|
+
title: Page Images
|
6
|
+
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
|
+
js:
|
8
|
+
admin:
|
9
|
+
page_images:
|
10
|
+
add_caption: Add Caption
|
11
|
+
done: Done
|
12
|
+
admin:
|
13
|
+
pages:
|
14
|
+
tabs:
|
15
|
+
images_bar:
|
16
|
+
add: Add Image
|
@@ -0,0 +1,16 @@
|
|
1
|
+
fr:
|
2
|
+
refinery:
|
3
|
+
plugins:
|
4
|
+
refinery_page_images:
|
5
|
+
title: Page Images
|
6
|
+
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
|
+
js:
|
8
|
+
admin:
|
9
|
+
page_images:
|
10
|
+
add_caption: Ajouter une légende
|
11
|
+
done: Terminé
|
12
|
+
admin:
|
13
|
+
pages:
|
14
|
+
tabs:
|
15
|
+
images_bar:
|
16
|
+
add: Ajouter une image
|
data/config/locales/nl.yml
CHANGED
@@ -1,10 +1,11 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
1
|
+
nl:
|
2
|
+
refinery:
|
3
|
+
plugins:
|
4
|
+
refinery_page_images:
|
5
|
+
title: Pagina Afbeeldingen
|
6
|
+
description: Pagina Afbeeldingen stelt u in staat op afbeeldingen te koppelen aan een specifieke pagina.
|
7
|
+
admin:
|
8
|
+
pages:
|
9
|
+
tabs:
|
10
|
+
images_bar:
|
11
|
+
add: Afbeelding toevoegen.
|
@@ -0,0 +1,16 @@
|
|
1
|
+
pt-BR:
|
2
|
+
refinery:
|
3
|
+
plugins:
|
4
|
+
refinery_page_images:
|
5
|
+
title: Imagens da Página
|
6
|
+
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
|
+
js:
|
8
|
+
admin:
|
9
|
+
page_images:
|
10
|
+
add_caption: Adicionar Legenda
|
11
|
+
done: Feito
|
12
|
+
admin:
|
13
|
+
pages:
|
14
|
+
tabs:
|
15
|
+
images_bar:
|
16
|
+
add: Adicionar Imagem
|
@@ -0,0 +1,11 @@
|
|
1
|
+
ru:
|
2
|
+
refinery:
|
3
|
+
plugins:
|
4
|
+
refinery_page_images:
|
5
|
+
title: Изображения страницы
|
6
|
+
description: Плагин работы с изображениями страницы "Page Images" позволяет связывать одно или несколько изображений с любой страницей в Refinery. С помощью плагина можно с легкостью создавать простые галереи изображений с поддержкой всплывающих полноразмерных изображений в стиле lightbox.
|
7
|
+
admin:
|
8
|
+
pages:
|
9
|
+
tabs:
|
10
|
+
images_bar:
|
11
|
+
add: Добавить
|
@@ -0,0 +1,16 @@
|
|
1
|
+
sk:
|
2
|
+
refinery:
|
3
|
+
plugins:
|
4
|
+
refinery_page_images:
|
5
|
+
title: Obrázky stránok
|
6
|
+
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
|
+
js:
|
8
|
+
admin:
|
9
|
+
page_images:
|
10
|
+
add_caption: Pridať titulok
|
11
|
+
done: Hotovo
|
12
|
+
admin:
|
13
|
+
pages:
|
14
|
+
tabs:
|
15
|
+
images_bar:
|
16
|
+
add: Pridať obrázok
|
@@ -1,18 +1,12 @@
|
|
1
1
|
class CreatePageImages < ActiveRecord::Migration
|
2
|
-
|
3
|
-
|
4
|
-
create_table :image_pages, :id => false do |t|
|
2
|
+
def change
|
3
|
+
create_table Refinery::ImagePage.table_name, :id => false do |t|
|
5
4
|
t.integer :image_id
|
6
5
|
t.integer :page_id
|
7
6
|
t.integer :position
|
8
7
|
end
|
9
8
|
|
10
|
-
add_index
|
11
|
-
add_index
|
12
|
-
end
|
13
|
-
|
14
|
-
def self.down
|
15
|
-
drop_table :image_pages
|
9
|
+
add_index Refinery::ImagePage.table_name, :image_id
|
10
|
+
add_index Refinery::ImagePage.table_name, :page_id
|
16
11
|
end
|
17
|
-
|
18
|
-
end
|
12
|
+
end
|
@@ -1,9 +1,5 @@
|
|
1
1
|
class AddCaptionToImagePages < ActiveRecord::Migration
|
2
|
-
def
|
3
|
-
add_column
|
4
|
-
end
|
5
|
-
|
6
|
-
def self.down
|
7
|
-
remove_column :image_pages, :caption
|
2
|
+
def change
|
3
|
+
add_column Refinery::ImagePage.table_name, :caption, :text
|
8
4
|
end
|
9
5
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
class TranslatePageImageCaptions < ActiveRecord::Migration
|
2
|
+
def up
|
3
|
+
add_column Refinery::ImagePage.table_name, :id, :primary_key
|
4
|
+
|
5
|
+
Refinery::ImagePage.reset_column_information
|
6
|
+
unless defined?(Refinery::ImagePage::Translation) && Refinery::ImagePage::Translation.table_exists?
|
7
|
+
Refinery::ImagePage.create_translation_table!({
|
8
|
+
:caption => :text
|
9
|
+
}, {
|
10
|
+
:migrate_data => true
|
11
|
+
})
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def down
|
16
|
+
Refinery::ImagePage.reset_column_information
|
17
|
+
|
18
|
+
Refinery::ImagePage.drop_translation_table! :migrate_data => true
|
19
|
+
|
20
|
+
remove_column Refinery::ImagePage.table_name, :id
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Refinery
|
2
|
+
class PageImagesGenerator < Rails::Generators::Base
|
3
|
+
|
4
|
+
source_root File.expand_path("../templates", __FILE__)
|
5
|
+
|
6
|
+
def rake_db
|
7
|
+
rake("refinery_page_images:install:migrations")
|
8
|
+
end
|
9
|
+
|
10
|
+
def generate_page_images_initializer
|
11
|
+
template "config/initializers/refinery/page_images.rb.erb", File.join(destination_root, "config", "initializers", "refinery", "page_images.rb")
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module Refinery
|
2
|
+
module PageImages
|
3
|
+
class Engine < Rails::Engine
|
4
|
+
include Refinery::Engine
|
5
|
+
|
6
|
+
isolate_namespace Refinery
|
7
|
+
|
8
|
+
engine_name :refinery_page_images
|
9
|
+
|
10
|
+
def self.register(tab)
|
11
|
+
tab.name = "images"
|
12
|
+
tab.partial = "/refinery/admin/pages/tabs/images"
|
13
|
+
end
|
14
|
+
|
15
|
+
initializer "register refinery_page_images plugin" do
|
16
|
+
Refinery::Plugin.register do |plugin|
|
17
|
+
plugin.name = "page_images"
|
18
|
+
plugin.hide_from_menu = true
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
config.to_prepare do
|
23
|
+
require 'refinerycms-pages'
|
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
|
29
|
+
end
|
30
|
+
|
31
|
+
config.after_initialize do
|
32
|
+
Refinery::Pages::Tab.register do |tab|
|
33
|
+
register tab
|
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)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|