alchemy_crm 2.0.1 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +10 -11
- data/alchemy_crm.gemspec +21 -21
- data/app/assets/javascripts/alchemy_crm/alchemy_crm.base.js +54 -54
- data/app/assets/stylesheets/alchemy_crm/base.css.scss +199 -199
- data/app/controllers/alchemy_crm/admin/base_controller.rb +5 -5
- data/app/controllers/alchemy_crm/admin/contact_groups_controller.rb +15 -15
- data/app/controllers/alchemy_crm/admin/contacts_controller.rb +95 -95
- data/app/controllers/alchemy_crm/admin/deliveries_controller.rb +66 -66
- data/app/controllers/alchemy_crm/admin/elements_controller_extension.rb +23 -23
- data/app/controllers/alchemy_crm/admin/mailings_controller.rb +44 -44
- data/app/controllers/alchemy_crm/admin/newsletters_controller.rb +16 -16
- data/app/controllers/alchemy_crm/admin/tags_controller.rb +60 -59
- data/app/controllers/alchemy_crm/base_controller.rb +3 -3
- data/app/controllers/alchemy_crm/contacts_controller.rb +88 -88
- data/app/controllers/alchemy_crm/mailings_controller.rb +16 -16
- data/app/controllers/alchemy_crm/recipients_controller.rb +30 -30
- data/app/controllers/alchemy_crm/subscriptions_controller.rb +54 -54
- data/app/helpers/alchemy/pages_helper_extension.rb +14 -14
- data/app/helpers/alchemy_crm/admin/base_helper.rb +8 -8
- data/app/helpers/alchemy_crm/mailings_helper.rb +175 -175
- data/app/mailers/alchemy_crm/bounce_receiver.rb +9 -9
- data/app/mailers/alchemy_crm/contacts_mailer.rb +21 -21
- data/app/mailers/alchemy_crm/mailings_mailer.rb +46 -46
- data/app/mailers/alchemy_crm/subscriptions_mailer.rb +12 -12
- data/app/models/alchemy/essence_element_teaser.rb +14 -14
- data/app/models/alchemy_crm/contact.rb +260 -260
- data/app/models/alchemy_crm/contact_group.rb +15 -15
- data/app/models/alchemy_crm/contact_group_filter.rb +17 -17
- data/app/models/alchemy_crm/delivery.rb +54 -54
- data/app/models/alchemy_crm/element_extension.rb +23 -23
- data/app/models/alchemy_crm/mailing.rb +90 -90
- data/app/models/alchemy_crm/newsletter.rb +33 -33
- data/app/models/alchemy_crm/reaction.rb +5 -5
- data/app/models/alchemy_crm/recipient.rb +46 -46
- data/app/models/alchemy_crm/subscription.rb +4 -4
- data/app/views/alchemy/admin/elements/fill.js.erb +11 -11
- data/app/views/alchemy/elements/_newsletter_article_view.html.erb +14 -14
- data/app/views/alchemy/elements/_newsletter_greeting_view.html.erb +9 -9
- data/app/views/alchemy/elements/_newsletter_signout_form_view.html.erb +18 -18
- data/app/views/alchemy/elements/_newsletter_signup_form_view.html.erb +62 -62
- data/app/views/alchemy/essences/_essence_element_teaser_editor.html.erb +29 -29
- data/app/views/alchemy/newsletter_layouts/_standard.html.erb +37 -37
- data/app/views/alchemy_crm/admin/contact_groups/_contact_group.html.erb +30 -30
- data/app/views/alchemy_crm/admin/contact_groups/_filter.html.erb +28 -28
- data/app/views/alchemy_crm/admin/contact_groups/_form.html.erb +45 -45
- data/app/views/alchemy_crm/admin/contact_groups/_tag.html.erb +4 -4
- data/app/views/alchemy_crm/admin/contact_groups/add_filter.js.erb +7 -7
- data/app/views/alchemy_crm/admin/contact_groups/index.html.erb +28 -28
- data/app/views/alchemy_crm/admin/contacts/_contact.html.erb +42 -42
- data/app/views/alchemy_crm/admin/contacts/_form.html.erb +76 -76
- data/app/views/alchemy_crm/admin/contacts/import.html.erb +27 -27
- data/app/views/alchemy_crm/admin/contacts/index.html.erb +39 -39
- data/app/views/alchemy_crm/admin/contacts/vcf_import_result.html.erb +24 -24
- data/app/views/alchemy_crm/admin/deliveries/_delivery.html.erb +30 -30
- data/app/views/alchemy_crm/admin/deliveries/_form.html.erb +61 -61
- data/app/views/alchemy_crm/admin/deliveries/_recipient.html.erb +36 -36
- data/app/views/alchemy_crm/admin/deliveries/index.html.erb +21 -21
- data/app/views/alchemy_crm/admin/deliveries/show.html.erb +61 -61
- data/app/views/alchemy_crm/admin/elements/teasables.html.erb +53 -53
- data/app/views/alchemy_crm/admin/mailings/_form.html.erb +41 -41
- data/app/views/alchemy_crm/admin/mailings/_mailing.html.erb +73 -73
- data/app/views/alchemy_crm/admin/mailings/edit_content.html.erb +170 -170
- data/app/views/alchemy_crm/admin/mailings/import_result.html.erb +18 -18
- data/app/views/alchemy_crm/admin/mailings/index.html.erb +25 -25
- data/app/views/alchemy_crm/admin/newsletters/_form.html.erb +52 -52
- data/app/views/alchemy_crm/admin/newsletters/_tag_with_radiobutton.html.erb +5 -5
- data/app/views/alchemy_crm/admin/newsletters/index.html.erb +29 -29
- data/app/views/alchemy_crm/admin/newsletters/new.html.erb +4 -4
- data/app/views/alchemy_crm/admin/tags/_radio_tag.html.erb +4 -4
- data/app/views/alchemy_crm/admin/tags/_tag.html.erb +30 -30
- data/app/views/alchemy_crm/admin/tags/edit.html.erb +32 -32
- data/app/views/alchemy_crm/admin/tags/index.html.erb +23 -23
- data/app/views/alchemy_crm/admin/tags/new.html.erb +14 -14
- data/app/views/alchemy_crm/contacts_mailer/signout_mail.html.erb +6 -6
- data/app/views/alchemy_crm/contacts_mailer/signout_mail.text.erb +2 -2
- data/app/views/alchemy_crm/contacts_mailer/signup_mail.html.erb +9 -9
- data/app/views/alchemy_crm/contacts_mailer/signup_mail.text.erb +2 -2
- data/app/views/alchemy_crm/mailings_mailer/verification_mail.html.erb +9 -9
- data/app/views/alchemy_crm/subscriptions/index.html.erb +4 -4
- data/app/views/alchemy_crm/subscriptions_mailer/overview_mail.html.erb +25 -25
- data/app/views/alchemy_crm/subscriptions_mailer/overview_mail.text.erb +2 -2
- data/app/views/csv_magic/import_errors.html.erb +23 -23
- data/app/views/csv_magic/mapper.html.erb +46 -46
- data/app/views/layouts/alchemy_crm/mailings.html.erb +177 -177
- data/config/initializers/assets.rb +2 -2
- data/config/locales/alchemy_crm.de.yml +1 -1
- data/config/locales/alchemy_crm.en.yml +1 -0
- data/config/locales/localized_country_select.de.rb +260 -260
- data/config/locales/localized_country_select.en.rb +274 -274
- data/config/routes.rb +67 -67
- data/db/migrate/20111104125306_remove_sent_mailing_pdf_id_from_sent_mailings.rb +1 -1
- data/db/migrate/20111124145923_namespace_alchemy_crm_models.rb +13 -13
- data/db/migrate/20120307160721_rename_alchemy_crm_recipients_sent_mailing_id.rb +3 -3
- data/db/migrate/20120320103412_add_indexes_to_alchemy_crm_sha1_columns.rb +3 -3
- data/db/migrate/20120327174301_add_more_indexes_to_alchemy_crm_tables.rb +10 -10
- data/lib/alchemy_crm.rb +15 -15
- data/lib/alchemy_crm/bounced_delivery.rb +38 -38
- data/lib/alchemy_crm/config.rb +25 -25
- data/lib/alchemy_crm/engine.rb +31 -31
- data/lib/alchemy_crm/i18n_helpers.rb +28 -28
- data/lib/alchemy_crm/newsletter_layout.rb +28 -28
- data/lib/alchemy_crm/seeder.rb +26 -26
- data/lib/alchemy_crm/version.rb +1 -1
- data/lib/generators/alchemy_crm/scaffold/files/newsletters.html.erb +19 -19
- data/lib/generators/alchemy_crm/scaffold/scaffold_generator.rb +2 -2
- data/lib/tasks/alchemy_crm.rake +22 -22
- data/lib/tasks/routes.rake +25 -25
- data/spec/config_spec.rb +24 -24
- data/spec/controllers/alchemy_crm/contacts_controller_spec.rb +147 -147
- data/spec/controllers/alchemy_crm/mailings_controller_spec.rb +62 -62
- data/spec/controllers/alchemy_crm/recipients_controller_spec.rb +109 -109
- data/spec/helpers/alchemy_crm/mailings_helper_spec.rb +165 -165
- data/spec/mailers/alchemy_crm/contacts_mailer_spec.rb +84 -84
- data/spec/mailers/alchemy_crm/mailings_mailer_spec.rb +29 -29
- data/spec/models/alchemy_crm/contact_group_spec.rb +25 -25
- data/spec/models/alchemy_crm/contact_spec.rb +71 -71
- data/spec/models/alchemy_crm/delivery_spec.rb +43 -39
- data/spec/models/alchemy_crm/mailing_spec.rb +46 -42
- data/spec/models/alchemy_crm/newsletter_spec.rb +29 -29
- data/spec/spec_helper.rb +36 -36
- metadata +6 -8
- data/rails/init.rb +0 -1
- data/recipes/alchemy-mailings-capistrano-tasks.rb +0 -12
@@ -1,20 +1,20 @@
|
|
1
1
|
module AlchemyCrm
|
2
|
-
|
2
|
+
class MailingsController < AlchemyCrm::BaseController
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
4
|
+
def show
|
5
|
+
@mailing = Mailing.find_by_sha1(params[:m])
|
6
|
+
if @mailing.nil? && !params[:id].blank?
|
7
|
+
@mailing = Mailing.find(params[:id])
|
8
|
+
end
|
9
|
+
@page = @mailing.page
|
10
|
+
if params[:r].present?
|
11
|
+
@recipient = @mailing.recipients.find_by_sha1(params[:r])
|
12
|
+
@contact = @recipient.contact || Contact.new_from_recipient(@recipient)
|
13
|
+
else
|
14
|
+
@contact = Contact.fake
|
15
|
+
@recipient = Recipient.new_from_contact(@contact)
|
16
|
+
end
|
17
|
+
end
|
18
18
|
|
19
|
-
|
19
|
+
end
|
20
20
|
end
|
@@ -1,35 +1,35 @@
|
|
1
1
|
module AlchemyCrm
|
2
|
-
|
2
|
+
class RecipientsController < AlchemyCrm::BaseController
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
4
|
+
def reads
|
5
|
+
recipient = Recipient.find_by_sha1(params[:h])
|
6
|
+
if recipient && !recipient.read?
|
7
|
+
recipient.reads!
|
8
|
+
end
|
9
|
+
render :nothing => true
|
10
|
+
end
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
12
|
+
def reacts
|
13
|
+
recipient = Recipient.find_by_sha1(params[:h])
|
14
|
+
if recipient
|
15
|
+
recipient.reacts!({
|
16
|
+
:page_id => params[:page_id],
|
17
|
+
:element_id => params[:element_id],
|
18
|
+
:url => params[:r]
|
19
|
+
})
|
20
|
+
end
|
21
|
+
if params[:r].present?
|
22
|
+
redirect_to params[:r]
|
23
|
+
else
|
24
|
+
page = Alchemy::Page.includes(:elements).find(params[:page_id])
|
25
|
+
element = page.elements.find_by_id(params[:element_id])
|
26
|
+
redirect_to alchemy.show_page_url(
|
27
|
+
:urlname => page.urlname,
|
28
|
+
:lang => multi_language? ? page.language_code : nil,
|
29
|
+
:anchor => element ? element.dom_id : nil
|
30
|
+
)
|
31
|
+
end
|
32
|
+
end
|
33
33
|
|
34
|
-
|
34
|
+
end
|
35
35
|
end
|
@@ -1,57 +1,57 @@
|
|
1
1
|
# Caution: Not yet implemmented!
|
2
2
|
module AlchemyCrm
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
3
|
+
class SubscriptionsController < AlchemyCrm::BaseController
|
4
|
+
include I18nHelpers
|
5
|
+
before_filter :load_contact, :except => :deliver_subscriptions_overview
|
6
|
+
|
7
|
+
def index
|
8
|
+
@page = Alchemy::Page.find_by_page_layout('newsletter_views')
|
9
|
+
@root_page = @page.get_language_root
|
10
|
+
render :template => 'alchemy/pages/show', :layout => layout_for_page
|
11
|
+
end
|
12
|
+
|
13
|
+
def new
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
def create
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
def edit
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
def update
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
def destroy
|
30
|
+
@subscription = @contact.subscriptions.find(params[:subscription_id])
|
31
|
+
@subscription.destroy
|
32
|
+
flash[:notice] = alchemy_crm_t(:subscription_destroyed)
|
33
|
+
@page = Alchemy::Page.find_by_page_layout('newsletter_views')
|
34
|
+
@root_page = @page.get_language_root
|
35
|
+
render :template => 'alchemy/pages/show', :layout => layout_for_page
|
36
|
+
end
|
37
|
+
|
38
|
+
def overview
|
39
|
+
@contact = Contact.find_by_email(params[:email])
|
40
|
+
if @contact
|
41
|
+
SubscriptionsMailer.overview_mail.deliver(@contact, @element)
|
42
|
+
flash[:notice] = alchemy_crm_t(:send_subscriptions_overview_via_email)
|
43
|
+
redirect_to :index
|
44
|
+
else
|
45
|
+
flash[:error] = alchemy_crm_t(:no_subscriber_found)
|
46
|
+
render :index
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
def load_contact
|
53
|
+
@contact = Contact.find_by_email_sha1(params[:token])
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
57
|
end
|
@@ -1,18 +1,18 @@
|
|
1
1
|
Alchemy::PagesHelper.module_eval do
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
3
|
+
def render_page_layout(options={})
|
4
|
+
default_options = {
|
5
|
+
:render_format => "html"
|
6
|
+
}
|
7
|
+
options = default_options.merge(options)
|
8
|
+
if @page.layout_description['newsletter']
|
9
|
+
render :partial => "alchemy/newsletter_layouts/#{@page.page_layout.downcase}.#{options[:render_format]}.erb"
|
10
|
+
else
|
11
|
+
render :partial => "alchemy/page_layouts/#{@page.page_layout.downcase}.#{options[:render_format]}.erb"
|
12
|
+
end
|
13
|
+
rescue ActionView::MissingTemplate
|
14
|
+
warning("PageLayout: '#{@page.page_layout}' not found. Rendering standard page_layout.")
|
15
|
+
render :partial => "alchemy/page_layouts/standard"
|
16
|
+
end
|
17
17
|
|
18
18
|
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
module AlchemyCrm
|
2
|
-
|
3
|
-
|
2
|
+
module Admin
|
3
|
+
module BaseHelper
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
# Renders a <small> html tag with the contact count for current tag in it.
|
6
|
+
def contact_count_from_tag(tag)
|
7
|
+
content_tag('small', "(#{Contact.tagged_with(tag).count})")
|
8
|
+
end
|
9
9
|
|
10
|
-
|
11
|
-
|
10
|
+
end
|
11
|
+
end
|
12
12
|
end
|
@@ -1,190 +1,190 @@
|
|
1
1
|
module AlchemyCrm
|
2
|
-
|
2
|
+
module MailingsHelper
|
3
3
|
|
4
|
-
|
4
|
+
include Alchemy::PagesHelper
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
6
|
+
# Renders the newsletter layout for +@mailing.page+
|
7
|
+
#
|
8
|
+
# The +@mailing.page.page_layout+ must have a +newsletter_layout+ prefix.
|
9
|
+
# The partial itself is named without the +newsletter_layout+ prefix.
|
10
|
+
# The partial resists in +/app/views/newsletter_layouts/+
|
11
|
+
#
|
12
|
+
# === Example:
|
13
|
+
#
|
14
|
+
# Given a mailing page with a +standard+ layout has partials named +_standard.html.erb+ and +_standard.text.erb+
|
15
|
+
# But the page page_layout attribute is +newsletter_layout_standard+
|
16
|
+
#
|
17
|
+
def render_newsletter_layout(options={})
|
18
|
+
options = {:format => 'html'}.update(options)
|
19
|
+
render "alchemy/newsletter_layouts/#{@page.page_layout.downcase.gsub(Regexp.new(Mailing::MAILING_PAGE_LAYOUT_PREFIX), '')}.#{options[:format]}.erb"
|
20
|
+
end
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
22
|
+
# Renders the tracking image that records the receivement of the mailing inside the mail client.
|
23
|
+
def render_tracking_image
|
24
|
+
return "" if @preview_mode || @recipient.nil?
|
25
|
+
image_tag(
|
26
|
+
alchemy_crm.recipient_reads_url(:h => @recipient.sha1, :host => current_host),
|
27
|
+
:style => "width: 0; height: 0; display: none",
|
28
|
+
:width => 0,
|
29
|
+
:height => 0,
|
30
|
+
:alt => ''
|
31
|
+
)
|
32
|
+
end
|
33
33
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
34
|
+
# Renders a link to the unsubscribe page.
|
35
|
+
#
|
36
|
+
# Please notice that you have to create a page with a +newsletter_signout+ page layout and this page has to be public.
|
37
|
+
#
|
38
|
+
# The text inside the link is translated.
|
39
|
+
#
|
40
|
+
# === Example translation:
|
41
|
+
#
|
42
|
+
# de:
|
43
|
+
# alchemy_crm:
|
44
|
+
# unsubscribe: 'abmelden'
|
45
|
+
#
|
46
|
+
# === Options:
|
47
|
+
#
|
48
|
+
# html_options [Hash] # Passed to the link. Useful for styling the link with inline css.
|
49
|
+
#
|
50
|
+
# You can pass an optional block thats gets passed to +link_to+
|
51
|
+
#
|
52
|
+
def link_to_unsubscribe_page(html_options={})
|
53
|
+
text = ::I18n.t(:unsubscribe, :scope => :alchemy_crm)
|
54
|
+
if block_given?
|
55
|
+
link_to(url_for_unsubscribe_page, html_options) do
|
56
|
+
yield
|
57
|
+
end
|
58
|
+
else
|
59
|
+
link_to(text, url_for_unsubscribe_page, html_options)
|
60
|
+
end
|
61
|
+
end
|
62
62
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
63
|
+
# Returns the url for the unsubscribe page.
|
64
|
+
# Used by +link_to_unsubscribe_page+ helper and inside of plain text views of mailings.
|
65
|
+
def url_for_unsubscribe_page
|
66
|
+
unsubscribe_page = Alchemy::Page.find_by_page_layout('newsletter_signout')
|
67
|
+
if unsubscribe_page.nil?
|
68
|
+
raise('Newsletter Signout Page Could Not Be Found. Please create one!')
|
69
|
+
else
|
70
|
+
alchemy.show_page_url(
|
71
|
+
:urlname => unsubscribe_page.urlname,
|
72
|
+
:lang => multi_language? ? unsubscribe_page.language_code : nil,
|
73
|
+
:email => @contact ? @contact.email : nil,
|
74
|
+
:host => current_host
|
75
|
+
)
|
76
|
+
end
|
77
|
+
end
|
78
78
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
79
|
+
# Renders a notice to open the mailing inside a browser, if it does not displays correctly.
|
80
|
+
#
|
81
|
+
# The notice and the link inside are translated via I18n.
|
82
|
+
#
|
83
|
+
# === Example translation:
|
84
|
+
#
|
85
|
+
# de:
|
86
|
+
# alchemy_crm:
|
87
|
+
# here: 'hier'
|
88
|
+
# read_in_browser_notice: "Falls der Newsletter nicht richtig dargestellt wird, klicken Sie bitte %{link}."
|
89
|
+
#
|
90
|
+
# === Options:
|
91
|
+
#
|
92
|
+
# html_options [Hash] # Passed to the link. Useful for styling the link with inline css.
|
93
|
+
#
|
94
|
+
def read_in_browser_notice(html_options = {})
|
95
|
+
return "" if @recipient.nil?
|
96
|
+
::I18n.t(
|
97
|
+
:read_in_browser_notice,
|
98
|
+
:link => link_to(
|
99
|
+
::I18n.t(:here, :scope => :alchemy_crm),
|
100
|
+
alchemy_crm.show_mailing_url(
|
101
|
+
:m => @mailing.sha1,
|
102
|
+
:r => @recipient.sha1,
|
103
|
+
:host => current_host
|
104
|
+
),
|
105
|
+
html_options,
|
106
|
+
:host => current_host
|
107
|
+
),
|
108
|
+
:scope => :alchemy_crm
|
109
|
+
).html_safe
|
110
|
+
end
|
111
111
|
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
112
|
+
# Use this helper to render an image from your server.
|
113
|
+
#
|
114
|
+
# The notice and the link inside are translated via I18n.
|
115
|
+
#
|
116
|
+
# === Example:
|
117
|
+
#
|
118
|
+
# <%= image_from_server_tag('logo.png', :alt => 'Logo', :width => 230, :height => 116, :style => 'outline:none; text-decoration:none; -ms-interpolation-mode: bicubic;') %>
|
119
|
+
# => <img src="http://example.com/assets/logo.png"
|
120
|
+
#
|
121
|
+
# === Options:
|
122
|
+
#
|
123
|
+
# html_options [Hash] # Passed to the image_tag helper.
|
124
|
+
#
|
125
|
+
def image_from_server_tag(image, html_options={})
|
126
|
+
image_tag([current_server, Rails.application.config.assets.prefix, image].join('/'), html_options)
|
127
|
+
end
|
128
128
|
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
129
|
+
# Renders a link that tracks the reaction of a recipient.
|
130
|
+
#
|
131
|
+
# After getting tracked the controller redirects to the url passed in.
|
132
|
+
#
|
133
|
+
# It has the same arguments that the Rails +link_to+ helper has.
|
134
|
+
#
|
135
|
+
# === Example:
|
136
|
+
#
|
137
|
+
# <%= tracked_link_tag('read more', :r => 'http://example.com/my-article', :style => 'color: black') %>
|
138
|
+
# => <a href="http://example.com/recipient/s3cr3tSh41/reacts?r=http%3A%2F%2Fexample.com%2Fmy-article" style="color: black">
|
139
|
+
#
|
140
|
+
# *NOTE:* You can even pass a block like you could for +link_to+ helper from Rails.
|
141
|
+
#
|
142
|
+
def tracked_link_tag(*args)
|
143
|
+
if block_given?
|
144
|
+
link_to(tracked_url_for(args.first), args.last) do
|
145
|
+
yield
|
146
|
+
end
|
147
|
+
else
|
148
|
+
link_to(args.first, tracked_url_for(args[1]), args.last)
|
149
|
+
end
|
150
|
+
end
|
151
151
|
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
152
|
+
# Returns the url for tracking a link that's clicked inside a mailing.
|
153
|
+
# Used by +tracked_link_tag+ helper and plain text mailing views.
|
154
|
+
def tracked_url_for(redirect_url)
|
155
|
+
alchemy_crm.recipient_reacts_url(:h => @recipient.sha1, :r => redirect_url, :host => current_host)
|
156
|
+
end
|
157
157
|
|
158
|
-
|
159
|
-
|
160
|
-
|
158
|
+
def current_host
|
159
|
+
(defined?(request)).nil? || request.nil? ? @options[:host] : request.host
|
160
|
+
end
|
161
161
|
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
162
|
+
def current_server
|
163
|
+
if (defined?(request)).nil? || request.nil?
|
164
|
+
protocol = @options.nil? || @options[:protocol].blank? ? 'http://' : @options[:protocol]
|
165
|
+
else
|
166
|
+
protocol = request.protocol
|
167
|
+
end
|
168
|
+
if (defined?(request)).nil? || request.nil?
|
169
|
+
if @options
|
170
|
+
port = @options[:port] && @options[:port] != 80 ? @options[:port] : nil
|
171
|
+
else
|
172
|
+
port = nil
|
173
|
+
end
|
174
|
+
else
|
175
|
+
port = request.port != 80 ? request.port : nil
|
176
|
+
end
|
177
|
+
[protocol, current_host, port ? ":#{port}" : nil].compact.join
|
178
|
+
end
|
179
179
|
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
180
|
+
def current_language
|
181
|
+
return @language if @language
|
182
|
+
if @options && @options[:language_id]
|
183
|
+
@language = Alchemy::Language.find(@options[:language_id])
|
184
|
+
else
|
185
|
+
@language = Alchemy::Language.get_default
|
186
|
+
end
|
187
|
+
end
|
188
188
|
|
189
|
-
|
189
|
+
end
|
190
190
|
end
|