sharkapps 0.1.2 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -0
- data/Gemfile.lock +65 -0
- data/Rakefile +1 -0
- data/VERSION +1 -1
- data/app/controllers/appforma_controller.rb +28 -0
- data/app/views/appforma/_footer.html.erb +30 -0
- data/app/views/appforma/_header.html.erb +34 -0
- data/app/views/appforma/_notifications.html.erb +8 -0
- data/app/views/appforma/intro.html.erb +7 -0
- data/app/views/appforma/not_authorized.html.erb +8 -0
- data/app/views/appforma/not_subscribed.html.erb +17 -0
- data/config/locales/appforma.en.yml +7 -0
- data/config/locales/appforma.il.yml +7 -0
- data/config/routes.rb +6 -0
- data/init.rb +0 -0
- data/lib/sharkapps/account.rb +29 -0
- data/lib/sharkapps/appforma.rb +4 -0
- data/lib/sharkapps/appforma_notification.rb +0 -0
- data/lib/sharkapps/controllers/sharkapps_controller.rb +22 -0
- data/lib/sharkapps/data_helpers.rb +43 -0
- data/lib/sharkapps/subscription.rb +34 -4
- data/lib/sharkapps/view_helpers.rb +9 -0
- data/lib/sharkapps.rb +38 -12
- data/sharkapps.gemspec +21 -2
- metadata +60 -20
data/Gemfile
CHANGED
@@ -6,6 +6,7 @@ source "http://rubygems.org"
|
|
6
6
|
# Add dependencies to develop your gem here.
|
7
7
|
# Include everything needed to run rake, tests, features, etc.
|
8
8
|
group :development do
|
9
|
+
gem "rails", ">=3.0.9"
|
9
10
|
gem "shoulda", ">= 0"
|
10
11
|
gem "bundler", "~> 1.0.0"
|
11
12
|
gem "jeweler", "~> 1.5.2"
|
data/Gemfile.lock
CHANGED
@@ -1,14 +1,78 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
+
abstract (1.0.0)
|
5
|
+
actionmailer (3.0.9)
|
6
|
+
actionpack (= 3.0.9)
|
7
|
+
mail (~> 2.2.19)
|
8
|
+
actionpack (3.0.9)
|
9
|
+
activemodel (= 3.0.9)
|
10
|
+
activesupport (= 3.0.9)
|
11
|
+
builder (~> 2.1.2)
|
12
|
+
erubis (~> 2.6.6)
|
13
|
+
i18n (~> 0.5.0)
|
14
|
+
rack (~> 1.2.1)
|
15
|
+
rack-mount (~> 0.6.14)
|
16
|
+
rack-test (~> 0.5.7)
|
17
|
+
tzinfo (~> 0.3.23)
|
18
|
+
activemodel (3.0.9)
|
19
|
+
activesupport (= 3.0.9)
|
20
|
+
builder (~> 2.1.2)
|
21
|
+
i18n (~> 0.5.0)
|
22
|
+
activerecord (3.0.9)
|
23
|
+
activemodel (= 3.0.9)
|
24
|
+
activesupport (= 3.0.9)
|
25
|
+
arel (~> 2.0.10)
|
26
|
+
tzinfo (~> 0.3.23)
|
27
|
+
activeresource (3.0.9)
|
28
|
+
activemodel (= 3.0.9)
|
29
|
+
activesupport (= 3.0.9)
|
30
|
+
activesupport (3.0.9)
|
31
|
+
arel (2.0.10)
|
32
|
+
builder (2.1.2)
|
33
|
+
erubis (2.6.6)
|
34
|
+
abstract (>= 1.0.0)
|
4
35
|
git (1.2.5)
|
36
|
+
i18n (0.5.0)
|
5
37
|
jeweler (1.5.2)
|
6
38
|
bundler (~> 1.0.0)
|
7
39
|
git (>= 1.2.5)
|
8
40
|
rake
|
41
|
+
mail (2.2.19)
|
42
|
+
activesupport (>= 2.3.6)
|
43
|
+
i18n (>= 0.4.0)
|
44
|
+
mime-types (~> 1.16)
|
45
|
+
treetop (~> 1.4.8)
|
46
|
+
mime-types (1.16)
|
47
|
+
polyglot (0.3.2)
|
48
|
+
rack (1.2.3)
|
49
|
+
rack-mount (0.6.14)
|
50
|
+
rack (>= 1.0.0)
|
51
|
+
rack-test (0.5.7)
|
52
|
+
rack (>= 1.0)
|
53
|
+
rails (3.0.9)
|
54
|
+
actionmailer (= 3.0.9)
|
55
|
+
actionpack (= 3.0.9)
|
56
|
+
activerecord (= 3.0.9)
|
57
|
+
activeresource (= 3.0.9)
|
58
|
+
activesupport (= 3.0.9)
|
59
|
+
bundler (~> 1.0)
|
60
|
+
railties (= 3.0.9)
|
61
|
+
railties (3.0.9)
|
62
|
+
actionpack (= 3.0.9)
|
63
|
+
activesupport (= 3.0.9)
|
64
|
+
rake (>= 0.8.7)
|
65
|
+
rdoc (~> 3.4)
|
66
|
+
thor (~> 0.14.4)
|
9
67
|
rake (0.8.7)
|
10
68
|
rcov (0.9.9)
|
69
|
+
rdoc (3.9.1)
|
11
70
|
shoulda (2.11.3)
|
71
|
+
thor (0.14.6)
|
72
|
+
treetop (1.4.10)
|
73
|
+
polyglot
|
74
|
+
polyglot (>= 0.3.1)
|
75
|
+
tzinfo (0.3.29)
|
12
76
|
|
13
77
|
PLATFORMS
|
14
78
|
ruby
|
@@ -16,5 +80,6 @@ PLATFORMS
|
|
16
80
|
DEPENDENCIES
|
17
81
|
bundler (~> 1.0.0)
|
18
82
|
jeweler (~> 1.5.2)
|
83
|
+
rails (>= 3.0.9)
|
19
84
|
rcov
|
20
85
|
shoulda
|
data/Rakefile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.5
|
@@ -0,0 +1,28 @@
|
|
1
|
+
class AppformaController < ApplicationController
|
2
|
+
skip_before_filter :ensure_canvas_connected_to_facebook
|
3
|
+
before_filter :set_tab_current_account, :except => [:intro, :not_authorized]
|
4
|
+
before_filter :set_edit_account, :only => [:not_authorized]
|
5
|
+
before_filter :set_locale, :except => [:intro, :not_subscribed]
|
6
|
+
skip_before_filter :check_account_authorized, :only => [:intro]
|
7
|
+
|
8
|
+
def not_subscribed
|
9
|
+
@external = true
|
10
|
+
end
|
11
|
+
|
12
|
+
def intro
|
13
|
+
render :layout => false
|
14
|
+
end
|
15
|
+
|
16
|
+
def locale_select
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
def not_authorized
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
def set_edit_account
|
26
|
+
@account = Account.find_by_acc_hash(params[:id])
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
<div id="footer">
|
2
|
+
<h6 id="footer_disclaimer"><%= t('general.diclaimer')%></h6>
|
3
|
+
<% case @account.footer_state.to_i %>
|
4
|
+
<% when Account::LOGO_REGULAR %>
|
5
|
+
<div id="appforma_solo" class="appforma_logo">
|
6
|
+
<div id="logo_solo_image">
|
7
|
+
<%= link_to image_tag("https://s3.amazonaws.com/appforma_static/logos/logo_solo.png", :border => 0), "http://www.appforma.com", {:target => "_blank"}%>
|
8
|
+
</div>
|
9
|
+
<div id="logo_dot_link">
|
10
|
+
<%= link_to t('general.logo_link'), "http://www.appforma.com/pricing?ref=#{@account.fbid}", {:target => "_blank"}%>
|
11
|
+
</div>
|
12
|
+
</div>
|
13
|
+
<% when Account::LOGO_DUAL %>
|
14
|
+
<div id="appforma_dual" class="appforma_logo"%>
|
15
|
+
<%= link_to image_tag("https://s3.amazonaws.com/appforma_static/logos/logo_poweredby.png", :border => 0), "http://www.appforma.com", {:target => "_blank"}%>
|
16
|
+
</div>
|
17
|
+
<div id="logo_brand">
|
18
|
+
<% if @account.image_logo.exists? %>
|
19
|
+
<%= link_to image_tag(@account.image_logo.url(:dual)), @account.logo_link, {:target => "_blank"}%>
|
20
|
+
<% end %>
|
21
|
+
</div>
|
22
|
+
<% when Account::LOGO_WHITE %>
|
23
|
+
<div id="logo_brand">
|
24
|
+
<% if @account.image_logo.exists? %>
|
25
|
+
<%= link_to image_tag(@account.image_logo.url(:white)), @account.logo_link, {:target => "_blank"}%>
|
26
|
+
<% end %>
|
27
|
+
</div>
|
28
|
+
<% end %>
|
29
|
+
|
30
|
+
</div>
|
@@ -0,0 +1,34 @@
|
|
1
|
+
<div id="header" >
|
2
|
+
<%= render :partial => "appforma/notifications"%>
|
3
|
+
<div style="background-image:url(/images/appicon.png); float:left; padding:10px 0 0 5px; position:relative; width:75px; height:75px; background-repeat:no-repeat;">
|
4
|
+
</div>
|
5
|
+
|
6
|
+
<div style="width:300px; font-family:Tahoma, Geneva, sans-serif; font-size:24px; position:relative; float:left; vertical-align:middle; padding-top:22px;direction:ltr;">
|
7
|
+
<span style="color:#09F">
|
8
|
+
Edit mode:
|
9
|
+
</span>
|
10
|
+
<span style="color:#000">
|
11
|
+
<%= t('general.app_name') %>
|
12
|
+
</span>
|
13
|
+
</div>
|
14
|
+
<div style="vertical-align:middle; padding-top:22px;direction:ltr;float:right;">
|
15
|
+
<% if params[:controller] == "dashboard"%>
|
16
|
+
<button id="edit"><%= t('dashboard.manage') %></button>
|
17
|
+
<% else %>
|
18
|
+
<button id="page_back"><%= t('general.back_to_page') %></button>
|
19
|
+
<% end %>
|
20
|
+
</div>
|
21
|
+
</div>
|
22
|
+
<div id="clearer"></div>
|
23
|
+
<script>
|
24
|
+
$(document).ready(function() {
|
25
|
+
$("button" ).button();
|
26
|
+
$('#page_back').click(function() {
|
27
|
+
top.location = "<%=@account.link_page(current_facebook_client) %>";
|
28
|
+
});
|
29
|
+
$('#edit').click(function() {
|
30
|
+
top.location = "<%="http://apps.facebook.com/#{SharkApps.canvas_name}/accounts/#{@account.to_param}/edit"%>";
|
31
|
+
});
|
32
|
+
});
|
33
|
+
|
34
|
+
</script>
|
@@ -0,0 +1,8 @@
|
|
1
|
+
<div id="flash" style="margin-top:10px">
|
2
|
+
<% if @account.approval_status == "trial" -%>
|
3
|
+
<div id="flash_notice">
|
4
|
+
<strong><i>Note: This message is only visible to page administrators.</i></strong><br/><br/>
|
5
|
+
You have <%= pluralize(@account.trial_remaining, 'day')%> remaining in trial mode. <%= link_to "Click here to upgrade", "http://www.appforma.com/myaccount", {:target => "blank"} %>
|
6
|
+
</div>
|
7
|
+
<% end -%>
|
8
|
+
</div>
|
@@ -0,0 +1,8 @@
|
|
1
|
+
<div id="flash" style="margin-top:10px">
|
2
|
+
<div id="flash_notice">
|
3
|
+
|
4
|
+
<%= t('appforma.errors.not_auth1')%><br/><br/>
|
5
|
+
<%= t('appforma.errors.not_auth2')%><br/><br/>
|
6
|
+
<%= t('appforma.errors.not_auth3')%> <%= link_to t('appforma.support_form'), "http://appformaapps.zendesk.com/", :target => "_blank"%><br/>
|
7
|
+
</div>
|
8
|
+
</div>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<% if is_admin %>
|
2
|
+
<div id="flash" style="margin-top:10px">
|
3
|
+
<div id="flash_notice">
|
4
|
+
<strong><i>Note: This message is only visible to page administrators.</i></strong><br/><br/>
|
5
|
+
<% if @account.approval_status == Subscription::UNAUTHORIZED%>
|
6
|
+
You have installed this application without registering it with <%= link_to "Appforma", "http://www.appforma.com/", :target => "_blank"%>.
|
7
|
+
Please go to <%= link_to "Appforma.com", "http://www.appforma.com/", :target => "_blank"%> to register and activate the applications.<br/><br/>
|
8
|
+
If you need more information please <%= link_to "contact us", "http://appformaapps.zendesk.com/", :target => "_blank"%>.
|
9
|
+
<% else %>
|
10
|
+
You trial period has expired.<br/><br/>
|
11
|
+
Please sign in to <%= link_to "your account", "http://www.appforma.com/myaccount", :target => "_blank"%> and upgrade your subscription. If you do not upgrade your account in 3 days it will be deactivated.<br/><br/>
|
12
|
+
If you need more information please <%= link_to "contact us", "http://appformaapps.zendesk.com/", :target => "_blank"%>.
|
13
|
+
<% end %>
|
14
|
+
|
15
|
+
</div>
|
16
|
+
</div>
|
17
|
+
<% end %>
|
data/config/routes.rb
ADDED
@@ -0,0 +1,6 @@
|
|
1
|
+
Rails.application.routes.draw do
|
2
|
+
root :to => 'appforma#intro'
|
3
|
+
match 'locale_selector' => 'appforma#locale_selector', :as => :locale_selector
|
4
|
+
match 'not_subscribed' => 'appforma#not_subscribed', :as => :not_subscribed
|
5
|
+
match 'not_authorized' => 'appforma#not_authorized', :as => :not_authorized
|
6
|
+
end
|
data/init.rb
ADDED
File without changes
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'sharkapps'
|
2
|
+
class AppformaAccount < ActiveResource::Base
|
3
|
+
|
4
|
+
self.element_name = "account"
|
5
|
+
|
6
|
+
def self.initialize_from_yaml
|
7
|
+
self.site = SharkApps.server_url
|
8
|
+
self.user = SharkApps.username
|
9
|
+
self.password = SharkApps.password
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.set_account_info(cur_account)
|
13
|
+
acc = self.find("#{cur_account.fbid}-#{cur_account.acc_hash}-#{SharkApps.app_id}")#, :hash => account.acc_hash)
|
14
|
+
cur_account.approval_status = acc.state
|
15
|
+
unless acc.state == Subscription::UNAUTHORIZED
|
16
|
+
cur_account.trial_remaining = acc.trial_remaining
|
17
|
+
end
|
18
|
+
cur_account.last_approval_check = Time.now
|
19
|
+
cur_account.save(false)
|
20
|
+
cur_account
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.check_admin_authorized(cur_account, userid=nil)
|
24
|
+
return false if userid == nil
|
25
|
+
a = self.find("#{cur_account.fbid}-#{cur_account.acc_hash}-#{SharkApps.app_id}")
|
26
|
+
c_array = a.collaborators.select {|c| c.fbid == userid}
|
27
|
+
return c_array.empty? == false
|
28
|
+
end
|
29
|
+
end
|
File without changes
|
@@ -0,0 +1,22 @@
|
|
1
|
+
class SharkappsController < ApplicationController
|
2
|
+
skip_before_filter :ensure_canvas_connected_to_facebook
|
3
|
+
before_filter :set_tab_current_account, :except => [:intro]
|
4
|
+
#before_filter :set_locale, :except => [:intro, :terms]
|
5
|
+
|
6
|
+
def not_subscribed
|
7
|
+
|
8
|
+
end
|
9
|
+
|
10
|
+
def locale_selector
|
11
|
+
if request.post?
|
12
|
+
#set the locale according to the form
|
13
|
+
redirect_to "/dashboard"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def intro
|
18
|
+
render :layout => false
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'spreadsheet'
|
2
|
+
#require "#{RAILS_ROOT}/app/models/account.rb"
|
3
|
+
|
4
|
+
class Railtie < Rails::Railtie
|
5
|
+
initializer 'rails_settings.initialize', :after => :after_initialize do
|
6
|
+
Account.class_eval do
|
7
|
+
|
8
|
+
def self.export_account_data
|
9
|
+
Spreadsheet.client_encoding = 'UTF-8'
|
10
|
+
book = Spreadsheet::Workbook.new
|
11
|
+
sheet1 = book.create_worksheet
|
12
|
+
sheet1.name = 'accounts'
|
13
|
+
sheet1.row(0).concat [
|
14
|
+
'URL',
|
15
|
+
'FBID',
|
16
|
+
'NAME',
|
17
|
+
'CREATED_DATE',
|
18
|
+
'ADMIN_URL'
|
19
|
+
]
|
20
|
+
i = 1
|
21
|
+
Account.all.each do |account|
|
22
|
+
name = page_link = Mogli::Page.find(account.fbid).name
|
23
|
+
admin_url = "http://apps.facebook.com/#{SharkApps.canvas_name}/account/#{account.to_param}/edit"
|
24
|
+
sheet1.row(i).concat [account.link_page, account.fbid, name, account.created_at, admin_url]
|
25
|
+
i = i + 1
|
26
|
+
end
|
27
|
+
|
28
|
+
book
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
AccountsController.class_eval do
|
35
|
+
define_method "export_account_data" do
|
36
|
+
excel_file = Account.export_account_data
|
37
|
+
data = StringIO.new ''
|
38
|
+
excel_file.write data
|
39
|
+
send_data(data.string.bytes.to_a.pack("C*"), :type=>"application/excel", :disposition=>'attachment', :filename => "#{SharkApps.canvas_name}-export.xls")
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -1,11 +1,41 @@
|
|
1
1
|
require 'sharkapps'
|
2
2
|
class Subscription < ActiveResource::Base
|
3
3
|
|
4
|
+
VALID = "active"
|
5
|
+
EXPIRED = "expired"
|
6
|
+
TRIAL = "trial"
|
7
|
+
UNAUTHORIZED = "unauthorized"
|
8
|
+
self.element_name = "account"
|
4
9
|
|
5
|
-
def self.check_account_authorized(account_id)
|
6
|
-
|
7
|
-
|
8
|
-
|
10
|
+
def self.check_account_authorized(account_id, acc_hash)
|
11
|
+
path = "#{self.site}accounts/app_authorized/#{account_id}/#{SharkApps.app_id}/#{acc_hash}.xml"
|
12
|
+
url = URI.parse(path)
|
13
|
+
req = Net::HTTP::Get.new(url.path)
|
14
|
+
req.basic_auth self.user, self.password
|
15
|
+
res = Net::HTTP.start(url.host, url.port) {|http|
|
16
|
+
http.request(req)
|
17
|
+
}
|
18
|
+
|
19
|
+
return res.body
|
20
|
+
#doc = REXML::Document.new(res.body)
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
def self.check_admin_authorized(account_id, user_id)
|
25
|
+
path = "#{self.site}accounts/app_authorized/#{account_id}/#{user_id}.xml"
|
26
|
+
url = URI.parse(path)
|
27
|
+
req = Net::HTTP::Get.new(url.path)
|
28
|
+
req.basic_auth self.user, self.password
|
29
|
+
res = Net::HTTP.start(url.host, url.port) {|http|
|
30
|
+
http.request(req)
|
31
|
+
}
|
32
|
+
|
33
|
+
return res.body
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.get_all_subscriptions(account)
|
37
|
+
sub = Subscription.find(account.fbid)
|
38
|
+
return sub.subscriptions unless sub.nil?
|
9
39
|
end
|
10
40
|
|
11
41
|
def self.initialize_from_yaml
|
data/lib/sharkapps.rb
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
module SharkApps
|
2
2
|
class NotConfigured < Exception; end
|
3
3
|
class << self
|
4
|
-
attr_accessor :server_url, :username, :password, :app_id, :canvas_name
|
4
|
+
attr_accessor :server_url, :username, :password, :app_id, :canvas_name, :debug_mode
|
5
5
|
end
|
6
6
|
|
7
7
|
require "facebooker2"
|
8
8
|
require "sharkapps/view_helpers"
|
9
|
-
|
9
|
+
require 'sharkapps/appforma'
|
10
|
+
#require "sharkapps/data_helpers"
|
10
11
|
ActionView::Base.send(:include, SharkApps::ViewHelpers)
|
11
12
|
|
12
13
|
def self.server_url
|
@@ -29,6 +30,10 @@ module SharkApps
|
|
29
30
|
@canvas_name || raise_unconfigured_exception
|
30
31
|
end
|
31
32
|
|
33
|
+
def self.debug_mode
|
34
|
+
@debug_mode #|| raise_unconfigured_exception
|
35
|
+
end
|
36
|
+
|
32
37
|
def self.raise_unconfigured_exception
|
33
38
|
raise NotConfigured.new("No configuration provided for Shark Apps. Call SharkApps.load_sharkapps_yaml in an initializer")
|
34
39
|
end
|
@@ -39,6 +44,7 @@ module SharkApps
|
|
39
44
|
self.password = hash[:password]
|
40
45
|
self.app_id = hash[:app_id]
|
41
46
|
self.canvas_name = hash[:canvas_name]
|
47
|
+
self.debug_mode = hash[:debug_mode]
|
42
48
|
end
|
43
49
|
|
44
50
|
def self.load_sharkapps_yaml
|
@@ -46,9 +52,11 @@ module SharkApps
|
|
46
52
|
raise NotConfigured.new("Unable to load configuration for #{::Rails.env} from sharkapps.yml. Is it set up?") if config.nil?
|
47
53
|
self.configuration = config.with_indifferent_access
|
48
54
|
Subscription.initialize_from_yaml
|
55
|
+
AppformaAccount.initialize_from_yaml
|
49
56
|
end
|
50
57
|
|
51
58
|
require "sharkapps/subscription"
|
59
|
+
require "sharkapps/account"
|
52
60
|
|
53
61
|
def self.included(base)
|
54
62
|
base.extend(ClassMethods)
|
@@ -61,17 +69,20 @@ module SharkApps
|
|
61
69
|
end
|
62
70
|
|
63
71
|
module InstanceMethods
|
64
|
-
|
65
|
-
super
|
66
|
-
#return if exception.message =~ /^No route matches/i # Supressing no route matches error emails
|
67
|
-
#Notifier.deliver_error_message( exception, clean_backtrace( exception ),
|
68
|
-
# session.instance_variable_get("@data"),
|
69
|
-
# params, request.env )
|
70
|
-
end
|
71
|
-
|
72
|
+
|
72
73
|
#redirect to the not_subscribed path if not authorized
|
73
74
|
def check_account_authorized
|
74
|
-
|
75
|
+
return true if SharkApps.debug_mode
|
76
|
+
res = @account.approval_status
|
77
|
+
need_check = @account.last_approval_check.nil? ? true : ((Time.now.to_i - @account.last_approval_check.to_i) > 5.minutes.to_i)
|
78
|
+
if need_check
|
79
|
+
#get the account
|
80
|
+
AppformaAccount.set_account_info(@account)
|
81
|
+
res = @account.approval_status
|
82
|
+
end
|
83
|
+
if res == Subscription::EXPIRED || res == Subscription::UNAUTHORIZED
|
84
|
+
redirect_to not_subscribed_path(:id => @account.acc_hash)
|
85
|
+
end
|
75
86
|
end
|
76
87
|
|
77
88
|
def set_tab_current_account
|
@@ -79,15 +90,30 @@ module SharkApps
|
|
79
90
|
temp = fb_load_facebook_params
|
80
91
|
page_id = temp["page"]["id"]
|
81
92
|
@account = Account.find_or_create_by_fbid(page_id)
|
93
|
+
#set the default locale if supported, and if the account doesn't have a locale set
|
94
|
+
if @account.respond_to? :locale and @account.locale.blank?
|
95
|
+
@account.locale = "il"
|
96
|
+
@account.save
|
97
|
+
end
|
82
98
|
@isliked = temp["page"]["liked"]
|
83
99
|
end
|
84
100
|
|
101
|
+
def check_admin
|
102
|
+
redirect_to not_authorized_url(:id => @account.acc_hash) unless is_admin
|
103
|
+
end
|
104
|
+
|
85
105
|
def is_admin
|
106
|
+
return true if SharkApps.debug_mode
|
86
107
|
if fb_load_facebook_params['page']
|
87
108
|
fb_load_facebook_params['page']['admin']
|
88
109
|
else
|
89
110
|
#go by the facebook user ID and make an API call. might need to store it in the session
|
90
|
-
|
111
|
+
sym = ("auth_admin_" + @account.fbid + "_" + current_facebook_user.id).to_sym
|
112
|
+
need_check = session[sym].nil?
|
113
|
+
if need_check #need_check
|
114
|
+
session[sym] = AppformaAccount.check_admin_authorized(@account, current_facebook_user.id)
|
115
|
+
end
|
116
|
+
return session[sym]
|
91
117
|
end
|
92
118
|
end
|
93
119
|
|
data/sharkapps.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{sharkapps}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.5"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Eyal Kedem"]
|
12
|
-
s.date = %q{
|
12
|
+
s.date = %q{2012-02-07}
|
13
13
|
s.description = %q{integration utilities with the shark apps framework}
|
14
14
|
s.email = %q{ekedem@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -24,7 +24,23 @@ Gem::Specification.new do |s|
|
|
24
24
|
"README.rdoc",
|
25
25
|
"Rakefile",
|
26
26
|
"VERSION",
|
27
|
+
"app/controllers/appforma_controller.rb",
|
28
|
+
"app/views/appforma/_footer.html.erb",
|
29
|
+
"app/views/appforma/_header.html.erb",
|
30
|
+
"app/views/appforma/_notifications.html.erb",
|
31
|
+
"app/views/appforma/intro.html.erb",
|
32
|
+
"app/views/appforma/not_authorized.html.erb",
|
33
|
+
"app/views/appforma/not_subscribed.html.erb",
|
34
|
+
"config/locales/appforma.en.yml",
|
35
|
+
"config/locales/appforma.il.yml",
|
36
|
+
"config/routes.rb",
|
37
|
+
"init.rb",
|
27
38
|
"lib/sharkapps.rb",
|
39
|
+
"lib/sharkapps/account.rb",
|
40
|
+
"lib/sharkapps/appforma.rb",
|
41
|
+
"lib/sharkapps/appforma_notification.rb",
|
42
|
+
"lib/sharkapps/controllers/sharkapps_controller.rb",
|
43
|
+
"lib/sharkapps/data_helpers.rb",
|
28
44
|
"lib/sharkapps/subscription.rb",
|
29
45
|
"lib/sharkapps/view_helpers.rb",
|
30
46
|
"sharkapps.gemspec",
|
@@ -46,17 +62,20 @@ Gem::Specification.new do |s|
|
|
46
62
|
s.specification_version = 3
|
47
63
|
|
48
64
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
65
|
+
s.add_development_dependency(%q<rails>, [">= 3.0.9"])
|
49
66
|
s.add_development_dependency(%q<shoulda>, [">= 0"])
|
50
67
|
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
51
68
|
s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
|
52
69
|
s.add_development_dependency(%q<rcov>, [">= 0"])
|
53
70
|
else
|
71
|
+
s.add_dependency(%q<rails>, [">= 3.0.9"])
|
54
72
|
s.add_dependency(%q<shoulda>, [">= 0"])
|
55
73
|
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
56
74
|
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
|
57
75
|
s.add_dependency(%q<rcov>, [">= 0"])
|
58
76
|
end
|
59
77
|
else
|
78
|
+
s.add_dependency(%q<rails>, [">= 3.0.9"])
|
60
79
|
s.add_dependency(%q<shoulda>, [">= 0"])
|
61
80
|
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
62
81
|
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
|
metadata
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sharkapps
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
|
9
|
+
- 5
|
10
|
+
segments_generated: true
|
11
|
+
version: 0.1.5
|
11
12
|
platform: ruby
|
12
13
|
authors:
|
13
14
|
- Eyal Kedem
|
@@ -15,25 +16,44 @@ autorequire:
|
|
15
16
|
bindir: bin
|
16
17
|
cert_chain: []
|
17
18
|
|
18
|
-
date:
|
19
|
+
date: 2012-02-07 00:00:00 +02:00
|
19
20
|
default_executable:
|
20
21
|
dependencies:
|
21
22
|
- !ruby/object:Gem::Dependency
|
22
|
-
|
23
|
+
name: rails
|
24
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
23
25
|
none: false
|
24
26
|
requirements:
|
25
27
|
- - ">="
|
26
28
|
- !ruby/object:Gem::Version
|
27
|
-
hash:
|
29
|
+
hash: 21
|
28
30
|
segments:
|
31
|
+
- 3
|
29
32
|
- 0
|
30
|
-
|
33
|
+
- 9
|
34
|
+
segments_generated: true
|
35
|
+
version: 3.0.9
|
36
|
+
requirement: *id001
|
37
|
+
prerelease: false
|
31
38
|
type: :development
|
39
|
+
- !ruby/object:Gem::Dependency
|
32
40
|
name: shoulda
|
41
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
hash: 3
|
47
|
+
segments:
|
48
|
+
- 0
|
49
|
+
segments_generated: true
|
50
|
+
version: "0"
|
51
|
+
requirement: *id002
|
33
52
|
prerelease: false
|
34
|
-
|
53
|
+
type: :development
|
35
54
|
- !ruby/object:Gem::Dependency
|
36
|
-
|
55
|
+
name: bundler
|
56
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
37
57
|
none: false
|
38
58
|
requirements:
|
39
59
|
- - ~>
|
@@ -43,13 +63,14 @@ dependencies:
|
|
43
63
|
- 1
|
44
64
|
- 0
|
45
65
|
- 0
|
66
|
+
segments_generated: true
|
46
67
|
version: 1.0.0
|
47
|
-
|
48
|
-
name: bundler
|
68
|
+
requirement: *id003
|
49
69
|
prerelease: false
|
50
|
-
|
70
|
+
type: :development
|
51
71
|
- !ruby/object:Gem::Dependency
|
52
|
-
|
72
|
+
name: jeweler
|
73
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
53
74
|
none: false
|
54
75
|
requirements:
|
55
76
|
- - ~>
|
@@ -59,13 +80,14 @@ dependencies:
|
|
59
80
|
- 1
|
60
81
|
- 5
|
61
82
|
- 2
|
83
|
+
segments_generated: true
|
62
84
|
version: 1.5.2
|
63
|
-
|
64
|
-
name: jeweler
|
85
|
+
requirement: *id004
|
65
86
|
prerelease: false
|
66
|
-
|
87
|
+
type: :development
|
67
88
|
- !ruby/object:Gem::Dependency
|
68
|
-
|
89
|
+
name: rcov
|
90
|
+
version_requirements: &id005 !ruby/object:Gem::Requirement
|
69
91
|
none: false
|
70
92
|
requirements:
|
71
93
|
- - ">="
|
@@ -73,11 +95,11 @@ dependencies:
|
|
73
95
|
hash: 3
|
74
96
|
segments:
|
75
97
|
- 0
|
98
|
+
segments_generated: true
|
76
99
|
version: "0"
|
77
|
-
|
78
|
-
name: rcov
|
100
|
+
requirement: *id005
|
79
101
|
prerelease: false
|
80
|
-
|
102
|
+
type: :development
|
81
103
|
description: integration utilities with the shark apps framework
|
82
104
|
email: ekedem@gmail.com
|
83
105
|
executables: []
|
@@ -95,7 +117,23 @@ files:
|
|
95
117
|
- README.rdoc
|
96
118
|
- Rakefile
|
97
119
|
- VERSION
|
120
|
+
- app/controllers/appforma_controller.rb
|
121
|
+
- app/views/appforma/_footer.html.erb
|
122
|
+
- app/views/appforma/_header.html.erb
|
123
|
+
- app/views/appforma/_notifications.html.erb
|
124
|
+
- app/views/appforma/intro.html.erb
|
125
|
+
- app/views/appforma/not_authorized.html.erb
|
126
|
+
- app/views/appforma/not_subscribed.html.erb
|
127
|
+
- config/locales/appforma.en.yml
|
128
|
+
- config/locales/appforma.il.yml
|
129
|
+
- config/routes.rb
|
130
|
+
- init.rb
|
98
131
|
- lib/sharkapps.rb
|
132
|
+
- lib/sharkapps/account.rb
|
133
|
+
- lib/sharkapps/appforma.rb
|
134
|
+
- lib/sharkapps/appforma_notification.rb
|
135
|
+
- lib/sharkapps/controllers/sharkapps_controller.rb
|
136
|
+
- lib/sharkapps/data_helpers.rb
|
99
137
|
- lib/sharkapps/subscription.rb
|
100
138
|
- lib/sharkapps/view_helpers.rb
|
101
139
|
- sharkapps.gemspec
|
@@ -118,6 +156,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
118
156
|
hash: 3
|
119
157
|
segments:
|
120
158
|
- 0
|
159
|
+
segments_generated: true
|
121
160
|
version: "0"
|
122
161
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
123
162
|
none: false
|
@@ -127,6 +166,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
127
166
|
hash: 3
|
128
167
|
segments:
|
129
168
|
- 0
|
169
|
+
segments_generated: true
|
130
170
|
version: "0"
|
131
171
|
requirements: []
|
132
172
|
|