forked from kernow/javascript_auto_include
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
… 581f9dff-63f6-4202-9a23-85763b9ce6d8
- Loading branch information
jamied
committed
Feb 15, 2008
0 parents
commit d121504
Showing
8 changed files
with
93 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
JavascriptAutoInclude | ||
===================== | ||
|
||
== Resources | ||
|
||
Install | ||
* Run the following command: | ||
script/plugin install http://kernowsoul.com/svn/plugins/javascript_auto_include | ||
|
||
== Usage | ||
|
||
Add the following to the head of your template file | ||
|
||
<%= javascript_auto_include_tags %> | ||
|
||
Now each time the template is loaded javascript files in the public/javascripts/views | ||
folder that correspond to the name of the current controller or view will be auto | ||
loaded. For example: | ||
|
||
/public | ||
/javascripts | ||
/views | ||
users.js | ||
/users | ||
edit.js | ||
roles.js | ||
/accounts | ||
show.js | ||
|
||
Assuming the above file structure loading each of the following urls would load: | ||
|
||
mydomain.com/users # loads users.js | ||
mydomain.com/users/edit/1 # loads users.js and edit.js | ||
mydomain.com/users/show/1 # loads users.js | ||
mydomain.com/roles # loads roles.js | ||
mydomain.com/accounts # no js files loaded | ||
mydomain.com/accounts/show/1 # loads show.js | ||
|
||
== More | ||
|
||
http://hosting.media72.co.uk/blog/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
require 'rake' | ||
require 'rake/testtask' | ||
require 'rake/rdoctask' | ||
|
||
desc 'Default: run unit tests.' | ||
task :default => :test | ||
|
||
desc 'Test the javascript_auto_include plugin.' | ||
Rake::TestTask.new(:test) do |t| | ||
t.libs << 'lib' | ||
t.pattern = 'test/**/*_test.rb' | ||
t.verbose = true | ||
end | ||
|
||
desc 'Generate documentation for the javascript_auto_include plugin.' | ||
Rake::RDocTask.new(:rdoc) do |rdoc| | ||
rdoc.rdoc_dir = 'rdoc' | ||
rdoc.title = 'JavascriptAutoInclude' | ||
rdoc.options << '--line-numbers' << '--inline-source' | ||
rdoc.rdoc_files.include('README') | ||
rdoc.rdoc_files.include('lib/**/*.rb') | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
require 'javascript_auto_include' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
require 'fileutils' | ||
|
||
FileUtils.mkdir File.dirname(__FILE__) + '/../../../public/views' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module ActionView | ||
module Helpers | ||
module AssetTagHelper | ||
def javascript_auto_include_tags | ||
js_path = "#{RAILS_ROOT}/public/javascripts/views" | ||
if File.directory? js_path | ||
paths = [controller.controller_name, File.join(controller.controller_name, controller.action_name)] | ||
paths.collect { |source| javascript_include_tag("views/#{source}") if File.exist?(File.join(js_path, "#{source}.js")) }.join("\n") | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# desc "Explaining what the task does" | ||
# task :javascript_auto_include do | ||
# # Task goes here | ||
# end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
require 'test/unit' | ||
|
||
class JavascriptAutoIncludeTest < Test::Unit::TestCase | ||
# Replace this with your real tests. | ||
def test_this_plugin | ||
flunk | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Uninstall hook code here |