2
0
unknown 9 жил өмнө
parent
commit
3e97f91aa9

+ 1 - 0
app/.meteor/packages

@@ -28,3 +28,4 @@ meteorhacks:async
 altapp:recaptcha
 http
 zimme:iron-router-active
+momentjs:moment

+ 1 - 0
app/.meteor/versions

@@ -61,6 +61,7 @@ minifiers@1.1.7
 minimongo@1.0.10
 mobile-experience@1.0.1
 mobile-status-bar@1.0.6
+momentjs:moment@2.10.6
 mongo@1.1.2
 mongo-id@1.0.1
 npm-bcrypt@0.7.8_2

+ 74 - 22
app/app.css

@@ -390,16 +390,16 @@ footer a:hover{
   margin-left: 35px;
 }
 .room-artist{
-  font-size: 2em;
+  font-size: 1.5em;
   color: white;
   margin-left: 35px;
 }
 #seeker-bar{
   background-color: black;
   width: 0;
-  height: 5px;
+  height: 10px;
   clear: both;
-  background-color: rgb(16, 140, 146);
+  background-color: rgba(16, 140, 146, 0.8);
 }
 .privacy {
   margin: 0 auto;
@@ -437,19 +437,19 @@ footer a:hover{
   -moz-appearance: none;
   appearance: none;
   outline: 0;
-  border: 1px solid rgba(83, 227, 166, 0.4);
-  background-color: rgba(83, 227, 166, 0.2);
-  width: 100%;
+  border: 1px solid white;
+  background-color: transparent;
+  width: 90%;
   border-radius: 3px;
   padding: 10px 15px;
   margin: 1em auto 10px auto;
-  display: block;
   text-align: left;
   font-size: 18px;
-  color: #53e3a6;
+  color: white;
   -webkit-transition-duration: 0.25s;
   transition-duration: 0.25s;
   font-weight: 300;
+  bottom: 0;
 }
 .song-input-select{
   -webkit-appearance: none;
@@ -513,6 +513,8 @@ footer a:hover{
   cursor: pointer;
 }
 #player {
+}
+.hidden {
   visibility: hidden;
   height: 0;
 }
@@ -532,7 +534,7 @@ footer a:hover{
 }
 #seeker-container {
   width: calc(100% - 70px);
-  margin-left: 20px;
+  margin-left: 30px;
   margin-right: 35px;
   overflow: hidden;
 }
@@ -637,31 +639,81 @@ footer a:hover{
   display: block;
   margin: 0 auto 20px auto;
 }
-#chat {
-  margin-top: 100px;
-}
-#chat-container {
+#station-main{
+  margin: 0;
   padding: 0;
 }
+#station-main nav{
+  height: 50px;
+  color: white;
+}
+#station-main nav i{
+  margin-left: 1em;
+  font-size: 2em;
+}
+#station-main nav h3{
+  display: inline-block;
+  margin: 10px auto;
+  margin-left: 50%;
+  font-size: 2em;
+}
+.embed-responsive{
+  margin-top: 15px;
+}
+#chat {
+  /*margin-top: 100px;*/
+  height: 100vh;
+  background-color: rgba(255,255,255,0.4);
+}
 .chat-message {
   font-size: 20px;
-  color: #53e3a6;
+  color: white;
 }
 #chat-ul {
-  max-height: 500px;
+  height: 90vh;
   overflow-y: scroll;
-  border: 1px solid rgba(83, 227, 166, 0.4);
-}
-#submit-message {
-  background-color: #53e3a6;
-  color: white;
+  margin: 0;
+  padding: 0;
 }
 .chat-message:nth-child(even) {
-  background-color: white;
+  color: white;
 }
 .chat-message:nth-child(odd) {
-  background-color: #F2F2F2;
+  color: darkblue;
+}
+#chat-input-container{
+
+}
+#submit{
+  margin-left: 10px;
+  font-size: 1.5em;
+  cursor: pointer;
+  display: inline-block;
 }
 #header {
   margin-bottom: 0px;
 }
+.user-stat {
+  font-size: 20px;
+  color: #53e3a6;
+}
+#profile-name {
+  font-size: 60px;
+  color: #FFFFFF;
+  margin-right: auto;
+  margin-left: auto;
+  text-align: center;
+}
+.admin-queue-panel:first-child {
+  margin-top: 100px;
+}
+#songs {
+  margin-top: -200px;
+  margin-bottom: 20px;
+}
+.back{
+  color: white;
+}
+.back:hover{
+  color: white;
+}

+ 129 - 53
app/app.js

@@ -53,12 +53,45 @@ if (Meteor.isClient) {
         return artist;
     }
 
+    Template.profile.helpers({
+        "username": function() {
+            return Session.get("username");
+        },
+        "first_joined": function() {
+            return moment(Session.get("first_joined")).format("DD/MM/YYYY HH:mm:ss");
+        },
+        "rank": function() {
+            return Session.get("rank");
+        },
+        loaded: function() {
+            return Session.get("loaded");
+        }
+    });
+
+    Template.profile.onCreated(function() {
+        var parts = location.href.split('/');
+        var username = parts.pop();
+        Session.set("loaded", false);
+        Meteor.subscribe("userProfiles", function() {
+            if (Meteor.users.find({"profile.usernameL": username.toLowerCase()}).count() === 0) {
+                window.location = "/";
+            } else {
+                var data = Meteor.users.find({"profile.usernameL": username.toLowerCase()}).fetch()[0];
+                Session.set("username", data.profile.username);
+                Session.set("first_joined", data.createdAt);
+                Session.set("rank", data.profile.rank);
+                Session.set("loaded", true);
+            }
+        });
+    });
+
     curPath=function(){var c=window.location.pathname;var b=c.slice(0,-1);var a=c.slice(-1);if(b==""){return"/"}else{if(a=="/"){return b}else{return c}}};
 
     Handlebars.registerHelper('active', function(path) {
         return curPath() == path ? 'active' : '';
     });
 
+
     Template.header.helpers({
         currentUser: function() {
             return Meteor.user();
@@ -92,10 +125,12 @@ if (Meteor.isClient) {
             Meteor.call("createUserMethod", {username: username, email: email, password: password}, captchaData, function(err, res) {
                 grecaptcha.reset();
 
+                console.log(username, password, err, res);
                 if (err) {
                     console.log(err);
                     $(".container").after('<div class="alert alert-danger" role="alert"><strong>Oh Snap!</strong> ' + err.reason + '</div>')
                 } else {
+                    console.log();
                     Meteor.loginWithPassword(username, password);
                 }
             });
@@ -146,18 +181,6 @@ if (Meteor.isClient) {
         }
     });
 
-    Template.dashboard.events({
-        "click #croom_create": function() {
-            Meteor.call("createRoom", $("#croom").val(), function (err, res) {
-                if (err) {
-                    alert("Error " + err.error + ": " + err.reason);
-                } else {
-                    window.location = "/" + $("#croom").val();
-                }
-            });
-        }
-    });
-
     Template.dashboard.helpers({
       rooms: function() {
         return Rooms.find({});
@@ -180,6 +203,19 @@ if (Meteor.isClient) {
                 console.log(err, res);
             });
         },
+        "click #toggle-video": function(e){
+            e.preventDefault();
+            Session.set("videoShown", !Session.get("videoShown"))
+            if (Session.get("videoShown")) {
+                $("#player").removeClass("hidden");
+                $("#toggle-video").text("Hide video");
+                var player = document.getElementById("player");
+                player.style.height = (player.offsetWidth / 16 * 9) + "px";
+            } else {
+                $("#player").addClass("hidden");
+                $("#toggle-video").text("Show video");
+            }
+        },
         "click #return": function(e){
             $("#add-info").hide();
             $("#search-info").show();
@@ -282,10 +318,19 @@ if (Meteor.isClient) {
         },
         "click #submit-message": function(){
             var message = $("#chat-input").val();
+            $("#chat-ul").scrollTop(1000000);
+            $("#chat-input").val("");
             Meteor.call("sendMessage", type, message);
         }
     });
 
+    Template.room.onRendered(function() {
+        $(window).resize(function() {
+            var player = document.getElementById("player");
+            player.style.height = (player.offsetWidth / 16 * 9) + "px";
+        });
+    });
+
     Template.room.helpers({
         type: function() {
           var parts = location.href.split('/');
@@ -385,6 +430,15 @@ if (Meteor.isClient) {
             if (_sound !== undefined) {
                 _sound.stop();
             }
+        },
+        "click #croom_create": function() {
+            Meteor.call("createRoom", $("#croom").val(), function (err, res) {
+                if (err) {
+                    alert("Error " + err.error + ": " + err.reason);
+                } else {
+                    window.location = "/" + $("#croom").val();
+                }
+            });
         }
     });
 
@@ -428,6 +482,7 @@ if (Meteor.isClient) {
     Meteor.subscribe("chat");
 
     Template.room.onCreated(function () {
+        Session.set("videoShown", false);
         var tag = document.createElement("script");
         tag.src = "https://www.youtube.com/iframe_api";
         var firstScriptTag = document.getElementsByTagName('script')[0];
@@ -697,10 +752,17 @@ if (Meteor.isServer) {
     });
 
     Accounts.onCreateUser(function(options, user) {
-        if (options.profile) {
-            user.profile = options.profile;
-            user.profile.rank = "default";
+        var username;
+        if (user.services) {
+            if (user.services.github) {
+                username = user.services.github.username;
+            } else if (user.services.facebook) {
+                //username = user.services.facebook.username;
+            } else if (user.services.password) {
+                username = user.username;
+            }
         }
+        user.profile = {username: username, usernameL: username.toLowerCase(), rank: "default"};
         return user;
     });
 
@@ -744,6 +806,11 @@ if (Meteor.isServer) {
         return Chat.find({});
     });
 
+    Meteor.publish("userProfiles", function() {
+        //console.log(Meteor.users.find({}, {profile: 1, createdAt: 1, services: 0, username: 0, emails: 0})).fetch();
+        return Meteor.users.find({}, {fields: {profile: 1, createdAt: 1}});
+    });
+
     Meteor.publish("isAdmin", function() {
         return Meteor.users.find({_id: this.userId, "profile.rank": "admin"});
     });
@@ -809,50 +876,55 @@ if (Meteor.isServer) {
             }
         },
         createRoom: function(type) {
-            if (Rooms.find({type: type}).count() === 0) {
-                Rooms.insert({type: type}, function(err) {
-                    if (err) {
-                        throw err;
-                    } else {
-                        if (Playlists.find({type: type}).count() === 1) {
-                            if (History.find({type: type}).count() === 0) {
-                                History.insert({type: type, history: []}, function(err3) {
-                                    if (err3) {
-                                        throw err3;
-                                    } else {
-                                        startStation();
-                                        return true;
-                                    }
-                                });
-                            } else {
-                                startStation();
-                                return true;
-                            }
+            var userData = Meteor.users.find(Meteor.userId());
+            if (Meteor.userId() && userData.count !== 0 && userData.fetch()[0].profile.rank === "admin") {
+                if (Rooms.find({type: type}).count() === 0) {
+                    Rooms.insert({type: type}, function(err) {
+                        if (err) {
+                            throw err;
                         } else {
-                            Playlists.insert({type: type, songs: getSongsByType(type)}, function (err2) {
-                                if (err2) {
-                                    throw err2;
+                            if (Playlists.find({type: type}).count() === 1) {
+                                if (History.find({type: type}).count() === 0) {
+                                    History.insert({type: type, history: []}, function(err3) {
+                                        if (err3) {
+                                            throw err3;
+                                        } else {
+                                            startStation();
+                                            return true;
+                                        }
+                                    });
                                 } else {
-                                    if (History.find({type: type}).count() === 0) {
-                                        History.insert({type: type, history: []}, function(err3) {
-                                            if (err3) {
-                                                throw err3;
-                                            } else {
-                                                startStation();
-                                                return true;
-                                            }
-                                        });
+                                    startStation();
+                                    return true;
+                                }
+                            } else {
+                                Playlists.insert({type: type, songs: getSongsByType(type)}, function (err2) {
+                                    if (err2) {
+                                        throw err2;
                                     } else {
-                                        startStation();
-                                        return true;
+                                        if (History.find({type: type}).count() === 0) {
+                                            History.insert({type: type, history: []}, function(err3) {
+                                                if (err3) {
+                                                    throw err3;
+                                                } else {
+                                                    startStation();
+                                                    return true;
+                                                }
+                                            });
+                                        } else {
+                                            startStation();
+                                            return true;
+                                        }
                                     }
-                                }
-                            });
+                                });
+                            }
                         }
-                    }
-                });
+                    });
+                } else {
+                    throw "Room already exists";
+                }
             } else {
-                throw "Room already exists";
+                return false;
             }
             function startStation() {
                 var startedAt = Date.now();
@@ -928,3 +1000,7 @@ Router.route("/admin", {
 Router.route("/:type", {
     template: "room"
 });
+
+Router.route("/u/:user", {
+    template: "profile"
+});

+ 11 - 1
app/templates/admin.html

@@ -2,7 +2,7 @@
     {{> header}}
     <div class="landing row">
         {{#each queues}}
-            <div class="col-md-8 col-md-offset-2 ">
+            <div class="col-md-8 col-md-offset-2 admin-queue-panel">
                 <div class="panel panel-primary">
                     <div class="panel-heading">
                         <h3 class="panel-title">{{type}} review queue</h3>
@@ -41,6 +41,16 @@
             </div>
         {{/each}}
 
+        <div class="col-md-4 col-md-offset-4">
+            <div id="croom_container">
+                <label for="croom" id="croom_label">Room Name:</label>
+                <div class="input-group">
+                    <input type="text" id="croom" name="croom" required />
+                </div>
+                <button class="btn btn-warning btn-block" id="croom_create">Create</button>
+            </div>
+        </div>
+
         <div id="previewModal" class="modal fade" role="dialog">
             <div class="modal-dialog">
                 <!-- Modal content-->

+ 0 - 11
app/templates/dashboard.html

@@ -11,17 +11,6 @@
               </div>
            {{/each}}
         </div>
-        <div class="col-md-4"></div>
-        <div class="col-md-4">
-            <div id="croom_container">
-                <label for="croom" id="croom_label">Room Name:</label>
-                <div class="input-group">
-                    <input type="text" id="croom" name="croom" required />
-                </div>
-                <button class="btn btn-warning btn-block" id="croom_create">Create</button>
-            </div>
-        </div>
-        <div class="col-md-4"></div>
         <ul class="bg-bubbles">
             <li></li>
             <li></li>

+ 1 - 1
app/templates/footer.html

@@ -3,7 +3,7 @@
         <p>Copyright © 2015 All Right Reserved</p>
         <a class="footerButtons" id="apiButton">API |</a>
         <a href="/terms" class="footerButtons" id="termsButton">Terms |</a>
-		<a href="/privacy" class="footerButtons" id="privacyButton">Privacy |</a>
+		    <a href="/privacy" class="footerButtons" id="privacyButton">Privacy |</a>
         <a class="footerButtons" id="aboutButton">About</a>
     </footer>
 </template>

+ 1 - 1
app/templates/header.html

@@ -30,7 +30,7 @@
                 <ul class="nav navbar-nav navbar-right">
                     <li class="dropdown">
                         {{#if currentUser}}
-                            <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">{{currentUser.profile.name}} <span class="caret"></span></a>
+                            <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">{{currentUser.profile.username}} <span class="caret"></span></a>
                             <ul class="dropdown-menu">
                                 <li><a href="#" class="logout">Logout</a></li>
                             </ul>

+ 34 - 0
app/templates/profile.html

@@ -0,0 +1,34 @@
+<template name="profile">
+    {{> header}}
+    <div class="landing row">
+        {{#if loaded}}
+            <h1 id="profile-name">{{username}}</h1>
+
+            <div class="col-md-4 col-md-offset-4">
+                <div class="panel panel-primary">
+                    <div class="panel-heading">{{username}}</div>
+                    <div class="panel-body">
+                        <ul>
+                            <li class="user-stat"><b>Joined: </b>{{first_joined}}</li>
+                            <li class="user-stat"><b>Rank: </b>{{rank}}</li>
+                        </ul>
+                    </div>
+                </div>
+            </div>
+        {{else}}
+            {{> loading}}
+        {{/if}}
+        <ul class="bg-bubbles">
+            <li></li>
+            <li></li>
+            <li></li>
+            <li></li>
+            <li></li>
+            <li></li>
+            <li></li>
+            <li></li>
+            <li></li>
+            <li></li>
+        </ul>
+    </div>
+</template>

+ 54 - 9
app/templates/room.html

@@ -1,28 +1,76 @@
 <template name="room">
-    {{> header}}
     <div class="landing">
         {{#if loaded}}
-            <h1 class="room-name">{{{type}}}</h1>
-            <div class="row">
+          <div class="row">
+            <div class="col-md-8" id="station-main">
+              <nav>
+                <a class="back" href="/"><i class="fa fa-chevron-left"></i></a>
+                <h3>{{{type}}}</h3>
+              </nav>
+              <div id="seeker-container">
+                  <div id="seeker-bar"></div>
+              </div>
+              <div class="row">
+                <div class="col-md-8">
+                  <div class="embed-responsive embed-responsive-16by9">
+                    <div id="player" class="embed-responsive-item"></div>
+                  </div>
+                </div>
+                <div class="col-md-4" style="margin-top:15px">
+                  <img class="song-img" id="song-img"/>
+                  <h2 class="room-title">{{{title}}}</h2>
+                  <h2 class="room-artist">{{{artist}}}</h2>
+                </div>
+              </div>
+              <button type="button" id="song-modal" class="button-nowidth col-md-4 col-sm-4 col-xs-4 col-md-offset-4 col-sm-offset-4 col-xs-offset-4" data-toggle="modal" data-target="#myModal">Add songs</button>
+            </div>
+            <div class="col-md-4" id="chat">
+              <ul id="chat-ul">
+                {{#each chat}}
+                    <li class="chat-message"><b class="bold">{{userid}}:</b> {{message}}</li>
+                {{/each}}
+              </ul>
+              <!-- <div class="row" id="chat-container">
+                <div class="col-md-10">
+                  <input id="chat-input"/>
+                </div>
+                <div class="col-md-2" id="submit">
+                  <i id="submit-message" class="fa fa-paper-plane-o"></i>
+                </div>
+              </div> -->
+              <div id="chat-input-container">
+                <input id="chat-input" placeholder="Type a message...">
+                <div id="submit">
+                  <i id="submit-message" class="fa fa-paper-plane-o"></i>
+                </div>
+              </div>
+            </div>
+          </div>
+            <!--<h1 class="room-name">{{{type}}}</h1>
+            <div class="row" id="songs">
                 <div class="col-md-3 col-sm-6 col-xs-12" id="s1">
                     <img class="song-img" id="song-img"/>
                     <h2 class="room-title">{{{title}}}</h2>
                     <h2 class="room-artist">{{{artist}}}</h2>
                 </div>
-                <div class="col-md-3 col-sm-6 col-xs-12" id="s2">
+                <div class="col-md-3 col-sm-6" id="s2">
                     <img class="song-img" id="song-img-next"/>
                     <h2 class="room-title">{{{title_next}}}</h2>
                     <h2 class="room-artist">{{{artist_next}}}</h2>
                 </div>
-                <div class="col-md-3 col-sm-6 col-xs-12" id="s3">
+                <div class="col-md-3" id="s3">
                     <img class="song-img" id="song-img-after"/>
                     <h2 class="room-title">{{{title_after}}}</h2>
                     <h2 class="room-artist">{{{artist_after}}}</h2>
                 </div>
+                <div width="960" height="540" id="player" class="hidden col-md-3 col-sm-12 col-xs-12"></div>
             </div>
             <div id="seeker-container">
                 <div id="seeker-bar"></div>
             </div>
+            <div class="row">
+                <button type="button" id="toggle-video" class="button-nowidth col-md-4 col-sm-4 col-xs-4 col-md-offset-4 col-sm-offset-4 col-xs-offset-4" >Show video</button>
+            </div>
             <div class="row">
                 <button type="button" id="song-modal" class="button-nowidth col-md-4 col-sm-4 col-xs-4 col-md-offset-4 col-sm-offset-4 col-xs-offset-4" data-toggle="modal" data-target="#myModal">Add songs</button>
             </div>
@@ -42,6 +90,7 @@
                     </div>
                 </div>
             </div>
+            -->
 
             <!-- Modal -->
             <div id="myModal" class="modal fade" role="dialog">
@@ -89,10 +138,6 @@
 
               </div>
             </div>
-            <!--src="http://www.youtube.com/embed/XGSy3_Czz8k?autoplay=1&controls=0&autohide=1">-->
-
-            <div width="960" height="540" id="player">
-            </div>
         {{else}}
             {{> loading}}
         {{/if}}