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
|
module Bullseye
|
||||||
class Configuration
|
class Configuration
|
||||||
attr_accessor :js_controller_search, :js_action_search, :css_selector, :html_tag, :fuzzy_search
|
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
|
end
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
@ -28,3 +18,4 @@ module Bullseye
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -12,5 +12,23 @@ module Bullseye
|
|||||||
app.assets.register_engine '.bullseye', Bullseye::Tilt::BullseyeTemplate
|
app.assets.register_engine '.bullseye', Bullseye::Tilt::BullseyeTemplate
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
module Bullseye
|
module Bullseye
|
||||||
module FindParts
|
module FindParts
|
||||||
|
SEPARATOR = '-'
|
||||||
|
|
||||||
def actions
|
def actions
|
||||||
parts.last.split('-')
|
parts.last.split(SEPARATOR)
|
||||||
end
|
end
|
||||||
|
|
||||||
def controller
|
def controller
|
||||||
parts[0..-2].join('-')
|
parts[0..-2].join(SEPARATOR)
|
||||||
end
|
end
|
||||||
|
|
||||||
def parts
|
def parts
|
||||||
|
@ -15,7 +15,7 @@ module Bullseye
|
|||||||
end
|
end
|
||||||
|
|
||||||
def __bullseye_controller
|
def __bullseye_controller
|
||||||
@__bullseye_controller || controller_path
|
@__bullseye_controller || controller_path.gsub('/', Bullseye::FindParts::SEPARATOR)
|
||||||
end
|
end
|
||||||
end
|
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