rails_com 1.0.0 → 1.1.0
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/app/assets/config/rails_com_manifest.js +3 -2
- data/app/assets/images/verification.jpg +0 -0
- data/app/assets/javascripts/rails_com/application.js +3 -0
- data/app/assets/stylesheets/rails_com/application.css +4 -0
- data/app/controllers/concerns/the_common_api.rb +20 -0
- data/app/controllers/the_guards_controller.rb +18 -0
- data/app/helpers/rails_com/active_helper.rb +18 -37
- data/app/helpers/rails_com_helper.rb +16 -0
- data/app/models/state_machine.rb +1 -1
- data/app/views/kaminari/_paginator.html.erb +1 -1
- data/app/views/layouts/rails_com/application.html.erb +17 -0
- data/app/views/the_guards/index.html.erb +18 -0
- data/config/locales/en.yml +7 -1
- data/config/routes.rb +3 -0
- data/lib/assets/javascripts/input-attachment.js +481 -0
- data/lib/assets/stylesheets/semantic.css +19466 -0
- data/lib/nondigest_assets/fonts/themes/default/assets/fonts/icons.eot +0 -0
- data/lib/nondigest_assets/fonts/themes/default/assets/fonts/icons.otf +0 -0
- data/lib/nondigest_assets/fonts/themes/default/assets/fonts/icons.svg +2671 -0
- data/lib/nondigest_assets/fonts/themes/default/assets/fonts/icons.ttf +0 -0
- data/lib/nondigest_assets/fonts/themes/default/assets/fonts/icons.woff +0 -0
- data/lib/nondigest_assets/fonts/themes/default/assets/fonts/icons.woff2 +0 -0
- data/lib/nondigest_assets/images/themes/default/assets/images/flags.png +0 -0
- data/lib/rails_com/controller_helper.rb +25 -0
- data/lib/rails_com/core_ext/hash.rb +1 -0
- data/lib/rails_com/core_ext/nil.rb +7 -0
- data/lib/rails_com/engine.rb +8 -0
- data/lib/rails_com/helpers/qiniu_helper.rb +21 -50
- data/lib/rails_com/sprockets/non_digest_assets.rb +34 -0
- data/lib/rails_com/sprockets/qiniu_exporter.rb +21 -0
- data/lib/rails_com/sprockets.rb +15 -0
- data/lib/rails_com/version.rb +1 -1
- data/lib/rails_com.rb +6 -4
- data/lib/templates/erb/scaffold/_form.html.erb +19 -0
- data/lib/templates/erb/scaffold/edit.html.erb +2 -0
- data/lib/templates/erb/scaffold/index.html.erb +36 -0
- data/lib/templates/erb/scaffold/new.html.erb +1 -0
- data/lib/templates/erb/scaffold/show.html.erb +13 -0
- data/lib/templates/rails/scaffold_controller/controller.rb +47 -0
- metadata +45 -7
- data/app/assets/config/qiniu.js +0 -23
- data/app/assets/config/qiniu1.js +0 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 32b4755a8bebb55e2b76cf7706a5db5847faf3d3
|
4
|
+
data.tar.gz: 353c60cc06071bb72a88ef9c146d2d3ec85369ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0384054fc7e6a81ad573089fe6a4b1357dee92dd60325dc5ca0375fe20b024fd64e08d513394c9036968fcea65f047e0bb2b55929af22abb6503b3e508c69728'
|
7
|
+
data.tar.gz: b92de35c6e6a552de2140bc4c6812b8098b733f61eb2dfef8df5f1a454a8b92e1dfcda849eb053c1dc68d447432755c79b75e3f3b2d23b63cce21c7330a2fa07
|
Binary file
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module TheCommonApi
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
included do
|
5
|
+
rescue_from 'ActiveRecord::RecordNotFound' do |exp|
|
6
|
+
render json: { error: exp.message, backtrace: exp.backtarce }, status: :not_found
|
7
|
+
end
|
8
|
+
rescue_from 'StandardError' do |exp|
|
9
|
+
render json: { error: exp.message, backtrace: exp.backtrace }, status: 500
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def process_errors(model)
|
14
|
+
render json: {
|
15
|
+
errors: model.errors.as_json(full_messages: true),
|
16
|
+
full_messages: model.errors.full_messages.join(',')
|
17
|
+
}, status: 500
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class TheGuardsController < ApplicationController
|
2
|
+
layout 'rails_com/application'
|
3
|
+
skip_before_action :require_recaptcha, raise: false
|
4
|
+
|
5
|
+
def index
|
6
|
+
|
7
|
+
end
|
8
|
+
|
9
|
+
def create
|
10
|
+
if verify_rucaptcha?
|
11
|
+
clear_ip_count
|
12
|
+
redirect_to session[:back_to] || root_url
|
13
|
+
else
|
14
|
+
redirect_to '/the_guards', alert: 'Invalid captcha code.'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
@@ -9,53 +9,34 @@ module RailsCom::ActiveHelper
|
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
def active_action(active_class: 'item active', item_class: 'item', **options)
|
25
|
-
ok = false
|
26
|
-
options.each do |key, value|
|
27
|
-
if controller_name == key.to_s
|
28
|
-
ok = true if value.include?(action_name)
|
12
|
+
# path: active_helper paths: '/work/employees' or active_helper paths: ['/work/employees']
|
13
|
+
# controller: active_helper controllers: 'xxx' or active_helper controllers: ['xxx1', 'admin/xxx2']
|
14
|
+
# action: active_helper 'work/employee': ['index', 'show']
|
15
|
+
# params: active_params state: 'xxx'
|
16
|
+
# active_helper controller: 'users', action: 'show', id: 371
|
17
|
+
def active_helper(paths: [], controllers: [], active_class: 'item active', item_class: 'item', **options)
|
18
|
+
check_parameters = options.delete(:check_parameters)
|
19
|
+
|
20
|
+
if paths.present?
|
21
|
+
Array(paths).each do |path|
|
22
|
+
return active_class if current_page?(path, check_parameters: check_parameters)
|
29
23
|
end
|
30
24
|
end
|
31
25
|
|
32
|
-
if
|
33
|
-
active_class
|
34
|
-
else
|
35
|
-
item_class
|
26
|
+
if controllers.present?
|
27
|
+
return active_class if (Array(controllers) & [controller_name, controller_path]).size > 0
|
36
28
|
end
|
37
|
-
end
|
38
29
|
|
39
|
-
|
40
|
-
def active_page(options)
|
41
|
-
active_class = options.delete(:active_class) || 'item active'
|
42
|
-
item_class = options.delete(:item_class) || 'item'
|
30
|
+
return active_class if options.present? && current_page?(options)
|
43
31
|
|
44
|
-
options.select { |
|
45
|
-
|
46
|
-
return active_class
|
47
|
-
else
|
48
|
-
return item_class
|
49
|
-
end
|
32
|
+
options.select { |k, _| [controller_name, controller_path].include?(k.to_s) }.each do |_, value|
|
33
|
+
return active_class if value.include?(action_name)
|
50
34
|
end
|
51
35
|
|
52
|
-
|
36
|
+
item_class
|
53
37
|
end
|
54
38
|
|
55
|
-
def active_params(options)
|
56
|
-
active_class = options.delete(:active_class) || 'item active'
|
57
|
-
item_class = options.delete(:item_class) || 'item'
|
58
|
-
|
39
|
+
def active_params(active_class: 'item active', item_class: 'item', **options)
|
59
40
|
options.select { |_, v| v.present? }.each do |k, v|
|
60
41
|
if params[k].to_s == v.to_s
|
61
42
|
return active_class
|
@@ -8,6 +8,22 @@ module RailsComHelper
|
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
|
+
def css_load(filename = nil, root: Rails.root, **options)
|
12
|
+
filename ||= "controllers/#{controller_path}/#{action_name}"
|
13
|
+
path = root + 'app/assets/stylesheets' + filename.to_s
|
14
|
+
if File.exist?(path.to_s + '.css')
|
15
|
+
stylesheet_link_tag filename, options
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def js_ready(filename = nil, root: Rails.root, **options)
|
20
|
+
filename ||= "controllers/#{controller_path}/#{action_name}.ready"
|
21
|
+
path = root + 'app/assets/javascripts' + filename.to_s
|
22
|
+
if File.exist?(path.to_s + '.js') || File.exist?(path.to_s + '.js.erb')
|
23
|
+
javascript_include_tag filename, options
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
11
27
|
def simple_format_hash(hash_text, options = {})
|
12
28
|
wrapper_tag = options.fetch(:wrapper_tag, :p)
|
13
29
|
|
data/app/models/state_machine.rb
CHANGED
@@ -0,0 +1,17 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
|
4
|
+
<head>
|
5
|
+
<title></title>
|
6
|
+
<%= stylesheet_link_tag 'rails_com/application', media: 'all', 'data-turbolinks-track': true %>
|
7
|
+
<%= javascript_include_tag 'rails_com/application', 'data-turbolinks-track': true %>
|
8
|
+
<%= csrf_meta_tags %>
|
9
|
+
</head>
|
10
|
+
|
11
|
+
<body>
|
12
|
+
|
13
|
+
<%= yield %>
|
14
|
+
|
15
|
+
</body>
|
16
|
+
|
17
|
+
</html>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<div class="ui basic segment">
|
2
|
+
<%= image_tag 'verification.jpg', class: 'ui centered image' %>
|
3
|
+
<h3 class="ui green center aligned header">
|
4
|
+
您的请求过于频繁,喝口茶休息一下吧
|
5
|
+
</h3>
|
6
|
+
<h4 class="ui center aligned header">
|
7
|
+
如果希望继续访问,请输入验证码
|
8
|
+
|
9
|
+
</h4>
|
10
|
+
<div class="ui center aligned basic segment">
|
11
|
+
<%= form_tag do %>
|
12
|
+
<%= rucaptcha_input_tag(class: 'form-control', placeholder: 'Input Captcha') %>
|
13
|
+
<% end %>
|
14
|
+
<%= rucaptcha_image_tag(alt: 'Captcha') %>
|
15
|
+
</div>
|
16
|
+
|
17
|
+
|
18
|
+
</div>
|
data/config/locales/en.yml
CHANGED
@@ -14,4 +14,10 @@ en:
|
|
14
14
|
one: "Displaying <b>1</b> %{entry_name}"
|
15
15
|
other: "Displaying <b>all %{count}</b> %{entry_name}"
|
16
16
|
more_pages:
|
17
|
-
display_entries: "Displaying %{entry_name} <b>%{first} - %{last}</b> of <b>%{total}</b> in total"
|
17
|
+
display_entries: "Displaying %{entry_name} <b>%{first} - %{last}</b> of <b>%{total}</b> in total"
|
18
|
+
select:
|
19
|
+
prompt: "Please select"
|
20
|
+
submit:
|
21
|
+
create: 'Create %{model}'
|
22
|
+
update: 'Update %{model}'
|
23
|
+
submit: 'Save %{model}'
|