Method: BaseHelper#page_title

Defined in:
app/helpers/base_helper.rb

#page_titleObject



112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
# File 'app/helpers/base_helper.rb', line 112

def page_title
  divider = " | ".html_safe

  app_base = configatron.community_name
  tagline = " #{divider} #{configatron.community_tagline}"
title = app_base

case controller.controller_name
  when 'base'
      title += tagline
    when 'pages'
      if @page and @page.title
        title = @page.title + divider + app_base + tagline
      end
  when 'posts'
      if @post and @post.title
        title = @post.title + divider + app_base + tagline
        title += (@post.tags.empty? ? '' : "#{divider}#{:keywords.l}: " + @post.tags[0...4].join(', ') )
        @canonical_url = user_post_url(@post.user, @post)
      end
    when 'users'
      if @user && !@user.new_record? && @user.
        title = @user.
        title += divider + app_base + tagline
        @canonical_url = user_url(@user)
      else
        title = :showing_users.l+divider + app_base + tagline
      end
    when 'photos'
      if @user and @user.
        title = :users_photos.l(:user => @user.) + divider + app_base + tagline
      end
    when 'clippings'
      if @user and @user.
        title = :user_clippings.l(:user => @user.) + divider + app_base + tagline
      end
    when 'tags'
      case controller.action_name
        when 'show'
          if params[:type]
            title = I18n.translate('all_' + params[:type].downcase.pluralize + '_tagged', :tag_name => @tags.map(&:name).join(', '))
          else
            title = :posts_photos_and_bookmarks.l(:name => @tags.map(&:name).join(', '))
          end
          title += " (#{:related_tags.l}: #{@related_tags.join(', ')})" if @related_tags
          title += divider + app_base
          @canonical_url = tag_url(URI.escape(URI.escape(@tags_raw), /[\/.?#]/)) if @tags_raw
        else
          title = "Showing tags #{divider} #{app_base} #{tagline}"
        end
    when 'categories'
      if @category and @category.name
        title = :posts_photos_and_bookmarks.l(:name => @category.name) + divider + app_base + tagline
      else
        title = :showing_categories.l + divider + app_base + tagline
      end
    when 'sessions'
      title = :login.l + divider + app_base + tagline
  end

  if @page_title
    title = @page_title + divider + app_base + tagline
  elsif title == app_base
  title = :showing.l + ' ' + controller.controller_name + divider + app_base + tagline
  end

  title
end