auto_html 1.6.3 → 2.1.0

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.
Files changed (81) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +65 -94
  3. data/Rakefile +8 -7
  4. data/lib/auto_html/emoji.rb +24 -0
  5. data/lib/auto_html/html_escape.rb +12 -0
  6. data/lib/auto_html/image.rb +23 -0
  7. data/lib/auto_html/link.rb +33 -0
  8. data/lib/auto_html/markdown.rb +17 -0
  9. data/lib/auto_html/pipeline.rb +18 -0
  10. data/lib/auto_html/simple_format.rb +23 -0
  11. data/lib/auto_html/tag_helper.rb +38 -0
  12. data/lib/auto_html.rb +11 -15
  13. data/spec/auto_html/emoji_spec.rb +9 -0
  14. data/spec/auto_html/html_escape_spec.rb +10 -0
  15. data/spec/auto_html/image_spec.rb +41 -0
  16. data/spec/auto_html/link_spec.rb +53 -0
  17. data/spec/auto_html/markdown_spec.rb +9 -0
  18. data/spec/auto_html/pipeline_spec.rb +26 -0
  19. data/spec/auto_html/simple_format_spec.rb +18 -0
  20. data/spec/auto_html/tag_helper_spec.rb +30 -0
  21. data/spec/spec_helper.rb +13 -0
  22. metadata +114 -92
  23. data/lib/auto_html/auto_html_for.rb +0 -64
  24. data/lib/auto_html/base.rb +0 -18
  25. data/lib/auto_html/builder.rb +0 -21
  26. data/lib/auto_html/capistrano.rb +0 -17
  27. data/lib/auto_html/filter.rb +0 -22
  28. data/lib/auto_html/filters/dailymotion.rb +0 -6
  29. data/lib/auto_html/filters/flickr.rb +0 -20
  30. data/lib/auto_html/filters/gist.rb +0 -8
  31. data/lib/auto_html/filters/google_map.rb +0 -19
  32. data/lib/auto_html/filters/google_video.rb +0 -6
  33. data/lib/auto_html/filters/hashtag.rb +0 -7
  34. data/lib/auto_html/filters/html_escape.rb +0 -9
  35. data/lib/auto_html/filters/image.rb +0 -16
  36. data/lib/auto_html/filters/instagram.rb +0 -10
  37. data/lib/auto_html/filters/link.rb +0 -16
  38. data/lib/auto_html/filters/liveleak.rb +0 -19
  39. data/lib/auto_html/filters/metacafe.rb +0 -13
  40. data/lib/auto_html/filters/redcarpet.rb +0 -4
  41. data/lib/auto_html/filters/sanitize.rb +0 -5
  42. data/lib/auto_html/filters/simple_format.rb +0 -12
  43. data/lib/auto_html/filters/soundcloud.rb +0 -21
  44. data/lib/auto_html/filters/ted.rb +0 -13
  45. data/lib/auto_html/filters/twitter.rb +0 -19
  46. data/lib/auto_html/filters/vimeo.rb +0 -15
  47. data/lib/auto_html/filters/worldstar.rb +0 -8
  48. data/lib/auto_html/filters/youtube.rb +0 -19
  49. data/lib/auto_html/filters/youtube_js_api.rb +0 -6
  50. data/lib/auto_html/railtie.rb +0 -10
  51. data/lib/auto_html/rake_tasks.rb +0 -27
  52. data/lib/auto_html/task.rb +0 -9
  53. data/test/fixture_setup.rb +0 -13
  54. data/test/fixtures/database.yml +0 -5
  55. data/test/fixtures/schema.rb +0 -20
  56. data/test/functional/auto_html_for_options_test.rb +0 -26
  57. data/test/functional/auto_html_for_test.rb +0 -56
  58. data/test/functional/filter_test.rb +0 -27
  59. data/test/test_helper.rb +0 -9
  60. data/test/unit/auto_html_test.rb +0 -37
  61. data/test/unit/filters/dailymotion_test.rb +0 -20
  62. data/test/unit/filters/gist_test.rb +0 -15
  63. data/test/unit/filters/google_map_test.rb +0 -24
  64. data/test/unit/filters/hashtag_test.rb +0 -25
  65. data/test/unit/filters/html_escape_test.rb +0 -15
  66. data/test/unit/filters/image_test.rb +0 -65
  67. data/test/unit/filters/instagram_test.rb +0 -8
  68. data/test/unit/filters/link_test.rb +0 -55
  69. data/test/unit/filters/liveleak_test.rb +0 -15
  70. data/test/unit/filters/metacafe_test.rb +0 -29
  71. data/test/unit/filters/redcarpet_test.rb +0 -38
  72. data/test/unit/filters/sanitize_test.rb +0 -36
  73. data/test/unit/filters/simple_format_test.rb +0 -15
  74. data/test/unit/filters/soundcloud_test.rb +0 -29
  75. data/test/unit/filters/ted_test.rb +0 -18
  76. data/test/unit/filters/twitter_test.rb +0 -45
  77. data/test/unit/filters/vimeo_test.rb +0 -50
  78. data/test/unit/filters/worldstar_test.rb +0 -14
  79. data/test/unit/filters/youtube_js_api_test.rb +0 -30
  80. data/test/unit/filters/youtube_test.rb +0 -59
  81. data/test/unit/unit_test_helper.rb +0 -3
@@ -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,139 +1,161 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: auto_html
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.3
5
- prerelease:
4
+ version: 2.1.0
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: 2014-04-01 00:00:00.000000000 Z
11
+ date: 2021-12-04 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
- name: rinku
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.5.0
19
+ version: 4.0.0.rc2
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.5.0
26
+ version: 4.0.0.rc2
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: '3.1'
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: '3.1'
46
- description: Automatically transforms URIs (via domain) and includes the destination
47
- resource (Vimeo, YouTube movie, image, ...) in your document
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/liveleak.rb
70
- - lib/auto_html/filters/metacafe.rb
71
- - lib/auto_html/filters/redcarpet.rb
72
- - lib/auto_html/filters/sanitize.rb
73
- - lib/auto_html/filters/simple_format.rb
74
- - lib/auto_html/filters/soundcloud.rb
75
- - lib/auto_html/filters/ted.rb
76
- - lib/auto_html/filters/twitter.rb
77
- - lib/auto_html/filters/vimeo.rb
78
- - lib/auto_html/filters/worldstar.rb
79
- - lib/auto_html/filters/youtube.rb
80
- - lib/auto_html/filters/youtube_js_api.rb
81
- - lib/auto_html/railtie.rb
82
- - lib/auto_html/rake_tasks.rb
83
- - lib/auto_html/task.rb
84
119
  - lib/auto_html.rb
85
- - test/fixture_setup.rb
86
- - test/fixtures/database.yml
87
- - test/fixtures/schema.rb
88
- - test/functional/auto_html_for_options_test.rb
89
- - test/functional/auto_html_for_test.rb
90
- - test/functional/filter_test.rb
91
- - test/test_helper.rb
92
- - test/unit/auto_html_test.rb
93
- - test/unit/filters/dailymotion_test.rb
94
- - test/unit/filters/gist_test.rb
95
- - test/unit/filters/google_map_test.rb
96
- - test/unit/filters/hashtag_test.rb
97
- - test/unit/filters/html_escape_test.rb
98
- - test/unit/filters/image_test.rb
99
- - test/unit/filters/instagram_test.rb
100
- - test/unit/filters/link_test.rb
101
- - test/unit/filters/liveleak_test.rb
102
- - test/unit/filters/metacafe_test.rb
103
- - test/unit/filters/redcarpet_test.rb
104
- - test/unit/filters/sanitize_test.rb
105
- - test/unit/filters/simple_format_test.rb
106
- - test/unit/filters/soundcloud_test.rb
107
- - test/unit/filters/ted_test.rb
108
- - test/unit/filters/twitter_test.rb
109
- - test/unit/filters/vimeo_test.rb
110
- - test/unit/filters/worldstar_test.rb
111
- - test/unit/filters/youtube_js_api_test.rb
112
- - test/unit/filters/youtube_test.rb
113
- - test/unit/unit_test_helper.rb
114
- - README.md
115
- homepage: http://github.com/dejan/auto_html
116
- licenses: []
117
- 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:
118
143
  rdoc_options: []
119
144
  require_paths:
120
145
  - lib
121
146
  required_ruby_version: !ruby/object:Gem::Requirement
122
- none: false
123
147
  requirements:
124
- - - ! '>='
148
+ - - ">="
125
149
  - !ruby/object:Gem::Version
126
- version: '0'
150
+ version: 2.5.0
127
151
  required_rubygems_version: !ruby/object:Gem::Requirement
128
- none: false
129
152
  requirements:
130
- - - ! '>='
153
+ - - ">="
131
154
  - !ruby/object:Gem::Version
132
155
  version: '0'
133
156
  requirements: []
134
- rubyforge_project:
135
- rubygems_version: 1.8.23
136
- signing_key:
137
- specification_version: 3
138
- 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
139
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
-
@@ -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
@@ -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
@@ -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
@@ -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 => '&amp;t=m', :satellite => '&amp;t=k', :terrain => '&amp;t=p', :hibrid => '&amp;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] ? '' : '&amp;iwloc=near')
14
- map_options << map_type[type] if map_type.has_key?(type)
15
- map_options << "&amp;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&amp;source=s_q&amp;#{map_query}&amp;output=embed#{map_options}"></iframe><br /><small><a href="//maps.google.#{domain_country}/maps?f=q&amp;source=embed&amp;#{map_query}" style="#{style}">#{link_text}</a></small>}
18
- end
19
- end
@@ -1,6 +0,0 @@
1
- # GoogleVideo is discontinued so don't do anything
2
- # TODO Remove this filter in auto_html v2.0
3
- AutoHtml.add_filter(:google_video) do |text, options|
4
- text
5
- end
6
-
@@ -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,9 +0,0 @@
1
- AutoHtml.add_filter(:html_escape).with(
2
- :map => {
3
- '&' => '&amp;',
4
- '>' => '&gt;',
5
- '<' => '&lt;',
6
- '"' => '&quot;' }) do |text, options|
7
-
8
- text.to_s.gsub(/[&"><]/) { |special| options[:map][special] }
9
- 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,19 +0,0 @@
1
- AutoHtml.add_filter(:liveleak).with(:width => 420, :height => 315, :frameborder => 0, :wmode => nil, :autoplay => false, :hide_related => false) do |text, options|
2
- regex = %r{http://www\.liveleak\.com/(?:ll_embed|view)\?.=(\w+)}
3
- text.gsub(regex) do
4
- liveleak_id = $1
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 = "http://www.liveleak.com/ll_embed?f=#{liveleak_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
- %{<iframe width="#{width}" height="#{height}" src="#{src}" frameborder="#{frameborder}" allowfullscreen></iframe>}
18
- end
19
- 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,4 +0,0 @@
1
- require 'redcarpet'
2
- AutoHtml.add_filter(:redcarpet).with(:renderer => Redcarpet::Render::HTML, :markdown_options => {}) do |text, options|
3
- Redcarpet::Markdown.new(options[:renderer], options[:markdown_options]).render(text)
4
- end
@@ -1,5 +0,0 @@
1
- AutoHtml.add_filter(:sanitize).with({}) do |text, options|
2
- require 'action_controller'
3
- require 'cgi'
4
- HTML::WhiteListSanitizer.new.sanitize(text, options)
5
- 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