ishapi 0.1.8.14 → 0.1.8.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ace07837fa637b3d9b053edb16cd769561956717
4
- data.tar.gz: 3088ac3e4b42361e4e81fa206ac173dbdf78264e
3
+ metadata.gz: 56e342680489f7e39cb92550ace7d74a3510793c
4
+ data.tar.gz: da837c0fa8c43e47819ffd789134c0a9950e76b4
5
5
  SHA512:
6
- metadata.gz: a1e0c0d2dd0e693de2dd6afe36dfdd07dc5a1f12cb72358ed84757b6d74c8f02917501d490b224c267d23e992f52df49fdffdb262903d8e4f6d763855fd8d615
7
- data.tar.gz: 70f844785e3aa06062edeca406273048d85ddb85f291ce45c1442b1e5394b421ef9e294deeb33b809f64fc8398f6053726364ae75c745a886c119757005c3698
6
+ metadata.gz: bec8b8ed5524363e939197469c8941e3cbc60e046eb65b7d09be5d9dd654608e9b6dc62883b55d020b8ad30e39ae25caa049fd11f45fb1dcecc0b1453b7453c2
7
+ data.tar.gz: f51815fd33819d81ab67736922c76eed51838933927e441a6abeaed6c30647355f661a5a7fa34c71316bc1e4ee9ebcd337312f7cf36ebfc1739f9e6d7785aa1b
data/README.md CHANGED
@@ -2,4 +2,5 @@
2
2
  # Develop
3
3
  # Test
4
4
  # Install
5
+ bundle
5
6
  gem build ishapi.gemspec
@@ -1,9 +1,10 @@
1
1
  module Ishapi
2
2
  class ApplicationController < ActionController::Base
3
- protect_from_forgery with: :exception
3
+ protect_from_forgery :prepend => true, :with => :exception
4
4
  layout :false
5
5
  before_action :set_current_ability
6
6
  check_authorization
7
+ skip_before_action :verify_authenticity_token
7
8
 
8
9
  private
9
10
 
@@ -1,4 +1,3 @@
1
-
2
1
  require_dependency "ishapi/application_controller"
3
2
 
4
3
  module Ishapi
@@ -0,0 +1,55 @@
1
+ require_dependency "ishapi/application_controller"
2
+
3
+ module Ishapi
4
+ class UsersController < ApplicationController
5
+
6
+ def fb_sign_in
7
+ authorize! :fb_sign_in, Ishapi
8
+
9
+ params.permit!
10
+
11
+ access_token = params[:accessToken]
12
+ email = params[:email]
13
+ name = params[:name]
14
+ user = User.where( :email => email ).first
15
+
16
+ u = IshModels::UserProfile.find_or_create_by :email => email
17
+ u.fb_access_token = access_token
18
+ u.name ||= name
19
+ u.user = user
20
+ u.user ||= User.create( :email => email, :password => (0..8).map { "#{rand(100)}" }.join("#{rand(100)}") )
21
+
22
+ if u.save
23
+ render :json => { :status => :ok }
24
+ else
25
+ render :json => { :status => :not_ok, :errors => u.errors.messages }
26
+ end
27
+ end
28
+
29
+ def show
30
+ authorize! :fb_sign_in, Ishapi
31
+
32
+ @graph = Koala::Facebook::API.new( params[:accessToken] )
33
+ me = @graph.get_object( 'me', :fields => 'email' )
34
+ @user = User.find_by( :email => me['email'] )
35
+ @user_profile = IshModels::UserProfile.find_by :email => me['email']
36
+ end
37
+
38
+ def update
39
+ authorize! :fb_sign_in, Ishapi
40
+
41
+ @graph = Koala::Facebook::API.new( params[:accessToken] )
42
+ me = @graph.get_object( 'me', :fields => 'email' )
43
+ @user = User.find_by( :email => me['email'] )
44
+ @user_profile = IshModels::UserProfile.find_by :email => me['email']
45
+
46
+ flag = @user_profile.update_attributes( params[:user_profile].permit( :about, :current_city_id ) )
47
+ if flag
48
+ render :json => { :status => :ok }
49
+ else
50
+ render :json => { :status => :not_ok, :errors => @user_profile.errors.messages }
51
+ end
52
+ end
53
+
54
+ end
55
+ end
@@ -0,0 +1,43 @@
1
+ require_dependency "ishapi/application_controller"
2
+
3
+ module Ishapi
4
+ class UsersController < ApplicationController
5
+
6
+ def fb_sign_in
7
+ authorize! :fb_sign_in, Ishapi
8
+
9
+ params.permit!
10
+
11
+ access_token = params[:accessToken]
12
+ email = params[:email]
13
+ name = params[:name]
14
+ user = User.where( :email => email ).first
15
+
16
+ u = IshModels::UserProfile.find_or_create_by :email => email
17
+ u.fb_access_token = access_token
18
+ u.name ||= name
19
+ u.user = user
20
+ u.user ||= User.create( :email => email, :password => (0..8).map { "#{rand(100)}" }.join("#{rand(100)}") )
21
+
22
+ if u.save
23
+ render :json => { :status => :ok }
24
+ else
25
+ render :json => { :status => :not_ok, :errors => u.errors.messages }
26
+ end
27
+ end
28
+
29
+ def show
30
+ puts! params, 'params'
31
+
32
+ # @oauth = Koala::Facebook::OAuth.new # ( app_id, app_secret )
33
+ # @oauth.get_user_info_from_cookies(cookies)
34
+
35
+ access_token = params[:access_token]
36
+ # @graph = Koala::Facebook::Api.new( access_token )
37
+ # puts! @graph.get_object 'me'
38
+
39
+ raise 'not implemented'
40
+ end
41
+
42
+ end
43
+ end
@@ -33,7 +33,7 @@ class Ishapi::Ability
33
33
  report.is_public
34
34
  end
35
35
 
36
- can [ :welcome_home ], Ishapi
36
+ can [ :welcome_home, :fb_sign_in, :open_permission ], Ishapi
37
37
 
38
38
  can [ :index, :show ], Site
39
39
 
@@ -12,9 +12,12 @@ json.cache! key do
12
12
  json.description @city.description
13
13
  json.x @city.x
14
14
  json.y @city.y
15
+
15
16
  json.partial! 'ishapi/newsitems/index', :newsitems => @city.newsitems
17
+ json.partial! 'ishapi/features/index', :features => @city.features
16
18
  json.partial! 'ishapi/galleries/index', :galleries => @city.galleries
17
19
  json.partial! 'ishapi/reports/index', :reports => @city.reports
20
+ json.partial! 'ishapi/users/index', :users => @city.current_users
18
21
  json.partial! 'ishapi/venues/index', :venues => @city.venues
19
22
  json.partial! 'ishapi/videos/index', :videos => @city.videos
20
23
  end
@@ -3,5 +3,10 @@
3
3
  # ishapi / features / _index
4
4
  #
5
5
 
6
+ json.n_features features.count
6
7
  json.features do
8
+ json.array! features do |feature|
9
+ json.id feature.id.to_s
10
+ json.name feature.name
11
+ end
7
12
  end
@@ -3,6 +3,7 @@
3
3
  # ishapi / galleries / _index
4
4
  #
5
5
 
6
+ json.n_galleries galleries.count
6
7
  json.galleries do
7
8
  json.array! galleries do |gallery|
8
9
  json.partial! 'ishapi/galleries/show', :gallery => gallery
@@ -3,6 +3,7 @@
3
3
  # ishapi / newsitems / _index
4
4
  #
5
5
 
6
+ json.n_newsitems newsitems.count
6
7
  json.newsitems do
7
8
  json.array! newsitems do |item|
8
9
  if item.gallery
@@ -3,6 +3,7 @@
3
3
  # ishapi / reports / _index
4
4
  #
5
5
 
6
+ json.n_reports reports.count
6
7
  json.reports do
7
8
  json.array! reports do |report|
8
9
  json.id report.id.to_s
@@ -0,0 +1,10 @@
1
+
2
+ json.n_users users.count
3
+ json.users do
4
+ json.array! users do |user|
5
+ json.id user.id.to_s
6
+ json.username user.username
7
+ json.name user.name
8
+ json.email user.email
9
+ end
10
+ end
@@ -0,0 +1,7 @@
1
+
2
+ json.users do
3
+ json.array! users do |user|
4
+ json.id user.id.to_s
5
+ json.email user.email
6
+ end
7
+ end
@@ -0,0 +1,15 @@
1
+
2
+ #
3
+ # ishapi / users / _show.jbuilder
4
+ #
5
+
6
+ json.email @user_profile.email
7
+ json.about @user_profile.about
8
+
9
+ if @user_profile.current_city
10
+ json.current_city_id @user_profile.current_city_id.to_s
11
+ json.current_city do
12
+ json.id @user_profile.current_city_id.to_s
13
+ json.name @user_profile.current_city.name
14
+ end
15
+ end
@@ -0,0 +1,9 @@
1
+
2
+ #
3
+ # ishapi / users / _show.jbuilder
4
+ #
5
+
6
+ json.current_city do
7
+ json.id @user_profile.current_city_id.to_s
8
+ json.name @user_profile.current_city.name
9
+ end
@@ -3,6 +3,7 @@
3
3
  # ishapi / venues / _index
4
4
  #
5
5
 
6
+ json.n_venues venues.count
6
7
  json.venues do
7
8
  json.array! venues do |venue|
8
9
  json.id venue.id.to_s
@@ -3,6 +3,7 @@
3
3
  # ishapi / videos / _index
4
4
  #
5
5
 
6
+ json.n_videos videos.count
6
7
  json.videos videos do |video|
7
- json.partial! :show, :video => video
8
+ json.partial! 'ishapi/videos/show', :video => video
8
9
  end
data/config/routes.rb CHANGED
@@ -12,6 +12,11 @@ Ishapi::Engine.routes.draw do
12
12
 
13
13
  get 'sites/view/:domain', :to => 'sites#show', :constraints => { :domain => /[^\/]+/ }
14
14
 
15
+ post 'users/fb_sign_in', :to => 'users#fb_sign_in'
16
+ post 'users/profile', :to => 'users#show'
17
+ post 'users/profile/update', :to => 'users#update'
18
+ get 'users/profile', :to => 'users#show' # @TODO: only for testing! accessToken must be hidden
19
+
15
20
  get 'venues/view/:venuename', :to => 'venues#show'
16
21
 
17
22
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ishapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8.14
4
+ version: 0.1.8.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - piousbox
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-14 00:00:00.000000000 Z
11
+ date: 2017-07-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -81,41 +81,27 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: '1.0'
83
83
  - !ruby/object:Gem::Dependency
84
- name: rspec
84
+ name: koala
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: '0'
97
- - !ruby/object:Gem::Dependency
98
- name: rspec-rails
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - ">="
87
+ - - "~>"
102
88
  - !ruby/object:Gem::Version
103
- version: '0'
104
- type: :development
89
+ version: '3.0'
90
+ type: :runtime
105
91
  prerelease: false
106
92
  version_requirements: !ruby/object:Gem::Requirement
107
93
  requirements:
108
- - - ">="
94
+ - - "~>"
109
95
  - !ruby/object:Gem::Version
110
- version: '0'
96
+ version: '3.0'
111
97
  - !ruby/object:Gem::Dependency
112
- name: simplecov
98
+ name: fb_graph
113
99
  requirement: !ruby/object:Gem::Requirement
114
100
  requirements:
115
101
  - - ">="
116
102
  - !ruby/object:Gem::Version
117
103
  version: '0'
118
- type: :development
104
+ type: :runtime
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
107
  requirements:
@@ -150,6 +136,8 @@ files:
150
136
  - app/controllers/ishapi/reports_controller.rb~
151
137
  - app/controllers/ishapi/sites_controller.rb
152
138
  - app/controllers/ishapi/sites_controller.rb~
139
+ - app/controllers/ishapi/users_controller.rb
140
+ - app/controllers/ishapi/users_controller.rb~
153
141
  - app/controllers/ishapi/venues_controller.rb
154
142
  - app/controllers/ishapi/venues_controller.rb~
155
143
  - app/helpers/ishapi/application_helper.rb
@@ -189,6 +177,10 @@ files:
189
177
  - app/views/ishapi/reports/show.jbuilder~
190
178
  - app/views/ishapi/sites/show.jbuilder
191
179
  - app/views/ishapi/sites/show.jbuilder~
180
+ - app/views/ishapi/users/_index.jbuilder
181
+ - app/views/ishapi/users/_index.jbuilder~
182
+ - app/views/ishapi/users/show.jbuilder
183
+ - app/views/ishapi/users/show.jbuilder~
192
184
  - app/views/ishapi/venues/_index.haml~
193
185
  - app/views/ishapi/venues/_index.jbuilder
194
186
  - app/views/ishapi/venues/_index.jbuilder~