caboose-cms 0.5.198 → 0.5.199

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OGZkM2MyZWI1ZWFjOTAwN2I5NGY0OGMxNzcyN2U2MTU1Mzg0OGQ1Ng==
4
+ NzQ3ZmY5MGQxOTFkZmNjNzE1YTJiMmMwZTllMTU2MDM2NjFhMTlkOQ==
5
5
  data.tar.gz: !binary |-
6
- OGRmZjI2NzRhYTRkZDIxZGFlNGY1ZjQ3MGZiYWQ3OGUxYzFmZDRhZQ==
6
+ OGE1ZmZlMWNhMmZmNmE1NjE0YTE2NWJmODE2NTY4NDkwMWQ4Y2NkMA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZWExZjliZDA4MWMwMGVkODY0ZTQ5OGMwMWM0NGJiZmIzOTI3ZjFlNzM1ZTNj
10
- NDFiNzU0OGI0NmE1MzhlOWQwYzhhOTY0NGY0Mzc1NTZjYjNjMzZlZmQwMTdk
11
- NTUxY2RjNWNmOGMxM2UyY2ZjNGVmYzQ2YzE1MmFjOTY3MjIwZTQ=
9
+ OWUxNTY3MDU3YjgyYmQwMGMyNDJjZWExNDhkOTVlMGQ5N2FmYzU1OWNiZmNk
10
+ ZmE3MGI5NjM4OWQ2Yzc3YmNlZjY2NjllMWFmMDE5NDlkZjhmZTRiMTg4OTAw
11
+ OGJiYzI3MGU2OTE2YWFlMmM1NTNjMzViMGMwNTlkNmJjZDBhMjI=
12
12
  data.tar.gz: !binary |-
13
- YThmMzA0OGY0MThjNmM1YWM1NjM2MzQ5MGJkZGFjOWZkZTYzYzdiMThmNGVh
14
- OWY1ZjQwZDllNGYzNjQ1MzZmZGNjZGZiZjg1OWQ5MGZjYWY5OWVlNTdjODY1
15
- ZWFiOGJhOWNmMjBkYjFlNTc3ZmE2YWI0OTg2NmMwZGI0NjM2M2Q=
13
+ YTdkMWJmMDYzMDMxMDhjOTUyZjQzNjVmMzQzNDc3ZjEwYWZjMmNmNmFmYmE0
14
+ Y2Y2ODMxNzNkYzViNGYzM2VlYTJiMDZiNjk3ZGVjM2RkNzMxMDZhMDY1ZWFl
15
+ N2ExZDZhOGU2MDNjOGNiNjQ5OTM5ZTc2Mzc3ZWUwNzcxOWQyMGM=
@@ -1,3 +1,6 @@
1
+ require 'cgi'
2
+ require 'open-uri'
3
+ require 'httparty'
1
4
 
2
5
  module Caboose
3
6
  class RetargetingController < ApplicationController
@@ -38,6 +41,65 @@ module Caboose
38
41
  render :json => resp
39
42
  end
40
43
 
44
+ ## GET /admin/sites/:id/retargeting/fb-auth
45
+ #def admin_fb_auth
46
+ # if params[:code]
47
+ # domain = "#{request.protocol}#{request.host}"
48
+ # domain << ":#{request.port}" if request.port != 80
49
+ # h = {
50
+ # :client_id => "664751370321086",
51
+ # :redirect_uri => "#{domain}/admin/sites/#{params[:site_id]}/retargeting/fb-auth/",
52
+ # :client_secret => "7724cd8006af75d5ab89aa1157057e71",
53
+ # :code => params[:code]
54
+ # }
55
+ # h = h.collect{ |k,v| "#{k}=#{URI::encode(v)}" }.join('&')
56
+ # resp = HTTParty.get("https://graph.facebook.com/oauth/access_token?#{h}")
57
+ # h = CGI::parse(resp.body)
58
+ #
59
+ # site = Site.find(params[:site_id])
60
+ # rc = site.retargeting_config
61
+ # rc.fb_access_token = h['access_token'].first
62
+ # rc.fb_access_token_expires = DateTime.now.utc + h['expires'].first.to_i.seconds
63
+ # rc.save
64
+ # redirect_to "/admin/sites/#{site.id}/retargeting"
65
+ #
66
+ # else
67
+ # domain = "#{request.protocol}#{request.host}"
68
+ # domain << ":#{request.port}" if request.port != 80
69
+ # h = {
70
+ # :client_id => "664751370321086",
71
+ # :redirect_uri => "#{domain}/admin/sites/#{params[:site_id]}/retargeting/fb-auth/",
72
+ # :scope => "ads_management"
73
+ # }
74
+ # h = h.collect{ |k,v| "#{k}=#{URI::encode(v)}" }.join('&')
75
+ # redirect_to "https://www.facebook.com/dialog/oauth?#{h}"
76
+ # end
77
+ #end
78
+ #
79
+ ## GET /admin/sites/:site_id/retargeting/fb-audiences
80
+ #def admin_fb_audiences
81
+ # site = Site.find(params[:site_id])
82
+ # rc = site.retargeting_config
83
+ #
84
+ # resp = HTTParty.get("https://graph.facebook.com/v2.3/act_279723427/customaudiences", :query => {
85
+ # :access_token => rc.fb_access_token,
86
+ # :fields => "id,name,subtype,approximate_count"
87
+ # })
88
+ # render :json => resp.body
89
+ #end
90
+ #
91
+ ## GET /admin/sites/:site_id/retargeting/fb-audiences/:custom_audience_id
92
+ #def admin_fb_audience_members
93
+ # site = Site.find(params[:site_id])
94
+ # rc = site.retargeting_config
95
+ #
96
+ # resp = HTTParty.get("https://graph.facebook.com/v2.3/#{params[:custom_audience_id]}", :query => {
97
+ # :access_token => rc.fb_access_token,
98
+ # :fields => "id,name,subtype,approximate_count"
99
+ # })
100
+ # render :json => resp.body
101
+ #end
102
+
41
103
  end
42
104
  end
43
105
 
@@ -9,6 +9,8 @@ module Caboose
9
9
  :google_labels_function,
10
10
  :fb_pixel_id,
11
11
  :fb_vars_function
12
+ #:fb_access_token,
13
+ #:fb_access_token_expires
12
14
 
13
15
  def google_labels(request, page)
14
16
  return [] if self.google_labels_function.nil? || self.google_labels_function.strip.length == 0
@@ -20,7 +22,7 @@ module Caboose
20
22
  end
21
23
 
22
24
  def fb_vars(request, page)
23
- return nil if self.fb_vars_function.nil? || self.fb_vars_function.strip.length == 0
25
+ return [] if self.fb_vars_function.nil? || self.fb_vars_function.strip.length == 0
24
26
  arr = eval(self.fb_vars_function)
25
27
  return [] if arr.nil?
26
28
  return [arr] if arr is_a? String
@@ -508,11 +508,13 @@ class Caboose::Schema < Caboose::Utilities::Schema
508
508
  [ :variant_id , :integer ]
509
509
  ],
510
510
  Caboose::RetargetingConfig => [
511
- [ :site_id , :integer ],
512
- [ :google_conversion_id , :string ],
513
- [ :google_labels_function , :text ],
514
- [ :fb_pixel_id , :string ],
515
- [ :fb_vars_function , :text ]
511
+ [ :site_id , :integer ],
512
+ [ :google_conversion_id , :string ],
513
+ [ :google_labels_function , :text ],
514
+ [ :fb_pixel_id , :string ],
515
+ [ :fb_vars_function , :text ]
516
+ #[ :fb_access_token , :string ],
517
+ #[ :fb_access_token_expires , :datetime ]
516
518
  ],
517
519
  Caboose::Review => [
518
520
  [ :product_id , :integer ],
@@ -31,18 +31,20 @@
31
31
  s.parentNode.insertBefore(fbds, s);
32
32
  _fbq.loaded = true;
33
33
  }
34
- _fbq.push(['addPixelId', '<%= raw rc.fb_pixel_id %>']);
34
+ _fbq.push(['addPixelId', '<%= raw rc.fb_pixel_id %>']);
35
35
  })();
36
- window._fbq = window._fbq || [];
37
- <% vars = rc.fb_vars(request, page) %>
38
- window._fbq.push(['track', 'PixelInitialized', <%= raw Caboose.json(vars) %>]);
36
+ window._fbq = window._fbq || [];
37
+ window._fbq.push(['track', 'PixelInitialized', {}]);
38
+ <% vars = rc.fb_vars(request, page) %>
39
+ <% vars.each do |v| %>
40
+ window._fbq.push(['track', <%= raw Caboose.json(v) %>]);
41
+ <% end %>
39
42
  </script>
40
- <noscript>
41
- <%
42
- cd = vars.collect{ |k,v| "cd[#{k}]=#{v}" }.join('&amp;')
43
- cd = "&amp;#{cd}" if vars.count > 0
44
- %>
45
- <img height="1" width="1" border="0" alt="" style="display:none" src="https://www.facebook.com/tr?id=<%= raw rc.fb_pixel_id %>&amp;ev=PixelInitialized<%= raw cd %>" />
43
+ <noscript>
44
+ <img height="1" width="1" border="0" alt="" style="display:none" src="https://www.facebook.com/tr?id=<%= raw rc.fb_pixel_id %>&amp;ev=PixelInitialized" />
45
+ <% vars.each do |v| %>
46
+ <img height="1" width="1" border="0" alt="" style="display:none" src="https://www.facebook.com/tr?id=<%= raw rc.fb_pixel_id %>&amp;ev=<%= raw v %>" />
47
+ <% end %>
46
48
  </noscript>
47
49
  <% end %>
48
50
  <% end %>
@@ -23,9 +23,11 @@ rc = s.retargeting_config
23
23
  <p><code>def facebook_custom_data_function(request, page) {</code></p>
24
24
  <p><div id='retargetingconfig_<%= rc.id %>_fb_vars_function' ></div></p>
25
25
  <p><code>
26
- &nbsp;&nbsp;# This function returns an array of key/value strings.<br />
27
- &nbsp;&nbsp;# Example:<br />
28
- &nbsp;&nbsp;# return { 'segment' => 'General' }<br />
26
+ &nbsp;&nbsp;# This function returns an event name string or an array of event names.<br />
27
+ &nbsp;&nbsp;# Example 1:<br />
28
+ &nbsp;&nbsp;# return "abc123"<br />
29
+ &nbsp;&nbsp;# Example 2: <br />
30
+ &nbsp;&nbsp;# return ["abc123", "xyz456"]<br />
29
31
  }</code></p>
30
32
 
31
33
  <%= render :partial => 'caboose/sites/admin_footer' %>
@@ -52,7 +52,11 @@ Caboose::Engine.routes.draw do
52
52
  #=============================================================================
53
53
  # Retargeting
54
54
  #=============================================================================
55
-
55
+
56
+ #get "admin/sites/:site_id/retargeting/fb-auth" => "retargeting#admin_fb_auth"
57
+ #get "admin/sites/:site_id/retargeting/fb-audiences" => "retargeting#admin_fb_audiences"
58
+ #get "admin/sites/:site_id/retargeting/fb-audiences/:custom_audience_id" => "retargeting#admin_fb_audience_members"
59
+
56
60
  get "admin/sites/:site_id/retargeting" => "retargeting#admin_edit"
57
61
  put "admin/sites/:site_id/retargeting" => "retargeting#admin_update"
58
62
 
@@ -1,3 +1,3 @@
1
1
  module Caboose
2
- VERSION = '0.5.198'
2
+ VERSION = '0.5.199'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: caboose-cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.198
4
+ version: 0.5.199
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Barry
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-13 00:00:00.000000000 Z
11
+ date: 2015-04-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pg