Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
gucki committed Sep 26, 2011
0 parents commit 2a7b428
Show file tree
Hide file tree
Showing 13 changed files with 156 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*.gem
.bundle
Gemfile.lock
pkg/*
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
source "http://rubygems.org"

# Specify your gem's dependencies in swfobject-rails.gemspec
gemspec
19 changes: 19 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright (c) 2010-2011 Corin Langosch

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
Rails 3.1 Integration for swfobject
==

This gem integrates [swfobject](http://code.google.com/p/swfobject/) with the Rails 3.1 asset pipeline.


Install
--

Just add it got your Gemfile:

gem swfobject-rails


Quick Start
--

Add to your application.js:

//= require swfobject

Place your SWFs you want to incude somewhere in the rails 3.1 assets directories (ex. app/assets/swfs/...).

In your view you can now do:

<%= swf_tag "video" %>


Updating
--
When new versions swfobject are released, simply update the gem to the latest version.

1 change: 1 addition & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
require "bundler/gem_tasks"
47 changes: 47 additions & 0 deletions app/helpers/swfobject_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# encoding: utf-8
module SwfobjectHelper
def swf_path(source)
asset_paths.compute_public_path(source, 'swfs')
end

def swf_tag(name, options = {})
width = height = nil
if options[:size]
width, height = options[:size].split("x")
else
width = options.delete(:width)
height = options.delete(:height)
end

if options[:flashvars]
# we need to urlencode flashvars, see question 9 at
# http://code.google.com/p/swfobject/wiki/faq
flashvars = {}
options[:flashvars].each_pair do |k, v|
flashvars[CGI.escape(k.to_s)] = CGI.escape(v.to_s)
end
else
flashvars = options[:flashvars]
end

code = "swfobject.embedSWF('%s', '%s', '%s', '%s', '%s', '%s', %s, %s, %s, %s);" % [
swf_path("#{name}.swf"),
options[:dom_id] || name,
width,
height,
options[:version] || "9.0.0",
swf_path("expressInstall.swf"),
flashvars.to_json,
options[:params].to_json,
options[:attributes].to_json,
options[:callback] ? options[:callback] : "null",
]

javascript_tag(code)
end

def swfoject(*args)
swf_tag(*args)
end
end

2 changes: 2 additions & 0 deletions lib/swfobject-rails.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require "swfobject/rails"

3 changes: 3 additions & 0 deletions lib/swfobject/rails.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
require 'swfobject/rails/version'
require 'swfobject/rails/engine'

7 changes: 7 additions & 0 deletions lib/swfobject/rails/engine.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module Swfobject
module Rails
class Engine < ::Rails::Engine
end
end
end

8 changes: 8 additions & 0 deletions lib/swfobject/rails/version.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module Swfobject
VERSION = "2.2"

module Rails
VERSION = "1.0.0"
end
end

25 changes: 25 additions & 0 deletions swfobject-rails.gemspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require "swfobject/rails/version"

Gem::Specification.new do |s|
s.name = "swfobject-rails"
s.version = Swfobject::Rails::VERSION
s.authors = ["Corin Langosch"]
s.email = ["info@corinlangosch.com"]
s.homepage = "https://github.com/gucki/swfobject-rails"
s.summary = %q{Integration of swfobject with the Rails 3.1 asset pipeline}
s.description = %q{This gem integrates swfobject with the Rails 3.1 asset pipeline.}

s.rubyforge_project = "swfobject-rails"

s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.require_paths = ["lib"]

# specify any dependencies here; for example:
# s.add_development_dependency "rspec"
s.add_runtime_dependency "rails", "~>3.1.0"
end

4 changes: 4 additions & 0 deletions vendor/assets/javascripts/swfobject.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added vendor/assets/swfs/expressInstall.swf
Binary file not shown.

0 comments on commit 2a7b428

Please sign in to comment.