myfashionhub / fit-schedule

A Google calendar-integrated app that lets users stay on top of all their fitness classes

Home Page:http://fitschedule.herokuapp.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Fit Schedule

A Google Calendar-integrated app that lets you stay on top of your fitness schedule.

How it works

  • User signs in with Google and gives FitSchedule access to the calendar (this request is handled by omniauth and omniauth-google-oauth2).

  • User pastes a schedule URL from FitReserve or MindBody Online. The app scrapes the page for the schedule, and shows users all the class types to choose from.

    • FitReserve is scraped using Nokogiri.

    • MindBody Online page is opened in a headless browser by Poltegeist, a PhantomJS driver for Capybara. Then the page's HTML can be parsed by Nokogiri.

  • The Calendar class, a non-ActiveRecord model used to handle interactions with the Google API client, obtains events in the user's calendar.

  • When the user goes on their schedule page, they can view all the classes that match their preferences and do not conflict with appointments they already have on the calendar. (Filter logic)

  • User can choose the classes he/she desires and saves it as an appointment.

fitschedule-preferences

fitschedule-schedule

Planned features

  • Invalidate cache when user adds new studios or filters.
  • Sync the appointments to Google Calendar.
  • Renew Google token offline to keep user signed in.
  • Scrape classes on ClassPass.

Getting started

  • Clone the repo, create the database: $ rake db:create db:migrate

  • Obtain Google client id and secret:

    • In the Google Developer Console, create a new project.

    • Under APIs & auth > API, enable the Google+ API and Calendar API

    • Under APIs & auth > Credentials, add to Authorized redirect URIs your callback URLs, i.e. http://localhost:3000/auth/google_oauth2/callback. (Add one for each environment if they have different hostname.)

  • Seed the db with studios:

rake db:seed
  • Add environment variables in a .env file in the project root:
FS_GOOGLE_ID=
FS_GOOGLE_SECRET=
API_URL=localhost:3000
  • Start the app with rails s, it should be available at localhost:3000

Deploying to Heroku

  • Create a new heroku remote and push to it:
$ heroku create [app name]
$ git push heroku master
  • Create the database:
$ heroku run rake db:create db:migrate
$ heroku run rake db:seed
  • Set environment variables:
$ heroku config:set FS_GOOGLE_ID=[Google id]
                    FS_GOOGLE_SECRET=[Google secret]
                    API_URL=[Heroku app URL]
  • If assets are not showing up, precompile them:
$ heroku run assets:precompile
  • Add buildpacks for Nodejs and PhantomJS
heroku buildpacks:add --index 1 heroku/nodejs
heroku buildpacks:add  https://github.com/stomita/heroku-buildpack-phantomjs
  • Add web process for Procfile
web: bin/rails server -p $PORT -e $RAILS_ENV
  • Add package.json to specify Node version

Tasks

  • schedule:scrape_studio_classes: gets classes for all studios.

  • schedule:scrape_studios updates schedule for all studios that are favorited by users (scheduled to run twice a day).

  • Get updated list of studios:

$ chrome --headless --dump-dom https://www.fitreserve.com/pricing
  • Update FitReserve studio entries: $ rake db:seed

About

A Google calendar-integrated app that lets users stay on top of all their fitness classes

http://fitschedule.herokuapp.com


Languages

Language:HTML 58.6%Language:Ruby 23.4%Language:JavaScript 13.5%Language:CSS 4.5%