-
Notifications
You must be signed in to change notification settings - Fork 3
/
app.rb
710 lines (597 loc) · 22.7 KB
/
app.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
begin
print 'Loading libraries... '
require 'colorize'
require 'sinatra'
require 'mysaas'
require 'lib/stubs'
puts 'done'.green
# --------------------------------------------------------------------------------------------------------------------------------------------------------------------
# Parsing command line parameters.
#
print 'Parsing command line parameters... '
parser = BlackStack::SimpleCommandLineParser.new(
:description => 'This command will launch a Sinatra-based BlackStack webserver.',
:configuration => [{
:name=>'port',
:mandatory=>false,
:description=>'Listening port.',
:type=>BlackStack::SimpleCommandLineParser::INT,
:default => 3000,
}, {
:name=>'config',
:mandatory=>false,
:description=>'Name of the configuration file.',
:type=>BlackStack::SimpleCommandLineParser::STRING,
:default => 'config',
}]
)
puts 'done'.green
#
print 'Loading configuration... '
require parser.value('config')
puts 'done'.green
print 'Loading version information... '
require 'version'
puts 'done'.green
print 'Connecting database... '
DB = BlackStack.db_connect
puts 'done'.green
print 'Loading models... '
require 'lib/skeletons'
puts 'done'.green
print 'Loading helpers... '
# helper to redirect with the params
# TODO: move this to a helper
def redirect2(url, params)
redirect url + '?' + params.reject { |key, value| key=='agent' }.map{|key, value| "#{key}=#{value}"}.join("&")
end
def nav1(name1, beta=false)
login = BlackStack::MySaaS::Login.where(:id=>session["login.id"]).first
user = BlackStack::MySaaS::User.where(:id=>login.id_user).first
ret =
"<p>" +
"<a class='simple' href='/'><b>#{CGI.escapeHTML(user.account.name.encode_html)}</b></a>" +
" <i class='icon-chevron-right'></i> " +
CGI.escapeHTML(name1)
ret += " <span class='badge badge-mini badge-important'>beta</span>" if beta
ret += "</p>"
end
def nav2(name1, url1, name2)
login = BlackStack::MySaaS::Login.where(:id=>session["login.id"]).first
user = BlackStack::MySaaS::User.where(:id=>login.id_user).first
"<p>" +
"<a class='simple' href='/'><b>#{user.account.name.encode_html}</b></a>" +
" <i class='icon-chevron-right'></i> " +
"<a class='simple' href='#{url1}'>#{CGI.escapeHTML(name1)}</a>" +
" <i class='icon-chevron-right'></i> " +
CGI.escapeHTML(name2) +
"</p>"
end
def nav3(name1, url1, name2, url2, name3)
login = BlackStack::MySaaS::Login.where(:id=>session["login.id"]).first
user = BlackStack::MySaaS::User.where(:id=>login.id_user).first
"<p>" +
"<a class='simple' href='/'><b>#{user.account.name.encode_html}</b></a>" +
" <i class='icon-chevron-right'></i> " +
"<a class='simple' href='#{url1}'>#{CGI.escapeHTML(name1)}</a>" +
" <i class='icon-chevron-right'></i> " +
"<a class='simple' href='#{url2}'>#{CGI.escapeHTML(name2)}</a>" +
" <i class='icon-chevron-right'></i> " +
name3 +
"</p>"
end
def nav4(name1, url1, name2, url2, name3, url3, name4)
login = BlackStack::MySaaS::Login.where(:id=>session["login.id"]).first
user = BlackStack::MySaaS::User.where(:id=>login.id_user).first
"<p>" +
"<a class='simple' href='/'><b>#{user.account.name.encode_html}</b></a>" +
" <i class='icon-chevron-right'></i> " +
"<a class='simple' href='#{url1}'>#{CGI.escapeHTML(name1)}</a>" +
" <i class='icon-chevron-right'></i> " +
"<a class='simple' href='#{url2}'>#{CGI.escapeHTML(name2)}</a>" +
" <i class='icon-chevron-right'></i> " +
"<a class='simple' href='#{url3}'>#{CGI.escapeHTML(name3)}</a>" +
" <i class='icon-chevron-right'></i> " +
name4 +
"</p>"
end
def nav5(name1, url1, name2, url2, name3, url3, name4, url4, name5)
login = BlackStack::MySaaS::Login.where(:id=>session["login.id"]).first
user = BlackStack::MySaaS::User.where(:id=>login.id_user).first
"<p>" +
"<a class='simple' href='/'><b>#{user.account.name.encode_html}</b></a>" +
" <i class='icon-chevron-right'></i> " +
"<a class='simple' href='#{url1}'>#{CGI.escapeHTML(name1)}</a>" +
" <i class='icon-chevron-right'></i> " +
"<a class='simple' href='#{url2}'>#{CGI.escapeHTML(name2)}</a>" +
" <i class='icon-chevron-right'></i> " +
"<a class='simple' href='#{url3}'>#{CGI.escapeHTML(name3)}</a>" +
" <i class='icon-chevron-right'></i> " +
"<a class='simple' href='#{url4}'>#{CGI.escapeHTML(name4)}</a>" +
" <i class='icon-chevron-right'></i> " +
name5 +
"</p>"
end
def nav6(name1, url1, name2, url2, name3, url3, name4, url4, name5, url5, name6)
login = BlackStack::MySaaS::Login.where(:id=>session["login.id"]).first
user = BlackStack::MySaaS::User.where(:id=>login.id_user).first
"<p>" +
"<a class='simple' href='/'><b>#{user.account.name.encode_html}</b></a>" +
" <i class='icon-chevron-right'></i> " +
"<a class='simple' href='#{url1}'>#{CGI.escapeHTML(name1)}</a>" +
" <i class='icon-chevron-right'></i> " +
"<a class='simple' href='#{url2}'>#{CGI.escapeHTML(name2)}</a>" +
" <i class='icon-chevron-right'></i> " +
"<a class='simple' href='#{url3}'>#{CGI.escapeHTML(name3)}</a>" +
" <i class='icon-chevron-right'></i> " +
"<a class='simple' href='#{url4}'>#{CGI.escapeHTML(name4)}</a>" +
" <i class='icon-chevron-right'></i> " +
"<a class='simple' href='#{url5}'>#{CGI.escapeHTML(name5)}</a>" +
" <i class='icon-chevron-right'></i> " +
name6 +
"</p>"
end
puts 'done'.green
# --------------------------------------------------------------------------------------------------------------------------------------------------------------------
# Buffering some tables required in some screens.
#
print 'Buffering timezone table... '
TIMEZONES = BlackStack::MySaaS::Timezone.order(:offset, :short_description).all
puts 'done'.green + " (#{TIMEZONES.size.to_s.blue} records)"
print 'Buffering country table... '
COUNTRIES = BlackStack::MySaaS::Country.order(:name).all
puts 'done'.green + " (#{COUNTRIES.size.to_s.blue} records)"
# --------------------------------------------------------------------------------------------------------------------------------------------------------------------
# Run webserver.
#
puts '
/\ "-./ \ /\ \_\ \ /\ ___\ /\ __ \ /\ __ \ /\ ___\
\ \ \-./\ \ \ \____ \ \ \___ \ \ \ __ \ \ \ __ \ \ \___ \
\ \_\ \ \_\ \/\_____\ \/\_____\ \ \_\ \_\ \ \_\ \_\ \/\_____\
\/_/ \/_/ \/_____/ \/_____/ \/_/\/_/ \/_/\/_/ \/_____/
Welcome to MySaaS '+MYSAAS_VERSION.green+'.
---> '+'https://github.com/leandrosardi/my.saas'.blue+' <---
Sandbox Environment: '+(BlackStack.sandbox? ? 'yes'.green : 'no'.red)+'.
'
#print "Saving PID... "
#File.open('./app.pid', 'w') { |f| f.write(Process.pid) }
#puts "done."
print 'Loading extensions configuration... '
# include the libraries of the extensions
# reference: https://github.com/leandrosardi/mysaas/issues/33
BlackStack::Extensions.extensions.each { |e|
require "extensions/#{e.name.downcase}/main"
}
puts 'done'.green
print 'Loading extensions models... '
# Load skeleton classes
BlackStack::Extensions.extensions.each { |e|
require "extensions/#{e.name.downcase}/lib/skeletons"
}
puts 'done'.green
print 'Setting up Sinatra... '
PORT = parser.value("port")
configure { set :server, :puma }
set :bind, '0.0.0.0'
set :port, PORT
enable :sessions
enable :static
configure do
enable :cross_origin
end
before do
headers 'Access-Control-Allow-Origin' => '*',
'Access-Control-Allow-Methods' => ['OPTIONS', 'GET', 'POST']
end
set :protection, false
# Setting the root of views and public folders in the `~/code` folder in order to have access to extensions.
# reference: https://stackoverflow.com/questions/69028408/change-sinatra-views-directory-location
set :root, File.dirname(__FILE__)
set :views, Proc.new { File.join(root) }
# Setting the public directory of MySaaS, and the public directories of all the extensions.
# Public folder is where we store the files who are referenced from HTML (images, CSS, JS, fonts).
# reference: https://stackoverflow.com/questions/18966318/sinatra-multiple-public-directories
# reference: https://github.com/leandrosardi/mysaas/issues/33
use Rack::TryStatic, :root => 'public', :urls => %w[/]
BlackStack::Extensions.extensions.each { |e|
use Rack::TryStatic, :root => "extensions/#{e.name.downcase}/public", :urls => %w[/]
}
# page not found redirection
not_found do
if !logged_in?
redirect '/'
else
redirect '/404'
end
#redirect "/404?url=#{request.env['rack.url_scheme']}://#{request.env['HTTP_HOST']}#{CGI::escape(request.path_info)}"
end
# unhandled exception redirectiopn
error do
max_lenght = 8000
s = "message=#{CGI.escape(env['sinatra.error'].to_s)}&"
s += "backtrace_size=#{CGI.escape(env['sinatra.error'].backtrace.size.to_s)}&"
i = 0
env['sinatra.error'].backtrace.each { |a|
a = "backtrace[#{i.to_s}]=#{CGI.escape(a.to_s)}&"
and_more = "backtrace[#{i.to_s}]=..."
if (s+a).size > max_lenght - and_more.size
s += and_more
break
else
s += a
end
i += 1
}
redirect "/500?#{s}"
end
# use this modifier for internal pages, who cannot be shown if there IS NOT a logged-in user
# condition: if there is not authenticated user on the platform, then redirect to the signup page
set(:auth) do |*roles|
condition do
if !logged_in?
# remember the internal page I have to return to after login or signup
session['redirect_on_success'] = "#{request.path_info.to_s}?#{request.query_string.to_s}"
redirect "/login"
elsif unavailable?
redirect "/unavailable"
else
@login = BlackStack::MySaaS::Login.where(:id=>session["login.id"]).first
@service = @login.user.preference('service', SERVICE_NAME.to_s, params[:service])
end
end
end
# use this modifier for external pages, who cannot be shown if there IS a logged-in user
# condition: if there is not authenticated user on the platform, then redirect to the / page
set(:noauth) do |*roles|
condition do
if logged_in?
redirect "/"
elsif unavailable?
redirect "/unavailable"
end
end
end
# condition: if there is not authenticated user on the platform
# it must either be a sysadmin or has a subecription (active or not);
# Otherwise, redirect to /offer
set(:premium) do |*roles|
condition do
if !logged_in?
redirect "/plans"
else
a = BlackStack::I2P::Account.where(:id=>@login.user.id_account).first
if !a.premium?
redirect "/plans?err=You+must+have+a+premium+subscription+to+unlock+that+feature."
end
end
end
end
# condition: only super-user can access this access point
# use this condition right after :api_key
set(:su) do |*roles|
condition do
@return_message = {}
@return_message[:status] = 'success'
# this is already proccessed in the :api_key condition
#@body = JSON.parse(request.body.read)
validation_api_key = @body['api_key'].to_s.to_guid.downcase
if validation_api_key != MYSAAS_API_KEY.to_s.to_guid.downcase
# libero recursos
DB.disconnect
GC.start
@return_message[:status] = "api_key of the super-user only is allowed for this access point."
@return_message[:value] = ""
halt @return_message.to_json
end
end
end
# condition: api_key parameter is required too for the access points
set(:api_key) do |*roles|
condition do
@return_message = {}
@return_message[:status] = 'success'
# validate: the pages using the :api_key condition must work as post only.
if request.request_method != 'POST'
@return_message[:status] = 'Pages with an `api_key` parameter are only available for POST requests.'
@return_message[:value] = ""
halt @return_message.to_json
end
@body = JSON.parse(request.body.read)
if [email protected]_key?('api_key')
# libero recursos
DB.disconnect
GC.start
@return_message[:status] = "api_key is required on #{@body.to_s}"
@return_message[:value] = ""
halt @return_message.to_json
end
if !@body['api_key'].guid?
# libero recursos
DB.disconnect
GC.start
@return_message[:status] = "Invalid api_key (#{@body['api_key']}))"
@return_message[:value] = ""
halt @return_message.to_json
end
validation_api_key = @body['api_key'].to_guid.downcase
@account = BlackStack::MySaaS::Account.where(:api_key => validation_api_key).first
if @account.nil?
# libero recursos
DB.disconnect
GC.start
#
@return_message[:status] = 'Api_key not found'
@return_message[:value] = ""
halt @return_message.to_json
end
end
end
puts 'done'.green
# --------------------------------------------------------------------------------------------------------------------------------------------------------------------
# External pages: pages that don't require login
print 'Setting up entries of external pages... '
get '/', :agent => /(.*)/ do
redirect BlackStack::Funnel.url_root(@login, 'funnels.main')
end
get '/404', :agent => /(.*)/ do
erb :'views/404', :layout => :'/views/layouts/public'
end
get '/500', :agent => /(.*)/ do
erb :'views/500', :layout => :'/views/layouts/public'
end
get '/demo' do
erb :'views/demo', :layout => :'/views/layouts/public'
end
get '/unavailable' do
erb :'views/unavailable', :layout => :'/views/layouts/public'
end
get '/login', :noauth => true, :agent => /(.*)/ do
erb :'views/login', :layout => :'/views/layouts/public'
end
post '/login' do
erb :'views/filter_login'
end
get '/filter_login' do
erb :'views/filter_login'
end
get '/signup', :noauth => true, :agent => /(.*)/ do
erb :'views/signup', :layout => :'/views/layouts/public'
end
post '/signup' do
erb :'views/filter_signup'
end
get '/confirm/:nid' do
erb :'views/filter_confirm'
end
get '/logout' do
erb :'views/filter_logout'
end
get '/recover', :noauth => true, :agent => /(.*)/ do
erb :'views/recover', :layout => :'/views/layouts/public'
end
post '/recover' do
erb :'views/filter_recover'
end
get '/reset/:nid', :agent => /(.*)/ do
erb :'views/reset', :layout => :'/views/layouts/public'
end
post '/reset' do
erb :'views/filter_reset'
end
# --------------------------------------------------------------------------------------------------------------------------------------------------------------------
# Funnel
#
get '/offer', :auth => true, :agent => /(.*)/ do
erb :'views/offer', :layout => :'/views/layouts/public'
end
get '/plans', :auth => true, :agent => /(.*)/ do
erb :'views/plans', :layout => :'/views/layouts/public'
end
puts 'done'.green
# --------------------------------------------------------------------------------------------------------------------------------------------------------------------
# User welcome
print 'Setting up entries of internal pages... '
get '/survey', :auth => true, :agent => /(.*)/ do
erb :'views/survey', :layout => :'/views/layouts/core'
end
get '/welcome', :auth => true, :agent => /(.*)/ do
erb :'views/welcome', :layout => :'/views/layouts/core'
end
get '/ajax/welcome', :auth => true, :agent => /(.*)/ do
erb :'views/ajax/welcome'
end
get '/new', :auth => true, :agent => /(.*)/ do
erb :'views/search', :layout => :'/views/layouts/core'
end
get '/edit/:sid', :auth => true, :agent => /(.*)/ do
erb :'views/search', :layout => :'/views/layouts/core'
end
get '/delete/:sid', :auth => true, :agent => /(.*)/ do
erb :'views/delete'
end
post '/filter_edit', :auth => true, :agent => /(.*)/ do
erb :'views/filter_edit'
end
post '/filter_new', :auth => true, :agent => /(.*)/ do
erb :'views/filter_new'
end
get '/filter_copy', :auth => true, :agent => /(.*)/ do
erb :'views/filter_copy'
end
get '/filter_delete', :auth => true, :agent => /(.*)/ do
erb :'views/filter_delete'
end
get '/filter_pause', :auth => true, :agent => /(.*)/ do
erb :'views/filter_pause'
end
get '/filter_play', :auth => true, :agent => /(.*)/ do
erb :'views/filter_play'
end
# --------------------------------------------------------------------------------------------------------------------------------------------------------------------
# Configuration screens
# main configuration screen
get '/settings', :auth => true do
redirect '/settings/dashboard'
end
get '/settings/', :auth => true do
redirect '/settings/dashboard'
end
get '/settings/dashboard', :auth => true, :agent => /(.*)/ do
erb :'views/settings/dashboard', :layout => :'/views/layouts/core'
end
# account information
get '/settings/account', :auth => true, :agent => /(.*)/ do
erb :'views/settings/account', :layout => :'/views/layouts/core'
end
post '/settings/filter_account', :auth => true do
erb :'views/settings/filter_account'
end
=begin
#
# UNDER CONSTRUCTION
#
# white label configuration
get '/settings/whitelabel', :auth => true, :agent => /(.*)/ do
erb :'views/settings/whitelabel', :layout => :'/views/layouts/core'
end
post '/settings/filter_whitelabel', :auth => true do
erb :'views/settings/filter_whitelabel'
end
=end
# change password
get '/settings/password', :auth => true, :agent => /(.*)/ do
erb :'views/settings/password', :layout => :'/views/layouts/core'
end
post '/settings/filter_password', :auth => true do
erb :'views/settings/filter_password'
end
# change password
get '/settings/apikey', :auth => true, :agent => /(.*)/ do
erb :'views/settings/apikey', :layout => :'/views/layouts/core'
end
post '/settings/filter_apikey', :auth => true do
erb :'views/settings/filter_apikey'
end
## users management screen
get '/settings/users', :auth => true, :agent => /(.*)/ do
erb :'views/settings/users', :layout => :'/views/layouts/core'
end
get '/settings/filter_users_add', :auth => true do
erb :'views/settings/filter_users_add'
end
post '/settings/filter_users_add', :auth => true do
erb :'views/settings/filter_users_add'
end
get '/settings/filter_users_delete', :auth => true do
erb :'views/settings/filter_users_delete'
end
post '/settings/filter_users_delete', :auth => true do
erb :'views/settings/filter_users_delete'
end
get '/settings/filter_users_update', :auth => true do
erb :'views/settings/filter_users_update'
end
post '/settings/filter_users_update', :auth => true do
erb :'views/settings/filter_users_update'
end
get '/settings/filter_users_send_confirmation_email', :auth => true do
erb :'views/settings/filter_users_send_confirmation_email'
end
post '/settings/filter_users_send_confirmation_email', :auth => true do
erb :'views/settings/filter_users_send_confirmation_email'
end
get '/settings/filter_users_set_account_owner', :auth => true do
erb :'views/settings/filter_users_set_account_owner'
end
post '/settings/filter_users_set_account_owner', :auth => true do
erb :'views/settings/filter_users_set_account_owner'
end
puts 'done'.green
# --------------------------------------------------------------------------------------------------------------------------------------------------------------------
# API access points
print 'Setting up entries of API access points... '
# ping
get '/api1.0/ping.json', :api_key => true do
erb :'views/api1.0/ping'
end
post '/api1.0/ping.json', :api_key => true do
erb :'views/api1.0/ping'
end
# Standard MySaaS API - URL resolution for subaccounts
#
post "/api1.0/resolve/get.json", :api_key => true do
erb :"views/api1.0/resolve/get"
end
# Standard MySaaS API - Managing subaccounts
#
post "/api1.0/subaccount/get.json", :api_key => true, :su => true do
erb :"views/api1.0/subaccount/get"
end
post "/api1.0/subaccount/create.json", :api_key => true, :su => true do
erb :"views/api1.0/subaccount/create"
end
post "/api1.0/subaccount/delete.json", :api_key => true, :su => true do
erb :"views/api1.0/subaccount/delete"
end
# Standard MySaaS API - Getting account attribute
#
post '/api1.0/account_value.json', :api_key => true do
erb :'views/api1.0/account_value'
end
# Standard MySaaS API - Managing objects
#
post "/api1.0/:object/page.json", :api_key => true do
erb :"views/api1.0/page"
end
post "/api1.0/:object/count.json", :api_key => true do
erb :"views/api1.0/count"
end
post "/api1.0/:object/get.json", :api_key => true do
erb :"views/api1.0/get"
end
post "/api1.0/:object/insert.json", :api_key => true do
erb :"views/api1.0/insert"
end
post "/api1.0/:object/update.json", :api_key => true do
erb :"views/api1.0/update"
end
post "/api1.0/:object/update_status.json", :api_key => true do
erb :"views/api1.0/update_status"
end
post "/api1.0/:object/upsert.json", :api_key => true do
erb :"views/api1.0/upsert"
end
# notifications
get '/api1.0/notifications/open.json' do
erb :'views/api1.0/notifications/open'
end
post '/api1.0/notifications/open.json' do
erb :'views/api1.0/notifications/open'
end
get '/api1.0/notifications/click.json' do
erb :'views/api1.0/notifications/click'
end
post '/api1.0/notifications/click.json' do
erb :'views/api1.0/notifications/click'
end
puts 'done'.green
# --------------------------------------------------------------------------------------------------------------------------------------------------------------------
# Require the app.rb file of each one of the extensions.
# reference: https://github.com/leandrosardi/mysaas/issues/33
print 'Setting up extensions entries... '
BlackStack::Extensions.extensions.each { |e|
require "extensions/#{e.name.downcase}/app.rb"
}
puts 'done'.green
# --------------------------------------------------------------------------------------------------------------------------------------------------------------------
# adding storage sub-folders
# DEPRECATED
#BlackStack::Extensions.add_storage_subfolders
rescue LoadError => e
STDERR.puts "Failed to load required file: #{e.message}".red
# You can add additional error handling here, such as exiting the script
exit(2)
rescue => e
STDERR.puts e.to_console.red
exit(1)
end