GithubHelp home page GithubHelp logo

chatterbox's Introduction

Chatterbox

Chatterbox is a small multi-room chat website built with Ruby on Rails and Faye (using the PrivatePub gem by Ryan Bates).

Getting it Running

Chatterbox has three major parts:

  1. The Rails application
  2. The Faye server
  3. The MongoDB chat log

The Rails Application

The Rails app is a standard Rails 3 application. Once you've set up your config/database.yml file, a bundle install, rake db:schema:laod, and rails server and you should be up and running.

The Faye Server

Faye handles pub/sub for the app, along with the PrivatePub extension. faye.ru is already set up to create a server for you; start it with

rackup faye.ru -s thin -E production

Note: Faye currently requires thin, and its environment must be set to production (this is the RACK_ENV variable internally, not the RAILS_ENV).

You can configure Faye/PrivatePub using config/private_pub.yml. There is a sample for you to work off at config/private_pub.yml.example. Be sure to choose a good secret token!

If config/private_pub.yml does not exist, faye.ru will use the values in ENV["PP_SERVER"] and ENV["PP_TOKEN"] for the server and token to use, respectively.

The MongoDB Chat Log

Chats and events are collected into a MongoDB collection. The app uses the values in the following environment variables to connect to a MongoDB database:

ENV["MONGO_HOST"] = "mongo.db.host"
ENV["MONGO_PORT"] = "12345"
ENV["MONGO_DB"]   = "database_name"

Additionally, if your connection requies a username and password, you may set these environment variables as well:

ENV["MONGO_USER"] = "mongo_user"
ENV["MONGO_PASS"] = "mongo_password"

You need to create a collection called chatlogs in your database (using a capped collection works great for Chatterbox's purposes).

The Future

Expect some improvements as time permits. Specifically:

  • A list of users currently in a room, along with active/idle status
  • Rooms get deleted after they are empty for a certain amount of time
  • Able to change room settings after creation
  • Third-party auth that doesn't crash MRI
  • Maybe even an API!?

chatterbox's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

chatterbox's Issues

Implement more robust "parted" status

Currently, the app depends on a window.onbeforeunload even to know that a user has left the room. While this is great for immediate feedback, it's not 100% reliable. Ideally, the application will keep track of whether or not a user is in a room.

Changed "joined" functionality

Currently Faye sends a "joined" event from the #show action, before the room loads. I think this would be better in the JavaScript for the room's document.ready; once the page loads, send an Ajax POST to /rooms/:id/join with the necessary parameters. Upon a successful response, the text input/send button would be enabled.

Chat content filtering

Currently chat data is shown in the chatlog as-is, including HTML, etc. This should be escaped or otherwise cleaned up.

Fix room URLs

It seems kinda pointless to generate random hex names for rooms if the room will be accessed by its ID in the URL.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.