Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Hooks into the image picker API when you script/generate refinery tit…

…le:string image_id:image (for example) i.e. when you specify a field is type 'image' it will set it up as an integer field and create a belongs_to association with the Image model and create an image picker on the backend and display the image using image_fu on the frontend. Fixed a few bugs with the image picker in the process. New Version 0.9.6.18
  • Loading branch information...
commit 395c711ff31c8811adcf98362b70b123c5beefb1 1 parent 947765a
@parndt parndt authored
View
2  VERSION
@@ -1 +1 @@
-0.9.6.17
+0.9.6.18
View
2  config/application.rb
@@ -2,7 +2,7 @@
RAILS_GEM_VERSION = '2.3.5' unless defined? RAILS_GEM_VERSION
# Specified gem version of Refinery to use when vendor/plugins/refinery/lib/refinery.rb is not present.
-REFINERY_GEM_VERSION = '0.9.6.15' unless defined? REFINERY_GEM_VERSION
+REFINERY_GEM_VERSION = '0.9.6.18' unless defined? REFINERY_GEM_VERSION
# Boot Rails
require File.join(File.dirname(__FILE__), 'boot')
View
6 db/seeds.rb
@@ -7,9 +7,9 @@
{:name => "image_thumbnails", :value => {
:dialog_thumb => 'c106x106',
:grid => 'c135x135',
- :thumb => '50x50',
- :medium => '225x255',
- :side_body => '300x500',
+ :thumb => '50x50>',
+ :medium => '225x255>',
+ :side_body => '300x500>',
:preview => 'c96x96'
}
}].each do |setting|
View
7 public/javascripts/refinery/admin.js
@@ -649,8 +649,11 @@ var image_picker = {
, changed: function(image) {
$(this.options.field).val(image.id.replace("image_", ""));
- image.src = image.src.replace('_dialog_thumb', '_' + this.options.thumbnail);
- $(this.options.image_display).attr('src', image.src).addClass('brown_border').show();
+ image.src = image.src.replace('_dialog_thumb', '_' + this.options.thumbnail).replace(/\?\d*/, '');
+
+ current_image = $(this.options.image_display);
+ current_image.replaceWith($("<img src='"+image.src+"?"+Math.floor(Math.random() * 1000000000)+"' id='"+current_image.attr('id')+"' class='brown_border' />"));
+
$(this.options.remove_image_button).show();
$(this.options.no_image_message).hide();
}
View
19 readme.md
@@ -27,16 +27,15 @@ Unlike other content managers, Refinery is truly aimed at the end user making it
## Requirements
-Refinery runs using a number of gems which (as of Refinery version 0.9.6.14) are outlined below:
-
-* [rake >= 0.8.3](http://rubygems.org/gems/rake)
-* [friendly_id >= 2.3.2](http://rubygems.org/gems/friendly_id)
-* [will_paginate >= 2.3.11](http://rubygems.org/gems/will_paginate)
-* [rails >= 2.3.5](http://rubygems.org/gems/rails)
-* [aasm >= 2.1.3](http://rubygems.org/gems/aasm)
-* [unicode >= 0.1](http://rubygems.org/gems/unicode)
-* [hpricot >= 0.8.1](http://rubygems.org/gems/hpricot)
-* [slim_scrooge >= 1.0.5](http://rubygems.org/gems/slim_scrooge)
+Refinery runs using a number of gems which (as of Refinery version 0.9.6.18) are outlined below:
+
+* [friendly_id ~> 2.3.2](http://rubygems.org/gems/friendly_id)
+* [will_paginate ~> 2.3.11](http://rubygems.org/gems/will_paginate)
+* [rails ~> 2.3.5](http://rubygems.org/gems/rails)
+* [aasm ~> 2.1.3](http://rubygems.org/gems/aasm)
+* [unicode ~> 0.1](http://rubygems.org/gems/unicode)
+* [hpricot ~> 0.8.1](http://rubygems.org/gems/hpricot)
+* [slim_scrooge ~> 1.0.5](http://rubygems.org/gems/slim_scrooge)
### Other dependancies
View
2  vendor/plugins/refinery/app/views/shared/admin/_image_picker.html.erb
@@ -10,7 +10,7 @@
<div id='current_image_container_<%= randomiser %>'<%= " style='display: none'" if toggle_image_display %> style="margin-top: 10px;">
<a id='current_image_link_<%= randomiser %>' href="<%= insert_admin_images_url(:dialog => true, :callback => "image_picker_#{randomiser}_changed", :width => 958, :height => 510) %>" style='border: 0px' title='Change <%= description.titleize %>' name='Change <%= description.titleize %>' class='dialog'>
<% unless image.nil? -%>
- <%= image_fu image, nil, {:class => "brown_border", :id => "current_picked_image_#{randomiser}"} %>
+ <%= image_fu image, :medium, {:class => "brown_border", :id => "current_picked_image_#{randomiser}"} %>
<% else -%>
<img id="current_picked_image_<%= randomiser %>" class="" src="" alt="" style='display: none' />
<% end -%>
View
8 vendor/plugins/refinery/lib/generators/refinery/refinery_generator.rb
@@ -12,10 +12,10 @@ def banner
def manifest
record do |m|
# Copy controller, model and migration
- directories = ["vendor/plugins/#{plural_name}", "vendor/plugins/#{plural_name}/app", "vendor/plugins/#{plural_name}/app/controllers",
- "vendor/plugins/#{plural_name}/app/controllers/admin", "vendor/plugins/#{plural_name}/app/models", "vendor/plugins/#{plural_name}/app/views",
- "vendor/plugins/#{plural_name}/app/helpers", "vendor/plugins/#{plural_name}/app/views", "vendor/plugins/#{plural_name}/app/views/admin",
- "vendor/plugins/#{plural_name}/config", "vendor/plugins/#{plural_name}/rails"]
+ directories = ["#{plural_name}", "#{plural_name}/app", "#{plural_name}/app/controllers",
+ "#{plural_name}/app/controllers/admin", "#{plural_name}/app/models", "#{plural_name}/app/views",
+ "#{plural_name}/app/helpers", "#{plural_name}/app/views", "#{plural_name}/app/views/admin",
+ "#{plural_name}/config", "#{plural_name}/rails"].map { |d| "vendor/plugins/#{d}" }
directories.each do |dir|
m.directory dir
View
9 vendor/plugins/refinery/lib/generators/refinery/templates/migration.rb
@@ -2,7 +2,14 @@ class <%= migration_name %> < ActiveRecord::Migration
def self.up
create_table :<%= table_name %> do |t|
-<% attributes.each do |attribute| -%>
+<%
+ attributes.each do |attribute|
+ # turn image into what it was supposed to be which is an integer reference to an image.
+ if attribute.type.to_s == 'image'
+ attribute.type = 'integer'
+ attribute.name = "#{attribute.name}_id".gsub("_id_id", "_id")
+ end
+-%>
t.<%= attribute.type %> :<%= attribute.name %>
<% end -%>
t.integer :position
View
6 vendor/plugins/refinery/lib/generators/refinery/templates/model.rb
@@ -5,5 +5,9 @@ class <%= class_name %> < ActiveRecord::Base
validates_presence_of :<%= attributes.first.name %>
validates_uniqueness_of :<%= attributes.first.name %>
+
+<% attributes.collect{|a| a if a.type.to_s == 'image'}.compact.uniq.each do |a| -%>
+ belongs_to :<%= a.name.gsub("_id", "") %><%= ", :class_name => 'Image'" unless a.name =~ /^image(_id)?$/ %>
+<% end -%>
-end
+end
View
11 vendor/plugins/refinery/lib/generators/refinery/templates/views/admin/_form.html.erb
@@ -3,7 +3,14 @@
<% attributes.each_with_index do |attribute, index| %>
<div class='field'>
<%%= f.label :<%= attribute.name %> -%>
-<% if attribute.field_type.to_s == "text_area" -%>
+<% if attribute.type.to_s == 'image' -%>
+ <%%= render :partial => "/shared/admin/image_picker", :locals => {
+ :f => f,
+ :field => :<%= "#{attribute.name}_id".gsub("_id_id", "_id") %>,
+ :image => @<%= singular_name %>.<%= attribute.name.gsub("_id", "") %>,
+ :toggle_image_display => false
+ } %>
+<% elsif attribute.field_type.to_s == "text_area" -%>
<%%= f.text_area :<%= attribute.name %>, :rows => 20, :cols => 140, :class => 'wymeditor' -%>
<% else -%>
<%%= f.<%= attribute.field_type -%> :<%= attribute.name -%><%= ", :class => 'larger'" if (index == 0 && attribute.field_type == :text_field) -%> -%>
@@ -11,4 +18,4 @@
</div>
<% end %>
<%%= render :partial => "/shared/admin/form_actions", :locals => {:f => f, :continue_editing => false} %>
-<%% end -%>
+<%% end -%>
View
4 vendor/plugins/refinery/lib/generators/refinery/templates/views/show.html.erb
@@ -6,7 +6,11 @@
<% attributes.each do |attribute| %>
<div>
<h3><%= attribute.name.titleize %></h3>
+<% unless attribute.type.to_s == 'image' -%>
<%%= @<%= singular_name %>.<%= attribute.name %> %>
+<% else -%>
+ <%%= image_fu @<%= singular_name %>.<%= attribute.name %>, nil %>
+<% end -%>
</div>
<% end %>
<%% end %>
Please sign in to comment.
Something went wrong with that request. Please try again.