swfobject-rails 1.1.1 → 2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +2 -0
- data/.rspec +1 -0
- data/LICENSE.txt +22 -0
- data/README.md +64 -12
- data/app/helpers/swfobject_helper.rb +79 -38
- data/app/views/shared/_swfobject.html.erb +21 -0
- data/lib/swfobject/rails/version.rb +1 -2
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/javascripts/swfobject-full.js +1 -0
- data/spec/dummy/app/assets/javascripts/swfobject-min.js +1 -0
- data/spec/dummy/app/assets/stylesheets/application.css +7 -0
- data/spec/dummy/app/assets/swfs/dir/file.swf +0 -0
- data/spec/dummy/app/assets/swfs/myContent.swf +0 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/mailers/.gitkeep +0 -0
- data/spec/dummy/app/models/.gitkeep +0 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +45 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +30 -0
- data/spec/dummy/config/environments/production.rb +60 -0
- data/spec/dummy/config/environments/test.rb +39 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +10 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +58 -0
- data/spec/dummy/db/schema.rb +15 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/lib/assets/.gitkeep +0 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +26 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/helpers/swfobject_helper_spec.rb +121 -0
- data/spec/requests/assets_spec.rb +26 -0
- data/spec/spec_helper.rb +13 -0
- data/spec/support/be_content_type_matcher.rb +9 -0
- data/spec/support/have_content_matcher.rb +5 -0
- data/swfobject-rails.gemspec +6 -4
- data/vendor/assets/javascripts/swfobject.js +775 -2
- data/vendor/assets/javascripts/swfobject.min.js +4 -0
- metadata +117 -16
- data/LICENSE +0 -19
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c217d21362a88a01ed03eea57ac21bb03a72792d
|
4
|
+
data.tar.gz: 7b03000f5439a775db520f8d47134d23efb8a9fe
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 45c5663d74f961aa0e43ccc4e34a042549c6ba5533baede562f98e6eb6708a92ebf7b0c50a282f650201f3235d25a1d806dc07d644c94fe415f1555c8c9ac6d9
|
7
|
+
data.tar.gz: 9401f04d007417534a887e8810f6b3f168d7f5699bfe174523d1cd55d82e7528a44578158236c87cd5023507c8b9fc2dffa9f1ca37390eef938749e31d3f0c34
|
data/.gitignore
CHANGED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--format d --color
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2010 - 2013 Corin Langosch
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,32 +1,84 @@
|
|
1
|
-
Rails
|
1
|
+
Rails Integration for SWFObject
|
2
2
|
==
|
3
3
|
|
4
|
-
This gem integrates [
|
4
|
+
This gem integrates [SWFObject](http://code.google.com/p/swfobject/) with the Rails asset pipeline. It has been tested with Rails 3.1, 3.2 and 4.0.
|
5
5
|
|
6
6
|
|
7
|
-
|
8
|
-
|
7
|
+
Installation
|
8
|
+
------------
|
9
9
|
|
10
|
-
Just add it
|
10
|
+
Just add it to your `Gemfile`:
|
11
11
|
|
12
|
-
|
12
|
+
``` ruby
|
13
|
+
gem "swfobject-rails"
|
14
|
+
```
|
13
15
|
|
14
16
|
|
15
17
|
Quick Start
|
16
|
-
|
18
|
+
-----------
|
17
19
|
|
18
|
-
Add to your application.js
|
20
|
+
Add to your `application.js`:
|
19
21
|
|
20
|
-
|
22
|
+
``` javascript
|
23
|
+
//= require swfobject
|
24
|
+
```
|
21
25
|
|
22
26
|
Place your SWFs you want to incude somewhere in the rails assets directories (ex. app/assets/swfs/...).
|
23
27
|
|
24
|
-
|
28
|
+
swfobject-rails includes a helper for generating static embed code, `#swf_tag`:
|
25
29
|
|
26
|
-
|
30
|
+
``` erb
|
31
|
+
<%= swf_tag "video", :id => "my_video", :params => {:loop => true}, :flashvars => {:debug => true} do %>
|
32
|
+
<p>You should download the latest Flash player!</p>
|
33
|
+
<% end %>
|
34
|
+
```
|
35
|
+
|
36
|
+
This would generate the following HTML:
|
37
|
+
|
38
|
+
``` html
|
39
|
+
<object id="my_video" name="my_video" width="100%" height="100%" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000">
|
40
|
+
<param name="movie" value="/assets/video.swf" />
|
41
|
+
<param name="wmode" value="transparent" />
|
42
|
+
<param name="loop" value="true" />
|
43
|
+
<param name="allowfullscreen" value="true" />
|
44
|
+
<param name="allowscriptaccess" value="always" />
|
45
|
+
<param name="flashvars" value="debug=true" />
|
46
|
+
<!--[if !IE]>-->
|
47
|
+
<object data="/assets/video.swf" width="100%" height="100%">
|
48
|
+
<param name="wmode" value="transparent" />
|
49
|
+
<param name="loop" value="true" />
|
50
|
+
<param name="allowfullscreen" value="true" />
|
51
|
+
<param name="allowscriptaccess" value="always" />
|
52
|
+
<param name="flashvars" value="debug=true" />
|
53
|
+
<!--<![endif]-->
|
54
|
+
<p>You should download the latest Flash player!</p>
|
55
|
+
<!--[if !IE]>-->
|
56
|
+
</object>
|
57
|
+
<!--<![endif]-->
|
58
|
+
</object>
|
59
|
+
<script type="text/javascript">
|
60
|
+
swfobject.registerObject("my_video", "9.0.0", "/assets/expressInstall.swf");
|
61
|
+
</script>
|
62
|
+
```
|
27
63
|
|
28
64
|
|
29
65
|
Updating
|
30
|
-
|
66
|
+
--------
|
67
|
+
|
31
68
|
When new versions swfobject are released, simply update the gem to the latest version.
|
32
69
|
|
70
|
+
|
71
|
+
Contributing
|
72
|
+
--------
|
73
|
+
|
74
|
+
1. Fork it
|
75
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
76
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
77
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
78
|
+
5. Create new Pull Request
|
79
|
+
|
80
|
+
|
81
|
+
Copyright
|
82
|
+
--------
|
83
|
+
|
84
|
+
Copyright (c) 2010 - 2013 [Corin Langosch](http://www.corinlangosch.com) and contributors. Released unter the MIT license.
|
@@ -1,47 +1,88 @@
|
|
1
|
-
# encoding: utf-8
|
2
1
|
module SwfobjectHelper
|
3
|
-
|
4
|
-
|
5
|
-
|
2
|
+
# Default options for the #swfobject helper.
|
3
|
+
DEFAULT_OPTIONS = {
|
4
|
+
:width => "100%",
|
5
|
+
:height => "100%",
|
6
|
+
:version => "9.0.0",
|
7
|
+
:partial => "shared/swfobject"
|
8
|
+
}
|
6
9
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
10
|
+
# Default <param> tags.
|
11
|
+
DEFAULT_PARAMS = {
|
12
|
+
:allowfullscreen => true,
|
13
|
+
:allowscriptaccess => "always",
|
14
|
+
:wmode => "transparent"
|
15
|
+
}
|
16
|
+
|
17
|
+
# Generates static embed HTML using the method recommend here:
|
18
|
+
# http://code.google.com/p/swfobject/wiki/documentation
|
19
|
+
#
|
20
|
+
# +file+ is the path to the SWF. Alternate content can be used
|
21
|
+
# by passing a +block+
|
22
|
+
#
|
23
|
+
# Other Options:
|
24
|
+
#
|
25
|
+
# * <tt>:id</tt> - The ID on the outer <object> tag. Defaults to
|
26
|
+
# an underscored version of the filename.
|
27
|
+
# * <tt>:width</tt> - The width of the SWF. Defaults to "100%".
|
28
|
+
# * <tt>:height</tt> - The height of the SWF. Defaults to "100%".
|
29
|
+
# * <tt>:version</tt> - The minimum version of the Flash player required.
|
30
|
+
# Defaults to "9.0.0".
|
31
|
+
# * <tt>:params</tt> - A hash of parameters to configure the SWF. Will be used
|
32
|
+
# to generate <param> tags. Defaults to DEFAULT_PARAMS.
|
33
|
+
# * <tt>:flashvars</tt> - A hash of variables to send to the flash file. Will
|
34
|
+
# be sent using an encoded value in a <param> tag.
|
35
|
+
#
|
36
|
+
def swf_tag(file, options = {}, &block)
|
37
|
+
options = options.reverse_merge(DEFAULT_OPTIONS)
|
38
|
+
|
39
|
+
# Get path to asset
|
40
|
+
file = swf_path(file)
|
15
41
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
else
|
24
|
-
flashvars = options[:flashvars]
|
42
|
+
# Extract params from options
|
43
|
+
params = options.delete(:params) || {}
|
44
|
+
params.reverse_merge!(DEFAULT_PARAMS)
|
45
|
+
|
46
|
+
# Extract flashvars and add to params
|
47
|
+
if flashvars = options.delete(:flashvars)
|
48
|
+
params[:flashvars] = flashvars.to_query
|
25
49
|
end
|
26
50
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
51
|
+
# Generate ID from file if necessary
|
52
|
+
id = options.delete(:id) || File.basename(file, File.extname(file)).underscore
|
53
|
+
|
54
|
+
# Extract other specific options
|
55
|
+
version = options.delete(:version)
|
56
|
+
partial = options.delete(:partial)
|
57
|
+
alt_content = options.delete(:alternate_content)
|
58
|
+
alt_content = capture(&block) if block_given?
|
59
|
+
|
60
|
+
# And finally, render the partial
|
61
|
+
render partial,
|
62
|
+
:file => file,
|
63
|
+
:id => id,
|
64
|
+
:version => version,
|
65
|
+
:params => params,
|
66
|
+
:attributes => options,
|
67
|
+
:alternate_content => alt_content
|
41
68
|
end
|
69
|
+
alias :swfobject :swf_tag
|
42
70
|
|
43
|
-
|
44
|
-
|
71
|
+
# Computes the path to a SWF file in the assets pipeline.
|
72
|
+
# If the +source+ filename has no extension, .swf will be appended (except for explicit URIs)
|
73
|
+
# Full paths from the document root will be passed through.
|
74
|
+
# Used internally by #swf_tag to build the path to the SWF file.
|
75
|
+
#
|
76
|
+
# ==== Examples
|
77
|
+
#
|
78
|
+
# swf_path "file" # => /assets/file.swf
|
79
|
+
# swf_path "dir/file.swf" # => /assets/dir/file.swf
|
80
|
+
# swf_path "/dir/file.swf" # => /dir/file.swf
|
81
|
+
# swf_path "http://www.example.com/file" # => http://www.example.com/file
|
82
|
+
# swf_path "http://www.example.com/file.swf" # => http://www.example.com/file.swf
|
83
|
+
#
|
84
|
+
def swf_path(source)
|
85
|
+
source = source + ".swf" if source !~ /^http/ && File.extname(source) == ""
|
86
|
+
asset_path(source)
|
45
87
|
end
|
46
88
|
end
|
47
|
-
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<%= content_tag :object, attributes.merge(:id => id, :name => id, :classid => "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000") do %>
|
2
|
+
<%= tag :param, :name => "movie", :value => file %>
|
3
|
+
<% params.each do |name, value| %>
|
4
|
+
<%= tag :param, :name => name, :value => value %>
|
5
|
+
<% end %>
|
6
|
+
<!--[if !IE]>-->
|
7
|
+
<%= content_tag :object, attributes.merge(:data => file) do %>
|
8
|
+
<% params.each do |name, value| %>
|
9
|
+
<%= tag :param, :name => name, :value => value %>
|
10
|
+
<% end %>
|
11
|
+
<% if alternate_content %>
|
12
|
+
<!--<![endif]-->
|
13
|
+
<%= raw alternate_content.to_s %>
|
14
|
+
<!--[if !IE]>-->
|
15
|
+
<% end %>
|
16
|
+
<% end %>
|
17
|
+
<!--<![endif]-->
|
18
|
+
<% end %>
|
19
|
+
<script type="text/javascript">
|
20
|
+
swfobject.registerObject("<%= id %>", "<%= version %>", "<%= swf_path 'expressInstall' %>");
|
21
|
+
</script>
|
data/spec/dummy/Rakefile
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
3
|
+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
4
|
+
|
5
|
+
require File.expand_path('../config/application', __FILE__)
|
6
|
+
|
7
|
+
Dummy::Application.load_tasks
|
@@ -0,0 +1 @@
|
|
1
|
+
//= require swfobject
|
@@ -0,0 +1 @@
|
|
1
|
+
//= require swfobject.min
|
@@ -0,0 +1,7 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll automatically include all the stylesheets available in this directory
|
3
|
+
* and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
|
4
|
+
* the top of the compiled file, but it's generally better to create a new file per style scope.
|
5
|
+
*= require_self
|
6
|
+
*= require_tree .
|
7
|
+
*/
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
# Pick the frameworks you want:
|
4
|
+
require "rails/all"
|
5
|
+
Bundler.require
|
6
|
+
require "swfobject-rails"
|
7
|
+
|
8
|
+
module Dummy
|
9
|
+
class Application < Rails::Application
|
10
|
+
# Settings in config/environments/* take precedence over those specified here.
|
11
|
+
# Application configuration should go into files in config/initializers
|
12
|
+
# -- all .rb files in that directory are automatically loaded.
|
13
|
+
|
14
|
+
# Custom directories with classes and modules you want to be autoloadable.
|
15
|
+
# config.autoload_paths += %W(#{config.root}/extras)
|
16
|
+
|
17
|
+
# Only load the plugins named here, in the order given (default is alphabetical).
|
18
|
+
# :all can be used as a placeholder for all plugins not explicitly named.
|
19
|
+
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
|
20
|
+
|
21
|
+
# Activate observers that should always be running.
|
22
|
+
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
|
23
|
+
|
24
|
+
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
25
|
+
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
26
|
+
# config.time_zone = 'Central Time (US & Canada)'
|
27
|
+
|
28
|
+
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
29
|
+
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
30
|
+
# config.i18n.default_locale = :de
|
31
|
+
|
32
|
+
# Configure the default encoding used in templates for Ruby 1.9.
|
33
|
+
config.encoding = "utf-8"
|
34
|
+
|
35
|
+
# Configure sensitive parameters which will be filtered from the log file.
|
36
|
+
config.filter_parameters += [:password]
|
37
|
+
|
38
|
+
# Enable the asset pipeline
|
39
|
+
config.assets.enabled = true
|
40
|
+
|
41
|
+
# Version of your assets, change this if you want to expire all your assets
|
42
|
+
config.assets.version = '1.0'
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# SQLite version 3.x
|
2
|
+
# gem install sqlite3
|
3
|
+
#
|
4
|
+
# Ensure the SQLite 3 gem is defined in your Gemfile
|
5
|
+
# gem 'sqlite3'
|
6
|
+
development:
|
7
|
+
adapter: sqlite3
|
8
|
+
database: db/development.sqlite3
|
9
|
+
pool: 5
|
10
|
+
timeout: 5000
|
11
|
+
|
12
|
+
# Warning: The database defined as "test" will be erased and
|
13
|
+
# re-generated from your development database when you run "rake".
|
14
|
+
# Do not set this db to the same as development or production.
|
15
|
+
test:
|
16
|
+
adapter: sqlite3
|
17
|
+
database: db/test.sqlite3
|
18
|
+
pool: 5
|
19
|
+
timeout: 5000
|
20
|
+
|
21
|
+
production:
|
22
|
+
adapter: sqlite3
|
23
|
+
database: db/production.sqlite3
|
24
|
+
pool: 5
|
25
|
+
timeout: 5000
|