GithubHelp home page GithubHelp logo

mythmon / crimsontwins Goto Github PK

View Code? Open in Web Editor NEW
25.0 8.0 5.0 8.04 MB

We have these two big TVs on the wall. This is something to do with them.

License: Mozilla Public License 2.0

JavaScript 69.33% CSS 30.67%

crimsontwins's Introduction

CrimsonTwins

Build Status

Mozilla WebDev recently got two big wall mounted screens for our nefarious uses. We decided they should show some useful information, and be a source of irc-based mayem. This is a Node.js app that starts an IRC bot and a HTTP server, including a Socket.IO layer.

The main page served to the browser opens a Socket.IO listener, and waits for events from the server. The bot triggers events when the denizens of IRC tell it URLs of images, websites, and hilarious Youtube videos. It relays these to the front end. The front end then dynamically loads the content onto the display. Content is loaded, without refreshing the page, via iframes or other methods.

A second page is provided, called Hydra. Hydra will take URL parameters for 'x' and 'y', and then build a grid of the main page tiled across the page. This is useful if you want to give the impression of multiple screens on a single monitor.

Installation

CrimsonTwins is a node app, so you'll need a copy of node in your path. Pull down the repo, install dependencies with npm, edit your configuration, and start the process. The whole process looks like:

git clone https://github.com/mythmon/crimsontwins.git
cd crimsontwins
npm install
cp config.json-dist cp config.json
vi config.json
node crimsontwins.js

Requirements

Dependencies are listed in package.json. You can install everything automatically with:

> npm install

Configuration

You'll need to configure things. Copy config.json-dist to config.json, and edit it appropriately. The options you can set in this file are:

  • resetUrls - An array of urls for the default rotation.
  • resetTime - The time it takes to automatically cycle a screen.
  • screens - An array of screens to automatically create.
  • web
    • host - The host to bind to.
    • port - The port to bind to.

Warning! This file may be overwritten at run time. Things that can change are currently limited to the resetUrls and screens, which are editable from the web interface.

Run

The main file is crimsontwins.js. Run that like

> node crimsontwins.js

If you encounter warn - error raised: Error: listen EACCES, you probably set a port you don't have access to listen on, such as ports below 1024. You may need to escalate privileges of the user running the account and execute it as:

> sudo node crimsontwins.js

You should now have a running crimsontwins instance.

Development

Make a feature branch and hack away. When you're ready, open a pull request. Use make test to run tests locally.

Running the IRC bot

We've bundled an IRC bot for issuing commands to the server. The bot is a separate Node.js app, located at /ext/chat.js, and is not required to run or use the crimsontwins server. It may eventually graduate to its own repo.

Configuration

The bot doesn't read from the same config file as the main app. You'll need to set some environment variables:

  • CT_IRC_SERVER - IRC server name
  • CT_IRC_NICK - IRC bot's nick
  • CT_IRC_CHANNELS - comma-separated list of IRC channels
  • CT_API_URL - Crimsontwins URL

If your IRC server requires a password, set CT_IRC_SERVER_PASSWORD as well.

Run

Here's an example:

> export CT_IRC_SERVER=irc.server.org
> export CT_IRC_NICK=crimsontwins
> export CT_IRC_CHANNELS='#foo,#bar'
> export CT_API_URL=http://myct.example.com
> node ext/chat.js

API

Your CrimsonTwins instance will expose an API that can be directly queried by external tools and services.

GET /api/ping

Returns "pong". Useful as a heartbeat monitor or general sanity check.


POST /api/sendurl

params: timeout    - an integer for how long to keep this on the page
        screenName - the name of the screen that should display the content
                     (optional)
        url        - the url to display (http and all)

Send a particular url to a particular CT screen


GET /api/config

Returns the current configuration of the server. This is probably only useful for debugging.


GET /api/staticpath

Returns the file system path of crimsontwins's static assets. This is probably only useful for debugging.


GET /api/env

Returns the crimsontwin's process environment. This is probably only useful for debugging.

crimsontwins's People

Contributors

jaredhirsch avatar lonnen avatar mattbasta avatar mythmon avatar potch avatar rfreebern avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

crimsontwins's Issues

Don't follow temporary redirects during initialization

Some sites use 301 temporary redirects to do random things. These redirects should not be followed during initialization, so that the resets show random content when desired. This might mean that we need to just ditch the idea of doing this processing and verification upfront.

Enable third parties to connect and see content on screen

If we deployed this on a server, people could run their own screen if they so desire.

At the moment, this will just add additional screens to the pool, which is not what we want.

Either we remove the pool and every client is just a copy of the main screen or we come up with a way to distinguish (login?).. hmmm.

Seperate the server and irc bot.

Make the bot independent of Crimsontwins. Leave the bot as a reference implementation or consider rewriting it as a Hubot plugin. May be blocked on issue #21

Implement API

Implement an HTTP API that has equivalent functionality to the bot.

Client should gracefully handle a server reboot

When the server is temporarily down the client happily displays what it last loaded, but requires a refresh to reconnect. The client should be able to reconnect on its own and display some UI warning that it's disconnected or that it's screen does not exist.

Have some default content.

There should be a list of URLs that are shown when nothing else is going on, and after a few minutes of showing whatever silly gif someone posted, it should return to a default url.

What am I missing

I discovered CT through DevOps weekly and it's a perfect solution to my multiple screen problems - better than the hacky PHP page I put together. But I can't get the IRC part to do anything - I can add screens through the admin interface and the bot joins our IRC server but it doesn't respond to anything :-(

I've tried mentioning it and messaging it with URLs and they scroll past in stdout but they don't get added to the displays.

My very limited NodeJS experience means I can just about work out what the app is doing but I can't figure out what I'm missing.

Any suggestions?

Use nunjucks for templating

Actually, doesn't have to be nunjucks, but at any rate, currently the application code and templates are intermingled and they shouldn't be.

We might have to precompile the templates at start time, but this is node, we can do that!

/cc @jlongster and @tofumatt so they can tell me this is a horrible idea ;)

optional param to modify the black bar content

There should be an optional param to modify the content of the black bar. In it's absence the bar will display the URL, as it currently does.

This would allow us to add comic alt text to the bars, or include data from the IRC bot about what the dashbot query params were that lead to the image.

Switch to Stylus, do it on the server side.

Right now we are using LESS. Lets jump on the bandwagon and use Stylus.

Right now LESS is being compiled on the client side, every time. Lets stop that, and compile the CSS on the server.

create api endpoints for adding and removing screens

Video Lego Blocks RFC is a first stab at a fuzzy notion of auto-registering air mozilla components. It's a little long, so I've boiled it down into something more concrete --

Consider a live air mozilla setup -- mozcamp, mozfest, perhaps summit. Cameras turning on and off as different talks, keynotes, and social events start and stop. We have camera blocks that can 'check in' with a predefined url and then start streaming. With the proposed API these camera blocks could register a new CT screen at start up and stream to it, then deregister it when it disconnects. This may require a thin shim, but I think the idea is sound and this would be a necessary first step.

More complete monitor multiplexing

Consider adding the ability to stretch a single virtual screen across multiple physical screens. Will require CrimsonTwins has some knowledge of how its screens are laid out.

Move on TV to my wall

Since this is a problem I propose that we could cut this problem in half by moving a tv to my wall.

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.