Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

pull out extension manager

  • Loading branch information...
commit 0466375e4e75ffa59c5b2c182d7aff75caf2c91a 1 parent 0101442
Jim Gay saturnflyer authored
Showing with 309 additions and 13 deletions.
  1. +0 −13 lib/radiant/admin_ui.rb
  2. +3 −0  vendor/extensions/extension_manager/README
  3. +136 −0 vendor/extensions/extension_manager/Rakefile
  4. 0  { → vendor/extensions/extension_manager}/app/controllers/admin/extensions_controller.rb
  5. 0  { → vendor/extensions/extension_manager}/app/helpers/admin/extensions_helper.rb
  6. 0  { → vendor/extensions/extension_manager}/app/views/admin/extensions/index.html.haml
  7. +3 −0  vendor/extensions/extension_manager/config/locales/en.yml
  8. +5 −0 vendor/extensions/extension_manager/config/routes.rb
  9. +1 −0  vendor/extensions/extension_manager/cucumber.yml
  10. +28 −0 vendor/extensions/extension_manager/extension_manager_extension.rb
  11. +22 −0 vendor/extensions/extension_manager/features/support/env.rb
  12. +14 −0 vendor/extensions/extension_manager/features/support/paths.rb
  13. +55 −0 vendor/extensions/extension_manager/lib/tasks/extension_manager_extension_tasks.rake
  14. 0  { → vendor/extensions/extension_manager}/spec/controllers/admin/extensions_controller_spec.rb
  15. 0  { → vendor/extensions/extension_manager}/spec/helpers/admin/extensions_helper_spec.rb
  16. +6 −0 vendor/extensions/extension_manager/spec/spec.opts
  17. +36 −0 vendor/extensions/extension_manager/spec/spec_helper.rb
13 lib/radiant/admin_ui.rb
View
@@ -139,17 +139,12 @@ def load_default_nav
design << nav_item("Layouts", "/admin/layouts")
design << nav_item("Snippets", "/admin/snippets")
nav << design
-
- settings = nav_tab("Settings")
- settings << nav_item("Extensions", "/admin/extensions")
- nav << settings
end
def load_default_regions
@page = load_default_page_regions
@snippet = load_default_snippet_regions
@layout = load_default_layout_regions
- @extension = load_default_extension_regions
end
private
@@ -204,13 +199,5 @@ def load_default_layout_regions
end
end
- def load_default_extension_regions
- returning OpenStruct.new do |extension|
- extension.index = RegionSet.new do |index|
- index.thead.concat %w{title_header website_header version_header}
- index.tbody.concat %w{title_cell website_cell version_cell}
- end
- end
- end
end
end
3  vendor/extensions/extension_manager/README
View
@@ -0,0 +1,3 @@
+= Extension Manager
+
+This provides the standard view of installed extensions for Radiant
136 vendor/extensions/extension_manager/Rakefile
View
@@ -0,0 +1,136 @@
+begin
+ require 'jeweler'
+ Jeweler::Tasks.new do |gem|
+ gem.name = "radiant-extension_manager-extension"
+ gem.summary = %Q{Extension Manager Extension for Radiant CMS}
+ gem.description = %Q{Describe your extension here}
+ gem.email = "jim@saturnflyer.com"
+ gem.homepage = "http://github.com/saturnflyer/radiant-extension_manager-extension"
+ gem.authors = ["Jim Gay"]
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
+ end
+rescue LoadError
+ puts "Jeweler (or a dependency) not available. This is only required if you plan to package extension_manager as a gem."
+end
+
+# In rails 1.2, plugins aren't available in the path until they're loaded.
+# Check to see if the rspec plugin is installed first and require
+# it if it is. If not, use the gem version.
+
+# Determine where the RSpec plugin is by loading the boot
+unless defined? RADIANT_ROOT
+ ENV["RAILS_ENV"] = "test"
+ case
+ when ENV["RADIANT_ENV_FILE"]
+ require File.dirname(ENV["RADIANT_ENV_FILE"]) + "/boot"
+ when File.dirname(__FILE__) =~ %r{vendor/radiant/vendor/extensions}
+ require "#{File.expand_path(File.dirname(__FILE__) + "/../../../../../")}/config/boot"
+ else
+ require "#{File.expand_path(File.dirname(__FILE__) + "/../../../")}/config/boot"
+ end
+end
+
+require 'rake'
+require 'rake/rdoctask'
+require 'rake/testtask'
+
+rspec_base = File.expand_path(RADIANT_ROOT + '/vendor/plugins/rspec/lib')
+$LOAD_PATH.unshift(rspec_base) if File.exist?(rspec_base)
+require 'spec/rake/spectask'
+require 'cucumber'
+require 'cucumber/rake/task'
+
+# Cleanup the RADIANT_ROOT constant so specs will load the environment
+Object.send(:remove_const, :RADIANT_ROOT)
+
+extension_root = File.expand_path(File.dirname(__FILE__))
+
+task :default => :spec
+task :stats => "spec:statsetup"
+
+desc "Run all specs in spec directory"
+Spec::Rake::SpecTask.new(:spec) do |t|
+ t.spec_opts = ['--options', "\"#{extension_root}/spec/spec.opts\""]
+ t.spec_files = FileList['spec/**/*_spec.rb']
+end
+
+task :features => 'spec:integration'
+
+namespace :spec do
+ desc "Run all specs in spec directory with RCov"
+ Spec::Rake::SpecTask.new(:rcov) do |t|
+ t.spec_opts = ['--options', "\"#{extension_root}/spec/spec.opts\""]
+ t.spec_files = FileList['spec/**/*_spec.rb']
+ t.rcov = true
+ t.rcov_opts = ['--exclude', 'spec', '--rails']
+ end
+
+ desc "Print Specdoc for all specs"
+ Spec::Rake::SpecTask.new(:doc) do |t|
+ t.spec_opts = ["--format", "specdoc", "--dry-run"]
+ t.spec_files = FileList['spec/**/*_spec.rb']
+ end
+
+ [:models, :controllers, :views, :helpers].each do |sub|
+ desc "Run the specs under spec/#{sub}"
+ Spec::Rake::SpecTask.new(sub) do |t|
+ t.spec_opts = ['--options', "\"#{extension_root}/spec/spec.opts\""]
+ t.spec_files = FileList["spec/#{sub}/**/*_spec.rb"]
+ end
+ end
+
+ desc "Run the Cucumber features"
+ Cucumber::Rake::Task.new(:integration) do |t|
+ t.fork = true
+ t.cucumber_opts = ['--format', (ENV['CUCUMBER_FORMAT'] || 'progress')]
+ # t.feature_pattern = "#{extension_root}/features/**/*.feature"
+ t.profile = "default"
+ end
+
+ # Setup specs for stats
+ task :statsetup do
+ require 'code_statistics'
+ ::STATS_DIRECTORIES << %w(Model\ specs spec/models)
+ ::STATS_DIRECTORIES << %w(View\ specs spec/views)
+ ::STATS_DIRECTORIES << %w(Controller\ specs spec/controllers)
+ ::STATS_DIRECTORIES << %w(Helper\ specs spec/views)
+ ::CodeStatistics::TEST_TYPES << "Model specs"
+ ::CodeStatistics::TEST_TYPES << "View specs"
+ ::CodeStatistics::TEST_TYPES << "Controller specs"
+ ::CodeStatistics::TEST_TYPES << "Helper specs"
+ ::STATS_DIRECTORIES.delete_if {|a| a[0] =~ /test/}
+ end
+
+ namespace :db do
+ namespace :fixtures do
+ desc "Load fixtures (from spec/fixtures) into the current environment's database. Load specific fixtures using FIXTURES=x,y"
+ task :load => :environment do
+ require 'active_record/fixtures'
+ ActiveRecord::Base.establish_connection(RAILS_ENV.to_sym)
+ (ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/) : Dir.glob(File.join(RAILS_ROOT, 'spec', 'fixtures', '*.{yml,csv}'))).each do |fixture_file|
+ Fixtures.create_fixtures('spec/fixtures', File.basename(fixture_file, '.*'))
+ end
+ end
+ end
+ end
+end
+
+desc 'Generate documentation for the extension_manager extension.'
+Rake::RDocTask.new(:rdoc) do |rdoc|
+ rdoc.rdoc_dir = 'rdoc'
+ rdoc.title = 'ExtensionManagerExtension'
+ rdoc.options << '--line-numbers' << '--inline-source'
+ rdoc.rdoc_files.include('README')
+ rdoc.rdoc_files.include('lib/**/*.rb')
+end
+
+# For extensions that are in transition
+desc 'Test the extension_manager extension.'
+Rake::TestTask.new(:test) do |t|
+ t.libs << 'lib'
+ t.pattern = 'test/**/*_test.rb'
+ t.verbose = true
+end
+
+# Load any custom rakefiles for extension
+Dir[File.dirname(__FILE__) + '/tasks/*.rake'].sort.each { |f| require f }
0  app/controllers/admin/extensions_controller.rb → ...er/app/controllers/admin/extensions_controller.rb
View
File renamed without changes
0  app/helpers/admin/extensions_helper.rb → ...on_manager/app/helpers/admin/extensions_helper.rb
View
File renamed without changes
0  app/views/admin/extensions/index.html.haml → ...anager/app/views/admin/extensions/index.html.haml
View
File renamed without changes
3  vendor/extensions/extension_manager/config/locales/en.yml
View
@@ -0,0 +1,3 @@
+---
+en:
+ extension manager: Extension Manager
5 vendor/extensions/extension_manager/config/routes.rb
View
@@ -0,0 +1,5 @@
+ActionController::Routing::Routes.draw do |map|
+ map.namespace :admin do |admin|
+ admin.resources :extensions, :only => :index
+ end
+end
1  vendor/extensions/extension_manager/cucumber.yml
View
@@ -0,0 +1 @@
+default: --format progress features --tags ~@proposed,~@in_progress
28 vendor/extensions/extension_manager/extension_manager_extension.rb
View
@@ -0,0 +1,28 @@
+# Uncomment this if you reference any of your controllers in activate
+# require_dependency 'application_controller'
+
+class ExtensionManagerExtension < Radiant::Extension
+ version "1.0"
+ description "Standard view of extensions"
+ url "http://github.com/radiant/radiant-extension_manager-extension"
+
+ def activate
+ tab 'Settings' do
+ add_item "Extensions", "/admin/extensions"
+ end
+
+ Radiant::AdminUI.class_eval {
+ attr_accessor :extensions
+
+ def load_default_extension_regions
+ returning OpenStruct.new do |extension|
+ extension.index = Radiant::AdminUI::RegionSet.new do |index|
+ index.thead.concat %w{title_header website_header version_header}
+ index.tbody.concat %w{title_cell website_cell version_cell}
+ end
+ end
+ end
+ }
+ admin.extensions = Radiant::AdminUI.load_default_extension_regions
+ end
+end
22 vendor/extensions/extension_manager/features/support/env.rb
View
@@ -0,0 +1,22 @@
+# Sets up the Rails environment for Cucumber
+ENV["RAILS_ENV"] = "test"
+# Extension root
+extension_env = File.expand_path(File.dirname(__FILE__) + '/../../../../../config/environment')
+require extension_env+'.rb'
+
+require 'cucumber/formatter/unicode' # Remove this line if you don't want Cucumber Unicode support
+require 'cucumber/rails/rspec'
+require 'cucumber/rails/world'
+require 'cucumber/rails/active_record'
+require 'cucumber/web/tableish'
+
+Dir.glob(File.join(RADIANT_ROOT, "features", "**", "*.rb")).each {|step| require step}
+
+Cucumber::Rails::World.class_eval do
+ include Dataset
+ datasets_directory "#{RADIANT_ROOT}/spec/datasets"
+ Dataset::Resolver.default = Dataset::DirectoryResolver.new("#{RADIANT_ROOT}/spec/datasets", File.dirname(__FILE__) + '/../../spec/datasets', File.dirname(__FILE__) + '/../datasets')
+ self.datasets_database_dump_path = "#{Rails.root}/tmp/dataset"
+
+ # dataset :extension_manager
+end
14 vendor/extensions/extension_manager/features/support/paths.rb
View
@@ -0,0 +1,14 @@
+def path_to(page_name)
+ case page_name
+
+ when /the homepage/i
+ root_path
+
+ when /login/i
+ login_path
+ # Add more page name => path mappings here
+
+ else
+ raise "Can't find mapping from \"#{page_name}\" to a path."
+ end
+end
55 vendor/extensions/extension_manager/lib/tasks/extension_manager_extension_tasks.rake
View
@@ -0,0 +1,55 @@
+namespace :radiant do
+ namespace :extensions do
+ namespace :extension_manager do
+
+ desc "Runs the migration of the Extension Manager extension"
+ task :migrate => :environment do
+ require 'radiant/extension_migrator'
+ if ENV["VERSION"]
+ ExtensionManagerExtension.migrator.migrate(ENV["VERSION"].to_i)
+ Rake::Task['db:schema:dump'].invoke
+ else
+ ExtensionManagerExtension.migrator.migrate
+ Rake::Task['db:schema:dump'].invoke
+ end
+ end
+
+ desc "Copies public assets of the Extension Manager to the instance public/ directory."
+ task :update => :environment do
+ is_svn_or_dir = proc {|path| path =~ /\.svn/ || File.directory?(path) }
+ puts "Copying assets from ExtensionManagerExtension"
+ Dir[ExtensionManagerExtension.root + "/public/**/*"].reject(&is_svn_or_dir).each do |file|
+ path = file.sub(ExtensionManagerExtension.root, '')
+ directory = File.dirname(path)
+ mkdir_p RAILS_ROOT + directory, :verbose => false
+ cp file, RAILS_ROOT + path, :verbose => false
+ end
+ unless ExtensionManagerExtension.root.starts_with? RAILS_ROOT # don't need to copy vendored tasks
+ puts "Copying rake tasks from ExtensionManagerExtension"
+ local_tasks_path = File.join(RAILS_ROOT, %w(lib tasks))
+ mkdir_p local_tasks_path, :verbose => false
+ Dir[File.join ExtensionManagerExtension.root, %w(lib tasks *.rake)].each do |file|
+ cp file, local_tasks_path, :verbose => false
+ end
+ end
+ end
+
+ desc "Syncs all available translations for this ext to the English ext master"
+ task :sync => :environment do
+ # The main translation root, basically where English is kept
+ language_root = ExtensionManagerExtension.root + "/config/locales"
+ words = TranslationSupport.get_translation_keys(language_root)
+
+ Dir["#{language_root}/*.yml"].each do |filename|
+ next if filename.match('_available_tags')
+ basename = File.basename(filename, '.yml')
+ puts "Syncing #{basename}"
+ (comments, other) = TranslationSupport.read_file(filename, basename)
+ words.each { |k,v| other[k] ||= words[k] } # Initializing hash variable as empty if it does not exist
+ other.delete_if { |k,v| !words[k] } # Remove if not defined in en.yml
+ TranslationSupport.write_file(filename, basename, comments, other)
+ end
+ end
+ end
+ end
+end
0  spec/controllers/admin/extensions_controller_spec.rb → ...c/controllers/admin/extensions_controller_spec.rb
View
File renamed without changes
0  spec/helpers/admin/extensions_helper_spec.rb → ...ager/spec/helpers/admin/extensions_helper_spec.rb
View
File renamed without changes
6 vendor/extensions/extension_manager/spec/spec.opts
View
@@ -0,0 +1,6 @@
+--colour
+--format
+progress
+--loadby
+mtime
+--reverse
36 vendor/extensions/extension_manager/spec/spec_helper.rb
View
@@ -0,0 +1,36 @@
+unless defined? RADIANT_ROOT
+ ENV["RAILS_ENV"] = "test"
+ case
+ when ENV["RADIANT_ENV_FILE"]
+ require ENV["RADIANT_ENV_FILE"]
+ when File.dirname(__FILE__) =~ %r{vendor/radiant/vendor/extensions}
+ require "#{File.expand_path(File.dirname(__FILE__) + "/../../../../../../")}/config/environment"
+ else
+ require "#{File.expand_path(File.dirname(__FILE__) + "/../../../../")}/config/environment"
+ end
+end
+require "#{RADIANT_ROOT}/spec/spec_helper"
+
+Dataset::Resolver.default << (File.dirname(__FILE__) + "/datasets")
+
+if File.directory?(File.dirname(__FILE__) + "/matchers")
+ Dir[File.dirname(__FILE__) + "/matchers/*.rb"].each {|file| require file }
+end
+
+Spec::Runner.configure do |config|
+ # config.use_transactional_fixtures = true
+ # config.use_instantiated_fixtures = false
+ # config.fixture_path = RAILS_ROOT + '/spec/fixtures'
+
+ # You can declare fixtures for each behaviour like this:
+ # describe "...." do
+ # fixtures :table_a, :table_b
+ #
+ # Alternatively, if you prefer to declare them only once, you can
+ # do so here, like so ...
+ #
+ # config.global_fixtures = :table_a, :table_b
+ #
+ # If you declare global fixtures, be aware that they will be declared
+ # for all of your examples, even those that don't use them.
+end
Please sign in to comment.
Something went wrong with that request. Please try again.