refinerycms 0.9.6.9 → 0.9.6.10

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/Rakefile CHANGED
@@ -17,7 +17,7 @@ require 'tasks/rails'
17
17
 
18
18
  extra_rake_tasks = []
19
19
  # When running Refinery from a gem we lose the rake tasks, so add them back in:
20
- extra_rake_tasks << Dir[File.join(REFINERY_ROOT, %w(vendor plugins * ** tasks ** *.rake))].sort unless REFINERY_ROOT.to_s == Rails.root.to_s
20
+ extra_rake_tasks << Dir[Refinery.root.join("vendor", "plugins", "*", "**", "tasks", "**", "*", "*.rake")].sort unless Refinery.root == Rails.root
21
21
  # We also need to load in the rake tasks from gem plugins whether Refinery is a gem or not:
22
22
  extra_rake_tasks << $refinery_gem_plugin_lib_paths.collect {|path| Dir[File.join(%W(#{path} tasks ** *.rake))].sort} if defined?($refinery_gem_plugin_lib_paths) && !$refinery_gem_plugin_lib_paths.nil?
23
23
  extra_rake_tasks.flatten.compact.uniq.each {|rake| load rake }
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.6.9
1
+ 0.9.6.10
@@ -1,6 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
+ require 'pathname'
2
3
  require 'fileutils'
3
- REFINERY_ROOT = File.expand_path(File.dirname(__FILE__) << "/..")
4
+
5
+ REFINERY_ROOT = Pathname.new(File.expand_path(File.dirname(__FILE__) << "/..")) unless defined?(REFINERY_ROOT) && REFINERY_ROOT.is_a?(Pathname)
4
6
  unless (app_path = ARGV.shift).nil? or app_path.length == 0
5
7
  # if "" or "." or "./" is specified then get the current directory otherwise accept the specified app_path.
6
8
  RAILS_ROOT = (app_path.length <= 2 and ((is_current_dir = app_path =~ /(\.(\/)?)/).nil? or is_current_dir < 2)) ? Dir.getwd : app_path
@@ -19,7 +21,7 @@ unless (app_path = ARGV.shift).nil? or app_path.length == 0
19
21
 
20
22
  # copy in all of the relevant directories and root files.
21
23
  to_copy = %w(app config db lib public script contributors.md license.md Rakefile readme.md VERSION).map do |dir|
22
- File.join REFINERY_ROOT, dir
24
+ REFINERY_ROOT.join(dir).to_s
23
25
  end
24
26
  FileUtils::cp_r to_copy, RAILS_ROOT, :verbose => false
25
27
  FileUtils::mkdir File.join(%W(#{RAILS_ROOT} themes))
@@ -1,15 +1,17 @@
1
1
  #!/usr/bin/env ruby
2
+ require 'pathname'
2
3
  require 'fileutils'
3
- REFINERY_ROOT = File.expand_path(File.dirname(__FILE__) << "/..")
4
+
5
+ REFINERY_ROOT = Pathname.new(File.expand_path(File.dirname(__FILE__) << "/..")) unless defined?(REFINERY_ROOT) && REFINERY_ROOT.is_a?(Pathname)
4
6
  unless (override_path = ARGV.shift).nil? or (override_path.length == 0)
5
7
  # if "" or "." or "./" is specified then get the current directory otherwise accept the specified app_path.
6
8
  if ((app_path = ARGV.shift).nil? or app_path.length <= 2) and ((is_current_dir = app_path =~ /(\.(\/)?)/).nil? or !is_current_dir or is_current_dir < 2)
7
- RAILS_ROOT = Dir.getwd
9
+ RAILS_ROOT = Pathname.new(Dir.getwd)
8
10
  else
9
- RAILS_ROOT = app_path
11
+ RAILS_ROOT = Pathname.new(app_path)
10
12
  end
11
13
 
12
- if File.exists? RAILS_ROOT
14
+ if RAILS_ROOT.exists?
13
15
  # figure out what to override
14
16
  override_parts = override_path.downcase.split('/').compact.collect {|part| part if part.length > 0 }.compact
15
17
  admin = ""
@@ -29,11 +31,11 @@ unless (override_path = ARGV.shift).nil? or (override_path.length == 0)
29
31
 
30
32
  # copy the controller
31
33
  unless controller_with_admin =~ /\*(\*)?/ and !action.nil?
32
- refinery_controllers = Dir[File.join(REFINERY_ROOT, %w(vendor plugins ** app controllers), "#{controller_with_admin}_controller.rb")]
34
+ refinery_controllers = Dir[REFINERY_ROOT.join("vendor", "plugins", "**", "app", "controllers", "#{controller_with_admin}_controller.rb")]
33
35
  if refinery_controllers.compact.any? # the controllers may not exist.
34
36
  refinery_controllers.each do |refinery_controller|
35
37
  # make the directories
36
- FileUtils.mkdir_p(copy_to = File.join(RAILS_ROOT, %w(app controllers), admin))
38
+ FileUtils.mkdir_p(copy_to = RAILS_ROOT.join("app" "controllers", admin))
37
39
  FileUtils.cp(refinery_controller, copy_to)
38
40
  end
39
41
  else
@@ -44,7 +46,7 @@ unless (override_path = ARGV.shift).nil? or (override_path.length == 0)
44
46
  # copy the action, if it exists
45
47
  unless action.nil? or action.length == 0
46
48
  # get all the matching files
47
- looking_for = File.join(REFINERY_ROOT, %w(vendor plugins ** app views), controller_with_admin.split('/'), "#{action}*.erb")
49
+ looking_for = REFINERY_ROOT.join("vendor", "plugins", "**", "app", "views", controller_with_admin.split('/'), "#{action}*.erb")
48
50
  action_files = Dir[looking_for]
49
51
 
50
52
  # copy in the action template
@@ -53,8 +55,8 @@ unless (override_path = ARGV.shift).nil? or (override_path.length == 0)
53
55
  action_file_dir = action_file_path.split('/')
54
56
  action_file_dir.pop # get rid of the file.
55
57
 
56
- FileUtils.mkdir_p(File.join(RAILS_ROOT, %w(app views), action_file_dir))
57
- FileUtils.cp action_file, File.join(RAILS_ROOT, %w(app views), action_file_path)
58
+ FileUtils.mkdir_p(RAILS_ROOT.join("app", "views", action_file_dir))
59
+ FileUtils.cp action_file, RAILS_ROOT.join("app", "views", action_file_path)
58
60
  end
59
61
  else
60
62
  puts "Note: No action was specified."
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
+ require 'pathname'
2
3
  require 'fileutils'
3
- REFINERY_ROOT = File.expand_path(File.dirname(__FILE__) << "/..")
4
+ REFINERY_ROOT = Pathname.new(File.expand_path(File.dirname(__FILE__) << "/..")) unless defined?(REFINERY_ROOT) && REFINERY_ROOT.is_a?(Pathname)
4
5
  RAILS_ROOT = ARGV.first unless defined? RAILS_ROOT
5
6
  unless RAILS_ROOT.nil? or RAILS_ROOT.length == 0
6
7
  # ensure asset directories exist.
@@ -39,7 +39,8 @@ else
39
39
  # Only load the plugins named here, in the order given. By default, all plugins
40
40
  # in vendor/plugins are loaded in alphabetical order.
41
41
  # :all can be used as a placeholder for all plugins not explicitly named
42
- # config.plugins = [ :authentication, :acts_as_tree, :attachment_fu, :all ]
42
+ # Loading gem plugins that other plugins may rely on first.
43
+ config.plugins = [ :friendly_id, :will_paginate, :aasm, :all ]
43
44
 
44
45
  # Add additional load paths for your own custom dirs
45
46
  # config.load_paths += %W( #{RAILS_ROOT}/extras )
@@ -18,8 +18,7 @@ config.action_controller.perform_caching = true
18
18
  # Disable delivery errors, bad email addresses will be ignored
19
19
  # config.action_mailer.raise_delivery_errors = false
20
20
 
21
- # We don't really need all the other stuff:
22
- config.log_level = :warn
21
+ config.log_level = :info
23
22
 
24
23
  # Set to true in order to use Amazon's Simple Storage Service on your production machine
25
24
  # instead of the default file system for resources and images
@@ -1,9 +1,12 @@
1
+ require 'pathname'
2
+
1
3
  # until Rails 3
2
4
  ENV["GEM_HOME"] = File.expand_path('../../vendor/bundler_gems', __FILE__)
3
5
 
4
6
  # pick the refinery root path
5
- if File.exist?(non_gem_path=File.join(%W(#{RAILS_ROOT} lib refinery_initializer.rb)))
6
- require non_gem_path
7
+ rails_root = defined?(Rails.root) ? Rails.root : Pathname.new(RAILS_ROOT)
8
+ if (non_gem_path = rails_root.join("lib", "refinery_initializer.rb")).exist?
9
+ require non_gem_path.to_s
7
10
  else
8
11
  require 'rubygems'
9
12
  version = if defined? REFINERY_GEM_VERSION
@@ -11,7 +14,7 @@ else
11
14
  elsif ENV.include?("REFINERY_GEM_VERSION")
12
15
  ENV["REFINERY_GEM_VERSION"]
13
16
  else
14
- $1 if File.read(File.join(%W(#{RAILS_ROOT} config environment.rb))) =~ /^[^#]*REFINERY_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
17
+ $1 if rails_root.join("config", "application.rb") =~ /^[^#]*REFINERY_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
15
18
  end
16
19
 
17
20
  if version
@@ -23,9 +26,8 @@ else
23
26
  require 'refinery_initializer'
24
27
  end
25
28
 
26
-
27
- REFINERY_ROOT = RAILS_ROOT unless defined? REFINERY_ROOT
29
+ Refinery.root = rails_root unless defined?(Refinery.root) && Refinery.root.is_a?(Pathname)
28
30
 
29
31
  # Set to true in your environment specific file (e.g. production.rb) to use Amazon's Simple
30
32
  # Storage Service instead of the default file system for resources and images
31
- USE_S3_BACKEND = false unless defined?(USE_S3_BACKEND)
33
+ USE_S3_BACKEND = false unless defined?(USE_S3_BACKEND)
@@ -119,7 +119,7 @@ Page.create(:title => "Down for maintenance",
119
119
 
120
120
  # Install default themes.
121
121
  Rails.root.join("themes").mkdir unless Rails.root.join("themes").directory?
122
- Dir[File.join(%W(#{REFINERY_ROOT} themes *.zip))].each do |theme|
122
+ Dir[Refinery.root.join("themes", "*.zip")].each do |theme|
123
123
  Theme.create(:uploaded_data => {
124
124
  "size" => File.size(theme),
125
125
  "content_type" => "application/zip",
@@ -1,10 +1,17 @@
1
- REFINERY_ROOT = File.expand_path(File.dirname(__FILE__) << "/..")
1
+ require 'pathname'
2
+ begin
3
+ require 'vendor/plugins/refinery/lib/refinery'
4
+ rescue LoadError => load_error
5
+ # We won't be able to load this if we're in the gem as there is no such thing.
6
+ end
2
7
 
3
- unless REFINERY_ROOT == RAILS_ROOT # e.g. only if we're in a gem.
4
- $LOAD_PATH.unshift "#{REFINERY_ROOT}/vendor/plugins"
5
- $LOAD_PATH.unshift "#{REFINERY_ROOT}/vendor/plugins/refinery/lib"
8
+ refinery_root = Pathname.new((defined?(Refinery.root) ? Refinery.root.to_s : File.expand_path(File.dirname(__FILE__) << "/..")))
9
+ unless refinery_root == (defined?(Rails.root) ? Rails.root : Pathname.new(RAILS_ROOT)) # e.g. only if we're in a gem.
10
+ $LOAD_PATH.unshift refinery_root.join("vendor", "plugins").to_s
11
+ $LOAD_PATH.unshift refinery_root.join("vendor", "plugins", "refinery", "lib").to_s
6
12
 
7
13
  require 'refinery'
14
+ Refinery.root = refinery_root
8
15
  require 'refinery/initializer'
9
16
  end
10
17
 
@@ -51,7 +51,7 @@ class PageTest < ActiveSupport::TestCase
51
51
  end
52
52
 
53
53
  def test_should_have_regular_url
54
- assert pages(:services).url[:controller] == "pages"
54
+ assert pages(:services).url[:controller] == "/pages"
55
55
  # not sure how I get it to render the friendly_id url /pages/services
56
56
  # test seems to reduce the id instead e.g. /pages/234423
57
57
  end
data/todo.md CHANGED
@@ -1,9 +1,21 @@
1
- = Todo
1
+ # Todo
2
2
 
3
3
  What are some of the known things that need to be done?
4
4
 
5
- == Tests
5
+ ## Tests
6
6
 
7
7
  * Add unit test coverage for user, user plugin and user mailer
8
8
  * Add unit test coverage for inquiry mailer and inquiry setting
9
- * Add functional tests for the whole of Refinery.
9
+ * Add functional tests for the whole of Refinery.
10
+
11
+ # Rails 3.0 Support
12
+
13
+ We've started an effort to move to Rails 3.0 - that just needs to be completed.
14
+
15
+ # Improve the Generator
16
+
17
+ We need to have support for build in Refinery field types like "image". So I could run
18
+
19
+ ./script/generate refinery staff name:string bio:text mugshot:image
20
+
21
+ And it will automatically create a form field that pops open the image picker on the staff form.
@@ -10,4 +10,4 @@ Refinery::Plugin.register do |plugin|
10
10
  end
11
11
 
12
12
  # Set the actionmailer root so that it'll work for delivering emails from this plugin.
13
- ActionMailer::Base.template_root = "#{REFINERY_ROOT}/vendor/plugins/inquiries/app/views"
13
+ ActionMailer::Base.template_root = Refinery.root.join("vendor", "plugins", "inquiries", "app", "views").to_s
@@ -1,9 +1,10 @@
1
1
  <%
2
2
  show_empty_sections ||= false
3
+ remove_automatic_sections ||= false
3
4
 
4
- body_content_title = ((title = yield :body_content_title).present? or (title.blank? and show_empty_sections)) ? title : page_title
5
- body_content_left = ((body_content_left = yield :body_content_left).present? or (body_content_left.blank? and show_empty_sections)) ? body_content_left : @page[:body]
6
- body_content_right = ((body_content_right = yield :body_content_right).present? or (body_content_right.blank? and show_empty_sections)) ? body_content_right : @page[:side_body]
5
+ body_content_title = page_title if (body_content_title = yield :body_content_title).blank? and !show_empty_sections and !remove_automatic_sections
6
+ body_content_left = @page[:body] if (body_content_left = yield :body_content_left).blank? and !show_empty_sections and !remove_automatic_sections
7
+ body_content_right = @page[:side_body] if (body_content_right = yield :body_content_right).blank? and !show_empty_sections and !remove_automatic_sections
7
8
 
8
9
  extra_body_content_classes = []
9
10
  extra_body_content_classes << "no_title" if body_content_title.blank?
@@ -12,17 +13,17 @@
12
13
  -%>
13
14
  <%= render :partial => "/shared/submenu" if !admin? and (show_submenu ||= true) and RefinerySetting.find_or_set(:show_submenu_on_content_pages, true) %>
14
15
  <div id='body_content' class='clearfix<%= " #{extra_body_content_classes.join(" ")}" if extra_body_content_classes.any? %>'>
15
- <% if body_content_title.present? or show_empty_sections -%>
16
+ <% if body_content_title.present? or (show_empty_sections and !remove_automatic_sections) -%>
16
17
  <h1 id='body_content_page_title'>
17
18
  <%= body_content_title %>
18
19
  </h1>
19
20
  <% end -%>
20
- <% if body_content_left.present? or show_empty_sections -%>
21
+ <% if body_content_left.present? or (show_empty_sections and !remove_automatic_sections) -%>
21
22
  <div id='body_content_left' class='clearfix'>
22
23
  <%= body_content_left %>
23
24
  </div>
24
25
  <% end -%>
25
- <% if body_content_right.present? or show_empty_sections -%>
26
+ <% if body_content_right.present? or (show_empty_sections and !remove_automatic_sections) -%>
26
27
  <div id='body_content_right' class='clearfix'>
27
28
  <%= body_content_right %>
28
29
  </div>
@@ -1,7 +1,8 @@
1
1
  <% cache(:action_suffix => "site_menu") do %>
2
2
  <ul id='<%= dom_id ||= "menu" %>' class='menu clearfix'>
3
3
  <%= render :partial => "/shared/menu_branch", :collection => @menu_pages, :locals => {
4
- :hide_children => RefinerySetting.find_or_set(:menu_hide_children, false)
4
+ :hide_children => RefinerySetting.find_or_set(:menu_hide_children, false),
5
+ :sibling_count => @menu_pages.size-1
5
6
  } -%>
6
7
  </ul>
7
8
  <% end %>
@@ -2,7 +2,7 @@
2
2
  css = []
3
3
  css << "selected" if selected_page?(menu_branch) or descendant_page_selected?(menu_branch)
4
4
  css << "first" if menu_branch_counter == 0
5
- css << "last" if menu_branch_counter == menu_branch.shown_siblings.size
5
+ css << "last" if menu_branch_counter == (sibling_count ||= menu_branch.shown_siblings.size)
6
6
  domid = "item_#{menu_branch_counter}" unless menu_branch.parent_id.present? or menu_branch.title.blank?
7
7
  -%>
8
8
  <% if menu_branch.in_menu? %>
@@ -11,12 +11,12 @@
11
11
  <%
12
12
  unless hide_children or
13
13
  menu_branch.parent_id.present? or
14
- (children = menu_branch.children.collect{|c| c if c.in_menu? }.compact).empty?
14
+ (children = Page.find(:all, :conditions => "parent_id = #{menu_branch.id}").collect{|c| c if c.in_menu? }.compact).empty?
15
15
  -%>
16
16
  <ul class='clearfix'>
17
17
  <%= render :partial => "/shared/menu_branch",
18
18
  :collection => children,
19
- :locals => {:hide_children => hide_children} -%>
19
+ :locals => {:hide_children => hide_children, :sibling_count => children.size-1} -%>
20
20
  </ul>
21
21
  <% end -%>
22
22
  </li>
@@ -1,21 +1,7 @@
1
1
  module Refinery
2
2
 
3
- def self.add_gems
4
- ActiveRecord::Base.module_eval do
5
- begin
6
- require 'friendly_id'
7
- require 'will_paginate'
8
- require 'aasm'
9
- rescue LoadError => load_error
10
- # this will stop us running rake gems:install which we don't really want so just trap this error.
11
- end
12
-
13
- # Stub has_friendly_id. This will get overriden when/if included.
14
- # The config will still complain that the gem is missing but this allows it to do so.
15
- def self.has_friendly_id(column, options = {}, &block)
16
- super if defined? super and table_exists?
17
- end
18
- end
3
+ class << self
4
+ attr_accessor :root
19
5
  end
20
6
 
21
- end
7
+ end
@@ -1,6 +1,6 @@
1
1
  begin
2
2
  # Try to include the rails initializer. If this isn't in a gem, this will fail.
3
- require 'initializer' unless REFINERY_ROOT == RAILS_ROOT # A Refinery gem install's Rails.root is not the REFINERY_ROOT.
3
+ require 'initializer' unless Refinery.root.to_s == RAILS_ROOT # A Refinery gem install's Rails.root is not the Refinery.root.
4
4
  rescue LoadError => load_error
5
5
  end
6
6
 
@@ -9,7 +9,7 @@ module Refinery
9
9
  if defined? Rails::Configuration
10
10
  class Configuration < Rails::Configuration
11
11
  def default_plugin_paths
12
- paths = super.push(File.join(%W(#{REFINERY_ROOT} vendor plugins))).uniq
12
+ paths = super.push(Refinery.root.join("vendor", "plugins")).uniq
13
13
  end
14
14
  end
15
15
  end
@@ -19,9 +19,9 @@ module Refinery
19
19
  def add_plugin_load_paths
20
20
  super
21
21
  # add plugin lib paths to the $LOAD_PATH so that rake tasks etc. can be run when using a gem for refinery or gems for plugins.
22
- search_for = Regexp.new(File.join(%W(\( #{REFINERY_ROOT} vendor plugins \)? .+? lib)))
22
+ search_for = Regexp.new(File.join(%W(\( #{Refinery.root.join("vendor", "plugins")} \)? .+? lib)))
23
23
  paths = plugins.collect{ |plugin| plugin.load_paths }.flatten.reject{|path| path.scan(search_for).empty? or path.include?('/rails-') }
24
- paths = paths.reject{ |path| path.include?(REFINERY_ROOT) } if REFINERY_ROOT == Rails.root.to_s # superfluous when not in gem.
24
+ paths = paths.reject{ |path| path.include?(Refinery.root.to_s) } if Refinery.root == Rails.root # superfluous when not in gem.
25
25
  ($refinery_gem_plugin_lib_paths = paths).each do |path|
26
26
  $LOAD_PATH.unshift path
27
27
  end
@@ -33,16 +33,11 @@ module Refinery
33
33
  if defined? Rails::Initializer
34
34
  class Initializer < Rails::Initializer
35
35
  def self.run(command = :process, configuration = Configuration.new)
36
- Rails.configuration = configuration
37
36
  configuration.plugin_loader = Refinery::PluginLoader
38
- super
39
- end
40
-
41
- def load_plugins
42
- Refinery.add_gems
37
+ Rails.configuration = configuration
43
38
  super
44
39
  end
45
40
  end
46
41
  end
47
42
 
48
- end
43
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: refinerycms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.6.9
4
+ version: 0.9.6.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Resolve Digital