Skip to content
Permalink
Browse files

Reorder repository to allow for custom selector engines to be include…

…d instead of Sizzle (the current default). Selector engines belong in the vendor directory and must have a selector_engine.js file. To build a Prototype with your engine of choice just spepcify it at build time using the SELECTOR_ENGINE option. For example, to build a version with NSMatcher: rake dist SELECTOR_ENGINE=nwmatcher.
  • Loading branch information...
tobie committed Oct 23, 2009
1 parent 3e19f95 commit 7762e002cb0dd757b347494c896b6aa520b21c16
@@ -11,6 +11,6 @@
path = vendor/sprockets
url = git://github.com/sstephenson/sprockets.git

[submodule "vendor/sizzle"]
path = vendor/sizzle
[submodule "vendor/sizzle/sizzle"]
path = vendor/sizzle/sizzle
url = git://github.com/jeresig/sizzle.git
@@ -42,7 +42,7 @@ module PrototypeHelper
require_sizzle
secretary = Sprockets::Secretary.new(
:root => File.join(ROOT_DIR, path),
:load_path => [SRC_DIR, SIZZLE_DIR],
:load_path => self.load_path,
:source_files => [source],
:strip_comments => strip_comments
)
@@ -51,6 +51,18 @@ module PrototypeHelper
secretary.concatenation.save_to(destination)
end

def self.load_path
selector = ENV['SELECTOR_ENGINE'] || 'sizzle'
selector_path = File.join(ROOT_DIR, 'vendor', selector)
if File.exists?(selector_path)
[SRC_DIR, selector_path]
else
puts "\nYou seem to be missing vendor/#{selector}."
puts "Built Prototype using Sizzle instead.\n\n"
[SRC_DIR, SIZZLE_DIR]
end
end

def self.build_doc_for(file)
mkdir_p TMP_DIR
temp_path = File.join(TMP_DIR, "prototype.temp.js")
@@ -83,8 +95,8 @@ module PrototypeHelper
end

def self.require_sizzle
if !File.exists?(File.join(SIZZLE_DIR, 'sizzle.js'))
exit unless get_submodule("Sizzle", "sizzle")
if !File.exists?(File.join(SIZZLE_DIR, 'sizzle', 'sizzle.js'))
exit unless get_submodule("Sizzle", "sizzle/sizzle")
end
end

@@ -21,7 +21,7 @@


//= require "dom/dom"
//= require "dom/sizzle_adapter"
//= require <selector_engine>
//= require "dom/selector"
//= require "dom/form"
//= require "dom/event"

5 comments on commit 7762e00

@jdalton

This comment has been minimized.

Copy link
Contributor

replied Oct 23, 2009

It would be nice if you allowed the engines to be sub modules and load them in, so devs could get the latest engine with they update the other submodules. Both NWMatcher and Sizzle are on github so it should be a quick addition. It's really awesome that you have allowed more selector engine options :D

@jdalton

This comment has been minimized.

Copy link
Contributor

replied Oct 23, 2009

For example you are using version 1.1.1 of NWMatcher when its current version is 1.2.0.

@tobie

This comment has been minimized.

Copy link
Collaborator Author

replied Oct 23, 2009

We already do for Sizzle. It's auto-initiated and updated, too. I wasn't aware that NWMatcher was hosted on github. Thought it was on Google Code only. Anyway, was more of a POC for the latter.

@jdalton

This comment has been minimized.

Copy link
Contributor

replied Oct 23, 2009

@tobie here is his project link http://github.com/dperini/nwmatcher

@subtleGradient

This comment has been minimized.

Copy link

replied Oct 23, 2009

Good stuff.

Please sign in to comment.
You can’t perform that action at this time.