pixelforce_recipes 3.9.2 → 4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/app/controllers/admin/api/admin_base_controller.rb +97 -0
- data/app/controllers/admin/api/v1/app_versions_controller.rb +28 -0
- data/app/controllers/admin/api/v1/available_modules_controller.rb +22 -0
- data/app/controllers/admin/api/v1/users_controller.rb +66 -0
- data/app/controllers/api/base_controller.rb +74 -0
- data/app/controllers/api/v1/health_check_controller.rb +11 -0
- data/app/controllers/application_controller.rb +10 -0
- data/app/controllers/auth/passwords_controller.rb +7 -0
- data/app/controllers/concerns/.keep +0 -0
- data/app/controllers/concerns/exception_handler.rb +54 -0
- data/app/controllers/concerns/request_header_handler.rb +35 -0
- data/app/controllers/concerns/response_handler.rb +31 -0
- data/app/controllers/pages_controller.rb +36 -0
- data/app/controllers/users_controller.rb +3 -0
- data/lib/pixelforce_recipes/engine.rb +5 -0
- data/lib/pixelforce_recipes/railtie.rb +4 -0
- data/lib/pixelforce_recipes/version.rb +1 -1
- data/lib/pixelforce_recipes.rb +7 -9
- data/pixelforce_recipes.gemspec +1 -1
- data/recipes.rb +4 -0
- metadata +46 -36
- data/lib/pixelforce_recipes/legacy_recipes/base.rb +0 -24
- data/lib/pixelforce_recipes/legacy_recipes/logrotate.rb +0 -14
- data/lib/pixelforce_recipes/legacy_recipes/puma.rb +0 -26
- data/lib/pixelforce_recipes/legacy_recipes/resque.rb +0 -22
- data/lib/pixelforce_recipes/legacy_recipes/resque_scheduler.rb +0 -22
- data/lib/pixelforce_recipes/legacy_recipes/sidekiq.rb +0 -23
- data/lib/pixelforce_recipes/legacy_recipes/unicorn.rb +0 -29
- /data/lib/{pixelforce_recipes/capistrano_3_recipes → recipes/capistrano_recipes}/base.rb +0 -0
- /data/lib/{pixelforce_recipes/capistrano_3_recipes → recipes/capistrano_recipes}/elbas.rb +0 -0
- /data/lib/{pixelforce_recipes/capistrano_3_recipes → recipes/capistrano_recipes}/logrotate.rb +0 -0
- /data/lib/{pixelforce_recipes/capistrano_3_recipes → recipes/capistrano_recipes}/puma.rb +0 -0
- /data/lib/{pixelforce_recipes/capistrano_3_recipes → recipes/capistrano_recipes}/resque.rb +0 -0
- /data/lib/{pixelforce_recipes/capistrano_3_recipes → recipes/capistrano_recipes}/resque_scheduler.rb +0 -0
- /data/lib/{pixelforce_recipes/capistrano_3_recipes → recipes/capistrano_recipes}/sidekiq.rb +0 -0
- /data/lib/{pixelforce_recipes/capistrano_3_recipes → recipes/capistrano_recipes}/supervisor.rb +0 -0
- /data/lib/{pixelforce_recipes/capistrano_3_recipes → recipes/capistrano_recipes}/unicorn.rb +0 -0
- /data/lib/{pixelforce_recipes → recipes}/templates/logrotate.erb +0 -0
- /data/lib/{pixelforce_recipes → recipes}/templates/nginx_config.erb +0 -0
- /data/lib/{pixelforce_recipes → recipes}/templates/nginx_puma_config.erb +0 -0
- /data/lib/{pixelforce_recipes → recipes}/templates/puma.rb.erb +0 -0
- /data/lib/{pixelforce_recipes → recipes}/templates/puma_systemd.erb +0 -0
- /data/lib/{pixelforce_recipes → recipes}/templates/resque_init.erb +0 -0
- /data/lib/{pixelforce_recipes → recipes}/templates/resque_scheduler_init.erb +0 -0
- /data/lib/{pixelforce_recipes → recipes}/templates/resque_scheduler_supervisor.erb +0 -0
- /data/lib/{pixelforce_recipes → recipes}/templates/resque_supervisor.erb +0 -0
- /data/lib/{pixelforce_recipes → recipes}/templates/sidekiq_init.erb +0 -0
- /data/lib/{pixelforce_recipes → recipes}/templates/sidekiq_supervisor.erb +0 -0
- /data/lib/{pixelforce_recipes → recipes}/templates/sidekiq_systemd.erb +0 -0
- /data/lib/{pixelforce_recipes → recipes}/templates/supervisor.erb +0 -0
- /data/lib/{pixelforce_recipes → recipes}/templates/unicorn_init.erb +0 -0
- /data/lib/{pixelforce_recipes → recipes}/templates/unicorn_supervisor.erb +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fdb07c77204b3a75b2c73d4322c0d27fdfc2937cafe090283d190645d7616346
|
4
|
+
data.tar.gz: b28395f2db9c1a2e049cb666a6fb54c4e5e099f15fcbdb81399c98c22678ac42
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c126f24f3eeec6f4426a21ae7cb0808607c6e37d5044e305ead5cf358232c4c024dbdc6edd70248f24ee7a66d4d1722cccc7b43086487edfd6b0c1a05175dc22
|
7
|
+
data.tar.gz: e93d0a39728da785197ef83ebe7937061e5b35ac5f4b5e3df76ce5dffc44682b406587de2afe9541e24fcffdc85fd2218657c33fe068424b3735ab7323739386
|
data/.gitignore
CHANGED
@@ -0,0 +1,97 @@
|
|
1
|
+
module Admin
|
2
|
+
module Api
|
3
|
+
class AdminBaseController < ApplicationController
|
4
|
+
include DeviseTokenAuth::Concerns::SetUserByToken
|
5
|
+
include ResponseHandler
|
6
|
+
include RequestHeaderHandler
|
7
|
+
include ExceptionHandler
|
8
|
+
|
9
|
+
before_action :authenticate_admin_user!
|
10
|
+
before_action :format_params
|
11
|
+
before_action :prepare_pagination_params
|
12
|
+
|
13
|
+
def authenticate_admin_user!
|
14
|
+
authenticate_admin_api_v1_admin_user!
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def render_error(status, message, validation_errors = nil)
|
20
|
+
errors = {}
|
21
|
+
errors['root'] = { 'serverError': message } if message.present?
|
22
|
+
if validation_errors.is_a?(ActiveModel::Errors)
|
23
|
+
data = {}
|
24
|
+
validation_errors.to_hash.each do |key, value|
|
25
|
+
data[key] = value.join(', ')
|
26
|
+
end
|
27
|
+
|
28
|
+
errors.merge!(data) if data.present?
|
29
|
+
end
|
30
|
+
|
31
|
+
response = {
|
32
|
+
errors:
|
33
|
+
}
|
34
|
+
render status:, json: response
|
35
|
+
end
|
36
|
+
|
37
|
+
def set_response_format
|
38
|
+
if request.format.to_s != 'text/csv'
|
39
|
+
request.format = :json
|
40
|
+
self.content_type = 'application/json'
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def pagination_headers(collection, item_name)
|
45
|
+
headers['Content-Range'] = "#{item_name} #{collection.offset_value}-#{collection.offset_value + collection.limit_value - 1}/#{collection.total_count}"
|
46
|
+
headers['Access-Control-Expose-Headers'] = 'Content-Range'
|
47
|
+
end
|
48
|
+
|
49
|
+
def pagination_headers_for_dropdown(item_name)
|
50
|
+
headers['Content-Range'] = "#{item_name} 0-999/1000"
|
51
|
+
headers['Access-Control-Expose-Headers'] = 'Content-Range'
|
52
|
+
end
|
53
|
+
|
54
|
+
def default_per_page
|
55
|
+
10
|
56
|
+
end
|
57
|
+
|
58
|
+
def keywords
|
59
|
+
keyword = params[:filter].try(:[], :keyword)
|
60
|
+
if keyword.present?
|
61
|
+
@keywords = keyword.split(/,| */).reject(&:blank?).map { |value| "%#{value.strip}%" }
|
62
|
+
else
|
63
|
+
[]
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def export_resource_csv(resources, headers)
|
68
|
+
resources = resources.except(:limit, :offset)
|
69
|
+
table_name = resources.table_name
|
70
|
+
csv_data = CSV.generate(headers: true) do |csv|
|
71
|
+
csv << headers.map(&:titleize)
|
72
|
+
resources.find_each do |resource|
|
73
|
+
csv << headers.map { |header| resource.send(header.parameterize.to_sym) }
|
74
|
+
end
|
75
|
+
end
|
76
|
+
send_data csv_data, filename: "#{table_name}-#{Date.today}.csv"
|
77
|
+
end
|
78
|
+
|
79
|
+
def prepare_pagination_params
|
80
|
+
if params[:range].present? && params[:range].is_a?(Array) && params[:range].length == 2
|
81
|
+
beginning_offset = params[:range][0].to_i
|
82
|
+
end_offset = params[:range][1].to_i
|
83
|
+
per_page = end_offset - beginning_offset + 1
|
84
|
+
params[:perPage] = per_page
|
85
|
+
params[:page] = (beginning_offset / per_page) + 1
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def format_params
|
90
|
+
if request.method_symbol == :get
|
91
|
+
params[:filter] = ActionController::Parameters.new(JSON.parse(params[:filter])) if params[:filter].present? && params[:filter].is_a?(String)
|
92
|
+
params[:range] = JSON.parse(params[:range]) if params[:range].present? && params[:range].is_a?(String)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Admin
|
2
|
+
module Api
|
3
|
+
module V1
|
4
|
+
class AppVersionsController < Admin::Api::AdminBaseController
|
5
|
+
def show
|
6
|
+
app_version = AppVersion.last
|
7
|
+
app_version ||= AppVersion.create!
|
8
|
+
render json: app_version.as_json(only: %i[id ios_minimum_version_number android_minimum_version_number])
|
9
|
+
end
|
10
|
+
|
11
|
+
def update
|
12
|
+
app_version = AppVersion.find(params[:id])
|
13
|
+
if app_version.update(app_version_params)
|
14
|
+
render json: app_version.as_json(only: %i[id ios_minimum_version_number android_minimum_version_number])
|
15
|
+
else
|
16
|
+
render_error(400, nil, app_version.errors)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def app_version_params
|
23
|
+
params.permit(:ios_minimum_version_number, :android_minimum_version_number)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Admin
|
2
|
+
module Api
|
3
|
+
module V1
|
4
|
+
class AvailableModulesController < AdminBaseController
|
5
|
+
def index
|
6
|
+
render json: [
|
7
|
+
{
|
8
|
+
"id": 1,
|
9
|
+
"name": 'Dashboard',
|
10
|
+
"path": '/dashboard'
|
11
|
+
},
|
12
|
+
{
|
13
|
+
"id": 2,
|
14
|
+
"name": 'Users',
|
15
|
+
"path": '/users'
|
16
|
+
}
|
17
|
+
]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
module Admin
|
2
|
+
module Api
|
3
|
+
module V1
|
4
|
+
class UsersController < Admin::Api::AdminBaseController
|
5
|
+
def index
|
6
|
+
users = User.all.order(id: :desc).page(params[:page]).per(params[:perPage] || default_per_page)
|
7
|
+
if keywords.present?
|
8
|
+
users = users.where('first_name ILIKE ANY ( array[?] ) OR last_name ILIKE ANY ( array[?] ) OR email ILIKE ANY ( array[?] ) or id = ?', @keywords, @keywords, @keywords, @keywords.first.delete('%').to_i)
|
9
|
+
end
|
10
|
+
pagination_headers(users, 'users')
|
11
|
+
|
12
|
+
respond_to do |format|
|
13
|
+
format.json do
|
14
|
+
render json: users.as_json(only: %i[id first_name last_name email], methods: :status, for_admin: true)
|
15
|
+
end
|
16
|
+
format.csv do
|
17
|
+
export_resource_csv(users, %w[id first_name last_name status email])
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def create
|
23
|
+
user = User.new user_params
|
24
|
+
if user.save
|
25
|
+
render json: user.as_json(only: %i[id first_name last_name email dob gender])
|
26
|
+
else
|
27
|
+
render_error(400, nil, user.errors)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def show
|
32
|
+
@user = User.find(params[:id])
|
33
|
+
render json: @user.as_json(only: %i[id first_name last_name email dob gender])
|
34
|
+
end
|
35
|
+
|
36
|
+
def update
|
37
|
+
user = User.find(params[:id])
|
38
|
+
if user.update(user_params)
|
39
|
+
render json: user.as_json(only: %i[id], for_admin: true)
|
40
|
+
else
|
41
|
+
render_error(400, nil, user.errors)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def destroy
|
46
|
+
user = User.find(params[:id])
|
47
|
+
user.destroy
|
48
|
+
|
49
|
+
render_success
|
50
|
+
end
|
51
|
+
|
52
|
+
def genders
|
53
|
+
pagination_headers_for_dropdown('genders')
|
54
|
+
render json: User.genders.keys.map { |k| { id: k, name: k } }
|
55
|
+
end
|
56
|
+
|
57
|
+
private
|
58
|
+
|
59
|
+
def user_params
|
60
|
+
permitted = params.permit(:first_name, :last_name, :dob, :email, :gender, :password)
|
61
|
+
permitted.presence || raise(ActionController::ParameterMissing, 'Parameters missing')
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
module Api
|
2
|
+
class BaseController < ApplicationController
|
3
|
+
include DeviseTokenAuth::Concerns::SetUserByToken
|
4
|
+
include ResponseHandler
|
5
|
+
include RequestHeaderHandler
|
6
|
+
include ExceptionHandler
|
7
|
+
|
8
|
+
protect_from_forgery with: :null_session
|
9
|
+
|
10
|
+
before_action :authenticate_user!
|
11
|
+
before_action :minimum_version_check!
|
12
|
+
before_action :set_user_timezone
|
13
|
+
before_action :create_user_devices!
|
14
|
+
|
15
|
+
after_action :track_request
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def create_user_devices!
|
20
|
+
if current_user.present? && device_headers[:device_token].present?
|
21
|
+
user_device = UserDevice.find_or_initialize_by(device_token: device_headers[:device_token])
|
22
|
+
|
23
|
+
if user_device.persisted? && user_device.user_id != current_user.id
|
24
|
+
user_device.destroy!
|
25
|
+
user_device = UserDevice.new(device_token: device_headers[:device_token])
|
26
|
+
end
|
27
|
+
|
28
|
+
user_device.user_id = current_user.id
|
29
|
+
user_device.app_version = device_headers[:app_version]
|
30
|
+
user_device.platform = device_headers[:platform]
|
31
|
+
user_device.device_model = device_headers[:device_model]
|
32
|
+
user_device.os_version = device_headers[:os_version]
|
33
|
+
user_device.app_build_version = device_headers[:app_build_version]
|
34
|
+
user_device.save!
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def set_user_timezone
|
39
|
+
if user_timezone && current_user && current_user.timezone != user_timezone
|
40
|
+
current_user.update(timezone: user_timezone)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def user_timezone
|
45
|
+
@user_timezone ||= device_headers[:user_timezone]
|
46
|
+
end
|
47
|
+
|
48
|
+
def minimum_version_check!
|
49
|
+
app_version = device_headers[:app_version]
|
50
|
+
platform = device_headers[:platform]
|
51
|
+
|
52
|
+
if app_version.present? && platform.present?
|
53
|
+
current_app_version = AppVersion.order(id: :desc).first
|
54
|
+
|
55
|
+
if current_app_version.present?
|
56
|
+
minimum_version = current_app_version.minimum_version(platform)
|
57
|
+
|
58
|
+
if minimum_version.present? && Gem::Version.new(app_version) < Gem::Version.new(minimum_version)
|
59
|
+
render_error(426, I18n.t('api.errors.upgrade_app_version'))
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def track_request
|
66
|
+
api_version = request.path.split('/')[2]
|
67
|
+
ahoy.track "ApiRequest::#{api_version}", {
|
68
|
+
params: request.filtered_parameters,
|
69
|
+
url: request.original_url,
|
70
|
+
response: response.status
|
71
|
+
}
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
File without changes
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module ExceptionHandler
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
included do
|
5
|
+
rescue_from StandardError do |e|
|
6
|
+
notify_error(e, airbrake_notify: true)
|
7
|
+
render_error(500, I18n.t('errors.server_error'))
|
8
|
+
end
|
9
|
+
|
10
|
+
rescue_from ActiveRecord::RecordNotFound do |e|
|
11
|
+
notify_error(e)
|
12
|
+
render_error(404, I18n.t('errors.record_not_found'))
|
13
|
+
end
|
14
|
+
|
15
|
+
rescue_from ActiveRecord::RecordInvalid do |e|
|
16
|
+
notify_error(e)
|
17
|
+
render_error(422, I18n.t('errors.record_invalid'))
|
18
|
+
end
|
19
|
+
|
20
|
+
rescue_from ActionController::ParameterMissing do |e|
|
21
|
+
notify_error(e)
|
22
|
+
render_error(404, I18n.t('errors.record_invalid'))
|
23
|
+
end
|
24
|
+
|
25
|
+
rescue_from JSON::ParserError do |e|
|
26
|
+
notify_error(e)
|
27
|
+
render_error(404, I18n.t('errors.record_invalid'))
|
28
|
+
end
|
29
|
+
|
30
|
+
rescue_from ActiveRecord::RecordNotUnique do |e|
|
31
|
+
notify_error(e)
|
32
|
+
render_error(404, I18n.t('errors.record_not_unique'))
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def notify_error(error, airbrake_notify: false)
|
38
|
+
airbrake_notify(error) if airbrake_notify
|
39
|
+
raise_error(error)
|
40
|
+
end
|
41
|
+
|
42
|
+
def raise_error(error)
|
43
|
+
if Rails.env.test? || Rails.env.development?
|
44
|
+
raise error
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def airbrake_notify(error)
|
49
|
+
if Rails.env.production? || Rails.env.staging?
|
50
|
+
Airbrake.notify(error)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module RequestHeaderHandler
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
def cloudfront_headers
|
5
|
+
@cloudfront_headers ||= {
|
6
|
+
cloudfront_viewer_address: request.headers['CloudFront-Viewer-Address'],
|
7
|
+
cloudfront_viewer_country: request.headers['CloudFront-Viewer-Country'],
|
8
|
+
cloudfront_is_ios_viewer: request.headers['CloudFront-Is-Ios-Viewer'],
|
9
|
+
cloudfront_is_tablet_viewer: request.headers['CloudFront-Is-Tablet-Viewer'],
|
10
|
+
cloudfront_viewer_country_name: request.headers['CloudFront-Viewer-Country-Name'],
|
11
|
+
cloudfront_is_mobile_viewer: request.headers['CloudFront-Is-Mobile-Viewer'],
|
12
|
+
cloudfront_is_smarttv_viewer: request.headers['CloudFront-Is-Smarttv-Viewer'],
|
13
|
+
cloudfront_viewer_country_region: request.headers['CloudFront-Viewer-Country-Region'],
|
14
|
+
cloudfront_is_android_viewer: request.headers['CloudFront-Is-Android-Viewer'],
|
15
|
+
cloudfront_viewer_country_region_name: request.headers['CloudFront-Viewer-Country-Region-Name'],
|
16
|
+
cloudfront_viewer_city: request.headers['CloudFront-Viewer-City'],
|
17
|
+
cloudfront_viewer_latitude: request.headers['CloudFront-Viewer-Latitude'],
|
18
|
+
cloudfront_viewer_longitude: request.headers['CloudFront-Viewer-Longitude'],
|
19
|
+
cloudfront_viewer_postal_code: request.headers['CloudFront-Viewer-Postal-Code'],
|
20
|
+
cloudfront_is_desktop_viewer: request.headers['CloudFront-Is-Desktop-Viewer']
|
21
|
+
}
|
22
|
+
end
|
23
|
+
|
24
|
+
def device_headers
|
25
|
+
@device_headers ||= {
|
26
|
+
app_version: request.headers['HTTP_X_APP_VERSION'],
|
27
|
+
platform: request.headers['HTTP_X_PLATFORM'],
|
28
|
+
device_model: request.headers['HTTP_X_DEVICE_MODEL'],
|
29
|
+
os_version: request.headers['HTTP_X_OS_VERSION'],
|
30
|
+
app_build_version: request.headers['HTTP_X_APP_BUILD_VERSION'],
|
31
|
+
device_token: request.headers['HTTP_X_DEVICE_TOKEN'],
|
32
|
+
user_timezone: request.headers['HTTP_X_USER_TIMEZONE']
|
33
|
+
}
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module ResponseHandler
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
included do
|
5
|
+
before_action :config_default_response_settings
|
6
|
+
end
|
7
|
+
|
8
|
+
def config_default_response_settings
|
9
|
+
set_response_format
|
10
|
+
end
|
11
|
+
|
12
|
+
def set_response_format
|
13
|
+
self.content_type = 'application/json'
|
14
|
+
end
|
15
|
+
|
16
|
+
def render_success
|
17
|
+
render json: {}, status: :ok
|
18
|
+
end
|
19
|
+
|
20
|
+
def render_no_content
|
21
|
+
render json: {}, status: :no_content
|
22
|
+
end
|
23
|
+
|
24
|
+
def render_error(status, message, data = nil)
|
25
|
+
response = {
|
26
|
+
errors: [message]
|
27
|
+
}
|
28
|
+
response = response.merge(data) if data
|
29
|
+
render json: response, status: status
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
class PagesController < ApplicationController
|
2
|
+
layout 'rails_template'
|
3
|
+
|
4
|
+
def index; end
|
5
|
+
|
6
|
+
def fonts_page; end
|
7
|
+
|
8
|
+
def spinners_page; end
|
9
|
+
|
10
|
+
def animations_page; end
|
11
|
+
|
12
|
+
def global_notice_page
|
13
|
+
flash.now[:notice] = 'Here is a notice flash message!'
|
14
|
+
flash.now[:success] = 'Here is a success flash message!'
|
15
|
+
flash.now[:warning] = 'Here is a warning flash message!'
|
16
|
+
flash.now[:error] = 'Here is an error flash message!'
|
17
|
+
end
|
18
|
+
|
19
|
+
def new
|
20
|
+
@template_model = TemplateModel.new
|
21
|
+
end
|
22
|
+
|
23
|
+
def create
|
24
|
+
@template_model = TemplateModel.new(template_model_params)
|
25
|
+
if @template_model.save
|
26
|
+
flash[:success] = 'Template has been created successfully.'
|
27
|
+
redirect_to new_template_model_path
|
28
|
+
else
|
29
|
+
render :new
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def template_model_params
|
34
|
+
params.require(:template_model).permit(:first_name, :last_name, :email, :dob, :gender, :message, :level, :active)
|
35
|
+
end
|
36
|
+
end
|
data/lib/pixelforce_recipes.rb
CHANGED
@@ -1,10 +1,8 @@
|
|
1
|
-
require
|
2
|
-
|
1
|
+
require 'rails'
|
2
|
+
require_relative 'pixelforce_recipes/railtie'
|
3
|
+
require_relative 'pixelforce_recipes/engine'
|
4
|
+
require_relative 'pixelforce_recipes/version'
|
3
5
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
else
|
8
|
-
Dir[File.expand_path("#{File.dirname(__FILE__)}/pixelforce_recipes/legacy_recipes/*.rb")].each {|file| require file }
|
9
|
-
end
|
10
|
-
end
|
6
|
+
module PixelforceRecipes
|
7
|
+
|
8
|
+
end
|
data/pixelforce_recipes.gemspec
CHANGED
@@ -23,5 +23,5 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.add_development_dependency "rake", "~> 13.0"
|
24
24
|
spec.add_development_dependency "rspec", "~> 3.0"
|
25
25
|
spec.add_development_dependency "elbas"
|
26
|
-
spec.add_dependency(%q<capistrano>, [">
|
26
|
+
spec.add_dependency(%q<capistrano>, ["> 3.0.0"])
|
27
27
|
end
|
data/recipes.rb
ADDED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pixelforce_recipes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: '4.0'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Zhang
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-09-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - ">"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: 3.0.0
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - ">"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
82
|
+
version: 3.0.0
|
83
83
|
description: Write a longer description or delete this line.
|
84
84
|
email:
|
85
85
|
- bzbnhang@gmail.com
|
@@ -94,42 +94,52 @@ files:
|
|
94
94
|
- LICENSE.txt
|
95
95
|
- README.md
|
96
96
|
- Rakefile
|
97
|
+
- app/controllers/admin/api/admin_base_controller.rb
|
98
|
+
- app/controllers/admin/api/v1/app_versions_controller.rb
|
99
|
+
- app/controllers/admin/api/v1/available_modules_controller.rb
|
100
|
+
- app/controllers/admin/api/v1/users_controller.rb
|
101
|
+
- app/controllers/api/base_controller.rb
|
102
|
+
- app/controllers/api/v1/health_check_controller.rb
|
103
|
+
- app/controllers/application_controller.rb
|
104
|
+
- app/controllers/auth/passwords_controller.rb
|
105
|
+
- app/controllers/concerns/.keep
|
106
|
+
- app/controllers/concerns/exception_handler.rb
|
107
|
+
- app/controllers/concerns/request_header_handler.rb
|
108
|
+
- app/controllers/concerns/response_handler.rb
|
109
|
+
- app/controllers/pages_controller.rb
|
110
|
+
- app/controllers/users_controller.rb
|
97
111
|
- bin/console
|
98
112
|
- bin/setup
|
99
113
|
- lib/pixelforce_recipes.rb
|
100
|
-
- lib/pixelforce_recipes/
|
101
|
-
- lib/pixelforce_recipes/
|
102
|
-
- lib/pixelforce_recipes/capistrano_3_recipes/logrotate.rb
|
103
|
-
- lib/pixelforce_recipes/capistrano_3_recipes/puma.rb
|
104
|
-
- lib/pixelforce_recipes/capistrano_3_recipes/resque.rb
|
105
|
-
- lib/pixelforce_recipes/capistrano_3_recipes/resque_scheduler.rb
|
106
|
-
- lib/pixelforce_recipes/capistrano_3_recipes/sidekiq.rb
|
107
|
-
- lib/pixelforce_recipes/capistrano_3_recipes/supervisor.rb
|
108
|
-
- lib/pixelforce_recipes/capistrano_3_recipes/unicorn.rb
|
109
|
-
- lib/pixelforce_recipes/legacy_recipes/base.rb
|
110
|
-
- lib/pixelforce_recipes/legacy_recipes/logrotate.rb
|
111
|
-
- lib/pixelforce_recipes/legacy_recipes/puma.rb
|
112
|
-
- lib/pixelforce_recipes/legacy_recipes/resque.rb
|
113
|
-
- lib/pixelforce_recipes/legacy_recipes/resque_scheduler.rb
|
114
|
-
- lib/pixelforce_recipes/legacy_recipes/sidekiq.rb
|
115
|
-
- lib/pixelforce_recipes/legacy_recipes/unicorn.rb
|
116
|
-
- lib/pixelforce_recipes/templates/logrotate.erb
|
117
|
-
- lib/pixelforce_recipes/templates/nginx_config.erb
|
118
|
-
- lib/pixelforce_recipes/templates/nginx_puma_config.erb
|
119
|
-
- lib/pixelforce_recipes/templates/puma.rb.erb
|
120
|
-
- lib/pixelforce_recipes/templates/puma_systemd.erb
|
121
|
-
- lib/pixelforce_recipes/templates/resque_init.erb
|
122
|
-
- lib/pixelforce_recipes/templates/resque_scheduler_init.erb
|
123
|
-
- lib/pixelforce_recipes/templates/resque_scheduler_supervisor.erb
|
124
|
-
- lib/pixelforce_recipes/templates/resque_supervisor.erb
|
125
|
-
- lib/pixelforce_recipes/templates/sidekiq_init.erb
|
126
|
-
- lib/pixelforce_recipes/templates/sidekiq_supervisor.erb
|
127
|
-
- lib/pixelforce_recipes/templates/sidekiq_systemd.erb
|
128
|
-
- lib/pixelforce_recipes/templates/supervisor.erb
|
129
|
-
- lib/pixelforce_recipes/templates/unicorn_init.erb
|
130
|
-
- lib/pixelforce_recipes/templates/unicorn_supervisor.erb
|
114
|
+
- lib/pixelforce_recipes/engine.rb
|
115
|
+
- lib/pixelforce_recipes/railtie.rb
|
131
116
|
- lib/pixelforce_recipes/version.rb
|
117
|
+
- lib/recipes/capistrano_recipes/base.rb
|
118
|
+
- lib/recipes/capistrano_recipes/elbas.rb
|
119
|
+
- lib/recipes/capistrano_recipes/logrotate.rb
|
120
|
+
- lib/recipes/capistrano_recipes/puma.rb
|
121
|
+
- lib/recipes/capistrano_recipes/resque.rb
|
122
|
+
- lib/recipes/capistrano_recipes/resque_scheduler.rb
|
123
|
+
- lib/recipes/capistrano_recipes/sidekiq.rb
|
124
|
+
- lib/recipes/capistrano_recipes/supervisor.rb
|
125
|
+
- lib/recipes/capistrano_recipes/unicorn.rb
|
126
|
+
- lib/recipes/templates/logrotate.erb
|
127
|
+
- lib/recipes/templates/nginx_config.erb
|
128
|
+
- lib/recipes/templates/nginx_puma_config.erb
|
129
|
+
- lib/recipes/templates/puma.rb.erb
|
130
|
+
- lib/recipes/templates/puma_systemd.erb
|
131
|
+
- lib/recipes/templates/resque_init.erb
|
132
|
+
- lib/recipes/templates/resque_scheduler_init.erb
|
133
|
+
- lib/recipes/templates/resque_scheduler_supervisor.erb
|
134
|
+
- lib/recipes/templates/resque_supervisor.erb
|
135
|
+
- lib/recipes/templates/sidekiq_init.erb
|
136
|
+
- lib/recipes/templates/sidekiq_supervisor.erb
|
137
|
+
- lib/recipes/templates/sidekiq_systemd.erb
|
138
|
+
- lib/recipes/templates/supervisor.erb
|
139
|
+
- lib/recipes/templates/unicorn_init.erb
|
140
|
+
- lib/recipes/templates/unicorn_supervisor.erb
|
132
141
|
- pixelforce_recipes.gemspec
|
142
|
+
- recipes.rb
|
133
143
|
homepage: https://github.com/BenZhang/pixelforce_recipes
|
134
144
|
licenses:
|
135
145
|
- MIT
|
@@ -149,7 +159,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
149
159
|
- !ruby/object:Gem::Version
|
150
160
|
version: '0'
|
151
161
|
requirements: []
|
152
|
-
rubygems_version: 3.
|
162
|
+
rubygems_version: 3.2.33
|
153
163
|
signing_key:
|
154
164
|
specification_version: 4
|
155
165
|
summary: Write a short summary, because Rubygems requires one.
|
@@ -1,24 +0,0 @@
|
|
1
|
-
if Capistrano::Configuration.instance(false)
|
2
|
-
|
3
|
-
Capistrano::Configuration.instance(true).load do |instance|
|
4
|
-
|
5
|
-
def template(from, to)
|
6
|
-
erb = File.read(File.expand_path("../../templates/#{from}", __FILE__))
|
7
|
-
put ERB.new(erb).result(binding), to
|
8
|
-
end
|
9
|
-
|
10
|
-
def set_default(name, *args, &block)
|
11
|
-
set(name, *args, &block) unless exists?(name)
|
12
|
-
end
|
13
|
-
|
14
|
-
namespace :deploy do
|
15
|
-
desc "Install everything onto the server"
|
16
|
-
task :install do
|
17
|
-
run "#{sudo} apt-get -y update"
|
18
|
-
run "#{sudo} apt-get -y install curl git-core python-software-properties build-essential openssl libreadline6 libreadline6-dev zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion"
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
end
|
23
|
-
|
24
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
if Capistrano::Configuration.instance(false)
|
2
|
-
|
3
|
-
Capistrano::Configuration.instance(true).load do |instance|
|
4
|
-
|
5
|
-
namespace :logrotate do
|
6
|
-
|
7
|
-
desc "Setup logrotate configuration for this application"
|
8
|
-
task :setup, roles: :app do
|
9
|
-
template "logrotate.erb", "/tmp/logrotate"
|
10
|
-
run "#{sudo} mv /tmp/logrotate /etc/logrotate.d/#{application}"
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
if Capistrano::Configuration.instance(false)
|
2
|
-
|
3
|
-
Capistrano::Configuration.instance(true).load do |instance|
|
4
|
-
|
5
|
-
namespace :puma do
|
6
|
-
|
7
|
-
desc "Setup puma configuration for this application"
|
8
|
-
task :setup, roles: :web do
|
9
|
-
template "puma_init.erb", "/tmp/puma"
|
10
|
-
run "#{sudo} mv /tmp/puma /etc/init.d/#{application}"
|
11
|
-
run "#{sudo} chmod +x /etc/init.d/#{application}"
|
12
|
-
run "#{sudo} update-rc.d #{application} defaults"
|
13
|
-
template "nginx_puma_config.erb", "/tmp/nginx_puma_config"
|
14
|
-
run "#{sudo} mv /tmp/nginx_puma_config /etc/nginx/sites-enabled/#{application}"
|
15
|
-
end
|
16
|
-
# after "deploy:setup", "nginx:setup"
|
17
|
-
|
18
|
-
%w[start stop restart].each do |command|
|
19
|
-
desc "#{command} puma"
|
20
|
-
task command, roles: :web do
|
21
|
-
run "/etc/init.d/#{application} #{command}"
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
if Capistrano::Configuration.instance(false)
|
2
|
-
Capistrano::Configuration.instance(true).load do |instance|
|
3
|
-
namespace :resque do
|
4
|
-
desc "Install resque"
|
5
|
-
|
6
|
-
desc "Setup resque configuration for this application"
|
7
|
-
task :setup, roles: :resque do
|
8
|
-
template "resque_init.erb", "/tmp/resque"
|
9
|
-
run "#{sudo} mv /tmp/resque /etc/init.d/resque"
|
10
|
-
run "#{sudo} chmod +x /etc/init.d/resque"
|
11
|
-
run "#{sudo} update-rc.d resque defaults"
|
12
|
-
end
|
13
|
-
|
14
|
-
%w[start stop restart].each do |command|
|
15
|
-
desc "#{command} resque"
|
16
|
-
task command do
|
17
|
-
run "/etc/init.d/resque #{command}"
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
if Capistrano::Configuration.instance(false)
|
2
|
-
Capistrano::Configuration.instance(true).load do |instance|
|
3
|
-
namespace :resque_scheduler do
|
4
|
-
desc "Install resque scheduler"
|
5
|
-
|
6
|
-
desc "Setup resque scheduler configuration for this application"
|
7
|
-
task :setup, roles: :resque do
|
8
|
-
template "resque_scheduler_init.erb", "/tmp/resque_scheduler"
|
9
|
-
run "#{sudo} mv /tmp/resque_scheduler /etc/init.d/resque_scheduler"
|
10
|
-
run "#{sudo} chmod +x /etc/init.d/resque_scheduler"
|
11
|
-
run "#{sudo} update-rc.d resque_scheduler defaults"
|
12
|
-
end
|
13
|
-
|
14
|
-
%w[start stop restart].each do |command|
|
15
|
-
desc "#{command} resque scheduler"
|
16
|
-
task command do
|
17
|
-
run "/etc/init.d/resque_scheduler #{command}"
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
if Capistrano::Configuration.instance(false)
|
2
|
-
Capistrano::Configuration.instance(true).load do |instance|
|
3
|
-
namespace :sidekiq do
|
4
|
-
desc "Install sidekiq"
|
5
|
-
|
6
|
-
desc "Setup sidekiq configuration for this application"
|
7
|
-
task :setup, roles: :sidekiq do
|
8
|
-
template "sidekiq_init.erb", "/tmp/sidekiq"
|
9
|
-
run "#{sudo} mv /tmp/sidekiq /etc/init.d/sidekiq"
|
10
|
-
run "#{sudo} chmod +x /etc/init.d/sidekiq"
|
11
|
-
run "#{sudo} update-rc.d sidekiq defaults"
|
12
|
-
end
|
13
|
-
# after "deploy:setup", "nginx:setup"
|
14
|
-
|
15
|
-
%w[start stop restart].each do |command|
|
16
|
-
desc "#{command} sidekiq"
|
17
|
-
task command do
|
18
|
-
run "/etc/init.d/sidekiq #{command}"
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
if Capistrano::Configuration.instance(false)
|
2
|
-
|
3
|
-
Capistrano::Configuration.instance(true).load do |instance|
|
4
|
-
|
5
|
-
namespace :unicorn do
|
6
|
-
desc "Install unicorn"
|
7
|
-
|
8
|
-
desc "Setup unicorn configuration for this application"
|
9
|
-
task :setup, roles: :web do
|
10
|
-
template "unicorn_init.erb", "/tmp/unicorn"
|
11
|
-
run "#{sudo} mv /tmp/unicorn /etc/init.d/#{application}"
|
12
|
-
run "#{sudo} chmod +x /etc/init.d/#{application}"
|
13
|
-
run "#{sudo} update-rc.d #{application} defaults"
|
14
|
-
template "nginx_config.erb", "/tmp/nginx_config"
|
15
|
-
run "#{sudo} mv /tmp/nginx_config /etc/nginx/sites-enabled/#{application}"
|
16
|
-
end
|
17
|
-
# after "deploy:setup", "nginx:setup"
|
18
|
-
|
19
|
-
%w[start stop restart].each do |command|
|
20
|
-
desc "#{command} unicorn"
|
21
|
-
task command, roles: :web do
|
22
|
-
run "/etc/init.d/#{application} #{command}"
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|
File without changes
|
File without changes
|
/data/lib/{pixelforce_recipes/capistrano_3_recipes → recipes/capistrano_recipes}/logrotate.rb
RENAMED
File without changes
|
File without changes
|
File without changes
|
/data/lib/{pixelforce_recipes/capistrano_3_recipes → recipes/capistrano_recipes}/resque_scheduler.rb
RENAMED
File without changes
|
File without changes
|
/data/lib/{pixelforce_recipes/capistrano_3_recipes → recipes/capistrano_recipes}/supervisor.rb
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|