Skip to content

Commit

Permalink
Merge branch 'master' into performance
Browse files Browse the repository at this point in the history
  • Loading branch information
parndt committed May 19, 2011
2 parents 169748a + a9b00c5 commit 22d70db
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 89 deletions.
4 changes: 2 additions & 2 deletions authentication/app/controllers/passwords_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def give_notice

# GET /registrations/password/edit?reset_password_token=abcdef
def edit
if params[:reset_password_token] and (@user = User.find_by_reset_password_token(params[:reset_password_token])).present?
if params[:reset_password_token] and (@user = User.where(:reset_password_token => params[:reset_password_token]).first).present?
render_with_scope :edit
else
redirect_to(new_user_password_url, :flash => ({
Expand All @@ -24,7 +24,7 @@ def edit
# POST /registrations/password
def create
if params[:user].present? and (email = params[:user][:email]).present? and
(user = User.find_by_email(email)).present?
(user = User.where(:email => email).first).present?

# Call devise reset function.
user.send(:generate_reset_password_token!)
Expand Down
6 changes: 3 additions & 3 deletions core/lib/refinery/crud.rb
Original file line number Diff line number Diff line change
Expand Up @@ -253,11 +253,11 @@ def update_positions
0.upto((newlist ||= params[:ul]).length - 1) do |index|
hash = newlist[index.to_s]
moved_item_id = hash['id'].split(/#{singular_name}\\_?/)
@current_#{singular_name} = #{class_name}.find_by_id(moved_item_id)
@current_#{singular_name} = #{class_name}.where(:id => moved_item_id).first
if @current_#{singular_name}.respond_to?(:move_to_root)
if previous.present?
@current_#{singular_name}.move_to_right_of(#{class_name}.find_by_id(previous))
@current_#{singular_name}.move_to_right_of(#{class_name}.where(:id => previous).first)
else
@current_#{singular_name}.move_to_root
end
Expand All @@ -280,7 +280,7 @@ def update_child_positions(node, #{singular_name})
0.upto(node['children'].length - 1) do |child_index|
child = node['children'][child_index.to_s]
child_id = child['id'].split(/#{singular_name}\_?/)
child_#{singular_name} = #{class_name}.find_by_id(child_id)
child_#{singular_name} = #{class_name}.where(:id => child_id).first
child_#{singular_name}.move_to_child_of(#{singular_name})
if child['children'].present?
Expand Down
183 changes: 102 additions & 81 deletions core/public/javascripts/refinery/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -412,9 +412,12 @@ init_tooltips = function(args){
var link_tester = {
initialised: false
, init: function(test_url, test_email) {
this.test_url = test_url;
this.test_email = test_email;
this.initialised = true;

if (!this.initialised) {
this.test_url = test_url;
this.test_email = test_email;
this.initialised = true;
}
},

email: function(value, callback) {
Expand Down Expand Up @@ -479,13 +482,16 @@ var link_tester = {
var link_dialog = {
initialised: false
, init: function(){
this.init_tabs();
this.init_resources_submit();
this.init_close();
this.page_tab();
this.web_tab();
this.email_tab();
this.initialised = true;

if (!this.initialised) {
this.init_tabs();
this.init_resources_submit();
this.init_close();
this.page_tab();
this.web_tab();
this.email_tab();
this.initialised = true;
}
},

init_tabs: function(){
Expand Down Expand Up @@ -630,30 +636,33 @@ var link_dialog = {
var page_options = {
initialised: false
, init: function(enable_parts, new_part_url, del_part_url){
// 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');
page_options.tabs.tabs({tabTemplate: '<li><a href="#{href}">#{label}</a></li>'});
page_options.tabs.find(' > ul li a').corner('top 5px');

part_shown = $('#page-tabs .page_part.field').not('.ui-tabs-hide');
$('#page-tabs .page_part.field').removeClass('ui-tabs-hide');

this.enable_parts = enable_parts;
this.new_part_url = new_part_url;
this.del_part_url = del_part_url;
this.show_options();
this.title_type();

$(document).ready($.proxy(function(){
// hide the tabs that are supposed to be hidden.
$('#page-tabs .page_part.field').not(this).addClass('ui-tabs-hide');
$('#page-tabs > ul li a').corner('top 5px');
}, part_shown));

if(this.enable_parts){
this.page_part_dialog();

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');
page_options.tabs.tabs({tabTemplate: '<li><a href="#{href}">#{label}</a></li>'});
page_options.tabs.find(' > ul li a').corner('top 5px');

part_shown = $('#page-tabs .page_part.field').not('.ui-tabs-hide');
$('#page-tabs .page_part.field').removeClass('ui-tabs-hide');

this.enable_parts = enable_parts;
this.new_part_url = new_part_url;
this.del_part_url = del_part_url;
this.show_options();
this.title_type();

$(document).ready($.proxy(function(){
// hide the tabs that are supposed to be hidden.
$('#page-tabs .page_part.field').not(this).addClass('ui-tabs-hide');
$('#page-tabs > ul li a').corner('top 5px');
}, part_shown));

if(this.enable_parts){
this.page_part_dialog();
}
this.initialised = true;
}
this.initialised = true;
},

show_options: function(){
Expand Down Expand Up @@ -766,11 +775,14 @@ var image_dialog = {
, callback: null

, init: function(callback){
this.callback = callback;
this.init_tabs();
this.init_select();
this.init_actions();
this.initialised = true;

if (!this.initialised) {
this.callback = callback;
this.init_tabs();
this.init_select();
this.init_actions();
this.initialised = true;
}
return this;
}

Expand Down Expand Up @@ -884,43 +896,46 @@ var image_dialog = {
var list_reorder = {
initialised: false
, init: function() {
$('#reorder_action').click(list_reorder.enable_reordering);
$('#reorder_action_done').click(list_reorder.disable_reordering);
if(list_reorder.tree === false) {
list_reorder.sortable_list.find('li').addClass('no-nest');
}
list_reorder.sortable_list.nestedSortable({
disableNesting: 'no-nest',
forcePlaceholderSize: true,
handle: list_reorder.tree ? 'div' : null,
items: 'li',
opacity: .6,
placeholder: 'placeholder',
tabSize: 25,
tolerance: 'pointer',
toleranceElement: list_reorder.tree ? '> div' : null,
disabled: true,
start: function () {
},
change: function () {
if (list_reorder.tree) {
list_reorder.reset_branch_classes(this);
}
},
stop: function () {
if (list_reorder.tree) {
list_reorder.reset_branch_classes(this);
} else {
list_reorder.reset_on_off_classes(this);

if (!this.initialised) {
$('#reorder_action').click(list_reorder.enable_reordering);
$('#reorder_action_done').click(list_reorder.disable_reordering);
if(list_reorder.tree === false) {
list_reorder.sortable_list.find('li').addClass('no-nest');
}
list_reorder.sortable_list.nestedSortable({
disableNesting: 'no-nest',
forcePlaceholderSize: true,
handle: list_reorder.tree ? 'div' : null,
items: 'li',
opacity: .6,
placeholder: 'placeholder',
tabSize: 25,
tolerance: 'pointer',
toleranceElement: list_reorder.tree ? '> div' : null,
disabled: true,
start: function () {
},
change: function () {
if (list_reorder.tree) {
list_reorder.reset_branch_classes(this);
}
},
stop: function () {
if (list_reorder.tree) {
list_reorder.reset_branch_classes(this);
} else {
list_reorder.reset_on_off_classes(this);
}
}
});
if (list_reorder.tree) {
list_reorder.reset_branch_classes(list_reorder.sortable_list);
} else {
list_reorder.reset_on_off_classes(list_reorder.sortable_list);
}
});
if (list_reorder.tree) {
list_reorder.reset_branch_classes(list_reorder.sortable_list);
} else {
list_reorder.reset_on_off_classes(list_reorder.sortable_list);
this.initialised = true;
}
this.initialised = true;
}
, reset_on_off_classes: function(ul) {
$("> li", ul).each(function(i, li) {
Expand Down Expand Up @@ -1005,13 +1020,16 @@ var image_picker = {
}

, init: function(new_options){
this.options = $.extend(this.options, new_options);
$(this.options.picker_container).find(this.options.remove_image_button)
.click($.proxy(this.remove_image, {container: this.options.picker_container, picker: this}));
$(this.options.picker_container).find(this.options.image_toggler)
.click($.proxy(this.toggle_image, {container: this.options.picker_container, picker: this}));

this.initialised = true;

if (!this.initialised) {
this.options = $.extend(this.options, new_options);
$(this.options.picker_container).find(this.options.remove_image_button)
.click($.proxy(this.remove_image, {container: this.options.picker_container, picker: this}));
$(this.options.picker_container).find(this.options.image_toggler)
.click($.proxy(this.toggle_image, {container: this.options.picker_container, picker: this}));

this.initialised = true;
}

return this;
}
Expand Down Expand Up @@ -1060,8 +1078,11 @@ var resource_picker = {
, callback: null

, init: function(callback) {
this.callback = callback;
this.initialised = true;

if (!this.initialised) {
this.callback = callback;
this.initialised = true;
}
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ endprologue.

h3. Overriding your first view

If you want to override one of the views Refinery comes built with (_for example, to add a phone number to the footer_), you'll need to override the view Refinery is providing. Refinery will then use your local version, rather than it's original copy.
If you want to override one of the views Refinery comes built with (_for example, to add a phone number to the footer_), you'll need to override the view Refinery is providing. Refinery will then use your local version, rather than its original copy.

It's easy to get a copy of this file to modify locally. For example, for the footer, just run in the terminal:

Expand Down
2 changes: 1 addition & 1 deletion pages/lib/refinery/pages/admin/instance_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Admin
module InstanceMethods

def error_404(exception=nil)
if (@page = Page.find_by_menu_match("^/404$", :include => [:parts, :slugs])).present?
if (@page = Page.where(:menu_match => "^/404$").includes(:parts, :slugs).first).present?
params[:action] = 'error_404'
# change any links in the copy to the admin_root_path
# and any references to "home page" to "Dashboard"
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ Wanna see Refinery for yourself? [Try the demo](http://demo.refinerycms.com/refi

* Manage who can access Refinery.
* Control which engines each user has access to.
* Uses the popular [authlogic](http://github.com/binarylogic/authlogic).
* Uses the popular [devise](http://github.com/plataformatec/devise).

### ...Want more? [Extend with Engines](http://github.com/resolve/refinerycms/blob/master/doc/engines.md#readme)

Expand Down

0 comments on commit 22d70db

Please sign in to comment.