Permalink
Browse files

First pass at gemification

  • Loading branch information...
1 parent b490fa1 commit 767279ef6190e34e2ace8c6b7bef0ab65f4234a5 @phurley phurley committed Jul 31, 2009
Showing with 119 additions and 18 deletions.
  1. +1 −0 .gitignore
  2. +18 −0 Manifest.txt
  3. +3 −1 README
  4. +40 −0 bin/jrails
  5. +1 −6 init.rb
  6. +9 −1 javascripts/jquery-ui.js
  7. +6 −6 javascripts/jquery.js
  8. +26 −0 jrails.gemspec
  9. +5 −3 lib/jrails.rb
  10. +9 −0 rails/init.rb
  11. +1 −1 tasks/jrails.rake
View
@@ -0,0 +1 @@
+jrails-0.4.1.gem
View
@@ -0,0 +1,18 @@
+CHANGELOG
+Manifest.txt
+README
+install.rb
+init.rb
+bin
+bin/jrails
+javascripts
+javascripts/jquery-ui.js
+javascripts/jquery.js
+javascripts/jrails.js
+javascripts/sources
+javascripts/sources/jrails.js
+lib
+lib/jrails.rb
+tasks/
+tasks/jrails.rake
+rails/init.rb
View
4 README
@@ -1,6 +1,8 @@
= jRails
jRails is a drop-in jQuery replacement for the Rails Prototype/script.aculo.us helpers.
+I (Patrick), modified the plugin to work as a gem and to support Ruby 1.9.X. All bugs
+are probably my fault, thanks to the original author.
== Resources
@@ -18,4 +20,4 @@ Web Site
Group Site
-* http://groups.google.com/group/jrails
+* http://groups.google.com/group/jrails
View
@@ -0,0 +1,40 @@
+#!/usr/bin/env ruby
+
+require 'rubygems'
+require 'rake'
+
+RAILS_ROOT = Dir.pwd
+rakeapp = Rake.application
+fname =File.join(File.dirname(__FILE__), '..', 'tasks', 'jrails.rake')
+load fname
+
+task :help do
+ puts "jrails [command]\n\n"
+ rakeapp.options.show_task_pattern = Regexp.new('^[hius]')
+ rakeapp.display_tasks_and_comments
+end
+
+desc "Copies the jQuery and jRails javascripts to public/javascripts"
+task :update do
+ Rake::Task['jrails:update:javascripts'].invoke
+end
+
+desc 'Installs the jQuery and jRails javascripts to public/javascripts'
+task :install do
+ Rake::Task['jrails:update:javascripts'].invoke
+end
+
+desc 'Remove the prototype / script.aculo.us javascript files'
+task :scrub do
+ files = %W[controls.js dragdrop.js effects.js prototype.js]
+ project_dir = File.join(RAILS_ROOT, 'public', 'javascripts')
+ files.each do |fname|
+ FileUtils.rm File.join(project_dir, fname)
+ end
+end
+
+
+rakeapp.init("jrails")
+task :default => [:help]
+
+rakeapp.top_level
View
@@ -1,6 +1 @@
-# uncomment to use jQuery.noConflict()
-#ActionView::Helpers::PrototypeHelper::JQUERY_VAR = 'jQuery'
-
-ActionView::Helpers::AssetTagHelper::JAVASCRIPT_DEFAULT_SOURCES = ['jquery','jquery-ui','jrails']
-ActionView::Helpers::AssetTagHelper::reset_javascript_include_default
-require 'jrails'
+require 'rails/init.rb'
View
Oops, something went wrong.
View
Oops, something went wrong.
View
@@ -0,0 +1,26 @@
+require 'rubygems'
+
+spec = Gem::Specification.new do |s|
+ s.name = "jrails"
+ s.version = "0.4.1"
+ s.authors = ["aaronchi", "Patrick Hurley"]
+ s.email = "phurley@gmail.com"
+ s.homepage = "http://ennerchi.com/projects/jrails"
+ s.platform = Gem::Platform::RUBY
+ s.summary = "jRails is a drop-in jQuery replacement for the Rails Prototype/script.aculo.us helpers."
+ s.description = "jRails is a drop-in jQuery replacement for Prototype/script.aculo.us on Rails. " +
+ "Using jRails, you can get all of the same default Rails helpers for javascript " +
+ "functionality using the lighter jQuery library."
+
+ files = IO.read("Manifest.txt").split
+ s.files = files
+
+ s.executables = ['jrails']
+
+ s.has_rdoc = false
+end
+
+if __FILE__ == $PROGRAM_NAME
+ Gem::manage_gems
+ Gem::Builder.new(spec).build
+end
View
@@ -36,6 +36,8 @@ module PrototypeHelper
unless const_defined? :JQCALLBACKS
JQCALLBACKS = Set.new([ :beforeSend, :complete, :error, :success ] + (100..599).to_a)
+ #instance_eval { remove_const :AJAX_OPTIONS }
+ remove_const(:AJAX_OPTIONS) if const_defined?(:AJAX_OPTIONS)
AJAX_OPTIONS = Set.new([ :before, :after, :condition, :url,
:asynchronous, :method, :insertion, :position,
:form, :with, :update, :script ]).merge(JQCALLBACKS)
@@ -226,7 +228,7 @@ def build_callbacks(options)
class JavaScriptElementProxy < JavaScriptProxy #:nodoc:
unless const_defined? :JQUERY_VAR
- JQUERY_VAR = ActionView::Helpers::PrototypeHelper::JQUERY_VAR
+ JQUERY_VAR = PrototypeHelper::JQUERY_VAR
end
def initialize(generator, id)
@@ -260,7 +262,7 @@ def value=(value)
class JavaScriptElementCollectionProxy < JavaScriptCollectionProxy #:nodoc:\
unless const_defined? :JQUERY_VAR
- JQUERY_VAR = ActionView::Helpers::PrototypeHelper::JQUERY_VAR
+ JQUERY_VAR = PrototypeHelper::JQUERY_VAR
end
def initialize(generator, pattern)
@@ -271,7 +273,7 @@ def initialize(generator, pattern)
module ScriptaculousHelper
unless const_defined? :JQUERY_VAR
- JQUERY_VAR = ActionView::Helpers::PrototypeHelper::JQUERY_VAR
+ JQUERY_VAR = PrototypeHelper::JQUERY_VAR
end
unless const_defined? :SCRIPTACULOUS_EFFECTS
View
@@ -0,0 +1,9 @@
+# I made this the default, because it adds very little to the
+# the size of the generated code and increases compatibility
+# If it is a real problem redefine it in an initializer
+ActionView::Helpers::PrototypeHelper::JQUERY_VAR = 'jQuery'
+
+ActionView::Helpers::AssetTagHelper::JAVASCRIPT_DEFAULT_SOURCES = ['jquery','jquery-ui','jrails']
+ActionView::Helpers::AssetTagHelper::reset_javascript_include_default
+require 'jrails'
+
View
@@ -4,7 +4,7 @@ namespace :jrails do
task :javascripts do
puts "Copying files..."
project_dir = RAILS_ROOT + '/public/javascripts/'
- scripts = Dir[File.join(File.dirname(__FILE__), '..') + '/javascripts/*.js']
+ scripts = Dir[File.join(File.dirname(__FILE__), '..', '/javascripts/', '*.js')]
FileUtils.cp(scripts, project_dir)
puts "files copied successfully."
end

0 comments on commit 767279e

Please sign in to comment.