Skip to content

Commit

Permalink
Remove rors.org references
Browse files Browse the repository at this point in the history
  • Loading branch information
dejan committed Jan 3, 2025
1 parent 056535f commit 0ff11f2
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 21 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,23 @@ AutoHtml uses concepts found in "Pipes and Filters" processing design pattern:

```ruby
link_filter = AutoHtml::Link.new(target: '_blank')
link_filter.call('Checkout out my blog: http://rors.org')
# => 'Checkout out my blog: <a target="blank" href="http://rors.org">http://rors.org</a>'
link_filter.call('Checkout out auto_html: https://github.com/dejan/auto_html')
# => 'Checkout out my blog: <a target="blank" href="https://github.com/dejan/auto_html">https://github.com/dejan/auto_html</a>'

emoji_filter = AutoHtml::Emoji.new
emoji_filter.call(':point_left: yo!')
# => '<img src="/images/emoji/unicode/1f448.png" class="emoji" title=":point_left:" alt=":point_left:" height="20" witdh="20" align="absmiddle" /> yo!'

# Use Pipeline to combine filters
base_format = AutoHtml::Pipeline.new(link_filter, emoji_filter)
base_format.call('Checkout out my blog: http://rors.org :point_left: yo!')
# => 'Checkout out my blog: <a href="http://rors.org">http://rors.org</a> <img src="/images/emoji/unicode/1f448.png" class="emoji" title=":point_left:" alt=":point_left:" height="20" witdh="20" align="absmiddle" /> yo!'
base_format.call('Checkout out auto_html: https://github.com/dejan/auto_html :point_left: yo!')
# => 'Checkout out my blog: <a href="https://github.com/dejan/auto_html">https://github.com/dejan/auto_html</a> <img src="/images/emoji/unicode/1f448.png" class="emoji" title=":point_left:" alt=":point_left:" height="20" witdh="20" align="absmiddle" /> yo!'

# A pipeline can be reused in another pipeline. Note that the order of filters is important - ie you want
# `Image` before `Link` filter so that URL of the image gets transformed to `img` tag and not `a` tag.
comment_format = AutoHtml::Pipeline.new(AutoHtml::Markdown.new, AutoHtml::Image.new, base_format)
comment_format.call("Hello!\n\n Checkout out my blog: http://rors.org :point_left: yo! \n\n http://gifs.joelglovier.com/boom/booyah.gif")
# => "<p>Hello!</p>\n\n<p>Checkout out my blog: <a href="<img src="http://rors.org" target="_blank">http://rors.org</a> <img src="/images/emoji/unicode/1f448.png" />" class="emoji" title=":point_left:" alt=":point_left:" height="20" witdh="20" align="absmiddle" /> yo! </p>\n\n<p><a href="<img src="http://gifs.joelglovier.com/boom/booyah.gif" />" target="_blank"><img src="http://gifs.joelglovier.com/boom/booyah.gif" /></a></p>\n"
comment_format.call("Hello!\n\n Checkout out auto_html: https://github.com/dejan/auto_html :point_left: yo! \n\n http://gifs.joelglovier.com/boom/booyah.gif")
# => "<p>Hello!</p>\n\n<p>Checkout out my blog: <a href="<img src="https://github.com/dejan/auto_html" target="_blank">https://github.com/dejan/auto_html</a> <img src="/images/emoji/unicode/1f448.png" />" class="emoji" title=":point_left:" alt=":point_left:" height="20" witdh="20" align="absmiddle" /> yo! </p>\n\n<p><a href="<img src="http://gifs.joelglovier.com/boom/booyah.gif" />" target="_blank"><img src="http://gifs.joelglovier.com/boom/booyah.gif" /></a></p>\n"
```

## Bundled filters
Expand Down
8 changes: 4 additions & 4 deletions spec/auto_html/image_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

RSpec.describe AutoHtml::Image do
it 'transforms an image link to image tag' do
result = subject.call('http://rors.org/images/rails.png')
expect(result).to eq('<img src="http://rors.org/images/rails.png" />')
result = subject.call('https://example.org/images/rails.png')
expect(result).to eq('<img src="https://example.org/images/rails.png" />')
end

it 'transforms image link with a param to image tag' do
Expand All @@ -30,8 +30,8 @@
end

it 'transforms an image link within text to image tag' do
result = subject.call('Which do you prefer, this one http://www.lockhartfineart.com/images/Rio_Grande_Frost.JPG, or this one http://rors.org/images/rails.png?')
expect(result).to eq('Which do you prefer, this one <img src="http://www.lockhartfineart.com/images/Rio_Grande_Frost.JPG" />, or this one <img src="http://rors.org/images/rails.png" />?')
result = subject.call('Which do you prefer, this one http://www.lockhartfineart.com/images/Rio_Grande_Frost.JPG, or this one https://example.org/images/rails.png?')
expect(result).to eq('Which do you prefer, this one <img src="http://www.lockhartfineart.com/images/Rio_Grande_Frost.JPG" />, or this one <img src="https://example.org/images/rails.png" />?')
end

it 'transforms an image link with a lot of param to image tag' do
Expand Down
12 changes: 6 additions & 6 deletions spec/auto_html/link_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@

it 'transforms with target options' do
filter = described_class.new(target: '_blank')
result = filter.call('http://rors.org')
expect(result).to eq '<a href="http://rors.org" target="_blank">http://rors.org</a>'
result = filter.call('https://example.org')
expect(result).to eq '<a href="https://example.org" target="_blank">https://example.org</a>'
end

it 'transforms with rel options' do
filter = described_class.new(rel: 'nofollow')
result = filter.call('http://rors.org')
expect(result).to eq '<a href="http://rors.org" rel="nofollow">http://rors.org</a>'
result = filter.call('https://example.org')
expect(result).to eq '<a href="https://example.org" rel="nofollow">https://example.org</a>'
end

it 'transforms with short_domains options' do
Expand All @@ -58,7 +58,7 @@

it 'transforms with target and rel options' do
filter = described_class.new(target: '_blank', rel: 'nofollow')
result = filter.call('http://rors.org')
expect(result).to eq '<a href="http://rors.org" target="_blank" rel="nofollow">http://rors.org</a>'
result = filter.call('https://example.org')
expect(result).to eq '<a href="https://example.org" target="_blank" rel="nofollow">https://example.org</a>'
end
end
6 changes: 3 additions & 3 deletions spec/auto_html/pipeline_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
subject { described_class.new(AutoHtml::SimpleFormat.new, AutoHtml::Image.new, AutoHtml::Link.new) }

it 'does not transforms input when no filters provided' do
input = 'Hey check out my blog => http://rors.org'
input = 'Hey check out my blog => https://example.org'
result = described_class.new.call(input)
expect(result).to eq input
end

it 'transforms input using provided filters' do
result = subject.call 'Check the logo: http://rors.org/images/rails.png. Visit: http://rubyonrails.org'
expect(result).to eq '<p>Check the logo: <img src="http://rors.org/images/rails.png" />. Visit: <a href="http://rubyonrails.org">http://rubyonrails.org</a></p>'
result = subject.call 'Check the logo: https://example.org/images/rails.png. Visit: http://rubyonrails.org'
expect(result).to eq '<p>Check the logo: <img src="https://example.org/images/rails.png" />. Visit: <a href="http://rubyonrails.org">http://rubyonrails.org</a></p>'
end

it 'is blank if input is blank' do
Expand Down
4 changes: 2 additions & 2 deletions spec/auto_html/simple_format_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

RSpec.describe AutoHtml::SimpleFormat do
it 'formats input using simple rules' do
result = subject.call('Hey check out my blog => http://rors.org')
expect(result).to eq '<p>Hey check out my blog => http://rors.org</p>'
result = subject.call('Hey check out my blog => https://example.org')
expect(result).to eq '<p>Hey check out my blog => https://example.org</p>'

expect(subject.call("crazy\r\n cross\r platform linebreaks")).to eq "<p>crazy\n<br /> cross\n<br /> platform linebreaks</p>"
expect(subject.call("A paragraph\n\nand another one!")).to eq "<p>A paragraph</p>\n\n<p>and another one!</p>"
Expand Down

0 comments on commit 0ff11f2

Please sign in to comment.