refinerycms 0.9.8.2 → 0.9.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore CHANGED
@@ -1,6 +1,7 @@
1
1
  # Rails
2
2
  .bundle
3
3
  db/*.sqlite3
4
+ db/*.sqlite3-journal
4
5
  *.log
5
6
  tmp/**/*
6
7
 
data/Gemfile CHANGED
@@ -44,8 +44,15 @@ gem 'refinerycms-inquiries', '~> 0.9.8.7'
44
44
  # Add i18n support (optional, you can remove this if you really want to).
45
45
  gem 'refinerycms-i18n', '~> 0.9.8.6', :require => 'refinery/i18n'
46
46
 
47
+ # Figure out how to get RMagick:
48
+ rmagick_options = {:require => false}
49
+ rmagick_options.update({
50
+ :git => 'git://github.com/refinerycms/rmagick.git',
51
+ :branch => 'windows'
52
+ }) if Bundler::WINDOWS
53
+
47
54
  # Specify a version of RMagick that works in your environment:
48
- gem 'rmagick', '~> 2.12.0', :require => false
55
+ gem 'rmagick', '~> 2.12.0', rmagick_options
49
56
 
50
57
  # END REFINERY CMS ============================================================
51
58
 
data/bin/refinerycms CHANGED
@@ -119,7 +119,7 @@ module Refinery
119
119
 
120
120
  def generate!
121
121
  # Generate a rails application
122
- rails_command = "rails new '#{@app_path}'"
122
+ rails_command = "rails new \"#{@app_path}\""
123
123
  rails_command << " --database #{@options[:database]}"
124
124
  rails_command << " --force" if @options[:force]
125
125
  rails_command << " --skip-test-unit --skip-prototype"
@@ -195,7 +195,7 @@ module Refinery
195
195
  run_command("bundle install")
196
196
 
197
197
  puts "\n\nSetting up your development database..\n"
198
- run_command("rake -f '#{@app_path.join('Rakefile')}' db:setup")
198
+ run_command("rake -f \"#{@app_path.join('Rakefile')}\" db:setup", {:cd => false})
199
199
 
200
200
  # Deploy to Heroku
201
201
  if @options[:heroku]
@@ -238,9 +238,13 @@ module Refinery
238
238
  def run_command(command, options = {})
239
239
  options = {:cd => true, :puts => true}.merge(options)
240
240
  to_run = %w()
241
- to_run << "cmd /c" if RbConfig::CONFIG["host_os"] =~ %r!(msdos|mswin|djgpp|mingw)!
242
- to_run << "cd #{@app_path} &&" if options[:cd]
241
+ to_run << "cd \"#{@app_path}\" &&" if options[:cd]
243
242
  to_run << command
243
+
244
+ if RbConfig::CONFIG["host_os"] =~ %r!(msdos|mswin|djgpp|mingw)!
245
+ to_run = %w(cmd /c) | to_run.map{|c| c.gsub(/\//m, '\\')}
246
+ end
247
+
244
248
  to_run = to_run.join(' ')
245
249
 
246
250
  if options[:puts]
@@ -21,4 +21,4 @@ module NavigationHelpers
21
21
  end
22
22
  end
23
23
  end
24
- end
24
+ end
@@ -1,22 +1,23 @@
1
1
  <%
2
2
  css = if ((defined?(apply_css) && apply_css) || !defined?(apply_css)) and
3
3
  (classes = css_for_menu_branch(menu_branch, menu_branch_counter, sibling_count||=nil)).any?
4
- " class='#{classes.join(' ')}'"
4
+ "class='#{classes.join(' ')}'"
5
5
  end
6
- dom_id = (" id='item_#{menu_branch_counter}'" if menu_branch.parent_id.nil? and menu_branch.title.present?)
7
- @menu_pages.reject! { |branch| branch == menu_branch } # Remove page from the array, so that future searching will be faster.
8
- children = @menu_pages.select { |p| p.parent_id == menu_branch.id && p.in_menu? }
6
+ dom_id = ("id='item_#{menu_branch_counter}'" if menu_branch.parent_id.nil? and menu_branch.title.present?)
7
+
8
+ hide_children = (defined?(hide_children) && hide_children)
9
+ children = hide_children ? [] : @menu_pages.select { |p| p.parent_id == menu_branch.id && p.in_menu? }
9
10
  -%>
10
- <li<%= css -%><%= dom_id -%>>
11
+ <li<%= ['', css, dom_id].join(' ').gsub(/\ *$/, '') %>>
11
12
  <%= link_to menu_branch.title, menu_branch.url %>
12
13
 
13
- <% unless hide_children or children.empty? %>
14
+ <% if children.present? %>
14
15
  <ul class='clearfix'>
15
16
  <%=
16
17
  render :partial => "/shared/menu_branch",
17
18
  :collection => children,
18
19
  :locals => {
19
- :hide_children => false, # hide children can't be true or we wouldn't get here.
20
+ :hide_children => hide_children,
20
21
  :sibling_count => children.size - 1
21
22
  } -%>
22
23
  </ul>
@@ -49,6 +49,9 @@ de:
49
49
  download_current: Aktuelles %{what} herunterladen
50
50
  opens_in_new_window: Öffnet in einem neuen Fenster
51
51
  remove_current: "Entferne aktuelles %{what}"
52
+ no_resource_selected: Es ist momentan keine Datei ausgewählt, klicken Sie hier, um eine hinzuzufügen.
53
+ name: Datei hinzufügen
54
+ current: Aktuelle Datei
52
55
  search:
53
56
  button_text: Suchen
54
57
  results_for: Suchergebnisse für '%{query}'
@@ -80,7 +80,7 @@ So when viewing a list of the images you have you don't want it to show all the
80
80
 
81
81
  You do that like this:
82
82
 
83
- :conditions => "parent_id IS NULL"
83
+ :conditions => {:parent_id => nil}
84
84
 
85
85
  ### ``:sortable``
86
86
 
@@ -86,7 +86,7 @@ This bit is important. It's where all the controllers are held to manage pages i
86
86
 
87
87
  class Admin::PagesController < Admin::BaseController
88
88
 
89
- crudify :page, :conditions => "parent_id IS NULL",
89
+ crudify :page, :conditions => {:parent_id => nil},
90
90
  :order => "position ASC", :paging => false
91
91
 
92
92
  end
@@ -11,4 +11,4 @@ module NavigationHelpers
11
11
  end
12
12
  end
13
13
  end
14
- end
14
+ end
@@ -26,7 +26,7 @@ module Refinery
26
26
  end
27
27
 
28
28
  initializer 'add presenters' do |app|
29
- app.config.load_paths += [
29
+ app.config.autoload_paths += [
30
30
  Rails.root.join("app", "presenters"),
31
31
  Rails.root.join("vendor", "**", "**", "app", "presenters"),
32
32
  Refinery.root.join("vendor", "refinerycms", "*", "app", "presenters")
@@ -7,7 +7,7 @@ page = Page.create(
7
7
  :title => "<%= class_name.pluralize.underscore.titleize %>",
8
8
  :link_url => "/<%= plural_name %>",
9
9
  :deletable => false,
10
- :position => ((Page.maximum(:position, :conditions => "parent_id IS NULL") || -1)+1),
10
+ :position => ((Page.maximum(:position, :conditions => {:parent_id => nil}) || -1)+1),
11
11
  :menu_match => "^/<%= plural_name %>(\/|\/.+?|)$"
12
12
  )
13
13
  RefinerySetting.find_or_set(:default_page_parts, ["Body", "Side Body"]).each do |default_page_part|
@@ -47,18 +47,16 @@ module Refinery
47
47
  # if the position field exists, set this object as last object, given the conditions of this class.
48
48
  if #{class_name}.column_names.include?("position")
49
49
  params[:#{singular_name}].merge!({
50
- :position => ((#{class_name}.maximum(:position, :conditions => "#{options[:conditions]}")||-1) + 1)
50
+ :position => ((#{class_name}.maximum(:position, :conditions => #{options[:conditions].inspect})||-1) + 1)
51
51
  })
52
52
  end
53
53
 
54
54
  if (@#{singular_name} = #{class_name}.create(params[:#{singular_name}])).valid?
55
- unless request.xhr?
56
- flash[:notice] = t('refinery.crudify.created',
57
- :what => "'\#{@#{singular_name}.#{options[:title_attribute]}}'")
58
- else
59
- flash.now[:notice] = t('refinery.crudify.created',
60
- :what => "'\#{@#{singular_name}.#{options[:title_attribute]}}'")
61
- end
55
+ (request.xhr? ? flash.now : flash).notice = t(
56
+ 'refinery.crudify.created',
57
+ :what => "'\#{@#{singular_name}.#{options[:title_attribute]}}'"
58
+ )
59
+
62
60
  unless from_dialog?
63
61
  unless params[:continue_editing] =~ /true|on|1/
64
62
  redirect_back_or_default(#{options[:redirect_to_url]})
@@ -91,13 +89,11 @@ module Refinery
91
89
 
92
90
  def update
93
91
  if @#{singular_name}.update_attributes(params[:#{singular_name}])
94
- unless request.xhr?
95
- flash[:notice] = t('refinery.crudify.updated',
96
- :what => "'\#{@#{singular_name}.#{options[:title_attribute]}}'")
97
- else
98
- flash.now[:notice] = t('refinery.crudify.updated',
99
- :what => "'\#{@#{singular_name}.#{options[:title_attribute]}}'")
100
- end
92
+ (request.xhr? ? flash.now : flash).notice = t(
93
+ 'refinery.crudify.updated',
94
+ :what => "'\#{@#{singular_name}.#{options[:title_attribute]}}'"
95
+ )
96
+
101
97
  unless from_dialog?
102
98
  unless params[:continue_editing] =~ /true|on|1/
103
99
  redirect_back_or_default(#{options[:redirect_to_url]})
@@ -125,80 +121,70 @@ module Refinery
125
121
  end
126
122
 
127
123
  def destroy
124
+ # object gets found by find_#{singular_name} function
128
125
  if @#{singular_name}.destroy
129
- flash[:notice] = t('refinery.crudify.destroyed',
130
- :what => "'\#{@#{singular_name}.#{options[:title_attribute]}}'")
126
+ flash.notice = t('refinery.crudify.destroyed',
127
+ :what => "'\#{@#{singular_name}.#{options[:title_attribute]}}'")
131
128
  end
132
129
  redirect_to #{options[:redirect_to_url]}
133
130
  end
134
131
 
132
+ # Finds one single result based on the id params.
135
133
  def find_#{singular_name}
136
134
  @#{singular_name} = #{class_name}.find(params[:id],
137
- :include => %w(#{options[:include].join(' ')}))
135
+ :include => #{options[:include].map(&:to_sym).inspect})
138
136
  end
139
137
 
140
- def find_all_#{plural_name}
141
- @#{plural_name} = #{class_name}.find(
142
- :all,
143
- :order => "#{options[:order]}",
144
- :conditions => "#{options[:conditions]}",
145
- :include => %w(#{options[:include].join(' ')})
146
- )
138
+ # Find the collection of @#{plural_name} based on the conditions specified into crudify
139
+ # It will be ordered based on the conditions specified into crudify
140
+ # And eager loading is applied as specified into crudify.
141
+ def find_all_#{plural_name}(conditions = #{options[:conditions].inspect})
142
+ @#{plural_name} = #{class_name}.where(conditions).includes(
143
+ #{options[:include].map(&:to_sym).inspect}
144
+ ).order("#{options[:order]}")
147
145
  end
148
146
 
147
+ # Paginate a set of @#{plural_name} that may/may not already exist.
149
148
  def paginate_all_#{plural_name}
150
- @#{plural_name} = #{class_name}.paginate(
151
- :page => params[:page],
152
- :order => "#{options[:order]}",
153
- :conditions => "#{options[:conditions]}",
154
- :include => %w(#{options[:include].join(' ')})
155
- )
149
+ # If we have already found a set then we don't need to again
150
+ find_all_#{plural_name} if @#{plural_name}.nil?
151
+
152
+ @#{plural_name} = @#{plural_name}.paginate(:page => params[:page])
156
153
  end
157
154
 
155
+ # Returns a weighted set of results based on the query specified by the user.
158
156
  def search_all_#{plural_name}
159
- @#{plural_name} = #{class_name}.with_query(params[:search]).find(
160
- :all,
161
- :order => "#{options[:order]}",
162
- :conditions => "#{options[:search_conditions]}",
163
- :include => %w(#{options[:include].join(' ')})
164
- )
165
- end
157
+ # First find normal results.
158
+ find_all_#{plural_name}(#{options[:search_conditions].inspect})
166
159
 
167
- def search_and_paginate_all_#{plural_name}
168
- @#{plural_name} = #{class_name}.with_query(params[:search]).paginate(
169
- :page => params[:page],
170
- :order => "#{options[:order]}",
171
- :conditions => "#{options[:search_conditions]}",
172
- :include => %w(#{options[:include].join(' ')})
173
- )
160
+ # Now get weighted results by running the query against the results already found.
161
+ @#{plural_name} = @#{plural_name}.with_query(params[:search])
174
162
  end
175
163
 
164
+ # Ensure all methods are protected so that they should only be called
165
+ # from within the current controller.
176
166
  protected :find_#{singular_name},
177
167
  :find_all_#{plural_name},
178
168
  :paginate_all_#{plural_name},
179
- :search_all_#{plural_name},
180
- :search_and_paginate_all_#{plural_name}
181
-
169
+ :search_all_#{plural_name}
182
170
  )
183
171
 
172
+ # Methods that are only included when this controller is searchable.
184
173
  if options[:searchable]
185
174
  if options[:paging]
186
175
  module_eval %(
187
176
  def index
188
- if searching?
189
- search_and_paginate_all_#{plural_name}
190
- else
191
- paginate_all_#{plural_name}
192
- end
177
+ search_all_#{plural_name} if searching?
178
+ paginate_all_#{plural_name}
193
179
  end
194
180
  )
195
181
  else
196
182
  module_eval %(
197
183
  def index
198
- if searching?
199
- search_all_#{plural_name}
200
- else
184
+ unless searching?
201
185
  find_all_#{plural_name}
186
+ else
187
+ search_all_#{plural_name}
202
188
  end
203
189
  end
204
190
  )
@@ -229,11 +215,9 @@ module Refinery
229
215
 
230
216
  # Based upon http://github.com/matenia/jQuery-Awesome-Nested-Set-Drag-and-Drop
231
217
  def update_positions
232
- newlist = params[:ul]
233
218
  previous = nil
234
219
  # The list doesn't come to us in the correct order. Frustration.
235
- index = 0
236
- while index < newlist.length do
220
+ while (index ||= 0) < (newlist ||= params[:ul]).length do
237
221
  hash = newlist[index.to_s]
238
222
  moved_item_id = hash['id'].split(/#{singular_name}/)
239
223
  @current_#{singular_name} = #{class_name}.find_by_id(moved_item_id)
@@ -267,7 +251,7 @@ module Refinery
267
251
  if child['children'].present?
268
252
  update_child_positions(child, child_#{singular_name})
269
253
  end
270
-
254
+
271
255
  child_index += 1
272
256
  end
273
257
  end
@@ -1266,9 +1266,17 @@ WYMeditor.editor.prototype.dialog = function( dialogType ) {
1266
1266
  selection = wym._iframe.contentWindow.getSelection();
1267
1267
  selected_html = $(selected).html();
1268
1268
 
1269
- new_html = selected_html.substring(0, selection.focusOffset)
1270
- + "<span id='replace_me_with_" + this._current_unique_stamp + "'></span>"
1271
- + selected_html.substring(selection.focusOffset);
1269
+ if ((selection.focusOffset - selection.anchorOffset) > 1) {
1270
+ new_html = selected_html.substring(0, selection.anchorOffset)
1271
+ + "<span id='replace_me_with_" + this._current_unique_stamp + "'>"
1272
+ + selected_html.substring(selection.anchorOffset, selection.focusOffset)
1273
+ + "</span>"
1274
+ + selected_html.substring(selection.focusOffset);
1275
+ } else {
1276
+ new_html = selected_html.substring(0, selection.focusOffset)
1277
+ + "<span id='replace_me_with_" + this._current_unique_stamp + "'></span>"
1278
+ + selected_html.substring(selection.focusOffset);
1279
+ }
1272
1280
 
1273
1281
  $(selected).html(new_html);
1274
1282
  } else {
@@ -11,4 +11,4 @@ module NavigationHelpers
11
11
  end
12
12
  end
13
13
  end
14
- end
14
+ end
@@ -9,12 +9,9 @@ class Admin::ImagesController < Admin::BaseController
9
9
  before_filter :change_list_mode_if_specified, :init_dialog
10
10
 
11
11
  def index
12
- if searching?
13
- search_and_paginate_all_images
14
- else
15
- paginate_all_images
16
- end
17
-
12
+ search_all_images if searching?
13
+ paginate_all_images
14
+
18
15
  if RefinerySetting.find_or_set(:group_images_by_date_uploaded, true)
19
16
  @grouped_images = group_by_date(@images)
20
17
  end
@@ -48,7 +45,7 @@ class Admin::ImagesController < Admin::BaseController
48
45
 
49
46
  #This returns a url. If params[:size] is provided, it will generate a url for this size.
50
47
  def url
51
- @image = Image.find(params[:id])
48
+ find_image
52
49
  if params[:size].present?
53
50
  begin
54
51
  thumbnail = @image.thumbnail(params[:size])
@@ -64,13 +61,14 @@ class Admin::ImagesController < Admin::BaseController
64
61
  def create
65
62
  begin
66
63
  @image = Image.create(params[:image])
67
- rescue Dragonfly::Delegator::UnableToHandle
64
+ rescue Dragonfly::FunctionManager::UnableToHandle
65
+ logger.warn($!.message)
68
66
  @image = Image.new
69
67
  end
70
68
 
71
69
  unless params[:insert]
72
70
  if @image.valid?
73
- flash[:notice] = t('refinery.crudify.created', :what => "'#{@image.title}'")
71
+ flash.notice = t('refinery.crudify.created', :what => "'#{@image.title}'")
74
72
  unless from_dialog?
75
73
  redirect_to :action => 'index'
76
74
  else
@@ -14,4 +14,4 @@ module NavigationHelpers
14
14
  end
15
15
  end
16
16
  end
17
- end
17
+ end
@@ -1,7 +1,7 @@
1
1
  class Admin::PagesController < Admin::BaseController
2
2
 
3
3
  crudify :page,
4
- :conditions => "pages.parent_id IS NULL",
4
+ :conditions => {:parent_id => nil},
5
5
  :order => "lft ASC",
6
6
  :include => [:parts, :slugs, :children, :parent],
7
7
  :paging => false
@@ -6,9 +6,9 @@ class Admin::PagesDialogsController < Admin::DialogsController
6
6
 
7
7
  def link_to
8
8
  @pages = Page.paginate :page => params[:page],
9
- :conditions => 'parent_id is null',
10
- :order => 'position ASC',
11
- :per_page => Page.per_page(dialog=true)
9
+ :conditions => {:parent_id => nil},
10
+ :order => 'position ASC',
11
+ :per_page => Page.per_page(dialog=true)
12
12
 
13
13
  @resources = Resource.paginate :page => params[:resource_page],
14
14
  :order => 'created_at DESC',
@@ -15,4 +15,4 @@ module NavigationHelpers
15
15
  end
16
16
  end
17
17
  end
18
- end
18
+ end
@@ -27,7 +27,7 @@ module Refinery
27
27
  @major = 0
28
28
  @minor = 9
29
29
  @tiny = 8
30
- @build = 2
30
+ @build = 3
31
31
 
32
32
  class << self
33
33
  attr_reader :major, :minor, :tiny, :build
@@ -34,11 +34,8 @@ class Admin::ResourcesController < Admin::BaseController
34
34
  end
35
35
 
36
36
  def index
37
- if searching?
38
- search_and_paginate_all_resources
39
- else
40
- paginate_all_resources
41
- end
37
+ search_all_resources if searching?
38
+ paginate_all_resources
42
39
 
43
40
  if RefinerySetting.find_or_set(:group_resources_by_date_uploaded, true)
44
41
  @grouped_resources = group_by_date(@resources)
@@ -155,7 +155,7 @@ class RefinerySetting < ActiveRecord::Base
155
155
  if %w(trueclass falseclass).include?(new_value.class.to_s.downcase)
156
156
  new_value = new_value.to_s
157
157
  end
158
-
158
+
159
159
  super
160
160
  end
161
161
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: refinerycms
3
3
  version: !ruby/object:Gem::Version
4
- hash: 35
4
+ hash: 33
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 9
9
9
  - 8
10
- - 2
11
- version: 0.9.8.2
10
+ - 3
11
+ version: 0.9.8.3
12
12
  platform: ruby
13
13
  authors:
14
14
  - Resolve Digital
@@ -18,7 +18,7 @@ autorequire:
18
18
  bindir: bin
19
19
  cert_chain: []
20
20
 
21
- date: 2010-09-14 00:00:00 +12:00
21
+ date: 2010-09-15 00:00:00 +12:00
22
22
  default_executable:
23
23
  dependencies:
24
24
  - !ruby/object:Gem::Dependency
@@ -890,7 +890,6 @@ files:
890
890
  - vendor/refinerycms/images/features/uploads/id-rather-be-here.jpg
891
891
  - vendor/refinerycms/images/features/uploads/refinery_is_awesome.txt
892
892
  - vendor/refinerycms/images/lib/images.rb
893
- - vendor/refinerycms/images/lib/tasks/images.rake
894
893
  - vendor/refinerycms/images/readme.md
895
894
  - vendor/refinerycms/pages/app/controllers/admin/page_parts_controller.rb
896
895
  - vendor/refinerycms/pages/app/controllers/admin/pages_controller.rb
@@ -1001,7 +1000,6 @@ post_install_message:
1001
1000
  rdoc_options: []
1002
1001
 
1003
1002
  require_paths:
1004
- - lib
1005
1003
  - vendor/refinerycms
1006
1004
  required_ruby_version: !ruby/object:Gem::Requirement
1007
1005
  none: false
@@ -1,50 +0,0 @@
1
- namespace :images do
2
-
3
- desc "Regenerate all thumbnails. Useful for when you've changed size or cropping on the images after images have been uploaded."
4
- task :regenerate => :environment do
5
- =begin
6
- thumbnails_size = Image.count(:conditions => "parent_id IS NOT NULL")
7
- puts "Preparing to delete #{thumbnails_size} generated thumbnails"
8
-
9
- if Image.destroy_all("parent_id IS NOT null")
10
- puts "--> #{thumbnails_size} thumbnails deleted"
11
- else
12
- puts "There may have been a problem deleting the thumbnails."
13
- end
14
-
15
- originals = Image.originals
16
- puts "Preparing to regenerate thumbnails for #{originals.size} images"
17
-
18
- originals.each do |image|
19
- begin
20
- image.rebuild_thumbnails!
21
- rescue Exception => e
22
- puts "--> ERROR image #{image.id} could not be saved because #{e.message}"
23
- end
24
- end
25
- puts "Image regeneration complete."
26
- =end
27
- puts "TODO: update task for Dragonfly"
28
- end
29
-
30
- desc "Update thumbnails. Useful for when you have added new thumbnail sizes and you just need to regenerate those without regenerating all the thumbnails again."
31
- task :update => :environment do
32
- =begin
33
- originals = Image.originals
34
-
35
- puts "Preparing to update #{originals.size} images. This may take a few minutes. Please wait..."
36
-
37
- originals.each do |image|
38
- begin
39
- image.rebuild_missing_thumbnails!
40
- rescue Exception => e
41
- puts "--> ERROR image #{image.id} could not be saved because #{e.message}"
42
- end
43
- end
44
-
45
- puts "Thumbnail update complete."
46
- =end
47
- puts "TODO: update task for Dragonfly"
48
- end
49
-
50
- end