Code Monkey home page Code Monkey logo

liftie's Introduction

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 [email protected]: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

liftie's People

Contributors

melitele avatar pirxpilot avatar

Watchers

 avatar

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.