journalduhacker/app/views/users/show.html.erb
joshua stein 9f5e04bbba use _path for most things instead of _url
Instead of hard-coding the scheme and host everywhere, use _path
methods to show relative URLs.

Except that our previous setting of
Rails.application.routes.default_url_options in
config.after_initialize made this moot because Rails inserts that
host into all _path helpers for some reason.  So revert that
setting.

But then anything that wants an absolute URL doesn't know the
hostname and the root_url helper throws an exception.  So make a
Rails.application.root_url shortcut to pass the per-app settings in
Rails.application to root_url.

Now we can just use _path helpers most places but still use _url
ones where we need them, such as in RSS views and e-mail templates.
2015-01-02 17:02:55 -06:00

121 lines
3.3 KiB
Plaintext

<div class="box wide">
<div class="legend">
<% if !@showing_user.is_active? %>
<span class="inactive_user">
<% elsif @showing_user.is_new? %>
<span class="new_user">
<% else %>
<span>
<% end %>
<%= @showing_user.username %>
</span>
<% if @user && @showing_user.is_active? %>
(<a href="/messages?to=<%= @showing_user.username %>">Send a Message</a>)
<% end %>
</div>
<% if @showing_user.is_active? %>
<div id="gravatar">
<img src="<%= @showing_user.avatar_url %>">
</div>
<% end %>
<label class="required">Status:</label>
<span class="d"
<%= @showing_user.is_banned? ? raw("style=\"color: red;\"") : "" %>>
<% if @showing_user.is_banned? %>
Banned
<% elsif !@showing_user.is_active? %>
Inactive
<% else %>
Active
<% end %>
<%= @showing_user.is_admin? ? "administrator" :
(@showing_user.is_moderator? ? "moderator" : "user") %>
</span>
<br>
<label class="required">Joined:</label>
<span class="d">
<%= raw(time_ago_in_words_label(@showing_user.created_at)) %> ago
<% if @showing_user.invited_by_user %>
by invitation from
<%= link_to @showing_user.invited_by_user.try(:username),
@showing_user.invited_by_user %>
<% end %>
</span>
<br>
<% if @showing_user.is_banned? %>
<label class="required">Banned:</label>
<span class="d">
<%= raw(time_ago_in_words_label(@showing_user.banned_at)) %> ago
<% if @showing_user.banned_by_user %>
by <%= link_to @showing_user.banned_by_user.try(:username),
@showing_user.banned_by_user %>:
<em><%= @showing_user.banned_reason %></em>
<% end %>
</span>
<br>
<% end %>
<% if @showing_user.hats.any? %>
<label class="required">Hats:</label>
<span class="d">
<% @showing_user.hats.each do |hat| %>
<%= hat.to_html_label %>
<% end %>
</span>
<br>
<% end %>
<% if @showing_user.deleted_at? %>
<label class="required">Left:</label>
<span class="d">
<%= raw(time_ago_in_words_label(@showing_user.deleted_at)) %> ago
</span>
<br>
<% end %>
<label class="required">Karma:</label>
<span class="d">
<%= @showing_user.karma %>, averaging <%=
number_with_precision(@showing_user.average_karma, :precision => 2) %>
per story/comment
</span>
<br>
<label class="required">Stories Submitted:</label>
<span class="d">
<% tag = @showing_user.most_common_story_tag %>
<a href="/newest/<%= @showing_user.username %>"><%=
@showing_user.stories_submitted_count %></a><%= tag ? ", " : "" %>
<% if tag %>
most commonly tagged <a href="<%= tag_path(tag.tag) %>"
class="<%= tag.css_class %>" title="<%= tag.description %>"><%=
tag.tag %></a>
<% end %>
</span>
<br>
<label class="required">Comments Posted:</label>
<span class="d">
<a href="/threads/<%= @showing_user.username %>"><%=
@showing_user.comments_posted_count %></a>
</span>
<br>
<% if @showing_user.is_active? %>
<label class="required">About:</label>
<div id="user_about" class="shorten_first_p">
<% if @showing_user.about.present? %>
<%= raw @showing_user.linkified_about %>
<% else %>
<span class="na">A mystery...</span>
<% end %>
</div>
<% end %>
</div>