Initial changes to user show page

This commit is contained in:
Luke Barratt 2014-04-16 09:44:36 +01:00
parent 960e8b5a21
commit b88d65ec16
9 changed files with 93 additions and 90 deletions

View file

@ -152,8 +152,8 @@ $(function() {
}); });
// User page // User page
$("td#userNavi > div > a").click(function(){ $("#user-profile li a").click(function(){
$("td#userData").fadeOut("fast"); $("#user-data").fadeOut("fast");
$.ajax({ $.ajax({
type: "GET", type: "GET",
url: window.location.protocol + "//" + window.location.host + "/" + window.location.pathname + ".js?page=" + $(this).attr('id'), url: window.location.protocol + "//" + window.location.host + "/" + window.location.pathname + ".js?page=" + $(this).attr('id'),

View file

@ -8,6 +8,7 @@ body {
padding: 0; padding: 0;
width: 100%; width: 100%;
min-height: 100%; min-height: 100%;
background-color: transparent;
} }
body { body {

View file

@ -2,7 +2,7 @@
Contester Contester
*/ */
#matches { div#matches {
@include span-columns(12); @include span-columns(12);
margin: em(20) 0; margin: em(20) 0;
} }

View file

@ -2,7 +2,7 @@
Matches Listing Matches Listing
*/ */
#matches { table#matches {
width: 100%; width: 100%;
display: table; display: table;
table-layout: auto; table-layout: auto;

View file

@ -54,6 +54,26 @@
} }
} }
#user-profile {
.photo {
@include span-columns(12);
margin: em(20) 0;
text-align: center;
img {
display: inline-block;
float: none;
width: auto;
}
}
#user-data {
@include span-columns(12);
margin-bottom: em(20);
}
}
/* /*
Agenda Agenda
*/ */

View file

@ -54,18 +54,19 @@ module ApplicationHelper
def printtime time, format def printtime time, format
return unless time return unless time
out = "" out = ""
out << '<span style="font-style: italic; ">' out << '<span style="font-style: italic; ">'
out << time.strftime(format) out << time.strftime(format)
out << '</span>' out << '</span>'
raw out
out.html_safe
end end
def cascade model, list def cascade model, list
out = "" out = list.map do |element|
list.each do |element|
name = key = element name = key = element
item = ""
result = "" result = ""
if element.instance_of?(Array) if element.instance_of?(Array)
@ -91,12 +92,19 @@ module ApplicationHelper
result << h(str) result << h(str)
end end
out << "<p>" item << content_tag(:dt) do
out << "<b>#{name.to_s.capitalize.gsub(/_s/, '').gsub(/_/, ' ')}</b>: " "#{name.to_s.capitalize.gsub(/_s/, '').gsub(/_/, ' ')}"
out << result end
out << "</p>" item << content_tag(:dd) do
result
end
item
end
content_tag(:dl) do
out.join.html_safe
end end
raw out
end end
def abslink text, url def abslink text, url

View file

@ -1,8 +1,6 @@
<h2> <div class="group">
General information <h4>General information</h4>
</h2>
<div class="userFields">
<%= cascade @user, ["steamid"] %> <%= cascade @user, ["steamid"] %>
<%= link_to "http://steamidfinder.com/?STEAM_#{@user.steamid}" do %> <%= link_to "http://steamidfinder.com/?STEAM_#{@user.steamid}" do %>
<small>Search for corresponding Steam account</small> <small>Search for corresponding Steam account</small>
@ -12,17 +10,17 @@
<%= cascade @user.profile, ["town"] %> <%= cascade @user.profile, ["town"] %>
</div> </div>
<h3>
Miscellaneous
</h3>
<div class="userFields">
<div class="group">
<h4>Miscellaneous</h4>
<p> <p>
<b>Joined:</b> <%= longtime @user.created_at %> <strong>Joined:</strong> <%= longtime @user.created_at %>
</p> </p>
<p> <p>
<b>Lastvisit:</b> <%= longtime @user.lastvisit %> <strong>Last visit:</strong> <%= longtime @user.lastvisit %>
</p> </p>
<% if cuser and cuser.admin? %> <% if cuser and cuser.admin? %>
@ -31,7 +29,7 @@
</p> </p>
<% end %> <% end %>
<%= cascade @user, [ ["Comments", "posted_comments.count"], ["Matches", "matches.count"]] %> <%= cascade @user, [["Comments", "posted_comments.count"], ["Matches", "matches.count"]] %>
<% if @user.groups.count > 0 %> <% if @user.groups.count > 0 %>
<p> <p>
@ -56,8 +54,8 @@
Contact Contact
</h3> </h3>
<div class="userFields"> <div class="group">
<%= cascade @user.profile, ["irc", "msn", "icq", "web"] %> <%= cascade @user.profile, ["web"] %>
<% if cuser and cuser.admin? or @user.public_email %> <% if cuser and cuser.admin? or @user.public_email %>
<%= cascade @user, ["email_s"] %> <%= cascade @user, ["email_s"] %>
@ -83,7 +81,7 @@
Achievements Achievements
</h3> </h3>
<div class="userFields"> <div class="group">
<%= raw @user.profile.achievements_parsed %> <%= raw @user.profile.achievements_parsed %>
</div> </div>
<% end %> <% end %>

View file

@ -1,72 +1,47 @@
<table> <div id="user-profile">
<tr> <h1 class="fancy">
<td id="userNavi"> <span><%= @user.username %></span>
<div class="box"> </h1>
<%= image_tag @user.profile.avatar.url, :id => "user" %>
<div class="center bold"> <div class="photo">
<%= @user.username %> <%= image_tag @user.profile.avatar.url %>
</div>
</div> </div>
<br /> <div class="tabs tabbed">
<ul id="user-nav" class="tabs">
<div class="box center"> <li><a id="general">General</a></li>
<a href="javascript:;" id="general">General</a>
</div>
<div class="box center">
<a href="javascript:;" id="favorites">Favorites</a>
</div>
<div class="box center">
<a href="javascript:;" id="computer">Computer</a>
</div>
<% if @user.articles.count > 0 %>
<div class="box center">
<a href="javascript:;" id="articles">Articles</a>
</div>
<% end %>
<% if @user.movies.count > 0 %>
<div class="box center">
<a href="javascript:;" id="movies">Movies</a>
</div>
<% end %>
<% if @user.teamers.past.count > 0 %> <% if @user.teamers.past.count > 0 %>
<div class="box center"> <li><a id="teams">Teams</a></li>
<a href="javascript:;" id="teams">Teams</a>
</div>
<% end %> <% end %>
<% if @user.match_teams.count > 0 %> <% if @user.match_teams.count > 0 %>
<div class="box center"> <li><a id="matches">Matches</a></li>
<a href="javascript:;" id="matches">Matches</a>
</div>
<% end %> <% end %>
<% if @user.predictions.count > 0 %> <% if @user.predictions.count > 0 %>
<div class="box center"> <li><a id="predictions">Predictions</a></li>
<a href="javascript:;" id="predictions">Predictions</a>
</div>
<% end %> <% end %>
<div class="box center"> <% if @user.articles.count > 0 %>
<a href="javascript:;" id="comments">Comments</a> <li><a id="articles">Articles</a></li>
</div>
<div class="center">
<% if cuser and @user.can_update? cuser %>
<%= link_to 'Edit', edit_user_path(@user) %>
<%= link_to 'My Agenda', "/users/agenda/#{cuser.id}" %>
<% end %> <% end %>
</div>
</td>
<td id="userData" class="box"> <% if @user.movies.count > 0 %>
<li><a id="movies">Movies</a></li>
<% end %>
<li><a id="comments">Comments</a></li>
</ul>
<div id="user-data" class="tabbed-contents">
<%= render :partial => "general" %> <%= render :partial => "general" %>
</td> </div>
</tr> </div>
</table>
<% if cuser and @user.can_update? cuser %>
<%= link_to 'Edit', edit_user_path(@user), class: 'button' %>
<%= link_to 'My Agenda', "/users/agenda/#{cuser.id}", class: 'button' %>
<% end %>
</div>

View file

@ -1,7 +1,8 @@
$("td#userData").fadeIn("fast"); $("#user-data").fadeIn("fast");
$("td#userData").html("<%= escape_javascript(render(:partial => @page)) %>"); $("#user-data").html("<%= escape_javascript(render(:partial => @page)) %>");
<% if ["comments", "matches", "predictions", "teams"].include? @page %> <% if ["comments", "matches", "predictions", "teams"].include? @page %>
$("td#userData").removeClass("box"); $("#user-data").removeClass("box");
<% else %> <% else %>
$("td#userData").addClass("box"); $("#user-data").addClass("box");
<% end %> <% end %>