├── .travis.yml ├── Gemfile ├── lib ├── google-instant-hangouts │ ├── version.rb │ ├── rails.rb │ └── helper.rb └── google-instant-hangouts.rb ├── Rakefile ├── Changelog.md ├── google-instant-hangouts.gemspec ├── Gemfile.lock ├── Readme.md └── app └── assets └── javascripts └── google-instant-hangouts.js /.travis.yml: -------------------------------------------------------------------------------- 1 | language: ruby 2 | rvm: 3 | - 2.0.0-p247 -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source "http://rubygems.org" 2 | gemspec 3 | -------------------------------------------------------------------------------- /lib/google-instant-hangouts/version.rb: -------------------------------------------------------------------------------- 1 | module GoogleInstantHangouts 2 | VERSION = "0.0.3" 3 | end 4 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require 'bundler/gem_tasks' 2 | 3 | task :default do 4 | puts "Hello google-instant-hangouts!" 5 | end -------------------------------------------------------------------------------- /Changelog.md: -------------------------------------------------------------------------------- 1 | # 0.0.3 / 2014-01-27 2 | 3 | Support for Hangout air,widget size & width paramters. 4 | 5 | # 0.0.1 / 2014-01-27 6 | 7 | Google instant hangouts gearing up! 8 | 9 | -------------------------------------------------------------------------------- /lib/google-instant-hangouts.rb: -------------------------------------------------------------------------------- 1 | require 'google-instant-hangouts/version' 2 | require 'google-instant-hangouts/rails' 3 | require 'google-instant-hangouts/helper' 4 | 5 | ActionView::Base.send(:include, GoogleInstantHangouts::Helper) 6 | -------------------------------------------------------------------------------- /lib/google-instant-hangouts/rails.rb: -------------------------------------------------------------------------------- 1 | module GoogleInstantHangouts 2 | module Rails 3 | class Engine < ::Rails::Engine 4 | 5 | initializer "precompile", :group => :all do |app| 6 | app.config.assets.precompile << Proc.new{|path| path == "google-instant-hangouts.js" } 7 | end 8 | end 9 | end 10 | end -------------------------------------------------------------------------------- /lib/google-instant-hangouts/helper.rb: -------------------------------------------------------------------------------- 1 | module GoogleInstantHangouts 2 | module Helper 3 | 4 | def instant_hangout(opts={}) 5 | defaults = {render: 'createhangout',lang: 'en',room_id: 'my_room',topic: 'my topic',widget_size: 136,width: 300, hangout_type: :normal} 6 | defaults.merge!(opts) 7 | content_tag(:div,nil, 8 | class: "instanthangouts", 9 | render: defaults[:render], 10 | lang: defaults[:lang], 11 | room_id: defaults[:room_id], 12 | topic: defaults[:topic], 13 | widget_size: defaults[:widget_size], 14 | width: defaults[:width], 15 | hangout_type: defaults[:hangout_type]) 16 | end 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /google-instant-hangouts.gemspec: -------------------------------------------------------------------------------- 1 | # -*- encoding: utf-8 -*- 2 | $:.push File.expand_path("../lib", __FILE__) 3 | require "google-instant-hangouts/version" 4 | 5 | Gem::Specification.new do |s| 6 | s.name = "google-instant-hangouts" 7 | s.version = GoogleInstantHangouts::VERSION 8 | s.authors = ["Ankit Gupta","Ashish Upadhyay"] 9 | s.date = '2014-01-27' 10 | s.email = ["ankit.gupta8898@gmail.com","ashish.upadhyaye@gmail.com"] 11 | s.summary = %q{Gem to Easily add Google+ Hangouts to any web page and Rails asset pipeline} 12 | s.description = %q{Gem to Easily add Google+ Hangouts to any web page and Rails asset pipeline} 13 | 14 | s.files = `git ls-files`.split("\n") 15 | s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") 16 | 17 | s.require_paths = ["lib"] 18 | s.licenses = ['MIT'] 19 | s.homepage = 'https://github.com/ankit8898/google-instant-hangouts' 20 | s.add_dependency "railties", ">= 3.1" 21 | s.add_development_dependency "bundler", "~> 1.0" 22 | s.add_development_dependency "rails", ">= 3.1" 23 | s.add_development_dependency 'rake' 24 | s.post_install_message = %q{------------------------------ Enjoy Google Instant Hangouts !------------------------------ } 25 | end 26 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | PATH 2 | remote: . 3 | specs: 4 | google-instant-hangouts (0.0.2) 5 | railties (>= 3.1) 6 | 7 | GEM 8 | remote: http://rubygems.org/ 9 | specs: 10 | actionmailer (4.0.2) 11 | actionpack (= 4.0.2) 12 | mail (~> 2.5.4) 13 | actionpack (4.0.2) 14 | activesupport (= 4.0.2) 15 | builder (~> 3.1.0) 16 | erubis (~> 2.7.0) 17 | rack (~> 1.5.2) 18 | rack-test (~> 0.6.2) 19 | activemodel (4.0.2) 20 | activesupport (= 4.0.2) 21 | builder (~> 3.1.0) 22 | activerecord (4.0.2) 23 | activemodel (= 4.0.2) 24 | activerecord-deprecated_finders (~> 1.0.2) 25 | activesupport (= 4.0.2) 26 | arel (~> 4.0.0) 27 | activerecord-deprecated_finders (1.0.3) 28 | activesupport (4.0.2) 29 | i18n (~> 0.6, >= 0.6.4) 30 | minitest (~> 4.2) 31 | multi_json (~> 1.3) 32 | thread_safe (~> 0.1) 33 | tzinfo (~> 0.3.37) 34 | arel (4.0.1) 35 | atomic (1.1.14) 36 | builder (3.1.4) 37 | erubis (2.7.0) 38 | hike (1.2.3) 39 | i18n (0.6.9) 40 | mail (2.5.4) 41 | mime-types (~> 1.16) 42 | treetop (~> 1.4.8) 43 | mime-types (1.25.1) 44 | minitest (4.7.5) 45 | multi_json (1.8.4) 46 | polyglot (0.3.3) 47 | rack (1.5.2) 48 | rack-test (0.6.2) 49 | rack (>= 1.0) 50 | rails (4.0.2) 51 | actionmailer (= 4.0.2) 52 | actionpack (= 4.0.2) 53 | activerecord (= 4.0.2) 54 | activesupport (= 4.0.2) 55 | bundler (>= 1.3.0, < 2.0) 56 | railties (= 4.0.2) 57 | sprockets-rails (~> 2.0.0) 58 | railties (4.0.2) 59 | actionpack (= 4.0.2) 60 | activesupport (= 4.0.2) 61 | rake (>= 0.8.7) 62 | thor (>= 0.18.1, < 2.0) 63 | rake (10.1.1) 64 | sprockets (2.10.1) 65 | hike (~> 1.2) 66 | multi_json (~> 1.0) 67 | rack (~> 1.0) 68 | tilt (~> 1.1, != 1.3.0) 69 | sprockets-rails (2.0.1) 70 | actionpack (>= 3.0) 71 | activesupport (>= 3.0) 72 | sprockets (~> 2.8) 73 | thor (0.18.1) 74 | thread_safe (0.1.3) 75 | atomic 76 | tilt (1.4.1) 77 | treetop (1.4.15) 78 | polyglot 79 | polyglot (>= 0.3.1) 80 | tzinfo (0.3.38) 81 | 82 | PLATFORMS 83 | ruby 84 | 85 | DEPENDENCIES 86 | bundler (~> 1.0) 87 | google-instant-hangouts! 88 | rails (>= 3.1) 89 | rake 90 | -------------------------------------------------------------------------------- /Readme.md: -------------------------------------------------------------------------------- 1 | [![Gem Version](https://badge.fury.io/rb/google-instant-hangouts.png)](http://badge.fury.io/rb/google-instant-hangouts)[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/ankit8898/google-instant-hangouts/trend.png)](https://bitdeli.com/free "Bitdeli Badge") 2 | 3 | # Google Instant Hangout 4 | ___ 5 | A Ruby wrapper to integrate Google's [Instant Hangout](https://github.com/google/instant-hangouts) - Instant Hangouts lets you easily add Google+ Hangouts to any web page: 6 | *** 7 | The Hangout button lets you to launch a Google+ Hangout directly from your site. When you use the button, you can set up the Hangout in a variety of configurations. For example, you can specify Hangout apps that launch along with the Hangout and setup the Hangout as a regular Hangout or a Hangout On Air. 8 | 9 | You can customize the Hangout button to meet the needs of your website by modifying the button size, loading the button when the page loads, or selectively showing the button using JavaScript. 10 | 11 | Use of the Hangout button is subject to the [Button Policy](https://developers.google.com/+/web/buttons-policy) 12 | ___ 13 | #### Sample Application 14 | 15 | [Sample Application with usage can be found here](http://serene-plateau-8981.herokuapp.com) 16 | *** 17 | ### Installation 18 | 19 | Add the gem to the Gemfile: 20 | 21 | gem "google-instant-hangouts" 22 | 23 | ### Usage 24 | 25 | In your JavaScript manifest (e.g. `application.js`): 26 | 27 | //= require google-instant-hangouts 28 | 29 | 30 | In your `*.html.erb` or `*.html.haml` you can use this helper 31 | 32 | <%= instant_hangout %> 33 | 34 | ### Options : 35 | 36 | #### Topic 37 | > Pre-populates the topic field for Hangouts on Air. Note that users can change the topic of the Hangout after they have joined. 38 | 39 | Add `topic: 'My Hangout'` as a option to the helper method 40 | 41 | <%= instant_hangout topic: 'My Hangout' %> 42 | 43 | #### Hangout Type 44 | > Specifies what type of Hangout should be started. The following values are supported: 45 | 46 | | Type | Function | 47 | | ------------|:----------------| 48 | | `:normal` | (Default) Launch the Hangout app without broadcasting to YouTube or starting a Hangout party. | 49 | | `:onair` | Launch the Hangout to be broadcast on YouTube as a Hangout On Air. | 50 | | `:party` | Launch the Hangout app as a Hangout party. | 51 | | `:moderated` | Launch the Hangout app with Control Room enabled. | 52 | 53 | Add `hangout_type: :type` as a option to the helper method 54 | 55 | <%= instant_hangout hangout_type: 'onair' %> 56 | 57 | 58 | #### Widget Size 59 | > Specifies the width of the button. The default value is 136. 60 | 61 | Add `widget_size: 200` as a option to the helper method 62 | 63 | <%= instant_hangout widget_size: 200 %> 64 | 65 | 66 | #### Language 67 | 68 | Add `lang: :en` as a option to the helper method 69 | 70 | <%= instant_hangout lang: :en %> 71 | 72 | 73 | | Type | Function | 74 | | ------------|:----------------| 75 | | Afrikaans | af | 76 | | Amharic | am | 77 | | Arabic | ar | 78 | | Basque | eu | 79 | | Bengali | bn | 80 | | Bulgarian | bg | 81 | | Catalan | ca | 82 | | Chinese (Hong Kong) | zh-HK | 83 | | Chinese (Simplified) | zh-CN | 84 | | Chinese (Traditional) | zh-TW | 85 | | Croatian | hr | 86 | | Czech | cs | 87 | | Danish | da | 88 | | Dutch | nl | 89 | | English (UK) | en-GB | 90 | | English (US) | en-US | 91 | | Estonian | et | 92 | | Filipino | fil | 93 | | Finnish | fi | 94 | | French | fr | 95 | | French (Canadian) | fr-CA | 96 | | Galician | gl | 97 | | German | de | 98 | | Greek | el | 99 | | Gujarati | gu | 100 | | Hebrew | iw | 101 | | Hindi | hi | 102 | | Hungarian | hu | 103 | | Icelandic | is | 104 | | Indonesian | id | 105 | | Italian | it | 106 | | Japanese | ja | 107 | | Kannada | kn | 108 | | Korean | ko | 109 | | Latvian | lv | 110 | | Lithuanian | lt | 111 | | Malay | ms | 112 | | Malayalam | ml | 113 | | Marathi | mr | 114 | | Norwegian | no | 115 | | Persian | fa | 116 | | Polish | pl | 117 | | Portuguese (Brazil) | pt-BR | 118 | | Portuguese (Portugal) | pt-PT | 119 | | Romanian | ro | 120 | | Russian | ru | 121 | | Serbian | sr | 122 | | Slovak | sk | 123 | | Slovenian | sl | 124 | | Spanish | es | 125 | | Spanish (Latin America) | es-419 | 126 | | Swahili | sw | 127 | | Swedish | sv | 128 | | Tamil | ta | 129 | | Telugu | te | 130 | | Thai | th | 131 | | Turkish | tr | 132 | | Ukrainian | uk | 133 | | Urdu | ur | 134 | | Vietnamese | vi | 135 | | Zulu | zu | 136 | 137 | 138 | 139 | 140 | **Note:** Work In Progress 141 | -------------------------------------------------------------------------------- /app/assets/javascripts/google-instant-hangouts.js: -------------------------------------------------------------------------------- 1 | (function () { 2 | 3 | // Copyright 2014 Google Inc. All Rights Reserved. 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS-IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | /** 18 | * Instantly create a Google+ Hangout on any web page. 19 | * 20 | * This is just an easy-to-use adapter for the Google+ Hangout Button. See 21 | * https://developers.google.com/+/hangouts/button. 22 | * 23 | * We handle details like inserting the script in async mode snd consolidating 24 | * all arguments onto one HTML element (in the default API they are scattered 25 | * across the render HTML element, the script element, a window global, and the 26 | * JS API). 27 | * 28 | * We do not support the full Hangouts Button API. In particular, we do not 29 | * support the initial_apps parameter. This means Instant Hangouts cannot be 30 | * used as an entry point if you want to run your own application inside a 31 | * Hangout. 32 | * 33 | * We support two modes. 34 | * 35 | * The first is widget mode. This mode is the default, and is selected when 36 | * the value for render is 'hangout'. This mode is not documented in the public 37 | * API. It creates a largish widget on the page that gives the user a control 38 | * for creating and joining a Hangout. It also provides a counter of the number 39 | * of participants currently in the Hangout. 40 | * 41 | * This mode supports rooms. A room is a distinct (publisher_id, room_id, topic) 42 | * 3-tuple. By default we supply the Instant Hangouts publisher_id, set the 43 | * room_id based on the host page URL, and the topic to 'Instant Hangout'. This 44 | * means that with zero configuration the room will be unique to the page the 45 | * user is on, so any user on that page will join the same Hangout. In this 46 | * mode, the only supported hangout type is 'normal', meaning a Hangout limited 47 | * to 10 concurrent participants. Width of the widget is set by the 'width' 48 | * attribute. 49 | * 50 | * Sample HTML for widget mode: 51 | * 52 | * 53 | *
54 | * 55 | * The second supported mode is button. In this mode there is no room support, 56 | * and every user clicking on the control starts a new Hangout. This mode 57 | * supports all Hangout types, like Hangouts on Air. Width is set by the 58 | * 'widget_size' attribute. 59 | * 60 | * Sample HTML for button mode: 61 | * 62 | * 63 | *
64 | * 65 | * Note the render attribute: this is how all variables are passed. 66 | * 67 | * In both cases, users may specify multiple
68 | * elements, and we will render a separate hangout control into each one. These 69 | * may be configured separately, except that the 'lang' and 'parsetags' options, 70 | * which apply globally, are only honored on the first 71 | *
found in the page. 72 | */ 73 | 74 | // Default type. See choices at 75 | // https://developers.google.com/+/hangouts/button#hangout_button_parameters 76 | // All modes are supported if render is 'createhangout', but only normal is 77 | // supported if render is 'hangout'. This is not enforced by the API and invalid 78 | // values are silently ignored. 79 | var DEFAULT_HANGOUT_TYPE = 'normal'; 80 | // Default widget language code. 81 | var DEFAULT_LANG = 'en'; 82 | // Default value for window.___gcfg.parsetags. explicit because we call render 83 | // ourselves and want to avoid time wasted by DOM traversal. 84 | var DEFAULT_PARSETAGS = 'explicit'; 85 | // Default publisher_id. We use the id for the Instant Hangouts Plus Page at 86 | // https://plus.google.com/b/112744459749475398119. Users may specify their own 87 | // id if they like, but this is not practically necessary since room uniqueness 88 | // is enforced by having the room_id contain the containing page's URL. 89 | var DEFAULT_PUBLISHER_ID = '112744459749475398119'; 90 | // Default render mode. Requires publisher_id, room_id, and topic. Choices are 91 | // 'hangout' for widget that supports rooms and 'createhangout' for plain 92 | // button with no room support. 93 | var DEFAULT_RENDER = 'hangout'; 94 | // Default topic, displayed in the Hangout and in the widget (but not button). 95 | var DEFAULT_TOPIC = 'Instant Hangout'; 96 | // Default width in pixels if render is 'createhangout'. Ignored if render is 97 | // 'hangout.' 98 | var DEFAULT_WIDGET_SIZE = '136'; 99 | // Default width in pixels if render is 'hangout'. 100 | var DEFAULT_WIDTH = '300'; 101 | // URL of the script that provides gapi.hangout. 102 | var GAPI_URL = 'https://apis.google.com/js/plusone.js'; 103 | // Class of the DOM element that both configures and receives the Hangouts 104 | // render. 105 | var PARENT_CLASS_NAME = 'instanthangouts'; 106 | // Valid values for render option to gapi.hangout.render. 107 | var RENDER_CHOICES = ['createhangout', 'hangout']; 108 | 109 | function addOnLoadHook(handler) { 110 | // Cross-browser shim. 111 | if (window.addEventListener) { 112 | window.addEventListener('load', handler, false); 113 | } else if (window.attachEvent) { 114 | window.attachEvent('onload', handler); 115 | } 116 | } 117 | 118 | function configureGlobals(attrs) { 119 | // When loading gapi asychronously, these two vars must be set through the 120 | // global config, not through the script tag. They are documented at 121 | // https://developers.google.com/+/hangouts/button#script_tag_parameters. 122 | // We set these globals unconditionally, so we will overwrite any values set 123 | // by the host page before our script is loaded. 124 | window.___gcfg = { 125 | // Widget language. Choices: 126 | // https://developers.google.com/+/web/api/supported-languages 127 | lang: attrs.lang, 128 | // Loading mechanism. 129 | parsetags: attrs.parsetags 130 | }; 131 | } 132 | 133 | function filter(elements, predicateFn) { 134 | // Returns all elements that match a predicateFn that takes a single element 135 | // as its argument. 136 | var matches = []; 137 | 138 | for (var i = 0; i < elements.length; i++) { 139 | var element = elements[i]; 140 | 141 | if (predicateFn(element)) { 142 | matches.push(element); 143 | } 144 | } 145 | 146 | return matches; 147 | } 148 | 149 | function getGapiScripts() { 150 | // The host page may have any number of