email_campaign 0.1.4 → 0.1.5
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.
- data/app/assets/images/email_campaign/open-tracker.gif +0 -0
- data/app/helpers/email_campaign/email_helper.rb +13 -5
- data/app/models/email_campaign/campaign.rb +10 -3
- data/app/models/email_campaign/recipient.rb +7 -2
- data/lib/email_campaign/engine.rb +10 -3
- data/lib/email_campaign/version.rb +1 -1
- metadata +3 -2
Binary file
|
@@ -1,20 +1,28 @@
|
|
1
1
|
module EmailCampaign
|
2
2
|
module EmailHelper
|
3
3
|
|
4
|
-
def
|
5
|
-
|
4
|
+
def email_tracking_tag
|
5
|
+
if @identifier
|
6
|
+
image_tag(EmailCampaign::Config.base_url + url_for(:controller => 'email', :action => 'open', :method => @method, :k => @identifier), :size => '1x1', :alt => '')
|
7
|
+
else
|
8
|
+
image_tag(EmailCampaign::Config.base_url + path_to_image('email_campaign/open-tracker.gif'), :size => '1x1', :alt => '')
|
9
|
+
end
|
6
10
|
end
|
7
11
|
|
8
12
|
def email_link_url(url)
|
9
|
-
|
13
|
+
if @identifier
|
14
|
+
EmailCampaign::Config.base_url + url_for(:controller => 'email', :action => 'link', :url => url, :k => @identifier)
|
15
|
+
else
|
16
|
+
url
|
17
|
+
end
|
10
18
|
end
|
11
19
|
|
12
20
|
def email_unsubscribe_url
|
13
|
-
|
21
|
+
EmailCampaign::Config.base_url + url_for(:controller => 'email', :action => 'unsubscribe', :k => @identifier)
|
14
22
|
end
|
15
23
|
|
16
24
|
def email_web_version_url
|
17
|
-
|
25
|
+
EmailCampaign::Config.base_url + url_for(:controller => 'email', :action => 'web_version', :method => @method, :k => @identifier)
|
18
26
|
end
|
19
27
|
|
20
28
|
end
|
@@ -9,7 +9,8 @@ class EmailCampaign::Campaign < ActiveRecord::Base
|
|
9
9
|
|
10
10
|
# new_recipients should be an Array of objects that respond to #email, #name, and #subscriber_id
|
11
11
|
# (falls back to #id if #subscriber_id doesn't exist; either way, id should be unique within campaign)
|
12
|
-
def add_recipients(new_recipients)
|
12
|
+
def add_recipients(new_recipients, options = {})
|
13
|
+
options.stringify_keys!
|
13
14
|
new_recipients = [ new_recipients ] unless new_recipients.is_a?(Array)
|
14
15
|
|
15
16
|
processed = 0
|
@@ -22,8 +23,14 @@ class EmailCampaign::Campaign < ActiveRecord::Base
|
|
22
23
|
new_recipients.each do |rcpt|
|
23
24
|
subscriber_id = rcpt.respond_to?(:subscriber_id) ? rcpt.subscriber_id : rcpt.id
|
24
25
|
|
25
|
-
if subscriber_id && recipients.
|
26
|
-
|
26
|
+
if subscriber_id && r = recipients.find_by_subscriber_id(subscriber_id)
|
27
|
+
if options['force']
|
28
|
+
r.requeue
|
29
|
+
valid += 1
|
30
|
+
else
|
31
|
+
skipped += 1
|
32
|
+
end
|
33
|
+
|
27
34
|
next
|
28
35
|
end
|
29
36
|
|
@@ -14,6 +14,10 @@ class EmailCampaign::Recipient < ActiveRecord::Base
|
|
14
14
|
before_create :generate_identifier, :check_for_duplicates, :check_for_unsubscribe
|
15
15
|
before_save :check_name, :check_email_address
|
16
16
|
|
17
|
+
def self.per_page
|
18
|
+
100
|
19
|
+
end
|
20
|
+
|
17
21
|
def generate_identifier(regenerate = false)
|
18
22
|
return identifier if identifier && !regenerate
|
19
23
|
|
@@ -83,8 +87,9 @@ class EmailCampaign::Recipient < ActiveRecord::Base
|
|
83
87
|
|
84
88
|
# resets failed and delivered flags... use sparingly
|
85
89
|
def requeue
|
86
|
-
|
87
|
-
|
90
|
+
update_attributes(:failed => false, :failed_at => nil, :failure_reason => nil,
|
91
|
+
:delivered => false, :delivered_at => nil)
|
92
|
+
queue
|
88
93
|
end
|
89
94
|
|
90
95
|
def deliver
|
@@ -6,13 +6,20 @@ module EmailCampaign
|
|
6
6
|
config.app_root = root
|
7
7
|
middleware.use ::ActionDispatch::Static, "#{root}/public"
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
initializer "email_campaign.assets.precompile" do |config|
|
10
|
+
Rails.application.config.assets.precompile += %w( email_campaign/open-tracker.gif )
|
11
|
+
end
|
12
12
|
|
13
13
|
#
|
14
14
|
# activate gems as needed
|
15
15
|
#
|
16
16
|
|
17
17
|
end
|
18
|
+
|
19
|
+
class Config
|
20
|
+
class << self
|
21
|
+
attr_accessor :base_url
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
18
25
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: email_campaign
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-03-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: actionmailer
|
@@ -104,6 +104,7 @@ files:
|
|
104
104
|
- README.rdoc
|
105
105
|
- Rakefile
|
106
106
|
- app/assets/images/.gitkeep
|
107
|
+
- app/assets/images/email_campaign/open-tracker.gif
|
107
108
|
- app/assets/javascripts/application.js
|
108
109
|
- app/assets/stylesheets/application.css
|
109
110
|
- app/controllers/email_campaigns_controller.rb
|