├── .gitignore ├── .meteor ├── .gitignore ├── release ├── platforms ├── packages ├── .finished-upgraders ├── .id └── versions ├── meteor-chat.css ├── README.md ├── LICENSE ├── meteor-chat.html └── meteor-chat.js /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | 3 | -------------------------------------------------------------------------------- /.meteor/.gitignore: -------------------------------------------------------------------------------- 1 | local 2 | -------------------------------------------------------------------------------- /.meteor/release: -------------------------------------------------------------------------------- 1 | METEOR@1.1.0.2 2 | -------------------------------------------------------------------------------- /.meteor/platforms: -------------------------------------------------------------------------------- 1 | server 2 | browser 3 | -------------------------------------------------------------------------------- /meteor-chat.css: -------------------------------------------------------------------------------- 1 | /* CSS declarations go here */ 2 | body { 3 | padding: 60px; 4 | } -------------------------------------------------------------------------------- /.meteor/packages: -------------------------------------------------------------------------------- 1 | # Meteor packages used by this project, one per line. 2 | # 3 | # 'meteor add' and 'meteor remove' will edit this file for you, 4 | # but you can also edit it by hand. 5 | 6 | standard-app-packages 7 | bootstrap 8 | accounts-ui 9 | accounts-password 10 | -------------------------------------------------------------------------------- /.meteor/.finished-upgraders: -------------------------------------------------------------------------------- 1 | # This file contains information which helps Meteor properly upgrade your 2 | # app when you run 'meteor update'. You should check it into version control 3 | # with your project. 4 | 5 | notices-for-0.9.0 6 | notices-for-0.9.1 7 | 0.9.4-platform-file 8 | notices-for-facebook-graph-api-2 9 | -------------------------------------------------------------------------------- /.meteor/.id: -------------------------------------------------------------------------------- 1 | # This file contains a token that is unique to your project. 2 | # Check it into your repository along with the rest of this directory. 3 | # It can be used for purposes such as: 4 | # - ensuring you don't accidentally deploy one app on top of another 5 | # - providing package authors with aggregated statistics 6 | 7 | wiwcxy25fht5cexxop 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | MeteorChat 2 | ========== 3 | 4 | Simple chat application with different chat-rooms built on the [Meteor](http://www.meteor.com/) JavaScript Platform. 5 | 6 | Not much functionality, only to demonstrate how _simple_ it is to set up a reactive app using Meteor. 7 | 8 | Used add-on packages (for convenience only!): 9 | 10 | * `bootstrap` for beautifying the UI 11 | * `accounts-password` and `accounts-ui` for having the user authenticated right out of the box 12 | 13 | Feel free to fork/copy/whatever... 14 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013 Niko Köbler 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /.meteor/versions: -------------------------------------------------------------------------------- 1 | accounts-base@1.2.0 2 | accounts-password@1.1.1 3 | accounts-ui@1.1.5 4 | accounts-ui-unstyled@1.1.7 5 | autoupdate@1.2.1 6 | base64@1.0.3 7 | binary-heap@1.0.3 8 | blaze@2.1.2 9 | blaze-tools@1.0.3 10 | boilerplate-generator@1.0.3 11 | bootstrap@1.0.1 12 | callback-hook@1.0.3 13 | check@1.0.5 14 | ddp@1.1.0 15 | deps@1.0.7 16 | ejson@1.0.6 17 | email@1.0.6 18 | fastclick@1.0.3 19 | geojson-utils@1.0.3 20 | html-tools@1.0.4 21 | htmljs@1.0.4 22 | http@1.1.0 23 | id-map@1.0.3 24 | jquery@1.11.3_2 25 | json@1.0.3 26 | launch-screen@1.0.2 27 | less@1.0.14 28 | livedata@1.0.13 29 | localstorage@1.0.3 30 | logging@1.0.7 31 | meteor@1.1.6 32 | meteor-platform@1.2.2 33 | minifiers@1.1.5 34 | minimongo@1.0.8 35 | mobile-status-bar@1.0.3 36 | mongo@1.1.0 37 | npm-bcrypt@0.7.8_2 38 | observe-sequence@1.0.6 39 | ordered-dict@1.0.3 40 | random@1.0.3 41 | reactive-dict@1.1.0 42 | reactive-var@1.0.5 43 | reload@1.1.3 44 | retry@1.0.3 45 | routepolicy@1.0.5 46 | service-configuration@1.0.4 47 | session@1.1.0 48 | sha@1.0.3 49 | spacebars@1.0.6 50 | spacebars-compiler@1.0.6 51 | srp@1.0.3 52 | standard-app-packages@1.0.5 53 | templating@1.1.1 54 | tracker@1.0.7 55 | ui@1.0.6 56 | underscore@1.0.3 57 | url@1.0.4 58 | webapp@1.2.0 59 | webapp-hashing@1.0.3 60 | -------------------------------------------------------------------------------- /meteor-chat.html: -------------------------------------------------------------------------------- 1 | 2 | MeteorChat 3 | 4 | 5 | 6 | {{> chat}} 7 | 8 | 9 | 49 | 50 | 54 | 55 | 63 | 64 | 67 | 68 | 76 | 77 | -------------------------------------------------------------------------------- /meteor-chat.js: -------------------------------------------------------------------------------- 1 | Messages = new Meteor.Collection("messages"); 2 | Rooms = new Meteor.Collection("rooms"); 3 | 4 | if (Meteor.isClient) { 5 | Accounts.ui.config({ 6 | passwordSignupFields: 'USERNAME_ONLY' 7 | }); 8 | 9 | Meteor.subscribe("rooms"); 10 | Meteor.subscribe("messages"); 11 | Session.setDefault("roomname", "Meteor"); 12 | 13 | Template.input.events({ 14 | 'click .sendMsg': function(e) { 15 | _sendMessage(); 16 | }, 17 | 'keyup #msg': function(e) { 18 | if (e.type == "keyup" && e.which == 13) { 19 | _sendMessage(); 20 | } 21 | } 22 | }); 23 | 24 | _sendMessage = function() { 25 | var el = document.getElementById("msg"); 26 | Messages.insert({user: Meteor.user().username, msg: el.value, ts: new Date(), room: Session.get("roomname")}); 27 | el.value = ""; 28 | el.focus(); 29 | }; 30 | 31 | Template.messages.helpers({ 32 | messages: function() { 33 | return Messages.find({room: Session.get("roomname")}, {sort: {ts: -1}}); 34 | }, 35 | roomname: function() { 36 | return Session.get("roomname"); 37 | } 38 | }); 39 | 40 | Template.message.helpers({ 41 | timestamp: function() { 42 | return this.ts.toLocaleString(); 43 | } 44 | }); 45 | 46 | Template.rooms.events({ 47 | 'click li': function(e) { 48 | Session.set("roomname", e.target.innerText); 49 | } 50 | }); 51 | 52 | Template.rooms.helpers({ 53 | rooms: function() { 54 | return Rooms.find(); 55 | } 56 | }); 57 | 58 | Template.room.helpers({ 59 | roomstyle: function() { 60 | return Session.equals("roomname", this.roomname) ? "font-weight: bold" : ""; 61 | } 62 | }); 63 | 64 | Template.chat.helpers({ 65 | release: function() { 66 | return Meteor.release; 67 | } 68 | }); 69 | } 70 | 71 | if (Meteor.isServer) { 72 | Meteor.startup(function () { 73 | Messages.remove({}); 74 | Rooms.remove({}); 75 | if (Rooms.find().count() === 0) { 76 | ["Meteor", "JavaScript", "Reactive", "MongoDB"].forEach(function(r) { 77 | Rooms.insert({roomname: r}); 78 | }); 79 | } 80 | }); 81 | 82 | Rooms.deny({ 83 | insert: function (userId, doc) { 84 | return true; 85 | }, 86 | update: function (userId, doc, fieldNames, modifier) { 87 | return true; 88 | }, 89 | remove: function (userId, doc) { 90 | return true; 91 | } 92 | }); 93 | Messages.deny({ 94 | insert: function (userId, doc) { 95 | return (userId === null); 96 | }, 97 | update: function (userId, doc, fieldNames, modifier) { 98 | return true; 99 | }, 100 | remove: function (userId, doc) { 101 | return true; 102 | } 103 | }); 104 | Messages.allow({ 105 | insert: function (userId, doc) { 106 | return (userId !== null); 107 | } 108 | }); 109 | 110 | Meteor.publish("rooms", function () { 111 | return Rooms.find(); 112 | }); 113 | Meteor.publish("messages", function () { 114 | return Messages.find({}, {sort: {ts: -1}}); 115 | }); 116 | } 117 | --------------------------------------------------------------------------------