convert 0.1.0 → 0.1.1
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.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/CHANGELOG.md +7 -0
- data/Gemfile +9 -0
- data/LICENSE +21 -0
- data/README.md +131 -0
- data/config/boot.rb +6 -0
- data/convert.gemspec +25 -0
- data/lib/convert.rb +0 -1
- data/lib/converters/auto_link.rb +19 -0
- data/lib/converters/dailymotion.rb +17 -0
- data/lib/converters/decode.rb +7 -0
- data/lib/converters/email_escape.rb +20 -0
- data/lib/converters/encode.rb +7 -0
- data/lib/converters/flickr.rb +23 -0
- data/lib/converters/gist.rb +17 -0
- data/lib/converters/google_maps.rb +35 -0
- data/lib/converters/hashtag.rb +14 -0
- data/lib/converters/html_escape.rb +11 -0
- data/lib/converters/iframe_embed.rb +10 -0
- data/lib/converters/image_tag.rb +9 -0
- data/lib/converters/instagram.rb +13 -0
- data/lib/converters/kramdown.rb +16 -0
- data/lib/converters/liveleak.rb +28 -0
- data/lib/converters/markdown.rb +18 -0
- data/lib/converters/metacafe.rb +28 -0
- data/lib/converters/nokogiri.rb +36 -0
- data/lib/converters/redcarpet.rb +10 -0
- data/lib/converters/sanitize.rb +13 -0
- data/lib/converters/simple_format.rb +9 -0
- data/lib/converters/soundcloud.rb +36 -0
- data/lib/converters/strip_params.rb +10 -0
- data/lib/converters/ted.rb +28 -0
- data/lib/converters/twitter.rb +21 -0
- data/lib/converters/unescape_html.rb +11 -0
- data/lib/converters/video_embed.rb +24 -0
- data/lib/converters/vimeo.rb +33 -0
- data/lib/converters/vimeo_embed.rb +10 -0
- data/lib/converters/worldstar.rb +18 -0
- data/lib/converters/youtube.rb +42 -0
- data/lib/converters/youtube_embed.rb +10 -0
- data/lib/converters/youtube_image.rb +35 -0
- data/lib/converters/youtube_js_api.rb +18 -0
- data/lib/sanitizers/custom.rb +45 -0
- data/lib/sanitizers/full.rb +46 -0
- data/lib/sanitizers/linebreaks.rb +12 -0
- data/lib/sanitizers/simple.rb +9 -0
- data/test.rb +16 -0
- metadata +63 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fb05f6e5b1cfcbc5696673f4225795be29d0978a
|
4
|
+
data.tar.gz: 04dfaf51cfd169b58171067e83fccf892e2d2419
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b852bd60f016e79141c7562e63ff96123eb9b122be67ea738420618f726cfce2d56a8583297f26fb709556c66cdde284e8c0a3b9ed223ab03b132e6fed3d39a2
|
7
|
+
data.tar.gz: f75962f693314439c7197691d752ea3b7d7412c89441947dd92ad66df934f30c90b86a9d47298bd634c5789d0e7902e7c726707561340166b00eccdd7fda28dd
|
data/.gitignore
ADDED
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2016 Fugroup
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,131 @@
|
|
1
|
+
# Convert strings and HTML to links and embedded content
|
2
|
+
|
3
|
+
Convert any string or HTML to links and embedded content from a long list of providers and libraries.
|
4
|
+
|
5
|
+
### Installation
|
6
|
+
```
|
7
|
+
gem install convert
|
8
|
+
```
|
9
|
+
or add to Gemfile.
|
10
|
+
|
11
|
+
### Usage
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
# Require convert if you're not using bundler
|
15
|
+
require 'convert'
|
16
|
+
|
17
|
+
# Run default converters. Pass :converters => [:auto_link, :decode]
|
18
|
+
Convert.run('string')
|
19
|
+
|
20
|
+
# Convert with Nokogiri, used by 'run'
|
21
|
+
Convert.nokogiri('HTML string')
|
22
|
+
|
23
|
+
# URL to HTML link
|
24
|
+
Convert.auto_link('https://crowdfundhq.com')
|
25
|
+
|
26
|
+
# Embed dailymotion videos (https://dailymotion.com)
|
27
|
+
Convert.dailymotion('string')
|
28
|
+
|
29
|
+
# Decode HTML, opposite of above
|
30
|
+
Convert.decode('string')
|
31
|
+
|
32
|
+
# Encode HTML with HTMLEntities
|
33
|
+
Convert.encode('string')
|
34
|
+
|
35
|
+
# Remove embedded videos from emails
|
36
|
+
Convert.email_escape('string')
|
37
|
+
|
38
|
+
# Embed flickr content (https://flickr.com)
|
39
|
+
Convert.flickr('string')
|
40
|
+
|
41
|
+
# Embed a Github gist (https://gist.github.com)
|
42
|
+
Convert.gist('string')
|
43
|
+
|
44
|
+
# Embed classic google maps (https://maps.google.com)
|
45
|
+
Convert.google_maps('string')
|
46
|
+
|
47
|
+
# Twitter or Facebook hastag to HTML link
|
48
|
+
Convert.hashtag('#flat')
|
49
|
+
|
50
|
+
# Escape HTML
|
51
|
+
Convert.escape_html('html')
|
52
|
+
|
53
|
+
# Unescape HTML
|
54
|
+
Convert.unescape_html('string')
|
55
|
+
|
56
|
+
# Embed iframe
|
57
|
+
Convert.iframe_embed('https://crowdfundhq.com/campaigns/flatty.embed')
|
58
|
+
|
59
|
+
# Convert
|
60
|
+
Convert.image_tag('https://crowdfundhq.com/logo.png')
|
61
|
+
|
62
|
+
# URL to Instagram embedded content
|
63
|
+
Convert.instagram('string')
|
64
|
+
|
65
|
+
# String to markdown (https://kramdown.gettalong.org)
|
66
|
+
Convert.kramdown('string')
|
67
|
+
|
68
|
+
# Embed live leak videos
|
69
|
+
Convert.liveleak('string')
|
70
|
+
|
71
|
+
# Embed markdown with Redcarpet
|
72
|
+
Convert.redcarpet('string')
|
73
|
+
|
74
|
+
# Sanitize HTML with the Sanitize gem
|
75
|
+
Convert.sanitize('HTML string')
|
76
|
+
|
77
|
+
# Sanitize config: :custom, :full, :linebreaks, :simple, :restricted, :basic, :relaxed
|
78
|
+
# You can add your own config by adding a file like the ones here:
|
79
|
+
# https://github.com/fugroup/convert/tree/master/lib/sanitizers
|
80
|
+
Convert.sanitize('HTML string', :config => :custom)
|
81
|
+
|
82
|
+
# Strip parameters from URL
|
83
|
+
Convert.strip_params('URL string')
|
84
|
+
|
85
|
+
# Same as above, a few other options
|
86
|
+
Convert.markdown('string')
|
87
|
+
|
88
|
+
# Embed metacafe content (https://www.metacafe.com)
|
89
|
+
Convert.metacafe('string')
|
90
|
+
|
91
|
+
# New lines to HTML br tags
|
92
|
+
Convert.simple_format('string')
|
93
|
+
|
94
|
+
# Embed Soundcloud music (https://soundcloud.com)
|
95
|
+
Convert.soundcloud('string')
|
96
|
+
|
97
|
+
# Embed TED videos (https://www.ted.com)
|
98
|
+
Convert.ted('string')
|
99
|
+
|
100
|
+
# Twitter embed tweet (https://twitter.com)
|
101
|
+
Convert.twitter('string')
|
102
|
+
|
103
|
+
# Embed Youtube or Vimeo videos from URL
|
104
|
+
Convert.video_embed('string')
|
105
|
+
|
106
|
+
# Embed Vimeo video, full (https://vimeo.com)
|
107
|
+
Convert.vimeo('string')
|
108
|
+
|
109
|
+
# Embed Vimeo video, simple
|
110
|
+
Convert.vimeo_embed('string')
|
111
|
+
|
112
|
+
# Embed worldstar content
|
113
|
+
Convert.worldstar('string')
|
114
|
+
|
115
|
+
# Embed Youtube videos, full (https://youtube.com)
|
116
|
+
Convert.youtube('string')
|
117
|
+
|
118
|
+
# Embed Youtube videos, simple
|
119
|
+
Convert.youtube_embed('string')
|
120
|
+
|
121
|
+
# Embed Youtube image
|
122
|
+
Convert.youtube_image('string')
|
123
|
+
|
124
|
+
# Embed Youtube JS API
|
125
|
+
Convert.youtube_js_api('string')
|
126
|
+
|
127
|
+
```
|
128
|
+
|
129
|
+
Created and maintained by [Fugroup Ltd.](https://www.fugroup.net) We are the creators of [CrowdfundHQ.](https://crowdfundhq.com)
|
130
|
+
|
131
|
+
`@authors: Vidar`
|
data/config/boot.rb
ADDED
data/convert.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = 'convert'
|
3
|
+
s.version = '0.1.1'
|
4
|
+
s.date = '2017-01-05'
|
5
|
+
s.summary = "Convert strings and HTML to links and embedded content"
|
6
|
+
s.description = "Easily convert any string and replace with links and embedded content from a long list of providers and libraries."
|
7
|
+
s.authors = ["Fugroup Limited"]
|
8
|
+
|
9
|
+
s.add_runtime_dependency 'redcarpet', '~> 3.4'
|
10
|
+
s.add_runtime_dependency 'kramdown', '~> 1.9'
|
11
|
+
s.add_runtime_dependency 'rinku', '~> 2.0'
|
12
|
+
s.add_runtime_dependency 'sanitize', '~> 4.4'
|
13
|
+
s.add_runtime_dependency 'htmlentities', '~> 4.3'
|
14
|
+
s.add_runtime_dependency 'nokogiri', '~> 1.6'
|
15
|
+
s.add_development_dependency 'futest', '>= 0'
|
16
|
+
|
17
|
+
s.email = 'mail@fugroup.net'
|
18
|
+
s.homepage = 'https://github.com/fugroup/convert'
|
19
|
+
s.license = 'MIT'
|
20
|
+
|
21
|
+
s.require_paths = ['lib']
|
22
|
+
s.files = `git ls-files -z`.split("\x0").reject do |f|
|
23
|
+
f.match(%r{^(test|spec|features)/})
|
24
|
+
end
|
25
|
+
end
|
data/lib/convert.rb
CHANGED
@@ -0,0 +1,19 @@
|
|
1
|
+
module Converters
|
2
|
+
|
3
|
+
# Convert URL to html link
|
4
|
+
def auto_link(string, options = {})
|
5
|
+
options = {
|
6
|
+
:mode => :all,
|
7
|
+
:link_attr => nil,
|
8
|
+
:skip_tags => nil,
|
9
|
+
:strip => false
|
10
|
+
}.merge(options)
|
11
|
+
|
12
|
+
Rinku.auto_link(string, options[:mode], options[:link_attr], options[:skip_tags]) do |url|
|
13
|
+
# Remove query options (default false)
|
14
|
+
url = strip_params(url) if options[:strip]
|
15
|
+
url
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Converters
|
2
|
+
|
3
|
+
def dailymotion(string, options = {})
|
4
|
+
# http://www.dailymotion.com/video/x3gpxwp_first-person-view-of-a-downhill-ice-cross-course-red-bull-crashed-ice-2015_sport
|
5
|
+
|
6
|
+
# Original 480 360
|
7
|
+
options = {:width => 590, :height => 335}.merge(options)
|
8
|
+
|
9
|
+
@regex = /http:\/\/www\.dailymotion\.com.*\/video\/(.+)_*/
|
10
|
+
|
11
|
+
string.gsub(@regex) do
|
12
|
+
video_id = $1
|
13
|
+
%{<object type="application/x-shockwave-flash" data="http://www.dailymotion.com/swf/#{video_id}&related=0" width="#{options[:width]}" height="#{options[:height]}"><param name="movie" value="http://www.dailymotion.com/swf/#{video_id}&related=0"></param><param name="allowFullScreen" value="true"></param><param name="allowScriptAccess" value="always"></param><a href="http://www.dailymotion.com/video/#{video_id}?embed=1"><img src="http://www.dailymotion.com/thumbnail/video/#{video_id}" width="#{options[:width]}" height="#{options[:height]}"/></a></object>}
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Converters
|
2
|
+
|
3
|
+
# Remove stuff from email body that is going to be stripped anyway.
|
4
|
+
def email_escape(string, options = {})
|
5
|
+
|
6
|
+
# No options at the moment
|
7
|
+
options = {}.merge(options)
|
8
|
+
|
9
|
+
# Youtube videos
|
10
|
+
@regex = /<iframe.+src=['"].+\/embed\/(.+)[?].+['"].+iframe>/
|
11
|
+
string = string.gsub(@regex, "https://youtu.be/#{'\1'}")
|
12
|
+
|
13
|
+
# Vimeo videos
|
14
|
+
# Example: https://vimeo.com/59437462
|
15
|
+
@regex = /<iframe.+src=['"]\/\/player\.vimeo.com\/video\/(.+)[?]{1}.+['"].+iframe>/
|
16
|
+
string = string.gsub(@regex, "https://vimeo.com/#{'\1'}")
|
17
|
+
string
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Converters
|
2
|
+
|
3
|
+
def flickr(string, options = {})
|
4
|
+
# https://www.flickr.com/photos/fotokunstsusanne/23160248869
|
5
|
+
|
6
|
+
{:maxwidth => nil, :maxheight => nil, :link_options => {}}.merge(options)
|
7
|
+
@regex = %r{https?://(www\.)?flickr\.com/photos/[^\s<]*}
|
8
|
+
|
9
|
+
string.gsub(@regex) do |match|
|
10
|
+
params = { :url => match, :format => "json" }
|
11
|
+
[:maxwidth, :maxheight].each{|p| params[p] = options[p] unless options[p].nil? or !options[p] > 0}
|
12
|
+
|
13
|
+
uri = URI("http://www.flickr.com/services/oembed")
|
14
|
+
uri.query = URI.encode_www_form(params)
|
15
|
+
|
16
|
+
response = JSON.parse(Net::HTTP.get(uri))
|
17
|
+
|
18
|
+
link_options = Array(options[:link_options]).reject { |k,v| v.nil? }.map { |k, v| %{#{k}="#{REXML::Text::normalize(v)}"} }.join(' ')
|
19
|
+
%{<a href="#{match}"#{ ' ' + link_options unless link_options.empty? }><img src="#{response["url"]}" alt="#{response["title"]}" title="#{response["title"]}" /></a>}
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Converters
|
2
|
+
|
3
|
+
def gist(string, options = {})
|
4
|
+
# https://gist.github.com/1710276
|
5
|
+
|
6
|
+
# No options at the moment
|
7
|
+
options = {}.merge(options)
|
8
|
+
|
9
|
+
@regex = %r{https?://gist\.github\.com/(\w+/)?(\d+)}
|
10
|
+
|
11
|
+
string.gsub(@regex) do
|
12
|
+
gist_id = $2
|
13
|
+
%{<script src="https://gist.github.com/#{gist_id}.js"></script>}
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Converters
|
2
|
+
|
3
|
+
def google_maps(string, options = {})
|
4
|
+
options = {
|
5
|
+
:width => 420,
|
6
|
+
:height => 315,
|
7
|
+
:style => "color:#000;text-align:left",
|
8
|
+
:link_text => "View Larger Map",
|
9
|
+
:show_info => true,
|
10
|
+
:type => :normal,
|
11
|
+
:zoom => 18,
|
12
|
+
:more => ''
|
13
|
+
}.merge(options)
|
14
|
+
|
15
|
+
map_type = {:normal => '&t=m', :satellite => '&t=k', :terrain => '&t=p', :hybrid => '&t=h'}
|
16
|
+
|
17
|
+
@regex = /(https?):\/\/maps\.google\.([a-z\.]+)\/maps\?(.*)/
|
18
|
+
|
19
|
+
string.gsub(@regex) do
|
20
|
+
domain_country = $2
|
21
|
+
map_query = $3
|
22
|
+
width = options[:width]
|
23
|
+
height = options[:height]
|
24
|
+
style = options[:style]
|
25
|
+
link_text = options[:link_text]
|
26
|
+
type = options[:type].to_sym
|
27
|
+
map_options = (options[:show_info] ? '' : '&iwloc=near')
|
28
|
+
map_options << map_type[type] if map_type.has_key?(type)
|
29
|
+
map_options << "&z=#{options[:zoom]}"
|
30
|
+
map_options << options[:more]
|
31
|
+
%{<iframe width="#{width}" height="#{height}" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="//maps.google.#{domain_country}/maps?f=q&source=s_q&#{map_query}&output=embed#{map_options}"></iframe><br><small><a href="//maps.google.#{domain_country}/maps?f=q&source=embed&#{map_query}" style="#{style}">#{link_text}</a></small>}
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Converters
|
2
|
+
|
3
|
+
def hashtag(string, options = {})
|
4
|
+
options = {:source => :twitter}.merge(options)
|
5
|
+
@regex = /#([^\s]+)/
|
6
|
+
|
7
|
+
if options[:source] == :twitter
|
8
|
+
string.gsub(@regex, '<a href="http://twitter.com/search?q=%23\1&f=realtime" class="hashtag" target="_blank">#\1</a>')
|
9
|
+
elsif options[:source] == :facebook
|
10
|
+
string.gsub(@regex, '<a href="https://www.facebook.com/hashtag/\1" class="hashtag" target="_blank">#\1</a>')
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module Converters
|
2
|
+
|
3
|
+
# Escape html
|
4
|
+
def escape_html(string, options = {})
|
5
|
+
options = {:map => {'&' => '&', '>' => '>', '<' => '<', '"' => '"' }}.merge(options)
|
6
|
+
|
7
|
+
@regex = /[&"><]/
|
8
|
+
string.gsub(@regex){|m| options[:map][m]}
|
9
|
+
end
|
10
|
+
|
11
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module Converters
|
2
|
+
|
3
|
+
# Iframe embed code
|
4
|
+
def iframe_embed(url, options = {})
|
5
|
+
options = {:width => 231, :height => 436, :scrolling => 'no', :frameborder => 0}.merge(options)
|
6
|
+
|
7
|
+
%{<iframe frameborder="#{options[:frameborder]}" scrolling="#{options[:scrolling]}" height="#{options[:height]}" width="#{options[:width]}" src="#{url}"></iframe>}
|
8
|
+
end
|
9
|
+
|
10
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Converters
|
2
|
+
|
3
|
+
def instagram(string, options = {})
|
4
|
+
options = {:height => 714, :width => 616}.merge(options)
|
5
|
+
@regex = %r{https?:\/\/(www.)?instagr(am\.com|\.am)/p/.+}
|
6
|
+
|
7
|
+
string.gsub(@regex) do
|
8
|
+
string += '/' unless string.end_with?('/')
|
9
|
+
%{<iframe src="#{string}embed" height="#{options[:height]}" width="#{options[:width]}" frameborder="0" scrolling="no"></iframe>}
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Converters
|
2
|
+
|
3
|
+
def kramdown(string, options = {})
|
4
|
+
options = {
|
5
|
+
:auto_ids => false,
|
6
|
+
:entity_output => :as_char,
|
7
|
+
:enable_coderay => true,
|
8
|
+
:parse_block_html => true,
|
9
|
+
:parse_span_html => true,
|
10
|
+
:smart_quotes => ['apos', 'apos', 'quot', 'quot']
|
11
|
+
}.merge(options)
|
12
|
+
|
13
|
+
Kramdown::Document.new(string, options).to_html
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Converters
|
2
|
+
|
3
|
+
def liveleak(string, options = {})
|
4
|
+
options = {
|
5
|
+
:width => 420,
|
6
|
+
:height => 315,
|
7
|
+
:frameborder => 0,
|
8
|
+
:wmode => nil,
|
9
|
+
:autoplay => false,
|
10
|
+
:hide_related => false
|
11
|
+
}.merge(options)
|
12
|
+
|
13
|
+
@regex = %r{http://www\.liveleak\.com/(?:ll_embed|view)\?.=(\w+)}
|
14
|
+
|
15
|
+
string.gsub(@regex) do
|
16
|
+
a = []
|
17
|
+
a << "wmode=#{options[:wmode]}" if options[:wmode]
|
18
|
+
a << "autoplay=1" if options[:autoplay]
|
19
|
+
a << "rel=0" if options[:hide_related]
|
20
|
+
|
21
|
+
src = "http://www.liveleak.com/ll_embed?f=#{$1}"
|
22
|
+
src += "?#{a.join '&'}" unless a.empty?
|
23
|
+
|
24
|
+
%{<iframe width="#{options[:width]}" height="#{options[:height]}" src="#{src}" frameborder="#{options[:frameborder]}" allowfullscreen></iframe>}
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Converters
|
2
|
+
|
3
|
+
# Converts the string into html
|
4
|
+
def markdown(string, options = {})
|
5
|
+
options = {
|
6
|
+
:autolink => true,
|
7
|
+
:fenced_code_blocks => true,
|
8
|
+
:disable_indented_code_blocks => true,
|
9
|
+
:no_intra_emphasis => true
|
10
|
+
}.merge(options)
|
11
|
+
|
12
|
+
Redcarpet::Markdown.new(
|
13
|
+
Redcarpet::Render::HTML.new(:filter_html => false, :hard_wrap => true),
|
14
|
+
options
|
15
|
+
).render(string)
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Converters
|
2
|
+
|
3
|
+
# Convert metacafe movie URL to embedded html
|
4
|
+
def metacafe(string, options = {})
|
5
|
+
# Original 440 272
|
6
|
+
options = {
|
7
|
+
:width => 590,
|
8
|
+
:height => 335,
|
9
|
+
:show_stats => false,
|
10
|
+
:autoplay => false
|
11
|
+
}.merge(options)
|
12
|
+
|
13
|
+
@regex = /http:\/\/www\.metacafe\.com\/watch\/([A-Za-z0-9._%-]*)\/([A-Za-z0-9._%-]*)(\/)?/
|
14
|
+
|
15
|
+
string.gsub(@regex) do
|
16
|
+
metacafe_id = $1
|
17
|
+
metacafe_slug = $2
|
18
|
+
width = options[:width]
|
19
|
+
height = options[:height]
|
20
|
+
show_stats = options[:show_stats] ? "showStats=yes" : "showStats=no"
|
21
|
+
autoplay = options[:autoplay] ? "autoPlay=yes" : "autoPlay=no"
|
22
|
+
flash_vars = [show_stats, autoplay].join("|")
|
23
|
+
|
24
|
+
%{<div style="background:#000000;width:#{width}px;height:#{height}px"><embed flashVars="playerVars=#{flash_vars}" src="http://www.metacafe.com/fplayer/#{metacafe_id}/#{metacafe_slug}.swf" width="#{width}" height="#{height}" wmode="transparent" allowFullScreen="true" allowScriptAccess="always" name="Metacafe_#{metacafe_id}" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed></div>}
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Converters
|
2
|
+
|
3
|
+
SKIP = ['a', 'pre', 'code', 'kbd', 'script', 'iframe', 'img', 'link']
|
4
|
+
|
5
|
+
# Scan a string with Nokogiri and convert if match string
|
6
|
+
def scan(string, options = {})
|
7
|
+
return string if options[:converters].empty?
|
8
|
+
|
9
|
+
doc = Nokogiri::HTML.fragment(string)
|
10
|
+
|
11
|
+
doc.search('.//text()').each do |el|
|
12
|
+
t = el.text
|
13
|
+
if t.strip.size > 0
|
14
|
+
t = convert(t, options) if convertable?(el)
|
15
|
+
end
|
16
|
+
el.replace(t)
|
17
|
+
end
|
18
|
+
|
19
|
+
doc.to_html
|
20
|
+
end
|
21
|
+
|
22
|
+
# Loop converters and convert
|
23
|
+
def convert(string, options = {})
|
24
|
+
options[:converters].each{|c| string = send(c, string)}
|
25
|
+
string
|
26
|
+
end
|
27
|
+
|
28
|
+
# Checks if a node is convertable by scanning the parents
|
29
|
+
def convertable?(node)
|
30
|
+
while(node = node.parent) do
|
31
|
+
return false if SKIP.include?(node.name)
|
32
|
+
end
|
33
|
+
true
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module Converters
|
2
|
+
|
3
|
+
# Markown converter
|
4
|
+
def redcarpet(string, options = {})
|
5
|
+
options = {:renderer => Redcarpet::Render::HTML, :markdown_options => {}}.merge(options)
|
6
|
+
|
7
|
+
Redcarpet::Markdown.new(options[:renderer], options[:markdown_options]).render(string)
|
8
|
+
end
|
9
|
+
|
10
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Converters
|
2
|
+
|
3
|
+
CONFIGS = [:custom, :full, :linebreaks, :simple, :restricted, :basic, :relaxed]
|
4
|
+
|
5
|
+
def sanitize(string, options = {})
|
6
|
+
return string if options[:config] == false
|
7
|
+
options = {:config => nil}.merge(options)
|
8
|
+
|
9
|
+
config = Object.const_get("Sanitize::Config::#{options[:config].to_s.upcase}") if CONFIGS.include?(options[:config])
|
10
|
+
Sanitize.fragment(string, config || {})
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Converters
|
2
|
+
|
3
|
+
# Convert soundcloud player URL to embedded iframe
|
4
|
+
def soundcloud(string, options = {})
|
5
|
+
options = {
|
6
|
+
:width => '100%',
|
7
|
+
:height => 166,
|
8
|
+
:auto_play => false,
|
9
|
+
:theme_color => '00FF00',
|
10
|
+
:color => '915f33',
|
11
|
+
:show_comments => false,
|
12
|
+
:show_artwork => false
|
13
|
+
}.merge(options)
|
14
|
+
|
15
|
+
@regex = /(https?:\/\/)?(www.)?soundcloud\.com\/\S*/
|
16
|
+
|
17
|
+
begin
|
18
|
+
string.gsub(@regex) do |match|
|
19
|
+
new_uri = match.to_s
|
20
|
+
new_uri = (new_uri =~ /^https?\:\/\/.*/) ? URI(new_uri) : URI("http://#{new_uri}")
|
21
|
+
new_uri.normalize!
|
22
|
+
width = options[:width]
|
23
|
+
height = options[:height]
|
24
|
+
auto_play = options[:auto_play]
|
25
|
+
theme_color = options[:theme_color]
|
26
|
+
color = options[:color]
|
27
|
+
show_artwork = options[:show_artwork]
|
28
|
+
show_comments = options[:show_comments]
|
29
|
+
%{<iframe width="#{width}" height="#{height}" scrolling="no" frameborder="no" src="http://w.soundcloud.com/player/?url=#{new_uri}&show_artwork=#{show_artwork}&show_comments=#{show_comments}&auto_play=#{auto_play}&color=#{color}&theme_color=#{theme_color}"></iframe> }
|
30
|
+
end
|
31
|
+
rescue URI::InvalidURIError
|
32
|
+
string
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Converters
|
2
|
+
|
3
|
+
# Convert ted movie URL to embedded iframe
|
4
|
+
def ted(string, options = {})
|
5
|
+
# Original: 640 360
|
6
|
+
options = {
|
7
|
+
:width => 590,
|
8
|
+
:height => 335,
|
9
|
+
:scrolling => 'no',
|
10
|
+
:frameborder => 0,
|
11
|
+
:allow_full_screen => false
|
12
|
+
}.merge(options)
|
13
|
+
|
14
|
+
@regex = /https?:\/\/(www.|embed.)?ted\.com\/talks\/([A-Za-z0-9._%-]*)\.html((\?|#)\S+)?/
|
15
|
+
|
16
|
+
string.gsub(@regex) do
|
17
|
+
ted_page = $2
|
18
|
+
width = options[:width]
|
19
|
+
height = options[:height]
|
20
|
+
frameborder = options[:frameborder]
|
21
|
+
scrolling = options[:scrolling]
|
22
|
+
allow_full_screen = options[:allow_full_screen]
|
23
|
+
|
24
|
+
%{<iframe width="#{width}" height="#{height}" frameborder="#{frameborder}" scrolling="#{scrolling}" src="http://embed.ted.com/talks/#{ted_page}.html"#{allow_full_screen ? ' webkitAllowFullScreen mozallowfullscreen allowFullScreen' : ''}></iframe>}
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Converters
|
2
|
+
|
3
|
+
# Convert twitter URL to embedded html
|
4
|
+
def twitter(string, options = {})
|
5
|
+
@regex = %r{(?<!href=")https://twitter\.com(/#!)?/[A-Za-z0-9_]{1,15}/status(es)?/\d+(/?)}
|
6
|
+
|
7
|
+
string.gsub(@regex) do |match|
|
8
|
+
params = {:url => match}.merge(options)
|
9
|
+
|
10
|
+
uri = URI("https://api.twitter.com/1/statuses/oembed.json")
|
11
|
+
uri.query = URI.encode_www_form(params)
|
12
|
+
|
13
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
14
|
+
http.use_ssl = true
|
15
|
+
|
16
|
+
response = JSON.parse(http.get(uri.request_uri).body)
|
17
|
+
response["html"]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Converters
|
2
|
+
|
3
|
+
# Vimeo and Youtube embed markdown extension
|
4
|
+
def video_embed(string, options = {})
|
5
|
+
@regex = /\?\[(youtube|vimeo)\]\(https?:\/\/(www\.)?(vimeo\.com\/|youtu\.be\/|youtube\.com\/watch\?v=)(\S+)\)/
|
6
|
+
|
7
|
+
string.scan(@regex).each do |type, prefix, url, id|
|
8
|
+
r = if('vimeo' == type)
|
9
|
+
vimeo_embed(options)
|
10
|
+
elsif('youtube' == type)
|
11
|
+
youtube_embed(options)
|
12
|
+
else
|
13
|
+
nil
|
14
|
+
end
|
15
|
+
# Substitute the original text with the embedded version
|
16
|
+
# OLD, optional https not supported:
|
17
|
+
# @text.gsub!("?[#{type}](https://#{prefix}#{url}#{id})", r) if r
|
18
|
+
x = %r{\?\[#{type}\]\(https?:\/\/#{Regexp.escape(prefix)}#{Regexp.escape(url)}#{id}\)}i
|
19
|
+
string.gsub!(x, r) if r
|
20
|
+
end
|
21
|
+
string
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Converters
|
2
|
+
|
3
|
+
# Convert vimeo movie URL to embedded iframe
|
4
|
+
def vimeo(string, options = {})
|
5
|
+
# Original: 440 248
|
6
|
+
options = {
|
7
|
+
:width => 590,
|
8
|
+
:height => 335,
|
9
|
+
:show_title => false,
|
10
|
+
:show_byline => false,
|
11
|
+
:show_portrait => false,
|
12
|
+
:allow_fullscreen => true
|
13
|
+
}.merge(options)
|
14
|
+
|
15
|
+
@regex = /https?:\/\/(www.)?vimeo\.com\/([A-Za-z0-9._%-]*)((\?|#)\S+)?/
|
16
|
+
|
17
|
+
string.gsub(@regex) do
|
18
|
+
vimeo_id = $2
|
19
|
+
width = options[:width]
|
20
|
+
height = options[:height]
|
21
|
+
show_title = "title=0" unless options[:show_title]
|
22
|
+
show_byline = "byline=0" unless options[:show_byline]
|
23
|
+
show_portrait = "portrait=0" unless options[:show_portrait]
|
24
|
+
allow_fullscreen = " allowfullscreen" if options[:allow_fullscreen]
|
25
|
+
frameborder = options[:frameborder] || 0
|
26
|
+
query_string_variables = [show_title, show_byline, show_portrait].compact.join("&")
|
27
|
+
query_string = "?" + query_string_variables unless query_string_variables.empty?
|
28
|
+
|
29
|
+
%{<iframe src="//player.vimeo.com/video/#{vimeo_id}#{query_string}" width="#{width}" height="#{height}" frameborder="#{frameborder}"#{allow_fullscreen}></iframe>}
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module Converters
|
2
|
+
|
3
|
+
# Embed vimeo by id
|
4
|
+
def vimeo_embed(string, options = {})
|
5
|
+
{:width => 590, :height => 335}.merge(options)
|
6
|
+
|
7
|
+
%{<iframe src="https://player.vimeo.com/video/#{string}?title=0&byline=0&portrait=0" width="#{options[:width]}" height="#{options[:height]}"></iframe>}
|
8
|
+
end
|
9
|
+
|
10
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Converters
|
2
|
+
|
3
|
+
# Convert worldstar movie URL to embedded html
|
4
|
+
def worldstar(string, options = {})
|
5
|
+
# Original: 448 374
|
6
|
+
options = {:width => 590, :height => 335}.merge(options)
|
7
|
+
|
8
|
+
@regex = /http:\/\/www\.worldstarhiphop\.com\/videos\/video\.php\?v\=(wshh[A-Za-z0-9]+)/
|
9
|
+
|
10
|
+
string.gsub(@regex) do
|
11
|
+
video_id = $1
|
12
|
+
width = options[:width]
|
13
|
+
height = options[:height]
|
14
|
+
%{<object width="#{width}" height="#{height}"><param name="movie" value="http://www.worldstarhiphop.com/videos/e/16711680/#{video_id}"><param name="allowFullScreen" value="true"></param><embed src="http://www.worldstarhiphop.com/videos/e/16711680/#{video_id}" type="application/x-shockwave-flash" allowFullscreen="true" width="#{width}" height="#{height}"></embed></object>}
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module Converters
|
2
|
+
|
3
|
+
# Convert youtube movie URL to embedded iframe
|
4
|
+
def youtube(string, options = {})
|
5
|
+
# Original: 420 315
|
6
|
+
options = {
|
7
|
+
:width => 590,
|
8
|
+
:height => 335,
|
9
|
+
:frameborder => 0,
|
10
|
+
:wmode => 'transparent',
|
11
|
+
:autoplay => false,
|
12
|
+
:hide_related => true,
|
13
|
+
:fs => true,
|
14
|
+
:modestbranding => true,
|
15
|
+
:allow_fullscreen => true
|
16
|
+
}.merge(options)
|
17
|
+
|
18
|
+
@regex = /(https?:\/\/)?(www.)?(youtube\.com\/watch\?v=|youtu\.be\/|youtube\.com\/watch\?feature=player_embedded&v=)([A-Za-z0-9_-]*)(\&\S+)?(\?\S+)?/
|
19
|
+
|
20
|
+
string.gsub(@regex) do
|
21
|
+
youtube_id = $4
|
22
|
+
src = "https://www.youtube.com/embed/#{youtube_id}"
|
23
|
+
width = options[:width]
|
24
|
+
height = options[:height]
|
25
|
+
allow_fullscreen = " allowfullscreen" if options[:allow_fullscreen]
|
26
|
+
frameborder = options[:frameborder]
|
27
|
+
|
28
|
+
a = []
|
29
|
+
a << "wmode=#{options[:wmode]}" if options[:wmode]
|
30
|
+
a << "autoplay=1" if options[:autoplay]
|
31
|
+
a << "rel=0" if options[:hide_related]
|
32
|
+
a << "modestbranding=1" if options[:modestbranding]
|
33
|
+
a << "fs=1" if options[:fs]
|
34
|
+
|
35
|
+
src += "?#{a.join '&'}" unless a.empty?
|
36
|
+
|
37
|
+
%{<iframe width="#{width}" height="#{height}" src="#{src}" frameborder="#{frameborder}"#{allow_fullscreen}></iframe>}
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module Converters
|
2
|
+
|
3
|
+
# Embed youtube by id
|
4
|
+
def youtube_embed(string, options = {})
|
5
|
+
options = {:width => 590, :height => 335}.merge(options)
|
6
|
+
|
7
|
+
%{<iframe src="https://www.youtube.com/embed/#{string}?wmode=transparent&modestbranding=1&fs=1&rel=0" allowfullscreen="1" webkitallowfullscreen="1" mozallowfullscreen="1" width="#{options[:width]}" height="#{options[:height]}" frameborder="0"></iframe>}
|
8
|
+
end
|
9
|
+
|
10
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Converters
|
2
|
+
|
3
|
+
def youtube_image(string, options = {})
|
4
|
+
options = {
|
5
|
+
:width => 320,
|
6
|
+
:height => 315,
|
7
|
+
:style => 'medium',
|
8
|
+
:target => 'blank',
|
9
|
+
:border => '0'
|
10
|
+
}.merge(options)
|
11
|
+
|
12
|
+
styles = {
|
13
|
+
'default' => 'default',
|
14
|
+
'high' => 'hqdefault',
|
15
|
+
'medium' => 'mqdefault',
|
16
|
+
'normal' => 'sddefault',
|
17
|
+
'max' => 'maxresdefault'
|
18
|
+
}
|
19
|
+
|
20
|
+
@regex = /(https?:\/\/)?(www.)?(youtube\.com\/watch\?v=|youtu\.be\/|youtube\.com\/watch\?feature=player_embedded&v=)([A-Za-z0-9_-]*)(\&\S+)?(\?\S+)?/
|
21
|
+
|
22
|
+
string.gsub(@regex) do
|
23
|
+
youtube_id = $4
|
24
|
+
video_url = "https://www.youtube.com/watch?v=#{youtube_id}"
|
25
|
+
target = options[:target]
|
26
|
+
width = options[:width]
|
27
|
+
height = options[:height]
|
28
|
+
border = options[:border]
|
29
|
+
style = styles[options[:style]] rescue styles['default']
|
30
|
+
src = "//img.youtube.com/vi/#{youtube_id}/#{style}.jpg"
|
31
|
+
%{<div class="thumbnail youtube"><a href="#{video_url}" target="_#{target}"><img src="#{src}" width="#{width}" height="#{height}" border="#{border}"></a></div>}
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Converters
|
2
|
+
|
3
|
+
def youtube_js_api(string, options = {})
|
4
|
+
# Original: 390 250
|
5
|
+
options = {:width => 590, :height => 335}.merge(options)
|
6
|
+
|
7
|
+
@regex = /https?:\/\/(www.)?youtube\.com\/watch\?v=([A-Za-z0-9._%-]*)(\&\S+)?/
|
8
|
+
|
9
|
+
string.gsub(@regex) do
|
10
|
+
youtube_id = $2
|
11
|
+
width = options[:width]
|
12
|
+
height = options[:height]
|
13
|
+
|
14
|
+
%{<object width="#{width}" height="#{height}"><param name="movie" value="//www.youtube.com/v/#{youtube_id}?enablejsapi=1&playerapiid=ytplayer"></param><param name="wmode" value="transparent"></param><param name="allowscriptaccess" value="always"></param><embed src="//www.youtube.com/v/#{youtube_id}?enablejsapi=1&playerapiid=ytplayer" type="application/x-shockwave-flash" wmode="transparent" width="#{width}" height="#{height}" allowscriptaccess="always"></embed></object>}
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
class Sanitize
|
2
|
+
module Config
|
3
|
+
|
4
|
+
CUSTOM = {
|
5
|
+
:elements => %w[
|
6
|
+
a abbr b blockquote br caption cite code col colgroup dd del div dl
|
7
|
+
dt nav em figcaption figure font form h1 h2 h3 h4 h5 h6 hgroup hr i img input ins li label link
|
8
|
+
ol p pre s small span strike strong style sub sup table tbody td
|
9
|
+
tfoot th thead time tr u ul iframe
|
10
|
+
],
|
11
|
+
|
12
|
+
:attributes => {
|
13
|
+
:all => ['dir', 'lang', 'title', 'class', 'style', 'id'],
|
14
|
+
'a' => ['href', 'target'],
|
15
|
+
'blockquote' => ['cite'],
|
16
|
+
'col' => ['span', 'width'],
|
17
|
+
'colgroup' => ['span', 'width'],
|
18
|
+
'del' => ['cite', 'datetime'],
|
19
|
+
'img' => ['align', 'alt', 'height', 'src', 'width'],
|
20
|
+
'ins' => ['cite', 'datetime'],
|
21
|
+
'input' => ['name','placeholder', 'type', 'value', 'width'],
|
22
|
+
'form' => ['action', 'method', 'name'],
|
23
|
+
'link' => ['href', 'rel', 'type'],
|
24
|
+
'ol' => ['start', 'reversed', 'type'],
|
25
|
+
'q' => ['cite'],
|
26
|
+
'table' => ['summary', 'width'],
|
27
|
+
'td' => ['abbr', 'axis', 'colspan', 'rowspan', 'width'],
|
28
|
+
'th' => ['abbr', 'axis', 'colspan', 'rowspan', 'scope', 'width'],
|
29
|
+
'time' => ['datetime', 'pubdate'],
|
30
|
+
'ul' => ['type'],
|
31
|
+
'iframe' => ['width', 'height', 'src', 'allowFullScreen']
|
32
|
+
},
|
33
|
+
|
34
|
+
:protocols => {
|
35
|
+
'a' => {'href' => ['ftp', 'http', 'https', 'mailto', :relative]},
|
36
|
+
'img' => {'src' => ['http', 'https', :relative]},
|
37
|
+
'ins' => {'cite' => ['http', 'https', :relative]},
|
38
|
+
'q' => {'cite' => ['http', 'https', :relative]}
|
39
|
+
},
|
40
|
+
|
41
|
+
:add_attributes => {}
|
42
|
+
}
|
43
|
+
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
class Sanitize
|
2
|
+
module Config
|
3
|
+
|
4
|
+
FULL = {
|
5
|
+
:elements => %w[
|
6
|
+
a abbr b blockquote br caption cite code col colgroup dd del div dl
|
7
|
+
dt nav em figcaption figure font form h1 h2 h3 h4 h5 h6 hgroup hr i img input ins li label link
|
8
|
+
ol p pre s script small span strike strong style sub sup table tbody td
|
9
|
+
tfoot th thead time tr u ul iframe
|
10
|
+
],
|
11
|
+
|
12
|
+
:attributes => {
|
13
|
+
:all => ['dir', 'lang', 'title', 'class', 'style', 'id'],
|
14
|
+
'a' => ['href', 'target'],
|
15
|
+
'blockquote' => ['cite'],
|
16
|
+
'col' => ['span', 'width'],
|
17
|
+
'colgroup' => ['span', 'width'],
|
18
|
+
'del' => ['cite', 'datetime'],
|
19
|
+
'img' => ['align', 'alt', 'height', 'src', 'width'],
|
20
|
+
'ins' => ['cite', 'datetime'],
|
21
|
+
'input' => ['name','placeholder', 'type', 'value', 'width'],
|
22
|
+
'form' => ['action', 'method', 'name'],
|
23
|
+
'link' => ['href', 'rel', 'type'],
|
24
|
+
'ol' => ['start', 'reversed', 'type'],
|
25
|
+
'q' => ['cite'],
|
26
|
+
'table' => ['summary', 'width'],
|
27
|
+
'td' => ['abbr', 'axis', 'colspan', 'rowspan', 'width'],
|
28
|
+
'th' => ['abbr', 'axis', 'colspan', 'rowspan', 'scope', 'width'],
|
29
|
+
'time' => ['datetime', 'pubdate'],
|
30
|
+
'ul' => ['type'],
|
31
|
+
'iframe' => ['width', 'height', 'src', 'allowFullScreen'],
|
32
|
+
'script' => ['src', 'type']
|
33
|
+
},
|
34
|
+
|
35
|
+
:protocols => {
|
36
|
+
'a' => {'href' => ['ftp', 'http', 'https', 'mailto', :relative]},
|
37
|
+
'img' => {'src' => ['http', 'https', :relative]},
|
38
|
+
'ins' => {'cite' => ['http', 'https', :relative]},
|
39
|
+
'q' => {'cite' => ['http', 'https', :relative]}
|
40
|
+
},
|
41
|
+
|
42
|
+
:add_attributes => {}
|
43
|
+
}
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
data/test.rb
ADDED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: convert
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fugroup Limited
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-01-
|
11
|
+
date: 2017-01-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redcarpet
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '1.6'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: futest
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
97
111
|
description: Easily convert any string and replace with links and embedded content
|
98
112
|
from a long list of providers and libraries.
|
99
113
|
email: mail@fugroup.net
|
@@ -101,7 +115,53 @@ executables: []
|
|
101
115
|
extensions: []
|
102
116
|
extra_rdoc_files: []
|
103
117
|
files:
|
118
|
+
- ".gitignore"
|
119
|
+
- CHANGELOG.md
|
120
|
+
- Gemfile
|
121
|
+
- LICENSE
|
122
|
+
- README.md
|
123
|
+
- config/boot.rb
|
124
|
+
- convert.gemspec
|
104
125
|
- lib/convert.rb
|
126
|
+
- lib/converters/auto_link.rb
|
127
|
+
- lib/converters/dailymotion.rb
|
128
|
+
- lib/converters/decode.rb
|
129
|
+
- lib/converters/email_escape.rb
|
130
|
+
- lib/converters/encode.rb
|
131
|
+
- lib/converters/flickr.rb
|
132
|
+
- lib/converters/gist.rb
|
133
|
+
- lib/converters/google_maps.rb
|
134
|
+
- lib/converters/hashtag.rb
|
135
|
+
- lib/converters/html_escape.rb
|
136
|
+
- lib/converters/iframe_embed.rb
|
137
|
+
- lib/converters/image_tag.rb
|
138
|
+
- lib/converters/instagram.rb
|
139
|
+
- lib/converters/kramdown.rb
|
140
|
+
- lib/converters/liveleak.rb
|
141
|
+
- lib/converters/markdown.rb
|
142
|
+
- lib/converters/metacafe.rb
|
143
|
+
- lib/converters/nokogiri.rb
|
144
|
+
- lib/converters/redcarpet.rb
|
145
|
+
- lib/converters/sanitize.rb
|
146
|
+
- lib/converters/simple_format.rb
|
147
|
+
- lib/converters/soundcloud.rb
|
148
|
+
- lib/converters/strip_params.rb
|
149
|
+
- lib/converters/ted.rb
|
150
|
+
- lib/converters/twitter.rb
|
151
|
+
- lib/converters/unescape_html.rb
|
152
|
+
- lib/converters/video_embed.rb
|
153
|
+
- lib/converters/vimeo.rb
|
154
|
+
- lib/converters/vimeo_embed.rb
|
155
|
+
- lib/converters/worldstar.rb
|
156
|
+
- lib/converters/youtube.rb
|
157
|
+
- lib/converters/youtube_embed.rb
|
158
|
+
- lib/converters/youtube_image.rb
|
159
|
+
- lib/converters/youtube_js_api.rb
|
160
|
+
- lib/sanitizers/custom.rb
|
161
|
+
- lib/sanitizers/full.rb
|
162
|
+
- lib/sanitizers/linebreaks.rb
|
163
|
+
- lib/sanitizers/simple.rb
|
164
|
+
- test.rb
|
105
165
|
homepage: https://github.com/fugroup/convert
|
106
166
|
licenses:
|
107
167
|
- MIT
|
@@ -122,7 +182,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
122
182
|
version: '0'
|
123
183
|
requirements: []
|
124
184
|
rubyforge_project:
|
125
|
-
rubygems_version: 2.
|
185
|
+
rubygems_version: 2.6.8
|
126
186
|
signing_key:
|
127
187
|
specification_version: 4
|
128
188
|
summary: Convert strings and HTML to links and embedded content
|