get rid of warnings about InstanceMethods (deprecated) + make the engine work smoother with an existing app + clean code
This commit is contained in:
parent
25e08596ef
commit
fa36b95a9d
@ -1,4 +1,5 @@
|
||||
class Locomotive::ContentLocalePickerCell < Cell::Base
|
||||
module Locomotive
|
||||
class ContentLocalePickerCell < Cell::Base
|
||||
|
||||
def show(args)
|
||||
site = args[:site]
|
||||
@ -13,3 +14,4 @@ class Locomotive::ContentLocalePickerCell < Cell::Base
|
||||
end
|
||||
|
||||
end
|
||||
end
|
@ -1,4 +1,5 @@
|
||||
class Locomotive::GlobalActionsCell < ::Locomotive::MenuCell
|
||||
module Locomotive
|
||||
class GlobalActionsCell < MenuCell
|
||||
|
||||
attr_reader :current_locomotive_account, :current_site_url
|
||||
|
||||
@ -32,3 +33,4 @@ class Locomotive::GlobalActionsCell < ::Locomotive::MenuCell
|
||||
end
|
||||
|
||||
end
|
||||
end
|
@ -1,4 +1,5 @@
|
||||
class Locomotive::MainMenuCell < ::Locomotive::MenuCell
|
||||
module Locomotive
|
||||
class MainMenuCell < MenuCell
|
||||
|
||||
protected
|
||||
|
||||
@ -8,3 +9,4 @@ class Locomotive::MainMenuCell < ::Locomotive::MenuCell
|
||||
end
|
||||
|
||||
end
|
||||
end
|
@ -1,8 +1,9 @@
|
||||
class Locomotive::MenuCell < Cell::Rails
|
||||
module Locomotive
|
||||
class MenuCell < Cell::Rails
|
||||
|
||||
include ::Locomotive::Engine.routes.url_helpers
|
||||
|
||||
delegate :sections, :to => :parent_controller
|
||||
delegate :main_app, :sections, :to => :parent_controller
|
||||
|
||||
attr_accessor :list
|
||||
|
||||
@ -98,3 +99,4 @@ class Locomotive::MenuCell < Cell::Rails
|
||||
end
|
||||
|
||||
end
|
||||
end
|
@ -1,4 +1,5 @@
|
||||
class Locomotive::SettingsMenuCell < ::Locomotive::SubMenuCell
|
||||
module Locomotive
|
||||
class SettingsMenuCell < SubMenuCell
|
||||
|
||||
protected
|
||||
|
||||
@ -9,3 +10,4 @@ class Locomotive::SettingsMenuCell < ::Locomotive::SubMenuCell
|
||||
end
|
||||
|
||||
end
|
||||
end
|
@ -1,4 +1,5 @@
|
||||
class Locomotive::SubMenuCell < ::Locomotive::MenuCell
|
||||
module Locomotive
|
||||
class SubMenuCell < MenuCell
|
||||
|
||||
protected
|
||||
|
||||
@ -9,3 +10,4 @@ class Locomotive::SubMenuCell < ::Locomotive::MenuCell
|
||||
end
|
||||
|
||||
end
|
||||
end
|
@ -14,8 +14,6 @@ module Locomotive
|
||||
validate :item_template_must_be_valid
|
||||
end
|
||||
|
||||
module InstanceMethods
|
||||
|
||||
def item_template
|
||||
@item_template ||= Marshal.load(read_attribute(:serialized_item_template).to_s) rescue nil
|
||||
end
|
||||
@ -46,8 +44,6 @@ module Locomotive
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -16,8 +16,6 @@ module Locomotive
|
||||
|
||||
end
|
||||
|
||||
module InstanceMethods
|
||||
|
||||
# Returns the fullpath of a page in the context of the current locale (I18n.locale)
|
||||
# or the one passed in parameter. It also depends on the default site locale.
|
||||
#
|
||||
@ -59,28 +57,8 @@ module Locomotive
|
||||
self.locales = [Locomotive.config.site_locales.first] if self.locales.blank?
|
||||
end
|
||||
|
||||
#
|
||||
# def add_missing_locales_for_all_pages
|
||||
# if self.locales_changed?
|
||||
# list = self.pages.to_a
|
||||
#
|
||||
# while !list.empty? do
|
||||
# page = list.pop
|
||||
# begin
|
||||
# page.send(:set_slug_and_fullpath_for_all_locales, self.locales)
|
||||
#
|
||||
# page.save
|
||||
#
|
||||
# rescue TypeError => e
|
||||
# list.insert(0, page)
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -1,5 +1,5 @@
|
||||
%h1
|
||||
= link_to current_site.name, pages_url
|
||||
= link_to current_site.name, locomotive.pages_url
|
||||
|
||||
= render_cell 'locomotive/global_actions', :show, :current_locomotive_account => current_locomotive_account, :current_site_url => current_site_public_url
|
||||
|
||||
|
@ -3,8 +3,8 @@
|
||||
- current_locomotive_account.sites.each do |site|
|
||||
- unless current_site._id == site._id
|
||||
%li
|
||||
= link_to site.name, pages_url(:host => site.full_subdomain, :port => request.port)
|
||||
= link_to site.name, locomotive.pages_url(:host => site.full_subdomain, :port => request.port)
|
||||
|
||||
- if can?(:manage, Locomotive::Site)
|
||||
%p.action
|
||||
= link_to t('locomotive.sites_picker.new'), new_site_url
|
||||
= link_to t('locomotive.sites_picker.new'), locomotive.new_site_url
|
19
config/initializers/locomotive_loaded_first.rb
Normal file
19
config/initializers/locomotive_loaded_first.rb
Normal file
@ -0,0 +1,19 @@
|
||||
require 'active_support/dependencies'
|
||||
|
||||
module ActiveSupport::Dependencies
|
||||
|
||||
alias_method :require_or_load_without_multiple, :require_or_load
|
||||
|
||||
def require_or_load(file_name, const_path = nil)
|
||||
if file_name.starts_with?(Rails.root.to_s + '/app')
|
||||
relative_name = file_name.gsub(Rails.root.to_s, '')
|
||||
@engine_paths ||= Rails::Application::Railties.engines.collect{|engine| engine.config.root.to_s }
|
||||
@engine_paths.each do |path|
|
||||
engine_file = File.join(path, relative_name)
|
||||
require_or_load_without_multiple(engine_file, const_path) if File.file?(engine_file)
|
||||
end
|
||||
end
|
||||
require_or_load_without_multiple(file_name, const_path)
|
||||
end
|
||||
|
||||
end
|
@ -8,8 +8,6 @@ module Locomotive
|
||||
helper_method :current_content_locale
|
||||
end
|
||||
|
||||
module InstanceMethods
|
||||
|
||||
def current_content_locale
|
||||
::Mongoid::Fields::I18n.locale
|
||||
end
|
||||
@ -45,7 +43,5 @@ module Locomotive
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
@ -4,8 +4,6 @@ module Locomotive
|
||||
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
module InstanceMethods
|
||||
|
||||
def sections(key = nil)
|
||||
if !key.nil? && key.to_sym == :sub
|
||||
@locomotive_sections[:sub] || self.controller_name.dasherize
|
||||
@ -14,8 +12,6 @@ module Locomotive
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
module ClassMethods
|
||||
|
||||
def sections(main, sub = nil)
|
||||
|
@ -8,8 +8,6 @@ module Locomotive
|
||||
helper_method :current_site_public_url, :switch_to_site_url, :public_page_url
|
||||
end
|
||||
|
||||
module InstanceMethods
|
||||
|
||||
def current_site_public_url
|
||||
request.protocol + request.host_with_port
|
||||
end
|
||||
@ -37,4 +35,3 @@ module Locomotive
|
||||
|
||||
end
|
||||
end
|
||||
end
|
@ -12,8 +12,6 @@ module Locomotive
|
||||
end
|
||||
end
|
||||
|
||||
module InstanceMethods
|
||||
|
||||
protected
|
||||
|
||||
def fetch_site
|
||||
@ -54,4 +52,3 @@ module Locomotive
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -29,17 +29,12 @@ Gem::Specification.new do |s|
|
||||
s.add_dependency 'bson_ext', '~> 1.5.2'
|
||||
s.add_dependency 'mongoid', '~> 2.4.3'
|
||||
s.add_dependency 'locomotive-mongoid-tree', '~> 0.6.2'
|
||||
# s.add_dependency 'locomotive_mongoid_acts_as_tree', '~> 0.1.5.8'
|
||||
|
||||
s.add_dependency 'custom_fields', '~> 2.0.0.rc3'
|
||||
|
||||
s.add_dependency 'kaminari', '~> 0.13.0'
|
||||
|
||||
s.add_dependency 'haml', '~> 3.1.4'
|
||||
# # s.add_dependency 'sass-rails', '~> 3.1.5'
|
||||
# # s.add_dependency 'coffee-script', '~> 2.2.0'
|
||||
# # s.add_dependency 'uglifier', '~> 1.2.2'
|
||||
# # # s.add_dependency 'compass', '~> 0.12.rc.0'
|
||||
s.add_dependency 'jquery-rails', '~> 1.0.16'
|
||||
s.add_dependency 'rails-backbone', '~> 0.6.1'
|
||||
s.add_dependency 'codemirror-rails', '~> 2.21'
|
||||
|
9
spec/dummy/app/cells/locomotive/main_menu_cell.rb
Normal file
9
spec/dummy/app/cells/locomotive/main_menu_cell.rb
Normal file
@ -0,0 +1,9 @@
|
||||
module Locomotive
|
||||
class MainMenuCell < MenuCell
|
||||
|
||||
update_for :foo do |new_menu|
|
||||
new_menu.add_before :settings, :foo, :url => new_menu.main_app.foo_url
|
||||
end
|
||||
|
||||
end
|
||||
end
|
@ -1,8 +1,10 @@
|
||||
class FooController < ApplicationController
|
||||
class FooController < Locomotive::BaseController
|
||||
|
||||
skip_load_and_authorize_resource
|
||||
|
||||
sections :foo
|
||||
|
||||
def index
|
||||
render :text => 'Foo'
|
||||
end
|
||||
|
||||
|
||||
end
|
1
spec/dummy/app/views/foo/index.html.haml
Normal file
1
spec/dummy/app/views/foo/index.html.haml
Normal file
@ -0,0 +1 @@
|
||||
%p Hello world !!!
|
@ -3,3 +3,8 @@
|
||||
|
||||
en:
|
||||
hello: "Hello world"
|
||||
|
||||
locomotive:
|
||||
shared:
|
||||
menu:
|
||||
foo: My FOO menu
|
Loading…
Reference in New Issue
Block a user