Skip to content

Instantly share code, notes, and snippets.

@manchunlam
Last active October 11, 2015 04:08
Show Gist options
  • Save manchunlam/3801021 to your computer and use it in GitHub Desktop.
Save manchunlam/3801021 to your computer and use it in GitHub Desktop.
Tabs Manual Install

Welcome to Tabs

Steps to Setting up your Tabs Development Environment

1. Setup Mac

On OS X,

  1. Install XCode

    If you are using XCode 4 and above, please also install Command Line Tools by

    Launch XCode > Preferences > Settings > Downloads
    
  2. Install Homebrew

    If you are using OS 10.7 or above, please see these prerequisites before going to the next step

  3. Install rbenv

    brew install rbenv
  4. Install ruby-build

    brew install ruby-build
  5. Insall ruby with rbenv

    rbenv install 1.9.2-p290
  6. Install git with

    brew install git
  7. Follow the instructions on this page to set up your SSH key pair and tell Github about your public key:

    https://help.github.com/articles/generating-ssh-keys

  8. Clone Tabs to the directory of your choice.

    git clone git@github.com:vitrue/tabs.git
    git checkout develop
  9. Set up the submodules:

    git submodule init
    git submodule update
  10. Install gems

    cd ~
    gem install bundler
    cd $project_root
    mkdir .bundle
    bundle install --path .bundle
  11. Download file-syncing scripts (if you don't develop on Mac, skip to Setup Virtual Machine)

  12. File Syncing Script * Save to $project_root/fsevent_rsync.rb * Change the variable vm_name

  13. rsync File Ignore List * Save to $project_root/.rsyncignore

  14. rsync File Keep List * Save to $project_root/.rsynckeep

  15. Run the file-sync script to put files on dev VM

    cd $project_root
    ruby fsevent_rsync.rb

    Note: The script must be running at all times to keep files synchronized between Mac and VM

  16. Create tmp directory If it doesn't already exist, do

    mkdir tmp
    mkdir tmp/pids
    mkdir tmp/sockets
    mkdir log

2. Setup Virtual Machine

On Virtual Machine,

  1. Install rbenv

  2. Install ruby-build

  3. Install the following packages

    For Ubuntu

    sudo apt-get install mysql-client libmysqlclient-dev libxml2 libxml2-dev libxslt1-dev imagemagick libmagickcore-dev libcurl4-gnutls-dev sqlite3 libsqlite3-dev openssl libssl-dev libopenssl-ruby1.9 libreadline-dev redis-server mysql-server nginx
  4. Install Ruby

    For Ubuntu

    sudo apt-get install libreadline5-dev libncurses5-dev
    ls -al /usr/include | ack-grep "readline"
    ls -al /usr/include | ack-grep "openssl"
    CONFIGURE_OPTS="--with-readline-dir=/usr/include/readline --with-openssl-dir=/usr/include/openssl" rbenv install 1.9.2-p290
  5. Install Gems

    cd ~
    gem install bundler rb_fsevent
  6. Install RMagick (Image Processing)

    For Ubuntu

    sudo apt-get install imagemagick libmagickcore-dev libmagickwand-dev librmagick-ruby
  7. Download the following files

  8. Unicorn Configuration File * Save to $project_root/config/unicorn.rb * Change the variable project_root

  9. Nginx Configuration File * Save to etc/nginx/sites-available/tabs.config * Change the variables project_url and project_root * Link the above in etc/nginx/sites-enable

      cd /etc/nginx/sites-enable
      ln -s /etc/nginx/sites-available/tabs.config .
  10. Start Nginx

    sudo nginx

3. Setup Tabs

On Virtual Machine,

  1. Create development and test databases, e.g. site_dev_tabs and site_test_tabs

    In terminal:

    mysql -u root

    In MySQL terminal:

    CREATE DATABASE site_dev_tabs;
    CREATE DATABASE site_test_tabs;
  2. Make a database.yml file, in $project_app/config folder, and configure it to use the newly created mysql database.

    Example:

    development: &dev
      adapter: mysql2
      hostname: localhost
      database: site_dev_tabs
      username: root
      password:
    
    test:
      adapter: mysql2
      hostname: localhost
      database: site_test_tabs
      username: root
      password:
  3. Create a new Facebook Application with these settings:

    • App Namespace: pick something unique to go here, like "yourname_dev_tabs"

    Notes: Don't fill URL or domain fields, Tabs will make it for you when you add application in Tabs.

  4. Make a facebooker.yml file, in the config folder, and configure it appropriately, with the info from previous step, like this:

    development: &dev
      api_key: "xxxx" # copy this from Facebook, make there are double-quotes around it
      secret_key: xxxx # copy this from Facebook
      application_id: xxxx # copy this from Facebook (same as api_key, but without quotes)
      canvas_page_name: yourname_dev_tabs
      callback_url: http://tabs.joelam123.dev.cloud.vitrue.com/ # your $project_url in Nginx config file
      pretty_errors: true
      set_asset_host_to_callback_url: false
      slug: fms
      use_for_fb_connect: true
    
    test: *dev
  5. Copy config files from templates

    bundle exec rake tabs:copy_configs
  6. Install gems

    bundle install
  7. Database migration

    bundle exec rake db:migrate
  8. Seed the database

    1. Edit lib/tasks/seed.rake to add your own user

      bundle exec rake --trace db:seed
  9. Start unicorn, and resque jobs

    cd $project_root
    bundle exec unicorn -c config/unicorn.rb -E development -D
    start-stop-daemon --start --exec /home/deploy/.rbenv/shims/bundle -d /home/deploy/Projects/Vitrue/tabs -b --make-pidfile --pidfile /home/deploy/Projects/Vitrue/tabs/tmp/pids/resque-pool.pid -v -- exec rake resque:pool
    start-stop-daemon --start --exec /home/deploy/.rbenv/shims/bundle -d /home/deploy/Projects/Vitrue/tabs -b --make-pidfile --pidfile /home/deploy/Projects/Vitrue/tabs/tmp/pids/resque-scheduler.pid -v -- exec rake resque:scheduler
  10. Check if Tabs is running

    1. Go to http://tabs.[yourname].dev.cloud.vitrue.com
    2. You should see a login screen

3. Using Tabs

  1. Contact Accounts team for your own account

    1. Ask for a super-admin account for Accounts Sandbox. Let them know you need Tabs
    2. Test it out by going to http://accounts-sandbox.staging.cloud.vitrue.com, and log in
  2. Log into Tabs

    1. Add your Facebook application Connections > My Apps
    2. Attach your Facebook Page to a Tabs view Connections > My Facebook Pages > Attach View

    Please see the help files: http://help.vitrue.com/kb/vitrue-tabs/connections-making-a-view-live-on-facebook

  3. [Optional] Setting up Tabs preview in development

    1. Create a new Facebook App
    • Canvas URL ($canvas_url) is just like usual

      $project_url/apid/$app_id/
      
    • Tab URL is

      $canvas_url/facebook/preview_iframe
      
    1. Add your Facebook App to a Facebook Page
    • Go to the Profile Page for your Facebook App
    • Click Add to Page
    • Pick your Page
    • Find the URL of your App on the Page and copy it to use for $page_url below
    1. Next update your facebooker.yml by adding your new app under alternative_keys. See an example below on where to put alternative_keys:

      development: &dev
        api_key: 1234
        secret_key: xxxx
        canvas_page_name: melsapp-fms-default
        callback_url: http://melinda.pipe.vitrue.com/
        application_id: 326655126925
        pretty_errors: true
        set_asset_host_to_callback_url: false
        page_url: "http://www.facebook.com/apps/application.php?id=326655126925&v=app_326655126925"
        slug: fms
        use_for_fb_connect: true
        alternative_keys:
          "<FILL IN NEW FACEBOOK APP ID>":
            secret_key: <FILL IN FACEBOOK SECRET KEY>
            canvas_page_name: <FILL IN CANVAS PAGE NAME>
            callback_url: <YOUR CALLBACK>
            application_id: <FILL IN YOUR APP ID>
            page_url: "<FILL IN THE URL FOR YOUR APP ON THE PAGE>"
            slug: tabs_iframe_preview
    2. Run a rake task:

      bundle exec rake facebook:add_preview_app

4. NOTES

  1. facebooker.yml canvas page name should be the same as the Namespace used for the Facebook App created

  2. gcc in Lion or above

    brew tap homebrew/versions
    brew install gcc45
    which gcc # change the link to point to gcc45
    bundle install
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment