jekyll-newsletter 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +16 -0
  3. data/lib/jekyll/newsletter.rb +12 -6
  4. metadata +13 -13
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cc734232e2002863e8a8694c868891049df398dd693da584bc39a06186ba43b2
4
- data.tar.gz: b23c45c69ba80a683242be81c9202c7bae7ddbea69c4ea16fa8c88e45449d795
3
+ metadata.gz: ef3265eb0c0fb1640bdc076e51e2ed8ad5fda5e8c9e021ee45fd1bc26f542471
4
+ data.tar.gz: ec57058138e12defed971cfe4b4321185ad2081bb34646169831613c9c719248
5
5
  SHA512:
6
- metadata.gz: 1d854e382af7883b83406a77cf79e4f098f0c0363b17eb126ee055c8be702232e55044d8781c79e03b0e28ef2796fc358548e23cd179e96e0f996ecf6b373f00
7
- data.tar.gz: '08b6efbcad1a32452ce4c03a833bcd37aff8101710a8b8907548e79135c7edc605362623c06df0a67de04a2a8c708997baff1dd8a896c4a5731ece08d6f7740c'
6
+ metadata.gz: f25e08ce0d21d726eb3c5cbf661f464bb60bb3808c792ab58f92560224d2feaa71dcfea739871a11885bb4ade0bb06a61f8a115d69d4f52996e3d33c18f51733
7
+ data.tar.gz: 315178839fa98e294c55bcc20a0bff685e51fdb0e0ea8be6acb01e967be16f6697db79fd5d7c1391ba9dca7e6fe5b02ae022749915ba24cb5c2b949ea8989067
data/README.md CHANGED
@@ -41,9 +41,25 @@ Environment variables:
41
41
  ```bash
42
42
  JEKYLL_NEWSLETTER_USERNAME # Defaults to From address
43
43
  JEKYLL_NEWSLETTER_PASSWORD
44
+ JEKYLL_NEWSLETTER_TO # If it's a secret address
44
45
  JEKYLL_ENV=production # Anything else will just output the email
45
46
  ```
46
47
 
48
+ The `to` option can be a single address or an array.
49
+ For `JEKYLL_NEWSLETTER_TO` to have multiple addresses, use
50
+ a comma-separated list.
51
+
52
+ ```yaml
53
+ newsletter:
54
+ to:
55
+ - some@addre.ss
56
+ - another@o.ne
57
+ ```
58
+
59
+ ```bash
60
+ JEKYLL_NEWSLETTER_TO=some@addre.ss,another@o.ne
61
+ ```
62
+
47
63
  ## Storage
48
64
 
49
65
  To keep track of which posts have already been sent, this plugin can use
@@ -25,7 +25,7 @@ module Jekyll
25
25
 
26
26
  return false unless mail.deliver
27
27
 
28
- Jekyll.logger.info "Newsletter sent"
28
+ Jekyll.logger.info 'Newsletter sent'
29
29
 
30
30
  cache[key_for_post(post)] = Time.now if production?
31
31
 
@@ -38,7 +38,7 @@ module Jekyll
38
38
  def post
39
39
  @post ||= site.to_liquid['site']['posts'].find do |post|
40
40
  !cache[key_for_post(post)]
41
- rescue
41
+ rescue StandardError
42
42
  # When the post isn't in the cache
43
43
  true
44
44
  end
@@ -48,7 +48,7 @@ module Jekyll
48
48
  @mail ||= begin
49
49
  mail = Mail.new
50
50
  mail.from = config[:from]
51
- mail.to = [config[:to]].flatten
51
+ mail.to = config[:to]
52
52
  mail.subject = post.data['title']
53
53
  mail.html_part = post.content
54
54
  # TODO: We don't have access to Markdown on post_write because
@@ -63,13 +63,19 @@ module Jekyll
63
63
  end
64
64
 
65
65
  def config
66
- @config ||= Jekyll::Utils.deep_merge_hashes(CONFIG, (site.config['newsletter'] || {}).transform_keys(&:to_sym)).tap do |config|
66
+ @config ||= Jekyll::Utils.deep_merge_hashes(CONFIG,
67
+ (site.config['newsletter'] || {}).transform_keys(&:to_sym)).tap do |config|
68
+
69
+ config[:to] = [config[:to]].flatten
70
+ config[:to].concat(ENV['JEKYLL_NEWSLETTER_TO']&.split(',')&.map(&:strip) || [])
71
+ config[:to].compact!
72
+
67
73
  %i[to from].each do |o|
68
- raise Jekyll::Errors::InvalidConfigurationError, "Missing `newsletter.#{o}` in _config.yml" if config[o].nil?
74
+ raise Jekyll::Errors::InvalidConfigurationError, "Missing `newsletter.#{o}` in _config.yml" if config[o].nil? || config[o].empty?
69
75
  end
70
76
 
71
77
  config[:delivery_method] = config[:delivery_method].to_sym
72
- config[:options].transform_keys! &:to_sym
78
+ config[:options].transform_keys!(&:to_sym)
73
79
  config[:options][:user_name] ||= config[:from].scan(/<([^>]+)>/)&.flatten&.first || config[:from]
74
80
  config[:delivery_method] = :logger unless production?
75
81
  end.freeze
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-newsletter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - f
@@ -28,44 +28,44 @@ dependencies:
28
28
  name: mail
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: '2.7'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: '2.7'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: pry
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: '0.14'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: '0.14'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rubocop
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: '1.12'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '0'
68
+ version: '1.12'
69
69
  description: Picks the latest post and sends it by email
70
70
  email:
71
71
  - f@sutty.nl