├── .rspec ├── spec ├── spec_helper.rb └── html │ └── pipeline │ └── youtube_filter_spec.rb ├── Gemfile ├── html-pipeline-youtube-0.0.1.gem ├── Rakefile ├── bin ├── setup └── console ├── lib └── html │ └── pipeline │ ├── youtube │ ├── version.rb │ └── youtube_filter.rb │ └── youtube.rb ├── .gitignore ├── .travis.yml ├── Guardfile ├── html-pipeline-youtube.gemspec └── README.md /.rspec: -------------------------------------------------------------------------------- 1 | --format documentation 2 | --color 3 | -------------------------------------------------------------------------------- /spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__) 2 | require 'html/pipeline/youtube' 3 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | group :test do 4 | gem "guard-rspec" 5 | gem "guard" 6 | end 7 | gemspec 8 | -------------------------------------------------------------------------------- /html-pipeline-youtube-0.0.1.gem: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polydice/html-pipeline-youtube/master/html-pipeline-youtube-0.0.1.gem -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require "bundler/gem_tasks" 2 | require 'rspec/core/rake_task' 3 | 4 | RSpec::Core::RakeTask.new(:spec) 5 | 6 | task :default => :spec 7 | -------------------------------------------------------------------------------- /bin/setup: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -euo pipefail 3 | IFS=$'\n\t' 4 | 5 | bundle install 6 | 7 | # Do any other automated setup that you need to do here 8 | -------------------------------------------------------------------------------- /lib/html/pipeline/youtube/version.rb: -------------------------------------------------------------------------------- 1 | module HTML 2 | class Pipeline 3 | module Youtube 4 | VERSION = '0.1.4' 5 | end 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /.bundle/ 2 | /.yardoc 3 | /Gemfile.lock 4 | /_yardoc/ 5 | /coverage/ 6 | /doc/ 7 | /pkg/ 8 | /spec/reports/ 9 | /tmp/ 10 | **.gem 11 | .ruby-version 12 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: ruby 2 | sudo: false 3 | cache: bundler 4 | rvm: 5 | - 2.3.4 6 | - 2.4.1 7 | - ruby-head 8 | 9 | notifications: 10 | email: 11 | recipients: 12 | - stan001212@gmail.com 13 | on_failure: change 14 | on_success: never 15 | -------------------------------------------------------------------------------- /Guardfile: -------------------------------------------------------------------------------- 1 | guard 'rspec', cmd: "bundle exec rspec" do 2 | # watch /lib/ files 3 | watch(%r{^lib/(.+).rb$}) do |m| 4 | "spec/#{m[1]}_spec.rb" 5 | end 6 | 7 | # watch /spec/ files 8 | watch(%r{^spec/(.+).rb$}) do |m| 9 | "spec/#{m[1]}.rb" 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /lib/html/pipeline/youtube.rb: -------------------------------------------------------------------------------- 1 | require "html/pipeline" 2 | require "html/pipeline/youtube/version" 3 | require "html/pipeline/youtube/youtube_filter.rb" 4 | 5 | module HTML 6 | class Pipeline 7 | autoload :YoutubeFilter, 'html/pipeline/youtube/youtube_filter' 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /bin/console: -------------------------------------------------------------------------------- 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 15 | -------------------------------------------------------------------------------- /html-pipeline-youtube.gemspec: -------------------------------------------------------------------------------- 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 "rake", "~> 10.0" 23 | end 24 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [](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 41 | -------------------------------------------------------------------------------- /lib/html/pipeline/youtube/youtube_filter.rb: -------------------------------------------------------------------------------- 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 = /(?<=^|\s|