fix some errors

This commit is contained in:
BOYA,CHIU 2021-07-15 18:59:12 +08:00
parent f200ef507c
commit df79763000
7 changed files with 47 additions and 35 deletions

View File

@ -1,4 +1,5 @@
class Admin::OfficialModuleController < OrbitAdminController class Admin::OfficialModuleController < OrbitAdminController
layout "structure"
def set_master_key def set_master_key
@master_password = MasterPassword.first rescue nil @master_password = MasterPassword.first rescue nil

View File

@ -1,5 +0,0 @@
module OfficialModule
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
end
end

View File

@ -7,11 +7,13 @@ Rails.application.routes.draw do
get "/store/form_token" => 'client_sites#get_csrf_token' get "/store/form_token" => 'client_sites#get_csrf_token'
locales = Site.first.in_use_locales rescue I18n.available_locales
scope "(:locale)", locale: Regexp.new(locales.join("|")) do
namespace :admin do namespace :admin do
resources :sites, only: [] do scope "sites/:id", :controller => 'official_module' do
get "set_master_key" => 'official_module#set_master_key' get "set_master_key" => 'official_module#set_master_key', as: :site_set_master_key
patch "update_master_password" => 'official_module#update_master_password' patch "update_master_password" => 'official_module#update_master_password'
end end
end end
end
end end

View File

@ -2,7 +2,6 @@ module OfficialModule
class Engine < ::Rails::Engine class Engine < ::Rails::Engine
initializer "official_module" do initializer "official_module" do
OrbitApp.registration "OfficialModule", :type => "ModuleApp" do OrbitApp.registration "OfficialModule", :type => "ModuleApp" do
module_label "official_module.official_module"
base_url File.expand_path File.dirname(__FILE__) base_url File.expand_path File.dirname(__FILE__)
set_keyword_contstraints ['/store/check_module_permissions', set_keyword_contstraints ['/store/check_module_permissions',
'/store/register_old_sites_modules', '/store/register_old_sites_modules',

View File

@ -2,7 +2,21 @@ $:.push File.expand_path("../lib", __FILE__)
# Maintain your gem's version: # Maintain your gem's version:
require "official_module/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('<li title="<%= t(\'search_engine\') %>">')
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: # Describe your gem and declare its dependencies:
Gem::Specification.new do |s| Gem::Specification.new do |s|
s.name = "official_module" s.name = "official_module"

1
official_module_li.erb Normal file
View File

@ -0,0 +1 @@
<li title="<%= t('master_key') %>"><%= link_to admin_site_set_master_key_path(current_site), :class => active_for_action('sites', 'preference') do %><span><i class="icons-key "></i></span><%end%></li>