From 9b6486e252c843473ab2e6a53dd57eee2f54ae23 Mon Sep 17 00:00:00 2001 From: jywarren Date: Fri, 14 Oct 2016 14:06:44 -0400 Subject: [PATCH] fix to sunspot config and additional activity grid tweaks refactor Rails.root to request.host update for mailers too mailer reqeust.host fixes in tests more mailer test tweaks mailer test fixes 2 more mailer test refactoring ActionMailer host changes in test and app more test tweaks test helper specifying hosts for mailers in dev and test revision timing change for order render body test w/ request host param render_body_email, not render_body hostname env. config and activity feed html tweak mailer/request.host additions style tweak last domain tweak --- app/assets/stylesheets/style.css | 12 +++++++++++ app/controllers/application_controller.rb | 4 ++-- app/controllers/legacy_controller.rb | 2 +- app/controllers/openid_controller.rb | 2 +- app/controllers/tag_controller.rb | 4 ++-- app/controllers/wiki_controller.rb | 2 +- app/helpers/application_helper.rb | 4 ++-- app/mailers/admin_mailer.rb | 8 ++++---- app/mailers/answer_mailer.rb | 2 +- app/mailers/comment_mailer.rb | 2 +- app/mailers/password_reset_mailer.rb | 2 +- app/mailers/subscription_mailer.rb | 2 +- app/mailers/welcome_mailer.rb | 2 +- app/models/concerns/comments_shared.rb | 4 ++-- app/models/drupal_file.rb | 10 +++++----- app/models/drupal_node_revision.rb | 8 ++++---- app/models/image.rb | 6 +----- app/models/user.rb | 6 +----- app/views/admin/spam.html.erb | 2 +- app/views/admin/users.html.erb | 2 +- .../notify_author_of_approval.html.erb | 6 +++--- .../notify_moderators_of_approval.html.erb | 10 +++++----- .../notify_moderators_of_spam.html.erb | 12 +++++------ .../notify_node_moderators.html.erb | 14 ++++++------- .../notify_answer_accept.html.erb | 6 +++--- .../answer_mailer/notify_answer_like.html.erb | 6 +++--- .../notify_answer_likers_author.html.erb | 12 +++++------ .../notify_question_author.html.erb | 12 +++++------ app/views/comment_mailer/notify.html.erb | 14 ++++++------- .../notify_answer_author.html.erb | 12 +++++------ .../comment_mailer/notify_barnstar.html.erb | 10 +++++----- .../comment_mailer/notify_callout.html.erb | 16 +++++++-------- .../notify_note_author.html.erb | 18 ++++++++--------- app/views/dashboard/_activity.html.erb | 6 +++--- app/views/editor/post.html.erb | 2 +- app/views/layouts/_footer.html.erb | 2 +- app/views/layouts/application.html.erb | 2 +- app/views/map/index.html.erb | 2 +- app/views/notes/_responses.html.erb | 2 +- app/views/notes/rss.rss.builder | 6 +++--- .../reset_notify.text.erb | 4 ++-- .../notify_node_creation.html.erb | 14 ++++++------- .../notify_note_liked.text.erb | 6 +++--- app/views/tag/icalendar.ics.erb | 4 ++-- app/views/tag/rss.rss.builder | 6 +++--- app/views/users/rss.rss.builder | 4 ++-- config/environments/development.rb | 4 ++++ config/environments/production.rb | 5 +++++ config/environments/test.rb | 5 +++++ config/sunspot.yml | 2 +- test/fixtures/node_revisions.yml | 2 +- test/functional/admin_controller_test.rb | 8 ++++---- test/functional/tag_controller_test.rb | 2 +- test/integration/moderate_and_ban_test.rb | 6 +++--- test/test_helper.rb | 5 +++++ test/unit/admin_mailer_test.rb | 16 +++++++-------- test/unit/answer_mailer_test.rb | 20 +++++++++---------- test/unit/comment_mailer_test.rb | 14 ++++++------- test/unit/drupal_node_revision_test.rb | 2 +- test/unit/subscription_mailer_test.rb | 16 +++++++-------- 60 files changed, 212 insertions(+), 189 deletions(-) diff --git a/app/assets/stylesheets/style.css b/app/assets/stylesheets/style.css index 3c9ce596d6..36db6cb53a 100644 --- a/app/assets/stylesheets/style.css +++ b/app/assets/stylesheets/style.css @@ -491,3 +491,15 @@ table th a { table th a:hover { color: #aaa; } + +@media (max-width:768px) { + table { + font-size: 90%; + } +} + +@media (max-width:400px) { + table { + font-size: 80%; + } +} diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 31f48a111e..65fa8cb6f3 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -83,7 +83,7 @@ def current_user @current_user = nil elsif @current_user.try(:drupal_user).try(:status) == 5 # Tell the user they are banned. Fails b/c redirect to require below. - flash[:warning] = "The user '#{@current_user.username}' has been placed in moderation; please see our moderation policy and contact moderators@#{Rails.root} if you believe this is in error." + flash[:warning] = "The user '#{@current_user.username}' has been placed in moderation; please see our moderation policy and contact moderators@#{request.host} if you believe this is in error." # Same effect as if the user clicked logout: current_user_session.destroy # Ensures no code will use old @current_user info. Treat the user @@ -142,7 +142,7 @@ def alert_and_redirect_moderated # no notification; don't let people easily fish for existing draft titles; we should try to 404 it redirect_to "/" elsif @node.author.status == 5 - flash.now[:warning] = "The user '#{@node.author.username}' has been placed in moderation and will not be able to respond to comments." + flash.now[:warning] = "The user '#{@node.author.username}' has been placed in moderation and will not be able to respond to comments." end end diff --git a/app/controllers/legacy_controller.rb b/app/controllers/legacy_controller.rb index 6bb0d1f2ba..9b8aa924fa 100644 --- a/app/controllers/legacy_controller.rb +++ b/app/controllers/legacy_controller.rb @@ -38,7 +38,7 @@ def openid_username end def file - redirect_to "//#{Rails.root}/sites/default/files/"+params[:filename]+"."+params[:format], :status => 301 + redirect_to "//#{request.host}/sites/default/files/"+params[:filename]+"."+params[:format], :status => 301 end # def image diff --git a/app/controllers/openid_controller.rb b/app/controllers/openid_controller.rb index 17dec3cf51..4e79c28973 100644 --- a/app/controllers/openid_controller.rb +++ b/app/controllers/openid_controller.rb @@ -215,7 +215,7 @@ def decision def server if @server.nil? server_url = url_for :action => 'index', :only_path => false - dir = Pathname.new(Rails.root).join('db').join('openid-store') + dir = Pathname.new(request.host).join('db').join('openid-store') store = OpenID::Store::Filesystem.new(dir) @server = Server.new(store, server_url) end diff --git a/app/controllers/tag_controller.rb b/app/controllers/tag_controller.rb index c39f9e9d34..11ed1f0f0a 100644 --- a/app/controllers/tag_controller.rb +++ b/app/controllers/tag_controller.rb @@ -82,11 +82,11 @@ def barnstar else flash[:notice] = I18n.t('tag_controller.barnstar_awarded', :url1 => "/wiki/barnstars#"+params[:star].split('-').each{|w| w.capitalize!}.join('+')+"+Barnstar", :star => params[:star], :url2 => "/profile/"+node.author.name, :awardee => node.author.name).html_safe # on success add comment - barnstar_info_link = 'barnstar' + barnstar_info_link = 'barnstar' node.add_comment({ :subject => 'barnstar', :uid => current_user.uid, - :body => "#{current_user.username} awards a #{barnstar_info_link} to #{node.drupal_users.name} for their awesome contribution!" + :body => "@#{current_user.username} awards a #{barnstar_info_link} to #{node.drupal_users.name} for their awesome contribution!" }) end redirect_to node.path + "?_=" + Time.now.to_i.to_s diff --git a/app/controllers/wiki_controller.rb b/app/controllers/wiki_controller.rb index a153449df1..6e8c89f958 100644 --- a/app/controllers/wiki_controller.rb +++ b/app/controllers/wiki_controller.rb @@ -5,7 +5,7 @@ class WikiController < ApplicationController before_filter :require_user, :only => [:new, :create, :edit, :update, :delete] def subdomain - url = "//#{Rails.root}/wiki/" + url = "//#{request.host}/wiki/" case request.subdomain when "new-york-city", "gulf-coast", diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 0a3787e129..21c4a1966c 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -80,7 +80,7 @@ def insert_extras(body) output += ' @' + node.author.username + '' output += ' ' + (node.has_power_tag('time') ? node.power_tag('time') : '-') + '' output += ' ' + (node.has_power_tag('difficulty') ? node.power_tag('difficulty') : '-') + '' - output += ' ' + node.response_count('replication').to_s + ' replications' + output += ' ' + node.response_count('replication').to_s + ' replications: Try it »' output += '' end output += '' @@ -109,7 +109,7 @@ def insert_extras(body) output += ' @' + node.author.username + '' output += ' ' + (node.has_power_tag('time') ? node.power_tag('time') : '-') + '' output += ' ' + (node.has_power_tag('difficulty') ? node.power_tag('difficulty') : '-') + '' - output += ' ' + node.response_count('build').to_s + ' builds' + output += ' ' + node.response_count('build').to_s + ' builds: Try it »' output += '' end output += '' diff --git a/app/mailers/admin_mailer.rb b/app/mailers/admin_mailer.rb index c87b168017..1cf82de1e1 100644 --- a/app/mailers/admin_mailer.rb +++ b/app/mailers/admin_mailer.rb @@ -1,12 +1,12 @@ class AdminMailer < ActionMailer::Base - default from: "do-not-reply@#{Rails.root}" + default from: "do-not-reply@#{ActionMailer::Base.default_url_options[:host]}" def notify_node_moderators(node) subject = "[New Public Lab poster needs moderation] " + node.title @node = node moderators = User.where(role: ['moderator', 'admin']).collect(&:email) mail( - to: "moderators@#{Rails.root}", + to: "moderators@#{ActionMailer::Base.default_url_options[:host]}", bcc: moderators, subject: subject ).deliver @@ -34,7 +34,7 @@ def notify_moderators_of_approval(node, moderator) @node = node moderators = User.where(role: ['moderator', 'admin']).collect(&:email) mail( - to: "moderators@#{Rails.root}", + to: "moderators@#{ActionMailer::Base.default_url_options[:host]}", bcc: moderators, subject: subject ).deliver @@ -47,7 +47,7 @@ def notify_moderators_of_spam(node, moderator) @node = node moderators = User.where(role: ['moderator', 'admin']).collect(&:email) mail( - to: "moderators@#{Rails.root}", + to: "moderators@#{ActionMailer::Base.default_url_options[:host]}", bcc: moderators, subject: subject ).deliver diff --git a/app/mailers/answer_mailer.rb b/app/mailers/answer_mailer.rb index 82020b4a11..c49cefb9dd 100644 --- a/app/mailers/answer_mailer.rb +++ b/app/mailers/answer_mailer.rb @@ -1,5 +1,5 @@ class AnswerMailer < ActionMailer::Base - default from: "do-not-reply@#{Rails.root}" + default from: "do-not-reply@#{ActionMailer::Base.default_url_options[:host]}" def notify_question_author(user, answer) subject = "[PublicLab] New answer to Question: " + answer.node.title diff --git a/app/mailers/comment_mailer.rb b/app/mailers/comment_mailer.rb index ff78bd508b..0a4c1a277a 100644 --- a/app/mailers/comment_mailer.rb +++ b/app/mailers/comment_mailer.rb @@ -1,5 +1,5 @@ class CommentMailer < ActionMailer::Base - default from: "do-not-reply@#{Rails.root}" + default from: "do-not-reply@#{ActionMailer::Base.default_url_options[:host]}" # CommentMailer.notify_of_comment(user,self).deliver def notify(user,comment) diff --git a/app/mailers/password_reset_mailer.rb b/app/mailers/password_reset_mailer.rb index 91e97ddfd8..7d023e4b8c 100644 --- a/app/mailers/password_reset_mailer.rb +++ b/app/mailers/password_reset_mailer.rb @@ -1,5 +1,5 @@ class PasswordResetMailer < ActionMailer::Base - default from: "do-not-reply@#{Rails.root}" + default from: "do-not-reply@#{ActionMailer::Base.default_url_options[:host]}" # PasswordResetMailer.reset_notify(user).deliver def reset_notify(user, key) diff --git a/app/mailers/subscription_mailer.rb b/app/mailers/subscription_mailer.rb index 85881d2a66..9eeb616ccb 100644 --- a/app/mailers/subscription_mailer.rb +++ b/app/mailers/subscription_mailer.rb @@ -1,5 +1,5 @@ class SubscriptionMailer < ActionMailer::Base - default from: "do-not-reply@#{Rails.root}" + default from: "do-not-reply@#{ActionMailer::Base.default_url_options[:host]}" def notify_node_creation(node) subject = "[PublicLab] " + (node.has_power_tag('question') ? "Question: " : "") + diff --git a/app/mailers/welcome_mailer.rb b/app/mailers/welcome_mailer.rb index 050707ca04..ecbdb95546 100644 --- a/app/mailers/welcome_mailer.rb +++ b/app/mailers/welcome_mailer.rb @@ -1,5 +1,5 @@ class WelcomeMailer < ActionMailer::Base - #default from: "do-not-reply@#{Rails.root}" + #default from: "do-not-reply@#{ActionMailer::Base.default_url_options[:host]}" # PasswordResetMailer.reset_notify(user).deliver def add_to_list(user,list) diff --git a/app/models/concerns/comments_shared.rb b/app/models/concerns/comments_shared.rb index fe33871dc7..d96600c037 100644 --- a/app/models/concerns/comments_shared.rb +++ b/app/models/concerns/comments_shared.rb @@ -5,8 +5,8 @@ module CommentsShared # filtered version additionally appending http/https # protocol to protocol-relative URLslike "/foo" - def body_email - self.body.gsub(/([\s|"|'|\[|\(])(\/\/)([\w]?\.?#{Rails.root})/, '\1https://\3') + def body_email(host = "publiclab.org") + self.body.gsub(/([\s|"|'|\[|\(])(\/\/)([\w]?\.?#{host})/, '\1https://\3') end def author diff --git a/app/models/drupal_file.rb b/app/models/drupal_file.rb index 1651e60294..14813bb64c 100644 --- a/app/models/drupal_file.rb +++ b/app/models/drupal_file.rb @@ -16,16 +16,16 @@ def is_image? def path(size = :default) if self.is_image? if size == :thumb - "https://#{Rails.root}/#{self.filepath.gsub('sites/default/files/','sites/default/files/imagecache/thumb/')}" + "/#{self.filepath.gsub('sites/default/files/','sites/default/files/imagecache/thumb/')}" elsif size == :default - "https://#{Rails.root}/#{self.filepath.gsub('sites/default/files/','sites/default/files/imagecache/default/')}" + "/#{self.filepath.gsub('sites/default/files/','sites/default/files/imagecache/default/')}" elsif size == :large - "https://#{Rails.root}/#{self.filepath.gsub('sites/default/files/','sites/default/files/imagecache/default/')}" + "/#{self.filepath.gsub('sites/default/files/','sites/default/files/imagecache/default/')}" elsif size == :original - "https://#{Rails.root}/#{self.filepath}" + "/#{self.filepath}" end else - "https://#{Rails.root}/#{self.filepath}" + "/#{self.filepath}" end end diff --git a/app/models/drupal_node_revision.rb b/app/models/drupal_node_revision.rb index b70b12523f..8302fd48a1 100644 --- a/app/models/drupal_node_revision.rb +++ b/app/models/drupal_node_revision.rb @@ -112,10 +112,10 @@ def render_body # filtered version additionally appending http/https protocol to protocol-relative URLs like "/foo" # render_body plus making all relative links absolute - def render_body_email - body = self.render_body.gsub(/([\s|"|'|\[|\(])(\/\/)([\w]?\.?#{Rails.root})/, '\1https://\3') - body = body.gsub("href='/","href='https://#{Rails.root}/") - body = body.gsub('href="/','href="https://' + Rails.root.to_s + '/') + def render_body_email(host = "publiclab.org") + body = self.render_body.gsub(/([\s|"|'|\[|\(])(\/\/)([\w]?\.?#{host})/, '\1https://\3') + body = body.gsub("href='/","href='https://#{host}/") + body = body.gsub('href="/','href="https://' + host.to_s + '/') body end diff --git a/app/models/image.rb b/app/models/image.rb index 73a53a3b0c..31a84e7f42 100644 --- a/app/models/image.rb +++ b/app/models/image.rb @@ -37,11 +37,7 @@ def path(size = :medium) else size = :original end - if Rails.env == "production" - 'https://i.' + Rails.root.to_s + self.photo.url(size) - else - self.photo.url(size).gsub('https://i.' + Rails.root.to_s,'') - end + self.photo.url(size) end def filename diff --git a/app/models/user.rb b/app/models/user.rb index a7711beca3..d5a01cfd05 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -214,11 +214,7 @@ def barnstars end def photo_path(size = :medium) - if Rails.env == "production" - '//i.' + Rails.root.to_s + self.photo.url(size) - else - self.photo.url(size).gsub("//i.#{Rails.root}",'') - end + self.photo.url(size) end def first_time_poster diff --git a/app/views/admin/spam.html.erb b/app/views/admin/spam.html.erb index 04d640fb15..8fa7d77ca2 100644 --- a/app/views/admin/spam.html.erb +++ b/app/views/admin/spam.html.erb @@ -2,7 +2,7 @@

Spam moderation:

-

Moderators and admins have the ability to "spam" posts if they include inappropriate content, blatant advertising, or are otherwise problematic. If you're not sure, email organizers@<%= Rails.root %>. If we all work together, we can keep spam to a minimum; thanks for helping out!

+

Moderators and admins have the ability to "spam" posts if they include inappropriate content, blatant advertising, or are otherwise problematic. If you're not sure, email organizers@<%= request.host %>. If we all work together, we can keep spam to a minimum; thanks for helping out!


diff --git a/app/views/admin/users.html.erb b/app/views/admin/users.html.erb index a8b32af3ea..4c6cfd46a7 100644 --- a/app/views/admin/users.html.erb +++ b/app/views/admin/users.html.erb @@ -2,7 +2,7 @@

User moderation:

-

Moderators and admins have the ability to ban users if they post inappropriate content, blatant advertising, or are otherwise problematic. If you're not sure, email organizers@<%= Rails.root %>. If we all work together, we can keep spam to a minimum; thanks for helping out!

+

Moderators and admins have the ability to ban users if they post inappropriate content, blatant advertising, or are otherwise problematic. If you're not sure, email organizers@<%= request.host %>. If we all work together, we can keep spam to a minimum; thanks for helping out!


diff --git a/app/views/admin_mailer/notify_author_of_approval.html.erb b/app/views/admin_mailer/notify_author_of_approval.html.erb index 17970aff43..c5c99e48b0 100644 --- a/app/views/admin_mailer/notify_author_of_approval.html.erb +++ b/app/views/admin_mailer/notify_author_of_approval.html.erb @@ -1,7 +1,7 @@ -

Hi! Your post was approved by <%= @moderator.username %> (a community moderator) and is now visible in the Public Lab research feed. Thanks for contributing to open research!

+

Hi! Your post was approved by <%= @moderator.username %> (a community moderator) and is now visible in the Public Lab research feed. Thanks for contributing to open research!


-

See your post here: https://<%= Rails.root %><%= @node.path %>

+

See your post here: https://<%= ActionMailer::Base.default_url_options[:host] %><%= @node.path %>

-

Thanks for your patience! We've had to moderate first time posters due to problems with spam. Your posts will no longer be moderated, as long as you follow our content guidelines.

+

Thanks for your patience! We've had to moderate first time posters due to problems with spam. Your posts will no longer be moderated, as long as you follow our content guidelines.

diff --git a/app/views/admin_mailer/notify_moderators_of_approval.html.erb b/app/views/admin_mailer/notify_moderators_of_approval.html.erb index 9df76ef989..5faa59bb61 100644 --- a/app/views/admin_mailer/notify_moderators_of_approval.html.erb +++ b/app/views/admin_mailer/notify_moderators_of_approval.html.erb @@ -1,15 +1,15 @@ -

Post was approved by <%= @moderator.username %> after entering moderation queue <%= time_ago_in_words(@node.created_at) %> ago and is now visible in the Public Lab research feed. Thanks for helping to keep Public Lab a welcoming and spam-free space!

+

Post was approved by <%= @moderator.username %> after entering moderation queue <%= time_ago_in_words(@node.created_at) %> ago and is now visible in the Public Lab research feed. Thanks for helping to keep Public Lab a welcoming and spam-free space!

-

Now, reach out to welcome the new community member; thank them, just say hello, or help them revise/format their post in the comments. You can read and respond to the post here: https://<%= Rails.root %><%= @node.path %>

+

Now, reach out to welcome the new community member; thank them, just say hello, or help them revise/format their post in the comments. You can read and respond to the post here: https://<%= ActionMailer::Base.default_url_options[:host] %><%= @node.path %>

-

View <%= @node.author.name %>'s profile

+

View <%= @node.author.name %>'s profile


-

You received this email because you are a Public Lab community moderator

+

You received this email because you are a Public Lab community moderator

-

To discuss spam/abuse, forward this to moderators@<%= Rails.root %>

+

To discuss spam/abuse, forward this to moderators@<%= ActionMailer::Base.default_url_options[:host] %>

diff --git a/app/views/admin_mailer/notify_moderators_of_spam.html.erb b/app/views/admin_mailer/notify_moderators_of_spam.html.erb index 217d147985..06617a2528 100644 --- a/app/views/admin_mailer/notify_moderators_of_spam.html.erb +++ b/app/views/admin_mailer/notify_moderators_of_spam.html.erb @@ -1,19 +1,19 @@ -

Post was marked as spam by <%= @moderator.username %> after entering moderation queue <%= time_ago_in_words(@node.created_at) %> ago. The user was also banned from the site.

+

Post was marked as spam by <%= @moderator.username %> after entering moderation queue <%= time_ago_in_words(@node.created_at) %> ago. The user was also banned from the site.

-

If you feel this was an error, you can republish this post at Public Lab research feed. To discuss spam/abuse with other moderators, forward this to moderators@<%= Rails.root %>

+

If you feel this was an error, you can republish this post at Public Lab research feed. To discuss spam/abuse with other moderators, forward this to moderators@<%= ActionMailer::Base.default_url_options[:host] %>

-

If this moderation was due to failure to follow community content guidelines, and not advertising spam, consider reaching out to the poster to explain why you decided to moderate their content. Their email address is: <%= @node.author.mail %>

+

If this moderation was due to failure to follow community content guidelines, and not advertising spam, consider reaching out to the poster to explain why you decided to moderate their content. Their email address is: <%= @node.author.mail %>

Thanks for helping to keep Public Lab a welcoming and spam-free space!

-

View <%= @node.author.name %>'s profile

+

View <%= @node.author.name %>'s profile


-

You received this email because you are a Public Lab community moderator

+

You received this email because you are a Public Lab community moderator

-

To discuss spam/abuse, forward this to moderators@<%= Rails.root %>

+

To discuss spam/abuse, forward this to moderators@<%= ActionMailer::Base.default_url_options[:host] %>

diff --git a/app/views/admin_mailer/notify_node_moderators.html.erb b/app/views/admin_mailer/notify_node_moderators.html.erb index 1931c368f4..b11e094ceb 100644 --- a/app/views/admin_mailer/notify_node_moderators.html.erb +++ b/app/views/admin_mailer/notify_node_moderators.html.erb @@ -1,23 +1,23 @@ -

First-time poster <%= @node.author.name %> has submitted their first research note!

+

First-time poster <%= @node.author.name %> has submitted their first research note!

-

Please help to approve it or mark it as spam: https://<%= Rails.root %><%= @node.path %>

+

Please help to approve it or mark it as spam: https://<%= ActionMailer::Base.default_url_options[:host] %><%= @node.path %>

-

Approve or Spam

+

Approve or Spam


<% if @node.main_image %><% end %> -<%= raw auto_link(@node.latest.render_body_email, :sanitize => false) %> +<%= raw auto_link(@node.latest.render_body_email(ActionMailer::Base.default_url_options[:host]), :sanitize => false) %>
-Approve or Spam +Approve or Spam
-

You received this email because you are a Public Lab community moderator

+

You received this email because you are a Public Lab community moderator

-

To discuss spam/abuse, forward this to moderators@<%= Rails.root %>

+

To discuss spam/abuse, forward this to moderators@<%= ActionMailer::Base.default_url_options[:host] %>

diff --git a/app/views/answer_mailer/notify_answer_accept.html.erb b/app/views/answer_mailer/notify_answer_accept.html.erb index 3212fc47a0..171df755b6 100644 --- a/app/views/answer_mailer/notify_answer_accept.html.erb +++ b/app/views/answer_mailer/notify_answer_accept.html.erb @@ -1,7 +1,7 @@

Dear <%= @answer.author.name %>,

-

Your answer for the question <%= @answer.node.title %> has been accepted by the question author.

+

Your answer for the question <%= @answer.node.title %> has been accepted by the question author.

-

View your answer here: https://<%= Rails.root %><%= @answer.node.path(:question) %>#a<%= @answer.id %>

+

View your answer here: https://<%= ActionMailer::Base.default_url_options[:host] %><%= @answer.node.path(:question) %>#a<%= @answer.id %>

-

To change your email preferences, please visit https://<%= Rails.root %>/subscriptions.

+

To change your email preferences, please visit https://<%= ActionMailer::Base.default_url_options[:host] %>/subscriptions.

diff --git a/app/views/answer_mailer/notify_answer_like.html.erb b/app/views/answer_mailer/notify_answer_like.html.erb index 234ad4a658..a19fb635ba 100644 --- a/app/views/answer_mailer/notify_answer_like.html.erb +++ b/app/views/answer_mailer/notify_answer_like.html.erb @@ -1,7 +1,7 @@

Dear <%= @answer.author.name %>,

-

Public Lab contributor <%= @user.username %> just liked your answer to the question <%= @answer.node.title %>

+

Public Lab contributor <%= @user.username %> just liked your answer to the question <%= @answer.node.title %>

-

View your answer here: https://<%= Rails.root %><%= @answer.node.path(:question) %>#a<%= @answer.id %>

+

View your answer here: https://<%= ActionMailer::Base.default_url_options[:host] %><%= @answer.node.path(:question) %>#a<%= @answer.id %>

-

To change your email preferences, please visit https://<%= Rails.root %>/subscriptions.

+

To change your email preferences, please visit https://<%= ActionMailer::Base.default_url_options[:host] %>/subscriptions.

diff --git a/app/views/answer_mailer/notify_answer_likers_author.html.erb b/app/views/answer_mailer/notify_answer_likers_author.html.erb index 36c1960953..e8a575fb7c 100644 --- a/app/views/answer_mailer/notify_answer_likers_author.html.erb +++ b/app/views/answer_mailer/notify_answer_likers_author.html.erb @@ -1,19 +1,19 @@ -Hi! There's been a new answer posted for the question '<%= @answer.node.title %>' that you <% if @answer.node.liked_by(@user.uid) %>liked<% else %>also answered<% end %>. Do NOT reply to this email; click this link to see the answer: +Hi! There's been a new answer posted for the question '<%= @answer.node.title %>' that you <% if @answer.node.liked_by(@user.uid) %>liked<% else %>also answered<% end %>. Do NOT reply to this email; click this link to see the answer: -

https://<%= Rails.root %><%= @answer.node.path(:question) %>#a<%= @answer.id %>

+

https://<%= ActionMailer::Base.default_url_options[:host] %><%= @answer.node.path(:question) %>#a<%= @answer.id %>

-

Here is the answer that <%= @answer.author.name %> wrote:

+

Here is the answer that <%= @answer.author.name %> wrote:


-

<%= raw auto_link(RDiscount.new(@answer.body_email).to_html) %>

+

<%= raw auto_link(RDiscount.new(@answer.body_email(ActionMailer::Base.default_url_options[:host])).to_html) %>


-

You can comment on the answer at: https://<%= Rails.root %><%= @answer.node.path(:question) %>#answer-<%= @answer.id %>-comment

+

You can comment on the answer at: https://<%= ActionMailer::Base.default_url_options[:host] %><%= @answer.node.path(:question) %>#answer-<%= @answer.id %>-comment

-

Report abuse to: moderators@<%= Rails.root %>

+

Report abuse to: moderators@<%= ActionMailer::Base.default_url_options[:host] %>

diff --git a/app/views/answer_mailer/notify_question_author.html.erb b/app/views/answer_mailer/notify_question_author.html.erb index 0ee2af4d98..b1b0fa129c 100644 --- a/app/views/answer_mailer/notify_question_author.html.erb +++ b/app/views/answer_mailer/notify_question_author.html.erb @@ -1,12 +1,12 @@ -Hi! A new answer has been posted for your question '<%= @answer.node.title %>'. Do NOT reply to this email; click this link to see the answer: +Hi! A new answer has been posted for your question '<%= @answer.node.title %>'. Do NOT reply to this email; click this link to see the answer: -

https://<%= Rails.root %><%= @answer.node.path(:question) %>#a<%= @answer.id %>

+

https://<%= ActionMailer::Base.default_url_options[:host] %><%= @answer.node.path(:question) %>#a<%= @answer.id %>

-

Here is the answer that <%= @answer.author.name %> wrote:

+

Here is the answer that <%= @answer.author.name %> wrote:


-

<%= raw auto_link(RDiscount.new(@answer.body_email).to_html) %>

+

<%= raw auto_link(RDiscount.new(@answer.body_email(ActionMailer::Base.default_url_options[:host])).to_html) %>


@@ -14,8 +14,8 @@ Hi! A new answer has been posted for your question ' -

https://<%= Rails.root %><%= @comment.parent.path(:question) %>#answer-<%= @comment.aid %>-comment-<%= @comment.cid %>

+

https://<%= ActionMailer::Base.default_url_options[:host] %><%= @comment.parent.path(:question) %>#answer-<%= @comment.aid %>-comment-<%= @comment.cid %>

<% else %> -

https://<%= Rails.root %><%= @comment.node.path %>#c<%= @comment.cid %>

+

https://<%= ActionMailer::Base.default_url_options[:host] %><%= @comment.node.path %>#c<%= @comment.cid %>

<% end %> -

<%= @comment.author.name %> wrote:

+

<%= @comment.author.name %> wrote:


-

<%= raw auto_link(RDiscount.new(@comment.body_email).to_html) %>

+

<%= raw auto_link(RDiscount.new(@comment.body_email(ActionMailer::Base.default_url_options[:host])).to_html) %>


<% if @comment.parent.has_power_tag('question') %> -

Reply at: https://<%= Rails.root %><%= @comment.parent.path(:question) %>#answer-<%= @comment.aid %>-comment

+

Reply at: https://<%= ActionMailer::Base.default_url_options[:host] %><%= @comment.parent.path(:question) %>#answer-<%= @comment.aid %>-comment

<% else %> -

Reply at: https://<%= Rails.root %><%= @comment.node.path %>#comments

+

Reply at: https://<%= ActionMailer::Base.default_url_options[:host] %><%= @comment.node.path %>#comments

<% end %> -

Report abuse to: moderators@<%= Rails.root %>

+

Report abuse to: moderators@<%= ActionMailer::Base.default_url_options[:host] %>

diff --git a/app/views/comment_mailer/notify_answer_author.html.erb b/app/views/comment_mailer/notify_answer_author.html.erb index 5a5fe072d8..d94291392d 100644 --- a/app/views/comment_mailer/notify_answer_author.html.erb +++ b/app/views/comment_mailer/notify_answer_author.html.erb @@ -1,19 +1,19 @@ -Hi! There's been a new comment to your answer on '<%= @comment.parent.title %>'. Do NOT reply to this email; click this link to see the comment: +Hi! There's been a new comment to your answer on '<%= @comment.parent.title %>'. Do NOT reply to this email; click this link to see the comment: -

https://<%= Rails.root %><%= @comment.parent.path(:question) %>#answer-<%= @comment.aid %>-comment-<%= @comment.cid %>

+

https://<%= ActionMailer::Base.default_url_options[:host] %><%= @comment.parent.path(:question) %>#answer-<%= @comment.aid %>-comment-<%= @comment.cid %>

-

<%= @comment.author.name %> wrote:

+

<%= @comment.author.name %> wrote:


-

<%= raw auto_link(RDiscount.new(@comment.body_email).to_html) %>

+

<%= raw auto_link(RDiscount.new(@comment.body_email(ActionMailer::Base.default_url_options[:host])).to_html) %>


-

Reply at: https://<%= Rails.root %><%= @comment.parent.path(:question) %>#answer-<%= @comment.answer.id %>-comment

+

Reply at: https://<%= ActionMailer::Base.default_url_options[:host] %><%= @comment.parent.path(:question) %>#answer-<%= @comment.answer.id %>-comment

-

Report abuse to: moderators@<%= Rails.root %>

+

Report abuse to: moderators@<%= ActionMailer::Base.default_url_options[:host] %>

diff --git a/app/views/comment_mailer/notify_barnstar.html.erb b/app/views/comment_mailer/notify_barnstar.html.erb index 4b95cd9ebc..0497194ddd 100644 --- a/app/views/comment_mailer/notify_barnstar.html.erb +++ b/app/views/comment_mailer/notify_barnstar.html.erb @@ -1,15 +1,15 @@ -
<%= @giver.name %> has awarded you a Barnstar for your work in the research note "<%= @note.title %>". Do NOT reply to this email; click this link to respond: +<%= @giver.name %> has awarded you a Barnstar for your work in the research note "<%= @note.title %>". Do NOT reply to this email; click this link to respond: -

https://<%= Rails.root %><%= @note.path %>

+

https://<%= ActionMailer::Base.default_url_options[:host] %><%= @note.path %>

-The barnstar will appear on your profile, at https://<%= Rails.root %>/profile/<%= @note.author.name %> +The barnstar will appear on your profile, at https://<%= ActionMailer::Base.default_url_options[:host] %>/profile/<%= @note.author.name %>
-

Reply at: https://<%= Rails.root %><%= @note.path %>#comments

+

Reply at: https://<%= ActionMailer::Base.default_url_options[:host] %><%= @note.path %>#comments

-

Report abuse to: moderators@<%= Rails.root %>

+

Report abuse to: moderators@<%= ActionMailer::Base.default_url_options[:host] %>

diff --git a/app/views/comment_mailer/notify_callout.html.erb b/app/views/comment_mailer/notify_callout.html.erb index a697d4af5a..99e85479b3 100644 --- a/app/views/comment_mailer/notify_callout.html.erb +++ b/app/views/comment_mailer/notify_callout.html.erb @@ -1,32 +1,32 @@ <% if @comment.aid == 0 %> Hi! You were mentioned by <%= @comment.author.name %> in a comment on <% if @comment.parent.has_power_tag('question') %>the question <% else %>the research note <% end %><%= @comment.parent.title %>. <% else %> -Hi! You were mentioned by <%= @comment.author.name %> in a comment on the answer about <%= @comment.parent.title %> +Hi! You were mentioned by <%= @comment.author.name %> in a comment on the answer about <%= @comment.parent.title %> <% end %> Do NOT reply to this email; click this link to respond: <% if @comment.parent.has_power_tag('question') %> -

https://<%= Rails.root %><%= @comment.parent.path(:question) %>#answer-comment-<%= @comment.cid %>

+

https://<%= ActionMailer::Base.default_url_options[:host] %><%= @comment.parent.path(:question) %>#answer-comment-<%= @comment.cid %>

<% else %> -

https://<%= Rails.root %><%= @comment.node.path %>#c<%= @comment.cid %>

+

https://<%= ActionMailer::Base.default_url_options[:host] %><%= @comment.node.path %>#c<%= @comment.cid %>

<% end %> -

<%= @comment.author.name %> wrote:

+

<%= @comment.author.name %> wrote:


-

<%= raw auto_link(RDiscount.new(@comment.body_email).to_html) %>

+

<%= raw auto_link(RDiscount.new(@comment.body_email(ActionMailer::Base.default_url_options[:host])).to_html) %>


<% if @comment.parent.has_power_tag('question') %> -

Reply at: https://<%= Rails.root %><%= @comment.parent.path(:question) %>#answer-<%= @comment.aid %>-comment

+

Reply at: https://<%= ActionMailer::Base.default_url_options[:host] %><%= @comment.parent.path(:question) %>#answer-<%= @comment.aid %>-comment

<% else %> -

Reply at: https://<%= Rails.root %><%= @comment.node.path %>#comments

+

Reply at: https://<%= ActionMailer::Base.default_url_options[:host] %><%= @comment.node.path %>#comments

<% end %> -

Report abuse to: moderators@<%= Rails.root %>

+

Report abuse to: moderators@<%= ActionMailer::Base.default_url_options[:host] %>

diff --git a/app/views/comment_mailer/notify_note_author.html.erb b/app/views/comment_mailer/notify_note_author.html.erb index a2fceb33c5..4c17d91dd7 100644 --- a/app/views/comment_mailer/notify_note_author.html.erb +++ b/app/views/comment_mailer/notify_note_author.html.erb @@ -1,32 +1,32 @@ <% if @comment.parent.has_power_tag('question') %> -Hi! There's been a comment to your question '<%= @comment.parent.title %>'. +Hi! There's been a comment to your question '<%= @comment.parent.title %>'. <% else %> -Hi! There's been a response to your research note '<%= @comment.parent.title %>'. +Hi! There's been a response to your research note '<%= @comment.parent.title %>'. <% end %> Do NOT reply to this email; click this link to respond: <% if @comment.parent.has_power_tag('question') %> -

https://<%= Rails.root %><%= @comment.node.path(:question) %>#answer-comment-<%= @comment.cid %>

+

https://<%= ActionMailer::Base.default_url_options[:host] %><%= @comment.node.path(:question) %>#answer-comment-<%= @comment.cid %>

<% else %> -

https://<%= Rails.root %><%= @comment.node.path %>#c<%= @comment.cid %>

+

https://<%= ActionMailer::Base.default_url_options[:host] %><%= @comment.node.path %>#c<%= @comment.cid %>

<% end %> -

<%= @comment.author.name %> wrote:

+

<%= @comment.author.name %> wrote:


-

<%= raw auto_link(RDiscount.new(@comment.body_email).to_html) %>

+

<%= raw auto_link(RDiscount.new(@comment.body_email(ActionMailer::Base.default_url_options[:host])).to_html) %>


<% if @comment.parent.has_power_tag('question') %> -

Reply at: https://<%= Rails.root %><%= @comment.node.path(:question) %>#answer-0-comment

+

Reply at: https://<%= ActionMailer::Base.default_url_options[:host] %><%= @comment.node.path(:question) %>#answer-0-comment

<% else %> -

Reply at: https://<%= Rails.root %><%= @comment.node.path %>#c<%= @comment.cid %>

+

Reply at: https://<%= ActionMailer::Base.default_url_options[:host] %><%= @comment.node.path %>#c<%= @comment.cid %>

<% end %> -

Report abuse to: moderators@<%= Rails.root %>

+

Report abuse to: moderators@<%= ActionMailer::Base.default_url_options[:host] %>

diff --git a/app/views/dashboard/_activity.html.erb b/app/views/dashboard/_activity.html.erb index d7fb7b31f6..95b69422df 100644 --- a/app/views/dashboard/_activity.html.erb +++ b/app/views/dashboard/_activity.html.erb @@ -35,9 +35,9 @@   -
<%= t('dashboard._activity.community_scientists') %> <%= t('dashboard._activity.past_week') %> + <% end %> @@ -71,4 +71,4 @@ -
\ No newline at end of file +
diff --git a/app/views/editor/post.html.erb b/app/views/editor/post.html.erb index c8aff512ff..01b5949ba5 100644 --- a/app/views/editor/post.html.erb +++ b/app/views/editor/post.html.erb @@ -21,7 +21,7 @@

Here you can ask a question to the Public Lab community to help you in your environmental exploration. This is a great space to ask whether a method exists for identifying a possible pollutant, or ask about details of a specific technique for identifying a pollutant.

You can add more tags in the tags section below to further relate your question. You can also change the main tag of the question by renaming the part after question: tag

New to Public Lab? Take a minute to read the Q & A wiki before posting your question

-

Learn more »

+

Learn more »

<% else %> diff --git a/app/views/layouts/_footer.html.erb b/app/views/layouts/_footer.html.erb index 47ce8a4c34..e81c979cd3 100644 --- a/app/views/layouts/_footer.html.erb +++ b/app/views/layouts/_footer.html.erb @@ -3,7 +3,7 @@

Getting help

diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 8d2c918001..266ca885b7 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -10,7 +10,7 @@ <% end %> - + diff --git a/app/views/map/index.html.erb b/app/views/map/index.html.erb index a88787ce80..c4555cb9cd 100644 --- a/app/views/map/index.html.erb +++ b/app/views/map/index.html.erb @@ -64,7 +64,7 @@

Most of the maps in this archive were made in MapKnitter, a free and open source tool created by Public Lab contributors to turn aerial photos into maps.

-

To add your open source map to the archive, contact staff@<%= Rails.root %> and be prepared to provide some background and to tell the story of your map. Creative Commons and Public Domain maps are both accepted.

+

To add your open source map to the archive, contact staff@<%= request.host %> and be prepared to provide some background and to tell the story of your map. Creative Commons and Public Domain maps are both accepted.

diff --git a/app/views/notes/_responses.html.erb b/app/views/notes/_responses.html.erb index afcc516dea..874288d41e 100644 --- a/app/views/notes/_responses.html.erb +++ b/app/views/notes/_responses.html.erb @@ -5,7 +5,7 @@ <% @responses = DrupalTag.find_nodes_by_type("#{response_type}:#{@node.id}") %> <% @unpaginated = true %> -

0 %>"><%= t('notes._responses.post_' + response_type) %>

+

0 %>"><%= t('notes._responses.post_' + response_type) %>


diff --git a/app/views/notes/rss.rss.builder b/app/views/notes/rss.rss.builder index 96cad4ee56..1623cd8cdb 100644 --- a/app/views/notes/rss.rss.builder +++ b/app/views/notes/rss.rss.builder @@ -3,7 +3,7 @@ xml.rss :version => "2.0" do xml.channel do xml.title "Recent research notes on PublicLab.org" xml.description "Open source environmental science research at Public Lab" - xml.link "https://#{ Rails.root }/feed.rss" + xml.link "https://#{ request.host }/feed.rss" @notes.each do |node| @@ -15,8 +15,8 @@ xml.rss :version => "2.0" do xml.author node.author.name xml.pubDate node.created_at.to_s(:rfc822) #xml.link url_for :only_path => false, :controller => 'notes', :action => 'show', :id => node.nid - xml.link "https://" + Rails.root.to_s + node.path - xml.image "https://" + Rails.root.to_s + node.main_image.path(:default) if node.main_image + xml.link "https://" + request.host.to_s + node.path + xml.image "https://" + request.host.to_s + node.main_image.path(:default) if node.main_image xml.description auto_link(body, :sanitize => false) xml.guid url_for :only_path => false, :controller => 'notes', :action => 'show', :id => node.nid end diff --git a/app/views/password_reset_mailer/reset_notify.text.erb b/app/views/password_reset_mailer/reset_notify.text.erb index cbc1753e78..89d03ee18c 100644 --- a/app/views/password_reset_mailer/reset_notify.text.erb +++ b/app/views/password_reset_mailer/reset_notify.text.erb @@ -2,9 +2,9 @@ Dear <%= @user.username %>, Someone (probably you) has requested a reset of your password. To reset your password, click here: -https://<%= Rails.root %>/reset/key/<%= @key %> +https://<%= ActionMailer::Base.default_url_options[:host] %>/reset/key/<%= @key %> ========================= -This link may only be used once. If you believe you have received this in error, please ignore this email. Please contact web@<%= Rails.root %> if you believe your account is at risk. +This link may only be used once. If you believe you have received this in error, please ignore this email. Please contact web@<%= ActionMailer::Base.default_url_options[:host] %> if you believe your account is at risk. diff --git a/app/views/subscription_mailer/notify_node_creation.html.erb b/app/views/subscription_mailer/notify_node_creation.html.erb index 63334431fd..d986179d91 100644 --- a/app/views/subscription_mailer/notify_node_creation.html.erb +++ b/app/views/subscription_mailer/notify_node_creation.html.erb @@ -1,29 +1,29 @@

Dear <%= @user.name %>,

-

Public Lab contributor <%= @node.author.name %> just <% if @node.has_power_tag('question') %>asked a question<% else %>posted a new research note<% end %> entitled '<%= @node.title %>':

+

Public Lab contributor <%= @node.author.name %> just <% if @node.has_power_tag('question') %>asked a question<% else %>posted a new research note<% end %> entitled '<%= @node.title %>':

<% if @node.has_power_tag('question') %> -

Help him/her by posting an answer here: https://<%= Rails.root %><%= @node.path(:question) %>

+

Help him/her by posting an answer here: https://<%= ActionMailer::Base.default_url_options[:host] %><%= @node.path(:question) %>

<% else %> -

Read and respond to the post here: https://<%= Rails.root %><%= @node.path %>

+

Read and respond to the post here: https://<%= ActionMailer::Base.default_url_options[:host] %><%= @node.path %>

<% end %>
<% if @node.main_image %><% end %> -<%= raw auto_link(@node.latest.render_body_email, :sanitize => false) %> +<%= raw auto_link(@node.latest.render_body_email(ActionMailer::Base.default_url_options[:host]), :sanitize => false) %>
-<% if @user.role == "admin" || @user.role == "moderator" %>Does this look like spam? Spam<% end %> +<% if @user.role == "admin" || @user.role == "moderator" %>Does this look like spam? Spam<% end %>

You received this email because you are subscribed to the following tags: <%= @tags.to_a.collect(&:name).join(",") %>.

-

To change your preferences, please visit https://<%= Rails.root %>/subscriptions.

+

To change your preferences, please visit https://<%= ActionMailer::Base.default_url_options[:host] %>/subscriptions.

-

Report spam and abuse to: moderators@<%= Rails.root %>

+

Report spam and abuse to: moderators@<%= ActionMailer::Base.default_url_options[:host] %>

diff --git a/app/views/subscription_mailer/notify_note_liked.text.erb b/app/views/subscription_mailer/notify_note_liked.text.erb index 6af07586b8..f33a561094 100644 --- a/app/views/subscription_mailer/notify_note_liked.text.erb +++ b/app/views/subscription_mailer/notify_note_liked.text.erb @@ -1,12 +1,12 @@ Dear <%= @node.author.name %>, -Public Lab contributor <%= @user.username %> (https://<%= Rails.root %>/profile/<%= @user.username %>) just liked your <% if @node.has_power_tag('question') %>question<% else %>research note<% end %> entitled '<%= @node.title %>': +Public Lab contributor <%= @user.username %> (https://<%= ActionMailer::Base.default_url_options[:host] %>/profile/<%= @user.username %>) just liked your <% if @node.has_power_tag('question') %>question<% else %>research note<% end %> entitled '<%= @node.title %>': ------------------------- -View your post here: https://<%= Rails.root %><% if @node.has_power_tag('question') %><%= @node.path(:question) %><% else %><%= @node.path %><% end %> +View your post here: https://<%= ActionMailer::Base.default_url_options[:host] %><% if @node.has_power_tag('question') %><%= @node.path(:question) %><% else %><%= @node.path %><% end %> ========================= -To change your email preferences, please visit https://<%= Rails.root %>/subscriptions. +To change your email preferences, please visit https://<%= ActionMailer::Base.default_url_options[:host] %>/subscriptions. diff --git a/app/views/tag/icalendar.ics.erb b/app/views/tag/icalendar.ics.erb index 225e74e01d..b714118370 100644 --- a/app/views/tag/icalendar.ics.erb +++ b/app/views/tag/icalendar.ics.erb @@ -6,13 +6,13 @@ PRODID:-//publiclab/events//NONSGML v1.0//EN <% begin %> <% date = DateTime.parse(node.power_tag('date')) %> BEGIN:VEVENT -UID:do-not-reply@<%= Rails.root %> +UID:do-not-reply@<%= request.host %> DTSTAMP:<%= date.strftime("%Y%m%dT%H%M%S") %> DTSTART;VALUE=DATE:<%= date.strftime("%Y%m%d") %> DTEND;VALUE=DATE:<%= (date + 1.day).strftime("%Y%m%d") %> SUMMARY:<%= node.title %> <% if node.has_power_tag('location') %>LOCATION:<%= node.power_tag('location') %><% end %> -URL:https://<%= Rails.root %><%= node.path %> +URL:https://<%= request.host %><%= node.path %> END:VEVENT <% rescue %> <% end %> diff --git a/app/views/tag/rss.rss.builder b/app/views/tag/rss.rss.builder index a61c2aaf05..57289ff4c5 100644 --- a/app/views/tag/rss.rss.builder +++ b/app/views/tag/rss.rss.builder @@ -3,7 +3,7 @@ xml.rss :version => "2.0" do xml.channel do xml.title "Research tagged '#{params[:tagname]}'" xml.description "Open source environmental science research at Public Lab" - xml.link "https://#{Rails.root}/feed/tag/"+params[:tagname]+".rss" + xml.link "https://#{request.host}/feed/tag/"+params[:tagname]+".rss" @notes.each do |node| @@ -23,8 +23,8 @@ xml.rss :version => "2.0" do xml.pubDate node.created_at.to_s(:rfc822) end #xml.link url_for :only_path => false, :controller => 'notes', :action => 'show', :id => node.nid - xml.link "https://" + Rails.root.to_s + node.path - #xml.image "//#{ Rails.root }/"+node.main_image.path(:default) if node.main_image + xml.link "https://" + request.host.to_s + node.path + #xml.image "//#{ request.host }/"+node.main_image.path(:default) if node.main_image xml.description auto_link(node.latest.render_body, :sanitize => false) xml.guid url_for :only_path => false, :controller => 'notes', :action => 'show', :id => node.nid end diff --git a/app/views/users/rss.rss.builder b/app/views/users/rss.rss.builder index f9c572a918..afdff3efee 100644 --- a/app/views/users/rss.rss.builder +++ b/app/views/users/rss.rss.builder @@ -3,7 +3,7 @@ xml.rss :version => "2.0" do xml.channel do xml.title "Research by "+params[:author] xml.description "Open source environmental science research at Public Lab" - xml.link "https://#{ Rails.root }/feed/"+params[:author]+".rss" + xml.link "https://#{ request.host }/feed/"+params[:author]+".rss" @notes.each do |node| @@ -17,7 +17,7 @@ xml.rss :version => "2.0" do xml.author node.author.name xml.pubDate node.created_at.to_s(:rfc822) #xml.link url_for :only_path => false, :controller => 'notes', :action => 'show', :id => node.nid - xml.link "https://" + Rails.root.to_s + node.path + xml.link "https://" + request.host.to_s + node.path #xml.image "http://publiclaboratory.org/"+node.main_image.path(:default) if node.main_image xml.description auto_link(node.latest.render_body, :sanitize => false) xml.guid url_for :only_path => false, :controller => 'notes', :action => 'show', :id => node.nid diff --git a/config/environments/development.rb b/config/environments/development.rb index 6fff06c727..f95111de62 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -40,4 +40,8 @@ # force SSL #config.force_ssl = true + config.action_mailer.default_url_options = { + host: 'www.example.com' + } + end diff --git a/config/environments/production.rb b/config/environments/production.rb index 33fbabea7d..7c165cc56c 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -73,4 +73,9 @@ # Log the query plan for queries taking more than this (works # with SQLite, MySQL, and PostgreSQL) # config.active_record.auto_explain_threshold_in_seconds = 0.5 + + config.action_mailer.default_url_options = { + host: 'publiclab.org' + } + end diff --git a/config/environments/test.rb b/config/environments/test.rb index 1828d13f0a..19b017d540 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -35,4 +35,9 @@ # Print deprecation notices to the stderr config.active_support.deprecation = :stderr + + config.action_mailer.default_url_options = { + host: 'www.example.com' + } + end diff --git a/config/sunspot.yml b/config/sunspot.yml index bd7b45cdcb..e5f8628815 100644 --- a/config/sunspot.yml +++ b/config/sunspot.yml @@ -3,7 +3,7 @@ production: hostname: localhost port: 8983 log_level: WARNING - path: /solr/production + path: /solr/default # read_timeout: 2 # open_timeout: 0.5 diff --git a/test/fixtures/node_revisions.yml b/test/fixtures/node_revisions.yml index e3b819511f..9cf2b73bf8 100644 --- a/test/fixtures/node_revisions.yml +++ b/test/fixtures/node_revisions.yml @@ -47,7 +47,7 @@ unmoderated_spam_revision: body: Lots of stuff for sale moderated_spam_revision: - timestamp: <%= Time.now.to_i %> + timestamp: <%= Time.now.to_i - 1 %> nid: 4 uid: 3 status: 0 diff --git a/test/functional/admin_controller_test.rb b/test/functional/admin_controller_test.rb index b6fd8c4428..1e3f6b0f27 100644 --- a/test/functional/admin_controller_test.rb +++ b/test/functional/admin_controller_test.rb @@ -154,7 +154,7 @@ def teardown email = ActionMailer::Base.deliveries.last assert_not_nil email.to assert_not_nil email.bcc - assert_equal ["moderators@#{Rails.root}"], ActionMailer::Base.deliveries.last.to + assert_equal ["moderators@#{request_host}"], ActionMailer::Base.deliveries.last.to # title same as initial for email client threading assert_equal "[New Public Lab poster needs moderation] " + node.title, email.subject end @@ -174,7 +174,7 @@ def teardown email = ActionMailer::Base.deliveries.last assert_not_nil email.to assert_not_nil email.bcc - assert_equal ["moderators@#{Rails.root}"], ActionMailer::Base.deliveries.last.to + assert_equal ["moderators@#{request_host}"], ActionMailer::Base.deliveries.last.to # title same as initial for email client threading assert_equal "[New Public Lab poster needs moderation] " + node.title, email.subject end @@ -226,7 +226,7 @@ def teardown # test the moderator notification email = ActionMailer::Base.deliveries[1] assert_equal "[New Public Lab poster needs moderation] " + node.title, email.subject - assert_equal ["moderators@#{Rails.root}"], email.to + assert_equal ["moderators@#{request_host}"], email.to # test general subscription notices # (we test the final one, but there are many) @@ -358,7 +358,7 @@ def teardown # test the moderator notification email = ActionMailer::Base.deliveries.last assert_equal "[New Public Lab poster needs moderation] " + node.title, email.subject - assert_equal ["moderators@#{Rails.root}"], email.to + assert_equal ["moderators@#{request_host}"], email.to assert_not_nil email.bcc end diff --git a/test/functional/tag_controller_test.rb b/test/functional/tag_controller_test.rb index f3c1095690..8bc26b7c2c 100644 --- a/test/functional/tag_controller_test.rb +++ b/test/functional/tag_controller_test.rb @@ -101,7 +101,7 @@ def setup ApplicationController.any_instance.stubs(:current_user).returns(User.first) assert_difference 'DrupalComment.count' do post :barnstar, :nid => DrupalNode.last.nid, :star => "basic" - assert_equal "#{User.first.username} awards a barnstar to #{DrupalNode.last.drupal_users.name} for their awesome contribution!", DrupalComment.last.body + assert_equal "[@#{User.first.username}](/profile/#{User.first.username}) awards a barnstar to #{DrupalNode.last.drupal_users.name} for their awesome contribution!", DrupalComment.last.body end end diff --git a/test/integration/moderate_and_ban_test.rb b/test/integration/moderate_and_ban_test.rb index 26e2c55619..8f9bf470a4 100644 --- a/test/integration/moderate_and_ban_test.rb +++ b/test/integration/moderate_and_ban_test.rb @@ -67,12 +67,12 @@ class ModerateAndBanTest < ActionDispatch::IntegrationTest assert_response :redirect follow_redirect! # in application_controller.rb: - assert_equal "The user '#{u.username}' has been placed in moderation; please see our moderation policy and contact moderators@#{Rails.root} if you believe this is in error.", flash[:warning] + assert_equal "The user '#{u.username}' has been placed in moderation; please see our moderation policy and contact moderators@#{request_host} if you believe this is in error.", flash[:warning] get node(:moderated_user_note).path assert_response :success - assert_equal "The user '#{u.username}' has been placed in moderation and will not be able to respond to comments.", flash[:warning] + assert_equal "The user '#{u.username}' has been placed in moderation and will not be able to respond to comments.", flash[:warning] get node(:question3).path # a Q by unmoderated_user @@ -82,7 +82,7 @@ class ModerateAndBanTest < ActionDispatch::IntegrationTest assert_response :success # in application_controller.rb: - assert_equal "The user '#{u.username}' has been placed in moderation and will not be able to respond to comments.", flash[:warning] + assert_equal "The user '#{u.username}' has been placed in moderation and will not be able to respond to comments.", flash[:warning] get "/profile/#{u.username}" diff --git a/test/test_helper.rb b/test/test_helper.rb index 5a91ddba08..347bd3df0a 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -25,6 +25,11 @@ class ActiveSupport::TestCase fixtures :all # Add more helper methods to be used by all tests here... + + def request_host + ActionMailer::Base.default_url_options[:host] + end + end def available_testing_locales diff --git a/test/unit/admin_mailer_test.rb b/test/unit/admin_mailer_test.rb index 7cd02aad7d..ee7600bb02 100644 --- a/test/unit/admin_mailer_test.rb +++ b/test/unit/admin_mailer_test.rb @@ -21,11 +21,11 @@ class AdminMailerTest < ActionMailer::TestCase assert_not_nil email.to assert_not_nil email.bcc - assert_equal ["moderators@#{Rails.root}"], ActionMailer::Base.deliveries.last.to + assert_equal ["moderators@#{request_host}"], ActionMailer::Base.deliveries.last.to assert_equal moderators.collect(&:email), ActionMailer::Base.deliveries.last.bcc assert_equal "[New Public Lab poster needs moderation] " + node.title, email.subject - assert email.body.include?("First-time poster #{node.author.name} has submitted their first research note!") - assert email.body.include?(node.latest.render_body_email) + assert email.body.include?("First-time poster #{node.author.name} has submitted their first research note!") + assert email.body.include?(node.latest.render_body_email(request_host)) end @@ -46,7 +46,7 @@ class AdminMailerTest < ActionMailer::TestCase assert_not_nil email.to assert_equal [node.author.mail], email.to assert_equal "[Public Lab] Your post was approved!", email.subject - assert email.body.include?("Hi! Your post was approved by #{moderator.username} (a community moderator) and is now visible in the Public Lab research feed. Thanks for contributing to open research!") + assert email.body.include?("Hi! Your post was approved by #{moderator.username} (a community moderator) and is now visible in the Public Lab research feed. Thanks for contributing to open research!") end @@ -67,12 +67,12 @@ class AdminMailerTest < ActionMailer::TestCase email = ActionMailer::Base.deliveries.last assert_not_nil email.to assert_not_nil email.bcc - assert_equal ["moderators@#{Rails.root}"], ActionMailer::Base.deliveries.last.to + assert_equal ["moderators@#{request_host}"], ActionMailer::Base.deliveries.last.to assert_equal moderators.collect(&:email), ActionMailer::Base.deliveries.last.bcc # title same as initial for email client threading assert_equal "[New Public Lab poster needs moderation] " + node.title, email.subject time_ago = time_ago_in_words(node.created_at) - assert email.body.include?("Post was approved by #{moderator.username} after entering moderation queue #{time_ago} ago and is now visible in the Public Lab research feed. Thanks for helping to keep Public Lab a welcoming and spam-free space!") + assert email.body.include?("Post was approved by #{moderator.username} after entering moderation queue #{time_ago} ago and is now visible in the Public Lab research feed. Thanks for helping to keep Public Lab a welcoming and spam-free space!") end @@ -95,12 +95,12 @@ class AdminMailerTest < ActionMailer::TestCase email = ActionMailer::Base.deliveries.last assert_not_nil email.to assert_not_nil email.bcc - assert_equal ["moderators@#{Rails.root}"], ActionMailer::Base.deliveries.last.to + assert_equal ["moderators@#{request_host}"], ActionMailer::Base.deliveries.last.to assert_equal moderators.collect(&:email), ActionMailer::Base.deliveries.last.bcc # title same as initial for email client threading assert_equal "[New Public Lab poster needs moderation] " + node.title, email.subject time_ago = time_ago_in_words(node.created_at) - assert email.body.include?("Post was marked as spam by #{moderator.username} after entering moderation queue #{time_ago} ago.") + assert email.body.include?("Post was marked as spam by #{moderator.username} after entering moderation queue #{time_ago} ago.") end end diff --git a/test/unit/answer_mailer_test.rb b/test/unit/answer_mailer_test.rb index b205515ecc..b73f949969 100644 --- a/test/unit/answer_mailer_test.rb +++ b/test/unit/answer_mailer_test.rb @@ -10,10 +10,10 @@ class AnswerMailerTest < ActionMailer::TestCase assert !ActionMailer::Base.deliveries.empty? email = ActionMailer::Base.deliveries.last - assert_equal ["do-not-reply@#{Rails.root}"], email.from + assert_equal ["do-not-reply@#{request_host}"], email.from assert_equal [user.email], email.to assert_equal "[PublicLab] New answer to Question: " + answer.node.title, email.subject - assert email.body.include?("Hi! A new answer has been posted for your question '#{answer.node.title}'") + assert email.body.include?("Hi! A new answer has been posted for your question '#{answer.node.title}'") end test "notify other answer authors" do @@ -25,10 +25,10 @@ class AnswerMailerTest < ActionMailer::TestCase assert !ActionMailer::Base.deliveries.empty? email = ActionMailer::Base.deliveries.last - assert_equal ["do-not-reply@#{Rails.root}"], email.from + assert_equal ["do-not-reply@#{request_host}"], email.from assert_equal [user.email], email.to assert_equal "[PublicLab] New answer to Question: " + answer.node.title, email.subject - assert email.body.include?("Hi! There's been a new answer posted for the question '#{answer.node.title}' that you also answered") + assert email.body.include?("Hi! There's been a new answer posted for the question '#{answer.node.title}' that you also answered") end test "notify user who liked the question" do @@ -40,10 +40,10 @@ class AnswerMailerTest < ActionMailer::TestCase assert !ActionMailer::Base.deliveries.empty? email = ActionMailer::Base.deliveries.last - assert_equal ["do-not-reply@#{Rails.root}"], email.from + assert_equal ["do-not-reply@#{request_host}"], email.from assert_equal [user.email], email.to assert_equal "[PublicLab] New answer to Question: " + answer.node.title, email.subject - assert email.body.include?("Hi! There's been a new answer posted for the question '#{answer.node.title}' that you liked") + assert email.body.include?("Hi! There's been a new answer posted for the question '#{answer.node.title}' that you liked") end test "notify answer author when answer is accepted" do @@ -55,10 +55,10 @@ class AnswerMailerTest < ActionMailer::TestCase assert !ActionMailer::Base.deliveries.empty? email = ActionMailer::Base.deliveries.last - assert_equal ["do-not-reply@#{Rails.root}"], email.from + assert_equal ["do-not-reply@#{request_host}"], email.from assert_equal [user.email], email.to assert_equal "[PublicLab] Your answer has been accepted", email.subject - assert email.body.include?("Your answer for the question #{answer.node.title} has been accepted") + assert email.body.include?("Your answer for the question #{answer.node.title} has been accepted") end test "notify answer author when answer is liked" do @@ -70,9 +70,9 @@ class AnswerMailerTest < ActionMailer::TestCase assert !ActionMailer::Base.deliveries.empty? email = ActionMailer::Base.deliveries.last - assert_equal ["do-not-reply@#{Rails.root}"], email.from + assert_equal ["do-not-reply@#{request_host}"], email.from assert_equal [answer.author.email], email.to assert_equal "[PublicLab] #{user.username} liked your answer to: " + answer.node.title, email.subject - assert email.body.include?("Public Lab contributor #{user.username} just liked your answer to the question #{answer.node.title}") + assert email.body.include?("Public Lab contributor #{user.username} just liked your answer to the question #{answer.node.title}") end end diff --git a/test/unit/comment_mailer_test.rb b/test/unit/comment_mailer_test.rb index 0fbcf00086..f8cf443e99 100644 --- a/test/unit/comment_mailer_test.rb +++ b/test/unit/comment_mailer_test.rb @@ -10,10 +10,10 @@ class CommentMailerTest < ActionMailer::TestCase assert !ActionMailer::Base.deliveries.empty? email = ActionMailer::Base.deliveries.last - assert_equal ["do-not-reply@#{Rails.root}"], email.from + assert_equal ["do-not-reply@#{request_host}"], email.from assert_equal [user.email], email.to assert_equal "New comment on '" + comment.parent.title + "'", email.subject - assert email.body.include?("

https://#{Rails.root}#{comment.parent.path(:question)}#answer-#{comment.aid}-comment-#{comment.cid}

") + assert email.body.include?("

https://#{request_host}#{comment.parent.path(:question)}#answer-#{comment.aid}-comment-#{comment.cid}

") end test "notify note author" do @@ -25,10 +25,10 @@ class CommentMailerTest < ActionMailer::TestCase assert !ActionMailer::Base.deliveries.empty? email = ActionMailer::Base.deliveries.last - assert_equal ["do-not-reply@#{Rails.root}"], email.from + assert_equal ["do-not-reply@#{request_host}"], email.from assert_equal [user.email], email.to assert_equal "New comment on '" + comment.parent.title + "'", email.subject - assert email.body.include?("Hi! There's been a comment to your question '#{comment.parent.title}'") + assert email.body.include?("Hi! There's been a comment to your question '#{comment.parent.title}'") end test "notify callout" do @@ -40,7 +40,7 @@ class CommentMailerTest < ActionMailer::TestCase assert !ActionMailer::Base.deliveries.empty? email = ActionMailer::Base.deliveries.last - assert_equal ["do-not-reply@#{Rails.root}"], email.from + assert_equal ["do-not-reply@#{request_host}"], email.from assert_equal [user.email], email.to assert_equal "You were mentioned in a comment.", email.subject assert email.body.include?("Hi! You were mentioned by #{comment.author.name} in a comment on the question #{comment.parent.title}") @@ -55,9 +55,9 @@ class CommentMailerTest < ActionMailer::TestCase assert !ActionMailer::Base.deliveries.empty? email = ActionMailer::Base.deliveries.last - assert_equal ["do-not-reply@#{Rails.root}"], email.from + assert_equal ["do-not-reply@#{request_host}"], email.from assert_equal [user.email], email.to assert_equal "New comment on your answer on '" + comment.parent.title + "'", email.subject - assert email.body.include?("Hi! There's been a new comment to your answer on '#{comment.parent.title}'") + assert email.body.include?("Hi! There's been a new comment to your answer on '#{comment.parent.title}'") end end diff --git a/test/unit/drupal_node_revision_test.rb b/test/unit/drupal_node_revision_test.rb index 0a256f110c..493dae4157 100644 --- a/test/unit/drupal_node_revision_test.rb +++ b/test/unit/drupal_node_revision_test.rb @@ -79,7 +79,7 @@ class DrupalNodeRevisionsTest < ActiveSupport::TestCase test "should render correct link for images in email" do revision = node_revisions(:email) - assert_includes revision.render_body_email, '//i.publiclab.org/system/images/photos/000/016/229/original/admin_tooltip.png' + assert_includes revision.render_body_email(request_host), '//i.publiclab.org/system/images/photos/000/016/229/original/admin_tooltip.png' end test "should add tags for hashtags" do diff --git a/test/unit/subscription_mailer_test.rb b/test/unit/subscription_mailer_test.rb index 83c2144852..4b68290b90 100644 --- a/test/unit/subscription_mailer_test.rb +++ b/test/unit/subscription_mailer_test.rb @@ -11,10 +11,10 @@ class SubscriptionMailerTest < ActionMailer::TestCase assert !ActionMailer::Base.deliveries.empty? email = ActionMailer::Base.deliveries.last - assert_equal ["do-not-reply@#{Rails.root}"], email.from + assert_equal ["do-not-reply@#{request_host}"], email.from assert_equal [subscribers.values.last[:user].email], email.to assert_equal "[PublicLab] " + node.title, email.subject - assert email.body.include?("Public Lab contributor #{node.author.name} just posted a new research note") + assert email.body.include?("Public Lab contributor #{node.author.name} just posted a new research note") end test "notify subscribers on creation of a question" do @@ -26,10 +26,10 @@ class SubscriptionMailerTest < ActionMailer::TestCase assert !ActionMailer::Base.deliveries.empty? email = ActionMailer::Base.deliveries.last - assert_equal ["do-not-reply@#{Rails.root}"], email.from + assert_equal ["do-not-reply@#{request_host}"], email.from assert_equal [subscribers.values.last[:user].email], email.to assert_equal "[PublicLab] Question: " + node.title, email.subject - assert email.body.include?("Public Lab contributor #{node.author.name} just asked a question") + assert email.body.include?("Public Lab contributor #{node.author.name} just asked a question") end test "notify note author when user likes a research note" do @@ -41,10 +41,10 @@ class SubscriptionMailerTest < ActionMailer::TestCase assert !ActionMailer::Base.deliveries.empty? email = ActionMailer::Base.deliveries.last - assert_equal ["do-not-reply@#{Rails.root}"], email.from + assert_equal ["do-not-reply@#{request_host}"], email.from assert_equal [node.author.email], email.to assert_equal "[PublicLab] #{user.username} liked your research note", email.subject - assert email.body.include?("Public Lab contributor #{user.username} (https://#{Rails.root}/profile/#{user.username}) just liked your research note") + assert email.body.include?("Public Lab contributor #{user.username} (https://#{request_host}/profile/#{user.username}) just liked your research note") end test "notify question author when user likes a question" do @@ -56,9 +56,9 @@ class SubscriptionMailerTest < ActionMailer::TestCase assert !ActionMailer::Base.deliveries.empty? email = ActionMailer::Base.deliveries.last - assert_equal ["do-not-reply@#{Rails.root}"], email.from + assert_equal ["do-not-reply@#{request_host}"], email.from assert_equal [node.author.email], email.to assert_equal "[PublicLab] #{user.username} liked your question", email.subject - assert email.body.include?("Public Lab contributor #{user.username} (https://#{Rails.root}/profile/#{user.username}) just liked your question") + assert email.body.include?("Public Lab contributor #{user.username} (https://#{request_host}/profile/#{user.username}) just liked your question") end end