diff --git a/app/controllers/admin/official_module_controller.rb b/app/controllers/admin/official_module_controller.rb index 9854f3f..e5f8ab6 100644 --- a/app/controllers/admin/official_module_controller.rb +++ b/app/controllers/admin/official_module_controller.rb @@ -1,5 +1,6 @@ class Admin::OfficialModuleController < OrbitAdminController - + layout "structure" + def set_master_key @master_password = MasterPassword.first rescue nil if @master_password.nil? diff --git a/app/controllers/official_module/application_controller.rb b/app/controllers/official_module/application_controller.rb deleted file mode 100644 index ef4998b..0000000 --- a/app/controllers/official_module/application_controller.rb +++ /dev/null @@ -1,5 +0,0 @@ -module OfficialModule - class ApplicationController < ActionController::Base - protect_from_forgery with: :exception - end -end diff --git a/app/views/admin/sites/set_master_key.html.erb b/app/views/admin/official_module/set_master_key.html.erb similarity index 100% rename from app/views/admin/sites/set_master_key.html.erb rename to app/views/admin/official_module/set_master_key.html.erb diff --git a/config/routes.rb b/config/routes.rb index 4d915e8..73d5205 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -7,11 +7,13 @@ Rails.application.routes.draw do get "/store/form_token" => 'client_sites#get_csrf_token' - - namespace :admin do - resources :sites, only: [] do - get "set_master_key" => 'official_module#set_master_key' - patch "update_master_password" => 'official_module#update_master_password' + locales = Site.first.in_use_locales rescue I18n.available_locales + scope "(:locale)", locale: Regexp.new(locales.join("|")) do + namespace :admin do + scope "sites/:id", :controller => 'official_module' do + get "set_master_key" => 'official_module#set_master_key', as: :site_set_master_key + patch "update_master_password" => 'official_module#update_master_password' + end end end end diff --git a/lib/official_module/engine.rb b/lib/official_module/engine.rb index e1bd33c..9f36694 100644 --- a/lib/official_module/engine.rb +++ b/lib/official_module/engine.rb @@ -2,7 +2,6 @@ module OfficialModule class Engine < ::Rails::Engine initializer "official_module" do OrbitApp.registration "OfficialModule", :type => "ModuleApp" do - module_label "official_module.official_module" base_url File.expand_path File.dirname(__FILE__) set_keyword_contstraints ['/store/check_module_permissions', '/store/register_old_sites_modules', diff --git a/official_module.gemspec b/official_module.gemspec index aebd91c..1e08edf 100644 --- a/official_module.gemspec +++ b/official_module.gemspec @@ -1,23 +1,37 @@ -$:.push File.expand_path("../lib", __FILE__) - -# Maintain your gem's version: -require "official_module/version" - -# Describe your gem and declare its dependencies: -Gem::Specification.new do |s| - s.name = "official_module" - s.version = OfficialModule::VERSION - s.authors = ["Harry Bomrah"] - s.email = ["harry@rulingcom.com"] - s.homepage = "http://www.rulingcom.com" - s.summary = "Summary of OfficialModule." - s.description = "Description of OfficialModule." - s.license = "MIT" - - s.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.rdoc"] - s.test_files = Dir["test/**/*"] - - s.add_dependency "rails", "~> 4.1.16" - - s.add_development_dependency "sqlite3" -end +$:.push File.expand_path("../lib", __FILE__) + +# Maintain your gem's version: +require "official_module/version" +bundle_update_flag = ARGV[0]=='update' || ARGV[0]=='install' +if bundle_update_flag + app_path = File.expand_path(__dir__) + #Add official module to Admin area + official_module_li = File.read(app_path+"/official_module_li.erb") + file_text = File.read(ENV['PWD']+'/app/views/shared/_side_bar.html.erb') + if !file_text.include?('master_key') + insert_index = file_text.index('
  • ') + file_text.insert(insert_index , official_module_li) + end + f = File.open(ENV['PWD']+'/app/views/shared/_side_bar.html.erb','w') + f.write(file_text) + f.close + puts "finish change official module in #{ENV['PWD']}/app/views/shared" +end +# Describe your gem and declare its dependencies: +Gem::Specification.new do |s| + s.name = "official_module" + s.version = OfficialModule::VERSION + s.authors = ["Harry Bomrah"] + s.email = ["harry@rulingcom.com"] + s.homepage = "http://www.rulingcom.com" + s.summary = "Summary of OfficialModule." + s.description = "Description of OfficialModule." + s.license = "MIT" + + s.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.rdoc"] + s.test_files = Dir["test/**/*"] + + s.add_dependency "rails", "~> 4.1.16" + + s.add_development_dependency "sqlite3" +end diff --git a/official_module_li.erb b/official_module_li.erb new file mode 100644 index 0000000..c0fa07e --- /dev/null +++ b/official_module_li.erb @@ -0,0 +1 @@ +
  • <%= link_to admin_site_set_master_key_path(current_site), :class => active_for_action('sites', 'preference') do %><%end%>
  • \ No newline at end of file