refinerycms-core 0.9.9.5 → 0.9.9.7

Sign up to get free protection for your applications and to get access to all the features.
data/lib/refinery/crud.rb CHANGED
@@ -18,15 +18,17 @@ module Refinery
18
18
  this_class = class_name.constantize.base_class
19
19
 
20
20
  {
21
- :title_attribute => "title",
22
- :order => ('position ASC' if this_class.table_exists? and this_class.column_names.include?('position')),
23
21
  :conditions => '',
24
- :sortable => true,
25
- :searchable => true,
26
22
  :include => [],
23
+ :order => ('position ASC' if this_class.table_exists? and this_class.column_names.include?('position')),
27
24
  :paging => true,
25
+ :per_page => false,
26
+ :redirect_to_url => "admin_#{plural_name}_url",
27
+ :searchable => true,
28
28
  :search_conditions => '',
29
- :redirect_to_url => "admin_#{plural_name}_url"
29
+ :sortable => true,
30
+ :title_attribute => "title",
31
+ :xhr_paging => false
30
32
  }
31
33
  end
32
34
 
@@ -161,8 +163,11 @@ module Refinery
161
163
 
162
164
  paging_options = {:page => params[:page]}
163
165
 
166
+ # Use per_page from crudify options.
167
+ if #{options[:per_page].present?.inspect}
168
+ paging_options.update({:per_page => #{options[:per_page].inspect}})
164
169
  # Seems will_paginate doesn't always use the implicit method.
165
- if #{class_name}.methods.map(&:to_sym).include?(:per_page)
170
+ elsif #{class_name}.methods.map(&:to_sym).include?(:per_page)
166
171
  paging_options.update({:per_page => #{class_name}.per_page})
167
172
  end
168
173
 
@@ -193,6 +198,8 @@ module Refinery
193
198
  def index
194
199
  search_all_#{plural_name} if searching?
195
200
  paginate_all_#{plural_name}
201
+
202
+ render :partial => '#{plural_name}' if #{options[:xhr_paging].inspect} && request.xhr?
196
203
  end
197
204
  )
198
205
  else
@@ -212,6 +219,8 @@ module Refinery
212
219
  module_eval %(
213
220
  def index
214
221
  paginate_all_#{plural_name}
222
+
223
+ render :partial => '#{plural_name}' if #{options[:xhr_paging].inspect} && request.xhr?
215
224
  end
216
225
  )
217
226
  else
@@ -2,17 +2,18 @@ module Refinery
2
2
  module Helpers
3
3
  module TagHelper
4
4
 
5
- # Returns <span class='help' title='Your Input'>(help)</span>
5
+ # Returns <img class='help' tooltip='Your Input' src='refinery/icons/information.png' />
6
6
  # Remember to wrap your block with <span class='label_with_help'></span> if you're using a label next to the help tag.
7
7
  def refinery_help_tag(title='')
8
8
  title = h(title) unless title.html_safe?
9
9
 
10
- "<span class=\"help\" title=\"#{title}\">(#{t('help', :scope => 'shared.admin')})</span>".html_safe
10
+ refinery_icon_tag('information', :class => 'help', :tooltip => title)
11
11
  end
12
12
 
13
13
  # This is just a quick wrapper to render an image tag that lives inside refinery/icons.
14
14
  # They are all 16x16 so this is the default but is able to be overriden with supplied options.
15
15
  def refinery_icon_tag(filename, options = {})
16
+ filename = "#{filename}.png" unless filename.split('.').many?
16
17
  image_tag "refinery/icons/#{filename}", {:width => 16, :height => 16}.merge(options)
17
18
  end
18
19
 
@@ -162,50 +162,10 @@ namespace :refinery do
162
162
 
163
163
  desc "Update the core files with the gem"
164
164
  task :update => :environment do
165
- verbose = ENV["verbose"] || false
166
- require 'fileutils'
167
-
168
- # Clean up mistakes
169
- if (bad_migration = Rails.root.join('db', 'migrate', '20100913234704_add_cached_slug_to_pages.rb')).file?
170
- FileUtils::rm bad_migration
171
- end
172
-
173
- unless (devise_config = Rails.root.join('config', 'initializers', 'devise.rb')).file?
174
- devise_config.parent.mkpath
175
- FileUtils::cp Refinery.roots('core').join(*%w(lib generators templates config initializers devise.rb)),
176
- devise_config,
177
- :verbose => verbose
178
- end
179
-
180
- (contents = Rails.root.join('Gemfile').read).gsub!("group :test do", "group :development, :test do")
181
- Rails.root.join('Gemfile').open("w") do |f|
182
- f.puts contents
183
- end
184
-
185
- # copy in any new migrations, except for ones that create schemas (this is an update!)
186
- # or ones that exist already.
187
- Rails.root.join("db", "migrate").mkpath
188
- migrations = Pathname.glob(Refinery.roots.map{|r| r.join("db", "migrate", "*.rb")}).reject{|m|
189
- m.to_s =~ %r{\d+_create_refinerycms_.+?_schema\.rb} or
190
- Dir[Rails.root.join('db', 'migrate', "*#{m.basename.to_s.split(/\d+_/).last}")].any?
191
- }
192
- FileUtils::cp migrations,
193
- Rails.root.join('db', 'migrate').cleanpath.to_s,
194
- :verbose => verbose
195
-
196
- Rails.root.join("db", "seeds").mkpath
197
- Pathname.glob(Refinery.roots.map{|r| r.join('db', 'seeds', '*.rb')}).each do |seed|
198
- unless (destination = Rails.root.join('db', 'seeds', seed.basename)).exist?
199
- FileUtils::cp seed, destination.to_s, :verbose => verbose
200
- end
201
- end
202
-
203
- puts "\n" if verbose
204
-
205
- unless (ENV["from_installer"] || 'false').to_s == 'true'
206
- puts "\n=== ACTION REQUIRED ==="
207
- puts "Please run rake db:migrate to ensure your database is at the correct version.\n"
208
- end
165
+ puts "\nThe rake refinery:update task is DEPRECATED."
166
+ puts "Please use the generator instead:"
167
+ puts "rails generate refinerycms --update"
168
+ puts "\n"
209
169
  end
210
170
 
211
171
  namespace :cache do
@@ -13,14 +13,31 @@ if(typeof(window.onpopstate) == "object"){
13
13
  $(window).bind('popstate', function(e) {
14
14
  // this fires on initial page load too which we don't need.
15
15
  if(!initialLoad) {
16
- $.get(location.href, function(data) {
17
- $('.pagination_container').slideTo(data);
18
- });
16
+ $(document).paginateTo((location.pathname + location.href.split(location.pathname)[1]));
19
17
  }
20
18
  initialLoad = false;
21
19
  });
22
20
  }
23
21
 
22
+ $.fn.paginateTo = function(stateUrl) {
23
+ // Grab the url, ensuring not to cache.
24
+ $.ajax({
25
+ url: stateUrl,
26
+ cache: false,
27
+ success: function(data) {
28
+ $('.pagination_container').slideTo(data);
29
+
30
+ // remove caching _ argument.
31
+ $('.pagination_container .pagination a').each(function(i, a){
32
+ $(this).attr('href', $(this).attr('href').replace(/\?\_\=[^&]+&/, '?'));
33
+ })
34
+ },
35
+ failure: function(data) {
36
+ window.location = popstate_location;
37
+ }
38
+ });
39
+ }
40
+
24
41
  $.fn.slideTo = function(response) {
25
42
  $(this).html(response);
26
43
  $(this).applyMinimumHeightFromChildren();
@@ -46,12 +63,17 @@ init_ajaxy_pagination = function(){
46
63
  if(typeof(window.history.pushState) == 'function' && $('.pagination_container').length > 0){
47
64
  var pagination_pages = $('.pagination_container .pagination a');
48
65
  pagination_pages.live('click',function(e) {
49
- this.href = (this.href.replace(/(\&(amp\;)?)?from_page\=\d+/, '')
50
- + '&from_page=' + $(this).parent().find('em').text()).replace('?&', '?');
51
- history.pushState({ path: this.path }, '', this.href);
52
- $.get(this.href, function(data) {
53
- $('.pagination_container').slideTo(data)
54
- })
66
+ navigate_to = this.href.replace(/(\&(amp\;)?)?from_page\=\d+/, '');
67
+ navigate_to += '&from_page=' + $(this).parent().find('em').text();
68
+ navigate_to = navigate_to.replace('?&', '?');
69
+
70
+ var current_state_location = (location.pathname + location.href.split(location.pathname)[1]);
71
+ window.history.pushState({
72
+ path: current_state_location
73
+ }, '', navigate_to);
74
+
75
+ $(document).paginateTo(navigate_to);
76
+
55
77
  e.preventDefault();
56
78
  });
57
79
  }
@@ -1369,9 +1369,15 @@ input.button.close_dialog:active, a.button.close_dialog:active, #content a.butto
1369
1369
  .hemisquare small {
1370
1370
  font-size: 0.9em;
1371
1371
  }
1372
- .label_with_help label, .label_with_help span.help {
1372
+ .label_with_help {
1373
+ vertical-align: middle;
1374
+ }
1375
+ .label_with_help label, .label_with_help span.help, .label_with_help img.help {
1373
1376
  display: inline;
1374
1377
  }
1378
+ .label_with_help img.help {
1379
+ vertical-align: middle;
1380
+ }
1375
1381
  .label_with_help span.help {
1376
1382
  font-weight: normal;
1377
1383
  margin-left: 3px;
@@ -2,10 +2,10 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{refinerycms-core}
5
- s.version = %q{0.9.9.5}
5
+ s.version = %q{0.9.9.7}
6
6
  s.summary = %q{Core engine for Refinery CMS}
7
7
  s.description = %q{The core of Refinery CMS. This handles the common functionality and is required by most engines}
8
- s.date = %q{2011-03-08}
8
+ s.date = %q{2011-03-10}
9
9
  s.email = %q{info@refinerycms.com}
10
10
  s.homepage = %q{http://refinerycms.com}
11
11
  s.rubyforge_project = %q{refinerycms}
@@ -14,8 +14,8 @@ Gem::Specification.new do |s|
14
14
  s.require_paths = %w(lib)
15
15
  s.executables = %w()
16
16
 
17
- s.add_dependency 'refinerycms-base', '~> 0.9.9.5'
18
- s.add_dependency 'refinerycms-settings', '~> 0.9.9.5'
17
+ s.add_dependency 'refinerycms-base', '~> 0.9.9.7'
18
+ s.add_dependency 'refinerycms-settings', '~> 0.9.9.7'
19
19
  s.add_dependency 'refinerycms-generators', '~> 0.9.9.3'
20
20
  s.add_dependency 'acts_as_indexed', '~> 0.7'
21
21
  s.add_dependency 'friendly_id_globalize3', '~> 3.2.1'
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: refinerycms-core
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.9.9.5
5
+ version: 0.9.9.7
6
6
  platform: ruby
7
7
  authors:
8
8
  - Resolve Digital
@@ -13,7 +13,7 @@ autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
15
 
16
- date: 2011-03-08 00:00:00 +13:00
16
+ date: 2011-03-10 00:00:00 +13:00
17
17
  default_executable:
18
18
  dependencies:
19
19
  - !ruby/object:Gem::Dependency
@@ -24,7 +24,7 @@ dependencies:
24
24
  requirements:
25
25
  - - ~>
26
26
  - !ruby/object:Gem::Version
27
- version: 0.9.9.5
27
+ version: 0.9.9.7
28
28
  type: :runtime
29
29
  version_requirements: *id001
30
30
  - !ruby/object:Gem::Dependency
@@ -35,7 +35,7 @@ dependencies:
35
35
  requirements:
36
36
  - - ~>
37
37
  - !ruby/object:Gem::Version
38
- version: 0.9.9.5
38
+ version: 0.9.9.7
39
39
  type: :runtime
40
40
  version_requirements: *id002
41
41
  - !ruby/object:Gem::Dependency
@@ -473,7 +473,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
473
473
  requirements: []
474
474
 
475
475
  rubyforge_project: refinerycms
476
- rubygems_version: 1.6.0
476
+ rubygems_version: 1.6.1
477
477
  signing_key:
478
478
  specification_version: 3
479
479
  summary: Core engine for Refinery CMS