refinerycms-page-images 0.9 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/gemspec.rb +32 -0
- data/public/javascripts/page-image-picker.js +103 -0
- data/public/stylesheets/page-image-picker.css +50 -0
- data/readme.md +28 -0
- metadata +12 -6
data/lib/gemspec.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
version = '0.9.1'
|
3
|
+
raise "Could not get version so gemspec can not be built" if version.nil?
|
4
|
+
files = %w( readme.md )
|
5
|
+
%w(app config generators lib public rails test vendor).each do |dir|
|
6
|
+
files += Dir.glob("#{dir}/**/*") if File.directory?(dir)
|
7
|
+
end
|
8
|
+
|
9
|
+
gemspec = <<EOF
|
10
|
+
Gem::Specification.new do |s|
|
11
|
+
s.name = %q{refinerycms-page-images}
|
12
|
+
s.version = %q{#{version}}
|
13
|
+
s.description = %q{Page Images Engine for Refinery CMS}
|
14
|
+
s.date = %q{#{Time.now.strftime('%Y-%m-%d')}}
|
15
|
+
s.summary = %q{Page Images Engine for Refinery CMS}
|
16
|
+
s.email = %q{dave@resolvedigital.com}
|
17
|
+
s.homepage = %q{http://github.com/resolve/refinerycms-page-images}
|
18
|
+
s.authors = ['Resolve Digital', 'David Jones']
|
19
|
+
s.require_paths = %w(lib)
|
20
|
+
|
21
|
+
#s.add_dependency 'refinerycms', '>= 0.9.9'
|
22
|
+
|
23
|
+
s.files = [
|
24
|
+
'#{files.join("',\n '")}'
|
25
|
+
]
|
26
|
+
#{"s.test_files = [
|
27
|
+
'#{Dir.glob("test/**/*.rb").join("',\n '")}'
|
28
|
+
]" if File.directory?("test")}
|
29
|
+
end
|
30
|
+
EOF
|
31
|
+
|
32
|
+
File.open(File.expand_path("../../refinerycms-page-images.gemspec", __FILE__), 'w').puts(gemspec)
|
@@ -0,0 +1,103 @@
|
|
1
|
+
$(document).ready(function(){
|
2
|
+
$('#custom_images_tab a').click(function(){
|
3
|
+
if (!(picker = $('#page_image_picker')).data('size-applied')){
|
4
|
+
wym_box = $('.page_part:first .wym_box');
|
5
|
+
iframe = $('.page_part:first iframe');
|
6
|
+
picker.css({
|
7
|
+
height: wym_box.height()
|
8
|
+
, width: wym_box.width()
|
9
|
+
}).data('size-applied', true).corner('tr 5px').corner('bottom 5px').find('.wym_box').css({
|
10
|
+
backgroundColor: 'white'
|
11
|
+
, height: iframe.height() + $('.page_part:first .wym_area_top').height() - parseInt($('.wym_area_top .label_inline_with_link a').css('lineHeight'))
|
12
|
+
, width: iframe.width() - 20
|
13
|
+
, 'border-color': iframe.css('border-top-color')
|
14
|
+
, 'border-style': iframe.css('border-top-style')
|
15
|
+
, 'border-width': iframe.css('border-top-width')
|
16
|
+
, padding: '0px 10px 0px 10px'
|
17
|
+
});
|
18
|
+
}
|
19
|
+
});
|
20
|
+
|
21
|
+
reset_functionality();
|
22
|
+
});
|
23
|
+
|
24
|
+
reindex_images = function() {
|
25
|
+
$('#page_images li input:hidden').each(function(i, input){
|
26
|
+
// make the image's name consistent with its position.
|
27
|
+
parts = $(input).attr('name').split(']');
|
28
|
+
parts[1] = ('[' + i)
|
29
|
+
$(input).attr('name', parts.join(']'));
|
30
|
+
|
31
|
+
// make the image's id consistent with its position.
|
32
|
+
$(input).attr('id', $(input).attr('id').replace(/_\d_/, '_'+i+'_').replace(/_\d/, '_'+i));
|
33
|
+
});
|
34
|
+
}
|
35
|
+
|
36
|
+
reset_functionality = function() {
|
37
|
+
$("#page_images").sortable({
|
38
|
+
'tolerance': 'pointer'
|
39
|
+
, 'placeholder': 'placeholder'
|
40
|
+
, 'cursor': 'drag'
|
41
|
+
, 'items': 'li'
|
42
|
+
, stop: reindex_images
|
43
|
+
});
|
44
|
+
|
45
|
+
$('#content #page_images li:not(.empty)').each(function(index, li) {
|
46
|
+
$(this).hover(function(e){
|
47
|
+
if ((image_actions = $(this).find('.image_actions')).length == 0) {
|
48
|
+
image_actions = $("<div class='image_actions'></div>");
|
49
|
+
img_delete = $("<img src='/images/refinery/icons/delete.png' width='16' height='16' />");
|
50
|
+
img_delete.appendTo(image_actions);
|
51
|
+
img_delete.click(function() {
|
52
|
+
$(this).parents('li[id*=image_]').remove();
|
53
|
+
reindex_images();
|
54
|
+
});
|
55
|
+
|
56
|
+
image_actions.appendTo($(li));
|
57
|
+
}
|
58
|
+
|
59
|
+
image_actions.show();
|
60
|
+
}, function(e) {
|
61
|
+
$(this).find('.image_actions').hide();
|
62
|
+
});
|
63
|
+
});
|
64
|
+
|
65
|
+
reindex_images();
|
66
|
+
}
|
67
|
+
|
68
|
+
image_added = function(image) {
|
69
|
+
new_list_item = (current_list_item = $('li.empty')).clone();
|
70
|
+
image_id = $(image).attr('id').replace('image_', '');
|
71
|
+
current_list_item.find('input:hidden').val(image_id);
|
72
|
+
$.ajax({
|
73
|
+
async: false,
|
74
|
+
url: '/refinery/images/'+image_id+'/url',
|
75
|
+
data: {size: '135x135#c'},
|
76
|
+
success: function (result, status, xhr) {
|
77
|
+
if (result.error) {
|
78
|
+
if (console && console.log) {
|
79
|
+
console.log("Something went wrong with the image insertion!");
|
80
|
+
console.log(result);
|
81
|
+
}
|
82
|
+
} else {
|
83
|
+
(img = $("<img />")).attr({
|
84
|
+
title: $(image).attr('title')
|
85
|
+
, alt: $(image).attr('alt')
|
86
|
+
, src: result.url
|
87
|
+
}).appendTo(current_list_item);
|
88
|
+
}
|
89
|
+
},
|
90
|
+
error: function(xhr, txt, status) {
|
91
|
+
if (console && console.log) {
|
92
|
+
console.log("Something went wrong with the image insertion!");
|
93
|
+
console.log(xhr);
|
94
|
+
console.log(txt);
|
95
|
+
console.log(status);
|
96
|
+
}
|
97
|
+
}
|
98
|
+
});
|
99
|
+
|
100
|
+
current_list_item.attr('id', 'image_' + image_id).removeClass('empty');
|
101
|
+
|
102
|
+
new_list_item.appendTo($('#page_images'));
|
103
|
+
}
|
@@ -0,0 +1,50 @@
|
|
1
|
+
#page_images {
|
2
|
+
margin: 0px;
|
3
|
+
padding: 0px;
|
4
|
+
width: 280px;
|
5
|
+
}
|
6
|
+
#page_images li {
|
7
|
+
position: relative;
|
8
|
+
list-style: none;
|
9
|
+
float: left;
|
10
|
+
margin-bottom: 20px;
|
11
|
+
}
|
12
|
+
#page_images li.odd {
|
13
|
+
margin-right: 18px;
|
14
|
+
}
|
15
|
+
#page_images {
|
16
|
+
width: 100%;
|
17
|
+
}
|
18
|
+
#page_images li {
|
19
|
+
margin-right: 20px;
|
20
|
+
position: relative;
|
21
|
+
margin-bottom: 10px;
|
22
|
+
margin-top: 10px;
|
23
|
+
}
|
24
|
+
#page_images li .image_actions {
|
25
|
+
background: white;
|
26
|
+
position: absolute;
|
27
|
+
padding: 3px;
|
28
|
+
left: 0px;
|
29
|
+
top: 0px;
|
30
|
+
}
|
31
|
+
#page_images li * {
|
32
|
+
cursor: move;
|
33
|
+
}
|
34
|
+
#page_images li .image_actions * {
|
35
|
+
cursor: pointer;
|
36
|
+
}
|
37
|
+
#content ul.ui-sortable li {
|
38
|
+
border: 0px none;
|
39
|
+
background: none !important;
|
40
|
+
}
|
41
|
+
#content #page_images.ui-sortable li.placeholder {
|
42
|
+
width: 135px;
|
43
|
+
height: 135px;
|
44
|
+
}
|
45
|
+
|
46
|
+
a#add_image_link {
|
47
|
+
line-height: 20px;
|
48
|
+
padding: 2px 5px 2px 5px;
|
49
|
+
display: inline;
|
50
|
+
}
|
data/readme.md
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# Page Images Engine for Refinery CMS
|
2
|
+
|
3
|
+
## About
|
4
|
+
|
5
|
+
This engine does two main things:
|
6
|
+
|
7
|
+
1. Adds a relationship between pages and images
|
8
|
+
2. A new "Images" tab will appear when editing a page in the "Pages" section
|
9
|
+
|
10
|
+
This 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.
|
11
|
+
|
12
|
+
## Install
|
13
|
+
|
14
|
+
Add this line to your applications `Gemfile`
|
15
|
+
|
16
|
+
gem 'refinerycms-page-images', '= 0.9'
|
17
|
+
|
18
|
+
Next run
|
19
|
+
|
20
|
+
bundle install
|
21
|
+
rails g refinerycms_page_images
|
22
|
+
rake db:migrate
|
23
|
+
|
24
|
+
Now when you start up your Refinery application, edit a page and there should be a b=new "Images" tab.
|
25
|
+
|
26
|
+
## Todo
|
27
|
+
|
28
|
+
Reordering doesn't store it's position yet.
|
metadata
CHANGED
@@ -1,20 +1,22 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: refinerycms-page-images
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 57
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 9
|
9
|
-
|
9
|
+
- 1
|
10
|
+
version: 0.9.1
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
|
-
- Resolve Digital
|
13
|
+
- Resolve Digital
|
14
|
+
- David Jones
|
13
15
|
autorequire:
|
14
16
|
bindir: bin
|
15
17
|
cert_chain: []
|
16
18
|
|
17
|
-
date: 2010-10-
|
19
|
+
date: 2010-10-07 00:00:00 +13:00
|
18
20
|
default_executable:
|
19
21
|
dependencies: []
|
20
22
|
|
@@ -27,10 +29,14 @@ extensions: []
|
|
27
29
|
extra_rdoc_files: []
|
28
30
|
|
29
31
|
files:
|
30
|
-
-
|
31
|
-
- lib/refinerycms-page-images.rb
|
32
|
+
- readme.md
|
32
33
|
- app/models/images_pages.rb
|
33
34
|
- app/views/admin/pages/tabs/_images.html.erb
|
35
|
+
- lib/gemspec.rb
|
36
|
+
- lib/generators/refinerycms_page_images_generator.rb
|
37
|
+
- lib/refinerycms-page-images.rb
|
38
|
+
- public/javascripts/page-image-picker.js
|
39
|
+
- public/stylesheets/page-image-picker.css
|
34
40
|
has_rdoc: true
|
35
41
|
homepage: http://github.com/resolve/refinerycms-page-images
|
36
42
|
licenses: []
|