Navigation Menu

Skip to content

Commit

Permalink
Merge branch '1-0-stable'
Browse files Browse the repository at this point in the history
Conflicts:
	db/seeds/pages.rb
	images/app/models/image.rb
	images/spec/models/image_spec.rb
	pages/db/seeds/pages.rb
  • Loading branch information
parndt committed Jul 26, 2011
2 parents 6209aab + 33a2415 commit f41a74d
Show file tree
Hide file tree
Showing 10 changed files with 143 additions and 147 deletions.
27 changes: 11 additions & 16 deletions core/app/assets/javascripts/refinery/admin.js
Expand Up @@ -412,7 +412,7 @@ init_tooltips = function(args){
var link_tester = {
initialised: false
, init: function(test_url, test_email) {

if (!this.initialised) {
this.test_url = test_url;
this.test_email = test_email;
Expand Down Expand Up @@ -488,7 +488,7 @@ var link_tester = {
var link_dialog = {
initialised: false
, init: function(){

if (!this.initialised) {
this.init_tabs();
this.init_resources_submit();
Expand Down Expand Up @@ -627,7 +627,7 @@ var link_dialog = {
var page_options = {
initialised: false
, init: function(enable_parts, new_part_url, del_part_url){

if (!this.initialised) {
// set the page tabs up, but ensure that all tabs are shown so that when wymeditor loads it has a proper height.
page_options.tabs = $('#page-tabs');
Expand Down Expand Up @@ -705,17 +705,17 @@ var page_options = {
}, function(data, status){
$('#submit_continue_button').remove();
// Add a new tab for the new content section.
$(data).appendTo('#page_part_editors');
$('#page_part_editors').append(data);
page_options.tabs.tabs('add', '#page_part_new_' + $('#new_page_part_index').val(), part_title);
page_options.tabs.tabs('select', $('#new_page_part_index').val());

// hook into wymedtior to instruct it to select this new tab again once it has loaded.
// hook into wymeditor to instruct it to select this new tab again once it has loaded.
WYMeditor.onload_functions.push(function() {
$('#page_part_new_' + $('#new_page_part_index').val()).appendTo('#page_part_editors');
page_options.tabs.tabs('select', $('#new_page_part_index').val());
});

// turn the new textarea into a wymeditor.
$('#page_part_new_' + $('#new_page_part_index').val()).appendTo('#page_part_editors')
WYMeditor.init();

// Wipe the title and increment the index counter by one.
Expand Down Expand Up @@ -766,7 +766,7 @@ var image_dialog = {
, callback: null

, init: function(callback){

if (!this.initialised) {
this.callback = callback;
this.init_tabs();
Expand Down Expand Up @@ -887,7 +887,7 @@ var image_dialog = {
var list_reorder = {
initialised: false
, init: function() {

if (!this.initialised) {
$('#reorder_action').click(list_reorder.enable_reordering);
$('#reorder_action_done').click(list_reorder.disable_reordering);
Expand Down Expand Up @@ -981,12 +981,7 @@ var list_reorder = {
}

, restore_controls: function(e) {
if (list_reorder.tree && !$.browser.msie) {
list_reorder.sortable_list.add(list_reorder.sortable_list.find('ul, li, div')).draggable({ disabled: true });
} else {
$(list_reorder.sortable_list).sortable('destroy');
}
$(list_reorder.sortable_list).removeClass('reordering, ui-sortable');
$(list_reorder.sortable_list).removeClass('reordering');

$('#sortable_list .actions, .sortable_list .actions, #site_bar, header > *:not(script)').fadeTo(250, 1);
$('#actions *:not("#reorder_action_done, #reorder_action")').not($('#reorder_action_done').parents('li, ul, div')).fadeTo(250, 1, function() {
Expand All @@ -1012,7 +1007,7 @@ var image_picker = {
}

, init: function(new_options){

if (!this.initialised) {
this.options = $.extend(this.options, new_options);
$(this.options.picker_container).find(this.options.remove_image_button)
Expand Down Expand Up @@ -1069,7 +1064,7 @@ var resource_picker = {
, callback: null

, init: function(callback) {

if (!this.initialised) {
this.callback = callback;
this.initialised = true;
Expand Down
5 changes: 2 additions & 3 deletions core/app/assets/javascripts/refinery/boot_wym.js
Expand Up @@ -263,8 +263,7 @@ WYMeditor.editor.prototype.loadIframe = function(iframe) {
};

WYMeditor.init = function() {
wymeditor_inputs = $('.wymeditor');
wymeditor_inputs = wymeditor_inputs.filter(function(index) {
wymeditor_inputs = $('.wymeditor').filter(function(index) {
for (i=0; i < WYMeditor.INSTANCES.length; i++) {
if (WYMeditor.INSTANCES[i]._element.attr('id') == $(this).attr('id')) {
return false;
Expand All @@ -275,7 +274,7 @@ WYMeditor.init = function() {
});

wymeditor_inputs.each(function(input) {
if ((containing_field = $(this).parents('.field')).length > 0 && containing_field.get(0).style.height === '') {
if ((containing_field = $(this).parents('.field')).length > 0 && containing_field.get(0).style.height.replace('auto', '') === '') {
containing_field.addClass('hide-overflow')
.css('height', $(this).outerHeight() - containing_field.offset().top + $(this).offset().top + 45);
}
Expand Down
21 changes: 7 additions & 14 deletions core/lib/refinery/helpers/image_helper.rb
@@ -1,3 +1,5 @@
require 'ostruct'

module Refinery
module Helpers
module ImageHelper
Expand Down Expand Up @@ -25,25 +27,16 @@ def content_fu(content, thumbnail)
# <%= image_fu @model.image, '200x200' %> or with no thumbnail: <%= image_fu @model.image %>
def image_fu(image, geometry = nil, options={})
if image.present?
# call rails' image tag function with default alt tag.
# if any other options were supplied these are merged in and can replace the defaults.
# if the geomtry is nil, then we know the image height and width already.
# detect nil geometry or cropping presence which is where we can guess the dimensions
unless geometry.nil? or !(split_geometry = geometry.to_s.split('#')).many? or !(split_geometry = split_geometry.first.split('x')).many?
image_width, image_height = split_geometry
else
image_width = nil
image_height = nil
end
original_width = image.image_width
original_height = image.image_height

dimensions = (image.thumbnail_dimensions(geometry) rescue {})

image_tag(image.thumbnail(geometry).url, {
:alt => image.respond_to?(:title) ? image.title : image.image_name,
:width => image_width,
:height => image_height
}.merge(options))
}.merge(dimensions).merge(options))
end
end

end
end
end
89 changes: 50 additions & 39 deletions db/seeds/pages.rb
@@ -1,4 +1,6 @@
module Refinery
::Refinery::Page.reset_column_information

# Check whether all columns are applied yet by seo_meta.
unless !defined?(::SeoMeta) || ::SeoMeta.attributes.keys.all? { |k|
::Refinery::Page.translation_class.instance_methods.include?(k)
Expand All @@ -8,45 +10,54 @@ module Refinery
end

page_position = -1
home_page = ::Refinery::Page.create!({:title => "Home",
:deletable => false,
:link_url => "/",
:menu_match => "^/$",
:position => (page_position += 1)})
home_page.parts.create({
:title => "Body",
:body => "<p>Welcome to our site. This is just a place holder page while we gather our content.</p>",
:position => 0
})
home_page.parts.create({
:title => "Side Body",
:body => "<p>This is another block of content over here.</p>",
:position => 1
})

home_page_position = -1
page_not_found_page = home_page.children.create(:title => "Page not found",
:menu_match => "^/404$",
:show_in_menu => false,
:deletable => false,
:position => (home_page_position += 1))
page_not_found_page.parts.create({
:title => "Body",
:body => "<h2>Sorry, there was a problem...</h2><p>The page you requested was not found.</p><p><a href='/'>Return to the home page</a></p>",
:position => 0
})
unless ::Refinery::Page.where(:menu_match => "^/$").any?
home_page = ::Refinery::Page.create!({:title => "Home",
:deletable => false,
:link_url => "/",
:menu_match => "^/$",
:position => (page_position += 1)})
home_page.parts.create({
:title => "Body",
:body => "<p>Welcome to our site. This is just a place holder page while we gather our content.</p>",
:position => 0
})
home_page.parts.create({
:title => "Side Body",
:body => "<p>This is another block of content over here.</p>",
:position => 1
})

about_us_page = ::Refinery::Page.create(:title => "About",
:deletable => true,
:position => (page_position += 1))
about_us_page.parts.create({
:title => "Body",
:body => "<p>This is just a standard text page example. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin metus dolor, hendrerit sit amet, aliquet nec, posuere sed, purus. Nullam et velit iaculis odio sagittis placerat. Duis metus tellus, pellentesque ut, luctus id, egestas a, lorem. Praesent vitae mauris. Aliquam sed nulla. Sed id nunc vitae leo suscipit viverra. Proin at leo ut lacus consequat rhoncus. In hac habitasse platea dictumst. Nunc quis tortor sed libero hendrerit dapibus.\n\nInteger interdum purus id erat. Duis nec velit vitae dolor mattis euismod. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Suspendisse pellentesque dignissim lacus. Nulla semper euismod arcu. Suspendisse egestas, erat a consectetur dapibus, felis orci cursus eros, et sollicitudin purus urna et metus. Integer eget est sed nunc euismod vestibulum. Integer nulla dui, tristique in, euismod et, interdum imperdiet, enim. Mauris at lectus. Sed egestas tortor nec mi.</p>",
:position => 0
})
about_us_page.parts.create({
:title => "Side Body",
:body => "<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus fringilla nisi a elit. Duis ultricies orci ut arcu. Ut ac nibh. Duis blandit rhoncus magna. Pellentesque semper risus ut magna. Etiam pulvinar tellus eget diam. Morbi blandit. Donec pulvinar mauris at ligula. Sed pellentesque, ipsum id congue molestie, lectus risus egestas pede, ac viverra diam lacus ac urna. Aenean elit.</p>",
:position => 1
})
home_page_position = -1
page_not_found_page = home_page.children.create(:title => "Page not found",
:menu_match => "^/404$",
:show_in_menu => false,
:deletable => false,
:position => (home_page_position += 1))
page_not_found_page.parts.create({
:title => "Body",
:body => "<h2>Sorry, there was a problem...</h2><p>The page you requested was not found.</p><p><a href='/'>Return to the home page</a></p>",
:position => 0
})
else
page_position += 1
end

unless ::Refinery::Page.by_title("About").any?
about_us_page = ::Refinery::Page.create(:title => "About",
:deletable => true,
:position => (page_position += 1))
about_us_page.parts.create({
:title => "Body",
:body => "<p>This is just a standard text page example. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin metus dolor, hendrerit sit amet, aliquet nec, posuere sed, purus. Nullam et velit iaculis odio sagittis placerat. Duis metus tellus, pellentesque ut, luctus id, egestas a, lorem. Praesent vitae mauris. Aliquam sed nulla. Sed id nunc vitae leo suscipit viverra. Proin at leo ut lacus consequat rhoncus. In hac habitasse platea dictumst. Nunc quis tortor sed libero hendrerit dapibus.\n\nInteger interdum purus id erat. Duis nec velit vitae dolor mattis euismod. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Suspendisse pellentesque dignissim lacus. Nulla semper euismod arcu. Suspendisse egestas, erat a consectetur dapibus, felis orci cursus eros, et sollicitudin purus urna et metus. Integer eget est sed nunc euismod vestibulum. Integer nulla dui, tristique in, euismod et, interdum imperdiet, enim. Mauris at lectus. Sed egestas tortor nec mi.</p>",
:position => 0
})
about_us_page.parts.create({
:title => "Side Body",
:body => "<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus fringilla nisi a elit. Duis ultricies orci ut arcu. Ut ac nibh. Duis blandit rhoncus magna. Pellentesque semper risus ut magna. Etiam pulvinar tellus eget diam. Morbi blandit. Donec pulvinar mauris at ligula. Sed pellentesque, ipsum id congue molestie, lectus risus egestas pede, ac viverra diam lacus ac urna. Aenean elit.</p>",
:position => 1
})
else
page_position += 1
end
end
Expand Up @@ -16,7 +16,7 @@ In Refinery's backend, go to the "Settings" tab. Look for a setting called "Defa
NOTE: If you don't have this setting, try creating a new page and then restarting your web server.

<yaml>
---
---
- Body
- Side Body
</yaml>
Expand All @@ -26,7 +26,7 @@ Edit this YAML to have the names of the default page parts you want, click +Save
Here's a sample of a site that would have three content areas on most of its pages.

<yaml>
---
---
- Left Body
- Middle Body
- Right Body
Expand Down
Expand Up @@ -48,6 +48,8 @@ ENV['S3_SECRET']='fill_in_your_secret_key_here'
ENV['S3_BUCKET']='fill_in_your_bucket_name_here'
</ruby>

(Note: For Heroku, you should use config-vars to set your environment variables using Heroku's command line utility. Documentation for this can be found here: http://devcenter.heroku.com/articles/config-vars)

h3. Turning S3 on and off

S3 should automatically sense that it is enabled based on these ENV variables
Expand Down

This file was deleted.

35 changes: 35 additions & 0 deletions images/app/models/refinery/image.rb
Expand Up @@ -65,6 +65,41 @@ def thumbnail(geometry = nil)
end
end

# Intelligently works out dimensions for a thumbnail of this image based on the Dragonfly geometry string.
def thumbnail_dimensions(geometry)
geometry = geometry.to_s
width = self.image_width.to_f
height = self.image_height.to_f
geometry_width, geometry_height = geometry.to_s.split(%r{\#{1,2}|\+|>|!|x}im)[0..1].map(&:to_f)
if (width * height > 0) && geometry =~ ::Dragonfly::ImageMagick::Processor::THUMB_GEOMETRY
if geometry =~ ::Dragonfly::ImageMagick::Processor::RESIZE_GEOMETRY
if geometry !~ %r{\d+x\d+>} || (geometry =~ %r{\d+x\d+>} && (width > geometry_width.to_f || height > geometry_height.to_f))
if geometry_width > geometry_height
width = if (aspect = (width / height)) >= 1
geometry_height * aspect
else
geometry_height / aspect
end
height = geometry_height
else
height = if (aspect = (height / width)) >= 1
geometry_width * aspect
else
geometry_width / aspect
end
width = geometry_width
end
end
else
# cropping
width = geometry_width
height = geometry_height
end
end

{:width => width.to_i, :height => height.to_i}
end

# Returns a titleized version of the filename
# my_file.jpg returns My File
def title
Expand Down

0 comments on commit f41a74d

Please sign in to comment.