Explorar o código

Merge branch 'february_release' of https://github.com/Musare/Musare into february_release

Akira Laine %!s(int64=9) %!d(string=hai) anos
pai
achega
bdd73082c3

+ 6 - 0
app/client/scripts/helpers.js

@@ -204,6 +204,12 @@ Template.queues.helpers({
     }
 });
 
+Template.news.helpers({
+    articles: function() {
+        return News.find().fetch().reverse();
+    }
+});
+
 Template.manageStation.helpers({
     songs: function () {
         var parts = location.href.split('/');

+ 1 - 0
app/client/scripts/main.js

@@ -21,6 +21,7 @@ Deps.autorun(function() {
     Meteor.subscribe("songs");
     Meteor.subscribe("alerts");
     Meteor.subscribe("rooms");
+    Meteor.subscribe("news");
     Meteor.subscribe("userData", Meteor.userId());
 });
 

+ 9 - 0
app/client/scripts/onRendered.js

@@ -50,6 +50,15 @@ Template.manageStation.onRendered(function() {
     });
 });
 
+Template.news.onRendered(function() {
+    if (rTimeInterval !== undefined) {
+        Meteor.clearInterval(rTimeInterval)
+    }
+    rTimeInterval = Meteor.setInterval(function() {
+        Session.set("time", new Date().getTime());
+    }, 10000);
+});
+
 Template.room.onRendered(function() {
     if (rTimeInterval !== undefined) {
         Meteor.clearInterval(rTimeInterval)

+ 6 - 0
app/client/stylesheets/app.css

@@ -175,4 +175,10 @@ textarea{
 
 #desc_text{
     color: black;
+}
+
+#team-page-container {
+    margin-left: 0;
+    margin-right: 0;
+    /* Weird hack... No clue why this is needed but it is.*/
 }

+ 17 - 26
app/client/templates/news.html

@@ -1,31 +1,22 @@
 <template name="news">
     {{> header}}
-    <main class="content-box">
-        <h3 class="black-text thin">News, Updates & Announcements</h3>
-        <ul class="collection">
-        <!--
-        {{#each chat}}
-        <li class="collection-item news-box">
-            <span class="news-title">{{title}}</span>
-            <hr>
-            <p class="news-content">{{content}}</p>
-            <p class="news-creator">Posted by: {{postBy}}</p>
-            <p class="news-postTime">{{timePostedAgo}}. ({{timePostedDate}})</p>
-        </li>
-        {{/each}}
-        -->
-
-        <!-- TEMP HARDCODED NEWS ARTICLE, soon you can add/remove news from the admin panel -->
-        <li class="collection-item news-box">
-            <span class="news-title">Welcome To Musare 2.0</span>
-            <hr>
-            <p class="news-content">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla rhoncus magna orci, tristique aliquam arcu ultricies non.
-              <br />Vivamus iaculis leo lectus. In quis nunc rhoncus nulla hendrerit pellentesque in nec ipsum. Curabitur facilisis enim nulla, sit amet dapibus lacus aliquet ut. Integer lacinia pharetra semper.
-              <br />Duis mattis varius egestas. Cras sit amet venenatis lacus. Curabitur ut maximus urna, vel pulvinar ex. Do It Work?!</p>
-            <p class="news-creator">Posted by: Johand</p>
-            <p class="news-postTime">5days ago. (5/01/2016)</p>
-        </li>
-        </ul>
+    <main class="content-box row">
+        <h3 class="black-text thin center">News</h3>
+            {{#each articles}}
+                <div class="card teal-text col m6 s12 l6 offset-m3 offset-l3">
+                    <div class="card-content">
+                        <span>{{title}}</span>
+                        <hr>
+                        <p class="flow-text" style="word-wrap:break-word;">
+                            {{content}}
+                        </p>
+                    </div>
+                    <div class="card-action">
+                        <span>Posted by: {{author}}.</span><br>
+                        <span>Created at: {{rtime time}}.</span>
+                    </div>
+                </div>
+            {{/each}}
     </main>
     {{> footer}}
 </template>

+ 49 - 37
app/client/templates/project.html

@@ -1,42 +1,54 @@
 <template name="project">
     {{> header}}
-    <main class="content-box">
-        <h3 class="black-text thin">The Project</h3>
-        <hr>
-        <h4 class="thin">What is Musare?</h4>
-        <p class="flow-text">
-            Musare is a modern, open source, collaborative music app where a user can go into any of our "stations" and
-            listen to music simultaneously with other users in that "station".
-        </p>
-        <hr>
-        <h4 class="thin">What is Musare's end goal?</h4>
-        <p class="flow-text">
-            Musare's end goal is to be a collaborative way of discovering new music. We are working hard to implement
-            all the features that are necessary for this.
-        </p>
-        <hr>
-        <h4 class="thin">How can I help?</h4>
-        <p class="flow-text">
-            There are essentially 3 main ways in which you can help us:
-        <ol>
-            <li>
-                If you are a JavaScript developer, then we can use your help! Our project is open source and all the
-                source code can be found on GitHub. We would love for you to create new features, add exciting
-                content or just improve what already is on Musare. Also, if you see a bug or glitch on Musare, then
-                create a new
-                "issue" on GitHub and we will fix it as soon as possible. You can also have a try at fixing a
-                bug that you may find!
-            </li>
-            <li>
-                If you are not a developer but want some way of supporting us - you can donate to Musare. Any
-                amount of donation is highly appreciated, and will help us maintain server costs.
-            </li>
-            <li>
-                Send us feedback! You're comments and/or suggestion are extremely valuable to us. In order to improve
-                we need to know what you like, don't like or what you might want on the app.
-            </li>
-        </ol>
-        </p>
+    <main class="content-box row">
+        <div class="col s12 l4 m8 offset-l4 offset-m2">
+            <h3 class="black-text thin">The Project</h3>
+            <hr>
+            <div class="card teal accent-3">
+                <div class="card-content white-text">
+                    <span class="card-title">What is Musare?</span>
+                    <p>
+                        Musare is a modern, open source, collaborative music app where a user can go into any of our "stations" and
+                        listen to music simultaneously with other users in that "station".
+                    </p>
+                </div>
+            </div>
+            <div class="card teal accent-3">
+                <div class="card-content white-text">
+                    <span class="card-title">What is Musare's end goal?</span>
+                    <p>
+                        Musare's end goal is to be a collaborative way of discovering new music. We are working hard to implement
+                        all the features that are necessary for this.
+                    </p>
+                </div>
+            </div>
+            <div class="card teal accent-3">
+                <div class="card-content white-text">
+                    <span class="card-title">How can I help?</span>
+                    <p>
+                        There are essentially 3 main ways in which you can help us:
+                        <ol>
+                            <li>
+                                If you are a JavaScript developer, then we can use your help! Our project is open source and all the
+                                source code can be found on GitHub. We would love for you to create new features, add exciting
+                                content or just improve what already is on Musare. Also, if you see a bug or glitch on Musare, then
+                                create a new
+                                "issue" on GitHub and we will fix it as soon as possible. You can also have a try at fixing a
+                                bug that you may find!
+                            </li>
+                            <li>
+                                If you are not a developer but want some way of supporting us - you can donate to Musare. Any
+                                amount of donation is highly appreciated, and will help us maintain server costs.
+                            </li>
+                            <li>
+                                Send us feedback! Your comments and/or suggestion are extremely valuable to us. In order to improve
+                                we need to know what you like, don't like or what you might want on the app.
+                            </li>
+                        </ol>
+                    </p>
+                </div>
+            </div>
+        </div>
     </main>
     {{> footer}}
 </template>

+ 54 - 52
app/client/templates/team.html

@@ -1,57 +1,59 @@
 <template name="team">
     {{> header}}
-    <main class="content-box">
-        <h3 class="black-text thin">The Team</h3>
-        <ul class="collection">
-            <li class="collection-item avatar">
-                <img src="https://avatars0.githubusercontent.com/u/11958359?v=3&s=460" alt="Akira's Profile Picture"
-                     class="circle">
-                <span class="title">Akira Laine</span>
-                <p>Co Founder, Lead Developer & Whovian</p>
-                <div class="contact-details">
-                    <i class="material-icons">my_location</i> <span>Noumea, New Caledonia</span>
-                </div>
-                <div class="contact-details">
-                    <i class="material-icons">email</i> <span>akira_laine@outlook.com</span>
-                </div>
-            </li>
-            <li class="collection-item avatar">
-                <img src="https://avatars2.githubusercontent.com/u/9784561?v=3&s=460" alt="Kris' Profile Picture"
-                     class="circle">
-                <span class="title">Kris Vos</span>
-                <p>Co Founder, Lead Developer & Fox</p>
-                <div class="contact-details">
-                    <i class="material-icons">my_location</i> <span>Haarlem, The Netherlands</span>
-                </div>
-                <div class="contact-details">
-                    <i class="material-icons">email</i> <span>krisvos130@gmail.com</span>
-                </div>
-            </li>
-            <li class="collection-item avatar">
-                <img src="https://avatars2.githubusercontent.com/u/6952369?v=3&s=460" alt="Johand's Profile Picture"
-                     class="circle">
-                <span class="title">Johannes Andersen</span>
-                <p>Co Founder, <span title="Chief business officer">CBO</span> & Developer</p>
-                <div class="contact-details">
-                    <i class="material-icons">my_location</i> <span>Fredrikstad, Norway</span>
-                </div>
-                <div class="contact-details">
-                    <i class="material-icons">email</i> <span>Johand@Johand.me</span>
-                </div>
-            </li>
-            <li class="collection-item avatar">
-                <img src="https://avatars0.githubusercontent.com/u/1158013?v=3&s=460" alt="Wesley's Profile Picture"
-                     class="circle">
-                <span class="title">Wesley McCaan</span>
-                <p>Core Developer</p>
-                <div class="contact-details">
-                    <i class="material-icons">my_location</i> <span>Colorado Springs, CA</span>
-                </div>
-                <!--<div class="contact-details">-->
-                    <!--<i class="material-icons">email</i> <span></span>-->
-                <!--</div>-->
-            </li>
-        </ul>
+    <main class="content-box row" id="team-page-container">
+        <div class="col s12 l4 m8 offset-l4 offset-m2">
+            <h3 class="black-text thin">The Team</h3>
+            <ul class="collection">
+                <li class="collection-item avatar">
+                    <img src="https://avatars0.githubusercontent.com/u/11958359?v=3&s=460" alt="Akira's Profile Picture"
+                         class="circle">
+                    <span class="title">Akira Laine</span>
+                    <p>Co Founder, Lead Developer & Whovian</p>
+                    <div class="contact-details">
+                        <i class="material-icons">my_location</i> <span>Noumea, New Caledonia</span>
+                    </div>
+                    <div class="contact-details">
+                        <i class="material-icons">email</i> <span>akira_laine@outlook.com</span>
+                    </div>
+                </li>
+                <li class="collection-item avatar">
+                    <img src="https://avatars2.githubusercontent.com/u/9784561?v=3&s=460" alt="Kris' Profile Picture"
+                         class="circle">
+                    <span class="title">Kristian Vos</span>
+                    <p>Co Founder, Lead Developer & Fox</p>
+                    <div class="contact-details">
+                        <i class="material-icons">my_location</i> <span>Haarlem, The Netherlands</span>
+                    </div>
+                    <div class="contact-details">
+                        <i class="material-icons">email</i> <span>krisvos130@gmail.com</span>
+                    </div>
+                </li>
+                <li class="collection-item avatar">
+                    <img src="https://avatars2.githubusercontent.com/u/6952369?v=3&s=460" alt="Johand's Profile Picture"
+                         class="circle">
+                    <span class="title">Johannes Andersen</span>
+                    <p>Co Founder, <span title="Chief business officer">CBO</span> & Developer</p>
+                    <div class="contact-details">
+                        <i class="material-icons">my_location</i> <span>Fredrikstad, Norway</span>
+                    </div>
+                    <div class="contact-details">
+                        <i class="material-icons">email</i> <span>Johand@Johand.me</span>
+                    </div>
+                </li>
+                <li class="collection-item avatar">
+                    <img src="https://avatars0.githubusercontent.com/u/1158013?v=3&s=460" alt="Wesley's Profile Picture"
+                         class="circle">
+                    <span class="title">Wesley McCaan</span>
+                    <p>Core Developer</p>
+                    <div class="contact-details">
+                        <i class="material-icons">my_location</i> <span>Colorado Springs, CA</span>
+                    </div>
+                    <!--<div class="contact-details">-->
+                        <!--<i class="material-icons">email</i> <span></span>-->
+                    <!--</div>-->
+                </li>
+            </ul>
+        </div>
     </main>
     {{> footer}}
 </template>

+ 2 - 1
app/database/collections.js

@@ -6,4 +6,5 @@ Chat = new Mongo.Collection("chat");
 Alerts = new Mongo.Collection("alerts");
 Deleted = new Mongo.Collection("deleted");
 Feedback = new Mongo.Collection("feedback");
-Songs = new Mongo.Collection("songs");
+Songs = new Mongo.Collection("songs");
+News = new Mongo.Collection("news");

+ 20 - 0
app/database/schemas.js

@@ -503,6 +503,25 @@ Schemas.Report = new SimpleSchema({
     }
 });
 
+Schemas.Article = new SimpleSchema({
+    "title": {
+        type: String,
+        label: "Article Title"
+    },
+    "content": {
+        type: String,
+        label: "Article Content"
+    },
+    "author": {
+        type: String,
+        label: "Article's Author"
+    },
+    "time": {
+        type: Date,
+        label: "Article's Create Date"
+    }
+});
+
 Rooms.attachSchema(Schemas.Room);
 Alerts.attachSchema(Schemas.Alert);
 Chat.attachSchema(Schemas.Chat);
@@ -512,3 +531,4 @@ Meteor.users.attachSchema(Schemas.User);
 Reports.attachSchema(Schemas.Report);
 Feedback.attachSchema(Schemas.Feedback);
 Songs.attachSchema(Schemas.FullSong);
+News.attachSchema(Schemas.Article);

+ 35 - 0
app/server/server.js

@@ -438,6 +438,10 @@ Meteor.publish("alerts", function () {
     return Alerts.find({active: true})
 });
 
+Meteor.publish("news", function () {
+    return News.find({})
+});
+
 Meteor.publish("userData", function (userId) {
     if (userId !== undefined) {
         return Meteor.users.find(userId, {fields: {"services.github.username": 1, "punishments": 1}})
@@ -936,6 +940,37 @@ Meteor.methods({
             return true;
         }
     },
+    createArticle: function(data) {
+        if (!isBanned() && isModerator()) {
+            var userId = Meteor.userId();
+            var requiredProperties = ["title", "content", "author"];
+            if (data !== undefined && Object.keys(data).length === requiredProperties.length) {
+                for (var property in requiredProperties) {
+                    if (data[requiredProperties[property]] === undefined) {
+                        throw new Meteor.Error(403, "Invalid data.");
+                    }
+                }
+                if (data.author === true) {
+                    data.author = Meteor.user().profile.username
+                } else {
+                    data.author = "A Musare Admin";
+                }
+                data.time =  new Date();
+                News.insert(data, function(err, res) {
+                    if (err) {
+                        console.log(err);
+                        throw err.sanitizedError;
+                    } else {
+                        return true;
+                    }
+                });
+            } else {
+                throw new Meteor.Error(403, "Invalid data.");
+            }
+        } else {
+            throw new Meteor.Error(403, "Invalid permissions.");
+        }
+    },
     addSongToQueue: function (songData) {
         if (Meteor.userId() && !isBanned()) {
             var userId = Meteor.userId();