Allows the precise version of BrowserCMS to be determined programmatically.
SPEC | = | eval(File.read(__root__ + '/browsercms.gemspec')) |
VERSION | = | "3.1.0" |
attachment_file_permission | [RW] |
This is used by CMS modules to register with the CMS generator which files should be copied over to the app when the CMS generator is run. src_root is the absolute path to the root of the files, then each argument after that is a Dir.glob pattern string.
# File lib/cms/init.rb, line 44 44: def add_generator_paths(src_root, *files) 45: generator_paths << [src_root, files] 46: end
# File lib/cms/init.rb, line 52 52: def add_to_rails_paths(path) 53: ActiveSupport::Dependencies.load_paths << File.join(path, "app", "portlets") 54: end
This is called after the environment is ready
# File lib/cms/init.rb, line 22 22: def init 23: ActionController::Routing::RouteSet::Mapper.send :include, Cms::Routes 24: ActiveSupport::Dependencies.load_paths += ??( #{RAILS_ROOT}/app/portlets ) 25: ActiveSupport::Dependencies.load_paths += ??( #{RAILS_ROOT}/app/portlets/helpers ) 26: ActionController::Base.append_view_path DynamicView.base_path 27: ActionView::Base.default_form_builder = Cms::FormBuilder 28: 29: # ActiveRecord JDBC adapter depends on no database connection having 30: # been established to work properly. 31: require 'jdbc_adapter' if defined?(JRUBY_VERSION) 32: 33: # This is just to be safe 34: # dynamic views are stored in a tmp dir 35: # so they could be blown away on a server restart or something 36: # so this just makes sure they get written out 37: DynamicView.write_all_to_disk! if DynamicView.table_exists? 38: end
# File lib/cms/init.rb, line 17 17: def load_rake_tasks 18: load "#{Cms.root}/lib/tasks/cms.rake" 19: end
# File lib/cms/init.rb, line 75 75: def reserved_paths 76: @reserved_paths ||= ["/cms", "/cache"] 77: end
This next ‘hack’ is to allow script/generate browser_cms to work on Windows machines. I‘m not sure why this is necessary.
This Generator is adding an absolute file path to the manifest, which is file (like a .js or migration) in the gem directory on the developers‘s machine, rather than just a relative path with the rails_generator directory. On windows, this will mean you are basically doing this.
m.file "C:/Ruby/lib/ruby/gems/1.8/gems/browsercms-3.0.0/public/javascripts/jquery-ui.js", "testing/jquery-ui.js"
When the generator hits this command during playback, it will throw an error like this:
Pattern 'c' matches more than one generator: content_block, controller
The generator then fails and stops copying. Stripping the C: off the front seems to fix this problem. I.e. This command correctly copies the file on Windows XP.
m.file "/Ruby/lib/ruby/gems/1.8/gems/browsercms-3.0.0/public/javascripts/jquery-ui.js", "testing/jquery-ui.js"
# File lib/cms/init.rb, line 93 93: def scrub_path(path) 94: windows_drive_pattern = /\b[A-Za-z]:\// # Works on drives labeled A-Z: 95: scrubbed_source_file_name = path.gsub(windows_drive_pattern, "/") 96: end
# File lib/cms/init.rb, line 63 63: def wysiwig_js 64: @wysiwig_js ||= ['/bcms/ckeditor/ckeditor.js', '/bcms/ckeditor/editor.js'] 65: end