some stuff for better rails integration
This commit is contained in:
parent
051766915f
commit
1ab0f26aec
@ -6,16 +6,6 @@ require 'bullseye/sass/bullseye_functions'
|
||||
module Bullseye
|
||||
class Configuration
|
||||
attr_accessor :js_controller_search, :js_action_search, :css_selector, :html_tag, :fuzzy_search
|
||||
|
||||
def initialize
|
||||
@js_controller_search = %{$('body').data('controller')}
|
||||
@js_action_search = %{$('body').data('action')}
|
||||
|
||||
@css_selector = %{body[data-action=':action'][data-controller=':controller']}
|
||||
@html_tag = { 'data-action' => ':action', 'data-controller' => ':controller' }
|
||||
|
||||
@fuzzy_search = false
|
||||
end
|
||||
end
|
||||
|
||||
class << self
|
||||
@ -28,3 +18,4 @@ module Bullseye
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -12,5 +12,23 @@ module Bullseye
|
||||
app.assets.register_engine '.bullseye', Bullseye::Tilt::BullseyeTemplate
|
||||
end
|
||||
end
|
||||
|
||||
class InstallGenerator < ::Rails::Generators::Base
|
||||
source_root File.expand_path('../../../skel', __FILE__)
|
||||
|
||||
def create_initializer_file
|
||||
copy_file "config/initializers/bullseye.rb", "config/initializers/bullseye.rb"
|
||||
|
||||
puts
|
||||
puts "Add to your main application.js file:"
|
||||
puts
|
||||
puts "//= require bullseye"
|
||||
puts
|
||||
puts "and replace your body tag layouts/application.html with a call to bullseye_body:"
|
||||
puts
|
||||
puts "= bullseye_body do"
|
||||
puts
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -1,11 +1,13 @@
|
||||
module Bullseye
|
||||
module FindParts
|
||||
SEPARATOR = '-'
|
||||
|
||||
def actions
|
||||
parts.last.split('-')
|
||||
parts.last.split(SEPARATOR)
|
||||
end
|
||||
|
||||
def controller
|
||||
parts[0..-2].join('-')
|
||||
parts[0..-2].join(SEPARATOR)
|
||||
end
|
||||
|
||||
def parts
|
||||
|
@ -15,7 +15,7 @@ module Bullseye
|
||||
end
|
||||
|
||||
def __bullseye_controller
|
||||
@__bullseye_controller || controller_path
|
||||
@__bullseye_controller || controller_path.gsub('/', Bullseye::FindParts::SEPARATOR)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
9
skel/config/initializers/bullseye.rb
Normal file
9
skel/config/initializers/bullseye.rb
Normal file
@ -0,0 +1,9 @@
|
||||
Bullseye.configure do |c|
|
||||
c.js_controller_search = %{$('body').data('controller')}
|
||||
c.js_action_search = %{$('body').data('action')}
|
||||
|
||||
c.css_selector = %{body[data-action=':action'][data-controller=':controller']}
|
||||
c.html_tag = { 'data-action' => ':action', 'data-controller' => ':controller' }
|
||||
|
||||
c.fuzzy_search = false
|
||||
end
|
Loading…
Reference in New Issue
Block a user