Added Who's Playing? screen
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
class StaticsController < ApplicationController
|
||||
|
||||
caches_action :online, expires_in: 10.seconds
|
||||
|
||||
def index
|
||||
if current_user
|
||||
redirect_to blogposts_path
|
||||
@@ -14,4 +16,8 @@ class StaticsController < ApplicationController
|
||||
def donate
|
||||
end
|
||||
|
||||
def online
|
||||
@players = JSON.parse(File.read("/etc/minecraft/redstoner/plugins/JavaUtils/players.json"))["players"]
|
||||
@players.collect!{ |p| User.find_by(uuid: p["uuid"].tr("-", "")) or User.new(name: p["name"], ign: p["name"], uuid: p["uuid"].tr("-", ""), role: Role.get("normal"), confirmed: true) }.sort_by!(&:role).reverse!
|
||||
end
|
||||
end
|
||||
|
||||
@@ -31,6 +31,9 @@
|
||||
<li>
|
||||
<%= link_to "Donate", donate_statics_path, class: ("active" if con == "statics" && params[:action] == "donate") %>
|
||||
</li>
|
||||
<li>
|
||||
<%= link_to "Who's Playing?", online_statics_path, class: ("active" if con == "statics" && params[:action] == "online") %>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="userbar">
|
||||
|
||||
17
app/views/statics/online.html.erb
Normal file
17
app/views/statics/online.html.erb
Normal file
@@ -0,0 +1,17 @@
|
||||
<% title "Who's Playing?" %>
|
||||
<h1>These players are currently playing on Redstoner:</h1>
|
||||
<div id="userlist">
|
||||
<% @players.each do |u| %>
|
||||
<div class="list-user">
|
||||
<%= link_to(u.avatar(64), u) %>
|
||||
<div class="detail">
|
||||
<%= render partial: "users/username", locals: { user: u } %><br>
|
||||
<i><%= u.ign %></i>
|
||||
<% unless u.id %>
|
||||
<br><i>(Not signed up)</i>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user