Further improvements to user pages

Added styling to private messages
Updated puma config and deployment scripts
This commit is contained in:
Luke Barratt 2014-04-15 23:04:43 +01:00
parent f2d908a06f
commit 4f26f5a559
16 changed files with 329 additions and 205 deletions

View file

@ -8,7 +8,6 @@ PUMA_WORKERS=1
PUMA_MIN_THREADS=1 PUMA_MIN_THREADS=1
PUMA_MAX_THREADS=16 PUMA_MAX_THREADS=16
PUMA_PORT=4000 PUMA_PORT=4000
PUMA_SOCKET=/tmp/ensl.sock
PUMA_TIMEOUT=30 PUMA_TIMEOUT=30
MYSQL_DATABASE=ensl MYSQL_DATABASE=ensl

View file

@ -88,7 +88,7 @@ $navbar-text: white;
$flash-text: white; $flash-text: white;
$flash-notice: #5a9aa8; $flash-notice: #5a9aa8;
$flash-success: #1f7f5c; $flash-success: $green;
$flash-warning: $red; $flash-warning: $red;
$flash-error: #e56c69; $flash-error: #e56c69;
@ -107,5 +107,5 @@ $input-dark-border-hover-colour: $blue;
$input-dark-border-focus-colour: $green; $input-dark-border-focus-colour: $green;
$button-primary: #5a9aa8; $button-primary: #5a9aa8;
$button-secondary: #1f7f5c; $button-secondary: $green;
$button-text: white; $button-text: white;

View file

@ -12,6 +12,7 @@
&.success { &.success {
@include flash($flash-success); @include flash($flash-success);
&:before { &:before {
content: "\f00c"; content: "\f00c";
} }
@ -19,6 +20,7 @@
&.error { &.error {
@include flash($flash-error); @include flash($flash-error);
&:before { &:before {
content: "\f00d"; content: "\f00d";
} }
@ -27,6 +29,7 @@
&.warning, &.warning,
&.alert { &.alert {
@include flash($flash-warning); @include flash($flash-warning);
&:before { &:before {
content: "\f071"; content: "\f071";
} }
@ -42,10 +45,6 @@ div#errors {
@include span-columns(12); @include span-columns(12);
margin-bottom: em(20); margin-bottom: em(20);
&:before {
height: 100%;
}
strong { strong {
@include span-columns(12); @include span-columns(12);
margin-bottom: em(10); margin-bottom: em(10);

View file

@ -3,6 +3,17 @@
*/ */
form { form {
.inline {
float: left;
display: inline-block;
width: auto;
margin-bottom: em(20);
input {
margin-bottom: 0;
}
}
.fields { .fields {
> .field_with_errors:first-child, > .field_with_errors:first-child,
> label { > label {
@ -122,10 +133,13 @@ form {
} }
&:hover { &:hover {
border: $input-border-width solid lighten($input-secondary, 20%);
cursor: pointer; cursor: pointer;
} }
&:checked { &:checked {
border-color: $button-secondary;
&:after { &:after {
content: $fa-var-check; content: $fa-var-check;
pointer-events: none; pointer-events: none;
@ -136,6 +150,7 @@ form {
font-size: em(22); font-size: em(22);
top: em(4); top: em(4);
left: em(5); left: em(5);
color: $button-secondary;
} }
} }
} }

View file

@ -23,7 +23,7 @@
left: 0; left: 0;
float: left; float: left;
width: em(44); width: em(44);
height: em(44); height: 100%;
padding: em(9); padding: em(9);
line-height: em(26); line-height: em(26);
text-align: center; text-align: center;

View file

@ -10,6 +10,14 @@ div.article {
.content { .content {
@include span-columns(12); @include span-columns(12);
margin-bottom: em(40); margin-bottom: em(40);
ul {
list-style-type: disc;
li {
margin-left: em(20);
}
}
} }
.author { .author {

View file

@ -53,3 +53,80 @@
} }
} }
} }
/*
Agenda
*/
#agenda {
h4 {
margin-bottom: 1em;
}
table {
margin-bottom: em(20);
}
form {
@include span-columns(12);
margin-bottom: em(20);
}
.tab {
:last-child {
margin-bottom: 0;
}
}
#teams {
table {
margin-bottom: em(40);
}
}
}
/*
Messages
*/
#messages {
h1 {
margin-bottom: 1em;
}
.tab {
:last-child {
margin-bottom: 0;
}
}
.message {
@include span-columns(12);
margin-bottom: em(20);
.subject {
margin-bottom: 1em;
}
.content {
margin-bottom: em(20);
}
a.message {
display: inline;
margin: 0;
float: none;
}
&.highlight {
font-weight: bold;
}
}
.back {
margin-top: em(20);
}
}

View file

@ -0,0 +1,9 @@
<h5><%= namelink message %></h5>
<p class="preview">
<%= sanitize message.text[0, 100] %>...
</p>
<p>
<%= namelink message.sender %> on <em><%= longdate message.created_at %></em>
</p>

View file

@ -1,39 +1,47 @@
<h1>Received Messages (<%= cuser.new_messages.count %> unread / <%= cuser.received_messages.count %> total)</h1> <div id="messages" class="tabbed">
<h1>Private Messages</h1>
<% cuser.received_messages.reverse_each do |message| %> <ul id="messages-nav" class="tabs">
<div class="indented"> <li>
<div class="left"> <a href="#inbox">
<% if cuser.new_messages.include?(message) %> Inbox (<%= cuser.new_messages.count %>/<%= cuser.received_messages.count %>)
<p class = "bold"> </a>
</li>
<li>
<a href="#sent">
Sent (<%= cuser.sent_messages.count %>)
</a>
</li>
</ul>
<div class="tabbed-contents">
<div id="inbox" class="tab">
<% if cuser.received_messages.any? %>
<% cuser.received_messages.reverse_each do |message| %>
<div class="message <% 'highlight' if cuser.new_messages.include?(message) %>">
<%= render partial: 'message', locals: { message: message } %>
</div>
<% end %> <% end %>
<%= namelink message %> <% else %>
<span class="description"> <p>You have no incoming messages.</p>
<%= sanitize message.text[0, 20] %>
</span>
<% if cuser.new_messages.include?(message) %>
</p>
<% end %> <% end %>
</div> </div>
<div class="right"> <div id="sent" class="tab">
(<%= namelink message.sender %> on <%= longdate message.created_at %>) <% if cuser.sent_messages.any? %>
<% cuser.sent_messages.reverse_each do |message| %>
<div class="message">
<%= render partial: 'message', locals: { message: message } %>
</div> </div>
<br class="clear" /> <% end %>
<% else %>
<p>You have no sent messages.</p>
<% end %>
</div> </div>
<% end %> </div>
</div>
<h1>Sent Messages (<%= cuser.sent_messages.count %> total)</h1> <script type="text/javascript">
new Yetii({
<% cuser.sent_messages.reverse_each do |message| %> id: 'messages'
<div class="indented"> });
<div class="left"> </script>
<%= namelink message %>
<span class="description">
<%= sanitize message.text[0, 20] %>
</span>
</div>
<div class="right">
(<%= namelink message.recipient %> on <%= longdate message.created_at %>)
</div>
<br class="clear" />
</div>
<% end %>

View file

@ -1,29 +1,29 @@
<div class="wide box"> <div id="messages">
<h1>New message</h1> <h1>New Message</h1>
<%= form_for(@message) do |f| %> <%= form_for(@message, html: { class: 'square' }) do |f| %>
<%= f.error_messages %> <%= f.error_messages %>
<%= f.hidden_field :recipient_id %> <%= f.hidden_field :recipient_id %>
<%= f.hidden_field :recipient_type %> <%= f.hidden_field :recipient_type %>
<p> <div class="fields horizontal">
<%= f.label :sender %><br /> <%= f.label :sender %>
<%= f.select :sender_raw, cuser.to_s, {:include_blank => cuser.to_s} %> <%= f.select :sender_raw, cuser.to_s, {:include_blank => cuser.to_s} %>
</p> </div>
<%= f.label :recipient %><br /> <div class="fields horizontal">
<%= f.label :recipient %>
<%= text_field_tag :asdf, @message.recipient, :disabled => true %> <%= text_field_tag :asdf, @message.recipient, :disabled => true %>
</p> </div>
<p> <div class="fields horizontal">
<%= f.label :title %><br /> <%= f.label :title %>
<%= f.text_field :title %> <%= f.text_field :title %>
</p> </div>
<p> <div class="fields horizontal">
<%= f.label :text %><br /> <%= f.label :text %>
<%= f.text_area :text %> <%= f.text_area :text %>
</p> </div>
<p> <div class="controls">
<%= f.submit 'Send' %> <%= f.submit 'Send Message' %>
</p> </div>
<% end %> <% end %>
<%= link_to 'Back', messages_path %>
</div> </div>

View file

@ -1,22 +1,24 @@
<h2><%= link_to 'Back to the Inbox', messages_path %></h2><br/> <div id="messages">
<h1>Private Message</h1>
<% @messages.each do |message| %> <% @messages.each do |message| %>
<div class="article wide"> <div class="message">
<h1 class="<%= message.recipient == @message.recipient ? "sender" : "recipient" %>"> <h3 class="subject <%= message.recipient == @message.recipient ? "sender" : "recipient" %>">
<%= raw("&#187;") if message == @message %> <%= icon("chevron-right") if message == @message %>
<%= namelink message %> <%= namelink message %>
</h1> </h3>
<div class="clear content"> <div class="content">
<%= raw message.text_parsed %> <%= raw message.text_parsed %>
</div> </div>
<h4 class="left"> <p>Sent by: <%= namelink message.sender %> on <%= shortdate message.created_at %></p>
Sent by: <%= namelink message.sender %> <p>
on <%= shortdate message.created_at %> <%= link_to "Reply",
</h4> { controller: "messages", action: "new", id: message.sender_type, id2: message.sender_id, title: message.title },
<h3 class="right"> { class: 'button tiny'} %>
<%= link_to "Reply", :controller => "messages", :action => "new", :id => message.sender_type, :id2 => message.sender_id, :title => message.title %> </p>
</h3>
</div> </div>
<% end %> <% end %>
<%= link_to 'Back to Messages', messages_path, class: 'button back' %>
</div>
<h2><%= link_to 'Back to the Inbox', messages_path %></h2>

View file

@ -1,5 +1,5 @@
<div id="agendaTab"> <div id="agenda" class="tabbed">
<ul id="agendaTab-nav" class="tabs"> <ul id="agenda-nav" class="tabs">
<li><a href="#teams">Teams</a></li> <li><a href="#teams">Teams</a></li>
<li><a href="#matches">Matches</a></li> <li><a href="#matches">Matches</a></li>
<li><a href="#articles">Articles</a></li> <li><a href="#articles">Articles</a></li>
@ -9,9 +9,11 @@
<li><a href="#bans">Bans</a></li> <li><a href="#bans">Bans</a></li>
</ul> </ul>
<div class="box wide tabs"> <div class="tabbed-contents">
<div class="tab" id="teams"> <div class="tab" id="teams">
<table class="data"> <h4>Your Teams</h4>
<table class="teams">
<tr> <tr>
<th>Name</th> <th>Name</th>
<th>Comment</th> <th>Comment</th>
@ -21,7 +23,7 @@
<% @user.teamers.active.each do |teamer| %> <% @user.teamers.active.each do |teamer| %>
<tr> <tr>
<td <% if teamer.team == @user.team %>class="bold"<% end %>> <td class="<%= 'current' if teamer.team == @user.team %>">
<%= link_to (h teamer.team.name), teamer.team %> <%= link_to (h teamer.team.name), teamer.team %>
</td> </td>
<td><%= h teamer.comment %></td> <td><%= h teamer.comment %></td>
@ -29,12 +31,11 @@
<td> <td>
<% if @user.team != teamer.team %> <% if @user.team != teamer.team %>
<%= form_for @user do |u| %> <%= form_for @user do |u| %>
<%= link_to("Set as Primary", user_path(@user, :user => { :team_id => teamer.team.id }), :method => :put, :confirm => "Are you sure?") %> <%= link_to("Set as Primary", user_path(@user, user: { team_id: teamer.team.id }), method: :put, confirm: "Are you sure?") %>
<%= link_to 'Leave', teamer, :confirm => 'Are you sure?', :method => :delete %>
<% end %> <% end %>
<% else %>
<%= link_to 'Leave', teamer, :confirm => 'Are you sure?', :method => :delete %>
<% end %> <% end %>
<%= link_to 'Leave', teamer, confirm: 'Are you sure?', method: :delete, class: 'button tiny' %>
</td> </td>
</tr> </tr>
<% end %> <% end %>
@ -44,33 +45,32 @@
<%= form_for @teamer do |f| %> <%= form_for @teamer do |f| %>
<%= f.error_messages %> <%= f.error_messages %>
<%= f.hidden_field :user_id %> <%= f.hidden_field :user_id %>
<p>
<h3>
Join an existing team:
</h3>
<h4>Join an existing team</h4>
<div class="fields inline">
<%= f.select :team_id, Team.active.collect {|t| [t.name, t.id]} %> <%= f.select :team_id, Team.active.collect {|t| [t.name, t.id]} %>
<%= f.submit "Join" %> </div>
</p> <div class="controls inline">
<%= f.submit "Join", class: 'button' %>
</div>
<% end %> <% end %>
<% else %> <% else %>
<p> <div class="flash warning">
You can join only one team at time. <p>You can join only be a member of one team at a time.</p>
Currently you are trying to join <%= namelink @user.teamers.joining.first.team %>. <p>Currently you are trying to join <%= namelink @user.teamers.joining.first.team %></p>
You can cancel this request by clicking <%= link_to "here", @user.teamers.joining.first, :method => :delete %>. <p>You can cancel this request by clicking "Cancel Request"</p>
</p> </div>
<%= link_to "Cancel Request", @user.teamers.joining.first, method: :delete, class: 'button' %>
<% end %> <% end %>
<p> <%= link_to 'Create a new team', new_team_path, class: 'button' %>
<%= link_to 'Create a new team', new_team_path %>
</p>
</div> </div>
<div class="tab" id="matches"> <div class="tab" id="matches">
<% if @user.challenges_received.future.pending.count > 0 %> <% if @user.challenges_received.future.pending.count > 0 %>
<h3 class="center"> <h4>Pending challenges for your response</h4>
Pending challenges for your response
</h3>
<table class="data"> <table class="data">
<tr> <tr>
@ -84,7 +84,7 @@
<tr> <tr>
<td> <td>
<%= link_to ("Open"), challenge %> <%= link_to ("Open"), challenge %>
| <%= link_to "Send a PM", :controller => "messages", :action => "new", :id => "Team", :id2 => challenge.contester1.team %> <%= link_to "Send a PM", controller: "messages", action: "new", id: "Team", id2: challenge.contester1.team %>
</td> </td>
<td><%= namelink challenge.contester1 %></td> <td><%= namelink challenge.contester1 %></td>
<td><%= longtime challenge.match_time %></td> <td><%= longtime challenge.match_time %></td>
@ -94,13 +94,10 @@
</tr> </tr>
<% end %> <% end %>
</table> </table>
<br />
<% end %> <% end %>
<% if @user.challenges_sent.future.count > 0 %> <% if @user.challenges_sent.future.count > 0 %>
<h3 class="center"> <h4>Sent challenges</h4>
Sent challenges
</h3>
<table class="data"> <table class="data">
<tr> <tr>
@ -130,9 +127,7 @@
<% end %> <% end %>
<% if @user.ref? and Match.future.unreffed.ordered.count > 0 %> <% if @user.ref? and Match.future.unreffed.ordered.count > 0 %>
<h3 class="center"> <h4>Matches without referee</h4>
Matches without referee
</h3>
<table class="data"> <table class="data">
<tr> <tr>
@ -147,12 +142,17 @@
<td><%= shorttime match.match_time %></td> <td><%= shorttime match.match_time %></td>
<td> <td>
<%= link_to 'Referee this match', <%= link_to 'Referee this match',
:remote => true, remote: true,
:url => {:controller => "matches", :action => "update", :id => match.id, url: {
:match => {:referee_id => @user.id}}, :method => "put", controller: "matches", action: "update", id: match.id,
:loading => "$('matchlink_#{match.id}').parentNode.innerHTML='Processing..';", match: {
:success => "$('matchlink_#{match.id}').parentNode.innerHTML='Complete';", referee_id: @user.id
:html => {:id => "matchlink_#{match.id}"} %> }
},
method: "put",
loading: "$('matchlink_#{match.id}').parentNode.innerHTML='Processing..';",
success: "$('matchlink_#{match.id}').parentNode.innerHTML='Complete';",
html: { id: "matchlink_#{match.id}" } %>
</td> </td>
</tr> </tr>
<% end %> <% end %>
@ -160,9 +160,7 @@
<% end %> <% end %>
<% if @user.upcoming_matches.length > 0 # TODO: fix this %> <% if @user.upcoming_matches.length > 0 # TODO: fix this %>
<h3 class="center"> <h4>Upcoming matches for your concern</h4>
Upcoming matches for your concern
</h3>
<table class="data"> <table class="data">
<tr> <tr>
@ -178,13 +176,10 @@
</tr> </tr>
<% end %> <% end %>
</table> </table>
<br />
<% end %> <% end %>
<% if @user.past_matches.length > 0 %> <% if @user.past_matches.length > 0 %>
<h3 class="center"> <h4>Past matches waiting for scoring or lineup</h4>
Past matches waiting for scoring or lineup
</h3>
<table class="data"> <table class="data">
<tr> <tr>
@ -200,43 +195,55 @@
</tr> </tr>
<% end %> <% end %>
</table> </table>
<br />
<% end %> <% end %>
</div> </div>
<div class="tab" id="articles"> <div class="tab" id="articles">
<%= render :partial => "articles/list", :locals => {:articles => @user.articles} %> <% if @user.articles.size > 0 %>
<%= link_to 'New article', new_article_path %> <%= render partial: "articles/list", locals: { articles: @user.articles } %>
<% end %>
<%= link_to 'New article', new_article_path, class: 'button' %>
</div> </div>
<div class="tab" id="movies"> <div class="tab" id="movies">
<%= render :partial => "movies/movie", :collection => @user.movies %> <%= render partial: "movies/movie", collection: @user.movies %>
<%= link_to "New Movie", { controller: "data_files", action: "new", id: Directory::MOVIES }, { class: 'button' } %>
</div> </div>
<div class="tab" id="servers"> <div class="tab" id="servers">
<%= render :partial => "servers/server", :collection => @user.servers %> <%= render partial: "servers/server", collection: @user.servers %>
<%= link_to 'New server', new_server_path %>
<%= link_to 'New server', new_server_path, class: 'button' %>
</div> </div>
<div class="tab" id="issues"> <div class="tab" id="issues">
<h3> <% if @user.issues.size > 0 %>
Issues created by you <h4>Issues created by you</h4>
</h3> <%= render partial: "issues/list", locals: { issues: @user.issues } %>
<%= render :partial => "issues/list", :locals => {:issues => @user.issues} %> <% end %>
<h3> <% if @user.open_issues.size > 0 %>
Open issues assigned to you <h4>Open issues assigned to you</h4>
</h3> <%= render partial: "issues/list", locals: { issues: @user.open_issues } %>
<%= render :partial => "issues/list", :locals => {:issues => @user.open_issues} %> <% end %>
<%= link_to 'New issue', new_issue_path %>
<%= link_to 'New issue', new_issue_path, class: 'button' %>
</div> </div>
<div class="tab" id="bans"> <div class="tab" id="bans">
<%= render :partial => "bans/list", :locals => {:bans => @user.bans.effective} %> <% if @user.bans.effective.size > 0 %>
</div> <%= render partial: "bans/list", locals: { bans: @user.bans.effective } %>
<% else %>
<p>You have no effective bans currently.</p>
<% end %>
</div> </div>
</div> </div>
</div>
<script type="text/javascript"> <script type="text/javascript">
var tabber1 = new Yetii({id: 'agendaTab'}); new Yetii({
</script> id: 'agenda'
});
</script>

View file

@ -12,7 +12,7 @@ set :rbenv_type, :user
set :rbenv_ruby, '2.1.1' set :rbenv_ruby, '2.1.1'
set :dotenv_role, [:app, :web] set :dotenv_role, [:app, :web]
set :puma_config, -> { File.join(shared_path, 'puma.rb') } set :puma_config, -> { File.join(current_path, 'config', 'puma.rb') }
set :puma_pid, -> { File.join(shared_path, 'tmp', 'pids', 'puma.pid') } set :puma_pid, -> { File.join(shared_path, 'tmp', 'pids', 'puma.pid') }
set :writable_dirs, %w{public tmp} set :writable_dirs, %w{public tmp}

View file

@ -1,4 +1,4 @@
set :branch, 'feature-redesign' set :branch, 'develop'
set :deploy_to, '/var/www/virtual/ensl.org/staging/rails' set :deploy_to, '/var/www/virtual/ensl.org/staging/rails'
set :rails_env, 'staging' set :rails_env, 'staging'

View file

@ -46,7 +46,7 @@ en:
hltv_stopped: "HLTV's stopped. Demos saved." hltv_stopped: "HLTV's stopped. Demos saved."
hltv_moved: "HLTV moved." hltv_moved: "HLTV moved."
hltv_movedd: "HLTVs moved to: " hltv_movedd: "HLTVs moved to: "
messages_create: "Message was successfully created." message_create: "Message was successfully sent."
movies_create: "Movie was successfully created." movies_create: "Movie was successfully created."
movies_update: "Movie was successfully updated." movies_update: "Movie was successfully updated."
execute: "Executed: " execute: "Executed: "

View file

@ -2,8 +2,8 @@ require "dotenv"
Dotenv.load Dotenv.load
base_path = (ENV['DEPLOY_PATH'] || Dir.pwd) base_path = (ENV['DEPLOY_PATH'] || Dir.pwd)
current_path = "#{base_path}" current_path = "#{base_path}/current"
shared_path = "#{base_path}" shared_path = "#{base_path}/shared"
stderr_path = "#{shared_path}/log/puma.stderr.log" stderr_path = "#{shared_path}/log/puma.stderr.log"
stdout_path = "#{shared_path}/log/puma.stdout.log" stdout_path = "#{shared_path}/log/puma.stdout.log"
@ -11,7 +11,7 @@ tag 'ENSL'
preload_app! preload_app!
daemonize true daemonize true
directory base_path directory current_path
pidfile "#{shared_path}/tmp/pids/puma.pid" pidfile "#{shared_path}/tmp/pids/puma.pid"
state_path "#{shared_path}/tmp/pids/puma.state" state_path "#{shared_path}/tmp/pids/puma.state"
stdout_redirect stdout_path, stderr_path stdout_redirect stdout_path, stderr_path
@ -19,7 +19,7 @@ stdout_redirect stdout_path, stderr_path
environment ENV['RACK_ENV'] || 'production' environment ENV['RACK_ENV'] || 'production'
rackup DefaultRackup rackup DefaultRackup
bind "unix://#{shared_path}#{ENV['PUMA_SOCKET']}" bind "unix://#{shared_path}/tmp/sockets/puma.sock"
port Integer(ENV['PUMA_PORT'] || 4000) port Integer(ENV['PUMA_PORT'] || 4000)
worker_timeout Integer(ENV['PUMA_TIMEOUT'] || 30) worker_timeout Integer(ENV['PUMA_TIMEOUT'] || 30)