more progress on this

This commit is contained in:
jamal 2014-10-13 22:30:28 -04:00
parent 4742be0ea5
commit 945061e812
35 changed files with 13156 additions and 8 deletions

View file

@ -41,9 +41,10 @@ gem 'neat', '~> 1.6.0'
gem 'haml', '~> 4.0.5'
gem 'rails_autolink', '~> 1.1.5'
gem 'active_model_serializers'
gem 'ember-source', '~> 1.8.0.beta.4'
gem 'ember-data-source', '~> 1.0.0.beta.10'
gem 'ember-rails', '~> 0.15.0'
gem 'es5-shim-rails', '~> 4.0.1'
group :assets do
gem 'uglifier', '~> 2.5.0'

View file

@ -126,6 +126,9 @@ GEM
ember-source (1.8.0.beta.4)
handlebars-source (~> 1.0)
erubis (2.7.0)
es5-shim-rails (4.0.1)
actionpack (>= 3.1)
railties (>= 3.1)
exceptional (2.0.33)
rack
execjs (2.2.1)
@ -277,6 +280,7 @@ PLATFORMS
DEPENDENCIES
active_link_to (~> 1.0.2)
active_model_serializers
annotate (~> 2.6.2)
bbcoder (~> 1.0.1)
better_errors (~> 1.1.0)
@ -296,9 +300,9 @@ DEPENDENCIES
database_cleaner (~> 1.2.0)
dotenv-rails (~> 0.10.0)
dynamic_form (~> 1.1.4)
ember-data-source (~> 1.0.0.beta.10)
ember-rails (~> 0.15.0)
ember-source (~> 1.8.0.beta.4)
es5-shim-rails (~> 4.0.1)
exceptional (~> 2.0.33)
factory_girl_rails (~> 4.4.1)
faraday (~> 0.9.0)

View file

@ -1 +1,45 @@
window.ENSL = Ember.Application.Create();
/**
* app.js is for the ember specific application
*/
//= require jquery
//= require handlebars
//= require ember
//= require es5-shim/es5-shim
//= require es5-shim/es5-sham
//= require ember-data-local
//= require_self
//= require router
//= require helpers
//= require_directory ./routes
//= require_directory ./controllers
//= require_directory ./models
//= require_tree ./templates
window.ENSL = Ember.Application.create({
rootElement: '#content'
});
ENSL.ApplicationAdapter = DS.ActiveModelAdapter.extend({
});
ENSL.Router.reopen({
location: 'history'
});
ENSL.ApplicationRoute = Ember.Route.extend({
});
ENSL.FullLayoutView = Ember.View.extend({
layoutName: 'layouts/full'
});
ENSL.FullLayoutRoute = Ember.Route.extend({
renderTemplate: function(controller, model) {
this.render(this.templateName, {
view: 'full_layout',
});
}
});

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,12 @@
Ember.Handlebars.helper('flag', function(country) {
if (country) {
return new Ember.Handlebars.SafeString('<img src="/assets/flags/' + country + '.png" class="flag" />');
}
return new Ember.Handlebars.SafeString('<img src="/assets/flags/EU.png" class="flag" />');
});
Ember.Handlebars.helper('votingBar', function(name, current, total) {
var bar = '<div class="voting-bar"><div class="label">' + name + '</div>';
bar += '<div class="vote-progress"><div style="width: ' + Math.round(current/total*100) + '%"></div></div></div>';
return new Ember.Handlebars.SafeString(bar);
});

View file

@ -0,0 +1,3 @@
ENSL.Category = DS.Model.extend({
name: DS.attr()
});

View file

@ -0,0 +1,12 @@
ENSL.Gather = DS.Model.extend({
status: DS.attr(),
votes: DS.attr(),
turn: DS.attr(),
lastpick1: DS.attr(),
lastpick2: DS.attr(),
category: DS.belongsTo('category'),
gatherers: DS.hasMany('gatherer'),
gatherServers: DS.hasMany('gatherServer'),
gatherMaps: DS.hasMany('gatherMap')
});

View file

@ -0,0 +1,5 @@
ENSL.GatherMap = DS.Model.extend({
votes: DS.attr('number', { defaultValue: 0 }),
map: DS.belongsTo('map')
});

View file

@ -0,0 +1,5 @@
ENSL.GatherServer = DS.Model.extend({
votes: DS.attr('number', { defaultValue: 0 }),
server: DS.belongsTo('server')
});

View file

@ -0,0 +1,3 @@
ENSL.Gatherer = DS.Model.extend({
user: DS.belongsTo('user')
});

View file

@ -0,0 +1,3 @@
ENSL.Map = DS.Model.extend({
name: DS.attr()
});

View file

@ -0,0 +1,3 @@
ENSL.Server = DS.Model.extend({
name: DS.attr()
});

View file

@ -0,0 +1,4 @@
ENSL.User = DS.Model.extend({
username: DS.attr(),
country: DS.attr()
});

View file

@ -0,0 +1,4 @@
ENSL.Router.map(function() {
// this.resource('gathers');
this.resource('gather', { path: '/gathers/:gather_id' });
});

View file

@ -0,0 +1,7 @@
ENSL.GatherRoute = ENSL.FullLayoutRoute.extend({
templateName: 'gathers/gather',
model: function(params) {
return this.store.find('gather', params.gather_id);
},
});

View file

@ -0,0 +1,3 @@
ENSL.GathersRoute = Ember.Route.extend({
});

View file

@ -0,0 +1,31 @@
<footer class="footer">
<div class="content wrapper">
<div class="footer-links">
{{!--
<ul>
<li><h3><%= link_to "Contests", controller: "contests", action: "current" %></h3></li>
<li><%= link_to "Current", "/contests/current" %></li>
<li><%= link_to "NS2 History", "/contests/historical/NS2" %></li>
<li><%= link_to "NS1 History", "/contests/historical/NS1" %></li>
</ul>
<ul>
<li><h3><%= link_to "Gathers", Gather.last %></h3></li>
<li><%= link_to "Introduction", article_url(464) %></li>
<li><%= link_to "Archives", "/gathers/" %></li>
</ul>
<ul>
<li><h3><%= link_to "Articles", articles_url %></h3></li>
<li><%= link_to "Articles", articles_url %></li>
<li><%= link_to "NS Movies", movies_url %></li>
<li><%= link_to "Files", directory_url(Directory::ROOT) %></li>
</ul>
<ul>
<li><h3><%= link_to "Forums", forums_url %></h3></li>
<li><%= link_to "Index", forums_url %></li>
<li><%= link_to "Rules", "/topics/12" %></li>
</ul>
--}}
</div>
<p>&copy; {{!-- <%= Time.zone.now.year %> --}} NSL</p>
</div>
</footer>

View file

@ -0,0 +1,15 @@
<header>
<div class="banner <%= 'authenticated' if cuser %>">
<div class="wrapper">
<div id="authentication" class="{{!-- <%= 'admin' if cuser && cuser.admin? %> --}}">
{{!--
<% if cuser %>
<%= render partial: "widgets/logged" %>
<% else %>
<%= render partial: "widgets/login" %>
<% end %>
--}}
</div>
</div>
</div>
</header>

View file

@ -0,0 +1,71 @@
<nav id="menu">
<div class="wrapper">
<div id="logo">
<%= link_to image_tag("themes/#{active_theme}/logo.png"), root_path %>
</div>
<ul class="navigation">
<li class="icon">
<%= active_link_to root_path, active: ["articles", "news_index"], class: 'news' do %>
News
<% end %>
</li>
<li class="dropdown icon">
<%= active_link_to({ controller: "contests", action: "current" }, class: 'contests') do %>
Contests
<% end %>
<ul>
<li><%= link_to "Rules", latest_rules %></li>
<li><%= link_to "Historical", "/contests" %></li>
<li><%= link_to "NS1 History", "/contests/historical/NS1" %></li>
<li><%= link_to "NS2 History", "/contests/historical/NS2" %></li>
</ul>
</li>
<li class="dropdown">
<%= active_link_to Gather.last, class: 'gathers' do %>
Gathers
<span class="count"><%= Gather.player_count_for_game('NS2') %>/<%= Gather::FULL %></span>
<% end %>
<ul>
<li><%= link_to "Introduction", article_url(464) %></li>
<li><%= link_to "Archives", "/gathers/" %></li>
</ul>
</li>
<li class="dropdown icon">
<%= active_link_to articles_path, class: 'articles' do %>
Articles
<% end %>
<ul>
<li><%= link_to "Hall of Fame", article_url(Article::HOF) %></li>
<li><%= link_to "History", article_url(Article::HISTORY) %></li>
<li><%= link_to "Movies", movies_url %></li>
<li><%= link_to "Files", directory_url(Directory::ROOT) %></li>
</ul>
</li>
<li class="dropdown icon">
<%= active_link_to forums_path, active: [["forums", "topics"]], class: 'forums' do %>
Forums
<% end %>
<ul>
<li><%= link_to "Index", forums_path %></li>
<li><%= link_to "Rules", "/topics/12" %></li>
</ul>
</li>
<li class="icon">
<%= active_link_to({ controller: "teams", action: :index }, class: 'teams') do %>
Teams
<% end %>
</li>
<li class="dropdown icon">
<%= active_link_to({ controller: "users", action: :index }, class: 'users') do %>
Users
<% end %>
<ul>
<li><%= link_to "Staff", controller: "about", action: "staff" %></li>
<li><%= link_to "Bans", bans_url %></li>
<li><%= link_to "Contact", new_issue_path %></li>
</ul>
</li>
</ul>
</div>
</nav>

View file

@ -0,0 +1,58 @@
<div id="gather">
<h1 class="fancy">
<span>
{{#link-to 'gather' gather}}{{category.name}} Gather{{/link-to}}
</span>
</h1>
<div id="gather-area">
<div class="gather-columns">
<div class="data players">
<div class="contents">
<h4>Players</h4>
<ul id="gatherers">
{{#each gatherers}}
<li>
{{flag user.country}}
{{user.username}}
</li>
{{/each}}
</ul>
</div>
</div>
<div class="gather-content">
<div class="voting">
<div class="data servers">
<div class="contents">
<h4>Servers</h4>
<ul class="votes">
{{#each gatherServers}}
<li>{{votingBar server.name votes 12}}</li>
{{/each}}
</ul>
</div>
</div>
<div class="data maps">
<div class="contents">
<h4>Maps</h4>
<ul class="votes">
{{#each gatherMaps}}
<li>{{votingBar map.name votes 12}}</li>
{{/each}}
</ul>
</div>
</div>
</div>
<div class="data chat">
<div class="contents">
<h4>Chat</h4>
</div>
</div>
</div>
</div>
</div>
</div>

View file

@ -0,0 +1,2 @@
{{!-- This is a placeholder for when we start doing layout in ember rather than rails --}}
{{yield}}

View file

@ -118,7 +118,6 @@
}
.data {
@include span-columns(4);
@include pad;
border-radius: $column-border-width + $column-border-radius;
padding-bottom: 20px;
@ -144,6 +143,8 @@
}
.players {
@include span-columns(4);
height: 600px;
.captain {
color: $gold;
@ -155,6 +156,49 @@
padding: 0 10px;
}
}
.gather-content {
@include span-columns(8);
.voting {
@include span-columns(12);
.data {
@include span-columns(6);
height: 350px;
}
.voting-bar {
@include span-columns(12);
height: 20px;
font-size: 0.9em;
.label {
@include span-columns(4);
}
.vote-progress {
@include span-columns(8);
height: 18px;
position: relative;
background: #555;
padding: 2px;
div {
height: 14px;
min-width: 1%;
position: absolute;
background: #ff000e;
}
}
}
}
.chat {
@include span-columns(12);
height: 250px;
}
}
}
#gather-stats {

View file

@ -1,13 +1,16 @@
class GathersController < ApplicationController
before_filter :get_gather, except: [:latest, :index, :create]
respond_to :html, :js
respond_to :html, :js, :json
def index
@gathers = Gather.ordered.limit(50).all
end
def show
render layout: 'full'
respond_to do |format|
format.html { render "layouts/ember", layout: false }
format.json { render json: @gather }
end
end
def latest

View file

@ -0,0 +1,4 @@
class ApplicationSerializer < ActiveModel::Serializer
embed :ids, :include => true
attributes :id
end

View file

@ -0,0 +1,3 @@
class CategorySerializer < ApplicationSerializer
attributes :id, :name
end

View file

@ -0,0 +1,5 @@
class GatherMapSerializer < ApplicationSerializer
attributes :id, :votes
has_one :map
end

View file

@ -0,0 +1,8 @@
class GatherSerializer < ApplicationSerializer
attributes :id, :status, :votes, :turn, :lastpick1, :lastpick2
has_one :category
has_many :gatherers
has_many :gather_servers
has_many :gather_maps
end

View file

@ -0,0 +1,5 @@
class GatherServerSerializer < ApplicationSerializer
attributes :id, :votes
has_one :server
end

View file

@ -0,0 +1,5 @@
class GathererSerializer < ApplicationSerializer
attributes :id
has_one :user
end

View file

@ -0,0 +1,3 @@
class MapSerializer < ApplicationSerializer
attributes :id, :name
end

View file

@ -0,0 +1,3 @@
class ServerSerializer < ApplicationSerializer
attributes :id, :name
end

View file

@ -0,0 +1,3 @@
class UserSerializer < ApplicationSerializer
attributes :id, :username, :country
end

View file

@ -98,11 +98,11 @@ class GoogleCalendar
end
def start
Time.use_zone(@timezone_offset) { Time.zone.parse(@entry["start"]["dateTime"]) }
Time.use_zone(@timezone_offset) { Time.zone.parse(@entry["start"]["date"]) }
end
def end
Time.use_zone(@timezone_offset) { Time.zone.parse(@entry["end"]["dateTime"]) }
Time.use_zone(@timezone_offset) { Time.zone.parse(@entry["end"]["date"]) }
end
def formatted_summary

View file

@ -0,0 +1,27 @@
<!doctype html>
<html>
<head>
<title><%= full_title(yield(:title)) %></title>
<meta charset="utf-8">
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
<meta name="viewport" content="width=device-width,initial-scale=1">
<%= favicon_link_tag 'shared/favicon.ico' %>
<%= theme_stylesheet_link_tag %>
<%= csrf_meta_tag %>
</head>
<body>
<div id="container">
<%= render partial: "header" %>
<%= render partial: "navigation" %>
<div class="body wrapper">
<div id="content" class="full">
<%= render partial: "messages" %>
<%= yield %>
</div>
</div>
<%= render partial: "footer" %>
</div>
<%= javascript_include_tag 'app' %>
</body>
</html>