reddavis-embedit 0.0.7 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/embedit.rb CHANGED
@@ -16,7 +16,8 @@ require 'embedit/validate'
16
16
  require 'embedit/player/player'
17
17
 
18
18
  # Oembed
19
- #puts a = Embedit::Media.new('http://www.vimeo.com/1260077').title
19
+
20
+ #puts a = Embedit::Media.new('http://www.vimeo.com/1263763').html
20
21
 
21
22
  #puts b = Embedit::Media.new('http://www.flickr.com/photos/reddavis999/2692043113/').html #valid? #.valid #.html(:height => 200)
22
23
 
@@ -42,6 +43,4 @@ require 'embedit/player/player'
42
43
 
43
44
  # Flash Player
44
45
 
45
- #puts a = Embedit::Media.new('../test.flv').html
46
-
47
- #puts File.exists?(File.expand_path('test.flv'))
46
+ #puts a = Embedit::Media.new('../test.flv').html(:height => 900)
data/lib/embedit/media.rb CHANGED
@@ -6,10 +6,10 @@ module Embedit
6
6
 
7
7
  def initialize(url)
8
8
  @valid = true #Innocent until proven guilty
9
- @oembed_providers = Providers.new.sites
9
+ @oembed_providers = Providers.new.sites
10
10
  find_provider(url)
11
- #rescue #Horrible hack, but flickrs poor status headers == :(
12
- # @valid = false #if it breaks, its gotta be invalid, I suggest removing when debugging
11
+ rescue #Horrible hack, but flickrs poor status headers == :(
12
+ @valid = false #if it breaks, its gotta be invalid, I suggest removing when debugging
13
13
  end
14
14
 
15
15
  def title
@@ -38,7 +38,7 @@ module Embedit
38
38
  #Find a provider
39
39
  def find_provider(url)
40
40
  return @valid = false unless Validate.new(url).valid?
41
-
41
+
42
42
  @oembed_providers.keys.each do |key| #First search oembed providers for a match
43
43
  if url.match(/(\.|\/)#{key}\./) #URL can be www.vimeo.com || http://vimeo.com
44
44
  return @media_data = Oembed.new(url, key)
@@ -1,14 +1,21 @@
1
- # TODO Having problems with using in rails (files not being found), need to look into. But works perfectly find with www.pandastream.com
2
1
  module Embedit
3
2
 
4
3
  class Player
5
-
4
+
5
+ FLASH_PLAYER = File.expand_path('..', __FILE__) + '/../../player/player.swf'
6
+ SWF_OBJECT = File.expand_path('..', __FILE__) + '/../../player/swfobject.js'
7
+ # MEDIA_PATH = File.dirname(__FILE__) + '/../../'
8
+
6
9
  attr_reader :title, :url, :format
7
10
 
8
11
  def initialize(url)
9
- @url = url
12
+ self.url = url
10
13
  end
11
-
14
+
15
+ def url=(path)
16
+ @url = File.expand_path(path)
17
+ end
18
+
12
19
  def html(size = {})
13
20
  self.html = @url # Reset measurements, incase if hmtl is called twice on the same object
14
21
  @html.gsub!(/400/, size[:width].to_s) unless size[:width].nil?
@@ -17,11 +24,19 @@ module Embedit
17
24
  end
18
25
 
19
26
  def html=(url)
20
- @html = %(<embed src="http://s3.amazonaws.com/panda-test/player.swf" width="400" height="300"
21
- allowfullscreen="true" allowscriptaccess="always"
22
- flashvars="&displayheight=300&file=#{url}&width=400&height=300" />)
27
+ @html = %{
28
+ <div id='preview'></div>
29
+ <script type='text/javascript' src='#{SWF_OBJECT}'></script>
30
+ <script type='text/javascript'>
31
+ var s1 = new SWFObject('#{FLASH_PLAYER}','player','400','300','9');
32
+ s1.addParam('allowfullscreen','true');
33
+ s1.addParam('allowscriptaccess','always');
34
+ s1.addParam('flashvars','file=#{url}');
35
+ s1.write('preview');
36
+ </script>
37
+ }
23
38
  end
24
39
 
25
40
  end
26
41
 
27
- end
42
+ end
@@ -12,14 +12,14 @@ class Validate
12
12
  private
13
13
 
14
14
  def check_url
15
- if (check_url_supported == true && check_response == true) || (File.extname(@url) != "" || nil && check_url_supported) #We first check that the url is one actually supported by Embedit
15
+ if check_url_supported == true && check_response == true #We first check that the url is one actually supported by Embedit
16
16
  return true
17
17
  end
18
18
  end
19
19
 
20
20
  def check_response
21
21
  true if open(@url) #Header codes are annoying, just check that the page works, the check with Embed::Media will narrow down more
22
- rescue
22
+ rescue
23
23
  false
24
24
  end
25
25
 
@@ -35,7 +35,7 @@ class Validate
35
35
  return true
36
36
  elsif @url.match(/share\.ovi\.com/)
37
37
  return true
38
- elsif File.extname(@url) != "" || nil
38
+ elsif File.extname(@url).match(/\.flv/)
39
39
  return true
40
40
  end
41
41
  return false #Return false if all else fail
Binary file
@@ -0,0 +1,8 @@
1
+ /**
2
+ * SWFObject v1.5: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
3
+ *
4
+ * SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License:
5
+ * http://www.opensource.org/licenses/mit-license.php
6
+ *
7
+ */
8
+ if(typeof deconcept=="undefined"){var deconcept=new Object();}if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a){if(!document.getElementById){return;}this.DETECT_KEY=_a?_a:"detectflash";this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);this.params=new Object();this.variables=new Object();this.attributes=new Array();if(_1){this.setAttribute("swf",_1);}if(id){this.setAttribute("id",id);}if(w){this.setAttribute("width",w);}if(h){this.setAttribute("height",h);}if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();if(!window.opera&&document.all&&this.installedVer.major>7){deconcept.SWFObject.doPrepUnload=true;}if(c){this.addParam("bgcolor",c);}var q=_7?_7:"high";this.addParam("quality",q);this.setAttribute("useExpressInstall",false);this.setAttribute("doExpressInstall",false);var _c=(_8)?_8:window.location;this.setAttribute("xiRedirectUrl",_c);this.setAttribute("redirectUrl","");if(_9){this.setAttribute("redirectUrl",_9);}};deconcept.SWFObject.prototype={useExpressInstall:function(_d){this.xiSWFPath=!_d?"expressinstall.swf":_d;this.setAttribute("useExpressInstall",true);},setAttribute:function(_e,_f){this.attributes[_e]=_f;},getAttribute:function(_10){return this.attributes[_10];},addParam:function(_11,_12){this.params[_11]=_12;},getParams:function(){return this.params;},addVariable:function(_13,_14){this.variables[_13]=_14;},getVariable:function(_15){return this.variables[_15];},getVariables:function(){return this.variables;},getVariablePairs:function(){var _16=new Array();var key;var _18=this.getVariables();for(key in _18){_16[_16.length]=key+"="+_18[key];}return _16;},getSWFHTML:function(){var _19="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");this.setAttribute("swf",this.xiSWFPath);}_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\"";_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";var _1a=this.getParams();for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}var _1c=this.getVariablePairs().join("&");if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");this.setAttribute("swf",this.xiSWFPath);}_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\">";_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";var _1d=this.getParams();for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}var _1f=this.getVariablePairs().join("&");if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}return _19;},write:function(_20){if(this.getAttribute("useExpressInstall")){var _21=new deconcept.PlayerVersion([6,0,65]);if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){this.setAttribute("doExpressInstall",true);this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));document.title=document.title.slice(0,47)+" - Flash Player Installation";this.addVariable("MMdoctitle",document.title);}}if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){var n=(typeof _20=="string")?document.getElementById(_20):_20;n.innerHTML=this.getSWFHTML();return true;}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}return false;}};deconcept.SWFObjectUtil.getPlayerVersion=function(){var _23=new deconcept.PlayerVersion([0,0,0]);if(navigator.plugins&&navigator.mimeTypes.length){var x=navigator.plugins["Shockwave Flash"];if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}}else{if(navigator.userAgent&&navigator.userAgent.indexOf("Windows CE")>=0){var axo=1;var _26=3;while(axo){try{_26++;axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+_26);_23=new deconcept.PlayerVersion([_26,0,0]);}catch(e){axo=null;}}}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}}return _23;};deconcept.PlayerVersion=function(_29){this.major=_29[0]!=null?parseInt(_29[0]):0;this.minor=_29[1]!=null?parseInt(_29[1]):0;this.rev=_29[2]!=null?parseInt(_29[2]):0;};deconcept.PlayerVersion.prototype.versionIsValid=function(fv){if(this.major<fv.major){return false;}if(this.major>fv.major){return true;}if(this.minor<fv.minor){return false;}if(this.minor>fv.minor){return true;}if(this.rev<fv.rev){return false;}return true;};deconcept.util={getRequestParameter:function(_2b){var q=document.location.search||document.location.hash;if(_2b==null){return q;}if(q){var _2d=q.substring(1).split("&");for(var i=0;i<_2d.length;i++){if(_2d[i].substring(0,_2d[i].indexOf("="))==_2b){return _2d[i].substring((_2d[i].indexOf("=")+1));}}}return "";}};deconcept.SWFObjectUtil.cleanupSWFs=function(){var _2f=document.getElementsByTagName("OBJECT");for(var i=_2f.length-1;i>=0;i--){_2f[i].style.display="none";for(var x in _2f[i]){if(typeof _2f[i][x]=="function"){_2f[i][x]=function(){};}}}};if(deconcept.SWFObject.doPrepUnload){if(!deconcept.unloadSet){deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};window.attachEvent("onunload",deconcept.SWFObjectUtil.cleanupSWFs);};window.attachEvent("onbeforeunload",deconcept.SWFObjectUtil.prepUnload);deconcept.unloadSet=true;}}if(!document.getElementById&&document.all){document.getElementById=function(id){return document.all[id];};}var getQueryParamValue=deconcept.util.getRequestParameter;var FlashObject=deconcept.SWFObject;var SWFObject=deconcept.SWFObject;
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reddavis-embedit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Red Davis
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-09-28 07:15:59 -07:00
12
+ date: 2008-09-26 07:08:33 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -33,6 +33,8 @@ files:
33
33
  - lib/embedit/validate.rb
34
34
  - lib/embedit/ovi/ovi.rb
35
35
  - lib/embedit/player/player.rb
36
+ - lib/player/player.swf
37
+ - lib/player/swfobject.js
36
38
  - spec/spec_helper.rb
37
39
  - spec/oembed_spec.rb
38
40
  - spec/youtube_spec.rb