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.
Files changed (123) hide show
  1. data/Gemfile +10 -11
  2. data/alchemy_crm.gemspec +21 -21
  3. data/app/assets/javascripts/alchemy_crm/alchemy_crm.base.js +54 -54
  4. data/app/assets/stylesheets/alchemy_crm/base.css.scss +199 -199
  5. data/app/controllers/alchemy_crm/admin/base_controller.rb +5 -5
  6. data/app/controllers/alchemy_crm/admin/contact_groups_controller.rb +15 -15
  7. data/app/controllers/alchemy_crm/admin/contacts_controller.rb +95 -95
  8. data/app/controllers/alchemy_crm/admin/deliveries_controller.rb +66 -66
  9. data/app/controllers/alchemy_crm/admin/elements_controller_extension.rb +23 -23
  10. data/app/controllers/alchemy_crm/admin/mailings_controller.rb +44 -44
  11. data/app/controllers/alchemy_crm/admin/newsletters_controller.rb +16 -16
  12. data/app/controllers/alchemy_crm/admin/tags_controller.rb +60 -59
  13. data/app/controllers/alchemy_crm/base_controller.rb +3 -3
  14. data/app/controllers/alchemy_crm/contacts_controller.rb +88 -88
  15. data/app/controllers/alchemy_crm/mailings_controller.rb +16 -16
  16. data/app/controllers/alchemy_crm/recipients_controller.rb +30 -30
  17. data/app/controllers/alchemy_crm/subscriptions_controller.rb +54 -54
  18. data/app/helpers/alchemy/pages_helper_extension.rb +14 -14
  19. data/app/helpers/alchemy_crm/admin/base_helper.rb +8 -8
  20. data/app/helpers/alchemy_crm/mailings_helper.rb +175 -175
  21. data/app/mailers/alchemy_crm/bounce_receiver.rb +9 -9
  22. data/app/mailers/alchemy_crm/contacts_mailer.rb +21 -21
  23. data/app/mailers/alchemy_crm/mailings_mailer.rb +46 -46
  24. data/app/mailers/alchemy_crm/subscriptions_mailer.rb +12 -12
  25. data/app/models/alchemy/essence_element_teaser.rb +14 -14
  26. data/app/models/alchemy_crm/contact.rb +260 -260
  27. data/app/models/alchemy_crm/contact_group.rb +15 -15
  28. data/app/models/alchemy_crm/contact_group_filter.rb +17 -17
  29. data/app/models/alchemy_crm/delivery.rb +54 -54
  30. data/app/models/alchemy_crm/element_extension.rb +23 -23
  31. data/app/models/alchemy_crm/mailing.rb +90 -90
  32. data/app/models/alchemy_crm/newsletter.rb +33 -33
  33. data/app/models/alchemy_crm/reaction.rb +5 -5
  34. data/app/models/alchemy_crm/recipient.rb +46 -46
  35. data/app/models/alchemy_crm/subscription.rb +4 -4
  36. data/app/views/alchemy/admin/elements/fill.js.erb +11 -11
  37. data/app/views/alchemy/elements/_newsletter_article_view.html.erb +14 -14
  38. data/app/views/alchemy/elements/_newsletter_greeting_view.html.erb +9 -9
  39. data/app/views/alchemy/elements/_newsletter_signout_form_view.html.erb +18 -18
  40. data/app/views/alchemy/elements/_newsletter_signup_form_view.html.erb +62 -62
  41. data/app/views/alchemy/essences/_essence_element_teaser_editor.html.erb +29 -29
  42. data/app/views/alchemy/newsletter_layouts/_standard.html.erb +37 -37
  43. data/app/views/alchemy_crm/admin/contact_groups/_contact_group.html.erb +30 -30
  44. data/app/views/alchemy_crm/admin/contact_groups/_filter.html.erb +28 -28
  45. data/app/views/alchemy_crm/admin/contact_groups/_form.html.erb +45 -45
  46. data/app/views/alchemy_crm/admin/contact_groups/_tag.html.erb +4 -4
  47. data/app/views/alchemy_crm/admin/contact_groups/add_filter.js.erb +7 -7
  48. data/app/views/alchemy_crm/admin/contact_groups/index.html.erb +28 -28
  49. data/app/views/alchemy_crm/admin/contacts/_contact.html.erb +42 -42
  50. data/app/views/alchemy_crm/admin/contacts/_form.html.erb +76 -76
  51. data/app/views/alchemy_crm/admin/contacts/import.html.erb +27 -27
  52. data/app/views/alchemy_crm/admin/contacts/index.html.erb +39 -39
  53. data/app/views/alchemy_crm/admin/contacts/vcf_import_result.html.erb +24 -24
  54. data/app/views/alchemy_crm/admin/deliveries/_delivery.html.erb +30 -30
  55. data/app/views/alchemy_crm/admin/deliveries/_form.html.erb +61 -61
  56. data/app/views/alchemy_crm/admin/deliveries/_recipient.html.erb +36 -36
  57. data/app/views/alchemy_crm/admin/deliveries/index.html.erb +21 -21
  58. data/app/views/alchemy_crm/admin/deliveries/show.html.erb +61 -61
  59. data/app/views/alchemy_crm/admin/elements/teasables.html.erb +53 -53
  60. data/app/views/alchemy_crm/admin/mailings/_form.html.erb +41 -41
  61. data/app/views/alchemy_crm/admin/mailings/_mailing.html.erb +73 -73
  62. data/app/views/alchemy_crm/admin/mailings/edit_content.html.erb +170 -170
  63. data/app/views/alchemy_crm/admin/mailings/import_result.html.erb +18 -18
  64. data/app/views/alchemy_crm/admin/mailings/index.html.erb +25 -25
  65. data/app/views/alchemy_crm/admin/newsletters/_form.html.erb +52 -52
  66. data/app/views/alchemy_crm/admin/newsletters/_tag_with_radiobutton.html.erb +5 -5
  67. data/app/views/alchemy_crm/admin/newsletters/index.html.erb +29 -29
  68. data/app/views/alchemy_crm/admin/newsletters/new.html.erb +4 -4
  69. data/app/views/alchemy_crm/admin/tags/_radio_tag.html.erb +4 -4
  70. data/app/views/alchemy_crm/admin/tags/_tag.html.erb +30 -30
  71. data/app/views/alchemy_crm/admin/tags/edit.html.erb +32 -32
  72. data/app/views/alchemy_crm/admin/tags/index.html.erb +23 -23
  73. data/app/views/alchemy_crm/admin/tags/new.html.erb +14 -14
  74. data/app/views/alchemy_crm/contacts_mailer/signout_mail.html.erb +6 -6
  75. data/app/views/alchemy_crm/contacts_mailer/signout_mail.text.erb +2 -2
  76. data/app/views/alchemy_crm/contacts_mailer/signup_mail.html.erb +9 -9
  77. data/app/views/alchemy_crm/contacts_mailer/signup_mail.text.erb +2 -2
  78. data/app/views/alchemy_crm/mailings_mailer/verification_mail.html.erb +9 -9
  79. data/app/views/alchemy_crm/subscriptions/index.html.erb +4 -4
  80. data/app/views/alchemy_crm/subscriptions_mailer/overview_mail.html.erb +25 -25
  81. data/app/views/alchemy_crm/subscriptions_mailer/overview_mail.text.erb +2 -2
  82. data/app/views/csv_magic/import_errors.html.erb +23 -23
  83. data/app/views/csv_magic/mapper.html.erb +46 -46
  84. data/app/views/layouts/alchemy_crm/mailings.html.erb +177 -177
  85. data/config/initializers/assets.rb +2 -2
  86. data/config/locales/alchemy_crm.de.yml +1 -1
  87. data/config/locales/alchemy_crm.en.yml +1 -0
  88. data/config/locales/localized_country_select.de.rb +260 -260
  89. data/config/locales/localized_country_select.en.rb +274 -274
  90. data/config/routes.rb +67 -67
  91. data/db/migrate/20111104125306_remove_sent_mailing_pdf_id_from_sent_mailings.rb +1 -1
  92. data/db/migrate/20111124145923_namespace_alchemy_crm_models.rb +13 -13
  93. data/db/migrate/20120307160721_rename_alchemy_crm_recipients_sent_mailing_id.rb +3 -3
  94. data/db/migrate/20120320103412_add_indexes_to_alchemy_crm_sha1_columns.rb +3 -3
  95. data/db/migrate/20120327174301_add_more_indexes_to_alchemy_crm_tables.rb +10 -10
  96. data/lib/alchemy_crm.rb +15 -15
  97. data/lib/alchemy_crm/bounced_delivery.rb +38 -38
  98. data/lib/alchemy_crm/config.rb +25 -25
  99. data/lib/alchemy_crm/engine.rb +31 -31
  100. data/lib/alchemy_crm/i18n_helpers.rb +28 -28
  101. data/lib/alchemy_crm/newsletter_layout.rb +28 -28
  102. data/lib/alchemy_crm/seeder.rb +26 -26
  103. data/lib/alchemy_crm/version.rb +1 -1
  104. data/lib/generators/alchemy_crm/scaffold/files/newsletters.html.erb +19 -19
  105. data/lib/generators/alchemy_crm/scaffold/scaffold_generator.rb +2 -2
  106. data/lib/tasks/alchemy_crm.rake +22 -22
  107. data/lib/tasks/routes.rake +25 -25
  108. data/spec/config_spec.rb +24 -24
  109. data/spec/controllers/alchemy_crm/contacts_controller_spec.rb +147 -147
  110. data/spec/controllers/alchemy_crm/mailings_controller_spec.rb +62 -62
  111. data/spec/controllers/alchemy_crm/recipients_controller_spec.rb +109 -109
  112. data/spec/helpers/alchemy_crm/mailings_helper_spec.rb +165 -165
  113. data/spec/mailers/alchemy_crm/contacts_mailer_spec.rb +84 -84
  114. data/spec/mailers/alchemy_crm/mailings_mailer_spec.rb +29 -29
  115. data/spec/models/alchemy_crm/contact_group_spec.rb +25 -25
  116. data/spec/models/alchemy_crm/contact_spec.rb +71 -71
  117. data/spec/models/alchemy_crm/delivery_spec.rb +43 -39
  118. data/spec/models/alchemy_crm/mailing_spec.rb +46 -42
  119. data/spec/models/alchemy_crm/newsletter_spec.rb +29 -29
  120. data/spec/spec_helper.rb +36 -36
  121. metadata +6 -8
  122. data/rails/init.rb +0 -1
  123. data/recipes/alchemy-mailings-capistrano-tasks.rb +0 -12
@@ -1,20 +1,20 @@
1
1
  module AlchemyCrm
2
- class MailingsController < AlchemyCrm::BaseController
2
+ class MailingsController < AlchemyCrm::BaseController
3
3
 
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
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
- end
19
+ end
20
20
  end
@@ -1,35 +1,35 @@
1
1
  module AlchemyCrm
2
- class RecipientsController < AlchemyCrm::BaseController
2
+ class RecipientsController < AlchemyCrm::BaseController
3
3
 
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
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
- 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
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
- end
34
+ end
35
35
  end
@@ -1,57 +1,57 @@
1
1
  # Caution: Not yet implemmented!
2
2
  module AlchemyCrm
3
- class SubscriptionsController < AlchemyCrm::BaseController
4
-
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] = 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] = t(:send_subscriptions_overview_via_email)
43
- redirect_to :index
44
- else
45
- flash[:error] = 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
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
- 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
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
- module Admin
3
- module BaseHelper
2
+ module Admin
3
+ module BaseHelper
4
4
 
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
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
- end
11
- end
10
+ end
11
+ end
12
12
  end
@@ -1,190 +1,190 @@
1
1
  module AlchemyCrm
2
- module MailingsHelper
2
+ module MailingsHelper
3
3
 
4
- include Alchemy::PagesHelper
4
+ include Alchemy::PagesHelper
5
5
 
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
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
- # 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
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
- # 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
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
- # 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
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
- # 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
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
- # 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
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
- # 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
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
- # 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
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
- def current_host
159
- (defined?(request)).nil? || request.nil? ? @options[:host] : request.host
160
- end
158
+ def current_host
159
+ (defined?(request)).nil? || request.nil? ? @options[:host] : request.host
160
+ end
161
161
 
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
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
- 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
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
- end
189
+ end
190
190
  end