middleman-newsletter 0.0.2 → 0.0.4
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 +4 -4
- data/lib/middleman-newsletter/extension.rb +11 -4
- data/lib/middleman-newsletter/newsletter.rb +5 -0
- data/middleman-newsletter.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b2cec0f02f8412f5b919fbd7b27902ad28d94d102eb098aaa311152a295a3654
|
4
|
+
data.tar.gz: 874cb8afa280169aa555b6a4032ac722a85b1256ead4da34a4ea9ef7b76e324b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0b68fd205815855a3ea71a03c14d4eab49813cd68a2505f2fd3e25737225a8bb3aa494298c89369acf82df7e19f44882ae4fb0eb825c62cb22b60ce4baef720c
|
7
|
+
data.tar.gz: 53c8b682e4096081a0c887e35e9ebee642586d82f4d05f14fb2f43374faaeffc78d1f859f3018a9e864b0e8edf20e3ebf3ea4da30db39b73c3b17079ee186feb
|
@@ -15,6 +15,9 @@ module Middleman
|
|
15
15
|
option :layout, 'layout', 'Newsletter specific layout'
|
16
16
|
option :sendgrid_api_key, nil, 'API Key for SendGrid -- must have marketing access.'
|
17
17
|
option :sendgrid_category, 'newsletters', 'Category assigned to all managed single sends in SendGrid.'
|
18
|
+
option :subject_line, proc { |newsletter| newsletter.source_resource.title }, 'A proc that takes the newsletter resource and returns the subject line for the email. Defaults to the source blog post title.'
|
19
|
+
option :preview_text, proc { |newsletter| newsletter.source_resource.data.description }, 'A proc that takes the newsletter resource and returns preview text for the email. Defaults to the source blog post description.'
|
20
|
+
option :content_modifier, proc { |_newsletter, content| content }, 'A proc that takes the newsletter resource and rendered HTML for the newsletter and can return modified content.'
|
18
21
|
|
19
22
|
def initialize(app, options_hash={}, &block)
|
20
23
|
# Call super to build options from the options_hash
|
@@ -83,6 +86,10 @@ module Middleman
|
|
83
86
|
|
84
87
|
private
|
85
88
|
|
89
|
+
def render_newsletter(newsletter)
|
90
|
+
newsletter.render({}, {})
|
91
|
+
end
|
92
|
+
|
86
93
|
def sendgrid_client
|
87
94
|
@sendgrid_client ||= SendGrid::API.new(api_key: options.sendgrid_api_key).client
|
88
95
|
end
|
@@ -96,8 +103,8 @@ module Middleman
|
|
96
103
|
name: name,
|
97
104
|
categories: [options.sendgrid_category],
|
98
105
|
email_config: {
|
99
|
-
subject:
|
100
|
-
html_content: newsletter
|
106
|
+
subject: options.subject_line.call(newsletter),
|
107
|
+
html_content: render_newsletter(newsletter)
|
101
108
|
}
|
102
109
|
}
|
103
110
|
)
|
@@ -110,8 +117,8 @@ module Middleman
|
|
110
117
|
sendgrid_client.marketing.singlesends._(singlesend_id).patch(
|
111
118
|
request_body: {
|
112
119
|
email_config: {
|
113
|
-
subject:
|
114
|
-
html_content: newsletter
|
120
|
+
subject: options.subject_line.call(newsletter),
|
121
|
+
html_content: render_newsletter(newsletter)
|
115
122
|
}
|
116
123
|
}
|
117
124
|
)
|
@@ -18,7 +18,12 @@ module Middleman
|
|
18
18
|
opts[:layout] = opts[:layout].to_s if opts[:layout].is_a? Symbol
|
19
19
|
end
|
20
20
|
|
21
|
+
unless locs.key?(:preview_text)
|
22
|
+
locs[:preview_text] = newsletter_options.preview_text.call(self)
|
23
|
+
end
|
24
|
+
|
21
25
|
content = with_email_renderer { super(opts, locs, &block) }
|
26
|
+
content = newsletter_options.content_modifier.call(self, content)
|
22
27
|
|
23
28
|
Premailer.new(content, with_html_string: true, output_encoding: 'UTF-8', input_encoding: 'UTF-8').to_inline_css
|
24
29
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: middleman-newsletter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Scarborough
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-03-
|
11
|
+
date: 2024-03-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: middleman-core
|