diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index ab74ef8..e0aa508 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -16,8 +16,8 @@ class ApplicationController < ActionController::Base end if session[:u] && - (user = User.where(:session_token => session[:u].to_s).first) && - user.is_active? + (user = User.where(:session_token => session[:u].to_s).first) && + user.is_active? @user = user Rails.logger.info " Logged in as user #{@user.id} (#{@user.username})" end diff --git a/app/controllers/avatars_controller.rb b/app/controllers/avatars_controller.rb index fbe0c0f..0ffe381 100644 --- a/app/controllers/avatars_controller.rb +++ b/app/controllers/avatars_controller.rb @@ -21,7 +21,7 @@ class AvatarsController < ApplicationController end flash[:success] = "Your avatar cache has been purged of #{expired} " << - "file#{expired == 1 ? "" : "s"}" + "file#{expired == 1 ? "" : "s"}" return redirect_to "/settings" end diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index f1c69e0..7b80442 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -11,7 +11,7 @@ class CommentsController < ApplicationController def create if !(story = Story.where(:short_id => params[:story_id]).first) || - story.is_gone? + story.is_gone? return render :plain => "can't find story", :status => 400 end @@ -34,8 +34,9 @@ class CommentsController < ApplicationController # prevent double-clicks of the post button if params[:preview].blank? && - (pc = Comment.where(:story_id => story.id, :user_id => @user.id, - :parent_comment_id => comment.parent_comment_id).first) + (pc = Comment.where(:story_id => story.id, + :user_id => @user.id, + :parent_comment_id => comment.parent_comment_id).first) if (Time.now - pc.created_at) < 5.minutes && !@user.is_moderator? comment.errors.add(:comment, "^You have already posted a comment " << "here recently.") diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index e6e3282..e3fe3b9 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -45,8 +45,8 @@ class HomeController < ApplicationController render :action => "privacy" rescue ActionView::MissingTemplate render :html => "
" << - "You apparently have no privacy." << - "
", :layout => "application" + "You apparently have no privacy." << + "", :layout => "application" end end @@ -232,7 +232,7 @@ class HomeController < ApplicationController if length[:dur] > 1 @heading = @title = "Top Stories of the Past #{length[:dur]} " << - length[:intv] << "s" + length[:intv] << "s" else @heading = @title = "Top Stories of the Past " << length[:intv] end diff --git a/app/controllers/invitations_controller.rb b/app/controllers/invitations_controller.rb index ed0b7b1..7b13191 100644 --- a/app/controllers/invitations_controller.rb +++ b/app/controllers/invitations_controller.rb @@ -13,8 +13,7 @@ class InvitationsController < ApplicationController def index if !@user.can_see_invitation_requests? - flash[:error] = "Your account is not permitted to view invitation " << - "requests." + flash[:error] = "Your account is not permitted to view invitation requests." return redirect_to "/" end @@ -31,7 +30,7 @@ class InvitationsController < ApplicationController ir.save! flash[:success] = "Your invitation request has been validated and " << - "will now be shown to other logged-in users." + "will now be shown to other logged-in users." return redirect_to "/invitations/request" end @@ -51,10 +50,10 @@ class InvitationsController < ApplicationController i.save! i.send_email flash[:success] = "Successfully e-mailed invitation to " << - params[:email].to_s << "." + params[:email].to_s << "." rescue flash[:error] = "Could not send invitation, verify the e-mail " << - "address is valid." + "address is valid." end if params[:return_home] @@ -73,7 +72,7 @@ class InvitationsController < ApplicationController if @invitation_request.save flash[:success] = "You have been e-mailed a confirmation to " << - params[:invitation_request][:email].to_s << "." + params[:invitation_request][:email].to_s << "." return redirect_to "/invitations/request" else render :action => :build @@ -86,7 +85,7 @@ class InvitationsController < ApplicationController def send_for_request if !@user.can_see_invitation_requests? flash[:error] = "Your account is not permitted to view invitation " << - "requests." + "requests." return redirect_to "/" end @@ -102,10 +101,10 @@ class InvitationsController < ApplicationController i.send_email ir.destroy! flash[:success] = "Successfully e-mailed invitation to " << - ir.name.to_s << "." + ir.name.to_s << "." Rails.logger.info "[u#{@user.id}] sent invitiation for request " << - ir.inspect + ir.inspect return redirect_to "/invitations" end @@ -122,10 +121,10 @@ class InvitationsController < ApplicationController ir.destroy! flash[:success] = "Successfully deleted invitation request from " << - ir.name.to_s << "." + ir.name.to_s << "." Rails.logger.info "[u#{@user.id}] deleted invitation request " << - "from #{ir.inspect}" + "from #{ir.inspect}" return redirect_to "/invitations" end diff --git a/app/controllers/login_controller.rb b/app/controllers/login_controller.rb index d5a2c10..fcc624d 100644 --- a/app/controllers/login_controller.rb +++ b/app/controllers/login_controller.rb @@ -105,8 +105,7 @@ class LoginController < ApplicationController @found_user.initiate_password_reset_for_ip(request.remote_ip) - flash.now[:success] = "Password reset instructions have been e-mailed " << - "to you." + flash.now[:success] = "Password reset instructions have been e-mailed to you." return index end @@ -114,7 +113,7 @@ class LoginController < ApplicationController @title = "Reset Password" if (m = params[:token].to_s.match(/^(\d+)-/)) && - (Time.now - Time.at(m[1].to_i)) < 24.hours + (Time.now - Time.at(m[1].to_i)) < 24.hours @reset_user = User.where(:password_reset_token => params[:token].to_s).first end @@ -145,7 +144,7 @@ class LoginController < ApplicationController end else flash[:error] = "Invalid reset token. It may have already been " << - "used or you may have copied it incorrectly." + "used or you may have copied it incorrectly." return redirect_to forgot_password_path end end @@ -153,7 +152,7 @@ class LoginController < ApplicationController def twofa if tmpu = find_twofa_user Rails.logger.info " Authenticated as user #{tmpu.id} " << - "(#{tmpu.username}), verifying TOTP" + "(#{tmpu.username}), verifying TOTP" else reset_session return redirect_to "/login" diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index c2fe97a..dc98bb4 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -56,7 +56,7 @@ class MessagesController < ApplicationController if @new_message.save flash[:success] = "Your message has been sent to " << - @new_message.recipient.username.to_s << "." + @new_message.recipient.username.to_s << "." return redirect_to "/messages" else render :action => "index" diff --git a/app/controllers/settings_controller.rb b/app/controllers/settings_controller.rb index 400b66b..488ae98 100644 --- a/app/controllers/settings_controller.rb +++ b/app/controllers/settings_controller.rb @@ -28,7 +28,7 @@ class SettingsController < ApplicationController @edit_user = @user.clone if params[:user][:password].empty? || - @user.authenticate(params[:current_password].to_s) + @user.authenticate(params[:current_password].to_s) if @edit_user.update_attributes(user_params) flash.now[:success] = "Successfully updated settings." @user = @edit_user @@ -80,8 +80,10 @@ class SettingsController < ApplicationController # no option for inline svg, so just strip off leading tag qrcode = RQRCode::QRCode.new(totp_url) - qr = qrcode.as_svg(offset: 0, color: "000", module_size: 5, - shape_rendering: "crispEdges").gsub(/^<\?xml.*>/, "") + qr = qrcode.as_svg(offset: 0, + color: "000", + module_size: 5, + shape_rendering: "crispEdges").gsub(/^<\?xml.*>/, "") @qr_svg = "#{qr}" end @@ -90,7 +92,7 @@ class SettingsController < ApplicationController @title = "Two-Factor Authentication" if ((Time.now.to_i - session[:last_authed].to_i) > TOTP_SESSION_TIMEOUT) || - !session[:totp_secret] + !session[:totp_secret] flash[:error] = "Your enrollment period timed out." return redirect_to twofa_url end @@ -98,7 +100,7 @@ class SettingsController < ApplicationController def twofa_update if ((Time.now.to_i - session[:last_authed].to_i) > TOTP_SESSION_TIMEOUT) || - !session[:totp_secret] + !session[:totp_secret] flash[:error] = "Your enrollment period timed out." return redirect_to twofa_url end @@ -111,13 +113,12 @@ class SettingsController < ApplicationController session[:u] = @user.session_token - flash[:success] = "Two-Factor Authentication has been enabled on " << - "your account." + flash[:success] = "Two-Factor Authentication has been enabled on your account." session.delete(:totp_secret) return redirect_to "/settings" else flash[:error] = "Your TOTP code was invalid, please verify the " << - "current code in your TOTP application." + "current code in your TOTP application." return redirect_to twofa_verify_url end end @@ -151,8 +152,7 @@ class SettingsController < ApplicationController end if params[:rand].to_s != session[:pushover_rand].to_s - raise "rand param #{params[:rand].inspect} != " << - session[:pushover_rand].inspect + raise "rand param #{params[:rand].inspect} != #{session[:pushover_rand].inspect}" end @user.pushover_user_key = params[:pushover_user_key].to_s @@ -161,8 +161,7 @@ class SettingsController < ApplicationController if @user.pushover_user_key.present? flash[:success] = "Your account is now setup for Pushover notifications." else - flash[:success] = "Your account is no longer setup for Pushover " << - "notifications." + flash[:success] = "Your account is no longer setup for Pushover notifications." end return redirect_to "/settings" @@ -174,8 +173,9 @@ class SettingsController < ApplicationController end def github_callback - if !session[:github_state].present? || !params[:code].present? || - (params[:state].to_s != session[:github_state].to_s) + if !session[:github_state].present? || + !params[:code].present? || + (params[:state].to_s != session[:github_state].to_s) flash[:error] = "Invalid OAuth state" return redirect_to "/settings" end @@ -187,8 +187,7 @@ class SettingsController < ApplicationController @user.github_oauth_token = tok @user.github_username = username @user.save! - flash[:success] = "Your account has been linked to GitHub user " << - "#{username}." + flash[:success] = "Your account has been linked to GitHub user #{username}." else return github_disconnect end @@ -210,8 +209,8 @@ class SettingsController < ApplicationController end def twitter_callback - if !session[:twitter_state].present? || - (params[:state].to_s != session[:twitter_state].to_s) + if session[:twitter_state].blank? || + (params[:state].to_s != session[:twitter_state].to_s) flash[:error] = "Invalid OAuth state" return redirect_to "/settings" end @@ -225,8 +224,7 @@ class SettingsController < ApplicationController @user.twitter_oauth_token_secret = sec @user.twitter_username = username @user.save! - flash[:success] = "Your account has been linked to Twitter user @" << - "#{username}." + flash[:success] = "Your account has been linked to Twitter user @#{username}." else return twitter_disconnect end diff --git a/app/controllers/signup_controller.rb b/app/controllers/signup_controller.rb index 5f66b56..625fde9 100644 --- a/app/controllers/signup_controller.rb +++ b/app/controllers/signup_controller.rb @@ -49,7 +49,7 @@ class SignupController < ApplicationController @invitation.destroy session[:u] = @new_user.session_token flash[:success] = "Welcome to #{Rails.application.name}, " << - "#{@new_user.username}!" + "#{@new_user.username}!" return redirect_to "/signup/invite" else diff --git a/app/controllers/stories_controller.rb b/app/controllers/stories_controller.rb index 4816ca7..e5025e2 100644 --- a/app/controllers/stories_controller.rb +++ b/app/controllers/stories_controller.rb @@ -78,7 +78,7 @@ class StoriesController < ApplicationController if sattrs[:url].present? && @story.url != sattrs[:url] flash.now[:notice] = "Note: URL has been changed to fetched " << - "canonicalized version" + "canonicalized version" @story.url = sattrs[:url] end @@ -144,9 +144,9 @@ class StoriesController < ApplicationController "twitter:site" => "@lobsters", "twitter:title" => @story.title, "twitter:description" => "#{@story.comments_count} comment" << - "#{@story.comments_count == 1 ? "" : "s"}", + "#{@story.comments_count == 1 ? "" : "s"}", "twitter:image" => Rails.application.root_url + - "apple-touch-icon-144.png", + "apple-touch-icon-144.png", } if @story.user.twitter_username.present? @@ -377,7 +377,7 @@ private if !@story flash[:error] = "Could not find story or you are not authorized " << - "to manage it." + "to manage it." redirect_to "/" return false end diff --git a/app/mailers/ban_notification.rb b/app/mailers/ban_notification.rb index 2029e10..f4bb628 100644 --- a/app/mailers/ban_notification.rb +++ b/app/mailers/ban_notification.rb @@ -1,6 +1,5 @@ class BanNotification < ActionMailer::Base - default :from => "#{Rails.application.name} " << - "" + default :from => "#{Rails.application.name} " def notify(user, banner, reason) @banner = banner diff --git a/app/mailers/email_message.rb b/app/mailers/email_message.rb index 85b196e..ea8c898 100644 --- a/app/mailers/email_message.rb +++ b/app/mailers/email_message.rb @@ -1,6 +1,5 @@ class EmailMessage < ActionMailer::Base - default :from => "#{Rails.application.name} " << - "" + default :from => "#{Rails.application.name} " def notify(message, user) @message = message @@ -9,7 +8,7 @@ class EmailMessage < ActionMailer::Base mail( :to => user.email, :subject => "[#{Rails.application.name}] Private Message from " << - "#{message.author_username}: #{message.subject}" + "#{message.author_username}: #{message.subject}" ) end end diff --git a/app/mailers/email_reply.rb b/app/mailers/email_reply.rb index 5c9869a..f450b56 100644 --- a/app/mailers/email_reply.rb +++ b/app/mailers/email_reply.rb @@ -1,6 +1,5 @@ class EmailReply < ActionMailer::Base - default :from => "#{Rails.application.name} " << - "" + default :from => "#{Rails.application.name} " def reply(comment, user) @comment = comment @@ -9,7 +8,7 @@ class EmailReply < ActionMailer::Base mail( :to => user.email, :subject => "[#{Rails.application.name}] Reply from " << - "#{comment.user.username} on #{comment.story.title}" + "#{comment.user.username} on #{comment.story.title}" ) end @@ -20,7 +19,7 @@ class EmailReply < ActionMailer::Base mail( :to => user.email, :subject => "[#{Rails.application.name}] Mention from " << - "#{comment.user.username} on #{comment.story.title}" + "#{comment.user.username} on #{comment.story.title}" ) end end diff --git a/app/mailers/invitation_mailer.rb b/app/mailers/invitation_mailer.rb index 5b55a73..50d5215 100644 --- a/app/mailers/invitation_mailer.rb +++ b/app/mailers/invitation_mailer.rb @@ -1,14 +1,13 @@ class InvitationMailer < ActionMailer::Base - default :from => "#{Rails.application.name} " << - "" + default :from => "#{Rails.application.name} " def invitation(invitation) @invitation = invitation mail( to: invitation.email, - subject: "[#{Rails.application.name}] You have been invited to " << - Rails.application.name + subject: "[#{Rails.application.name}] You are invited to join " << + Rails.application.name ) end end diff --git a/app/mailers/invitation_request_mailer.rb b/app/mailers/invitation_request_mailer.rb index 29c1b17..fcb61f8 100644 --- a/app/mailers/invitation_request_mailer.rb +++ b/app/mailers/invitation_request_mailer.rb @@ -1,6 +1,5 @@ class InvitationRequestMailer < ActionMailer::Base - default :from => "#{Rails.application.name} " << - "" + default :from => "#{Rails.application.name} " def invitation_request(invitation_request) @invitation_request = invitation_request @@ -8,7 +7,7 @@ class InvitationRequestMailer < ActionMailer::Base mail( to: invitation_request.email, subject: "[#{Rails.application.name}] Confirm your invitation " << - "request to " << Rails.application.name + "request to " << Rails.application.name ) end end diff --git a/app/mailers/password_reset.rb b/app/mailers/password_reset.rb index 5868ec2..f618185 100644 --- a/app/mailers/password_reset.rb +++ b/app/mailers/password_reset.rb @@ -1,6 +1,5 @@ class PasswordReset < ActionMailer::Base - default :from => "#{Rails.application.name} " << - "" + default :from => "#{Rails.application.name} " def password_reset_link(user, ip) @user = user diff --git a/app/models/comment.rb b/app/models/comment.rb index 9496e2e..2238073 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -75,8 +75,8 @@ class Comment < ActiveRecord::Base # from the tree. otherwise they have to stay and a "[deleted]" stub # will be shown if node.is_gone? && # deleted or moderated - !children.present? && # don't have child comments - (!user || (!user.is_moderator? && node.user_id != user.id)) + children.empty? && # don't have child comments + (!user || (!user.is_moderator? && node.user_id != user.id)) # admins and authors should be able to see their deleted comments next end @@ -246,8 +246,9 @@ class Comment < ActiveRecord::Base end def deliver_reply_notifications - if self.parent_comment_id && (u = self.parent_comment.try(:user)) && - u.id != self.user.id + if self.parent_comment_id && + (u = self.parent_comment.try(:user)) && + u.id != self.user.id if u.email_replies? begin EmailReply.reply(self, u).deliver_now @@ -308,7 +309,7 @@ class Comment < ActiveRecord::Base elsif self.user.is_new? c.push "new_user" elsif self.story && self.story.user_is_author? && - self.story.user_id == self.user_id + self.story.user_id == self.user_id c.push "user_is_author" end @@ -420,8 +421,8 @@ class Comment < ActiveRecord::Base def showing_downvotes_for_user?(u) return (u && u.is_moderator?) || - (self.created_at && self.created_at < 36.hours.ago) || - !SCORE_RANGE_TO_HIDE.include?(self.score) + (self.created_at && self.created_at < 36.hours.ago) || + !SCORE_RANGE_TO_HIDE.include?(self.score) end def to_param diff --git a/app/models/hat.rb b/app/models/hat.rb index f134aee..63f6e64 100644 --- a/app/models/hat.rb +++ b/app/models/hat.rb @@ -33,9 +33,9 @@ class Hat < ActiveRecord::Base hl = (self.link.present? && self.link.match(/^https?:\/\//)) h = " *#{self.action}*\n" + "#{self.story.comments_url}) has been edited with the following " << + "changes:\n" << + "\n" << + "> *#{self.action}*\n" if self.reason.present? m.body << "\n" << @@ -36,9 +36,9 @@ class Moderation < ActiveRecord::Base m.recipient_user_id = self.comment.user_id m.subject = "Your comment has been moderated" m.body = "Your comment on [#{self.comment.story.title}](" << - "#{self.comment.story.comments_url}) has been moderated:\n" << - "\n" << - "> *#{self.comment.comment}*\n" + "#{self.comment.story.comments_url}) has been moderated:\n" << + "\n" << + "> *#{self.comment.comment}*\n" if self.reason.present? m.body << "\n" << diff --git a/app/models/story.rb b/app/models/story.rb index ec2af44..a612537 100644 --- a/app/models/story.rb +++ b/app/models/story.rb @@ -284,8 +284,7 @@ class Story < ActiveRecord::Base self.taggings.each do |t| if !t.tag.valid_for?(u) - raise "#{u.username} does not have permission to use privileged " << - "tag #{t.tag.tag}" + raise "#{u.username} does not have permission to use privileged tag #{t.tag.tag}" elsif t.tag.inactive? && t.new_record? && !t.marked_for_destruction? # stories can have inactive tags as long as they existed before raise "#{u.username} cannot add inactive tag #{t.tag.tag}" @@ -444,8 +443,7 @@ class Story < ActiveRecord::Base end def is_unavailable=(what) - self.unavailable_at = (what.to_i == 1 && !self.is_unavailable ? - Time.now : nil) + self.unavailable_at = (what.to_i == 1 && !self.is_unavailable ? Time.now : nil) end def is_undeletable_by_user?(user) @@ -460,8 +458,7 @@ class Story < ActiveRecord::Base def log_moderation if self.new_record? || - (!self.editing_from_suggestions && - (!self.editor || self.editor.id == self.user_id)) + (!self.editing_from_suggestions && (!self.editor || self.editor.id == self.user_id)) return end @@ -607,7 +604,7 @@ class Story < ActiveRecord::Base # XXX: AR bug? st.exists?(:tag => tag_name) does not work if tag_name.to_s != "" && !st.map {|x| x.tag.tag }.include?(tag_name) if (t = Tag.active.where(:tag => tag_name).first) && - t.valid_for?(user) + t.valid_for?(user) tg = self.suggested_taggings.build tg.user_id = user.id tg.tag_id = t.id @@ -638,14 +635,14 @@ class Story < ActiveRecord::Base if final_tags.any? && (final_tags.sort != self.tags_a.sort) Rails.logger.info "[s#{self.id}] promoting suggested tags " << - "#{final_tags.inspect} instead of #{self.tags_a.inspect}" + "#{final_tags.inspect} instead of #{self.tags_a.inspect}" self.editor = nil self.editing_from_suggestions = true self.moderation_reason = "Automatically changed from user suggestions" self.tags_a = final_tags.sort if !self.save Rails.logger.error "[s#{self.id}] failed auto promoting: " << - self.errors.inspect + self.errors.inspect end end end @@ -669,14 +666,14 @@ class Story < ActiveRecord::Base title_votes.sort_by {|_k, v| v }.reverse.each do |kv| if kv[1] >= SUGGESTION_QUORUM Rails.logger.info "[s#{self.id}] promoting suggested title " << - "#{kv[0].inspect} instead of #{self.title.inspect}" + "#{kv[0].inspect} instead of #{self.title.inspect}" self.editor = nil self.editing_from_suggestions = true self.moderation_reason = "Automatically changed from user suggestions" self.title = kv[0] if !self.save Rails.logger.error "[s#{self.id}] failed auto promoting: " << - self.errors.inspect + self.errors.inspect end break @@ -852,8 +849,9 @@ class Story < ActiveRecord::Base site_name = parsed.at_css("meta[property='og:site_name']") .attributes["content"].text - if site_name.present? && site_name.length < title.length && - title[-(site_name.length), site_name.length] == site_name + if site_name.present? && + site_name.length < title.length && + title[-(site_name.length), site_name.length] == site_name title = title[0, title.length - site_name.length] # remove title/site name separator @@ -869,9 +867,9 @@ class Story < ActiveRecord::Base # now get canonical version of url (though some cms software puts incorrect # urls here, hopefully the user will notice) begin - if (cu = parsed.at_css("link[rel='canonical']").attributes["href"] - .text).present? && (ucu = URI.parse(cu)) && ucu.scheme.present? && - ucu.host.present? + if (cu = parsed.at_css("link[rel='canonical']").attributes["href"] .text).present? && + (ucu = URI.parse(cu)) && ucu.scheme.present? && + ucu.host.present? @fetched_attributes[:url] = cu end rescue diff --git a/app/models/user.rb b/app/models/user.rb index 4ddb78e..e826e7e 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -178,10 +178,10 @@ class User < ActiveRecord::Base msg.recipient_user_id = self.id msg.subject = "Your invite privileges have been revoked" msg.body = "The reason given:\n" << - "\n" << - "> *#{reason}*\n" << - "\n" << - "*This is an automated message.*" + "\n" << + "> *#{reason}*\n" << + "\n" << + "*This is an automated message.*" msg.save! m = Moderation.new @@ -278,8 +278,8 @@ class User < ActiveRecord::Base def fetched_avatar(size = 100) gravatar_url = "https://www.gravatar.com/avatar/" << - Digest::MD5.hexdigest(self.email.strip.downcase) << - "?r=pg&d=identicon&s=#{size}" + Digest::MD5.hexdigest(self.email.strip.downcase) << + "?r=pg&d=identicon&s=#{size}" begin s = Sponge.new diff --git a/extras/sponge.rb b/extras/sponge.rb index fb93979..007e0e7 100644 --- a/extras/sponge.rb +++ b/extras/sponge.rb @@ -83,8 +83,7 @@ class Sponge # check for domain cookies @cookies.keys.each do |dom| - if dom.length < host.length && - dom == host[host.length - dom.length .. host.length - 1] + if dom.length < host.length && dom == host[host.length - dom.length .. host.length - 1] dputs "adding domain keys from #{dom}" cooks = cooks.merge @cookies[dom] end @@ -178,9 +177,9 @@ class Sponge path.gsub!(/^\/\//, "/") - dputs "fetching #{url} (#{ip.to_s}) " + (uri.user ? "with http auth " + - uri.user + "/" + ("*" * uri.password.length) + " " : "") + - "by #{method} with cookies #{cookies(uri.host)}" + dputs "fetching #{url} (#{ip.to_s}) " + + (uri.user ? "with http auth " + uri.user + "/" + ("*" * uri.password.length) + " " : "") + + "by #{method} with cookies #{cookies(uri.host)}" send_headers = { "Host" => uri.host, @@ -190,8 +189,7 @@ class Sponge }.merge(send_headers || {}) if uri.user - send_headers["Authorization"] = "Basic " + - ["#{uri.user}:#{uri.password}"].pack('m').delete("\r\n") + send_headers["Authorization"] = "Basic " + ["#{uri.user}:#{uri.password}"].pack('m').delete("\r\n") end res = nil diff --git a/extras/story_cacher.rb b/extras/story_cacher.rb index 21cea43..59efa94 100644 --- a/extras/story_cacher.rb +++ b/extras/story_cacher.rb @@ -16,8 +16,7 @@ class StoryCacher return nil end - db_url = "#{DIFFBOT_API_URL}?token=#{@@DIFFBOT_API_KEY}&url=" << - CGI.escape(story.url) + db_url = "#{DIFFBOT_API_URL}?token=#{@@DIFFBOT_API_KEY}&url=#{CGI.escape(story.url)}" begin s = Sponge.new diff --git a/script/mail_new_activity b/script/mail_new_activity index 425e79a..c1e8cbf 100755 --- a/script/mail_new_activity +++ b/script/mail_new_activity @@ -78,18 +78,15 @@ Story.where("id > ? AND is_expired = ?", last_story_id, false).order(:id).each d end domain = Rails.application.domain - list = "#{Rails.application.shortname}-#{u.mailing_list_token}@" << - Rails.application.domain + list = "#{Rails.application.shortname}-#{u.mailing_list_token}@#{ails.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 "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.root_url}settings>" + mail.puts "List-Unsubscribe: <#{Rails.application.root_url}settings>" mail.puts "Precedence: list" mail.puts "MIME-Version: 1.0" mail.puts "Content-Type: text/plain; charset=\"utf-8\"" @@ -160,8 +157,7 @@ last_comment_id, false, false).order(:id).each do |c| end domain = Rails.application.domain - list = "#{Rails.application.shortname}-#{u.mailing_list_token}@" << - 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| from = "From: \"#{c.user.username}" @@ -174,8 +170,7 @@ last_comment_id, false, false).order(:id).each do |c| mail.puts "Reply-To: #{list}" mail.puts "To: #{list}" mail.puts "List-Id: #{Rails.application.name} <#{list}>" - mail.puts "List-Unsubscribe: <" << - "#{Rails.application.root_url}settings>" + mail.puts "List-Unsubscribe: <#{Rails.application.root_url}settings>" mail.puts "Precedence: list" mail.puts "MIME-Version: 1.0" mail.puts "Content-Type: text/plain; charset=\"utf-8\"" diff --git a/script/post_to_twitter b/script/post_to_twitter index c310b5f..23eda01 100755 --- a/script/post_to_twitter +++ b/script/post_to_twitter @@ -24,17 +24,21 @@ StoriesPaginator.new(StoryRepository.new.hottest).get.first via = "" if s.user.twitter_username.present? - via = "\n" + (s.user_is_author? ? "by" : "via") + - " @#{s.user.twitter_username}" + via = "\n" + + (s.user_is_author? ? "by" : "via") + + " @#{s.user.twitter_username}" end - tco_status = via + "\n" + - ("X" * Twitter::TCO_LEN) + tags + - (s.url.present?? "\n" + ("X" * Twitter::TCO_LEN) : "") + tco_status = via + + "\n" + + ("X" * Twitter::TCO_LEN) + tags + + (s.url.present? ? "\n" + ("X" * Twitter::TCO_LEN) : "") - status = via + "\n" + - s.short_id_url + tags + - (s.url.present?? "\n" + s.url : "") + status = via + + "\n" + + s.short_id_url + + tags + + (s.url.present? ? "\n" + s.url : "") left_len = Twitter::MAX_TWEET_LEN - tco_status.length @@ -71,14 +75,12 @@ StoriesPaginator.new(StoryRepository.new.hottest).get.first elsif res["errors"].select {|e| e["code"] == 226 || e["code"] == 186 }.any? # twitter is rejecting the content of this message, skip it s.update_column("twitter_id", 0) - puts "skipping: failed posting story #{s.id} (#{status.inspect}): " + - "#{res.inspect}\n" + puts "skipping: failed posting story #{s.id} (#{status.inspect}): #{res.inspect}\n" else raise end rescue => e - puts "failed posting story #{s.id} (#{status.inspect}): #{e.inspect}\n" + - "#{res.inspect}" + puts "failed posting story #{s.id} (#{status.inspect}): #{e.inspect}\n#{res.inspect}" exit end end