letter_opener_web 1.3.1 → 1.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +3 -0
- data/.rspec +3 -0
- data/.rubocop.yml +27 -0
- data/.travis.yml +21 -4
- data/CHANGELOG.md +7 -0
- data/Gemfile +3 -7
- data/README.md +15 -4
- data/Rakefile +6 -35
- data/app/assets/javascripts/letter_opener_web/application.js +1 -1
- data/app/controllers/letter_opener_web/application_controller.rb +2 -0
- data/app/controllers/letter_opener_web/letters_controller.rb +19 -21
- data/app/models/letter_opener_web/letter.rb +27 -23
- data/app/views/layouts/letter_opener_web/{application.html.erb → letters.html.erb} +0 -2
- data/app/views/letter_opener_web/letters/index.html.erb +8 -8
- data/{script → bin}/rails +4 -1
- data/bin/setup +6 -0
- data/config/routes.rb +2 -0
- data/letter_opener_web.gemspec +13 -11
- data/lib/letter_opener_web.rb +20 -1
- data/lib/letter_opener_web/delivery_method.rb +5 -3
- data/lib/letter_opener_web/engine.rb +12 -7
- data/lib/letter_opener_web/version.rb +3 -1
- data/script/pre-push +2 -0
- data/spec/controllers/letter_opener_web/letters_controller_spec.rb +50 -32
- data/spec/dummy/Rakefile +8 -0
- data/spec/dummy/app/assets/config/manifest.js +5 -0
- data/spec/{internal/public/favicon.ico → dummy/app/assets/images/.keep} +0 -0
- data/spec/dummy/app/assets/javascripts/application.js +13 -0
- data/spec/dummy/app/assets/stylesheets/application.css +31 -0
- data/spec/dummy/app/controllers/application_controller.rb +5 -0
- data/spec/dummy/app/controllers/concerns/.keep +0 -0
- data/spec/dummy/app/controllers/home_controller.rb +10 -0
- data/spec/dummy/app/helpers/application_helper.rb +4 -0
- data/spec/dummy/app/mailers/application_mailer.rb +6 -0
- data/spec/dummy/app/mailers/contact_mailer.rb +14 -0
- data/spec/dummy/app/views/contact_mailer/new_message.html.erb +21 -0
- data/spec/dummy/app/views/contact_mailer/new_message.text.erb +3 -0
- data/spec/dummy/app/views/home/index.html.erb +50 -0
- data/spec/dummy/app/views/layouts/application.html.erb +18 -0
- data/spec/dummy/app/views/layouts/mailer.html.erb +13 -0
- data/spec/dummy/app/views/layouts/mailer.text.erb +1 -0
- data/spec/dummy/bin/bundle +5 -0
- data/spec/dummy/bin/rails +6 -0
- data/spec/dummy/bin/rake +6 -0
- data/spec/dummy/bin/setup +36 -0
- data/spec/dummy/bin/update +31 -0
- data/spec/dummy/config.ru +7 -0
- data/spec/dummy/config/application.rb +23 -0
- data/spec/dummy/config/boot.rb +7 -0
- data/spec/dummy/config/environment.rb +7 -0
- data/spec/dummy/config/environments/development.rb +40 -0
- data/spec/dummy/config/environments/production.rb +85 -0
- data/spec/dummy/config/environments/test.rb +37 -0
- data/spec/dummy/config/initializers/application_controller_renderer.rb +7 -0
- data/spec/dummy/config/initializers/assets.rb +13 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +8 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +7 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +6 -0
- data/spec/dummy/config/initializers/inflections.rb +17 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/new_framework_defaults.rb +10 -0
- data/spec/dummy/config/initializers/session_store.rb +5 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +16 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/puma.rb +49 -0
- data/spec/dummy/config/routes.rb +8 -0
- data/spec/dummy/config/secrets.yml +22 -0
- data/spec/dummy/config/spring.rb +8 -0
- data/spec/dummy/lib/assets/.keep +0 -0
- data/spec/dummy/public/404.html +67 -0
- data/spec/dummy/public/422.html +67 -0
- data/spec/dummy/public/500.html +66 -0
- data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
- data/spec/dummy/public/apple-touch-icon.png +0 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/letter_opener_web_spec.rb +44 -0
- data/spec/models/letter_opener_web/letter_spec.rb +23 -15
- data/spec/rails_helper.rb +8 -0
- data/spec/spec_helper.rb +2 -16
- metadata +142 -30
- data/Gemfile.lock +0 -167
- data/Guardfile +0 -14
- data/lib/tasks/letter_opener_web_tasks.rake +0 -4
- data/spec/internal/config/database.yml +0 -3
- data/spec/internal/config/routes.rb +0 -7
- data/spec/internal/db/schema.rb +0 -3
- data/spec/internal/log/.gitignore +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 5a52b402271aaa9c2010cfd193fd3858e186328f0c13b4fafb3f449ed768eb62
|
4
|
+
data.tar.gz: ad574fc2698517185a7b43a3dc02a431a12edf895f6bceb7b012d0cf61923f3b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a1c1eccaa4ac748e90f57069697724a9d5b9f4482f29c5e5cf1766407dc32ac85161fca9f9cce89db063b73b84b9f7ece72538eb6a78adf6f34bc02ab250a52d
|
7
|
+
data.tar.gz: 272edf9e6edf6912074367770a454dcc824ab1cec0eabba3b464b83eb319f744dbd6e42d0b77d5c4ef1ccc812c6df692ce8bb95d45f53b65d9e70469fb1bacb5
|
data/.gitignore
CHANGED
data/.rspec
CHANGED
data/.rubocop.yml
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
---
|
2
|
+
AllCops:
|
3
|
+
TargetRubyVersion: 2.3
|
4
|
+
Exclude:
|
5
|
+
- "spec/dummy/bin/**/*"
|
6
|
+
- "tmp/**/*"
|
7
|
+
- "vendor/**/*"
|
8
|
+
|
9
|
+
# not available in older versions of Ruby
|
10
|
+
Layout/IndentHeredoc:
|
11
|
+
Enabled: false
|
12
|
+
|
13
|
+
Style/Documentation:
|
14
|
+
Enabled: false
|
15
|
+
|
16
|
+
Style/ClassAndModuleChildren:
|
17
|
+
EnforcedStyle: nested
|
18
|
+
|
19
|
+
Style/SingleLineBlockParams:
|
20
|
+
Enabled: false
|
21
|
+
|
22
|
+
Metrics/BlockLength:
|
23
|
+
Exclude:
|
24
|
+
- spec/**/*_spec.rb
|
25
|
+
|
26
|
+
Metrics/LineLength:
|
27
|
+
Max: 120
|
data/.travis.yml
CHANGED
@@ -1,7 +1,24 @@
|
|
1
|
+
sudo: false
|
1
2
|
language: ruby
|
3
|
+
|
2
4
|
rvm:
|
3
|
-
- 2.
|
4
|
-
- 2.
|
5
|
-
- 2.
|
6
|
-
|
5
|
+
- 2.3.3
|
6
|
+
- 2.2.6
|
7
|
+
- 2.1.10
|
8
|
+
|
7
9
|
cache: bundler
|
10
|
+
|
11
|
+
before_install:
|
12
|
+
- gem update --system
|
13
|
+
|
14
|
+
notifications:
|
15
|
+
email: false
|
16
|
+
|
17
|
+
deploy:
|
18
|
+
provider: rubygems
|
19
|
+
gem: letter_opener_web
|
20
|
+
api_key:
|
21
|
+
secure: Rv1IgeIhnfIV9NVr3iPwb2UCXe0UEtuZHfgkGruu3yvfoSGmQQ0xnc45ZhOH8ANl6tjzYNuilSDYbhz3fWOmniHsnzLGbFbccz/CWHmldUpPgVnKQ0d0Bm2EeNuVpmHwdnG7KEqMC0x1gxFYks62BGpx4C/2Kh5nWbvvPxN8X0U=
|
22
|
+
on:
|
23
|
+
tags: true
|
24
|
+
repo: fgrehm/letter_opener_web
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
## [1.3.2](https://github.com/fgrehm/letter_opener_web/compare/v1.3.1...v1.3.2) (Jan 14, 2018)
|
2
|
+
|
3
|
+
- Disable Launchy with ENV to avoid redefining the whole delivery method [#73](https://github.com/fgrehm/letter_opener_web/pull/73)
|
4
|
+
- Fix new Rubocop warnings [#72](https://github.com/fgrehm/letter_opener_web/pull/72)
|
5
|
+
- Hover state fixed to only highlight `tbody>tr` [#70](https://github.com/fgrehm/letter_opener_web/pull/70)
|
6
|
+
- Use `ActiveSupport.on_load` to make sure we don't have load order issues [#66](https://github.com/fgrehm/letter_opener_web/pull/66)
|
7
|
+
|
1
8
|
## [1.3.1](https://github.com/fgrehm/letter_opener_web/compare/v1.3.0...v1.3.1) (Feb 04, 2017)
|
2
9
|
|
3
10
|
- Remove warnings about unused variables [#45](https://github.com/fgrehm/letter_opener_web/pull/45)
|
data/Gemfile
CHANGED
@@ -1,12 +1,8 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source 'http://rubygems.org'
|
2
4
|
|
3
5
|
# Declare your gem's dependencies in letter_opener_web.gemspec.
|
4
6
|
# Bundler will treat runtime dependencies like base dependencies, and
|
5
7
|
# development dependencies will be added by default to the :development group.
|
6
8
|
gemspec
|
7
|
-
|
8
|
-
group :development do
|
9
|
-
gem 'rb-inotify'
|
10
|
-
gem 'guard'
|
11
|
-
gem 'guard-rspec'
|
12
|
-
end
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# letter_opener_web
|
2
2
|
|
3
|
-
[![Build Status](https://travis-ci.org/fgrehm/letter_opener_web.png?branch=master)](https://travis-ci.org/fgrehm/letter_opener_web) [![Gem Version](https://badge.fury.io/rb/letter_opener_web.png)](http://badge.fury.io/rb/letter_opener_web) [![Code Climate](https://codeclimate.com/github/fgrehm/letter_opener_web.png)](https://codeclimate.com/github/fgrehm/letter_opener_web) [![
|
3
|
+
[![Build Status](https://travis-ci.org/fgrehm/letter_opener_web.png?branch=master)](https://travis-ci.org/fgrehm/letter_opener_web) [![Gem Version](https://badge.fury.io/rb/letter_opener_web.png)](http://badge.fury.io/rb/letter_opener_web) [![Code Climate](https://codeclimate.com/github/fgrehm/letter_opener_web.png)](https://codeclimate.com/github/fgrehm/letter_opener_web) [![Gitter chat](https://badges.gitter.im/fgrehm/letter_opener_web.png)](https://gitter.im/fgrehm/letter_opener_web)
|
4
4
|
|
5
5
|
Gives [letter_opener](https://github.com/ryanb/letter_opener) an interface for
|
6
6
|
browsing sent emails.
|
@@ -12,7 +12,9 @@ Check out http://letter-opener-web.herokuapp.com to see it in action.
|
|
12
12
|
First add the gem to your development environment and run the `bundle` command to install it.
|
13
13
|
|
14
14
|
```ruby
|
15
|
-
|
15
|
+
group :development do
|
16
|
+
gem 'letter_opener_web'
|
17
|
+
end
|
16
18
|
```
|
17
19
|
|
18
20
|
## Usage
|
@@ -52,6 +54,15 @@ config.action_mailer.delivery_method = :letter_opener_web
|
|
52
54
|
config.action_mailer.delivery_method = ENV['USER'] == 'vagrant' ? :letter_opener_web : :letter_opener
|
53
55
|
```
|
54
56
|
|
57
|
+
If you're using `:letter_opener_web` as your delivery method, you can change the location of the letters by adding the
|
58
|
+
following to an initializer (or in development.rb):
|
59
|
+
|
60
|
+
```ruby
|
61
|
+
LetterOpenerWeb.configure do |config|
|
62
|
+
config.letters_location = Rails.root.join('your', 'new', 'path')
|
63
|
+
end
|
64
|
+
```
|
65
|
+
|
55
66
|
## Usage on Heroku
|
56
67
|
|
57
68
|
Some people use this gem on staging environments on Heroku and to set that up
|
@@ -61,7 +72,7 @@ the route for all environments on your `routes.rb`.
|
|
61
72
|
In order words, your `Gemfile` will have:
|
62
73
|
|
63
74
|
```ruby
|
64
|
-
gem 'letter_opener_web'
|
75
|
+
gem 'letter_opener_web'
|
65
76
|
```
|
66
77
|
|
67
78
|
And your `routes.rb`:
|
@@ -85,7 +96,7 @@ ideas on [this pull request](https://github.com/ryanb/letter_opener/pull/12).
|
|
85
96
|
|
86
97
|
## Contributing
|
87
98
|
|
88
|
-
1. Fork it
|
99
|
+
1. Fork it and run `bin/setup`
|
89
100
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
90
101
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
91
102
|
4. Push to the branch (`git push origin my-new-feature`)
|
data/Rakefile
CHANGED
@@ -1,39 +1,10 @@
|
|
1
1
|
#!/usr/bin/env rake
|
2
|
-
|
3
|
-
desc 'Print out all defined routes in match order, with names. Target specific controller with CONTROLLER=x.'
|
4
|
-
task :routes do
|
5
|
-
require 'combustion'
|
6
|
-
Bundler.require :default, :development
|
7
|
-
|
8
|
-
Combustion.initialize! :action_controller, :action_view, :sprockets, :action_mailer
|
9
|
-
|
10
|
-
all_routes = LetterOpenerWeb::Engine.routes.routes
|
11
|
-
|
12
|
-
require 'rails/application/route_inspector'
|
13
|
-
inspector = Rails::Application::RouteInspector.new
|
14
|
-
puts inspector.format(all_routes, ENV['CONTROLLER']).join "\n"
|
15
|
-
end
|
16
|
-
|
17
|
-
begin
|
18
|
-
require 'rdoc/task'
|
19
|
-
rescue LoadError
|
20
|
-
require 'rdoc/rdoc'
|
21
|
-
require 'rake/rdoctask'
|
22
|
-
RDoc::Task = Rake::RDocTask
|
23
|
-
end
|
24
|
-
|
25
|
-
RDoc::Task.new(:rdoc) do |rdoc|
|
26
|
-
rdoc.rdoc_dir = 'rdoc'
|
27
|
-
rdoc.title = 'LetterOpenerWeb'
|
28
|
-
rdoc.options << '--line-numbers'
|
29
|
-
rdoc.rdoc_files.include('README.rdoc')
|
30
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
31
|
-
end
|
2
|
+
# frozen_string_literal: true
|
32
3
|
|
33
4
|
require 'bundler/gem_tasks'
|
5
|
+
require 'rspec/core/rake_task'
|
6
|
+
require 'rubocop/rake_task'
|
34
7
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
task :default => :spec
|
39
|
-
rescue LoadError; end
|
8
|
+
RuboCop::RakeTask.new
|
9
|
+
RSpec::Core::RakeTask.new(:spec)
|
10
|
+
task default: %i[spec rubocop]
|
@@ -10,7 +10,7 @@ jQuery(function($) {
|
|
10
10
|
var favicon = new Favcount($('link[rel="icon"]').attr('href'));
|
11
11
|
update_favicon(favicon);
|
12
12
|
|
13
|
-
$('.letter-opener').on('click', 'tr', function() {
|
13
|
+
$('.letter-opener').on('click', 'tbody > tr', function() {
|
14
14
|
var $this = $(this);
|
15
15
|
$('iframe').attr('src', $this.find('a').attr('href'));
|
16
16
|
$this.parent().find('.active').removeClass('active');
|
@@ -1,55 +1,53 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module LetterOpenerWeb
|
4
4
|
class LettersController < ApplicationController
|
5
|
-
before_action :check_style, :
|
6
|
-
before_action :load_letter, :
|
5
|
+
before_action :check_style, only: [:show]
|
6
|
+
before_action :load_letter, only: %i[show attachment destroy]
|
7
7
|
|
8
8
|
def index
|
9
9
|
@letters = Letter.search
|
10
10
|
end
|
11
11
|
|
12
12
|
def show
|
13
|
-
text = @letter.send("#{params[:style]}_text")
|
14
|
-
|
15
|
-
|
13
|
+
text = @letter.send("#{params[:style]}_text")
|
14
|
+
.gsub(/"plain\.html"/, "\"#{routes.letter_path(id: @letter.id, style: 'plain')}\"")
|
15
|
+
.gsub(/"rich\.html"/, "\"#{routes.letter_path(id: @letter.id, style: 'rich')}\"")
|
16
16
|
|
17
|
-
render :
|
17
|
+
render html: text.html_safe
|
18
18
|
end
|
19
19
|
|
20
20
|
def attachment
|
21
|
-
@letter = Letter.find(params[:id])
|
22
21
|
filename = "#{params[:file]}.#{params[:format]}"
|
22
|
+
file = @letter.attachments[filename]
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
else
|
27
|
-
render :plain => 'Attachment not found!', :status => 404
|
28
|
-
end
|
24
|
+
return render plain: 'Attachment not found!', status: 404 unless file.present?
|
25
|
+
send_file(file, filename: filename, disposition: 'inline')
|
29
26
|
end
|
30
27
|
|
31
28
|
def clear
|
32
29
|
Letter.destroy_all
|
33
|
-
redirect_to
|
30
|
+
redirect_to routes.letters_path
|
34
31
|
end
|
35
32
|
|
36
33
|
def destroy
|
37
|
-
@letter = Letter.find(params[:id])
|
38
34
|
@letter.delete
|
39
|
-
redirect_to
|
35
|
+
redirect_to routes.letters_path
|
40
36
|
end
|
41
37
|
|
42
38
|
private
|
43
39
|
|
44
40
|
def check_style
|
45
|
-
params[:style] = 'rich' unless [
|
41
|
+
params[:style] = 'rich' unless %w[plain rich].include?(params[:style])
|
46
42
|
end
|
47
43
|
|
48
44
|
def load_letter
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
45
|
+
@letter = Letter.find(params[:id])
|
46
|
+
head :not_found unless @letter.exists?
|
47
|
+
end
|
48
|
+
|
49
|
+
def routes
|
50
|
+
LetterOpenerWeb.railtie_routes_url_helpers
|
53
51
|
end
|
54
52
|
end
|
55
53
|
end
|
@@ -1,24 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module LetterOpenerWeb
|
2
4
|
class Letter
|
3
|
-
|
4
|
-
|
5
|
+
attr_reader :id, :sent_at
|
6
|
+
|
7
|
+
def self.letters_location
|
8
|
+
@letters_location ||= LetterOpenerWeb.config.letters_location
|
5
9
|
end
|
6
10
|
|
7
|
-
|
11
|
+
def self.letters_location=(directory)
|
12
|
+
LetterOpenerWeb.configure { |config| config.letters_location = directory }
|
13
|
+
@letters_location = nil
|
14
|
+
end
|
8
15
|
|
9
16
|
def self.search
|
10
|
-
letters = Dir.glob("#{letters_location}/*").map do |folder|
|
11
|
-
new
|
17
|
+
letters = Dir.glob("#{LetterOpenerWeb.config.letters_location}/*").map do |folder|
|
18
|
+
new(id: File.basename(folder), sent_at: File.mtime(folder))
|
12
19
|
end
|
13
20
|
letters.sort_by(&:sent_at).reverse
|
14
21
|
end
|
15
22
|
|
16
23
|
def self.find(id)
|
17
|
-
new
|
24
|
+
new(id: id)
|
18
25
|
end
|
19
26
|
|
20
27
|
def self.destroy_all
|
21
|
-
FileUtils.rm_rf(letters_location)
|
28
|
+
FileUtils.rm_rf(LetterOpenerWeb.config.letters_location)
|
22
29
|
end
|
23
30
|
|
24
31
|
def initialize(params)
|
@@ -27,11 +34,11 @@ module LetterOpenerWeb
|
|
27
34
|
end
|
28
35
|
|
29
36
|
def plain_text
|
30
|
-
@plain_text ||= adjust_link_targets
|
37
|
+
@plain_text ||= adjust_link_targets(read_file(:plain))
|
31
38
|
end
|
32
39
|
|
33
40
|
def rich_text
|
34
|
-
@rich_text ||= adjust_link_targets
|
41
|
+
@rich_text ||= adjust_link_targets(read_file(:rich))
|
35
42
|
end
|
36
43
|
|
37
44
|
def to_param
|
@@ -39,9 +46,7 @@ module LetterOpenerWeb
|
|
39
46
|
end
|
40
47
|
|
41
48
|
def default_style
|
42
|
-
style_exists?('rich') ?
|
43
|
-
'rich' :
|
44
|
-
'plain'
|
49
|
+
style_exists?('rich') ? 'rich' : 'plain'
|
45
50
|
end
|
46
51
|
|
47
52
|
def attachments
|
@@ -51,17 +56,17 @@ module LetterOpenerWeb
|
|
51
56
|
end
|
52
57
|
|
53
58
|
def delete
|
54
|
-
FileUtils.rm_rf("#{letters_location}/#{
|
59
|
+
FileUtils.rm_rf("#{LetterOpenerWeb.config.letters_location}/#{id}")
|
55
60
|
end
|
56
61
|
|
57
62
|
def exists?
|
58
|
-
File.
|
63
|
+
File.exist?(base_dir)
|
59
64
|
end
|
60
65
|
|
61
66
|
private
|
62
67
|
|
63
68
|
def base_dir
|
64
|
-
"#{letters_location}/#{id}"
|
69
|
+
"#{LetterOpenerWeb.config.letters_location}/#{id}"
|
65
70
|
end
|
66
71
|
|
67
72
|
def read_file(style)
|
@@ -69,7 +74,7 @@ module LetterOpenerWeb
|
|
69
74
|
end
|
70
75
|
|
71
76
|
def style_exists?(style)
|
72
|
-
File.
|
77
|
+
File.exist?("#{base_dir}/#{style}.html")
|
73
78
|
end
|
74
79
|
|
75
80
|
def adjust_link_targets(contents)
|
@@ -77,14 +82,13 @@ module LetterOpenerWeb
|
|
77
82
|
# "complete" (as in they have the whole <html> structure) and letter_opener
|
78
83
|
# prepends some information about the mail being sent, making REXML
|
79
84
|
# complain about it
|
80
|
-
contents.scan(
|
85
|
+
contents.scan(%r{<a\s[^>]+>(?:.|\s)*?</a>}).each do |link|
|
81
86
|
fixed_link = fix_link_html(link)
|
82
87
|
xml = REXML::Document.new(fixed_link).root
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
end
|
88
|
+
next if xml.attributes['href'] =~ /(plain|rich).html/
|
89
|
+
xml.attributes['target'] = '_blank'
|
90
|
+
xml.add_text('') unless xml.text
|
91
|
+
contents.gsub!(link, xml.to_s)
|
88
92
|
end
|
89
93
|
contents
|
90
94
|
end
|
@@ -95,7 +99,7 @@ module LetterOpenerWeb
|
|
95
99
|
fixed_link.gsub!('<br>', '<br/>')
|
96
100
|
fixed_link.scan(/<img(?:[^>]+?)>/).each do |img|
|
97
101
|
fixed_img = img.dup
|
98
|
-
fixed_img.gsub!(/>$/, '/>') unless img =~
|
102
|
+
fixed_img.gsub!(/>$/, '/>') unless img =~ %r{/>$}
|
99
103
|
fixed_link.gsub!(img, fixed_img)
|
100
104
|
end
|
101
105
|
end
|
@@ -2,17 +2,17 @@
|
|
2
2
|
<h1>
|
3
3
|
Letters
|
4
4
|
<span class="pull-right">
|
5
|
-
<%= link_to
|
5
|
+
<%= link_to letters_path, class: 'btn refresh' do %>
|
6
6
|
<i class="icon-refresh"></i>
|
7
7
|
Refresh
|
8
8
|
<% end %>
|
9
|
-
<%= link_to
|
9
|
+
<%= link_to clear_letters_path, method: 'delete', data: { confirm: 'Are you sure?' }, class: 'btn btn-danger' do %>
|
10
10
|
<i class="icon-trash icon-white"></i>
|
11
11
|
Clear
|
12
12
|
<% end %>
|
13
13
|
</span>
|
14
14
|
</h1>
|
15
|
-
<table class="table table-hover letter-opener" data-letters-path="<%=
|
15
|
+
<table class="table table-hover letter-opener" data-letters-path="<%= letters_path %>">
|
16
16
|
<thead>
|
17
17
|
<tr>
|
18
18
|
<th>ID</th>
|
@@ -24,11 +24,11 @@
|
|
24
24
|
<% if first_letter = @letters.shift %>
|
25
25
|
<tr class="active">
|
26
26
|
<td>
|
27
|
-
<%= link_to(first_letter.id,
|
27
|
+
<%= link_to(first_letter.id, letter_path(first_letter, style: first_letter.default_style), target: 'mail') %>
|
28
28
|
</td>
|
29
29
|
<td><%= first_letter.sent_at %></td>
|
30
30
|
<td>
|
31
|
-
<%= link_to
|
31
|
+
<%= link_to delete_letter_path(first_letter), method: 'delete', data: { confirm: 'Are you sure you want to delete this email?' } do %>
|
32
32
|
<span class="pull-right">
|
33
33
|
<i class="icon-remove-circle" title="Delete"></i>
|
34
34
|
</span>
|
@@ -39,11 +39,11 @@
|
|
39
39
|
<% @letters.each do |letter| %>
|
40
40
|
<tr>
|
41
41
|
<td>
|
42
|
-
<%= link_to(letter.id,
|
42
|
+
<%= link_to(letter.id, letter_path(letter, style: letter.default_style), target: 'mail') %>
|
43
43
|
</td>
|
44
44
|
<td><%= letter.sent_at %></td>
|
45
45
|
<td>
|
46
|
-
<%= link_to
|
46
|
+
<%= link_to delete_letter_path(letter), :method => 'delete', data: { confirm: 'Are you sure you want to delete this email?' } do %>
|
47
47
|
<span class="pull-right">
|
48
48
|
<i class="icon-remove-circle"></i>
|
49
49
|
</span>
|
@@ -55,5 +55,5 @@
|
|
55
55
|
</table>
|
56
56
|
</div>
|
57
57
|
<div class="col right">
|
58
|
-
<iframe name="mail" id="mail" src="<%= first_letter.present? ?
|
58
|
+
<iframe name="mail" id="mail" src="<%= first_letter.present? ? letter_path(first_letter, style: first_letter.default_style) : 'about:blank' %>"></iframe>
|
59
59
|
</div>
|