auto_html 1.6.2 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +65 -94
- data/Rakefile +8 -7
- data/lib/auto_html/emoji.rb +54 -0
- data/lib/auto_html/html_escape.rb +12 -0
- data/lib/auto_html/image.rb +23 -0
- data/lib/auto_html/link.rb +33 -0
- data/lib/auto_html/markdown.rb +17 -0
- data/lib/auto_html/pipeline.rb +18 -0
- data/lib/auto_html/simple_format.rb +23 -0
- data/lib/auto_html/tag_helper.rb +38 -0
- data/lib/auto_html.rb +11 -15
- data/spec/auto_html/emoji_spec.rb +12 -0
- data/spec/auto_html/html_escape_spec.rb +10 -0
- data/spec/auto_html/image_spec.rb +41 -0
- data/spec/auto_html/link_spec.rb +53 -0
- data/spec/auto_html/markdown_spec.rb +9 -0
- data/spec/auto_html/pipeline_spec.rb +26 -0
- data/spec/auto_html/simple_format_spec.rb +18 -0
- data/spec/auto_html/tag_helper_spec.rb +30 -0
- data/spec/spec_helper.rb +13 -0
- metadata +114 -90
- data/lib/auto_html/auto_html_for.rb +0 -64
- data/lib/auto_html/base.rb +0 -18
- data/lib/auto_html/builder.rb +0 -21
- data/lib/auto_html/capistrano.rb +0 -17
- data/lib/auto_html/filter.rb +0 -22
- data/lib/auto_html/filters/dailymotion.rb +0 -6
- data/lib/auto_html/filters/flickr.rb +0 -20
- data/lib/auto_html/filters/gist.rb +0 -8
- data/lib/auto_html/filters/google_map.rb +0 -19
- data/lib/auto_html/filters/google_video.rb +0 -6
- data/lib/auto_html/filters/hashtag.rb +0 -7
- data/lib/auto_html/filters/html_escape.rb +0 -9
- data/lib/auto_html/filters/image.rb +0 -16
- data/lib/auto_html/filters/instagram.rb +0 -10
- data/lib/auto_html/filters/link.rb +0 -16
- data/lib/auto_html/filters/metacafe.rb +0 -13
- data/lib/auto_html/filters/redcarpet.rb +0 -4
- data/lib/auto_html/filters/sanitize.rb +0 -5
- data/lib/auto_html/filters/simple_format.rb +0 -12
- data/lib/auto_html/filters/soundcloud.rb +0 -21
- data/lib/auto_html/filters/ted.rb +0 -13
- data/lib/auto_html/filters/twitter.rb +0 -16
- data/lib/auto_html/filters/vimeo.rb +0 -15
- data/lib/auto_html/filters/worldstar.rb +0 -8
- data/lib/auto_html/filters/youtube.rb +0 -19
- data/lib/auto_html/filters/youtube_js_api.rb +0 -6
- data/lib/auto_html/railtie.rb +0 -10
- data/lib/auto_html/rake_tasks.rb +0 -27
- data/lib/auto_html/task.rb +0 -9
- data/test/fixture_setup.rb +0 -13
- data/test/fixtures/database.yml +0 -5
- data/test/fixtures/schema.rb +0 -20
- data/test/functional/auto_html_for_options_test.rb +0 -26
- data/test/functional/auto_html_for_test.rb +0 -56
- data/test/functional/filter_test.rb +0 -27
- data/test/test_helper.rb +0 -9
- data/test/unit/auto_html_test.rb +0 -37
- data/test/unit/filters/dailymotion_test.rb +0 -20
- data/test/unit/filters/gist_test.rb +0 -15
- data/test/unit/filters/google_map_test.rb +0 -24
- data/test/unit/filters/hashtag_test.rb +0 -25
- data/test/unit/filters/html_escape_test.rb +0 -15
- data/test/unit/filters/image_test.rb +0 -65
- data/test/unit/filters/instagram_test.rb +0 -8
- data/test/unit/filters/link_test.rb +0 -55
- data/test/unit/filters/metacafe_test.rb +0 -29
- data/test/unit/filters/redcarpet_test.rb +0 -38
- data/test/unit/filters/sanitize_test.rb +0 -36
- data/test/unit/filters/simple_format_test.rb +0 -15
- data/test/unit/filters/soundcloud_test.rb +0 -29
- data/test/unit/filters/ted_test.rb +0 -18
- data/test/unit/filters/twitter_test.rb +0 -40
- data/test/unit/filters/vimeo_test.rb +0 -50
- data/test/unit/filters/worldstar_test.rb +0 -14
- data/test/unit/filters/youtube_js_api_test.rb +0 -30
- data/test/unit/filters/youtube_test.rb +0 -59
- data/test/unit/unit_test_helper.rb +0 -3
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
RSpec.describe AutoHtml::TagHelper do
|
6
|
+
it 'generates tag with attributes' do
|
7
|
+
result = subject.tag(:img, src: '1.png', alt: 'number one!')
|
8
|
+
expect(result).to eq '<img src="1.png" alt="number one!" />'
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'generates tag without attributes' do
|
12
|
+
result = subject.tag(:br)
|
13
|
+
expect(result).to eq '<br />'
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'generates content tags' do
|
17
|
+
result = subject.tag(:label, for: 'name') { 'Name' }
|
18
|
+
expect(result).to eq '<label for="name">Name</label>'
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'generates content tags without attributes' do
|
22
|
+
result = subject.tag(:label) { 'Username' }
|
23
|
+
expect(result).to eq '<label>Username</label>'
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'generates nested tags' do
|
27
|
+
result = subject.tag(:form) { subject.tag(:input, type: 'text') }
|
28
|
+
expect(result).to eq '<form><input type="text" /></form>'
|
29
|
+
end
|
30
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'auto_html'
|
4
|
+
|
5
|
+
RSpec.configure do |config|
|
6
|
+
config.expect_with :rspec do |expectations|
|
7
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
8
|
+
end
|
9
|
+
|
10
|
+
config.mock_with :rspec do |mocks|
|
11
|
+
mocks.verify_partial_doubles = true
|
12
|
+
end
|
13
|
+
end
|
metadata
CHANGED
@@ -1,137 +1,161 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: auto_html
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
5
|
-
prerelease:
|
4
|
+
version: 2.0.2
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Dejan Simic
|
9
|
-
autorequire:
|
8
|
+
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2021-11-30 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
14
|
+
name: gemoji
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- - ~>
|
17
|
+
- - "~>"
|
20
18
|
- !ruby/object:Gem::Version
|
21
|
-
version: 1
|
19
|
+
version: '2.1'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- - ~>
|
24
|
+
- - "~>"
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version: 1
|
26
|
+
version: '2.1'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: redcarpet
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3.5'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3.5'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rinku
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
36
46
|
- !ruby/object:Gem::Version
|
37
|
-
version: '
|
47
|
+
version: '2.0'
|
38
48
|
type: :runtime
|
39
49
|
prerelease: false
|
40
50
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
51
|
requirements:
|
43
|
-
- - ~>
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 13.0.6
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 13.0.6
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '3.3'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3.3'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec_junit_formatter
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.2'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
44
95
|
- !ruby/object:Gem::Version
|
45
|
-
version: '
|
46
|
-
|
47
|
-
|
96
|
+
version: '0.2'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rubocop
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '1.23'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '1.23'
|
111
|
+
description: Collection of filters for transforming text into HTML code
|
48
112
|
email: desimic@gmail.com
|
49
113
|
executables: []
|
50
114
|
extensions: []
|
51
115
|
extra_rdoc_files: []
|
52
116
|
files:
|
117
|
+
- README.md
|
53
118
|
- Rakefile
|
54
|
-
- lib/auto_html/auto_html_for.rb
|
55
|
-
- lib/auto_html/base.rb
|
56
|
-
- lib/auto_html/builder.rb
|
57
|
-
- lib/auto_html/capistrano.rb
|
58
|
-
- lib/auto_html/filter.rb
|
59
|
-
- lib/auto_html/filters/dailymotion.rb
|
60
|
-
- lib/auto_html/filters/flickr.rb
|
61
|
-
- lib/auto_html/filters/gist.rb
|
62
|
-
- lib/auto_html/filters/google_map.rb
|
63
|
-
- lib/auto_html/filters/google_video.rb
|
64
|
-
- lib/auto_html/filters/hashtag.rb
|
65
|
-
- lib/auto_html/filters/html_escape.rb
|
66
|
-
- lib/auto_html/filters/image.rb
|
67
|
-
- lib/auto_html/filters/instagram.rb
|
68
|
-
- lib/auto_html/filters/link.rb
|
69
|
-
- lib/auto_html/filters/metacafe.rb
|
70
|
-
- lib/auto_html/filters/redcarpet.rb
|
71
|
-
- lib/auto_html/filters/sanitize.rb
|
72
|
-
- lib/auto_html/filters/simple_format.rb
|
73
|
-
- lib/auto_html/filters/soundcloud.rb
|
74
|
-
- lib/auto_html/filters/ted.rb
|
75
|
-
- lib/auto_html/filters/twitter.rb
|
76
|
-
- lib/auto_html/filters/vimeo.rb
|
77
|
-
- lib/auto_html/filters/worldstar.rb
|
78
|
-
- lib/auto_html/filters/youtube.rb
|
79
|
-
- lib/auto_html/filters/youtube_js_api.rb
|
80
|
-
- lib/auto_html/railtie.rb
|
81
|
-
- lib/auto_html/rake_tasks.rb
|
82
|
-
- lib/auto_html/task.rb
|
83
119
|
- lib/auto_html.rb
|
84
|
-
-
|
85
|
-
-
|
86
|
-
-
|
87
|
-
-
|
88
|
-
-
|
89
|
-
-
|
90
|
-
-
|
91
|
-
-
|
92
|
-
-
|
93
|
-
-
|
94
|
-
-
|
95
|
-
-
|
96
|
-
-
|
97
|
-
-
|
98
|
-
-
|
99
|
-
-
|
100
|
-
-
|
101
|
-
|
102
|
-
|
103
|
-
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
- test/unit/filters/vimeo_test.rb
|
108
|
-
- test/unit/filters/worldstar_test.rb
|
109
|
-
- test/unit/filters/youtube_js_api_test.rb
|
110
|
-
- test/unit/filters/youtube_test.rb
|
111
|
-
- test/unit/unit_test_helper.rb
|
112
|
-
- README.md
|
113
|
-
homepage: http://github.com/dejan/auto_html
|
114
|
-
licenses: []
|
115
|
-
post_install_message:
|
120
|
+
- lib/auto_html/emoji.rb
|
121
|
+
- lib/auto_html/html_escape.rb
|
122
|
+
- lib/auto_html/image.rb
|
123
|
+
- lib/auto_html/link.rb
|
124
|
+
- lib/auto_html/markdown.rb
|
125
|
+
- lib/auto_html/pipeline.rb
|
126
|
+
- lib/auto_html/simple_format.rb
|
127
|
+
- lib/auto_html/tag_helper.rb
|
128
|
+
- spec/auto_html/emoji_spec.rb
|
129
|
+
- spec/auto_html/html_escape_spec.rb
|
130
|
+
- spec/auto_html/image_spec.rb
|
131
|
+
- spec/auto_html/link_spec.rb
|
132
|
+
- spec/auto_html/markdown_spec.rb
|
133
|
+
- spec/auto_html/pipeline_spec.rb
|
134
|
+
- spec/auto_html/simple_format_spec.rb
|
135
|
+
- spec/auto_html/tag_helper_spec.rb
|
136
|
+
- spec/spec_helper.rb
|
137
|
+
homepage: https://github.com/dejan/auto_html
|
138
|
+
licenses:
|
139
|
+
- MIT
|
140
|
+
metadata:
|
141
|
+
rubygems_mfa_required: 'true'
|
142
|
+
post_install_message:
|
116
143
|
rdoc_options: []
|
117
144
|
require_paths:
|
118
145
|
- lib
|
119
146
|
required_ruby_version: !ruby/object:Gem::Requirement
|
120
|
-
none: false
|
121
147
|
requirements:
|
122
|
-
- -
|
148
|
+
- - ">="
|
123
149
|
- !ruby/object:Gem::Version
|
124
|
-
version:
|
150
|
+
version: 2.5.0
|
125
151
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
126
|
-
none: false
|
127
152
|
requirements:
|
128
|
-
- -
|
153
|
+
- - ">="
|
129
154
|
- !ruby/object:Gem::Version
|
130
155
|
version: '0'
|
131
156
|
requirements: []
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
summary: Transform URIs to appropriate markup
|
157
|
+
rubygems_version: 3.2.22
|
158
|
+
signing_key:
|
159
|
+
specification_version: 4
|
160
|
+
summary: Plain text to HTML conversion
|
137
161
|
test_files: []
|
@@ -1,64 +0,0 @@
|
|
1
|
-
require 'rails'
|
2
|
-
|
3
|
-
require 'active_support/core_ext/module/attribute_accessors' if Rails::VERSION::MAJOR >= 4
|
4
|
-
|
5
|
-
module AutoHtmlFor
|
6
|
-
|
7
|
-
# default options that can be overridden on the global level
|
8
|
-
@@auto_html_for_options = {
|
9
|
-
:htmlized_attribute_suffix => '_html'
|
10
|
-
}
|
11
|
-
mattr_reader :auto_html_for_options
|
12
|
-
|
13
|
-
def self.included(base)
|
14
|
-
base.extend(ClassMethods)
|
15
|
-
end
|
16
|
-
|
17
|
-
module ClassMethods
|
18
|
-
def auto_html_for(raw_attrs, &proc)
|
19
|
-
include AutoHtmlFor::InstanceMethods
|
20
|
-
|
21
|
-
if defined?(ActiveRecord) == "constant"
|
22
|
-
return unless ActiveRecord::Base.connection.table_exists? self.table_name
|
23
|
-
end
|
24
|
-
|
25
|
-
suffix = AutoHtmlFor.auto_html_for_options[:htmlized_attribute_suffix]
|
26
|
-
auto_html_for_columns = [raw_attrs].flatten.map { |a| "#{a}#{suffix}" }
|
27
|
-
|
28
|
-
# Needed for Mongoid
|
29
|
-
column_names = self.respond_to?(:column_names) ? self.column_names : fields.keys
|
30
|
-
|
31
|
-
missing_cache_columns = auto_html_for_columns - column_names
|
32
|
-
missing_cache_columns.each do |missing_cache_column|
|
33
|
-
raw_attr = missing_cache_column.gsub(suffix, '')
|
34
|
-
define_method(missing_cache_column) do
|
35
|
-
val = self[raw_attr] || self.send(raw_attr.to_sym)
|
36
|
-
auto_html(val, &proc)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
cache_columns = auto_html_for_columns - missing_cache_columns
|
41
|
-
cache_columns.each do |cache_column|
|
42
|
-
raw_attr = cache_column.gsub(suffix, '')
|
43
|
-
define_method("#{raw_attr}=") do |val|
|
44
|
-
self[raw_attr] = val
|
45
|
-
result = auto_html(val, &proc)
|
46
|
-
self.send("#{cache_column}=", result)
|
47
|
-
val
|
48
|
-
end
|
49
|
-
|
50
|
-
define_method(cache_column) do
|
51
|
-
result = self[cache_column]
|
52
|
-
result.respond_to?(:html_safe) ? result.html_safe : result
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
module InstanceMethods
|
60
|
-
include AutoHtml
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
|
data/lib/auto_html/base.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
module AutoHtml
|
2
|
-
extend self
|
3
|
-
|
4
|
-
def self.add_filter(name, &block)
|
5
|
-
AutoHtml::Builder.add_filter(name, &block)
|
6
|
-
end
|
7
|
-
|
8
|
-
def auto_html(raw, &proc)
|
9
|
-
return "" if raw.blank?
|
10
|
-
builder = Builder.new(raw)
|
11
|
-
result = builder.instance_eval(&proc)
|
12
|
-
return raw if result.nil?
|
13
|
-
result.respond_to?(:html_safe) ?
|
14
|
-
result.html_safe :
|
15
|
-
result
|
16
|
-
end
|
17
|
-
|
18
|
-
end
|
data/lib/auto_html/builder.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
module AutoHtml
|
2
|
-
class Builder
|
3
|
-
@@filters = {}
|
4
|
-
|
5
|
-
def initialize(text)
|
6
|
-
@text = text.dup
|
7
|
-
end
|
8
|
-
|
9
|
-
def self.add_filter(name, &block)
|
10
|
-
filter = Filter.new(block)
|
11
|
-
@@filters.merge!(name => filter)
|
12
|
-
src = %|
|
13
|
-
def #{name}(options = {})
|
14
|
-
@text = @@filters["#{name}".to_sym].apply(@text, options)
|
15
|
-
end
|
16
|
-
|
|
17
|
-
class_eval src, __FILE__, __LINE__
|
18
|
-
filter
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
data/lib/auto_html/capistrano.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
require 'auto_html/task'
|
2
|
-
|
3
|
-
# Capistrano task for AutoHtml.
|
4
|
-
# Just add:
|
5
|
-
|
6
|
-
# require 'auto_html/capistrano'
|
7
|
-
# in your Capistrano deploy.rb, you will have AutoHtml rake task in Capistrano
|
8
|
-
|
9
|
-
Capistrano::Configuration.instance(:must_exist).load do
|
10
|
-
namespace :auto_html do
|
11
|
-
desc "Rebuild auto_html columns"
|
12
|
-
task :rebuild do
|
13
|
-
klass = AutoHtml::Task.obtain_class
|
14
|
-
run "cd #{current_path} && bundle exec rake auto_html:rebuild CLASS=#{klass} RAILS_ENV=#{rails_env}"
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
data/lib/auto_html/filter.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
module AutoHtml
|
2
|
-
class Filter
|
3
|
-
def initialize(block)
|
4
|
-
@block = block
|
5
|
-
@options = nil
|
6
|
-
end
|
7
|
-
|
8
|
-
def with(options, &block)
|
9
|
-
@options = options
|
10
|
-
@block = block
|
11
|
-
end
|
12
|
-
|
13
|
-
def apply(text, options = {})
|
14
|
-
_options = @options && @options.merge(options)
|
15
|
-
if _options
|
16
|
-
@block.call(text.to_s.dup, _options)
|
17
|
-
else
|
18
|
-
@block.call(text.to_s.dup)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
@@ -1,6 +0,0 @@
|
|
1
|
-
AutoHtml.add_filter(:dailymotion).with(:width => 480, :height => 360) do |text, options|
|
2
|
-
text.gsub(/http:\/\/www\.dailymotion\.com.*\/video\/(.+)_*/) do
|
3
|
-
video_id = $1
|
4
|
-
%{<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>}
|
5
|
-
end
|
6
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
AutoHtml.add_filter(:flickr).with(:maxwidth => nil, :maxheight => nil, :link_options => {}) do |text, options|
|
2
|
-
require 'uri'
|
3
|
-
require 'net/http'
|
4
|
-
require 'rexml/document'
|
5
|
-
|
6
|
-
regex = %r{http://(www\.)?flickr\.com/photos/[^\s<]*}
|
7
|
-
|
8
|
-
text.gsub(regex) do |match|
|
9
|
-
params = { :url => match, :format => "json" }
|
10
|
-
[:maxwidth, :maxheight].each { |p| params[p] = options[p] unless options[p].nil? or not options[p] > 0 }
|
11
|
-
|
12
|
-
uri = URI("http://www.flickr.com/services/oembed")
|
13
|
-
uri.query = URI.encode_www_form(params)
|
14
|
-
|
15
|
-
response = JSON.parse(Net::HTTP.get(uri))
|
16
|
-
|
17
|
-
link_options = Array(options[:link_options]).reject { |k,v| v.nil? }.map { |k, v| %{#{k}="#{REXML::Text::normalize(v)}"} }.join(' ')
|
18
|
-
%{<a href="#{match}"#{ ' ' + link_options unless link_options.empty? }><img src="#{response["url"]}" alt="#{response["title"]}" title="#{response["title"]}" /></a>}
|
19
|
-
end
|
20
|
-
end
|
@@ -1,8 +0,0 @@
|
|
1
|
-
AutoHtml.add_filter(:gist).with({}) do |text, options|
|
2
|
-
# E.g. https://gist.github.com/1710276
|
3
|
-
regex = %r{https?://gist\.github\.com/(\w+/)?(\d+)}
|
4
|
-
text.gsub(regex) do
|
5
|
-
gist_id = $2
|
6
|
-
%{<script type="text/javascript" src="https://gist.github.com/#{gist_id}.js"></script>}
|
7
|
-
end
|
8
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
AutoHtml.add_filter(:google_map).with(:width => 420, :height => 315, :style => "color:#000;text-align:left", :link_text => "View Larger Map", :show_info => true, :type => :normal, :zoom => 18, :more => '') do |text, options|
|
3
|
-
map_type = { :normal => '&t=m', :satellite => '&t=k', :terrain => '&t=p', :hibrid => '&t=h' }
|
4
|
-
regex = /(https?):\/\/maps\.google\.([a-z\.]+)\/maps\?(.*)/
|
5
|
-
text.gsub(regex) do
|
6
|
-
domain_country = $2
|
7
|
-
map_query = $3
|
8
|
-
width = options[:width]
|
9
|
-
height = options[:height]
|
10
|
-
style = options[:style]
|
11
|
-
link_text = options[:link_text]
|
12
|
-
type = options[:type].to_sym
|
13
|
-
map_options = (options[:show_info] ? '' : '&iwloc=near')
|
14
|
-
map_options << map_type[type] if map_type.has_key?(type)
|
15
|
-
map_options << "&z=#{options[:zoom]}"
|
16
|
-
map_options << options[:more]
|
17
|
-
%{<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>}
|
18
|
-
end
|
19
|
-
end
|
@@ -1,7 +0,0 @@
|
|
1
|
-
AutoHtml.add_filter(:hashtag).with(:source => :twitter) do |text, options|
|
2
|
-
if options[:source] == :twitter
|
3
|
-
text.gsub(/#([^\s]+)/, '<a href="http://twitter.com/search?q=%23\1&f=realtime" class="hashtag" target="_blank">#\1</a>')
|
4
|
-
elsif options[:source] == :facebook
|
5
|
-
text.gsub(/#([^\s]+)/, '<a href="https://www.facebook.com/hashtag/\1" class="hashtag" target="_blank">#\1</a>')
|
6
|
-
end
|
7
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
require 'redcarpet'
|
2
|
-
|
3
|
-
class NoParagraphRenderer < ::Redcarpet::Render::XHTML
|
4
|
-
def paragraph(text)
|
5
|
-
text
|
6
|
-
end
|
7
|
-
end
|
8
|
-
|
9
|
-
AutoHtml.add_filter(:image).with({:alt => ''}) do |text, options|
|
10
|
-
r = Redcarpet::Markdown.new(NoParagraphRenderer)
|
11
|
-
alt = options[:alt]
|
12
|
-
options[:proxy] ||= ""
|
13
|
-
text.gsub(/(?<!src=")https?:\/\/.+?\.(jpg|jpeg|bmp|gif|png)(\?\S+)?/i) do |match|
|
14
|
-
r.render("![#{alt}](#{options[:proxy]}#{match})")
|
15
|
-
end
|
16
|
-
end
|
@@ -1,10 +0,0 @@
|
|
1
|
-
require 'uri'
|
2
|
-
require 'net/http'
|
3
|
-
|
4
|
-
AutoHtml.add_filter(:instagram) do |text|
|
5
|
-
text << '/' unless text.end_with?('/')
|
6
|
-
regex = %r{https?:\/\/(www.)?instagr(am\.com|\.am)/p/.+}
|
7
|
-
text.gsub(regex) do
|
8
|
-
%{<iframe src="#{text}embed" height="714" width="616" frameborder="0" scrolling="no"></iframe>}
|
9
|
-
end
|
10
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
AutoHtml.add_filter(:link).with({}) do |text, options|
|
2
|
-
require 'uri'
|
3
|
-
require 'rinku'
|
4
|
-
require 'rexml/document'
|
5
|
-
option_short_link_name = options.delete(:short_link_name)
|
6
|
-
attributes = Array(options).reject { |k,v| v.nil? }.map { |k, v| %{#{k}="#{REXML::Text::normalize(v)}"} }.join(' ')
|
7
|
-
Rinku.auto_link(text, :all, attributes) do |url|
|
8
|
-
if option_short_link_name
|
9
|
-
uri = URI.parse(URI.encode(url.strip))
|
10
|
-
uri.query = nil
|
11
|
-
uri.to_s
|
12
|
-
else
|
13
|
-
url
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
AutoHtml.add_filter(:metacafe).with(:width => 440, :height => 272, :show_stats => false, :autoplay => false) do |text, options|
|
2
|
-
text.gsub(/http:\/\/www\.metacafe\.com\/watch\/([A-Za-z0-9._%-]*)\/([A-Za-z0-9._%-]*)(\/)?/) do
|
3
|
-
metacafe_id = $1
|
4
|
-
metacafe_slug = $2
|
5
|
-
width = options[:width]
|
6
|
-
height = options[:height]
|
7
|
-
show_stats = options[:show_stats] ? "showStats=yes" : "showStats=no"
|
8
|
-
autoplay = options[:autoplay] ? "autoPlay=yes" : "autoPlay=no"
|
9
|
-
flash_vars = [show_stats, autoplay].join("|")
|
10
|
-
|
11
|
-
%{<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>}
|
12
|
-
end
|
13
|
-
end
|
@@ -1,12 +0,0 @@
|
|
1
|
-
AutoHtml.add_filter(:simple_format).with({}) do |text, html_options|
|
2
|
-
require 'action_view'
|
3
|
-
|
4
|
-
args = [text, {}, {:sanitize => false}]
|
5
|
-
begin
|
6
|
-
ActionView::Base.new.simple_format(*args)
|
7
|
-
rescue ArgumentError
|
8
|
-
# Rails 2 support
|
9
|
-
args.pop
|
10
|
-
retry
|
11
|
-
end
|
12
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
# set these options and default values
|
4
|
-
# :width => '100%', :height => 166, :auto_play => false, :theme_color => '00FF00', :color => '915f33', :show_comments => false
|
5
|
-
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|
|
6
|
-
require 'uri'
|
7
|
-
require 'net/http'
|
8
|
-
text.gsub(/(https?:\/\/)?(www.)?soundcloud\.com\/\S*/) do |match|
|
9
|
-
new_uri = match.to_s
|
10
|
-
new_uri = (new_uri =~ /^https?\:\/\/.*/) ? URI(new_uri) : URI("http://#{new_uri}")
|
11
|
-
new_uri.normalize!
|
12
|
-
width = options[:width]
|
13
|
-
height = options[:height]
|
14
|
-
auto_play = options[:auto_play]
|
15
|
-
theme_color = options[:theme_color]
|
16
|
-
color = options[:color]
|
17
|
-
show_artwork = options[:show_artwork]
|
18
|
-
show_comments = options[:show_comments]
|
19
|
-
%{<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>}
|
20
|
-
end
|
21
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
# TED talks (http://www.ted.com)
|
2
|
-
AutoHtml.add_filter(:ted).with(:width => 640, :height => 360, :scrolling => "no", :frameborder => 0, :allow_full_screen => false) do |text, options|
|
3
|
-
text.gsub(/https?:\/\/(www.|embed.)?ted\.com\/talks\/([A-Za-z0-9._%-]*)\.html((\?|#)\S+)?/) do
|
4
|
-
ted_page = $2
|
5
|
-
width = options[:width]
|
6
|
-
height = options[:height]
|
7
|
-
scrolling = options[:scrolling]
|
8
|
-
frameborder = options[:frameborder]
|
9
|
-
allow_full_screen = options[:allow_full_screen]
|
10
|
-
|
11
|
-
%{<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>}
|
12
|
-
end
|
13
|
-
end
|