Ver código fonte

Added profile pages.

KrisVos130 9 anos atrás
pai
commit
a3594b4670
5 arquivos alterados com 81 adições e 0 exclusões
  1. 1 0
      app/.meteor/packages
  2. 1 0
      app/.meteor/versions
  3. 11 0
      app/app.css
  4. 37 0
      app/app.js
  5. 31 0
      app/templates/profile.html

+ 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

+ 11 - 0
app/app.css

@@ -664,4 +664,15 @@ footer a:hover{
 }
 #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;
 }

+ 37 - 0
app/app.js

@@ -57,12 +57,40 @@ 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");
+        }
+    });
+
+    Template.profile.onCreated(function() {
+        var parts = location.href.split('/');
+        var username = parts.pop();
+        Meteor.subscribe("userProfiles", function() {
+            if (Meteor.users.find({"profile.username": username}).count() === 0) {
+                // Return to homepage
+            } else {
+                var data = Meteor.users.find({"profile.username": username}).fetch()[0];
+                Session.set("username", username);
+                Session.set("first_joined", data.createdAt);
+                Session.set("rank", data.profile.rank);
+            }
+        });
+    });
+
     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();
@@ -757,6 +785,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"});
     });
@@ -941,3 +974,7 @@ Router.route("/admin", {
 Router.route("/:type", {
     template: "room"
 });
+
+Router.route("/u/:user", {
+    template: "profile"
+});

+ 31 - 0
app/templates/profile.html

@@ -0,0 +1,31 @@
+<template name="profile">
+    {{> header}}
+    <div class="landing row">
+        <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>
+
+        <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>