jeffstieler / liftie

Clean, simple, easy to read, fast ski resort lift status.

Home Page:http://liftie.info

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Build Status Dependency Status NPM version Code Climate

#liftie.info

Clean, simple, easy to read, fast ski resort lift status.

Features

  • Displays multiple resorts on a single page.

  • Refreshes automatically every 65 seconds.

  • Index page displays all supported resorts but it's possible to specify (and bookmark) a subset:

      http://liftie.info?resorts=alpine,squaw
    
  • REST type API returns a status of each resort.

      GET http://liftie.info/api/resort/<resort>
    
  • Status is cached on a server side. Regardless of the number of browser request, server will retrieve (and parse) the resort pages only once per minute.

How to run liftie locally

Clone this repo (or your fork)

git clone git@github.com:code42day/liftie.git && cd liftie

Install dependencies with npm:

npm install

Build client side scripts: liftie is using component - make will install all external components and trigger component build for you.

make

Run and profit (liftie binds to port 3000 by default)

node app

How to add your favorite acme.com resort

The easiest way to start working on a new resort is to run generate script.

$./bin/generate

Short name of the resort [acme]:
Human readable name of the resort [Acme Ski]:
URL of the page with lift status [http://acme.com/lift/status]:

Generating files for Acme Ski
Generating lib/resorts/acme.js...
Generating test/resorts/acme.js...
Retrieving http://acme.com/lift/status to test/resorts/example/acme.html...

The script expects the short (one word) identifier of the ski resort, the human readable name and the URL of the page with lift status. It generates resort module lib/resort/acme.js and a test for a parsing function test/resort/acme.js. It also retrieves the lift status page and puts it in test/resort/example directory.

At this point you should probably run the tests: since parsing function is not implemented the test will fail.

lib/resorts/acme.js exports the following object

{
  name: 'Acme Ski Resort',
  url: {
    host: 'http://acme.com',
    pathname: '/lift/status'
  },
  tags: ['state', 'area'], // optional
  parse: function(dom) {}
}

Parse function needs to return a lift status object, which will look something like that:

{
  'Super Express Lift': 'closed',
  'Magic Carpet': 'open',
  'Ultra Gondola': 'hold',
  'T-Bar': 'scheduled'
}

Newly added resort is displayed automatically on liftie index page.

Using resort API

In addition to parsing lift status pages Liftie supports resorts that make their lift status available through REST API. In such cases you need to specify api element in resort descriptor.

{
  name: 'Acme Ski Resort',
  url: {
    host: 'http://acme.com',
    pathname: '/lift/status'
  },
  api: {
    host: 'http://api.acme.com',
    pathname: '/api/status'
  },
  parse: function(json) {}
}

If api is specified Liftie will retrieve status info through HTTP GET. The resort parse function will receive parsed json instead of the dom tree. Please note that you still need to configure url - it is used on Liftie pages to send users to official resort page. Check out Steamboat implementation, if you are looking for an example.

Credits

Icon Font generated with IconMoon App

Forecast Font from Icon Vault -- SIL Open Font License

Tags CSS (stylus) is a simplified version of Sliding Tags by Thibaut Courouble -- License MIT

License

BSD

TODO

  • refresh on change only (web sockets?)
  • detect changes and enable change notifications (HTML5 notifications)
  • tweet on change support

About

Clean, simple, easy to read, fast ski resort lift status.

http://liftie.info

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:HTML 97.6%Language:JavaScript 2.2%Language:CSS 0.1%Language:Makefile 0.0%Language:Shell 0.0%