rails_email_preview 2.0.4 → 2.0.6

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: ad245287c2281ea3c9fb7d7d62fdb2eeaffe0f15
4
- data.tar.gz: db3b448cbb4b90eb20100beb3c10d72a4892597f
2
+ SHA256:
3
+ metadata.gz: 1fec4ab249106fa4bdb5a18e46a31e8ee3bfc4ec0d5f62e23ebc3263ebda3180
4
+ data.tar.gz: af5cb7850af9125e8ef5d151a73e2d0c780f5c7f467a8173a691578a26a406a0
5
5
  SHA512:
6
- metadata.gz: 78e8f48adeb858442e6221ca95576cc067d55e60a414db112bd7d0e4a78816e02ade0521c1d920526a60b5806427910410b8c3f193fb9dcad5e48d2802ff63d3
7
- data.tar.gz: 6f9097e3a34c1dfd3524ecc623968cca04065f7385570de7f238a0b30558cee36d6083ab6295e1fcf4732533d982a7900608d21768f8a25f3852290aedc971e5
6
+ metadata.gz: 0d73fe44be945370c4e2df1a0b40caf7498b7a4ec4cfbf2206878c47c381ad0be24a1d9e5ffb3712b1470d43407f6b6371eb85f8995e1ef92ecab7f8b8025485
7
+ data.tar.gz: 9748544a2e0dfb998ac16198d58f60ccf380afdcfe4e8253c14d595a3ba09982fc887a12db53ae6b1be3f251fa0c61398c2bcf6c921a236f55619d3d681b8a6e
data/README.md CHANGED
@@ -17,7 +17,7 @@ REP comes with two themes: a simple standalone theme, and a theme that uses [Boo
17
17
  Add [![Gem Version][gem-badge]][gem] to Gemfile:
18
18
 
19
19
  ```ruby
20
- gem 'rails_email_preview', '~> 2.0.4'
20
+ gem 'rails_email_preview', '~> 2.0.6'
21
21
  ```
22
22
 
23
23
  Add an initializer and the routes:
@@ -25,13 +25,16 @@ module RailsEmailPreview
25
25
  end
26
26
 
27
27
  def name
28
- @name ||= "#{group_name}: #{method_name}"
28
+ @name ||= "#{group_name}: #{humanized_method_name}"
29
29
  end
30
30
 
31
- def method_name
31
+ def humanized_method_name
32
32
  @action_name ||= preview_method.to_s.humanize
33
33
  end
34
34
 
35
+ # @deprecated {#method_name} is deprecated and will be removed in v3
36
+ alias_method :method_name, :humanized_method_name
37
+
35
38
  def group_name
36
39
  @group_name ||= preview_class_name.to_s.underscore.gsub('/', ': ').sub(/(_mailer)?_preview$/, '').humanize
37
40
  end
@@ -8,47 +8,14 @@
8
8
  customize_form = show_url.present? || snippet && !snippet.persisted?
9
9
  %>
10
10
  <% if customize_form %>
11
- <script>
12
- if (window.parent && window.parent.rep && (new RegExp('<%= rails_email_preview.rep_root_path %>')).test(parent.location.href)) {
13
- jQuery(function ($) {
14
- // Hide nav:
15
- $('.left-column,.right-column').hide();
16
- $('.center-column').css('margin', 0);
17
- $('#comfy').css('backgroundColor', 'white');
18
-
19
- var showUrl = '<%= show_url %>';
20
-
21
- if (showUrl) {
22
- var parentParams = parent.location.search;
23
- if (!/\?/.test(showUrl)) showUrl += '?';
24
- showUrl = showUrl.replace(/\?.*$/, parentParams);
25
- $('.page-header h2').html(
26
- "<%= t '.edit_email' %>" + " <a class='<%= RailsEmailPreview.style[:btn_default_class] %>' href='" + showUrl + "'><%= t '.view_link' %></a>");
27
- }
28
-
29
- // Snippet form:
30
- var control = function (name) {
31
- return $('[name^="snippet[' + name + ']"]').closest('.form-group,.control-group');
32
- };
33
-
34
- // retext labels
35
- control('label').find('.control-label').text("Subject");
36
- control('content').find('.control-label').text("Body");
37
-
38
- // hide identifier and categories
39
- control('identifier').hide();
40
- control('category_ids').hide();
41
-
42
- // Do not mess with identifier
43
- $('[data-slug]').removeAttr('data-slug');
44
- });
45
-
46
- // Schedule headers view refresh on next load
47
- jQuery(window).on('load', function () {
48
- setTimeout(function () {
49
- window.parent.rep.fetchHeadersOnNextLoad = true;
50
- })
51
- });
52
- }
53
- </script>
11
+ <meta name="rep-root-path" content="<%= rails_email_preview.rep_root_path %>">
12
+ <div id="rep-cms-integration-data"
13
+ data-show-url="<%= show_url %>"
14
+ data-view-link-label="<%= t '.view_link' %>"
15
+ data-edit-email-label="<%= t '.edit_email'%>"></div>
16
+ <% if adapter.cms_v2_plus? %>
17
+ <script><%= render file: 'integrations/cms/comfy_v2_integration.js' %></script>
18
+ <% else # CMS v1 %>
19
+ <script><%= render file: 'integrations/cms/comfy_v1_integration.js' %></script>
20
+ <% end %>
54
21
  <% end %>
@@ -0,0 +1,43 @@
1
+ if (window.parent && window.parent.rep && (new RegExp(document.querySelector('meta[name="rep-root-path"]').content)).test(parent.location.href)) {
2
+ jQuery(function($) {
3
+ // Hide nav:
4
+ $('.left-column,.right-column').hide();
5
+ $('.center-column').css('margin', 0);
6
+ $('#comfy').css('backgroundColor', 'white');
7
+
8
+ // Replace header:
9
+ const repData = document.querySelector('#rep-cms-integration-data').dataset;
10
+ let showUrl = repData.showUrl;
11
+ if (showUrl) {
12
+ const parentParams = parent.location.search;
13
+ if (!/\?/.test(showUrl)) showUrl += '?';
14
+ showUrl = showUrl.replace(/\?.*$/, parentParams);
15
+ document.querySelector('.page-header h2').innerHTML =
16
+ `${repData.editEmailLabel} <a class='btn btn-link' href='${showUrl}'>${repData.viewLinkLabel}</a>`;
17
+ document.querySelector('.form-actions a').href = showUrl;
18
+ }
19
+
20
+ // Snippet form:
21
+ var control = function(name) {
22
+ return $('[name^="snippet[' + name + ']"]').closest('.form-group,.control-group');
23
+ };
24
+
25
+ // retext labels
26
+ control('label').find('.control-label').text("Subject");
27
+ control('content').find('.control-label').text("Body");
28
+
29
+ // hide identifier and categories
30
+ control('identifier').hide();
31
+ control('category_ids').hide();
32
+
33
+ // Do not mess with identifier
34
+ $('[data-slug]').removeAttr('data-slug');
35
+ });
36
+
37
+ // Schedule headers view refresh on next load
38
+ jQuery(window).on('load', function() {
39
+ setTimeout(function() {
40
+ window.parent.rep.fetchHeadersOnNextLoad = true;
41
+ })
42
+ });
43
+ }
@@ -0,0 +1,44 @@
1
+ (() => {
2
+ if (!(window.parent && window.parent.rep &&
3
+ (new RegExp(document.querySelector('meta[name="rep-root-path"]').content)).test(parent.location.href))) return;
4
+ document.querySelector('#cms-left').style.display = 'none';
5
+ document.addEventListener('DOMContentLoaded', () => {
6
+ // Hide nav
7
+ document.querySelector('#cms-right').style.display = 'none';
8
+ const main = document.querySelector('#cms-main');
9
+ main.classList.remove('col-lg-8');
10
+ main.classList.add('col-lg-12');
11
+
12
+ // Replace header:
13
+ const repData = document.querySelector('#rep-cms-integration-data').dataset;
14
+ let showUrl = repData.showUrl;
15
+ if (showUrl) {
16
+ const parentParams = parent.location.search;
17
+ if (!/\?/.test(showUrl)) showUrl += '?';
18
+ showUrl = showUrl.replace(/\?.*$/, parentParams);
19
+ main.querySelector('.page-header h2').innerHTML =
20
+ `${repData.editEmailLabel} <a class='btn btn-link' href='${showUrl}'>${repData.viewLinkLabel}</a>`;
21
+ main.querySelector('.form-actions a').href = showUrl;
22
+ }
23
+
24
+ const control = (name) => {
25
+ const input = main.querySelector(`[name^="snippet[${name}]"]:not([type="hidden"])`);
26
+ let parent = input.parentElement;
27
+ while (!parent.classList.contains('form-group')) parent = parent.parentElement;
28
+ return parent;
29
+ };
30
+
31
+ // Retext labels:
32
+ control('label').querySelector('label').innerText = 'Subject';
33
+ control('content').querySelector('label').innerText = 'Body';
34
+
35
+ // Hide identifiers and categories:
36
+ control('identifier').style.display = 'none';
37
+ control('category_ids').style.display = 'none';
38
+
39
+ // Do not mess with the identifier
40
+ document.querySelector('[data-slug]').removeAttribute('data-slug');
41
+ });
42
+ window.parent.rep.fetchHeadersOnNextLoad = true;
43
+ window.parent.rep.iframeOnDOMContentLoaded();
44
+ })();
@@ -16,7 +16,7 @@
16
16
  <% group_previews.each do |p| %>
17
17
  <a class="<%= rep_style[:list_group_item_class] %>"
18
18
  href="<%= rails_email_preview.rep_email_path(preview_id: p.id, email_locale: @email_locale) %>">
19
- <%= p.method_name %>
19
+ <%= p.humanized_method_name %>
20
20
  </a>
21
21
  <% end %>
22
22
  </div>
@@ -146,6 +146,10 @@ module RailsEmailPreview
146
146
  end
147
147
  end
148
148
 
149
+ def cms_v2_plus?
150
+ cms_version_gte? '2.0.0'
151
+ end
152
+
149
153
  private
150
154
  def cms_version_gte?(version)
151
155
  (::ComfortableMexicanSofa::VERSION.split('.').map(&:to_i) <=> version.split('.').map(&:to_i)) >= 0
@@ -1,3 +1,3 @@
1
1
  module RailsEmailPreview
2
- VERSION = '2.0.4'
2
+ VERSION = '2.0.6'
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: 2.0.4
4
+ version: 2.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gleb Mazovetskiy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-17 00:00:00.000000000 Z
11
+ date: 2018-03-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -141,6 +141,8 @@ files:
141
141
  - app/models/rails_email_preview/preview.rb
142
142
  - app/presenters/rails_email_preview/preview_list_presenter.rb
143
143
  - app/views/integrations/cms/_customize_cms_for_rails_email_preview.html.erb
144
+ - app/views/integrations/cms/comfy_v1_integration.js
145
+ - app/views/integrations/cms/comfy_v2_integration.js
144
146
  - app/views/layouts/rails_email_preview/_flash_notices.html.erb
145
147
  - app/views/layouts/rails_email_preview/application.html.erb
146
148
  - app/views/layouts/rails_email_preview/email.html.erb
@@ -190,7 +192,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
190
192
  version: '0'
191
193
  requirements: []
192
194
  rubyforge_project:
193
- rubygems_version: 2.6.12
195
+ rubygems_version: 2.7.3
194
196
  signing_key:
195
197
  specification_version: 4
196
198
  summary: Preview emails in browser (rails engine)