letter_opener_web 1.3.2 → 1.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +3 -4
- data/.travis.yml +4 -5
- data/CHANGELOG.md +21 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +1 -1
- data/README.md +6 -6
- data/app/controllers/letter_opener_web/letters_controller.rb +8 -2
- data/app/models/letter_opener_web/letter.rb +15 -4
- data/app/views/layouts/letter_opener_web/_javascripts.html.erb +564 -0
- data/app/views/layouts/letter_opener_web/_styles.html.erb +63 -0
- data/app/views/layouts/letter_opener_web/letters.html.erb +4 -3
- data/config/routes.rb +4 -4
- data/letter_opener_web.gemspec +12 -11
- data/lib/letter_opener_web/delivery_method.rb +6 -1
- data/lib/letter_opener_web/engine.rb +0 -10
- data/lib/letter_opener_web/version.rb +1 -1
- data/spec/controllers/letter_opener_web/letters_controller_spec.rb +19 -8
- data/spec/models/letter_opener_web/letter_spec.rb +14 -3
- data/spec/rails_helper.rb +1 -1
- data/spec/spec_helper.rb +8 -0
- metadata +12 -20
- data/app/assets/javascripts/letter_opener_web/application.js +0 -30
- data/app/assets/stylesheets/letter_opener_web/application.css.erb +0 -54
- data/bin/rails +0 -11
- data/vendor/assets/images/letter_opener_web/blue-dot.ico +0 -0
- data/vendor/assets/images/letter_opener_web/glyphicons-halflings-white.png +0 -0
- data/vendor/assets/images/letter_opener_web/glyphicons-halflings.png +0 -0
- data/vendor/assets/javascripts/letter_opener_web/bootstrap.min.js +0 -6
- data/vendor/assets/javascripts/letter_opener_web/favcount.js +0 -102
- data/vendor/assets/javascripts/letter_opener_web/jquery-1.8.3.min.js +0 -2
- data/vendor/assets/javascripts/letter_opener_web/jquery_ujs.js +0 -429
- data/vendor/assets/stylesheets/letter_opener_web/bootstrap.min.css +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cf8f22bcc360d6d8da5a1e462a24faa5d8dfe4589a7cad91bebe688a06a1001c
|
4
|
+
data.tar.gz: f9cc899aee871f4d68ec12390be6470d62fba0b85123ecb38ae5a11e98899f42
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 79ecd487c5042e2acfd3627a38ee8379e8a372c06a64aaa8c01be30cddf01b123dc23ec80dafe1cc94f7924698ef80304066c1b06a5d776f8304a547ddaa11be
|
7
|
+
data.tar.gz: c5fb0b7be26b025400c346a8d4850e834e890f578cfd6a849fd949d1b12c93999aaefef65c1e641e8a6fca2a25e866467f6f223527ed84cea94fb4022b07984e
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
---
|
2
2
|
AllCops:
|
3
|
-
TargetRubyVersion: 2.
|
3
|
+
TargetRubyVersion: 2.5
|
4
4
|
Exclude:
|
5
5
|
- "spec/dummy/bin/**/*"
|
6
6
|
- "tmp/**/*"
|
7
7
|
- "vendor/**/*"
|
8
8
|
|
9
|
-
|
10
|
-
Layout/IndentHeredoc:
|
9
|
+
Layout/HeredocIndentation:
|
11
10
|
Enabled: false
|
12
11
|
|
13
12
|
Style/Documentation:
|
@@ -23,5 +22,5 @@ Metrics/BlockLength:
|
|
23
22
|
Exclude:
|
24
23
|
- spec/**/*_spec.rb
|
25
24
|
|
26
|
-
|
25
|
+
Layout/LineLength:
|
27
26
|
Max: 120
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,24 @@
|
|
1
|
+
## [1.4.1](https://github.com/fgrehm/letter_opener_web/compare/v1.4.0...v1.4.1) (Oct 5, 2021)
|
2
|
+
|
3
|
+
- Ensure letter is within letters base path [#110](https://github.com/fgrehm/letter_opener_web/pull/110)
|
4
|
+
|
5
|
+
## [1.4.0](https://github.com/fgrehm/letter_opener_web/compare/v1.3.4...v1.4.0) (Jan 29, 2020)
|
6
|
+
|
7
|
+
- Removed the dependency on the asset pipeline. Good news for API-only apps! [#83](https://github.com/fgrehm/letter_opener_web/pull/83)
|
8
|
+
- Avoid `require_dependency` if Zeitwerk is enabled [#98](https://github.com/fgrehm/letter_opener_web/pull/98)
|
9
|
+
- Drop support for old rubies and rails. Ruby 2.5+ is supported and Rails 4 is no longer tested [#100](https://github.com/fgrehm/letter_opener_web/pull/100)
|
10
|
+
|
11
|
+
## [1.3.4](https://github.com/fgrehm/letter_opener_web/compare/v1.3.3...v1.3.4) (Apr 04, 2018)
|
12
|
+
|
13
|
+
### Fixed
|
14
|
+
|
15
|
+
- Due to a load order issue, sometimes the main `ApplicationController` was used by this gem (unnecessary) [#82](https://github.com/fgrehm/letter_opener_web/pull/82)
|
16
|
+
|
17
|
+
## [1.3.3](https://github.com/fgrehm/letter_opener_web/compare/v1.3.2...v1.3.3) (Jan 29, 2018)
|
18
|
+
|
19
|
+
- Set `LAUNCHY_DRY_RUN` explicitly to avoid `Launchy::CommandNotFoundError` [#75](https://github.com/fgrehm/letter_opener_web/pull/75)
|
20
|
+
- Update Ruby matrix for test to include more recent versions [#77](https://github.com/fgrehm/letter_opener_web/pull/77)
|
21
|
+
|
1
22
|
## [1.3.2](https://github.com/fgrehm/letter_opener_web/compare/v1.3.1...v1.3.2) (Jan 14, 2018)
|
2
23
|
|
3
24
|
- Disable Launchy with ENV to avoid redefining the whole delivery method [#73](https://github.com/fgrehm/letter_opener_web/pull/73)
|
data/Gemfile
CHANGED
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# letter_opener_web
|
2
2
|
|
3
|
-
[![Build Status](https://travis-ci.org/fgrehm/letter_opener_web.
|
3
|
+
[![Build Status](https://travis-ci.org/fgrehm/letter_opener_web.svg?branch=master)](https://travis-ci.org/fgrehm/letter_opener_web)
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/letter_opener_web.svg)](http://badge.fury.io/rb/letter_opener_web)
|
5
|
+
[![Code Climate](https://codeclimate.com/github/fgrehm/letter_opener_web.svg)](https://codeclimate.com/github/fgrehm/letter_opener_web)
|
4
6
|
|
5
7
|
Gives [letter_opener](https://github.com/ryanb/letter_opener) an interface for
|
6
8
|
browsing sent emails.
|
@@ -13,7 +15,7 @@ First add the gem to your development environment and run the `bundle` command t
|
|
13
15
|
|
14
16
|
```ruby
|
15
17
|
group :development do
|
16
|
-
gem 'letter_opener_web'
|
18
|
+
gem 'letter_opener_web', '~> 1.0'
|
17
19
|
end
|
18
20
|
```
|
19
21
|
|
@@ -23,9 +25,7 @@ Add to your routes.rb:
|
|
23
25
|
|
24
26
|
```ruby
|
25
27
|
Your::Application.routes.draw do
|
26
|
-
if Rails.env.development?
|
27
|
-
mount LetterOpenerWeb::Engine, at: "/letter_opener"
|
28
|
-
end
|
28
|
+
mount LetterOpenerWeb::Engine, at: "/letter_opener" if Rails.env.development?
|
29
29
|
end
|
30
30
|
```
|
31
31
|
|
@@ -69,7 +69,7 @@ Some people use this gem on staging environments on Heroku and to set that up
|
|
69
69
|
is just a matter of moving the gem out of the `development` group and enabling
|
70
70
|
the route for all environments on your `routes.rb`.
|
71
71
|
|
72
|
-
In
|
72
|
+
In other words, your `Gemfile` will have:
|
73
73
|
|
74
74
|
```ruby
|
75
75
|
gem 'letter_opener_web'
|
@@ -1,8 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
unless Rails.respond_to?(:autoloaders) && Rails.autoloaders.zeitwerk_enabled?
|
4
|
+
require_dependency 'letter_opener_web/application_controller'
|
5
|
+
end
|
6
|
+
|
3
7
|
module LetterOpenerWeb
|
4
8
|
class LettersController < ApplicationController
|
5
|
-
before_action :check_style, only:
|
9
|
+
before_action :check_style, only: :show
|
6
10
|
before_action :load_letter, only: %i[show attachment destroy]
|
7
11
|
|
8
12
|
def index
|
@@ -22,6 +26,7 @@ module LetterOpenerWeb
|
|
22
26
|
file = @letter.attachments[filename]
|
23
27
|
|
24
28
|
return render plain: 'Attachment not found!', status: 404 unless file.present?
|
29
|
+
|
25
30
|
send_file(file, filename: filename, disposition: 'inline')
|
26
31
|
end
|
27
32
|
|
@@ -43,7 +48,8 @@ module LetterOpenerWeb
|
|
43
48
|
|
44
49
|
def load_letter
|
45
50
|
@letter = Letter.find(params[:id])
|
46
|
-
|
51
|
+
|
52
|
+
head :not_found unless @letter.valid?
|
47
53
|
end
|
48
54
|
|
49
55
|
def routes
|
@@ -56,17 +56,19 @@ module LetterOpenerWeb
|
|
56
56
|
end
|
57
57
|
|
58
58
|
def delete
|
59
|
-
|
59
|
+
return unless valid?
|
60
|
+
|
61
|
+
FileUtils.rm_rf(base_dir.to_s)
|
60
62
|
end
|
61
63
|
|
62
|
-
def
|
63
|
-
|
64
|
+
def valid?
|
65
|
+
exists? && base_dir_within_letters_location?
|
64
66
|
end
|
65
67
|
|
66
68
|
private
|
67
69
|
|
68
70
|
def base_dir
|
69
|
-
|
71
|
+
LetterOpenerWeb.config.letters_location.join(id).cleanpath
|
70
72
|
end
|
71
73
|
|
72
74
|
def read_file(style)
|
@@ -77,6 +79,14 @@ module LetterOpenerWeb
|
|
77
79
|
File.exist?("#{base_dir}/#{style}.html")
|
78
80
|
end
|
79
81
|
|
82
|
+
def exists?
|
83
|
+
File.exist?(base_dir)
|
84
|
+
end
|
85
|
+
|
86
|
+
def base_dir_within_letters_location?
|
87
|
+
base_dir.to_s.start_with?(LetterOpenerWeb.config.letters_location.to_s)
|
88
|
+
end
|
89
|
+
|
80
90
|
def adjust_link_targets(contents)
|
81
91
|
# We cannot feed the whole file to an XML parser as some mails are
|
82
92
|
# "complete" (as in they have the whole <html> structure) and letter_opener
|
@@ -86,6 +96,7 @@ module LetterOpenerWeb
|
|
86
96
|
fixed_link = fix_link_html(link)
|
87
97
|
xml = REXML::Document.new(fixed_link).root
|
88
98
|
next if xml.attributes['href'] =~ /(plain|rich).html/
|
99
|
+
|
89
100
|
xml.attributes['target'] = '_blank'
|
90
101
|
xml.add_text('') unless xml.text
|
91
102
|
contents.gsub!(link, xml.to_s)
|