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_MAX_THREADS=16
PUMA_PORT=4000
PUMA_SOCKET=/tmp/ensl.sock
PUMA_TIMEOUT=30
MYSQL_DATABASE=ensl

View file

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

View file

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

View file

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

View file

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

View file

@ -10,6 +10,14 @@ div.article {
.content {
@include span-columns(12);
margin-bottom: em(40);
ul {
list-style-type: disc;
li {
margin-left: em(20);
}
}
}
.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| %>
<div class="indented">
<div class="left">
<% if cuser.new_messages.include?(message) %>
<p class = "bold">
<ul id="messages-nav" class="tabs">
<li>
<a href="#inbox">
Inbox (<%= cuser.new_messages.count %>/<%= cuser.received_messages.count %>)
</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 %>
<%= namelink message %>
<span class="description">
<%= sanitize message.text[0, 20] %>
</span>
<% if cuser.new_messages.include?(message) %>
</p>
<% else %>
<p>You have no incoming messages.</p>
<% end %>
</div>
<div class="right">
(<%= namelink message.sender %> on <%= longdate message.created_at %>)
<div id="sent" class="tab">
<% if cuser.sent_messages.any? %>
<% cuser.sent_messages.reverse_each do |message| %>
<div class="message">
<%= render partial: 'message', locals: { message: message } %>
</div>
<% end %>
<% else %>
<p>You have no sent messages.</p>
<% end %>
</div>
<br class="clear" />
</div>
<% end %>
</div>
<h1>Sent Messages (<%= cuser.sent_messages.count %> total)</h1>
<% cuser.sent_messages.reverse_each do |message| %>
<div class="indented">
<div class="left">
<%= 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 %>
<script type="text/javascript">
new Yetii({
id: 'messages'
});
</script>

View file

@ -1,29 +1,29 @@
<div class="wide box">
<h1>New message</h1>
<div id="messages">
<h1>New Message</h1>
<%= form_for(@message) do |f| %>
<%= form_for(@message, html: { class: 'square' }) do |f| %>
<%= f.error_messages %>
<%= f.hidden_field :recipient_id %>
<%= f.hidden_field :recipient_type %>
<p>
<%= f.label :sender %><br />
<div class="fields horizontal">
<%= f.label :sender %>
<%= f.select :sender_raw, cuser.to_s, {:include_blank => cuser.to_s} %>
</p>
<%= f.label :recipient %><br />
<%= text_field_tag :asdf, @message.recipient, :disabled => true %>
</p>
<p>
<%= f.label :title %><br />
<%= f.text_field :title %>
</p>
<p>
<%= f.label :text %><br />
<%= f.text_area :text %>
</p>
<p>
<%= f.submit 'Send' %>
</p>
<% end %>
<%= link_to 'Back', messages_path %>
</div>
<div class="fields horizontal">
<%= f.label :recipient %>
<%= text_field_tag :asdf, @message.recipient, :disabled => true %>
</div>
<div class="fields horizontal">
<%= f.label :title %>
<%= f.text_field :title %>
</div>
<div class="fields horizontal">
<%= f.label :text %>
<%= f.text_area :text %>
</div>
<div class="controls">
<%= f.submit 'Send Message' %>
</div>
<% end %>
</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| %>
<div class="article wide">
<h1 class="<%= message.recipient == @message.recipient ? "sender" : "recipient" %>">
<%= raw("&#187;") if message == @message %>
<%= namelink message %>
</h1>
<div class="clear content">
<%= raw message.text_parsed %>
<% @messages.each do |message| %>
<div class="message">
<h3 class="subject <%= message.recipient == @message.recipient ? "sender" : "recipient" %>">
<%= icon("chevron-right") if message == @message %>
<%= namelink message %>
</h3>
<div class="content">
<%= raw message.text_parsed %>
</div>
<p>Sent by: <%= namelink message.sender %> on <%= shortdate message.created_at %></p>
<p>
<%= link_to "Reply",
{ controller: "messages", action: "new", id: message.sender_type, id2: message.sender_id, title: message.title },
{ class: 'button tiny'} %>
</p>
</div>
<h4 class="left">
Sent by: <%= namelink message.sender %>
on <%= shortdate message.created_at %>
</h4>
<h3 class="right">
<%= link_to "Reply", :controller => "messages", :action => "new", :id => message.sender_type, :id2 => message.sender_id, :title => message.title %>
</h3>
</div>
<% end %>
<% end %>
<h2><%= link_to 'Back to the Inbox', messages_path %></h2>
<%= link_to 'Back to Messages', messages_path, class: 'button back' %>
</div>

View file

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

View file

@ -12,7 +12,7 @@ set :rbenv_type, :user
set :rbenv_ruby, '2.1.1'
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 :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 :rails_env, 'staging'

View file

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

View file

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