File: youtube.rb

package info (click to toggle)
tdiary-contrib 5.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 2,772 kB
  • sloc: ruby: 17,305; javascript: 8,263; lisp: 562; xml: 451; php: 61; sql: 40; makefile: 18
file content (30 lines) | stat: -rw-r--r-- 914 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#
# youtube.rb: YouTube plugin for tDiary
#
# Copyright (C) 2010 by TADA Tadashi <t@tdtds.jp>
#
# usage: <%= youtube 'VIDEO_ID' %>
#
def youtube( video_id, size = [425,350] )
	if feed?
		%Q|<div class="youtube"><a href="//www.youtube.com/watch?v=#{video_id}">YouTube (#{video_id})</a></div>|
	else
		<<-TAG
		<div class="youtube-player-wrapper">
		<iframe class="youtube-player" type="text/html" width="#{size[0]}" height="#{size[1]}" src="//www.youtube.com/embed/#{video_id}" frameborder="0">
		</iframe>
		</div>
		TAG
	end
end

def youtube_custom( video_id, size = [416,337] )
  <<-TAG
  <div class="youtube-player-wrapper">
  <object width="#{size[0]}" height="#{size[1]}">
  <param name="movie" value="//www.youtube.com/cp/#{video_id}"></param>
  <embed src="//www.youtube.com/cp/#{video_id}" type="application/x-shockwave-flash" width="#{size[0]}" height="#{size[1]}"></embed>
  </object>
  </div>
  TAG
end