censor_bear 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +80 -0
  4. data/Rakefile +18 -0
  5. data/app/assets/config/censor_bear_manifest.js +1 -0
  6. data/app/assets/stylesheets/censor_bear/application.css +15 -0
  7. data/app/assets/stylesheets/censor_bear/logs.css +4 -0
  8. data/app/assets/stylesheets/censor_bear/mod_logs.css +4 -0
  9. data/app/assets/stylesheets/censor_bear/stop_words.css +4 -0
  10. data/app/assets/stylesheets/censor_bear/tailwind.min.css +1 -0
  11. data/app/assets/stylesheets/scaffold.css +80 -0
  12. data/app/controllers/censor_bear/application_controller.rb +9 -0
  13. data/app/controllers/censor_bear/logs_controller.rb +62 -0
  14. data/app/controllers/censor_bear/mod_logs_controller.rb +87 -0
  15. data/app/controllers/censor_bear/stop_words_controller.rb +69 -0
  16. data/app/helpers/censor_bear/application_helper.rb +5 -0
  17. data/app/helpers/censor_bear/logs_helper.rb +4 -0
  18. data/app/helpers/censor_bear/mod_logs_helper.rb +4 -0
  19. data/app/helpers/censor_bear/stop_words_helper.rb +4 -0
  20. data/app/jobs/censor_bear/application_job.rb +4 -0
  21. data/app/mailers/censor_bear/application_mailer.rb +6 -0
  22. data/app/models/censor_bear/application_record.rb +5 -0
  23. data/app/models/censor_bear/log.rb +4 -0
  24. data/app/models/censor_bear/mod_log.rb +50 -0
  25. data/app/models/censor_bear/stop_word.rb +7 -0
  26. data/app/views/censor_bear/logs/_form.html.erb +37 -0
  27. data/app/views/censor_bear/logs/edit.html.erb +6 -0
  28. data/app/views/censor_bear/logs/index.html.erb +35 -0
  29. data/app/views/censor_bear/logs/new.html.erb +5 -0
  30. data/app/views/censor_bear/logs/show.html.erb +24 -0
  31. data/app/views/censor_bear/mod_logs/_form.html.erb +37 -0
  32. data/app/views/censor_bear/mod_logs/edit.html.erb +6 -0
  33. data/app/views/censor_bear/mod_logs/index.html.erb +44 -0
  34. data/app/views/censor_bear/mod_logs/new.html.erb +5 -0
  35. data/app/views/censor_bear/mod_logs/show.html.erb +24 -0
  36. data/app/views/censor_bear/stop_words/_form.html.haml +30 -0
  37. data/app/views/censor_bear/stop_words/_stop_word.html.haml +33 -0
  38. data/app/views/censor_bear/stop_words/destroy.turbo_stream.haml +1 -0
  39. data/app/views/censor_bear/stop_words/edit.html.haml +6 -0
  40. data/app/views/censor_bear/stop_words/index.html.haml +20 -0
  41. data/app/views/censor_bear/stop_words/new.html.haml +5 -0
  42. data/app/views/censor_bear/stop_words/show.html.haml +1 -0
  43. data/app/views/layouts/censor_bear/application.html.haml +18 -0
  44. data/config/cable.yml +9 -0
  45. data/config/initializers/censor_bear.rb +6 -0
  46. data/config/locales/censor_bear.yml +7 -0
  47. data/config/routes.rb +12 -0
  48. data/db/migrate/20211126133758_create_censor_bear_stop_words.rb +16 -0
  49. data/db/migrate/20211129093508_create_censor_bear_logs.rb +12 -0
  50. data/db/migrate/20211129110218_create_censor_bear_mod_logs.rb +18 -0
  51. data/lib/censor_bear/censor.rb +64 -0
  52. data/lib/censor_bear/configuration.rb +12 -0
  53. data/lib/censor_bear/engine.rb +11 -0
  54. data/lib/censor_bear/version.rb +3 -0
  55. data/lib/censor_bear.rb +36 -0
  56. data/lib/tasks/censor_bear_tasks.rake +4 -0
  57. metadata +177 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 3b7bf815d7375b755966c23467029b2219e3a3c3645bc93d0796b9afb0720bdc
4
+ data.tar.gz: 82a58299728acbeca22d1bf5ec0739ed2a07d4150e6c48639decc0a652f9480a
5
+ SHA512:
6
+ metadata.gz: c403de59e6da357406191a1cbbeecba4dc0b1fcadd5fca74ffdd6ba32a3fca4f63fdd0c0b32d02db6956916e28bb998ca180080eaa6c0296235fbf731d58b7de
7
+ data.tar.gz: 84e32c7fc6e3d029829fcbc6bf65da0901a816e7a411a37cb09beb75cf2e0fecd2de9a929c708038f40b9476e5d725becc449539f737a8d734f168e7d8063eaa
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2021 hongda
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.
data/README.md ADDED
@@ -0,0 +1,80 @@
1
+ # CensorBear
2
+ Short description and motivation.
3
+
4
+ ## Usage
5
+ How to use my plugin.
6
+
7
+ ## Installation
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'censor_bear'
12
+ ```
13
+
14
+ And then execute:
15
+ ```bash
16
+ $ bundle
17
+ ```
18
+
19
+ Or install it yourself as:
20
+ ```bash
21
+ $ gem install censor_bear
22
+ ```
23
+
24
+ ## Authentication
25
+ ### Devise
26
+ ```ruby
27
+ authenticate :user, ->(user) { user.admin? } do
28
+ mount Blazer::Engine, at: "blazer"
29
+ end
30
+ ```
31
+
32
+ ### Other
33
+ Specify a before_action method to run in `censor_bear.yml`.
34
+ ```ruby
35
+ before_action_method: require_admin
36
+ ```
37
+ You can define this method in your ApplicationController.
38
+ ```
39
+ def require_admin
40
+ # depending on your auth, something like...
41
+ redirect_to root_path unless current_user && current_user.admin?
42
+ end
43
+ ```
44
+ Be sure to render or redirect for unauthorized users.
45
+
46
+ ## Migration
47
+ ```bash
48
+ rails censor_bear:install:migrations
49
+ ```
50
+
51
+ ## 🦆 Methods
52
+ ```ruby
53
+ censor_delete # 删除内容
54
+ censor_approve # 通过审核
55
+ censor_show_path # 详情路由
56
+ censor_ban_user # 封禁用户
57
+ ```
58
+
59
+ ## Exceptions
60
+ 检测到被ban的关键词,会抛出`NotPassedException`异常,禁止用户继续创建内容,可在controller捕获该方法处理好返回值。
61
+
62
+ ```ruby
63
+ class NotPassedException < StandardError; end
64
+ ```
65
+
66
+ ## 注意事项
67
+ 1. 为 MOD 时,表示需要人工审核,需要被审查对象(UGC内容)支持`is_approved`字段(默认为`true`),此时内容自己能看到,别人暂时看不到,需审核通过后可见。
68
+ 2. 被审查对象可以通过软删实现,隐藏(目的是防止错判,撤销),删除的内容对自己和别人都是不可见的。
69
+ 3. 建立回收站机制,设定保护期,定时永久删除过期内容。
70
+ 4. 忽略,表示因为某种原因暂时不做处理,针对待处理任务临时隐藏,可通过条件筛选重新查找处理。一些犹豫不觉得任务可以做搁置处理。此时用户状态是自己可见,别人不可见。
71
+ 5. 对于UGC内容有审核机制(MOD状态),对于用户昵称、个人描述、头像等处罚后直接封禁或重置。
72
+ 6. 被BAN掉的内容,无法创建,直接返回异常,速错。
73
+
74
+
75
+
76
+ ## Contributing
77
+ Contribution directions go here.
78
+
79
+ ## License
80
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,18 @@
1
+ require "bundler/setup"
2
+
3
+ APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
4
+ load "rails/tasks/engine.rake"
5
+
6
+ load "rails/tasks/statistics.rake"
7
+
8
+ require "bundler/gem_tasks"
9
+
10
+ require "rake/testtask"
11
+
12
+ Rake::TestTask.new(:test) do |t|
13
+ t.libs << 'test'
14
+ t.pattern = 'test/**/*_test.rb'
15
+ t.verbose = false
16
+ end
17
+
18
+ task default: :test
@@ -0,0 +1 @@
1
+ //= link_directory ../stylesheets/censor_bear .css
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
10
+ * files in this directory. Styles in this file should be added after the last require_* statement.
11
+ * It is generally better to create a new file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */