ishapi 0.1.8.193 → 0.1.8.195
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 +4 -4
- data/Rakefile +0 -3
- data/app/controllers/ishapi/application_controller.rb +11 -13
- data/app/controllers/ishapi/galleries_controller.rb +0 -4
- data/app/controllers/ishapi/maps_controller.rb +2 -6
- data/app/controllers/ishapi/users/registrations_controller.rb +1 -1
- data/app/controllers/ishapi/users/sessions_controller.rb +3 -3
- data/app/controllers/ishapi/users_controller.rb +32 -34
- data/app/controllers/ishapi/videos_controller.rb +0 -9
- data/app/helpers/ishapi/application_helper.rb +1 -1
- data/app/models/ishapi/ability.rb +8 -25
- data/app/views/ishapi/application/_meta.jbuilder +0 -10
- data/app/views/ishapi/galleries/_show.jbuilder +1 -1
- data/app/views/ishapi/galleries/index.jbuilder +1 -4
- data/app/views/ishapi/maps/_show.jbuilder +1 -5
- data/app/views/ishapi/maps/show.jbuilder +1 -1
- data/app/views/ishapi/markers/_index.jbuilder +2 -2
- data/app/views/ishapi/newsitems/_index.jbuilder +4 -4
- data/app/views/ishapi/reports/_index.jbuilder +0 -2
- data/app/views/ishapi/reports/show.jbuilder +0 -3
- data/app/views/ishapi/user_profiles/_account.jbuilder +21 -0
- data/app/views/ishapi/{users → user_profiles}/_index.jbuilder +0 -0
- data/app/views/ishapi/user_profiles/account.jbuilder +2 -0
- data/app/views/ishapi/user_profiles/login.jbuilder +5 -0
- data/app/views/ishapi/user_profiles/show.jbuilder +0 -4
- data/app/views/ishapi/{users/show.jbuilder → user_profiles/show.jbuilder-bk} +1 -4
- data/app/views/ishapi/videos/_show.jbuilder +2 -10
- data/config/routes.rb +6 -22
- data/lib/ishapi/engine.rb +1 -1
- metadata +7 -35
- data/app/controllers/ishapi/application_controller.rb-trash +0 -275
- data/app/controllers/ishapi/articles_controller.rb +0 -62
- data/app/controllers/ishapi/cities_controller.rb +0 -35
- data/app/controllers/ishapi/events_controller.rb +0 -21
- data/app/controllers/ishapi/measurements_controller.rb +0 -26
- data/app/controllers/ishapi/sites_controller.rb +0 -55
- data/app/controllers/ishapi/tags_controller.rb +0 -24
- data/app/controllers/ishapi/venues_controller.rb +0 -20
- data/app/views/ishapi/articles/_form.html.erb +0 -27
- data/app/views/ishapi/articles/edit.html.erb +0 -6
- data/app/views/ishapi/articles/index.html.erb +0 -29
- data/app/views/ishapi/articles/new.html.erb +0 -5
- data/app/views/ishapi/articles/show.html.erb +0 -14
- data/app/views/ishapi/cities/_index.jbuilder +0 -16
- data/app/views/ishapi/cities/features.jbuilder +0 -9
- data/app/views/ishapi/cities/index.jbuilder +0 -9
- data/app/views/ishapi/cities/show.jbuilder +0 -30
- data/app/views/ishapi/events/_index.jbuilder +0 -13
- data/app/views/ishapi/events/show.jbuilder +0 -11
- data/app/views/ishapi/features/_index.jbuilder +0 -41
- data/app/views/ishapi/sites/show.jbuilder +0 -31
- data/app/views/ishapi/tags/_index.jbuilder +0 -14
- data/app/views/ishapi/tags/_widget.jbuilder +0 -11
- data/app/views/ishapi/tags/index.jbuilder +0 -10
- data/app/views/ishapi/tags/show.jbuilder +0 -14
- data/app/views/ishapi/users/_account.jbuilder +0 -21
- data/app/views/ishapi/users/account.jbuilder +0 -2
- data/app/views/ishapi/users/login.jbuilder +0 -5
- data/app/views/ishapi/venues/_index.jbuilder +0 -21
- data/app/views/ishapi/venues/index.jbuilder +0 -2
- data/app/views/ishapi/venues/show.jbuilder +0 -15
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.
|
4
|
+
version: 0.1.8.195
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- piousbox
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-10-
|
11
|
+
date: 2022-10-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -266,15 +266,10 @@ files:
|
|
266
266
|
- app/assets/stylesheets/scaffold.css
|
267
267
|
- app/controllers/ishapi/addresses_controller.rb
|
268
268
|
- app/controllers/ishapi/application_controller.rb
|
269
|
-
- app/controllers/ishapi/application_controller.rb-trash
|
270
|
-
- app/controllers/ishapi/articles_controller.rb
|
271
|
-
- app/controllers/ishapi/cities_controller.rb
|
272
|
-
- app/controllers/ishapi/events_controller.rb
|
273
269
|
- app/controllers/ishapi/galleries_controller.rb
|
274
270
|
- app/controllers/ishapi/gameui_controller.rb
|
275
271
|
- app/controllers/ishapi/invoices_controller.rb
|
276
272
|
- app/controllers/ishapi/maps_controller.rb
|
277
|
-
- app/controllers/ishapi/measurements_controller.rb
|
278
273
|
- app/controllers/ishapi/my/galleries_controller.rb
|
279
274
|
- app/controllers/ishapi/my/reports_controller.rb
|
280
275
|
- app/controllers/ishapi/my/videos_controller.rb
|
@@ -284,14 +279,11 @@ files:
|
|
284
279
|
- app/controllers/ishapi/payments_controller.rb
|
285
280
|
- app/controllers/ishapi/photos_controller.rb
|
286
281
|
- app/controllers/ishapi/reports_controller.rb
|
287
|
-
- app/controllers/ishapi/sites_controller.rb
|
288
282
|
- app/controllers/ishapi/stock_watches_controller.rb
|
289
|
-
- app/controllers/ishapi/tags_controller.rb
|
290
283
|
- app/controllers/ishapi/user_profiles_controller.rb
|
291
284
|
- app/controllers/ishapi/users/registrations_controller.rb
|
292
285
|
- app/controllers/ishapi/users/sessions_controller.rb
|
293
286
|
- app/controllers/ishapi/users_controller.rb
|
294
|
-
- app/controllers/ishapi/venues_controller.rb
|
295
287
|
- app/controllers/ishapi/videos_controller.rb
|
296
288
|
- app/helpers/ishapi/application_helper.rb
|
297
289
|
- app/jobs/ishapi/application_job.rb
|
@@ -301,18 +293,6 @@ files:
|
|
301
293
|
- app/views/ishapi/addresses/_show.jbuilder
|
302
294
|
- app/views/ishapi/application/_meta.jbuilder
|
303
295
|
- app/views/ishapi/application/_pagination.jbuilder
|
304
|
-
- app/views/ishapi/articles/_form.html.erb
|
305
|
-
- app/views/ishapi/articles/edit.html.erb
|
306
|
-
- app/views/ishapi/articles/index.html.erb
|
307
|
-
- app/views/ishapi/articles/new.html.erb
|
308
|
-
- app/views/ishapi/articles/show.html.erb
|
309
|
-
- app/views/ishapi/cities/_index.jbuilder
|
310
|
-
- app/views/ishapi/cities/features.jbuilder
|
311
|
-
- app/views/ishapi/cities/index.jbuilder
|
312
|
-
- app/views/ishapi/cities/show.jbuilder
|
313
|
-
- app/views/ishapi/events/_index.jbuilder
|
314
|
-
- app/views/ishapi/events/show.jbuilder
|
315
|
-
- app/views/ishapi/features/_index.jbuilder
|
316
296
|
- app/views/ishapi/galleries/_index.jbuilder
|
317
297
|
- app/views/ishapi/galleries/_show.jbuilder
|
318
298
|
- app/views/ishapi/galleries/index.jbuilder
|
@@ -342,21 +322,13 @@ files:
|
|
342
322
|
- app/views/ishapi/reports/_index.jbuilder
|
343
323
|
- app/views/ishapi/reports/index.jbuilder
|
344
324
|
- app/views/ishapi/reports/show.jbuilder
|
345
|
-
- app/views/ishapi/sites/show.jbuilder
|
346
325
|
- app/views/ishapi/stock_watches/index.jbuilder
|
347
|
-
- app/views/ishapi/
|
348
|
-
- app/views/ishapi/
|
349
|
-
- app/views/ishapi/
|
350
|
-
- app/views/ishapi/
|
326
|
+
- app/views/ishapi/user_profiles/_account.jbuilder
|
327
|
+
- app/views/ishapi/user_profiles/_index.jbuilder
|
328
|
+
- app/views/ishapi/user_profiles/account.jbuilder
|
329
|
+
- app/views/ishapi/user_profiles/login.jbuilder
|
351
330
|
- app/views/ishapi/user_profiles/show.jbuilder
|
352
|
-
- app/views/ishapi/
|
353
|
-
- app/views/ishapi/users/_index.jbuilder
|
354
|
-
- app/views/ishapi/users/account.jbuilder
|
355
|
-
- app/views/ishapi/users/login.jbuilder
|
356
|
-
- app/views/ishapi/users/show.jbuilder
|
357
|
-
- app/views/ishapi/venues/_index.jbuilder
|
358
|
-
- app/views/ishapi/venues/index.jbuilder
|
359
|
-
- app/views/ishapi/venues/show.jbuilder
|
331
|
+
- app/views/ishapi/user_profiles/show.jbuilder-bk
|
360
332
|
- app/views/ishapi/videos/_index.jbuilder
|
361
333
|
- app/views/ishapi/videos/_show.jbuilder
|
362
334
|
- app/views/ishapi/videos/index.jbuilder
|
@@ -1,275 +0,0 @@
|
|
1
|
-
module Ishapi
|
2
|
-
class ApplicationController < ActionController::Base
|
3
|
-
after_action :append_long_term_token, except: [ :long_term_token, :test ]
|
4
|
-
|
5
|
-
protect_from_forgery :prepend => true, :with => :exception
|
6
|
-
layout :false
|
7
|
-
|
8
|
-
check_authorization except: [ :long_term_token ]
|
9
|
-
skip_before_action :verify_authenticity_token
|
10
|
-
|
11
|
-
def test
|
12
|
-
end
|
13
|
-
|
14
|
-
def long_term_token
|
15
|
-
accessToken = request.headers[:accessToken]
|
16
|
-
accessToken ||= params[:accessToken]
|
17
|
-
|
18
|
-
params['domain'] = 'tgm.piousbox.com'
|
19
|
-
|
20
|
-
response = ::HTTParty.get "https://graph.facebook.com/v5.0/oauth/access_token?grant_type=fb_exchange_token&" +
|
21
|
-
"client_id=#{FB[params['domain']][:app]}&client_secret=#{FB[params['domain']][:secret]}&" +
|
22
|
-
"fb_exchange_token=#{accessToken}"
|
23
|
-
j = JSON.parse response.body
|
24
|
-
@long_term_token = j['access_token']
|
25
|
-
@graph = Koala::Facebook::API.new( accessToken )
|
26
|
-
@me = @graph.get_object( 'me', :fields => 'email' )
|
27
|
-
@current_user = User.where( :email => @me['email'] ).first
|
28
|
-
|
29
|
-
# send the jwt to client
|
30
|
-
@jwt_token = encode(user_id: @current_user.id.to_s)
|
31
|
-
|
32
|
-
render json: {
|
33
|
-
email: @current_user.email,
|
34
|
-
jwt_token: @jwt_token,
|
35
|
-
long_term_token: @long_term_token,
|
36
|
-
n_unlocks: @current_user.profile.n_unlocks,
|
37
|
-
}
|
38
|
-
end
|
39
|
-
|
40
|
-
def home
|
41
|
-
authorize! :welcome_home, Ishapi
|
42
|
-
render :json => { :status => :ok, :message => 'Ishapi::ApiController.home',
|
43
|
-
:n_reports => Report.count, :n_cities => City.count }
|
44
|
-
end
|
45
|
-
|
46
|
-
#
|
47
|
-
# private
|
48
|
-
#
|
49
|
-
private
|
50
|
-
|
51
|
-
def append_long_term_token
|
52
|
-
if @long_term_token
|
53
|
-
response.body = JSON.parse(response.body).merge({ long_term_token: @long_term_token }).to_json
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
## Hard check by default; craps out if accessToken is missing
|
58
|
-
def check_long_term_token soft=false
|
59
|
-
accessToken = request.headers[:accessToken]
|
60
|
-
accessToken ||= params[:accessToken]
|
61
|
-
if accessToken
|
62
|
-
@graph = Koala::Facebook::API.new( accessToken )
|
63
|
-
@me = @graph.get_object( 'me', :fields => 'email' )
|
64
|
-
@current_user = User.where( :email => @me['email'] ).first
|
65
|
-
@profile = @current_user.profile
|
66
|
-
raise '98& - no profile' unless @profile
|
67
|
-
else
|
68
|
-
if soft
|
69
|
-
return
|
70
|
-
else
|
71
|
-
raise 'no access token'
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
## Does not crap out if accessToken is missing
|
77
|
-
def soft_check_long_term_token
|
78
|
-
check_long_term_token soft=true
|
79
|
-
end
|
80
|
-
|
81
|
-
def check_multiprofile provider = 'google'
|
82
|
-
if 'google' == provider
|
83
|
-
# client_secrets = ::Google::APIClient::ClientSecrets.load
|
84
|
-
# accessToken = params[:accessToken]
|
85
|
-
# authorization = ::Google::Auth.get_application_default
|
86
|
-
# result = authorization.apply({ accessToken: params[:accessToken] })
|
87
|
-
# puts! result, 'googleauth result'
|
88
|
-
|
89
|
-
decoded_token = JWT.decode params[:idToken], nil, false
|
90
|
-
|
91
|
-
@current_user = User.find_by email: decoded_token[0]['email']
|
92
|
-
|
93
|
-
elsif 'facebook' == provider
|
94
|
-
# accessToken ||= params[:fb_long_access_token]
|
95
|
-
|
96
|
-
accessToken = request.headers[:accessToken]
|
97
|
-
accessToken ||= params[:accessToken]
|
98
|
-
if accessToken
|
99
|
-
|
100
|
-
#
|
101
|
-
# long-term token
|
102
|
-
#
|
103
|
-
params['domain'] = 'tgm.piousbox.com'
|
104
|
-
response = HTTParty.get "https://graph.facebook.com/v5.0/oauth/access_token?grant_type=fb_exchange_token&" +
|
105
|
-
"client_id=#{FB[params['domain']][:app]}&client_secret=#{FB[params['domain']][:secret]}&" +
|
106
|
-
"fb_exchange_token=#{accessToken}"
|
107
|
-
j = JSON.parse response.body
|
108
|
-
@long_term_token = j['access_token']
|
109
|
-
|
110
|
-
|
111
|
-
@graph = Koala::Facebook::API.new( accessToken )
|
112
|
-
@me = @graph.get_object( 'me', :fields => 'email' )
|
113
|
-
@current_user = User.where( :email => @me['email'] ).first
|
114
|
-
@current_user ||= User.create! email: @me['email'], password: SecureRandom.urlsafe_base64
|
115
|
-
|
116
|
-
@current_profile = @current_user.profile
|
117
|
-
if !@current_profile
|
118
|
-
begin
|
119
|
-
g = Gallery.find '5e1495e2d697f768ad0779eb'
|
120
|
-
rescue Mongoid::Errors::DocumentNotFound => e
|
121
|
-
g = Gallery.create id: '5e1495e2d697f768ad0779eb'
|
122
|
-
end
|
123
|
-
@current_profile = IshModels::UserProfile.create user: @current_user, name: @me['email'], email: @me['email']
|
124
|
-
test_newsitem = Newsitem.new gallery_id: '5e1495e2d697f768ad0779eb'
|
125
|
-
@current_profile.newsitems << test_newsitem
|
126
|
-
@current_profile.save
|
127
|
-
end
|
128
|
-
@current_profile.update fb_long_access_token: @long_term_token
|
129
|
-
else
|
130
|
-
@current_user = current_user if Rails.env.test?
|
131
|
-
end
|
132
|
-
|
133
|
-
elsif 'jwt' == provider
|
134
|
-
decoded = decode(params[:jwt_token])
|
135
|
-
@current_user = User.find decoded['user_id']
|
136
|
-
puts! @current_user, '@current_user from decoded'
|
137
|
-
else
|
138
|
-
raise "ww1 - not implemented"
|
139
|
-
end
|
140
|
-
|
141
|
-
sign_in @current_user, scope: :user
|
142
|
-
puts! current_user, 'did I sign in?'
|
143
|
-
current_ability
|
144
|
-
end
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
# same as check_profile but doesn't error out when jwt_token is missing or expired
|
149
|
-
def check_profile_optionally
|
150
|
-
if !params[:jwt_token]
|
151
|
-
# @current_user = User.new profile: Profile.new
|
152
|
-
else
|
153
|
-
begin
|
154
|
-
check_profile
|
155
|
-
rescue JWT::ExpiredSignature
|
156
|
-
Rails.logger.info("JWT::ExpiredSignature")
|
157
|
-
# @current_user = User.new profile: Profile.new
|
158
|
-
end
|
159
|
-
end
|
160
|
-
end
|
161
|
-
|
162
|
-
# this doesn't generate long-lived token, doesn't update user_profile
|
163
|
-
def check_profile
|
164
|
-
# return check_multiprofile 'google'
|
165
|
-
# return check_multiprofile 'facebook'
|
166
|
-
return check_multiprofile 'jwt'
|
167
|
-
|
168
|
-
accessToken = request.headers[:accessToken]
|
169
|
-
accessToken ||= params[:fb_long_access_token]
|
170
|
-
accessToken ||= params[:accessToken]
|
171
|
-
if accessToken
|
172
|
-
@graph = Koala::Facebook::API.new( accessToken )
|
173
|
-
@me = @graph.get_object( 'me', :fields => 'email' )
|
174
|
-
@current_user = User.find_by :email => @me['email']
|
175
|
-
else
|
176
|
-
@current_user = current_user if Rails.env.test?
|
177
|
-
end
|
178
|
-
@current_profile = @current_user.profile
|
179
|
-
@current_order = @current_profile.current_order
|
180
|
-
# orders.where( :submitted_at => nil ).first || ::CoTailors::Order.create( :profile_id => @current_profile.id )
|
181
|
-
|
182
|
-
## for sedux
|
183
|
-
sign_in( @current_user )
|
184
|
-
end
|
185
|
-
|
186
|
-
def set_profile
|
187
|
-
accessToken = request.headers[:accessToken]
|
188
|
-
accessToken ||= params[:fb_long_access_token]
|
189
|
-
accessToken ||= params[:accessToken]
|
190
|
-
|
191
|
-
# params[:domain] ||= '_default'
|
192
|
-
|
193
|
-
if accessToken
|
194
|
-
begin
|
195
|
-
@graph = Koala::Facebook::API.new( accessToken )
|
196
|
-
@me = @graph.get_object( 'me', :fields => 'email' )
|
197
|
-
@current_user = User.find_or_create_by :email => @me['email']
|
198
|
-
@oauth = Koala::Facebook::OAuth.new( FB[params['domain']][:app], FB[params['domain']][:secret] )
|
199
|
-
get_token = get_long_token( accessToken )
|
200
|
-
@long_lived_token = get_token['access_token']
|
201
|
-
|
202
|
-
begin
|
203
|
-
@current_profile = IshModels::UserProfile.find_by :email => @me['email']
|
204
|
-
@current_profile.update_attributes({ :fb_access_token => @long_lived_token,
|
205
|
-
:fb_long_access_token => @long_lived_token,
|
206
|
-
:fb_expires_in => get_token['expires_in']
|
207
|
-
})
|
208
|
-
rescue Mongoid::Errors::DocumentNotFound
|
209
|
-
@current_profile = IshModels::UserProfile.create :user => @current_user, :email => @me['email'],
|
210
|
-
:fb_access_token => @long_lived_token,
|
211
|
-
:fb_long_access_token => @long_lived_token,
|
212
|
-
:fb_expires_in => get_token['expires_in'],
|
213
|
-
:fb_id => params[:id],
|
214
|
-
:name => params[:name],
|
215
|
-
:signed_request => params[:signedRequest]
|
216
|
-
end
|
217
|
-
@current_user.reload
|
218
|
-
rescue Koala::Facebook::AuthenticationError => e
|
219
|
-
render :json => { :status => :not_ok, :errors => "Probably expired token: #{accessToken}" }
|
220
|
-
return
|
221
|
-
end
|
222
|
-
else
|
223
|
-
@current_user = current_user if Rails.env.test?
|
224
|
-
end
|
225
|
-
@current_profile = @current_user.profile
|
226
|
-
@current_order = @current_profile.current_order
|
227
|
-
# orders.where( :submitted_at => nil ).first || ::CoTailors::Order.new( :profile_id => @current_profile.id )
|
228
|
-
end
|
229
|
-
|
230
|
-
def get_long_token accessToken
|
231
|
-
url = "https://graph.facebook.com/oauth/access_token?grant_type=fb_exchange_token&" +
|
232
|
-
"client_id=#{FB[params['domain']][:app]}&client_secret=#{FB[params['domain']][:secret]}&fb_exchange_token=#{accessToken}"
|
233
|
-
result = HTTParty.get url
|
234
|
-
token = JSON.parse result.body
|
235
|
-
return token # ['access_token']
|
236
|
-
end
|
237
|
-
|
238
|
-
def current_ability
|
239
|
-
# @current_user ||= User.new({ profile: ::IshModels::UserProfile.new })
|
240
|
-
@current_ability ||= Ishapi::Ability.new( current_user )
|
241
|
-
end
|
242
|
-
|
243
|
-
def puts! a, b=''
|
244
|
-
puts "+++ +++ #{b}"
|
245
|
-
puts a.inspect
|
246
|
-
end
|
247
|
-
|
248
|
-
# jwt
|
249
|
-
def check_jwt
|
250
|
-
begin
|
251
|
-
decoded = decode(params[:jwt_token])
|
252
|
-
@current_user = User.find decoded['user_id']
|
253
|
-
rescue JWT::ExpiredSignature
|
254
|
-
Rails.logger.info("JWT::ExpiredSignature")
|
255
|
-
rescue JWT::DecodeError
|
256
|
-
Rails.logger.info("JWT::DecodeError")
|
257
|
-
end
|
258
|
-
# @current_user ||= User.new
|
259
|
-
current_ability
|
260
|
-
end
|
261
|
-
|
262
|
-
# jwt
|
263
|
-
def encode(payload, exp = 2.hours.from_now)
|
264
|
-
payload[:exp] = exp.to_i
|
265
|
-
JWT.encode(payload, Rails.application.secrets.secret_key_base.to_s)
|
266
|
-
end
|
267
|
-
|
268
|
-
# jwt
|
269
|
-
def decode(token)
|
270
|
-
decoded = JWT.decode(token, Rails.application.secrets.secret_key_base.to_s)[0]
|
271
|
-
HashWithIndifferentAccess.new decoded
|
272
|
-
end
|
273
|
-
|
274
|
-
end
|
275
|
-
end
|
@@ -1,62 +0,0 @@
|
|
1
|
-
require_dependency "ishapi/application_controller"
|
2
|
-
|
3
|
-
module Ishapi
|
4
|
-
class ArticlesController < ApplicationController
|
5
|
-
before_action :set_article, only: [:show, :edit, :update, :destroy]
|
6
|
-
|
7
|
-
# GET /articles
|
8
|
-
def index
|
9
|
-
@articles = Article.all
|
10
|
-
end
|
11
|
-
|
12
|
-
# GET /articles/1
|
13
|
-
def show
|
14
|
-
end
|
15
|
-
|
16
|
-
# GET /articles/new
|
17
|
-
def new
|
18
|
-
@article = Article.new
|
19
|
-
end
|
20
|
-
|
21
|
-
# GET /articles/1/edit
|
22
|
-
def edit
|
23
|
-
end
|
24
|
-
|
25
|
-
# POST /articles
|
26
|
-
def create
|
27
|
-
@article = Article.new(article_params)
|
28
|
-
|
29
|
-
if @article.save
|
30
|
-
redirect_to @article, notice: 'Article was successfully created.'
|
31
|
-
else
|
32
|
-
render :new
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
# PATCH/PUT /articles/1
|
37
|
-
def update
|
38
|
-
if @article.update(article_params)
|
39
|
-
redirect_to @article, notice: 'Article was successfully updated.'
|
40
|
-
else
|
41
|
-
render :edit
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
# DELETE /articles/1
|
46
|
-
def destroy
|
47
|
-
@article.destroy
|
48
|
-
redirect_to articles_url, notice: 'Article was successfully destroyed.'
|
49
|
-
end
|
50
|
-
|
51
|
-
private
|
52
|
-
# Use callbacks to share common setup or constraints between actions.
|
53
|
-
def set_article
|
54
|
-
@article = Article.find(params[:id])
|
55
|
-
end
|
56
|
-
|
57
|
-
# Only allow a trusted parameter "white list" through.
|
58
|
-
def article_params
|
59
|
-
params.require(:article).permit(:title, :text)
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
require_dependency "ishapi/application_controller"
|
2
|
-
|
3
|
-
module Ishapi
|
4
|
-
class CitiesController < Ishapi::ApplicationController
|
5
|
-
protect_from_forgery :prepend => true, :with => :exception
|
6
|
-
layout :false
|
7
|
-
|
8
|
-
check_authorization
|
9
|
-
skip_before_action :verify_authenticity_token
|
10
|
-
before_action :set_current_ability
|
11
|
-
|
12
|
-
def index
|
13
|
-
authorize! :index, City
|
14
|
-
@cities = City.all
|
15
|
-
end
|
16
|
-
|
17
|
-
def features
|
18
|
-
authorize! :index, City
|
19
|
-
@cities = City.where( :is_feature => true )
|
20
|
-
end
|
21
|
-
|
22
|
-
def show
|
23
|
-
@city = City.find_by :cityname => params[:cityname]
|
24
|
-
authorize! :show, @city
|
25
|
-
end
|
26
|
-
|
27
|
-
|
28
|
-
private
|
29
|
-
|
30
|
-
def set_current_ability
|
31
|
-
@current_ability ||= ::Ishapi::Ability.new( User.new )
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|
35
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
require_dependency "ishapi/application_controller"
|
2
|
-
module Ishapi
|
3
|
-
class EventsController < ApplicationController
|
4
|
-
|
5
|
-
def index
|
6
|
-
@events = Event.all
|
7
|
-
authorize! :index, Event
|
8
|
-
if params[:cityname]
|
9
|
-
city = City.find_by :cityname => params[:cityname]
|
10
|
-
@events = @events.where( :city => city )
|
11
|
-
end
|
12
|
-
@events = @events.page( params[:events_page] ).per( 10 )
|
13
|
-
end
|
14
|
-
|
15
|
-
def show
|
16
|
-
@event = ::Event.unscoped.find_by :eventname => params[:eventname]
|
17
|
-
authorize! :show, @event
|
18
|
-
end
|
19
|
-
|
20
|
-
end
|
21
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
require_dependency "ishapi/application_controller"
|
2
|
-
|
3
|
-
module Ishapi
|
4
|
-
class MeasurementsController < ApplicationController
|
5
|
-
before_action :check_profile, :only => [ :update ]
|
6
|
-
|
7
|
-
def update
|
8
|
-
authorize! :update_measurements, CoTailors::Order
|
9
|
-
flag = @current_profile.measurement.update_attributes params[:measurement].permit( CoTailors::Order::MEASUREMENT_PARAMS )
|
10
|
-
|
11
|
-
# byebug
|
12
|
-
|
13
|
-
if flag
|
14
|
-
render :json => { :status => :ok }
|
15
|
-
else
|
16
|
-
render :json => { :status => :not_ok, :error => @current_profile.measurement.errors.messages }
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
#
|
21
|
-
# private
|
22
|
-
#
|
23
|
-
private
|
24
|
-
|
25
|
-
end
|
26
|
-
end
|
@@ -1,55 +0,0 @@
|
|
1
|
-
require_dependency "ishapi/application_controller"
|
2
|
-
|
3
|
-
module Ishapi
|
4
|
-
class SitesController < ApplicationController
|
5
|
-
|
6
|
-
before_action :check_profile, only: %i| show |
|
7
|
-
|
8
|
-
def index
|
9
|
-
authorize! :index, ::Site
|
10
|
-
@sites = ::Site.all
|
11
|
-
end
|
12
|
-
|
13
|
-
def show
|
14
|
-
if params[:domain].include?(".json")
|
15
|
-
domain = params[:domain][0...-5]
|
16
|
-
else
|
17
|
-
domain = params[:domain]
|
18
|
-
end
|
19
|
-
@site = ::Site.find_by(domain: domain, lang: :en)
|
20
|
-
authorize! :show, @site
|
21
|
-
|
22
|
-
if @site.is_private
|
23
|
-
if !params[:accessToken]
|
24
|
-
render :json => { :status => :unauthorized}, :status => :unauthorized
|
25
|
-
return
|
26
|
-
end
|
27
|
-
access_token = params[:accessToken]
|
28
|
-
@graph = Koala::Facebook::API.new( access_token, ::FB[@site.domain][:secret] )
|
29
|
-
@profile = @graph.get_object "me", :fields => 'email'
|
30
|
-
if @site.private_user_emails.include?( @profile['email'] )
|
31
|
-
;
|
32
|
-
else
|
33
|
-
render :json => { :status => :unauthorized}, :status => :unauthorized
|
34
|
-
render :status => :unauthorized
|
35
|
-
return
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
@galleries = @site.galleries.limit( 10 ) # @TODO: paginate
|
40
|
-
@newsitems = @site.newsitems.limit( @site.newsitems_per_page ) # @TODO: paginate
|
41
|
-
@reports = @site.reports.limit( 10 ) # @TODO: paginate
|
42
|
-
@langs = ::Site.where( :domain => domain ).map( &:lang )
|
43
|
-
@feature_tags = @site.tags.where( :is_feature => true )
|
44
|
-
end
|
45
|
-
|
46
|
-
private
|
47
|
-
|
48
|
-
# # jwt
|
49
|
-
# def decode(token)
|
50
|
-
# decoded = JWT.decode(token, Rails.application.secrets.secret_key_base.to_s)[0]
|
51
|
-
# HashWithIndifferentAccess.new decoded
|
52
|
-
# end
|
53
|
-
|
54
|
-
end
|
55
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
require_dependency "ishapi/application_controller"
|
2
|
-
module Ishapi
|
3
|
-
class TagsController < ApplicationController
|
4
|
-
|
5
|
-
def index
|
6
|
-
authorize! :index, Tag
|
7
|
-
@tags = Tag.all
|
8
|
-
if params[:domain]
|
9
|
-
@site = Site.find_by( :domain => params[:domain], :lang => :en )
|
10
|
-
@tags = @tags.where( :site => @site )
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
def show
|
15
|
-
begin
|
16
|
-
@tag = Tag.find_by( slug: params[:slug] )
|
17
|
-
rescue Mongoid::Errors::DocumentNotFound
|
18
|
-
@tag = Tag.find params[:slug]
|
19
|
-
end
|
20
|
-
authorize! :show, @tag
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
24
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
require_dependency "ishapi/application_controller"
|
2
|
-
module Ishapi
|
3
|
-
class VenuesController < ApplicationController
|
4
|
-
|
5
|
-
def index
|
6
|
-
authorize! :index, ::Venue
|
7
|
-
@venues = ::Venue.all
|
8
|
-
if params[:cityname]
|
9
|
-
city = City.find_by :cityname => params[:cityname]
|
10
|
-
@venues = @venues.where( :city => city )
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
def show
|
15
|
-
@venue = Venue.find_by :slug => params[:venuename]
|
16
|
-
authorize! :show, @venue
|
17
|
-
end
|
18
|
-
|
19
|
-
end
|
20
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
<%= form_with(model: article, local: true) do |form| %>
|
2
|
-
<% if article.errors.any? %>
|
3
|
-
<div id="error_explanation">
|
4
|
-
<h2><%= pluralize(article.errors.count, "error") %> prohibited this article from being saved:</h2>
|
5
|
-
|
6
|
-
<ul>
|
7
|
-
<% article.errors.full_messages.each do |message| %>
|
8
|
-
<li><%= message %></li>
|
9
|
-
<% end %>
|
10
|
-
</ul>
|
11
|
-
</div>
|
12
|
-
<% end %>
|
13
|
-
|
14
|
-
<div class="field">
|
15
|
-
<%= form.label :title %>
|
16
|
-
<%= form.text_field :title, id: :article_title %>
|
17
|
-
</div>
|
18
|
-
|
19
|
-
<div class="field">
|
20
|
-
<%= form.label :text %>
|
21
|
-
<%= form.text_area :text, id: :article_text %>
|
22
|
-
</div>
|
23
|
-
|
24
|
-
<div class="actions">
|
25
|
-
<%= form.submit %>
|
26
|
-
</div>
|
27
|
-
<% end %>
|
@@ -1,29 +0,0 @@
|
|
1
|
-
<p id="notice"><%= notice %></p>
|
2
|
-
|
3
|
-
<h1>Articles</h1>
|
4
|
-
|
5
|
-
<table>
|
6
|
-
<thead>
|
7
|
-
<tr>
|
8
|
-
<th>Title</th>
|
9
|
-
<th>Text</th>
|
10
|
-
<th colspan="3"></th>
|
11
|
-
</tr>
|
12
|
-
</thead>
|
13
|
-
|
14
|
-
<tbody>
|
15
|
-
<% @articles.each do |article| %>
|
16
|
-
<tr>
|
17
|
-
<td><%= article.title %></td>
|
18
|
-
<td><%= article.text %></td>
|
19
|
-
<td><%= link_to 'Show', article %></td>
|
20
|
-
<td><%= link_to 'Edit', edit_article_path(article) %></td>
|
21
|
-
<td><%= link_to 'Destroy', article, method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
22
|
-
</tr>
|
23
|
-
<% end %>
|
24
|
-
</tbody>
|
25
|
-
</table>
|
26
|
-
|
27
|
-
<br>
|
28
|
-
|
29
|
-
<%= link_to 'New Article', new_article_path %>
|