properly set @title/@heading everywhere

This commit is contained in:
joshua stein 2012-09-07 09:18:15 -05:00
parent c093431898
commit 1987a24a2a
11 changed files with 41 additions and 19 deletions

View file

@ -171,7 +171,7 @@ class CommentsController < ApplicationController
end end
def index def index
@title = "Newest Comments" @heading = @title = "Newest Comments"
@cur_url = "/comments" @cur_url = "/comments"
@comments = Comment.find(:all, :conditions => "is_deleted = 0", @comments = Comment.find(:all, :conditions => "is_deleted = 0",
@ -192,14 +192,14 @@ class CommentsController < ApplicationController
def threads def threads
if params[:user] if params[:user]
@showing_user = User.find_by_username!(params[:user]) @showing_user = User.find_by_username!(params[:user])
@title = "Threads for #{@showing_user.username}" @heading = @title = "Threads for #{@showing_user.username}"
@cur_url = "/threads/#{@showing_user.username}" @cur_url = "/threads/#{@showing_user.username}"
elsif !@user elsif !@user
# TODO: show all recent threads # TODO: show all recent threads
return redirect_to "/login" return redirect_to "/login"
else else
@showing_user = @user @showing_user = @user
@title = "Your Threads" @heading = @title = "Your Threads"
@cur_url = "/threads" @cur_url = "/threads"
end end

View file

@ -2,7 +2,11 @@ class FiltersController < ApplicationController
before_filter :require_logged_in_user before_filter :require_logged_in_user
def index def index
@cur_url = "/filters"
@heading = @title = "Filtered Tags"
@filtered_tags = @user.tag_filters.reload @filtered_tags = @user.tag_filters.reload
render :action => "index" render :action => "index"
end end

View file

@ -8,7 +8,7 @@ class HomeController < ApplicationController
@rss_link ||= "<link rel=\"alternate\" type=\"application/rss+xml\" " << @rss_link ||= "<link rel=\"alternate\" type=\"application/rss+xml\" " <<
"title=\"RSS 2.0\" href=\"/rss\" />" "title=\"RSS 2.0\" href=\"/rss\" />"
@title = "" @heading = @title = ""
@cur_url = "/" @cur_url = "/"
respond_to do |format| respond_to do |format|
@ -21,7 +21,7 @@ class HomeController < ApplicationController
@stories = find_stories_for_user_and_tag_and_newest_and_by_user(@user, @stories = find_stories_for_user_and_tag_and_newest_and_by_user(@user,
nil, true, nil) nil, true, nil)
@title = "Newest Stories" @heading = @title = "Newest Stories"
@cur_url = "/newest" @cur_url = "/newest"
@rss_link = "<link rel=\"alternate\" type=\"application/rss+xml\" " << @rss_link = "<link rel=\"alternate\" type=\"application/rss+xml\" " <<
@ -41,7 +41,7 @@ class HomeController < ApplicationController
@stories = find_stories_for_user_and_tag_and_newest_and_by_user(@user, @stories = find_stories_for_user_and_tag_and_newest_and_by_user(@user,
nil, false, for_user.id) nil, false, for_user.id)
@title = "Newest Stories by #{for_user.username}" @heading = @title = "Newest Stories by #{for_user.username}"
@cur_url = "/newest/#{for_user.username}" @cur_url = "/newest/#{for_user.username}"
@newest = true @newest = true
@ -55,7 +55,7 @@ class HomeController < ApplicationController
@stories = find_stories_for_user_and_tag_and_newest_and_by_user(@user, @stories = find_stories_for_user_and_tag_and_newest_and_by_user(@user,
@tag, false, nil) @tag, false, nil)
@title = @tag.description.blank?? @tag.tag : @tag.description @heading = @title = @tag.description.blank?? @tag.tag : @tag.description
@cur_url = tag_url(@tag.tag) @cur_url = tag_url(@tag.tag)
@rss_link = "<link rel=\"alternate\" type=\"application/rss+xml\" " << @rss_link = "<link rel=\"alternate\" type=\"application/rss+xml\" " <<

View file

@ -10,7 +10,7 @@ class LoginController < ApplicationController
end end
def index def index
@page_title = "Login" @title = "Login"
render :action => "index" render :action => "index"
end end
@ -26,7 +26,7 @@ class LoginController < ApplicationController
end end
def forgot_password def forgot_password
@page_title = "Reset Password" @title = "Reset Password"
render :action => "forgot_password" render :action => "forgot_password"
end end
@ -47,6 +47,8 @@ class LoginController < ApplicationController
end end
def set_new_password def set_new_password
@title = "Reset Password"
if params[:token].blank? || if params[:token].blank? ||
!(@reset_user = User.find_by_password_reset_token(params[:token])) !(@reset_user = User.find_by_password_reset_token(params[:token]))
flash[:error] = "Invalid reset token. It may have already been " << flash[:error] = "Invalid reset token. It may have already been " <<

View file

@ -3,6 +3,9 @@ class MessagesController < ApplicationController
before_filter :find_message, :only => [ :show, :destroy, :keep_as_new ] before_filter :find_message, :only => [ :show, :destroy, :keep_as_new ]
def index def index
@cur_url = "/messages"
@title = "Messages"
@new_message = Message.new @new_message = Message.new
if params[:to] if params[:to]
@ -11,6 +14,9 @@ class MessagesController < ApplicationController
end end
def create def create
@cur_url = "/messages"
@title = "Messages"
@new_message = Message.new(params[:message]) @new_message = Message.new(params[:message])
@new_message.author_user_id = @user.id @new_message.author_user_id = @user.id
@ -25,6 +31,9 @@ class MessagesController < ApplicationController
end end
def show def show
@cur_url = "/messages"
@title = @message.subject
@new_message = Message.new @new_message = Message.new
@new_message.recipient_username = (@message.author_user_id == @user.id ? @new_message.recipient_username = (@message.author_user_id == @user.id ?
@message.recipient.username : @message.author.username) @message.recipient.username : @message.author.username)

View file

@ -1,5 +1,7 @@
class ModerationsController < ApplicationController class ModerationsController < ApplicationController
def index def index
@title = "Moderation Log"
@pages = Moderation.count @pages = Moderation.count
@page = params[:page] ? params[:page].to_i : 0 @page = params[:page] ? params[:page].to_i : 0

View file

@ -2,6 +2,8 @@ class SettingsController < ApplicationController
before_filter :require_logged_in_user before_filter :require_logged_in_user
def index def index
@title = "Account Settings"
@edit_user = @user.dup @edit_user = @user.dup
end end

View file

@ -6,7 +6,6 @@ class SignupController < ApplicationController
end end
@title = "Signup" @title = "Signup"
@page_title = "Create an Account"
end end
def invited def invited
@ -15,14 +14,13 @@ class SignupController < ApplicationController
return redirect_to "/" return redirect_to "/"
end end
@title = "Signup"
@page_title = "Create an Account"
if !(@invitation = Invitation.find_by_code(params[:invitation_code])) if !(@invitation = Invitation.find_by_code(params[:invitation_code]))
flash[:error] = "Invalid or expired invitation" flash[:error] = "Invalid or expired invitation"
return redirect_to "/signup" return redirect_to "/signup"
end end
@title = "Signup"
@new_user = User.new @new_user = User.new
@new_user.email = @invitation.email @new_user.email = @invitation.email
@ -35,6 +33,8 @@ class SignupController < ApplicationController
return redirect_to "/signup" return redirect_to "/signup"
end end
@title = "Signup"
@new_user = User.new(params[:user]) @new_user = User.new(params[:user])
@new_user.invited_by_user_id = @invitation.user_id @new_user.invited_by_user_id = @invitation.user_id

View file

@ -110,9 +110,9 @@ class StoriesController < ApplicationController
@story = Story.find_by_short_id!(params[:id]) @story = Story.find_by_short_id!(params[:id])
if @story.can_be_seen_by_user?(@user) if @story.can_be_seen_by_user?(@user)
@page_title = @story.title @title = @story.title
else else
@page_title = "[Story removed]" @title = "[Story removed]"
end end
@short_url = @story.short_id_url @short_url = @story.short_id_url
@ -139,7 +139,7 @@ class StoriesController < ApplicationController
def show_comment def show_comment
@story = Story.find_by_short_id!(params[:id]) @story = Story.find_by_short_id!(params[:id])
@page_title = @story.title @title = @story.title
@showing_comment = Comment.find_by_short_id(params[:comment_short_id]) @showing_comment = Comment.find_by_short_id(params[:comment_short_id])

View file

@ -1,10 +1,12 @@
class UsersController < ApplicationController class UsersController < ApplicationController
def show def show
@showing_user = User.find_by_username!(params[:id]) @showing_user = User.find_by_username!(params[:id])
@page_title = "User: #{@showing_user.username}" @title = "User #{@showing_user.username}"
end end
def tree def tree
@title = "Users"
parents = {} parents = {}
karmas = {} karmas = {}
User.all.each do |u| User.all.each do |u|

View file

@ -37,9 +37,10 @@
<% end %> <% end %>
<% links.merge!({ "/search" => "Search" }) %> <% links.merge!({ "/search" => "Search" }) %>
<% if @cur_url.present? && !links.keys.include?(@cur_url) %> <% if @cur_url.present? && !links.keys.include?(@cur_url) &&
@heading.present? %>
<span id="headertitle"> <span id="headertitle">
<a href="<%= @cur_url %>"><%= @title %></a> <a href="<%= @cur_url %>"><%= @heading %></a>
</span> </span>
<% end %> <% end %>