smartfocus4rails 1.0.0
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 +7 -0
- data/Gemfile +14 -0
- data/LICENSE +20 -0
- data/README.md +81 -0
- data/Rakefile +29 -0
- data/lib/generators/newsletter_generator.rb +23 -0
- data/lib/generators/smartfocus4rails/setup_generator.rb +11 -0
- data/lib/generators/smartfocus4rails/templates/smartfocus.yml +15 -0
- data/lib/generators/templates/action.html.emv +11 -0
- data/lib/generators/templates/action.text.emv +3 -0
- data/lib/generators/templates/newsletter.rb +15 -0
- data/lib/smartfocus4rails/configuration.rb +9 -0
- data/lib/smartfocus4rails/controllers/base_controller.rb +64 -0
- data/lib/smartfocus4rails/emv_handler.rb +18 -0
- data/lib/smartfocus4rails/models/base.rb +57 -0
- data/lib/smartfocus4rails/models/campaign.rb +86 -0
- data/lib/smartfocus4rails/models/message.rb +146 -0
- data/lib/smartfocus4rails/premailer.rb +19 -0
- data/lib/smartfocus4rails/railtie.rb +23 -0
- data/lib/smartfocus4rails/rendered_views.rb +29 -0
- data/lib/smartfocus4rails/version.rb +3 -0
- data/lib/smartfocus4rails.rb +29 -0
- metadata +170 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5b85d249bcf83d89c6359f6f7d299a75b757fd93
|
4
|
+
data.tar.gz: 8f6dd87bdc11173355d91265a052048e7fea4da3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 90fe7752b5448e327efda3b2446baf1058d715557a4e630e764a423c3275d93e284bace381577c5dffbc51b4b8024797819f3b23d590b8d6389585c110615ec0
|
7
|
+
data.tar.gz: bb25ac2f15328d578184128ab20af92af52043da5b9ae71f74036444f12f59074bea7eaedacd14a497ee345c0fd5784d0cc7d62a560a013d079bee96e1ee761d
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2007-2013 Bastien Gysler (www.bastiengysler.com) and eboutic.ch
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
Smartfocus ruby on rails library
|
2
|
+
=================================
|
3
|
+
|
4
|
+
Smartfocus4rails is a library used to manage messages and campaigns or more simply newsletters from your rails application.
|
5
|
+
|
6
|
+
[](http://travis-ci.org/eboutic/smartfocus4rails)
|
7
|
+
|
8
|
+
IMPORTANT
|
9
|
+
---------
|
10
|
+
|
11
|
+
This is the official forked gem from https://github.com/basgys/emailvision4rails
|
12
|
+
Bastien Gysler is the creator of this gem.
|
13
|
+
The gem was rename to reflect the rename from emvailvision to smartfocus
|
14
|
+
|
15
|
+
This version changed all Emailvision4rails class to Smartfocus4rails
|
16
|
+
|
17
|
+
Install
|
18
|
+
-------
|
19
|
+
|
20
|
+
### Without bundler
|
21
|
+
|
22
|
+
```shell
|
23
|
+
$ gem install smartfocus4rails
|
24
|
+
```
|
25
|
+
|
26
|
+
### With bundler
|
27
|
+
|
28
|
+
Past this line to your Gemfile
|
29
|
+
|
30
|
+
```ruby
|
31
|
+
gem 'smartfocus4rails'
|
32
|
+
```
|
33
|
+
|
34
|
+
Setup
|
35
|
+
-----
|
36
|
+
|
37
|
+
```shell
|
38
|
+
$ rails generate smartfocus4rails:setup
|
39
|
+
```
|
40
|
+
|
41
|
+
This will create the following config file : **config/smartfocus.yml**
|
42
|
+
|
43
|
+
Generator
|
44
|
+
---------
|
45
|
+
|
46
|
+
```shell
|
47
|
+
$ rails generate newsletter standard daily weekly
|
48
|
+
create app/newsletters/standard_newsletter.rb
|
49
|
+
create app/views/standard_newsletter/daily.html.emv
|
50
|
+
create app/views/standard_newsletter/daily.text.emv
|
51
|
+
create app/views/standard_newsletter/weekly.html.emv
|
52
|
+
create app/views/standard_newsletter/weekly.text.emv
|
53
|
+
```
|
54
|
+
|
55
|
+
Publication
|
56
|
+
|
57
|
+
```ruby
|
58
|
+
StandardNewsletter.daily.publish
|
59
|
+
```
|
60
|
+
|
61
|
+
Preview
|
62
|
+
|
63
|
+
```ruby
|
64
|
+
StandardNewsletter.daily.to_html # or to_text
|
65
|
+
```
|
66
|
+
|
67
|
+
More infos
|
68
|
+
----------
|
69
|
+
|
70
|
+
If you want to dig deeper, Go see our wiki pages.
|
71
|
+
|
72
|
+
Author
|
73
|
+
------
|
74
|
+
|
75
|
+
Funded by Bastien Gysler :: [bastiengysler.com](http://www.bastiengysler.com/) :: @basgys
|
76
|
+
Smartfocus4rails gem is maintained by eboutic.ch
|
77
|
+
|
78
|
+
License
|
79
|
+
-------
|
80
|
+
|
81
|
+
eboutic is Copyright © 2007-2013 eboutic.ch. It is free software, and may be redistributed under the terms specified in the LICENSE file.
|
data/Rakefile
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
require 'rubygems'
|
3
|
+
begin
|
4
|
+
require 'bundler/setup'
|
5
|
+
rescue LoadError
|
6
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
7
|
+
end
|
8
|
+
|
9
|
+
require 'rake'
|
10
|
+
require 'rdoc/task'
|
11
|
+
|
12
|
+
require 'rake/testtask'
|
13
|
+
|
14
|
+
Rake::TestTask.new(:test) do |t|
|
15
|
+
t.libs << 'lib'
|
16
|
+
t.libs << 'test'
|
17
|
+
t.pattern = 'test/**/*_test.rb'
|
18
|
+
t.verbose = false
|
19
|
+
end
|
20
|
+
|
21
|
+
task :default => :test
|
22
|
+
|
23
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
24
|
+
rdoc.rdoc_dir = 'rdoc'
|
25
|
+
rdoc.title = 'Smartfocus'
|
26
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
27
|
+
rdoc.rdoc_files.include('README.rdoc')
|
28
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
29
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class NewsletterGenerator < Rails::Generators::NamedBase
|
2
|
+
argument :actions, :type => :array, :default => [], :banner => "action action"
|
3
|
+
check_class_collision :suffix => "Newsletter"
|
4
|
+
source_root File.expand_path("../templates", __FILE__)
|
5
|
+
|
6
|
+
def create_newsletter_file
|
7
|
+
template 'newsletter.rb', File.join('app/newsletters', class_path, "#{file_name}_newsletter.rb")
|
8
|
+
end
|
9
|
+
|
10
|
+
def create_view_files
|
11
|
+
actions.each do |action|
|
12
|
+
available_formats.each do |format|
|
13
|
+
template "action.#{format}.emv", File.join('app/views', class_path, "#{file_name}_newsletter", "#{action}.#{format}.emv")
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
protected
|
19
|
+
|
20
|
+
def available_formats
|
21
|
+
%w(html text)
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<% module_namespacing do -%>
|
2
|
+
class <%= class_name %>Newsletter < Smartfocus4rails::AbstractNewsletter
|
3
|
+
<% actions.each do |action| -%>
|
4
|
+
|
5
|
+
def <%= action %>
|
6
|
+
@greeting = "Hi"
|
7
|
+
|
8
|
+
newsletter(
|
9
|
+
:message => {:name => "<%= action %>"},
|
10
|
+
:campaign => {:send_date => Time.now+10.minutes, :mailinglist_id => 123}
|
11
|
+
)
|
12
|
+
end
|
13
|
+
<% end -%>
|
14
|
+
end
|
15
|
+
<% end -%>
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'abstract_controller'
|
2
|
+
require 'action_view'
|
3
|
+
require 'action_mailer/collector'
|
4
|
+
|
5
|
+
module Smartfocus4rails
|
6
|
+
class BaseController < ::AbstractController::Base
|
7
|
+
abstract!
|
8
|
+
|
9
|
+
include AbstractController::Logger
|
10
|
+
include AbstractController::Rendering
|
11
|
+
include AbstractController::Layouts
|
12
|
+
|
13
|
+
append_view_path "#{Rails.root}/app/views"
|
14
|
+
|
15
|
+
private_class_method :new
|
16
|
+
|
17
|
+
class << self
|
18
|
+
def respond_to?(method, include_private = false)
|
19
|
+
super || action_methods.include?(method.to_s)
|
20
|
+
end
|
21
|
+
|
22
|
+
protected
|
23
|
+
|
24
|
+
def method_missing(method, *args)
|
25
|
+
return super unless respond_to?(method)
|
26
|
+
instance = new(method, *args)
|
27
|
+
instance.render_views
|
28
|
+
instance.rendered_views
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
attr_internal :rendered_views
|
33
|
+
|
34
|
+
def initialize(method_name=nil, *args)
|
35
|
+
super()
|
36
|
+
lookup_context.formats = [:text, :html] # Restrict rendering formats to html and text
|
37
|
+
process(method_name, *args) if method_name
|
38
|
+
end
|
39
|
+
|
40
|
+
def process(method_name, *args)
|
41
|
+
lookup_context.skip_default_locale!
|
42
|
+
super(method_name, *args)
|
43
|
+
end
|
44
|
+
|
45
|
+
def render_views
|
46
|
+
self.rendered_views = ::Smartfocus4rails::RenderedViews.new(collect_responses(lookup_context.formats))
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
def collect_responses(formats)
|
52
|
+
collector = ActionMailer::Collector.new(lookup_context) do
|
53
|
+
render(action_name)
|
54
|
+
end
|
55
|
+
responses = {}
|
56
|
+
formats.each do |f|
|
57
|
+
collector.send(f)
|
58
|
+
responses[f] = collector.responses.last[:body]
|
59
|
+
end
|
60
|
+
responses
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'action_view/template'
|
2
|
+
|
3
|
+
module Smartfocus4rails
|
4
|
+
module EmvHandler
|
5
|
+
def self.erb_handler
|
6
|
+
@@erb_handler ||= ActionView::Template.registered_template_handler(:erb)
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.call(template)
|
10
|
+
compiled_source = erb_handler.call(template)
|
11
|
+
if template.formats.include?(:html)
|
12
|
+
"Smartfocus4rails::Premailer.new((begin;#{compiled_source};end)).to_inline_css"
|
13
|
+
else
|
14
|
+
compiled_source
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'active_model/conversion'
|
2
|
+
require 'active_model/attribute_methods'
|
3
|
+
require 'active_model/naming'
|
4
|
+
require 'active_model/translation'
|
5
|
+
require 'active_model/validator'
|
6
|
+
require 'active_model/validations'
|
7
|
+
require 'active_model/callbacks'
|
8
|
+
|
9
|
+
class Smartfocus4rails::Base
|
10
|
+
include ActiveModel::Conversion
|
11
|
+
include ActiveModel::AttributeMethods
|
12
|
+
include ActiveModel::Validations
|
13
|
+
|
14
|
+
extend ActiveModel::Callbacks
|
15
|
+
extend ActiveModel::Naming
|
16
|
+
|
17
|
+
class_attribute :_attributes
|
18
|
+
self._attributes = []
|
19
|
+
|
20
|
+
attribute_method_suffix '?'
|
21
|
+
|
22
|
+
define_model_callbacks :create, :update, :destroy
|
23
|
+
|
24
|
+
def self.attributes(*names)
|
25
|
+
attr_accessor *names
|
26
|
+
define_attribute_methods names
|
27
|
+
|
28
|
+
self._attributes += names
|
29
|
+
end
|
30
|
+
|
31
|
+
def attributes
|
32
|
+
self._attributes.inject({}) do |hash, attr|
|
33
|
+
hash[attr.to_s] = send(attr)
|
34
|
+
hash
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def persisted?
|
39
|
+
false
|
40
|
+
end
|
41
|
+
|
42
|
+
def to_emv
|
43
|
+
attributes.reject {|k,v| v.nil?}
|
44
|
+
end
|
45
|
+
|
46
|
+
protected
|
47
|
+
|
48
|
+
def api
|
49
|
+
@api ||= Smartfocus::Api.new :endpoint => "apiccmd"
|
50
|
+
@api.open_connection unless @api.connected?
|
51
|
+
@api
|
52
|
+
end
|
53
|
+
|
54
|
+
def attribute?(attribute)
|
55
|
+
send(attribute).present?
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
class Smartfocus4rails::Campaign < Smartfocus4rails::Base
|
2
|
+
|
3
|
+
attributes(
|
4
|
+
:id,
|
5
|
+
:name,
|
6
|
+
:mailinglist_id,
|
7
|
+
:message_id,
|
8
|
+
:send_date,
|
9
|
+
:description,
|
10
|
+
:emaildedupflg,
|
11
|
+
:format,
|
12
|
+
:delivery_speed,
|
13
|
+
:notification,
|
14
|
+
:post_click_tracking,
|
15
|
+
:strategy,
|
16
|
+
:target,
|
17
|
+
:url_end_campaign,
|
18
|
+
:url_host,
|
19
|
+
:analytics
|
20
|
+
)
|
21
|
+
|
22
|
+
validates_presence_of(
|
23
|
+
:name,
|
24
|
+
:mailinglist_id,
|
25
|
+
:message_id,
|
26
|
+
:send_date
|
27
|
+
)
|
28
|
+
|
29
|
+
validates_numericality_of(
|
30
|
+
:mailinglist_id,
|
31
|
+
:message_id
|
32
|
+
)
|
33
|
+
|
34
|
+
validate do
|
35
|
+
if send_date.blank? or (send_date < Time.now+5.minutes)
|
36
|
+
errors.add(:send_date, "must be more than 5 minutes in the future")
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def initialize(payload = {})
|
41
|
+
payload.each do |attr, val|
|
42
|
+
send("#{attr}=", val) if attributes.has_key?(attr.to_s)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def post
|
47
|
+
api.get.campaign.post(uri: [id]).call
|
48
|
+
end
|
49
|
+
|
50
|
+
def unpost
|
51
|
+
api.get.campaign.unpost(uri: [id]).call
|
52
|
+
end
|
53
|
+
|
54
|
+
def create
|
55
|
+
if valid?
|
56
|
+
run_callbacks :create do
|
57
|
+
self.id = api.post.campaign.create(:body => {:campaign => self.to_emv}).call
|
58
|
+
end
|
59
|
+
true
|
60
|
+
else
|
61
|
+
false
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def update
|
66
|
+
if valid? and persisted?
|
67
|
+
run_callbacks :update do
|
68
|
+
self.id = api.post.campaign.update(:body => {:campaign => self.to_emv}).call
|
69
|
+
end
|
70
|
+
true
|
71
|
+
else
|
72
|
+
false
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def destroy
|
77
|
+
run_callbacks :destroy do
|
78
|
+
self.id = api.get.campaign.delete(:uri => [self.id]).call
|
79
|
+
end
|
80
|
+
true
|
81
|
+
end
|
82
|
+
|
83
|
+
def persisted?
|
84
|
+
id.present?
|
85
|
+
end
|
86
|
+
end
|
@@ -0,0 +1,146 @@
|
|
1
|
+
class Smartfocus4rails::Message < Smartfocus4rails::Base
|
2
|
+
|
3
|
+
attributes(
|
4
|
+
:name,
|
5
|
+
:subject,
|
6
|
+
:from,
|
7
|
+
:from_email,
|
8
|
+
:body,
|
9
|
+
:reply_to,
|
10
|
+
:reply_to_email,
|
11
|
+
:id,
|
12
|
+
:create_date,
|
13
|
+
:to,
|
14
|
+
:description,
|
15
|
+
:encoding,
|
16
|
+
:hotmail_unsub_url,
|
17
|
+
:type,
|
18
|
+
:hotmail_unsub_flg,
|
19
|
+
:is_bounceback
|
20
|
+
)
|
21
|
+
|
22
|
+
validates_presence_of(
|
23
|
+
:name,
|
24
|
+
:subject,
|
25
|
+
:from,
|
26
|
+
:from_email,
|
27
|
+
:body,
|
28
|
+
:reply_to,
|
29
|
+
:reply_to_email
|
30
|
+
)
|
31
|
+
|
32
|
+
# See emv official doc
|
33
|
+
LANG_MAPPER = {
|
34
|
+
en: 1,
|
35
|
+
en_us: 1,
|
36
|
+
en_uk: 2,
|
37
|
+
fr: 3,
|
38
|
+
de: 4
|
39
|
+
}.freeze
|
40
|
+
|
41
|
+
LINK_TYPE_MAPPER = {
|
42
|
+
link: true,
|
43
|
+
button: false
|
44
|
+
}.freeze
|
45
|
+
|
46
|
+
# Validate format of email address
|
47
|
+
|
48
|
+
def initialize(body = "", payload = {})
|
49
|
+
self.body = body
|
50
|
+
payload.each do |attr, val|
|
51
|
+
send("#{attr}=", val) if attributes.has_key?(attr.to_s)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def create
|
56
|
+
if valid?
|
57
|
+
run_callbacks :create do
|
58
|
+
self.id = api.post.message.create(:body => {:message => self.to_emv}).call
|
59
|
+
end
|
60
|
+
true
|
61
|
+
else
|
62
|
+
false
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def update
|
67
|
+
if valid? and persisted?
|
68
|
+
run_callbacks :update do
|
69
|
+
api.post.message.update(:body => {:message => self.to_emv}).call
|
70
|
+
end
|
71
|
+
else
|
72
|
+
false
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def destroy
|
77
|
+
run_callbacks :destroy do
|
78
|
+
self.id = api.get.message.deleteMessage(:uri => [self.id]).call
|
79
|
+
end
|
80
|
+
true
|
81
|
+
end
|
82
|
+
|
83
|
+
# Deprecated
|
84
|
+
def mirror_url_id
|
85
|
+
warn "[DEPRECATION] mirror_url_id is deprecated. Use create_and_add_mirror_url instead"
|
86
|
+
@mirror_url_id ||= create_and_add_mirror_url
|
87
|
+
end
|
88
|
+
|
89
|
+
# Replaces the first occurrence of &&& with
|
90
|
+
# [EMV LINK]ORDER[EMV /LINK] (where ORDER is the mirror link order number).
|
91
|
+
def create_and_add_mirror_url
|
92
|
+
api.get.url.create_and_add_mirror_url(uri: [id, 'mirror_url']).call
|
93
|
+
end
|
94
|
+
|
95
|
+
# Replaces the first occurrence of &&& with
|
96
|
+
# [EMV LINK]ORDER[EMV /LINK] (where ORDER is the action link order number).
|
97
|
+
# Parameters :
|
98
|
+
# - name : The name of the URL
|
99
|
+
# - action : The action to perform
|
100
|
+
def create_and_add_action_url(name, action)
|
101
|
+
api.get.url.create_and_add_action_url(uri: [id, name, action, 'a', 1, 'b', 2]).call # Last 4 params hardcoded because of an API bug
|
102
|
+
end
|
103
|
+
|
104
|
+
|
105
|
+
# Replaces the first occurrence of &&& with [EMV SHARE lang=xx]
|
106
|
+
# Parameters :
|
107
|
+
# - type : :link, :button
|
108
|
+
# - lang : :en, :fr, :de (optionnal)
|
109
|
+
# - url : The url of the share link
|
110
|
+
def create_and_add_share_link(type, lang, url)
|
111
|
+
type = LINK_TYPE_MAPPER[type.to_sym]
|
112
|
+
lang = LANG_MAPPER[lang.to_sym]
|
113
|
+
api.get.add_share_link(uri: [id, type, url,lang]).call
|
114
|
+
end
|
115
|
+
|
116
|
+
# This method retrieves the unused tracked links
|
117
|
+
# It returns an array of link ids
|
118
|
+
def unused_tracked_links
|
119
|
+
result = api.get.message.get_all_unused_tracked_links(uri: [id]).call
|
120
|
+
|
121
|
+
result["entities"]["id"]
|
122
|
+
rescue NoMethodError
|
123
|
+
[]
|
124
|
+
end
|
125
|
+
|
126
|
+
# This method deletes a URL.
|
127
|
+
# You can only delete a message's URL, if the message is not associated to a campaign.
|
128
|
+
# Parameter :
|
129
|
+
# - link_id : The ID of the link to delete
|
130
|
+
def delete_link(link_id)
|
131
|
+
api.get.url.delete_url(uri: [id, link_id]).call
|
132
|
+
end
|
133
|
+
|
134
|
+
def track_links
|
135
|
+
api.get.message.track_all_links(id: id).call
|
136
|
+
end
|
137
|
+
|
138
|
+
def untrack_links
|
139
|
+
api.get.message.untrack_all_links(id: id).call
|
140
|
+
end
|
141
|
+
|
142
|
+
def persisted?
|
143
|
+
id.present?
|
144
|
+
end
|
145
|
+
|
146
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Smartfocus4rails
|
2
|
+
class Premailer < ::Premailer
|
3
|
+
def initialize(html)
|
4
|
+
::Premailer.send(:include, Adapter.find(Adapter.use))
|
5
|
+
|
6
|
+
encoding = Configuration.encoding.try(:upcase)
|
7
|
+
options = {
|
8
|
+
:adapter => :hpricot,
|
9
|
+
:warn_level => Premailer::Warnings::SAFE,
|
10
|
+
:with_html_string => true,
|
11
|
+
:encoding => encoding,
|
12
|
+
:input_encoding => encoding,
|
13
|
+
:inputencoding => encoding
|
14
|
+
}
|
15
|
+
|
16
|
+
super(html, options)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'rails'
|
2
|
+
|
3
|
+
module Smartfocus4rails
|
4
|
+
class Railtie < Rails::Railtie
|
5
|
+
|
6
|
+
config.to_prepare do
|
7
|
+
file = "#{Rails.root}/config/smartfocus.yml"
|
8
|
+
|
9
|
+
if File.exist?(file)
|
10
|
+
config = YAML.load_file(file)[Rails.env] || {}
|
11
|
+
|
12
|
+
Configuration.server_name = config['server_name']
|
13
|
+
Configuration.endpoint = config['endpoint']
|
14
|
+
Configuration.login = config['login']
|
15
|
+
Configuration.password = config['password']
|
16
|
+
Configuration.key = config['key']
|
17
|
+
Configuration.debug = config['debug']
|
18
|
+
Configuration.encoding = Rails.configuration.encoding || 'utf-8'
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Smartfocus4rails
|
2
|
+
class RenderedViews
|
3
|
+
|
4
|
+
attr_accessor :parts
|
5
|
+
|
6
|
+
def initialize(parts = {})
|
7
|
+
@parts = parts
|
8
|
+
end
|
9
|
+
|
10
|
+
def content
|
11
|
+
parts.map do |format, content|
|
12
|
+
"[EMV #{format.upcase}PART]\n#{content}"
|
13
|
+
end.join("\n")
|
14
|
+
end
|
15
|
+
|
16
|
+
def to_html
|
17
|
+
parts[:html]
|
18
|
+
end
|
19
|
+
|
20
|
+
def to_text
|
21
|
+
parts[:text]
|
22
|
+
end
|
23
|
+
|
24
|
+
def to_s
|
25
|
+
content
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'rails'
|
2
|
+
require 'action_view'
|
3
|
+
require 'premailer'
|
4
|
+
require 'smartfocus'
|
5
|
+
|
6
|
+
module Smartfocus4rails
|
7
|
+
# Base
|
8
|
+
autoload :EmvHandler, 'smartfocus4rails/emv_handler'
|
9
|
+
autoload :Collector, 'smartfocus4rails/collector'
|
10
|
+
autoload :Newsletter, 'smartfocus4rails/newsletter'
|
11
|
+
autoload :Configuration, 'smartfocus4rails/configuration'
|
12
|
+
autoload :Premailer, 'smartfocus4rails/premailer'
|
13
|
+
autoload :RenderedViews, 'smartfocus4rails/rendered_views'
|
14
|
+
autoload :Version, 'smartfocus4rails/version'
|
15
|
+
|
16
|
+
# Models
|
17
|
+
autoload :Base, 'smartfocus4rails/models/base'
|
18
|
+
autoload :Message, 'smartfocus4rails/models/message'
|
19
|
+
autoload :Campaign, 'smartfocus4rails/models/campaign'
|
20
|
+
|
21
|
+
# Controllers
|
22
|
+
autoload :BaseController, 'smartfocus4rails/controllers/base_controller'
|
23
|
+
|
24
|
+
ActionView::Template.register_template_handler :emv, EmvHandler
|
25
|
+
|
26
|
+
if defined?(Rails)
|
27
|
+
require 'smartfocus4rails/railtie'
|
28
|
+
end
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,170 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: smartfocus4rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Bastien Gysler
|
8
|
+
- eboutic.ch
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-11-14 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: smartfocus
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - '>='
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '0'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - '>='
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '0'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: premailer
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ~>
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 1.7.0
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ~>
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: 1.7.0
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: hpricot
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ~>
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: 0.8.0
|
49
|
+
type: :runtime
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ~>
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: 0.8.0
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: actionpack
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - '>='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '3.2'
|
63
|
+
- - <=
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '4.0'
|
66
|
+
type: :runtime
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - '>='
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '3.2'
|
73
|
+
- - <=
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '4.0'
|
76
|
+
- !ruby/object:Gem::Dependency
|
77
|
+
name: activemodel
|
78
|
+
requirement: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3.2'
|
83
|
+
- - <=
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '4.0'
|
86
|
+
type: :runtime
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - '>='
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '3.2'
|
93
|
+
- - <=
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '4.0'
|
96
|
+
- !ruby/object:Gem::Dependency
|
97
|
+
name: railties
|
98
|
+
requirement: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - '>='
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '3.2'
|
103
|
+
- - <=
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '4.0'
|
106
|
+
type: :runtime
|
107
|
+
prerelease: false
|
108
|
+
version_requirements: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - '>='
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: '3.2'
|
113
|
+
- - <=
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '4.0'
|
116
|
+
description: Manage Smartfocus campaigns and messages from your rails application
|
117
|
+
email:
|
118
|
+
- basgys@gmail.com
|
119
|
+
- tech@eboutic.ch
|
120
|
+
executables: []
|
121
|
+
extensions: []
|
122
|
+
extra_rdoc_files: []
|
123
|
+
files:
|
124
|
+
- lib/generators/newsletter_generator.rb
|
125
|
+
- lib/generators/smartfocus4rails/setup_generator.rb
|
126
|
+
- lib/generators/smartfocus4rails/templates/smartfocus.yml
|
127
|
+
- lib/generators/templates/action.html.emv
|
128
|
+
- lib/generators/templates/action.text.emv
|
129
|
+
- lib/generators/templates/newsletter.rb
|
130
|
+
- lib/smartfocus4rails/configuration.rb
|
131
|
+
- lib/smartfocus4rails/controllers/base_controller.rb
|
132
|
+
- lib/smartfocus4rails/emv_handler.rb
|
133
|
+
- lib/smartfocus4rails/models/base.rb
|
134
|
+
- lib/smartfocus4rails/models/campaign.rb
|
135
|
+
- lib/smartfocus4rails/models/message.rb
|
136
|
+
- lib/smartfocus4rails/premailer.rb
|
137
|
+
- lib/smartfocus4rails/railtie.rb
|
138
|
+
- lib/smartfocus4rails/rendered_views.rb
|
139
|
+
- lib/smartfocus4rails/version.rb
|
140
|
+
- lib/smartfocus4rails.rb
|
141
|
+
- LICENSE
|
142
|
+
- Rakefile
|
143
|
+
- Gemfile
|
144
|
+
- README.md
|
145
|
+
homepage: https://github.com/eboutic/smartfocus4rails
|
146
|
+
licenses:
|
147
|
+
- MIT
|
148
|
+
metadata: {}
|
149
|
+
post_install_message:
|
150
|
+
rdoc_options: []
|
151
|
+
require_paths:
|
152
|
+
- lib
|
153
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
154
|
+
requirements:
|
155
|
+
- - '>='
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: '0'
|
158
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
159
|
+
requirements:
|
160
|
+
- - '>='
|
161
|
+
- !ruby/object:Gem::Version
|
162
|
+
version: '0'
|
163
|
+
requirements: []
|
164
|
+
rubyforge_project:
|
165
|
+
rubygems_version: 2.1.9
|
166
|
+
signing_key:
|
167
|
+
specification_version: 4
|
168
|
+
summary: Smartfocus (ex Emailvision) library for Ruby on Rails
|
169
|
+
test_files: []
|
170
|
+
has_rdoc:
|