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 += '
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!
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!
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.
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 %>
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 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!
<% 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
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:
-
<%= 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:
-
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:
-
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:
-
-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 %>
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') %>
-
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') %>
-
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.from_other') %> <%= t('dashboard._activity.community_scientists') %> <%= t('dashboard._activity.past_week') %> |
+ <%= t('dashboard._activity.from_other') %> <%= t('dashboard._activity.community_scientists') %> <%= t('dashboard._activity.past_week') %>
<% if current_user %>
- <%= t('dashboard._activity.your_work') %>
+ |<%= t('dashboard._activity.your_work') %>
<% 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
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/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.
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?("
")
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