rails_com 1.2.1 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +165 -0
  3. data/README.md +18 -26
  4. data/Rakefile +6 -9
  5. data/app/assets/config/rails_com_manifest.js +2 -0
  6. data/app/assets/javascripts/controllers/active_storage_ext/videos/show.ready.js +1 -0
  7. data/app/assets/javascripts/rails_com/common.js +3 -0
  8. data/app/assets/javascripts/rails_com/fetch_xhr_script.js +3 -2
  9. data/app/assets/stylesheets/controllers/active_storage_ext/videos/show.css +7 -0
  10. data/app/assets/stylesheets/controllers/active_storage_ext/videos/transfer.css +4 -0
  11. data/app/controllers/active_storage/attachments_controller.rb +13 -0
  12. data/app/controllers/active_storage_ext/videos_controller.rb +25 -0
  13. data/app/controllers/concerns/the_common_api.rb +7 -1
  14. data/app/helpers/rails_com/active_helper.rb +14 -10
  15. data/app/helpers/rails_com/assets_helper.rb +40 -14
  16. data/app/helpers/rails_com/format_helper.rb +37 -0
  17. data/app/models/state_machine.rb +10 -6
  18. data/app/views/active_storage/attachments/_image_item.html.erb +6 -0
  19. data/app/views/active_storage/attachments/_list.html.erb +28 -0
  20. data/app/views/active_storage/attachments/_list_edit.html.erb +25 -0
  21. data/app/views/active_storage/attachments/_list_form.html.erb +28 -0
  22. data/app/views/active_storage/attachments/_video_item.html.erb +6 -0
  23. data/app/views/active_storage/attachments/destroy.js.erb +1 -0
  24. data/app/views/active_storage_ext/videos/show.html.erb +6 -0
  25. data/app/views/kaminari/_next_page.html.erb +1 -1
  26. data/app/views/kaminari/_prev_page.html.erb +1 -1
  27. data/app/views/shared/_error_messages.html.erb +1 -1
  28. data/config/locales/en.yml +5 -0
  29. data/config/locales/zh.yml +5 -0
  30. data/config/routes.rb +10 -5
  31. data/lib/assets/javascripts/input-attachment.js +83 -22
  32. data/lib/mina/git2.rb +59 -0
  33. data/lib/rails_com.rb +22 -12
  34. data/lib/rails_com/config.rb +3 -1
  35. data/lib/rails_com/core_ext/array.rb +35 -17
  36. data/lib/rails_com/core_ext/date.rb +24 -0
  37. data/lib/rails_com/core_ext/numeric.rb +11 -0
  38. data/lib/rails_com/core_ext/string.rb +15 -0
  39. data/lib/rails_com/engine.rb +23 -11
  40. data/lib/rails_com/{controller_helper.rb → helpers/controller_helper.rb} +0 -20
  41. data/lib/rails_com/{model_helper.rb → helpers/model_helper.rb} +3 -3
  42. data/lib/rails_com/{controllers.rb → meta/controllers.rb} +0 -0
  43. data/lib/rails_com/{models.rb → meta/models.rb} +1 -0
  44. data/lib/rails_com/{routes.rb → meta/routes.rb} +9 -0
  45. data/lib/rails_com/rails_ext/activestorage_attached.rb +5 -5
  46. data/lib/rails_com/rails_ext/attachment_transfer.rb +40 -0
  47. data/lib/rails_com/rails_ext/named_base.rb +9 -0
  48. data/lib/rails_com/rails_ext/template_renderer.rb +18 -1
  49. data/lib/rails_com/rails_ext/video_response.rb +28 -0
  50. data/lib/{utils → rails_com/utils}/ip_helper.rb +0 -0
  51. data/lib/rails_com/{helpers → utils}/jobber.rb +0 -0
  52. data/lib/rails_com/utils/num_helper.rb +45 -0
  53. data/lib/rails_com/{setting.rb → utils/setting.rb} +0 -0
  54. data/lib/rails_com/utils/time_helper.rb +58 -0
  55. data/lib/rails_com/{helpers → utils}/uid_helper.rb +0 -0
  56. data/lib/rails_com/version.rb +1 -1
  57. data/lib/templates/erb/scaffold/_form.html.erb.tt +2 -2
  58. data/lib/templates/erb/scaffold/index.html.erb.tt +21 -13
  59. data/lib/templates/erb/scaffold/show.html.erb.tt +14 -5
  60. data/lib/templates/rails/scaffold_controller/api_controller.rb.tt +48 -0
  61. data/lib/templates/rails/scaffold_controller/controller.rb.tt +16 -15
  62. metadata +45 -35
  63. data/MIT-LICENSE +0 -20
  64. data/app/controllers/common_controller.rb +0 -10
  65. data/app/controllers/the_guards_controller.rb +0 -18
  66. data/app/helpers/rails_com/common_helper.rb +0 -13
  67. data/app/views/the_guards/index.html.erb +0 -18
  68. data/lib/utils/time_helper.rb +0 -37
data/MIT-LICENSE DELETED
@@ -1,20 +0,0 @@
1
- Copyright 2017 qinmingyuan
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,10 +0,0 @@
1
- class CommonController < ApplicationController
2
-
3
- def locales
4
- respond_to do |format|
5
- format.html
6
- format.js
7
- end
8
- end
9
-
10
- end
@@ -1,18 +0,0 @@
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
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
- module RailsCom::CommonHelper
3
-
4
- def simple_format_hash(hash_text, options = {})
5
- wrapper_tag = options.fetch(:wrapper_tag, :p)
6
-
7
- hash_text.map do |k, v|
8
- text = k.to_s + ': ' + v.to_s
9
- content_tag(wrapper_tag, text)
10
- end.join("\n\n").html_safe
11
- end
12
-
13
- end
@@ -1,18 +0,0 @@
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>
@@ -1,37 +0,0 @@
1
- module TimeHelper
2
- extend self
3
-
4
- def exact_distance_time(from_time, to_time)
5
- from_time = from_time.to_datetime
6
- to_time = to_time.to_datetime
7
-
8
- return {} if from_time > to_time
9
-
10
- years = to_time.year - from_time.year
11
- months = to_time.month - from_time.month
12
- days = to_time.mday - from_time.mday
13
- day_seconds = to_time.seconds_since_midnight.to_i - from_time.seconds_since_midnight.to_i
14
-
15
- if day_seconds < 0
16
- days -= 1
17
- day_seconds = 86400 + day_seconds
18
- end
19
-
20
- if days < 0
21
- months -= 1
22
- days = to_time.prev_month.end_of_month.mday + days
23
- end
24
-
25
- if months < 0
26
- years -= 1
27
- months = 12 + months
28
- end
29
-
30
- hours, minute_seconds = day_seconds.to_i.divmod(3600)
31
- minutes, seconds = minute_seconds.divmod(60)
32
-
33
- { year: years, month: months, day: days, hour: hours, minute: minutes, second: seconds }
34
- end
35
-
36
- end
37
-