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
def index
@title = "Newest Comments"
@heading = @title = "Newest Comments"
@cur_url = "/comments"
@comments = Comment.find(:all, :conditions => "is_deleted = 0",
@ -192,14 +192,14 @@ class CommentsController < ApplicationController
def threads
if 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}"
elsif !@user
# TODO: show all recent threads
return redirect_to "/login"
else
@showing_user = @user
@title = "Your Threads"
@heading = @title = "Your Threads"
@cur_url = "/threads"
end

View file

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

View file

@ -8,7 +8,7 @@ class HomeController < ApplicationController
@rss_link ||= "<link rel=\"alternate\" type=\"application/rss+xml\" " <<
"title=\"RSS 2.0\" href=\"/rss\" />"
@title = ""
@heading = @title = ""
@cur_url = "/"
respond_to do |format|
@ -21,7 +21,7 @@ class HomeController < ApplicationController
@stories = find_stories_for_user_and_tag_and_newest_and_by_user(@user,
nil, true, nil)
@title = "Newest Stories"
@heading = @title = "Newest Stories"
@cur_url = "/newest"
@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,
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}"
@newest = true
@ -55,7 +55,7 @@ class HomeController < ApplicationController
@stories = find_stories_for_user_and_tag_and_newest_and_by_user(@user,
@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)
@rss_link = "<link rel=\"alternate\" type=\"application/rss+xml\" " <<

View file

@ -10,7 +10,7 @@ class LoginController < ApplicationController
end
def index
@page_title = "Login"
@title = "Login"
render :action => "index"
end
@ -26,7 +26,7 @@ class LoginController < ApplicationController
end
def forgot_password
@page_title = "Reset Password"
@title = "Reset Password"
render :action => "forgot_password"
end
@ -47,6 +47,8 @@ class LoginController < ApplicationController
end
def set_new_password
@title = "Reset Password"
if params[:token].blank? ||
!(@reset_user = User.find_by_password_reset_token(params[:token]))
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 ]
def index
@cur_url = "/messages"
@title = "Messages"
@new_message = Message.new
if params[:to]
@ -11,6 +14,9 @@ class MessagesController < ApplicationController
end
def create
@cur_url = "/messages"
@title = "Messages"
@new_message = Message.new(params[:message])
@new_message.author_user_id = @user.id
@ -25,6 +31,9 @@ class MessagesController < ApplicationController
end
def show
@cur_url = "/messages"
@title = @message.subject
@new_message = Message.new
@new_message.recipient_username = (@message.author_user_id == @user.id ?
@message.recipient.username : @message.author.username)

View file

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

View file

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

View file

@ -6,7 +6,6 @@ class SignupController < ApplicationController
end
@title = "Signup"
@page_title = "Create an Account"
end
def invited
@ -15,14 +14,13 @@ class SignupController < ApplicationController
return redirect_to "/"
end
@title = "Signup"
@page_title = "Create an Account"
if !(@invitation = Invitation.find_by_code(params[:invitation_code]))
flash[:error] = "Invalid or expired invitation"
return redirect_to "/signup"
end
@title = "Signup"
@new_user = User.new
@new_user.email = @invitation.email
@ -35,6 +33,8 @@ class SignupController < ApplicationController
return redirect_to "/signup"
end
@title = "Signup"
@new_user = User.new(params[:user])
@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])
if @story.can_be_seen_by_user?(@user)
@page_title = @story.title
@title = @story.title
else
@page_title = "[Story removed]"
@title = "[Story removed]"
end
@short_url = @story.short_id_url
@ -139,7 +139,7 @@ class StoriesController < ApplicationController
def show_comment
@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])

View file

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

View file

@ -37,9 +37,10 @@
<% end %>
<% 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">
<a href="<%= @cur_url %>"><%= @title %></a>
<a href="<%= @cur_url %>"><%= @heading %></a>
</span>
<% end %>