muck-invites 3.1.1 → 3.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -23,8 +23,12 @@ You can include muck-invites.css or copy and paste the styles and change them as
23
23
  <%= stylesheet_link_tag 'muck-invites' -%>
24
24
 
25
25
  Include a link to initialize the invite process. You might want to do this in a lightbox.
26
+
27
+ The simple version that simply asks for an email and password:
26
28
  <%= link_to 'Invite Your Friends', new_invite_path, :class => 'invite_box' %>
27
29
 
30
+ The better method that uses oauth to talk to email services instead of asking for a password:
31
+ <%= link_to 'Invite Friends', compose_invites_path, :class => 'invite_box' %>
28
32
 
29
33
  === Oauth
30
34
  The invite system can use oauth where available to acquire contacts. To enable this functionality install the
data/Rakefile CHANGED
@@ -52,16 +52,15 @@ begin
52
52
  gem.description = "The invite engine for the muck system."
53
53
  gem.authors = ["Justin Ball, Joel Duffin"]
54
54
 
55
- gem.add_dependency "contacts"
55
+ gem.add_dependency "contacts", ">=1.2.4"
56
+ gem.add_dependency "muck-portablecontacts"
56
57
  gem.add_dependency "hpricot"
57
58
  gem.add_dependency "muck-engine"
59
+ gem.add_dependency "muck-auth", ">=3.5.1"
58
60
  gem.files.exclude 'test/**'
59
61
  gem.test_files.exclude 'test/**'
60
62
  end
61
63
  Jeweler::GemcutterTasks.new
62
- Jeweler::RubyforgeTasks.new do |rubyforge|
63
- rubyforge.doc_task = "rdoc"
64
- end
65
64
  rescue LoadError
66
65
  puts "Jeweler not available. Install it with: sudo gem install jeweler"
67
66
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.1.1
1
+ 3.3.0
@@ -22,5 +22,40 @@ module MuckInvitesHelper
22
22
  def contact_container(contacts)
23
23
  render :partial => 'invites/contact_container', :locals => { :contacts => contacts }
24
24
  end
25
+
26
+ def google_oauth_for(user)
27
+ user.authentications.find_by_provider('google')
28
+ end
29
+
30
+ # Generates a javascript array of emails from gmail. Values will be
31
+ # put into a variable named 'gmail_contacts'
32
+ def gmail_contacts_for_auto_complete(user, ignore_cache = false)
33
+ return unless google_oauth_for(user)
34
+ contacts = gmail_contacts(user, ignore_cache).collect{|contact| "'#{contact[:email]} (#{contact[:name]})'" }
35
+ "var gmail_contacts = [#{contacts.join(',')}];"
36
+ end
37
+
38
+ def gmail_contacts(user, ignore_cache = false)
39
+ if @user_gmail_contacts && @user_gmail_contacts[user] && !ignore_cache
40
+ @user_gmail_contacts[user]
41
+ else
42
+ google = google_oauth_for(user)
43
+ if google
44
+ @user_gmail_contacts ||= {}
45
+ result = google.access_token.get('https://www.google.com/m8/feeds/contacts/default/full?max-results=10000')
46
+ contacts = []
47
+ if result.code == '200'
48
+ xml_doc = Nokogiri::XML(result.body) {|config| config.options = Nokogiri::XML::ParseOptions::STRICT }
49
+ contacts = xml_doc.xpath('//xmlns:entry').map do |entry|
50
+ {
51
+ :name => entry.xpath('xmlns:title').inner_html,
52
+ :email => entry.xpath('gd:email').attr('address').value
53
+ }
54
+ end
55
+ end
56
+ @user_gmail_contacts[user] = contacts
57
+ end
58
+ end
59
+ end
25
60
 
26
61
  end
@@ -2,8 +2,8 @@
2
2
  <% contacts.each_with_index do |contact,i| %>
3
3
  <tr class="contact <%= i%2==0 ? 'even' : 'odd' %>">
4
4
  <td class="cb"><input type="checkbox" value="<%= h(contact[1]) %>" name="emails[]"></td>
5
- <td class="name"><%= contact[0] %></td>
6
- <td class="email"><%= contact[1] %></td>
5
+ <td class="name"><%= contact[:name] %></td>
6
+ <td class="email"><%= contact[:email] %></td>
7
7
  </tr>
8
8
  <% end %>
9
9
  </table>
@@ -2,10 +2,10 @@
2
2
  <table class="contacts-list">
3
3
  <% contacts.each_with_index do |contact,i| %>
4
4
  <tr class="contact <%= i%2==0 ? 'even' : 'odd' %>">
5
- <td class="cb"><input type="checkbox" value="<%= h(contact[1]) %>" name="emails[]"></td>
6
- <td class="icon"><%= image_tag(gravatar(contact[1], default_image, 20), :class => 'contact-list-image', :alt => contact[0]) %></td>
7
- <td class="name"><%= contact[0] %></td>
8
- <td class="email"><%= contact[1] %></td>
5
+ <td class="cb"><input type="checkbox" value="<%= contact[:email] %>" name="emails[]"></td>
6
+ <td class="icon"><%= image_tag(gravatar(contact[:email], default_image, 20), :class => 'contact-list-image', :alt => contact[:email]) %></td>
7
+ <td class="name"><%= contact[:name] %></td>
8
+ <td class="email"><%= contact[:email] %></td>
9
9
  </tr>
10
10
  <% end %>
11
11
  </table>
@@ -1,10 +1,10 @@
1
1
  <% return unless logged_in? -%>
2
2
  <div id="gmail" class="invite-query">
3
- <% if !current_user.google -%>
4
- <p><a href="/oauth_consumers/google">Click to connect to your Gmail</a></p>
5
- <% else -%>
3
+ <% if google_oauth_for(current_user) -%>
6
4
  <div class="contact-list">
7
- <%= contact_container(gmail_contacts_as_array(current_user)) %>
8
- </div>
5
+ <%= contact_container(gmail_contacts(current_user)) %>
6
+ </div>
7
+ <% else -%>
8
+ <p><a href="/auth/google">Connect to Gmail</a></p>
9
9
  <% end -%>
10
10
  </div>
@@ -21,11 +21,11 @@
21
21
  <div class="form-row">
22
22
  <label class="invite-email" for="emails">Emails</label>
23
23
  <p class="invite-email">Enter emails of friends to invite or select them above:</p>
24
- <%= text_area_tag :emails, params[:emails] %>
24
+ <%= text_area_tag :emails, emails || params[:emails] %>
25
25
  </div>
26
26
  <div class="form-row">
27
27
  <label class="invite-message" for="message">Message</label>
28
- <%= text_area_tag :message, params[:message] %>
28
+ <%= text_area_tag :message, message || params[:message] %>
29
29
  </div>
30
30
  <div class="form-row">
31
31
  <%= f.submit t('muck.invites.invite_button'), :class => "button invite-submit" %>
@@ -49,7 +49,7 @@ jQuery(document).ready(function() {
49
49
 
50
50
  apply_ajax_forms();
51
51
 
52
- <% if current_user.google -%>
52
+ <% if google_oauth_for(current_user) -%>
53
53
  <%= gmail_contacts_for_auto_complete(current_user) %>
54
54
  jQuery("#emails").autocomplete(gmail_contacts, {
55
55
  minChars: 1,
@@ -1 +1 @@
1
- <%= render :partial => 'invites/invite_compose' %>
1
+ <%= render :partial => 'invites/invite_compose', :locals => { :message => nil, :emails => nil } %>
data/lib/muck-invites.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'contacts'
2
+ require 'portable_contacts'
2
3
 
3
4
  require 'muck-invites/config'
4
5
  require 'muck-invites/exceptions'
data/muck-invites.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{muck-invites}
8
- s.version = "3.1.1"
8
+ s.version = "3.3.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Justin Ball, Joel Duffin"]
12
- s.date = %q{2011-03-19}
12
+ s.date = %q{2011-04-25}
13
13
  s.description = %q{The invite engine for the muck system.}
14
14
  s.email = %q{justin@tatemae.com}
15
15
  s.extra_rdoc_files = [
@@ -108,18 +108,24 @@ Gem::Specification.new do |s|
108
108
  s.specification_version = 3
109
109
 
110
110
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
111
- s.add_runtime_dependency(%q<contacts>, [">= 0"])
111
+ s.add_runtime_dependency(%q<contacts>, [">= 1.2.4"])
112
+ s.add_runtime_dependency(%q<muck-portablecontacts>, [">= 0"])
112
113
  s.add_runtime_dependency(%q<hpricot>, [">= 0"])
113
114
  s.add_runtime_dependency(%q<muck-engine>, [">= 0"])
115
+ s.add_runtime_dependency(%q<muck-auth>, [">= 3.5.1"])
114
116
  else
115
- s.add_dependency(%q<contacts>, [">= 0"])
117
+ s.add_dependency(%q<contacts>, [">= 1.2.4"])
118
+ s.add_dependency(%q<muck-portablecontacts>, [">= 0"])
116
119
  s.add_dependency(%q<hpricot>, [">= 0"])
117
120
  s.add_dependency(%q<muck-engine>, [">= 0"])
121
+ s.add_dependency(%q<muck-auth>, [">= 3.5.1"])
118
122
  end
119
123
  else
120
- s.add_dependency(%q<contacts>, [">= 0"])
124
+ s.add_dependency(%q<contacts>, [">= 1.2.4"])
125
+ s.add_dependency(%q<muck-portablecontacts>, [">= 0"])
121
126
  s.add_dependency(%q<hpricot>, [">= 0"])
122
127
  s.add_dependency(%q<muck-engine>, [">= 0"])
128
+ s.add_dependency(%q<muck-auth>, [">= 3.5.1"])
123
129
  end
124
130
  end
125
131
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: muck-invites
3
3
  version: !ruby/object:Gem::Version
4
- hash: 1
4
+ hash: 11
5
5
  prerelease:
6
6
  segments:
7
7
  - 3
8
- - 1
9
- - 1
10
- version: 3.1.1
8
+ - 3
9
+ - 0
10
+ version: 3.3.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Justin Ball, Joel Duffin
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-03-19 00:00:00 -06:00
18
+ date: 2011-04-25 00:00:00 -06:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -26,14 +26,16 @@ dependencies:
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- hash: 3
29
+ hash: 23
30
30
  segments:
31
- - 0
32
- version: "0"
31
+ - 1
32
+ - 2
33
+ - 4
34
+ version: 1.2.4
33
35
  type: :runtime
34
36
  version_requirements: *id001
35
37
  - !ruby/object:Gem::Dependency
36
- name: hpricot
38
+ name: muck-portablecontacts
37
39
  prerelease: false
38
40
  requirement: &id002 !ruby/object:Gem::Requirement
39
41
  none: false
@@ -47,7 +49,7 @@ dependencies:
47
49
  type: :runtime
48
50
  version_requirements: *id002
49
51
  - !ruby/object:Gem::Dependency
50
- name: muck-engine
52
+ name: hpricot
51
53
  prerelease: false
52
54
  requirement: &id003 !ruby/object:Gem::Requirement
53
55
  none: false
@@ -60,6 +62,36 @@ dependencies:
60
62
  version: "0"
61
63
  type: :runtime
62
64
  version_requirements: *id003
65
+ - !ruby/object:Gem::Dependency
66
+ name: muck-engine
67
+ prerelease: false
68
+ requirement: &id004 !ruby/object:Gem::Requirement
69
+ none: false
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ hash: 3
74
+ segments:
75
+ - 0
76
+ version: "0"
77
+ type: :runtime
78
+ version_requirements: *id004
79
+ - !ruby/object:Gem::Dependency
80
+ name: muck-auth
81
+ prerelease: false
82
+ requirement: &id005 !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ hash: 17
88
+ segments:
89
+ - 3
90
+ - 5
91
+ - 1
92
+ version: 3.5.1
93
+ type: :runtime
94
+ version_requirements: *id005
63
95
  description: The invite engine for the muck system.
64
96
  email: justin@tatemae.com
65
97
  executables: []