browsercms 3.3.0.beta → 3.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. data/.yardopts +5 -0
  2. data/README.markdown +11 -11
  3. data/app/helpers/cms/page_helper.rb +1 -1
  4. data/app/models/page_route.rb +9 -0
  5. data/app/models/portlet.rb +2 -2
  6. data/app/models/section.rb +1 -1
  7. data/app/views/cms/form_builder/_cms_text_area.html.erb +2 -5
  8. data/app/views/cms/form_builder/_cms_text_editor.html.erb +1 -0
  9. data/app/views/cms/pages/_form.html.erb +2 -10
  10. data/bin/bcms +114 -3
  11. data/bin/browsercms +3 -72
  12. data/browsercms.gemspec +4 -2
  13. data/lib/cms/behaviors/soft_deleting.rb +4 -5
  14. data/lib/cms/extensions/active_record/base.rb +22 -1
  15. data/lib/cms/routes.rb +2 -5
  16. data/lib/cms/version.rb +1 -1
  17. data/lib/generators/browser_cms/cms/cms_generator.rb +1 -0
  18. data/lib/generators/browser_cms/demo_site/demo_site_generator.rb +1 -1
  19. data/lib/generators/browser_cms/demo_site/templates/demo_site.rake +3 -0
  20. data/lib/generators/cms/upgrade_module/templates/COPYRIGHT.txt +23 -0
  21. data/{templates/module.rb → lib/generators/cms/upgrade_module/templates/GPL.txt} +2 -223
  22. data/lib/generators/cms/upgrade_module/templates/LICENSE.txt +165 -0
  23. data/lib/tasks/db.rake +3 -0
  24. data/public/stylesheets/cms/sitemap.css +5 -5
  25. metadata +8 -74
  26. data/doc/guides/html/authentication.html +0 -457
  27. data/doc/guides/html/build_it_yourself.html +0 -457
  28. data/doc/guides/html/building_modules.html +0 -480
  29. data/doc/guides/html/building_templates.html +0 -457
  30. data/doc/guides/html/content_blocks.html +0 -457
  31. data/doc/guides/html/customizing_browsercms.html +0 -457
  32. data/doc/guides/html/deployment_guide.html +0 -568
  33. data/doc/guides/html/files/bcmsorg.js +0 -28
  34. data/doc/guides/html/files/clearfix.css +0 -8
  35. data/doc/guides/html/files/cufon.js +0 -7
  36. data/doc/guides/html/files/global.css +0 -190
  37. data/doc/guides/html/files/helvetica.js +0 -91
  38. data/doc/guides/html/files/javascripts/code_highlighter.js +0 -188
  39. data/doc/guides/html/files/javascripts/guides.js +0 -7
  40. data/doc/guides/html/files/javascripts/highlighters.js +0 -90
  41. data/doc/guides/html/files/jquery.js +0 -11
  42. data/doc/guides/html/files/stylesheets/main.css +0 -441
  43. data/doc/guides/html/files/stylesheets/reset.css +0 -43
  44. data/doc/guides/html/files/stylesheets/style.css +0 -13
  45. data/doc/guides/html/files/stylesheets/syntax.css +0 -31
  46. data/doc/guides/html/getting_started.html +0 -457
  47. data/doc/guides/html/images/bg.png +0 -0
  48. data/doc/guides/html/images/bottom_cap.png +0 -0
  49. data/doc/guides/html/images/browsercms_logo.png +0 -0
  50. data/doc/guides/html/images/content_blocks/add_field_to_form.png +0 -0
  51. data/doc/guides/html/images/content_blocks/add_second_block.png +0 -0
  52. data/doc/guides/html/images/dot.png +0 -0
  53. data/doc/guides/html/images/icons/README +0 -5
  54. data/doc/guides/html/images/icons/callouts/1.png +0 -0
  55. data/doc/guides/html/images/icons/callouts/10.png +0 -0
  56. data/doc/guides/html/images/icons/callouts/11.png +0 -0
  57. data/doc/guides/html/images/icons/callouts/12.png +0 -0
  58. data/doc/guides/html/images/icons/callouts/13.png +0 -0
  59. data/doc/guides/html/images/icons/callouts/14.png +0 -0
  60. data/doc/guides/html/images/icons/callouts/15.png +0 -0
  61. data/doc/guides/html/images/icons/callouts/2.png +0 -0
  62. data/doc/guides/html/images/icons/callouts/3.png +0 -0
  63. data/doc/guides/html/images/icons/callouts/4.png +0 -0
  64. data/doc/guides/html/images/icons/callouts/5.png +0 -0
  65. data/doc/guides/html/images/icons/callouts/6.png +0 -0
  66. data/doc/guides/html/images/icons/callouts/7.png +0 -0
  67. data/doc/guides/html/images/icons/callouts/8.png +0 -0
  68. data/doc/guides/html/images/icons/callouts/9.png +0 -0
  69. data/doc/guides/html/images/icons/caution.png +0 -0
  70. data/doc/guides/html/images/icons/example.png +0 -0
  71. data/doc/guides/html/images/icons/home.png +0 -0
  72. data/doc/guides/html/images/icons/important.png +0 -0
  73. data/doc/guides/html/images/icons/next.png +0 -0
  74. data/doc/guides/html/images/icons/note.png +0 -0
  75. data/doc/guides/html/images/icons/prev.png +0 -0
  76. data/doc/guides/html/images/icons/tip.png +0 -0
  77. data/doc/guides/html/images/icons/up.png +0 -0
  78. data/doc/guides/html/images/icons/warning.png +0 -0
  79. data/doc/guides/html/images/nfl_sitemap.png +0 -0
  80. data/doc/guides/html/images/top_cap.png +0 -0
  81. data/doc/guides/html/images/top_cap_content.png +0 -0
  82. data/doc/guides/html/index.html +0 -457
  83. data/doc/guides/html/installing_modules.html +0 -457
  84. data/doc/guides/html/portlets.html +0 -457
  85. data/doc/guides/html/user_guide.html +0 -457
  86. data/doc/guides/html/writing_guides.html +0 -457
  87. data/lib/initial_data.rb +0 -30
  88. data/lib/tasks/build_gem.rake +0 -1
  89. data/lib/tasks/cms.rake +0 -69
  90. data/lib/tasks/cucumber.rake +0 -53
  91. data/lib/tasks/dev.rake +0 -20
  92. data/templates/blank.rb +0 -48
  93. data/templates/demo.rb +0 -48
@@ -0,0 +1,5 @@
1
+ --no-private
2
+ --exclude lib/generators/cms/portlet/templates/*
3
+ --exclude lib/generators/cms/content_block/templates/*
4
+ app/**/*.rb
5
+ lib/**/*.rb
@@ -28,30 +28,30 @@ BrowserCMS can create websites that can work in any browser, depending on how de
28
28
  2. Safari 3.2+ (Mac, Windows) - Works, with some minor layout problems.
29
29
  3. Internet Explorer 7+ (Windows) - Mostly functional, though there are a number of layout issues in the admin.
30
30
 
31
- The next releases will be aimed at tightning up the admin for both Safari and IE7+. We will not be supporting the admin UI for IE6, or other browsers not explicitly listed above.
31
+ The next releases will be aimed at tightening up the admin for both Safari and IE7+. We will not be supporting the admin UI for IE6, or other browsers not explicitly listed above.
32
32
 
33
33
  ## Getting Started
34
- Before you can use BrowserCMS, you will need to install the gem. See the Getting Started guide at http://browsercms.org/doc/guides/html/getting_started.html, or packaged with this source code (under doc/guides/html/getting_started.html)
34
+ Before you can use BrowserCMS, you will need to install the gem. See the [Getting Started](https://github.com/browsermedia/browsercms/wiki/Getting-Started) guide.
35
35
 
36
36
  ## License
37
- BrowserCMS is released under a LGPL license, and is copyright 1998-2009 BrowserMedia. The complete copyright can be found in COPYRIGHT.txt, and copy of the license can be found in LICENSE.txt.
37
+ BrowserCMS is released under a LGPL license, and is copyright 1998-2011 BrowserMedia. The complete copyright can be found in COPYRIGHT.txt, and copy of the license can be found in LICENSE.txt.
38
38
 
39
39
 
40
40
  ## Documentation
41
41
  The user documentation and guides for this version of the application can be found at:
42
42
 
43
- 1. http://browsercms.org/doc/guides/html/index.html - User guides and manuals that cover the features and general functionality of the project. (Found locally at doc/guides/html/index.html)
44
- 2. http://browsercms.org/doc/app/index.html - The RDoc API documenation (locally at doc/app/index.html)
45
- 3. http://wiki.github.com/browsermedia/browsercms - The project wiki
43
+ 1. [Guides and Wiki](http://wiki.github.com/browsermedia/browsercms)
44
+ 2. [API Docs](http://rubydoc.info/gems/browsercms/)
46
45
 
47
- ## Modifying the source
46
+
47
+ ## Working on the core project source
48
48
  If you want to experiment with the source code, the BrowserCMS project can bootstrap itself as a web application. This allows developers who want to contribute to the project to easily alter and test changes. To run the application itself, do the following:
49
49
 
50
- cd /path/to/browsercms_source_code
51
- rake reset
52
- script/server
50
+ cd /path/to/browsercms
51
+ rake db:setup
52
+ rails server
53
53
 
54
- This will drop the 'browsercms_development' database, loads the same sample data from the demo.rb template. By default, the core project is setup to use mysql as the database, but you can change that via the database.yml files.
54
+ This will create and populate the BrowserCMS database with the minimal seed data for testing. By default, the core project is setup to use mysql as the database, but you can change that via the database.yml files.
55
55
 
56
56
  ## Support
57
57
  The homepage for the BrowserCMS project is http://browsercms.org. From there you can find links to the discussion groups and our twitter account. If you have questions about the project or want to get involved, the Google group is the best way to do so. If you would like to report a bug, please do so at https://browsermedia.lighthouseapp.com/projects/28481-browsercms-30
@@ -26,7 +26,7 @@ module Cms
26
26
  # Note: As of Jan 19, 2010, all render.html.erb templates must handle marking their content as 'html_safe'. This is
27
27
  # bit of a pain, but I can't figure out how (or if) i can globally do that or not.
28
28
  #
29
- # @returns [String] The HTML content for the container.
29
+ # @return [String] The HTML content for the container.
30
30
  def container(name)
31
31
  page_content = instance_variable_get("@_content_for")
32
32
  content = page_content[name]
@@ -24,6 +24,15 @@ class PageRoute < ActiveRecord::Base
24
24
 
25
25
  after_save :reload_routes
26
26
 
27
+
28
+ # Determines if its safe to call any persistent methods on PageRoutes. This can be false if either the database doesn't exist,
29
+ # or the page_routes table doesn't yet exist.
30
+ #
31
+ # @return [Boolean] Whether its safe to call any ActiveRecord persistent method or not.
32
+ def self.can_be_loaded?
33
+ database_exists? && table_exists?
34
+ end
35
+
27
36
  # Force Rails to reload the routes. Allows modules to call this without concern that the Rails classes are going to change again.
28
37
  def self.reload_routes
29
38
  Rails.application.reload_routes!
@@ -3,8 +3,8 @@ class Portlet < ActiveRecord::Base
3
3
  validates_presence_of :name
4
4
  is_searchable
5
5
 
6
- #These are here simply to temporarily hold these values
7
- #Makes it easy to pass them through the process of selecting a portlet type
6
+ # These are here simply to temporarily hold these values
7
+ # Makes it easy to pass them through the process of selecting a portlet type
8
8
  attr_accessor :connect_to_page_id, :connect_to_container
9
9
 
10
10
  attr_accessor :controller
@@ -146,7 +146,7 @@ class Section < ActiveRecord::Base
146
146
 
147
147
  ##
148
148
  # Set which groups are allowed to access this section.
149
- # @params [Symbol] code Set of groups to allow (Options :all, :none) Defaults to :none
149
+ # @param [Symbol] code Set of groups to allow (Options :all, :none) Defaults to :none
150
150
  def allow_groups=(code=:none)
151
151
  if code == :all
152
152
  self.groups = Group.all
@@ -1,4 +1,4 @@
1
- <div class="fields text_editor_fields">
1
+ <div class="fields textarea_fields">
2
2
  <% if cms_options[:label] %>
3
3
  <%= f.label method, cms_options[:label] %>
4
4
  <% else %>
@@ -6,8 +6,5 @@
6
6
  <% end %>
7
7
  <br />
8
8
  <%= f.text_area method, options %>
9
- <% if cms_options[:instructions] %>
10
- <div class="instructions"><%=h cms_options[:instructions] %></div>
11
- <br clear="all"/>
12
- <% end %>
9
+ <%= f.cms_instructions cms_options[:instructions] %>
13
10
  </div>
@@ -15,4 +15,5 @@
15
15
  <div class="editor">
16
16
  <%= f.text_editor method, options %>
17
17
  </div>
18
+ <%= f.cms_instructions cms_options[:instructions] %>
18
19
  </div>
@@ -33,14 +33,6 @@
33
33
  </div>
34
34
  </div>
35
35
 
36
- <div class="fields textarea_fields">
37
- <%= f.label :description %>
38
- <%= f.text_area :description, :size => "80x5", :tabindex => next_tabindex %>
39
- </div>
40
-
41
- <div class="fields textarea_fields">
42
- <%= f.label :keywords %>
43
- <%= f.text_area :keywords, :size => "80x3", :tabindex => next_tabindex %>
44
- </div>
45
-
36
+ <%= f.cms_text_area :description, :size=>"80x5", :instructions=>"(Optional) Often used for the meta-description element of the page." %>
37
+ <%= f.cms_text_area :keywords, :size=>"80x3", :instructions=>"(Optional) Often used for the meta-keyword meta element of the page. Most search engine will ignore this however." %>
46
38
  <%= f.cms_text_field :language %>
data/bin/bcms CHANGED
@@ -1,6 +1,117 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- ##
4
- # Just a shorter version of 'browsercms' command.
3
+ require 'rubygems'
4
+ require 'thor'
5
+ require 'term/ansicolor'
6
+ require 'rails/generators/actions'
7
+ require 'active_support/core_ext/string/inflections'
8
+ require 'cms/version'
9
+
10
+ class String
11
+ include Term::ANSIColor
12
+ end
13
+
14
+
15
+ class App < Thor
16
+ include Thor::Actions
17
+ include Rails::Generators::Actions
18
+ source_root File.expand_path('../../lib/generators/cms/upgrade_module/templates', __FILE__)
19
+
20
+ def self.common_options
21
+ method_option :database, :aliases => "-d", :desc => "Preconfigure for selected database (options: mysql/oracle/postgresql/sqlite3/frontbase/ibm_db) [Default: sqlite3]"
22
+ method_option :template, :aliases => "-m", :desc => "Path to an application template (can be a filesystem path or URL)"
23
+ end
24
+
25
+ desc "new", "Creates a blank BrowserCMS project with a single default template. Suitable for starting a new website project."
26
+ common_options
27
+ def new(name)
28
+ create_blank_cms_project(name)
29
+ echo_next_steps(name)
30
+ end
31
+
32
+
33
+ desc 'demo', "Generates a BrowserCMS application with a sample demo website. Suitable for learning BrowserCMS."
34
+ common_options
35
+ def demo(name)
36
+ create_blank_cms_project(name)
37
+ generate "browser_cms:demo_site"
38
+ echo_next_steps(name)
39
+ end
40
+
41
+
42
+ desc 'module', "Generates a BrowserCMS module for sharing code between BrowserCMS projects. (Name must start with bcms_)"
43
+ common_options
44
+ def module(name)
45
+ create_blank_cms_project(name)
46
+ generate 'cms:upgrade_module', name
47
+ template 'COPYRIGHT.txt'
48
+ template 'LICENSE.txt'
49
+ template 'GPL.txt'
50
+ echo_next_steps(name)
51
+ end
52
+
53
+ desc 'version', 'Show BrowserCMS version'
54
+ map "-v" => :version, "--version" => :version
55
+ def version
56
+ puts "BrowserCMS #{Cms::VERSION}"
57
+ end
58
+
59
+ private
60
+
61
+ def start_working_in_rails_directory(name)
62
+ self.destination_root = (File.join(destination_root, name))
63
+ end
64
+
65
+ def create_rails_app(name)
66
+ rails_cmd = "rails new #{name}"
67
+ if options[:template]
68
+ rails_cmd += " -m #{options[:template]}"
69
+ end
70
+ if options[:database]
71
+ rails_cmd += " -d #{options[:database]}"
72
+ end
73
+ run(rails_cmd)
74
+ end
75
+
76
+
77
+ def echo_next_steps(name)
78
+ puts "\nCreated new BrowserCMS project '#{name}'."
79
+ puts " To get started, type 'cd #{name}'"
80
+ puts " then type 'rake db:install'"
81
+ puts " then type 'rails server' and open your browser to 'http://localhost:3000'."
82
+ end
83
+
84
+ def create_blank_cms_project(name)
85
+ create_rails_app(name)
86
+ start_working_in_rails_directory(name)
87
+
88
+ # Unsure if this handles windows specific removal of files
89
+ remove_file("public/index.html")
90
+ remove_file("db/seeds.rb")
91
+
92
+ gem 'browsercms', :version=>::Cms::VERSION
93
+
94
+ generate :jdbc if defined?(JRUBY_VERSION)
95
+ route "routes_for_browser_cms"
96
+
97
+ generate "browser_cms:cms"
98
+ environment 'SITE_DOMAIN="localhost:3000"', :env => "development"
99
+ environment 'SITE_DOMAIN="localhost:3000"', :env => "test"
100
+ environment 'SITE_DOMAIN="localhost:3000"', :env => "production"
101
+
102
+ insert_into_file "config/environments/production.rb", :after => "Application.configure do\n" do
103
+ <<-CODE
104
+ config.action_view.cache_template_loading = false
105
+ config.action_controller.page_cache_directory = Rails.root + '/public/cache/'
106
+ CODE
107
+ end
108
+ initializer 'browsercms.rb', <<-CODE
109
+ Cms.attachment_file_permission = 0640
110
+ CODE
111
+
112
+ generate "cms:template", "default"
113
+ end
114
+ end
115
+
116
+ App.start
5
117
 
6
- load File.join(File.dirname(__FILE__), 'browsercms')
@@ -1,73 +1,4 @@
1
- #!/usr/bin/env ruby
1
+ ##!/usr/bin/env ruby
2
2
 
3
- ##
4
- # A fancy wrapper around 'rails' that creates a BrowserCMS project.
5
- #
6
- require File.join(File.dirname(__FILE__), "..", 'lib/command_line')
7
- require 'optparse'
8
-
9
-
10
- ARGV << "-h" if ARGV.empty?
11
-
12
- # Using optsparse primarily for help messages, since most options just get passed directly to rails.
13
- options = {}
14
- ARGV.clone.options do |opts|
15
- opts.banner = "Usage: browsercms /path/to/your/cms/project [options]"
16
-
17
- # While Rails supports more databases, BrowserCMS has really only been tested against the following:
18
- opts.on("-d", "--database=name", String, "Preconfigure for selected database (options: mysql/postgresql/sqlite3)", "Default: sqlite3")
19
- opts.on("-m", "--template=path", String, "BrowserCMS application type to create (options: module, demo)", "Default: blank")
20
-
21
- opts.separator(" ")
22
- opts.separator("BrowserCMS Info:")
23
- opts.on("-h", "--help", String, "Show this help message and quit.") { puts opts; exit }
24
- opts.on("-v", "--version", String, "Shows the rails version number and quit.") { system("rails -v"); exit }
25
-
26
- # These are copy&paste from the 'rails' options. Repeated here because I'm not sure its possible to reuse their options automatically.
27
- opts.separator(" ")
28
- opts.separator("Rails Options:")
29
- opts.on("-r", "--ruby=path", String, "Path to the Ruby binary of your choice (otherwise scripts use env, dispatchers current path).", "Default: /usr/local/bin/ruby")
30
- opts.on("-D", "--with-dispatchers", "Add CGI/FastCGI/mod_ruby dispatches code to generated application skeleton", "Default: false")
31
- opts.on("-f", "--freeze", "Freeze Rails in vendor/rails from the gems generating the skeleton.", "Default: false")
32
- opts.on("-p", "--pretend", "Run but do not make any changes.")
33
- opts.on("--force", "--force", "Overwrite files that already exist.")
34
- opts.on("-s", "--skip", "Skip files that already exist.")
35
- opts.on("-q", "--quiet", "Suppress normal output.")
36
- opts.on("-t", "--backtrace", "Debugging: show backtrace on errors.")
37
- opts.on("-c", "--svn", "Modify files with subversion. (Note: svn must be in path)")
38
- opts.on("-g", "--git", "Modify files with git. (Note: git must be in path)")
39
-
40
- opts.separator(" ")
41
- opts.separator("Description:")
42
- opts.separator(" The 'browsercms' command creates a new BrowserCMS application with a default directory structure ")
43
- opts.separator(" and configuration at the path you specify. It will create and migrate the database with the schema")
44
- opts.separator(" and seed data.")
45
- opts.separator(" ")
46
- opts.separator("Example:")
47
- opts.separator(" browsercms ~/projects/website_name")
48
- opts.separator(" This generates a blank BrowserCMS project. Suitable for starting a new website project.")
49
- opts.separator(" ")
50
- opts.separator(" browsercms website_name -m demo")
51
- opts.separator(" Generates a BrowserCMS application with a sample demo website. Suitable for learning BrowserCMS.")
52
- opts.separator(" ")
53
- opts.separator(" browsercms bcms_my_module -m module")
54
- opts.separator(" Generates a BrowserCMS module. Used to create code that can be shared between BrowserCMS projects.")
55
- opts.separator(" (Note: Module name MUST start with 'bcms_'.)")
56
-
57
- opts.parse!
58
- end
59
-
60
- # Replace short hand versions of the templates with the absolute path on the local machine.
61
- CommandLine.set_template(ARGV)
62
- command = (RUBY_PLATFORM =~ /mswin32/ ? "cmd /c " : "")
63
- command += "rails new #{ARGV.join(" ")}"
64
- success = system(command)
65
-
66
- project_name = ARGV[0]
67
- if (success)
68
- puts "\nCreated new BrowserCMS project '#{project_name}'."
69
- puts " To get started, type 'cd #{project_name}'"
70
- puts " then 'rails server' and open your browser to 'http://localhost:3000'."
71
- else
72
- puts "\n Unable to create BrowserCMS project '#{project_name}'."
73
- end
3
+ # Alias to bcms CLI
4
+ load File.join(File.dirname(__FILE__), 'bcms')
@@ -22,6 +22,7 @@ Gem::Specification.new do |s|
22
22
 
23
23
  s.files = Dir["rails/*.rb"]
24
24
  s.files += Dir["browsercms.gemspec"]
25
+ s.files += Dir[".yardopts"]
25
26
  s.files += Dir["doc/app/**/*"]
26
27
  s.files += Dir["doc/guides/html/**/*"]
27
28
  s.files += Dir["app/**/*"]
@@ -29,6 +30,8 @@ Gem::Specification.new do |s|
29
30
  s.files += Dir["db/demo/**/*"]
30
31
  s.files += Dir["db/seeds.rb"]
31
32
  s.files += Dir["lib/**/*"]
33
+ s.files -= Dir["lib/tasks/cucumber.rake"]
34
+ s.files -= Dir["lib/tasks/cms.rake"]
32
35
  s.files += Dir["public/stylesheets/cms/**/*"]
33
36
  s.files += Dir["public/javascripts/jquery*"]
34
37
  s.files += Dir["public/javascripts/cms/**/*"]
@@ -36,10 +39,9 @@ Gem::Specification.new do |s|
36
39
  s.files += Dir["public/site/**/*"]
37
40
  s.files += Dir["public/images/cms/**/*"]
38
41
  s.files += Dir["public/themes/**/*"]
39
- s.files += Dir["templates/*.rb"]
40
42
  s.files -= Dir['test/dummy/*']
41
43
 
42
- s.add_dependency('rails', "~> 3.0.5")
44
+ s.add_dependency('rails', "~> 3.0.7")
43
45
 
44
46
  # Required only for bcms-upgrade
45
47
  s.add_dependency('term-ansicolor')
@@ -10,9 +10,8 @@ module Cms
10
10
  !!@uses_soft_delete
11
11
  end
12
12
 
13
- def handle_missing_table_error_during_startup(e)
14
- puts e.inspect
15
- Rails.logger.info e.inspect
13
+ def handle_missing_table_error_during_startup(message, e)
14
+ Rails.logger.debug "#{message}: #{e.inspect}"
16
15
  end
17
16
 
18
17
  def uses_soft_delete(options={})
@@ -29,9 +28,9 @@ module Cms
29
28
  # By default, all queries for blocks should filter out deleted rows.
30
29
  begin
31
30
  default_scope where(:deleted => false)
32
- # This may fail during gem loading, if no DB exists. Log it and move on.
31
+ # This may fail during gem loading, if no DB or the table does not exist. Log it and move on.
33
32
  rescue StandardError => e
34
- handle_missing_table_error_during_startup(e)
33
+ handle_missing_table_error_during_startup("Can't set a default_scope for soft_deleting", e)
35
34
  end
36
35
  end
37
36
  end
@@ -1,6 +1,7 @@
1
1
  module Cms
2
2
  module Extensions
3
3
  module ActiveRecord
4
+
4
5
  module Base
5
6
  def updated_on_string(fmt="%b %e, %Y")
6
7
  if respond_to?(:updated_at) && updated_at
@@ -10,7 +11,27 @@ module Cms
10
11
  end
11
12
  end
12
13
  end
14
+
15
+ module ClassMethods
16
+ # Determines if the database for this Rails App exists yet. Useful for methods which might be called during
17
+ # rake tasks or initialize where a database not yet being created is not fatal, but should be ignored.
18
+ #
19
+ # @return [Boolean] false if it does not exist.
20
+ def database_exists?
21
+ begin
22
+ connection
23
+ return true
24
+ rescue StandardError # Hopefully this works with MySql, MySql2 and SQLite
25
+ logger.warn "Attempted to establish a connection with the database, but could not do so."
26
+ return false
27
+ end
28
+
29
+ end
30
+ end
13
31
  end
14
32
  end
15
33
  end
16
- ActiveRecord::Base.send(:include, Cms::Extensions::ActiveRecord::Base)
34
+ ActiveRecord::Base.send(:include, Cms::Extensions::ActiveRecord::Base)
35
+ ActiveRecord::Base.extend(Cms::Extensions::ActiveRecord::ClassMethods)
36
+
37
+
@@ -4,7 +4,7 @@ module Cms::Routes
4
4
  # Adds all necessary routes to manage a new content type. Works very similar to the Rails _resources_ method, adding basic CRUD routes, as well as additional ones
5
5
  # for CMS specific routes (like versioning)
6
6
  #
7
- # @params [Symbol] content_block_name - The plural name of a new Content Type. Should match the name of the content_block, like :dogs or :donation_statuses
7
+ # @param [Symbol] content_block_name - The plural name of a new Content Type. Should match the name of the content_block, like :dogs or :donation_statuses
8
8
  def content_blocks(content_block_name, options={}, & block)
9
9
  content_block = content_block_name.to_s.classify.constantize
10
10
  resources content_block_name do
@@ -126,16 +126,13 @@ module Cms::Routes
126
126
  get 'cache', :to=>'cache#show', :as=>'cache'
127
127
  delete 'cache', :to=>'cache#destroy'
128
128
 
129
- # This is only for testing, and should be moved to the config/routes.rb file eventually.
130
- # content_blocks :sample_blocks
131
-
132
129
  match "/routes", :to => "routes#index", :as=>'routes'
133
130
 
134
131
  end
135
132
 
136
133
  # Loads all Cms PageRoutes from the database
137
134
  # TODO: Needs a integration/functional level test to verify that a page route w/ constraints will be correctly mapped.
138
- if PageRoute.table_exists?
135
+ if PageRoute.can_be_loaded?
139
136
  PageRoute.all(:order => "page_routes.name").each do |r|
140
137
  match r.pattern, :to=>r.to, :as=>r.route_name, :_page_route_id=>r.page_route_id, :via=>r.via, :constraints=>r.constraints
141
138
  end