html-pipeline-youtube 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +16 -0
- data/Gemfile +7 -0
- data/Guardfile +11 -0
- data/README.md +40 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/html-pipeline-youtube-0.0.1.gem +0 -0
- data/html-pipeline-youtube.gemspec +24 -0
- data/lib/html/pipeline/youtube.rb +9 -0
- data/lib/html/pipeline/youtube/version.rb +7 -0
- data/lib/html/pipeline/youtube/youtube_filter.rb +35 -0
- metadata +100 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 99d398dedf937740a67c2dc93beb83256aeb2659
|
4
|
+
data.tar.gz: 964ebd00cc1343396ccad25ad17e5aed8793d075
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8a5de764a8d9ca09224ce9a7a8c0cb1879d4564eacbdeb6fcf92af7bec15c9e7aa15dce923f79c15810947c91d3925c055517820e064c5cd6f42ce261de70a4c
|
7
|
+
data.tar.gz: 8fe4bfaa407b7db8d17c373cd3c30cb8357efa4b1e2827df1257b699debd8c8d21003ec66d23374bb14a4448e0840b1b6cd022043cb1e24a8c9df3fffe5b1105
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
language: ruby
|
2
|
+
install:
|
3
|
+
- gem uninstall bundler
|
4
|
+
- gem install bundler --version '1.8.0'
|
5
|
+
- bundle install
|
6
|
+
|
7
|
+
script: "bundle exec rspec"
|
8
|
+
rvm:
|
9
|
+
- 2.2.0
|
10
|
+
|
11
|
+
notifications:
|
12
|
+
email:
|
13
|
+
recipients:
|
14
|
+
- stan001212@gmail.com
|
15
|
+
on_failure: change
|
16
|
+
on_success: never
|
data/Gemfile
ADDED
data/Guardfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
[![Build Status](https://travis-ci.org/st0012/html-pipeline-youtube.svg?branch=master)](https://travis-ci.org/st0012/html-pipeline-youtube)
|
2
|
+
|
3
|
+
# HTML::Pipeline Youtube Gem
|
4
|
+
A html-pipeline filter that converts youtube url into iframe
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem 'html-pipeline'
|
12
|
+
gem 'html-pipeline-youtube'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install html-pipeline-youtube
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
See [html-pipeline](https://github.com/jch/html-pipeline)
|
26
|
+
|
27
|
+
|
28
|
+
## Development
|
29
|
+
|
30
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
|
31
|
+
|
32
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
33
|
+
|
34
|
+
## Contributing
|
35
|
+
|
36
|
+
1. [Fork it]( https://github.com/st0012/html-pipeline-youtube/fork )
|
37
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
38
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
39
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
40
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "html/pipeline/youtube"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
Binary file
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'html/pipeline/youtube/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "html-pipeline-youtube"
|
8
|
+
spec.version = HTML::Pipeline::Youtube::VERSION
|
9
|
+
spec.authors = ["Stan Luo"]
|
10
|
+
spec.email = ["stan001212@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Youtube filter for html-pipeline}
|
13
|
+
spec.description = %q{A html-pipeline filter that converts youtube url into iframe}
|
14
|
+
spec.homepage = "https://github.com/st0012/html-pipeline-youtube"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.bindir = "exe"
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "html-pipeline", "~> 2.0"
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.8"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module HTML
|
2
|
+
class Pipeline
|
3
|
+
class YoutubeFilter < TextFilter
|
4
|
+
def call
|
5
|
+
# This filter converts youtube video's url into youtube iframe.
|
6
|
+
#
|
7
|
+
# Context options:
|
8
|
+
# :video_width - integer, sets iframe's width
|
9
|
+
# :video_height - integer, sets iframe's height
|
10
|
+
# :video_frame_border - integer, sets iframe border's width
|
11
|
+
# :video_wmode - string, sets iframe's wmode option
|
12
|
+
# :video_autoplay - boolean, whether video should autoplay
|
13
|
+
# :video_hide_related - boolean, whether shows related videos
|
14
|
+
regex = /(https?:\/\/)?(www.)?(youtube\.com\/watch\?v=|youtu\.be\/|youtube\.com\/watch\?feature=player_embedded&v=)([A-Za-z0-9_-]*)(\&\S+)?(\?\S+)?/
|
15
|
+
@text.gsub(regex) do
|
16
|
+
youtube_id = $4
|
17
|
+
width = context[:video_width] || 420
|
18
|
+
height = context[:video_height] || 315
|
19
|
+
frameborder = context[:video_frameborder] || 0
|
20
|
+
wmode = context[:video_wmode]
|
21
|
+
autoplay = context[:video_autoplay] || false
|
22
|
+
hide_related = context[:video_hide_related] || false
|
23
|
+
src = "//www.youtube.com/embed/#{youtube_id}"
|
24
|
+
params = []
|
25
|
+
params << "wmode=#{wmode}" if wmode
|
26
|
+
params << "autoplay=1" if autoplay
|
27
|
+
params << "rel=0" if hide_related
|
28
|
+
src += "?#{params.join '&'}" unless params.empty?
|
29
|
+
|
30
|
+
%{<div class="video youtube"><iframe width="#{width}" height="#{height}" src="#{src}" frameborder="#{frameborder}" allowfullscreen></iframe></div>}
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
metadata
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: html-pipeline-youtube
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Stan Luo
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-07-25 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: html-pipeline
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.8'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.8'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
description: A html-pipeline filter that converts youtube url into iframe
|
56
|
+
email:
|
57
|
+
- stan001212@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- ".rspec"
|
64
|
+
- ".travis.yml"
|
65
|
+
- Gemfile
|
66
|
+
- Guardfile
|
67
|
+
- README.md
|
68
|
+
- Rakefile
|
69
|
+
- bin/console
|
70
|
+
- bin/setup
|
71
|
+
- html-pipeline-youtube-0.0.1.gem
|
72
|
+
- html-pipeline-youtube.gemspec
|
73
|
+
- lib/html/pipeline/youtube.rb
|
74
|
+
- lib/html/pipeline/youtube/version.rb
|
75
|
+
- lib/html/pipeline/youtube/youtube_filter.rb
|
76
|
+
homepage: https://github.com/st0012/html-pipeline-youtube
|
77
|
+
licenses: []
|
78
|
+
metadata: {}
|
79
|
+
post_install_message:
|
80
|
+
rdoc_options: []
|
81
|
+
require_paths:
|
82
|
+
- lib
|
83
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
93
|
+
requirements: []
|
94
|
+
rubyforge_project:
|
95
|
+
rubygems_version: 2.4.5
|
96
|
+
signing_key:
|
97
|
+
specification_version: 4
|
98
|
+
summary: Youtube filter for html-pipeline
|
99
|
+
test_files: []
|
100
|
+
has_rdoc:
|