censor_bear 0.1.17 → 0.1.18

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: da82f8fafa1a258c9009099fc66621805e19ac0750662f92153eb3a1a8ba5b01
4
- data.tar.gz: 4a51f1c4260ba69397dfc583093fb59417ba0f9b95b458243d2b28ec58087454
3
+ metadata.gz: 718c2ec6b519d6148ea047125d8a756b3cdc982aba68b4c7ca6d62e73b71a606
4
+ data.tar.gz: af687db6053250f6da78e3eea1192c648725039158a236472f7e5bcc539226ba
5
5
  SHA512:
6
- metadata.gz: 0fed9c06844c55e4fca2c9d997d8f7af7a1bb04c33c0cc73f7fe1d1cbf4c1f0bce029a239f058a0eda4bd8bd11c9b670ad4019d8f3d75e9916d00f8d66a6ddf2
7
- data.tar.gz: 11a70e93051a636a39240dd09327ef38778c82fc22af53b325e28e1635036de93f9ab85ab4b66d6cc8e78d1c04ae6b74ad31b7fa31ee5a958a75b9ac09dcccb7
6
+ metadata.gz: 6f83eae4f76dca1658c2d585f36a2a5419dc49c4e3f3beaeec17fd856a7464035def3b347ecd6ae59b6e4fe31f9ce6d3bae52a9659bc0bbab7cff66219f4d5c6
7
+ data.tar.gz: 07b471f86713559334a67950d35483f22007005caad6c0aecc93b7cbaa01ecc5cfda3aac7d5d95f6cec37abf38218d67aa18f01965a82c5d9e39a3b6bedccbdb
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
- # CensorBear
2
- Short description and motivation.
1
+ # 🐻 CensorBear
3
2
 
4
- ## Usage
5
- How to use my plugin.
3
+ CensorBear 是一个可插拔的内容审核管理工具。
6
4
 
7
5
  ## Installation
8
6
  Add this line to your application's Gemfile:
@@ -21,40 +19,84 @@ Or install it yourself as:
21
19
  $ gem install censor_bear
22
20
  ```
23
21
 
24
- ## Authentication
25
- ### Devise
26
- ```ruby
27
- authenticate :user, ->(user) { user.admin? } do
28
- mount Blazer::Engine, at: "censor_bear"
29
- end
22
+ Then execute to copy migrations:
23
+
24
+ ```bash
25
+ rails censor_bear:install:migrations
30
26
  ```
31
27
 
32
- ### Other
33
- Specify a before_action method to run in `censor_bear.yml`.
28
+ ## 初始化配置
29
+ 详细配置项可在`lib/censor_bear/configuration.rb`中查看。
30
+
31
+ ### 待办
32
+ - [ ] 用户详情跳转路由
33
+
34
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?
35
+ CensorBear.configure do |config|
36
+ config.user_class = 'User'
37
+ config.user_name_method = 'nickname'
38
+
39
+ config.aliyun_green_access_key_id = 'access key id'
40
+ config.aliyun_green_access_key_secret = 'access key secret'
41
+ config.aliyun_green_enable_internal = false
42
+
43
+ config.main_app_root_path_method = 'root_path'
44
+ config.main_app_user_path_method = 'admins_user_path'
42
45
  end
43
46
  ```
44
- Be sure to render or redirect for unauthorized users.
45
47
 
46
- ## Migration
47
- ```bash
48
- rails censor_bear:install:migrations
48
+ ## I18n 配置
49
+ 复制i18n文件到`config/locales/censor_bear.yml`
50
+ ```yml
51
+ "zh-CN":
52
+ censor_log:
53
+ action:
54
+ mod: 审核
55
+ banned: 禁用
56
+ ignore: 忽略
57
+ replace: 替换
58
+ block: 禁用
59
+ pass: 忽略
60
+ review: 审核
61
+ aasm_state:
62
+ pending: 待审
63
+ handled: 已处理
64
+ suspended: 暂缓处理
65
+ stage:
66
+ check_search: 搜索检查
67
+ aliyun_check: 阿里云检查
68
+ tencent_check: 腾讯云检查
69
+ local_check: 本地检查
70
+ qq_regex: QQ正则检查
71
+ wechat_regex: 微信正则检查
72
+ label:
73
+ normal: 正常文本
74
+ spam: 含垃圾信息
75
+ ad: 广告
76
+ politics: 涉政
77
+ terrorism: 暴恐
78
+ abuse: 辱骂
79
+ porn: 色情
80
+ flood: 灌水
81
+ contraband: 违禁
82
+ meaningless: 无意义
83
+ harmful: 不良场景
84
+ customized: 自定义
49
85
  ```
50
86
 
51
- ## 🦆 Methods
87
+ ## 🦆 需要实现的钩子方法
52
88
  ```ruby
89
+ censor_show_path # 被审资源路由详情
90
+ censor_images # 被审资源图片关联资源
53
91
  censor_remove # 删除内容
54
- censor_cancel # 撤销删除
92
+ censor_undo_remove # 撤销删除内容
55
93
  censor_approve # 通过审核
56
- censor_show_path # 详情路由
94
+ censor_undo_approve # 撤销通过审核
57
95
  censor_ban_user # 封禁用户
96
+ ```
97
+
98
+ ## 用法
99
+ ```ruby
58
100
 
59
101
  ```
60
102
 
@@ -65,21 +107,34 @@ censor_ban_user # 封禁用户
65
107
  class NotPassedException < StandardError; end
66
108
  ```
67
109
 
68
- ## 初始化配置
69
- 详细配置项可在`lib/censor_bear/configuration.rb`中查看。
70
110
 
111
+ ## Authentication
112
+ ### Devise
71
113
  ```ruby
72
- CensorBear.configure do |config|
73
- config.user_class = 'User'
74
- config.user_name_method = 'nickname'
75
-
76
- config.aliyun_green_access_key_id = 'access key id'
77
- config.aliyun_green_access_key_secret = 'access key secret'
78
- config.aliyun_green_enable_internal = false
114
+ authenticate :user, ->(user) { user.admin? } do
115
+ mount CensorBear::Engine => "/censor_bear", as: "censor_bear"
116
+ end
117
+ ```
79
118
 
80
- config.main_app_root_path_method = 'root_path'
119
+ ### Other(todo)
120
+ Specify a before_action method to run in `censor_bear.yml`.
121
+ ```ruby
122
+ before_action_method: require_admin
123
+ ```
124
+ You can define this method in your ApplicationController.
125
+ ```
126
+ def require_admin
127
+ # depending on your auth, something like...
128
+ redirect_to root_path unless current_user && current_user.admin?
81
129
  end
82
130
  ```
131
+ Be sure to render or redirect for unauthorized users.
132
+
133
+
134
+ ## 数据库字段要求
135
+ - is_approved
136
+ - 支持软删
137
+
83
138
 
84
139
  ## 注意事项
85
140
  1. 为 MOD 时,表示需要人工审核,需要被审查对象(UGC内容)支持`is_approved`字段(默认为`true`),此时内容自己能看到,别人暂时看不到,需审核通过后可见。
@@ -90,7 +145,6 @@ end
90
145
  6. 被BAN掉的内容,无法创建,直接返回异常,速错。
91
146
 
92
147
 
93
-
94
148
  ## Contributing
95
149
  Contribution directions go here.
96
150
 
@@ -16,7 +16,8 @@
16
16
  - unless log.label.blank?
17
17
  %span{class: "text-sm bg-green-100 text-green-600 py-1 px-2 rounded-lg"}=log.label.upcase
18
18
  - unless log.user_id.blank?
19
- %span{class: "text-sm bg-gray-100 text-gray-600 py-1 px-2 rounded-lg font-bold"}="##{log.user_id}"
19
+ = link_to main_app.send(CensorBear.config.main_app_user_path_method.to_sym, log.user_id), data: {turbo: false} do
20
+ %span{class: "text-sm bg-gray-100 text-gray-600 py-1 px-2 rounded-lg font-bold"}="✍️ ##{log.user_id}"
20
21
  - unless log.ip.blank?
21
22
  %span{class: "text-sm bg-gray-100 text-gray-600 py-1 px-2 rounded-lg"}=log.ip
22
23
  - unless log.labels.blank?
@@ -19,7 +19,7 @@
19
19
  %h3{class: "text-2xl text-red-600"} 对应条目已被永久删除,当前审核请求已无效,请删除
20
20
  - else
21
21
  %div
22
- %span{class: "border border-pink-600 text-pink-600 rounded-lg text-xs p-0.5"}=mod_log.record.is_private ? "隐私" : "公开"
22
+ %span{class: "#{mod_log.record.is_private ? 'bg-black text-white' : 'border border-black text-black' } rounded-lg text-xs p-0.5 px-1"}=mod_log.record.is_private ? "🙈 隐私" : "🙉 公开"
23
23
  %span{class: "border border-blue-600 text-blue-600 rounded-lg text-xs p-0.5"}=mod_log.record.is_approved ? "审核通过" : "审核中..."
24
24
  - unless mod_log.labels.blank?
25
25
  - mod_log.labels.each do |label|
@@ -27,6 +27,9 @@
27
27
  - unless mod_log.mod_words.blank?
28
28
  - mod_log.mod_words.each do |word|
29
29
  %span{class: "border border-red-600 text-red-600 rounded-lg text-xs p-0.5"}="##{word}"
30
+ - unless mod_log&.record&.user_id&.blank?
31
+ = link_to main_app.send(CensorBear.config.main_app_user_path_method.to_sym, mod_log.record.user_id), data: {turbo: false} do
32
+ %span{class: "text-sm bg-gray-100 text-gray-600 py-1 px-2 rounded-lg font-bold"}="✍️ ##{mod_log.record.user_id}"
30
33
  - if mod_log.record.discarded?
31
34
  %div{class: "text-gray-900 leading-relaxed"}
32
35
  %del= mod_log.record.content
@@ -8,8 +8,6 @@
8
8
  = link_to "重置", mod_logs_path, class: "text-sm"
9
9
  %div{class: "flex items-center space-x-2"}
10
10
  %div{class: "text-sm text-gray-600"}="共 #{@pagy.count} 条"
11
- %div{class: "bg-gray-200 rounded-full px-3 py-1 text-xs #{params[:filter] == "all" ? 'font-bold' : ''}"}
12
- = link_to "全部", request.params.merge(filter: "all", state: "")
13
11
  %div{class: "bg-gray-200 rounded-full px-3 py-1 text-xs #{params[:state].blank? && params[:filter].blank? ? 'font-bold' : ''}"}
14
12
  = link_to "待处理", request.params.merge(state: "", filter: "")
15
13
  %div{class: "bg-gray-200 rounded-full px-3 py-1 text-xs #{params[:state] == 'rejected' ? 'font-bold' : ''}"}
@@ -18,6 +16,8 @@
18
16
  = link_to "通过", request.params.merge(state: "passed", filter: "")
19
17
  %div{class: "bg-gray-200 rounded-full px-3 py-1 text-xs #{params[:state] == 'suspended' ? 'font-bold' : ''}"}
20
18
  = link_to "暂缓处理", request.params.merge(state: "suspended", filter: "")
19
+ %div{class: "bg-gray-200 rounded-full px-3 py-1 text-xs #{params[:filter] == "all" ? 'font-bold' : ''}"}
20
+ = link_to "全部", request.params.merge(filter: "all", state: "")
21
21
  %div
22
22
  - if @mod_logs.blank?
23
23
  %div{class: "flex justify-center text-gray-500 p-8 border rounded-md"} 空空如也
@@ -19,5 +19,6 @@ module CensorBear
19
19
  attr_accessor :aliyun_green_enable_internal
20
20
 
21
21
  attr_accessor :main_app_root_path_method
22
+ attr_accessor :main_app_user_path_method
22
23
  end
23
24
  end
@@ -1,3 +1,3 @@
1
1
  module CensorBear
2
- VERSION = '0.1.17'.freeze
2
+ VERSION = '0.1.18'.freeze
3
3
  end
data/lib/censor_bear.rb CHANGED
@@ -26,6 +26,7 @@ module CensorBear
26
26
  @config.aliyun_green_access_key_secret = ''
27
27
  @config.aliyun_green_enable_internal = false
28
28
  @config.main_app_root_path_method = 'root_path'
29
+ @config.main_app_user_path_method = 'user_path'
29
30
 
30
31
  @config
31
32
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: censor_bear
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.17
4
+ version: 0.1.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - 42up
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-12-10 00:00:00.000000000 Z
11
+ date: 2021-12-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -114,7 +114,7 @@ dependencies:
114
114
  - - ">="
115
115
  - !ruby/object:Gem::Version
116
116
  version: '0'
117
- description: Description of CensorBear.
117
+ description: "\U0001F43B Watch your back! Young man."
118
118
  email:
119
119
  - foobar@v2up.com
120
120
  executables: []
@@ -215,5 +215,5 @@ requirements: []
215
215
  rubygems_version: 3.2.22
216
216
  signing_key:
217
217
  specification_version: 4
218
- summary: Summary of CensorBear.
218
+ summary: "\U0001F43B Watch your back! Young man."
219
219
  test_files: []