rails_email_preview 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0f5773872c3d519a23d5f76153fe456ccab6ea14
4
- data.tar.gz: dab9c099a7958f3e47066259296ad9b5cf560731
3
+ metadata.gz: e2327030739ba9db8a54b1ebb9dbe8b9ec2a08d1
4
+ data.tar.gz: 02f026c42ab14c959abd425df25333f4eda089ac
5
5
  SHA512:
6
- metadata.gz: 0ce53a1f8274cd14de46c7eeb4e10248efcb35e57ce47e0bf6464f9e1d209e17417c63e11c2983757abc8e90a22918adc645e394765097a8dcefd099f2227b15
7
- data.tar.gz: 9a742a012388f5553ce6f36abd487c1cf0909e724c43448b4b6f09395cf97f6a5848c8e83d7e3185526c9cca3acfde2085cdae5aacb81fcbc57bd11a94d6043f
6
+ metadata.gz: fa93f32d0dfaaaf849f237e528bbb639ad5c2061d857c991bc5a6e24dff04c18ec7efde75c052efeac910c4a400c16b6a72089c5f8596f597d0159fea93a1e5d
7
+ data.tar.gz: 6292757e5522d27c7e8431849da37cd44747a8de074b3ca72dfc1d4863124b078e495a683d638ff8bba0f8387f8091f03e84adfcff5efbf409e9a179fb56c1df
data/README.md CHANGED
@@ -3,9 +3,9 @@ Rails Email Preview
3
3
 
4
4
  A Rails Engine to preview plain text and html email in your browser. Compatible with Rails 3 and 4.
5
5
 
6
- ![screenshot](http://screencloud.net//img/screenshots/8861336ed60923429d3747e1fd379619.png)
7
6
  ![screenshot](http://screencloud.net//img/screenshots/22aa58b651815068f4b0676754275c6a.png)
8
- *Rendered within an application layout*
7
+ ![screenshot](http://screencloud.net//img/screenshots/8861336ed60923429d3747e1fd379619.png)
8
+ *(styles are from the application)*
9
9
 
10
10
  How to
11
11
  -----
@@ -40,23 +40,30 @@ You will need to provide data for preview of each email:
40
40
  User.new(name: name, email: "user@test.com#{rand 100}").tap { |u| u.define_singleton_method(:id) { 123 + rand(100) } }
41
41
  end
42
42
  end
43
+
44
+ # Let REP know about UserMailerPreview:
45
+ # touch config/initializers/rails_email_preview.rb
46
+ RailsEmailPreview.setup do |config|
47
+ config.preview_classes = [ UserMailerPreview ]
48
+ end
43
49
 
44
50
 
45
51
  Routing
46
52
  -------
47
53
 
48
- mount RailsEmailPreview::Engine, at: 'email_preview' # rails_email_preview.root_url #=> '/email_preview'
54
+ mount RailsEmailPreview::Engine, at: 'emails'
55
+
56
+ # You can access REP urls like this:
57
+ rails_email_preview.root_url #=> '/emails'
58
+
59
+ Email editing
60
+ -------------
49
61
 
62
+ You can use [comfortable_mexican_sofa](https://github.com/comfy/comfortable-mexican-sofa) for storing and editing emails.
63
+ REP comes with a CMS integration, see [ComfortableMexicanSofa integration guide](https://github.com/glebm/rails_email_preview/wiki/Edit-Emails-with-Comfortable-Mexican-Sofa).
50
64
 
51
- Configuration
52
- -------
53
-
54
- # touch config/initializers/rails_email_preview.rb
65
+ ![CMS integration screenshot](http://screencloud.net//img/screenshots/b000595dbd13ae061373fd1473f113ba.png)
55
66
 
56
- require 'rails_email_preview'
57
- RailsEmailPreview.setup do |config|
58
- config.preview_classes = [ UserMailerPreview ]
59
- end
60
67
 
61
68
  Premailer integration
62
69
  ---------------------
@@ -73,18 +80,11 @@ For [premailer-rails](https://github.com/fphilipe/premailer-rails), add to `Rail
73
80
 
74
81
  config.before_render { |message| Premailer::Rails::Hook.delivering_email(message) }
75
82
 
76
- Email editing
77
- -------------
78
-
79
- You can use [comfortable_mexican_sofa](https://github.com/comfy/comfortable-mexican-sofa) for storing and editing emails.
80
- REP comes with a CMS integration, see [ComfortableMexicanSofa integration guide](https://github.com/glebm/rails_email_preview/wiki/Edit-Emails-with-Comfortable-Mexican-Sofa).
81
-
82
- ![CMS integration screenshot](http://screencloud.net//img/screenshots/b000595dbd13ae061373fd1473f113ba.png)
83
83
 
84
84
  I18n
85
85
  -------------
86
86
 
87
- Rails Email Preview expect emails to be rendered using `I18n.locale`:
87
+ REP expects emails to use current `I18n.locale`:
88
88
 
89
89
  # current locale
90
90
  AccountMailer.some_notification.deliver
@@ -7,12 +7,12 @@ javascript:
7
7
  $('.center-column').css('margin', 0);
8
8
 
9
9
  // Snippet form:
10
- // * Hide identifier and categories
10
+ // Hide identifier and categories
11
11
  $('[name="snippet[identifier]"]').closest('.control-group').hide();
12
12
  $('label[for="snippet_"]').closest('.control-group').hide();
13
- // * Label -> Subject
13
+ // Label to Subject
14
14
  $('[name="snippet[label]"]').closest('.control-group').find('.control-label').text("Subject");
15
- // * Content -> Body
15
+ // Content to Body
16
16
  $('[name="snippet[content]"]').closest('.control-group').find('.control-label').text("Body");
17
17
  }
18
18
  });
@@ -25,12 +25,13 @@ module RailsEmailPreview
25
25
  title = snippet.label.to_s
26
26
  interpolation = interpolation.stringify_keys
27
27
  # set all missing values to ''
28
- title.scan(/%{([^}]+)}/) { |key| interpolation[key] ||= ''}
28
+ title.scan(/%{([^}]+)}/) { |m| interpolation[m[0]] ||= ''}
29
29
  # remove all missing keys
30
- subject = title % interpolation.delete_if { |k, v| title !~ /%{#{k}}/ }
30
+ subject = title % interpolation.symbolize_keys.delete_if { |k, v| title !~ /%{#{k}}/ }
31
31
 
32
32
  return subject if subject.present?
33
33
  end
34
+ '(no subject)'
34
35
  end
35
36
 
36
37
  # Will return snippet content, passing through Kramdown
@@ -44,7 +45,7 @@ module RailsEmailPreview
44
45
  default_site = Cms::Site.find_by_locale(I18n.default_locale)
45
46
  fallback_content = cms_snippet_content(snippet_id, default_site).presence
46
47
  end
47
- result = content || fallback_content
48
+ result = (content || fallback_content).to_s
48
49
 
49
50
  # If rendering in preview from admin, add edit/create lnk
50
51
  if caller.grep(/emails_controller/).present?
@@ -1,3 +1,3 @@
1
1
  module RailsEmailPreview
2
- VERSION = '0.1.2'
2
+ VERSION = '0.1.3'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_email_preview
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gleb Mazovetskiy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-06-09 00:00:00.000000000 Z
11
+ date: 2013-06-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport