From a42d750b3074e1c40d14fbafc0a55b8207c2025c Mon Sep 17 00:00:00 2001 From: Seth Call Date: Sat, 22 Feb 2014 07:46:41 +0000 Subject: [PATCH] * VRFS-468 - hiding any pages not needed for production appropriately --- web/app/controllers/gmail_controller.rb | 35 ++++++++++++++++++++++ web/app/controllers/spikes_controller.rb | 37 ++++-------------------- web/config/routes.rb | 34 ++++++++++------------ 3 files changed, 56 insertions(+), 50 deletions(-) create mode 100644 web/app/controllers/gmail_controller.rb diff --git a/web/app/controllers/gmail_controller.rb b/web/app/controllers/gmail_controller.rb new file mode 100644 index 000000000..516486364 --- /dev/null +++ b/web/app/controllers/gmail_controller.rb @@ -0,0 +1,35 @@ +class GmailController < ApplicationController + + + def gmail_contacts + if current_user.nil? + render :nothing => true, :status => 404 + return + end + authorization = current_user.user_authorizations.where(:provider => 'google_login') + if authorization.empty? + render :nothing => true, :status => 404 + return + end + token = authorization.first.token + uri = URI.parse("https://www.google.com/m8/feeds/contacts/default/full?oauth_token=#{token}&max-results=50000&alt=json") + + http = Net::HTTP.new(uri.host, uri.port) + http.use_ssl = true + http.verify_mode = OpenSSL::SSL::VERIFY_NONE + request = Net::HTTP::Get.new(uri.request_uri) + response = http.request(request) + contacts = ActiveSupport::JSON.decode(response.body) + ret_contacts = [] + contacts['feed']['entry'].each_with_index do |contact,index| + name = contact['title']['$t'] + contact['gd$email'].to_a.each do |email| + email_address = email['address'] + ret_contacts.push(email_address) + end + end + + render :json => ret_contacts + end + +end diff --git a/web/app/controllers/spikes_controller.rb b/web/app/controllers/spikes_controller.rb index fc44414ab..d64ff6c98 100644 --- a/web/app/controllers/spikes_controller.rb +++ b/web/app/controllers/spikes_controller.rb @@ -1,41 +1,14 @@ +############################################################### +### A spike is something that you build to prove something. ### +### It's not meant to be used in the actual product. ### +############################################################### + class SpikesController < ApplicationController def facebook_invite end - - def gmail_contacts - if current_user.nil? - render :nothing => true, :status => 404 - return - end - authorization = current_user.user_authorizations.where(:provider => 'google_login') - if authorization.empty? - render :nothing => true, :status => 404 - return - end - token = authorization.first.token - uri = URI.parse("https://www.google.com/m8/feeds/contacts/default/full?oauth_token=#{token}&max-results=50000&alt=json") - - http = Net::HTTP.new(uri.host, uri.port) - http.use_ssl = true - http.verify_mode = OpenSSL::SSL::VERIFY_NONE - request = Net::HTTP::Get.new(uri.request_uri) - response = http.request(request) - contacts = ActiveSupport::JSON.decode(response.body) - ret_contacts = [] - contacts['feed']['entry'].each_with_index do |contact,index| - name = contact['title']['$t'] - contact['gd$email'].to_a.each do |email| - email_address = email['address'] - ret_contacts.push(email_address) - end - end - - render :json => ret_contacts - end - def listen_in #as_musician = false is the critical search criteria for sessions to list correctly diff --git a/web/config/routes.rb b/web/config/routes.rb index 54cd40d12..3fa2edf92 100644 --- a/web/config/routes.rb +++ b/web/config/routes.rb @@ -8,14 +8,8 @@ SampleApp::Application.routes.draw do resources :users resources :sessions, only: [:new, :create, :destroy] - #root to: 'static_pages#home' - #root to: 'clients#index' root to: 'users#welcome' - #match '/welcome', to: 'users#welcome' - # This page is still here, and is under test. Keep a route to it. - match '/oldhome', to: 'static_pages#home' - # signup, and signup completed, related pages match '/signup', to: 'users#new', :via => 'get' match '/signup', to: 'users#create', :via => 'post' @@ -38,17 +32,10 @@ SampleApp::Application.routes.draw do match '/isp/ping.jar', :to => redirect('/ping.jar') match '/isp/ping:isp', :to => 'users#jnlp', :constraints => {:format => :jnlp}, :as => 'isp_ping' - match '/help', to: 'static_pages#help' - match '/about', to: 'static_pages#about' - match '/contact', to: 'static_pages#contact' - match '/faders', to: 'static_pages#faders' - match '/client', to: 'clients#index' match '/confirm/:signup_token', to: 'users#signup_confirm', as: 'signup_confirm' - match '/test_connection', to: 'sessions#connection_state', :as => :connection_state - match '/client/authed/:authed/:data', to: 'clients#auth_action', :as => :auth_action # ping test @@ -59,11 +46,6 @@ SampleApp::Application.routes.draw do match '/ping/pingtw.jnlp', to: 'ping#tw' match '/ping/pingvz.jnlp', to: 'ping#vz' - # spikes - match '/facebook_invite', to: 'spikes#facebook_invite' - match '/gmail_contacts', to: 'spikes#gmail_contacts' - match '/listen_in', to: 'spikes#listen_in' - # share tokens match '/s/:id', to: 'share_tokens#shareable_resolver', :as => 'share_token' @@ -76,12 +58,28 @@ SampleApp::Application.routes.draw do # email update match '/confirm_email' => 'users#finalize_update_email', :as => 'confirm_email' # NOTE: if you change this, you break outstanding email changes because links in user inboxes are broken + match '/gmail_contacts', to: 'gmail#gmail_contacts' + # embed resque-web if this is development mode if Rails.env == "development" require 'resque/server' require 'resque-retry' require 'resque-retry/server' mount Resque::Server.new, :at => "/resque" if Rails.env == "development" + + # route to spike controller (proof-of-concepts) + match '/facebook_invite', to: 'spikes#facebook_invite' + match '/listen_in', to: 'spikes#listen_in' + + # junk pages + match '/help', to: 'static_pages#help' + match '/about', to: 'static_pages#about' + match '/contact', to: 'static_pages#contact' + match '/faders', to: 'static_pages#faders' + end + + if Rails.env == "test" + match '/test_connection', to: 'sessions#connection_state', :as => :connection_state end scope '/corp' do