don't hardcode "Lobsters" and "lobste.rs" everywhere, use Rails.application.{name,domain}
This commit is contained in:
parent
7e71908f3d
commit
a471eb180a
27
README.md
27
README.md
|
@ -53,14 +53,31 @@ MariaDB have been tested) database, username, and password and put them in a
|
|||
|
||||
lobsters$ rake db:schema:load
|
||||
|
||||
* Create a `config/initializers/secret_token.rb` file, using a randomly generated key from the output of `rake secret`:
|
||||
* Create a `config/initializers/secret_token.rb` file, using a randomly
|
||||
generated key from the output of `rake secret`:
|
||||
|
||||
Lobsters::Application.config.secret_token = 'your random secret here'
|
||||
|
||||
* (Optional, only needed for the search engine) Install Sphinx. Build Sphinx config and start server:
|
||||
* (Optional, only needed for the search engine) Install Sphinx. Build Sphinx
|
||||
config and start server:
|
||||
|
||||
lobsters$ rake thinking_sphinx:rebuild
|
||||
|
||||
* Define your site's name and default domain, which are used in various places,
|
||||
in a `config/initializers/production.rb` or similar file:
|
||||
|
||||
class << Rails.application
|
||||
def domain
|
||||
"example.com"
|
||||
end
|
||||
|
||||
def name
|
||||
"Example News"
|
||||
end
|
||||
end
|
||||
|
||||
Rails.application.routes.default_url_options[:host] = Rails.application.domain
|
||||
|
||||
* Create an initial administrator user and at least one tag:
|
||||
|
||||
lobsters$ rails console
|
||||
|
@ -74,11 +91,7 @@ MariaDB have been tested) database, username, and password and put them in a
|
|||
irb(main):006:0> t.tag = "test"
|
||||
irb(main):007:0> t.save
|
||||
|
||||
* The default development hostname is defined as `lobsters.localhost:3000`.
|
||||
You should define this in `/etc/hosts` (or through DNS) to point to
|
||||
`127.0.0.1`.
|
||||
|
||||
* Run the Rails server in development mode. You should be able to login to
|
||||
`http://lobsters.localhost:3000` with your `test` user:
|
||||
`http://localhost:3000` with your new `test` user:
|
||||
|
||||
lobsters$ rails server
|
||||
|
|
|
@ -43,9 +43,10 @@ class SignupController < ApplicationController
|
|||
if @new_user.save
|
||||
@invitation.destroy
|
||||
session[:u] = @new_user.session_token
|
||||
flash[:success] = "Welcome to Lobsters, #{@new_user.username}!"
|
||||
flash[:success] = "Welcome to #{Rails.application.name}, " <<
|
||||
"#{@new_user.username}!"
|
||||
|
||||
Countinual.count!("lobsters.users.created", "+1")
|
||||
Countinual.count!("#{Rails.application.shortname}.users.created", "+1")
|
||||
|
||||
return redirect_to "/signup/invite"
|
||||
else
|
||||
|
|
|
@ -20,7 +20,8 @@ class StoriesController < ApplicationController
|
|||
Vote.vote_thusly_on_story_or_comment_for_user_because(1, @story.id,
|
||||
nil, @user.id, nil)
|
||||
|
||||
Countinual.count!("lobsters.stories.submitted", "+1")
|
||||
Countinual.count!("#{Rails.application.shortname}.stories.submitted",
|
||||
"+1")
|
||||
|
||||
return redirect_to @story.comments_url
|
||||
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
class EmailMessage < ActionMailer::Base
|
||||
default :from => "nobody@lobste.rs"
|
||||
default :from => "#{Rails.application.name} " <<
|
||||
"<nobody@#{Rails.application.domain}>"
|
||||
|
||||
def notify(message, user)
|
||||
@message = message
|
||||
@user = user
|
||||
|
||||
mail(:to => user.email, :from => "Lobsters <nobody@lobste.rs>",
|
||||
:subject => "[Lobsters] Private Message from " <<
|
||||
"#{message.author.username}: #{message.subject}")
|
||||
mail(
|
||||
:to => user.email,
|
||||
:subject => "[#{Rails.application.name}] Private Message from " <<
|
||||
"#{message.author.username}: #{message.subject}"
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,21 +1,26 @@
|
|||
class EmailReply < ActionMailer::Base
|
||||
default :from => "nobody@lobste.rs"
|
||||
default :from => "#{Rails.application.name} " <<
|
||||
"<nobody@#{Rails.application.domain}>"
|
||||
|
||||
def reply(comment, user)
|
||||
@comment = comment
|
||||
@user = user
|
||||
|
||||
mail(:to => user.email, :from => "Lobsters <nobody@lobste.rs>",
|
||||
:subject => "[Lobsters] Reply from #{comment.user.username} on " <<
|
||||
"#{comment.story.title}")
|
||||
mail(
|
||||
:to => user.email,
|
||||
:subject => "[#{Rails.application.name}] Reply from " <<
|
||||
"#{comment.user.username} on #{comment.story.title}"
|
||||
)
|
||||
end
|
||||
|
||||
def mention(comment, user)
|
||||
@comment = comment
|
||||
@user = user
|
||||
|
||||
mail(:to => user.email, :from => "Lobsters <nobody@lobste.rs>",
|
||||
:subject => "[Lobsters] Mention from #{comment.user.username} on " <<
|
||||
"#{comment.story.title}")
|
||||
mail(
|
||||
:to => user.email,
|
||||
:subject => "[#{Rails.application.name}] Mention from " <<
|
||||
"#{comment.user.username} on #{comment.story.title}"
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,9 +1,14 @@
|
|||
class InvitationMailer < ActionMailer::Base
|
||||
default :from => "#{Rails.application.name} " <<
|
||||
"<nobody@#{Rails.application.domain}>"
|
||||
|
||||
def invitation(invitation)
|
||||
@invitation = invitation
|
||||
|
||||
mail(:to => invitation.email,
|
||||
:from => "Lobsters Invitation <nobody@lobste.rs>",
|
||||
subject: "[Lobsters] Welcome to Lobsters")
|
||||
mail(
|
||||
:to => invitation.email,
|
||||
subject: "[#{Rails.application.name}] Welcome to " <<
|
||||
Rails.application.name
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,9 +1,14 @@
|
|||
class PasswordReset < ActionMailer::Base
|
||||
default :from => "#{Rails.application.name} " <<
|
||||
"<nobody@#{Rails.application.domain}>"
|
||||
|
||||
def password_reset_link(user, ip)
|
||||
@user = user
|
||||
@ip = ip
|
||||
|
||||
mail(:to => user.email, :from => "Lobsters <nobody@lobste.rs>",
|
||||
:subject => "[Lobsters] Reset your password")
|
||||
mail(
|
||||
:to => user.email,
|
||||
:subject => "[#{Rails.application.name}] Reset your password"
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -139,8 +139,8 @@ class Comment < ActiveRecord::Base
|
|||
|
||||
if u.pushover_mentions? && u.pushover_user_key.present?
|
||||
Pushover.push(u.pushover_user_key, u.pushover_device, {
|
||||
:title => "Lobsters mention by #{self.user.username} on " <<
|
||||
self.story.title,
|
||||
:title => "#{Rails.application.name} mention by " <<
|
||||
"#{self.user.username} on #{self.story.title}",
|
||||
:message => self.plaintext_comment,
|
||||
:url => self.url,
|
||||
:url_title => "Reply to #{self.user.username}",
|
||||
|
@ -164,8 +164,8 @@ class Comment < ActiveRecord::Base
|
|||
|
||||
if u.pushover_replies? && u.pushover_user_key.present?
|
||||
Pushover.push(u.pushover_user_key, u.pushover_device, {
|
||||
:title => "Lobsters reply from #{self.user.username} on " <<
|
||||
"#{self.story.title}",
|
||||
:title => "#{Rails.application.name} reply from " <<
|
||||
"#{self.user.username} on #{self.story.title}",
|
||||
:message => self.plaintext_comment,
|
||||
:url => self.url,
|
||||
:url_title => "Reply to #{self.user.username}",
|
||||
|
@ -179,7 +179,7 @@ class Comment < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def log_to_countinual
|
||||
Countinual.count!("lobsters.comments.submitted", "+1")
|
||||
Countinual.count!("#{Rails.application.shortname}.comments.submitted", "+1")
|
||||
end
|
||||
|
||||
def delete_for_user(user)
|
||||
|
@ -289,7 +289,7 @@ class Comment < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def mailing_list_message_id
|
||||
"comment.#{short_id}.#{created_at.to_i}@lobste.rs"
|
||||
"comment.#{short_id}.#{created_at.to_i}@#{Rails.application.domain}"
|
||||
end
|
||||
|
||||
def plaintext_comment
|
||||
|
|
|
@ -45,8 +45,8 @@ class Message < ActiveRecord::Base
|
|||
self.recipient.pushover_user_key.present?
|
||||
Pushover.push(self.recipient.pushover_user_key,
|
||||
self.recipient.pushover_device, {
|
||||
:title => "Lobsters message from #{self.author.username}: " <<
|
||||
"#{self.subject}",
|
||||
:title => "#{Rails.application.name} message from " <<
|
||||
"#{self.author.username}: #{self.subject}",
|
||||
:message => self.plaintext_body,
|
||||
:url => self.url,
|
||||
:url_title => "Reply to #{self.author.username}",
|
||||
|
|
|
@ -229,7 +229,8 @@ class Story < ActiveRecord::Base
|
|||
s = Sponge.new
|
||||
s.timeout = 3
|
||||
@fetched_content = s.fetch(self.url, :get, nil, nil,
|
||||
{ "User-agent" => "lobste.rs! for #{for_remote_ip}" }, 3)
|
||||
{ "User-agent" => "#{Rails.application.domain} for #{for_remote_ip}" },
|
||||
3)
|
||||
rescue
|
||||
end
|
||||
|
||||
|
@ -284,7 +285,7 @@ class Story < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def mailing_list_message_id
|
||||
"story.#{short_id}.#{created_at.to_i}@lobste.rs"
|
||||
"story.#{short_id}.#{created_at.to_i}@#{Rails.application.domain}"
|
||||
end
|
||||
|
||||
@_tags_a = []
|
||||
|
|
|
@ -133,7 +133,7 @@ class User < ActiveRecord::Base
|
|||
|
||||
def linkified_about
|
||||
# most users are probably mentioning "@username" to mean a twitter url, not
|
||||
# a link to a lobste.rs profile
|
||||
# a link to a profile on this site
|
||||
Markdowner.to_html(self.about, { :disable_profile_links => true })
|
||||
end
|
||||
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
<% coder = HTMLEntities.new %>
|
||||
<rss version="2.0">
|
||||
<channel>
|
||||
<title>lobste.rs<%= @title.present? ? ": " + h(@title) : "" %></title>
|
||||
<title><%= Rails.application.name %><%= @title.present? ?
|
||||
": " + h(@title) : "" %></title>
|
||||
<description><%= @title %></description>
|
||||
<link><%= root_url %>comments</link>
|
||||
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
<% coder = HTMLEntities.new %>
|
||||
<rss version="2.0">
|
||||
<channel>
|
||||
<title>lobste.rs<%= @title.present? ? ": " + h(@title) : "" %></title>
|
||||
<title><%= Rails.application.name %><%= @title.present? ?
|
||||
": " + h(@title) : "" %></title>
|
||||
<description><%= @title %></description>
|
||||
<link><%= root_url + (@newest ? "newest" : "") %></link>
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
Hello <%= @invitation.email %>,
|
||||
|
||||
The user <%= @invitation.user.username %> has invited you to the website Lobsters<%= @invitation.memo.present? ? raw(":\n\n #{@invitation.memo}") : "." %>
|
||||
The user <%= @invitation.user.username %> has invited you to the website <%= Rails.application.name %><%= @invitation.memo.present? ? raw(":\n\n #{@invitation.memo}") : "." %>
|
||||
|
||||
To create an account, visit the URL below:
|
||||
|
||||
|
|
|
@ -14,7 +14,8 @@
|
|||
<link rev="canonical" rel="self alternate shorter shorturl shortlink"
|
||||
href="<%= @short_url %>" />
|
||||
<% end %>
|
||||
<title><%= @title.present? ? "#{@title} | Lobsters" : "Lobsters" %></title>
|
||||
<title><%= @title.present? ? "#{@title} | " : "" %><%=
|
||||
Rails.application.name %></title>
|
||||
<%= stylesheet_link_tag "application", :media => "all" %>
|
||||
<%= javascript_include_tag "application" %>
|
||||
<%= csrf_meta_tags %>
|
||||
|
@ -33,7 +34,7 @@
|
|||
<div id="headerleft">
|
||||
<a id="l_holder" style="background-color: #<%= sprintf("%02x%02x%02x",
|
||||
[ 255, (@traffic * 7).floor + 50.0 ].min, 0, 0) %>;" href="/"
|
||||
title="Lobsters (<%= @traffic.to_i %>)"></a>
|
||||
title="<%= Rails.application.name %> (<%= @traffic.to_i %>)"></a>
|
||||
|
||||
<% links = {
|
||||
"/" => "Home",
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
Hello <%= @user.email %>,
|
||||
|
||||
Someone at <%= @ip %> requested to reset your account password
|
||||
on lobste.rs. If you submitted this request, visit the link below to
|
||||
on <%= Rails.application.name %>. If you submitted this request, visit the link below to
|
||||
set a new password. If not, you can disregard this e-mail.
|
||||
|
||||
<%= root_url %>login/set_new_password?token=<%= @user.password_reset_token %>
|
||||
|
|
|
@ -152,7 +152,8 @@
|
|||
<%= f.label :pushover_messages, "List Address:",
|
||||
:class => "required" %>
|
||||
<span>
|
||||
<tt>lobsters-<%= @edit_user.mailing_list_token %>@lobste.rs</tt>
|
||||
<tt><%= Rails.application.shortname %>-<%=
|
||||
@edit_user.mailing_list_token %>@<%= Rails.application.domain %></tt>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -21,16 +21,16 @@
|
|||
<a href="javascript:window.location=%22<%= root_url %>stories/new?url=%22+encodeURIComponent(document.location)+%22&title=%22+encodeURIComponent(document.title)"
|
||||
style="border: 1px solid #ddd; padding: 0.5em; background-color:
|
||||
#f8f8f8; line-height: 1.5em; margin-left: 1em;">Submit to
|
||||
Lobsters</a>
|
||||
<%= Rails.application.name %></a>
|
||||
</div>
|
||||
<ul>
|
||||
|
||||
<li>
|
||||
<p>
|
||||
To be able to easily submit a page you're viewing in your browser
|
||||
to Lobsters, drag the bookmarklet to the right to your bookmark
|
||||
bar. You'll be taken to this page with the viewed page's URL and
|
||||
title.
|
||||
to <%= Rails.application.name %>, drag the bookmarklet to the right
|
||||
to your bookmark bar. You'll be taken to this page with the viewed
|
||||
page's URL and title.
|
||||
</p>
|
||||
|
||||
<li><p>
|
||||
|
|
|
@ -60,10 +60,28 @@ module Lobsters
|
|||
end
|
||||
end
|
||||
|
||||
# disable yaml/xml/whatever input parsing
|
||||
silence_warnings do
|
||||
ActionDispatch::ParamsParser::DEFAULT_PARSERS = {}
|
||||
end
|
||||
|
||||
Rails.application.routes.default_url_options[:host] = "lobste.rs"
|
||||
# define site name and domain to be used globally, can be overridden in
|
||||
# config/initializers/production.rb
|
||||
class << Rails.application
|
||||
def domain
|
||||
"lobste.rs"
|
||||
end
|
||||
|
||||
def name
|
||||
"Lobsters"
|
||||
end
|
||||
|
||||
# used as mailing list prefix and countinual prefix, cannot have spaces
|
||||
def shortname
|
||||
name.downcase.gsub(/[^a-z]/, "")
|
||||
end
|
||||
end
|
||||
|
||||
Rails.application.routes.default_url_options[:host] = Rails.application.domain
|
||||
|
||||
require "#{Rails.root}/lib/monkey"
|
||||
|
|
|
@ -35,5 +35,3 @@ Lobsters::Application.configure do
|
|||
# Expands the lines which load the assets
|
||||
config.assets.debug = true
|
||||
end
|
||||
|
||||
Rails.application.routes.default_url_options[:host] = "lobsters.localhost:3000"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
ActionMailer::Base.smtp_settings = {
|
||||
:address => "127.0.0.1",
|
||||
:port => 25,
|
||||
:domain => "lobste.rs",
|
||||
:domain => Rails.application.domain,
|
||||
:enable_starttls_auto => false,
|
||||
}
|
||||
|
|
|
@ -49,14 +49,20 @@ Story.where("id > ?", last_story_id).order(:id).each do |s|
|
|||
next
|
||||
end
|
||||
|
||||
IO.popen([ {}, "/usr/sbin/sendmail", "-i", "-f", "nobody@lobste.rs",
|
||||
u.email ], "w") do |mail|
|
||||
mail.puts "From: #{s.user.username} <#{s.user.username}@lobste.rs>"
|
||||
mail.puts "Reply-To: lobsters-#{u.mailing_list_token}@lobste.rs"
|
||||
mail.puts "To: lobsters-#{u.mailing_list_token}@lobste.rs"
|
||||
mail.puts "X-BeenThere: lobsters-#{u.mailing_list_token}.lobste.rs"
|
||||
mail.puts "List-Id: Lobsters <lobsters-#{u.mailing_list_token}.lobste.rs>"
|
||||
mail.puts "List-Unsubscribe: <https://lobste.rs/settings>"
|
||||
domain = Rails.application.domain
|
||||
list = "#{Rails.application.shortname}-#{u.mailing_list_token}@" <<
|
||||
Rails.application.domain
|
||||
|
||||
IO.popen([ {}, "/usr/sbin/sendmail", "-i", "-f",
|
||||
"nobody@#{Rails.application.domain}", u.email ], "w") do |mail|
|
||||
mail.puts "From: #{s.user.username} <#{s.user.username}@" <<
|
||||
"#{Rails.application.domain}>"
|
||||
mail.puts "Reply-To: #{list}"
|
||||
mail.puts "To: #{list}"
|
||||
mail.puts "X-BeenThere: #{list}"
|
||||
mail.puts "List-Id: #{Rails.application.name} <#{list}>"
|
||||
mail.puts "List-Unsubscribe: <" <<
|
||||
"#{Rails.application.routes.url_helpers.root_url}settings>"
|
||||
mail.puts "Precedence: list"
|
||||
mail.puts "Content-Type: text/plain; charset=\"us-ascii\""
|
||||
mail.puts "Message-ID: <#{s.mailing_list_message_id}>"
|
||||
|
@ -105,13 +111,18 @@ Comment.where("id > ?", last_comment_id).order(:id).each do |c|
|
|||
next
|
||||
end
|
||||
|
||||
IO.popen([ {}, "/usr/sbin/sendmail", "-i", "-f", "nobody@lobste.rs",
|
||||
u.email ], "w") do |mail|
|
||||
mail.puts "From: #{c.user.username} <#{c.user.username}@lobste.rs>"
|
||||
mail.puts "Reply-To: lobsters-#{u.mailing_list_token}@lobste.rs"
|
||||
mail.puts "To: lobsters-#{u.mailing_list_token}@lobste.rs"
|
||||
mail.puts "List-Id: Lobsters <lobsters-#{u.mailing_list_token}.lobste.rs>"
|
||||
mail.puts "List-Unsubscribe: <https://lobste.rs/settings>"
|
||||
domain = Rails.application.domain
|
||||
list = "#{Rails.application.shortname}-#{u.mailing_list_token}@" <<
|
||||
Rails.application.domain
|
||||
|
||||
IO.popen([ {}, "/usr/sbin/sendmail", "-i", "-f",
|
||||
"nobody@#{domain}", u.email ], "w") do |mail|
|
||||
mail.puts "From: #{c.user.username} <#{c.user.username}@#{domain}>"
|
||||
mail.puts "Reply-To: #{list}"
|
||||
mail.puts "To: #{list}"
|
||||
mail.puts "List-Id: #{Rails.application.name} <#{list}>"
|
||||
mail.puts "List-Unsubscribe: <" <<
|
||||
"#{Rails.application.routes.url_helpers.root_url}settings>"
|
||||
mail.puts "Precedence: list"
|
||||
mail.puts "Content-Type: text/plain; charset=\"us-ascii\""
|
||||
mail.puts "Message-ID: <#{c.mailing_list_message_id}>"
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
#!/usr/bin/env ruby
|
||||
#
|
||||
# postfix main.cf:
|
||||
# relay_domains = lobste.rs
|
||||
# relay_domains = example.com
|
||||
# transport_maps = hash:/etc/postfix/transport
|
||||
# defer_transports =
|
||||
#
|
||||
# postfix transports:
|
||||
# lobste.rs lobsters:
|
||||
# example.com lobsters:
|
||||
#
|
||||
# postfix master.cf:
|
||||
# lobsters unix - n n - 2 pipe
|
||||
|
@ -25,7 +25,8 @@ EX_TEMPFAIL = 75
|
|||
EX_UNAVAILABLE = 69
|
||||
|
||||
recipient = ARGV[0]
|
||||
user_token = recipient.gsub(/^lobsters-/, "").gsub(/@.*/, "")
|
||||
user_token = recipient.gsub(/^#{Rails.application.shortname}-/, "").
|
||||
gsub(/@.*/, "")
|
||||
sender = ARGV[1]
|
||||
message = ""
|
||||
email = nil
|
||||
|
@ -34,7 +35,7 @@ while !STDIN.eof?
|
|||
message += STDIN.gets.to_s
|
||||
end
|
||||
|
||||
if message.match(/^X-BeenThere: lobsters-/i)
|
||||
if message.match(/^X-BeenThere: #{Rails.application.shortname}-/i)
|
||||
# avoid looping
|
||||
exit
|
||||
end
|
||||
|
@ -47,7 +48,7 @@ if !sending_user
|
|||
|
||||
# if this looks like a user token but invalid, generate a bounce to be
|
||||
# helpful. otherwise supress it to avoid talking back to spammers
|
||||
exit(recipient.match(/^lobsters-/) ? EX_NOUSER : 0)
|
||||
exit(recipient.match(/^#{Rails.application.shortname}-/) ? EX_NOUSER : 0)
|
||||
end
|
||||
|
||||
# the mail gem stupidly spams STDERR while parsing e-mail, so silence that
|
||||
|
|
Loading…
Reference in a new issue