unlock_auto_html 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0620740d3daa550582e5cd937026dd990da1bb25
4
+ data.tar.gz: 5baf2e36712e09994095f1c6586311a21ad2b450
5
+ SHA512:
6
+ metadata.gz: 7964ede2ebeb64fbd2a2d18a0c91706d86ca5f1ac859cd1ea294dd4eeef99bc0bae22e5f585213ac281c96e1565b7dcf4f2b4c4600521a54d570d12f501e4dc7
7
+ data.tar.gz: a63eb3b3d8a3a401cd6de14e13905c2384534d5c988702aaa1b62f192430afdded7bca69e2bc37de047ea6000392522b3d1b8cbea1a718c08cc39db5a6f3b8d6
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2014 YOURNAME
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,21 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'UnlockAutoHtml'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.rdoc')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+
18
+
19
+
20
+ Bundler::GemHelper.install_tasks
21
+
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :unlock_auto_html do
3
+ # # Task goes here
4
+ # end
@@ -0,0 +1,30 @@
1
+ module UnlockAutoHtml
2
+ module ActiveRecord
3
+
4
+ def self.included(base)
5
+ base.extend(ClassMethods)
6
+ end
7
+
8
+ module ClassMethods
9
+ def unlock_auto_html_for *attributes
10
+ attributes.each do |attribute|
11
+ self.auto_html_for attribute do
12
+ html_escape map: {
13
+ '&' => '&amp;',
14
+ '>' => '&gt;',
15
+ '<' => '&lt;',
16
+ '"' => '"'
17
+ }
18
+ image
19
+ youtube width: '100%', height: 403, wmode: "opaque"
20
+ vimeo width: '100%', height: 403
21
+ soundcloud width: '100%', height: 403
22
+ redcloth target: :_blank
23
+ link target: :_blank
24
+ end
25
+ end
26
+ end
27
+ end
28
+
29
+ end
30
+ end
@@ -0,0 +1,9 @@
1
+ require 'redcloth'
2
+
3
+ AutoHtml.add_filter(:redcloth).with({}) do |text, options|
4
+ result = RedCloth.new(text).to_html
5
+ if options and options[:target] and options[:target].to_sym == :_blank
6
+ result.gsub!(/<a/,'<a target="_blank"')
7
+ end
8
+ result
9
+ end
@@ -0,0 +1,17 @@
1
+ AutoHtml.add_filter(:soundcloud).with(:width => '100%', :height => 166, :auto_play => false, :theme_color => '00FF00', :color => '915f33', :show_comments => false, :show_artwork => false) do |text, options|
2
+ require 'uri'
3
+ require 'net/http'
4
+ text.gsub(/(https?:\/\/)?(www.)?soundcloud\.com\/\S*/) do |match|
5
+ new_uri = match.to_s
6
+ new_uri = (new_uri =~ /^https?\:\/\/.*/) ? URI(new_uri) : URI("http://#{new_uri}")
7
+ new_uri.normalize!
8
+ width = options[:width]
9
+ height = options[:height]
10
+ auto_play = options[:auto_play]
11
+ theme_color = options[:theme_color]
12
+ color = options[:color]
13
+ show_artwork = options[:show_artwork]
14
+ show_comments = options[:show_comments]
15
+ %{<iframe width="#{width}" height="#{height}" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?url=#{new_uri}&show_artwork=#{show_artwork}&show_comments=#{show_comments}&auto_play=#{auto_play}"></iframe>}
16
+ end
17
+ end
@@ -0,0 +1,15 @@
1
+ AutoHtml.add_filter(:vimeo).with(:width => 440, :height => 248, :show_title => false, :show_byline => false, :show_portrait => false) do |text, options|
2
+ text.gsub(/https?:\/\/(www.)?vimeo\.com\/([A-Za-z0-9._%-]*)((\?|#)\S+)?/) do
3
+ vimeo_id = $2
4
+ width = options[:width]
5
+ height = options[:height]
6
+ show_title = "title=0" unless options[:show_title]
7
+ show_byline = "byline=0" unless options[:show_byline]
8
+ show_portrait = "portrait=0" unless options[:show_portrait]
9
+ frameborder = options[:frameborder] || 0
10
+ query_string_variables = [show_title, show_byline, show_portrait].compact.join("&")
11
+ query_string = "?" + query_string_variables unless query_string_variables.empty?
12
+
13
+ %{<iframe src="https://player.vimeo.com/video/#{vimeo_id}#{query_string}" width="#{width}" height="#{height}" frameborder="#{frameborder}"></iframe>}
14
+ end
15
+ end
@@ -0,0 +1,19 @@
1
+ AutoHtml.add_filter(:youtube).with(:width => 420, :height => 315, :frameborder => 0, :wmode => nil, :autoplay => false, :hide_related => false) do |text, options|
2
+ regex = /(https?:\/\/)?(www.)?(youtube\.com\/watch\?v=|youtu\.be\/|youtube\.com\/watch\?feature=player_embedded&v=)([A-Za-z0-9_-]*)(\&\S+)?(\?\S+)?/
3
+ text.gsub(regex) do
4
+ youtube_id = $4
5
+ width = options[:width]
6
+ height = options[:height]
7
+ frameborder = options[:frameborder]
8
+ wmode = options[:wmode]
9
+ autoplay = options[:autoplay]
10
+ hide_related = options[:hide_related]
11
+ src = "https://www.youtube.com/embed/#{youtube_id}"
12
+ params = []
13
+ params << "wmode=#{wmode}" if wmode
14
+ params << "autoplay=1" if autoplay
15
+ params << "rel=0" if hide_related
16
+ src += "?#{params.join '&'}" unless params.empty?
17
+ %{<div class="video youtube"><iframe width="#{width}" height="#{height}" src="#{src}" frameborder="#{frameborder}" allowfullscreen></iframe></div>}
18
+ end
19
+ end
@@ -0,0 +1,3 @@
1
+ module UnlockAutoHtml
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,15 @@
1
+ require 'auto_html'
2
+ Dir["#{File.dirname(__FILE__) + '/unlock_auto_html/filters'}/**/*"].each do |filter|
3
+ require "#{filter}"
4
+ end
5
+
6
+ module UnlockAutoHtml
7
+ end
8
+
9
+ # if defined?(ActiveRecord::Base)
10
+ require 'unlock_auto_html/active_record'
11
+ class ActiveRecord::Base
12
+ include UnlockAutoHtml::ActiveRecord
13
+ end
14
+ # ActiveRecord::Base.send :include, UnlockAutoHtml::ActiveRecord
15
+ # end
metadata ADDED
@@ -0,0 +1,96 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: unlock_auto_html
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Daniel Weinmann
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-11-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: 4.1.6
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 4.1.6
27
+ - !ruby/object:Gem::Dependency
28
+ name: RedCloth
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: auto_html
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '='
46
+ - !ruby/object:Gem::Version
47
+ version: 1.5.1
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '='
53
+ - !ruby/object:Gem::Version
54
+ version: 1.5.1
55
+ description: AutoHtml helper and filters for Unlock
56
+ email:
57
+ - danielweinmann@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - MIT-LICENSE
63
+ - Rakefile
64
+ - lib/tasks/unlock_auto_html_tasks.rake
65
+ - lib/unlock_auto_html.rb
66
+ - lib/unlock_auto_html/active_record.rb
67
+ - lib/unlock_auto_html/filters/redcloth.rb
68
+ - lib/unlock_auto_html/filters/soundcloud.rb
69
+ - lib/unlock_auto_html/filters/vimeo.rb
70
+ - lib/unlock_auto_html/filters/youtube.rb
71
+ - lib/unlock_auto_html/version.rb
72
+ homepage: https://github.com/danielweinmann/unlock_auto_html
73
+ licenses:
74
+ - MIT
75
+ metadata: {}
76
+ post_install_message:
77
+ rdoc_options: []
78
+ require_paths:
79
+ - lib
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - '>='
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ requirements: []
91
+ rubyforge_project:
92
+ rubygems_version: 2.4.2
93
+ signing_key:
94
+ specification_version: 4
95
+ summary: AutoHtml helper and filters for Unlock
96
+ test_files: []