censor_bear 0.1.8 → 0.1.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/censor_bear/mod_logs_controller.rb +2 -3
- data/app/models/censor_bear/mod_log.rb +4 -0
- data/app/views/censor_bear/logs/_log.html.haml +1 -2
- data/app/views/censor_bear/logs/index.html.haml +2 -2
- data/app/views/censor_bear/mod_logs/_mod_log.html.haml +2 -2
- data/app/views/censor_bear/mod_logs/index.html.haml +4 -4
- data/config/locales/censor_bear.yml +5 -5
- data/lib/censor_bear/censor.rb +10 -8
- data/lib/censor_bear/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 58d7a9f6214a5f560794d6bca513cf288d01e7444aa293e243a3cf3e33e8e8d8
|
4
|
+
data.tar.gz: c1385ce54281b8d764f191f262c7941b32c0590b304d57976ef8e661f24c49ec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 97924df8a0ab45a7afc36d483e20bba15ecd98c23134d629bb4c93e44c233eff45e935871579303b68f107ba3b555d5b595c7f5e0a129bf107b4b213b4827272
|
7
|
+
data.tar.gz: e964103ec3434614e1d7eea7829efebf1bc66b6ad2b8bec9c8e6b2c8868b637c13baa2aad85ccc7f3427437ba3e04eb5a8f649f4f8c85dc947246d50c1bd4494
|
@@ -7,7 +7,6 @@ module CensorBear
|
|
7
7
|
# GET /mod_logs
|
8
8
|
def index
|
9
9
|
load_mod_logs
|
10
|
-
@mod_logs = ModLog.pending.all
|
11
10
|
end
|
12
11
|
|
13
12
|
# GET /mod_logs/1
|
@@ -80,12 +79,12 @@ module CensorBear
|
|
80
79
|
end
|
81
80
|
|
82
81
|
def load_mod_logs
|
83
|
-
builder ||= mod_log_scope
|
82
|
+
builder ||= mod_log_scope.includes(:record)
|
84
83
|
builder = builder.where("content ilike ?", "%#{params[:q]}%") if params[:q].present?
|
85
84
|
|
86
85
|
builder = builder.order(id: :desc)
|
87
86
|
|
88
|
-
@pagy, @
|
87
|
+
@pagy, @mod_logs = pagy(builder)
|
89
88
|
end
|
90
89
|
|
91
90
|
private
|
@@ -10,6 +10,8 @@ module CensorBear
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def delete(reason)
|
13
|
+
return if record.blank?
|
14
|
+
return if record.discarded?
|
13
15
|
# ugc内容需要开软删,便于撤销&查看统计,可以定时删除统计并删除软删内容,类似回收站机制
|
14
16
|
raise NoMethodError.new("undefined censor_delete for record") unless record.respond_to?(:censor_delete)
|
15
17
|
|
@@ -18,6 +20,7 @@ module CensorBear
|
|
18
20
|
end
|
19
21
|
|
20
22
|
def approve
|
23
|
+
return if record.blank?
|
21
24
|
raise NoMethodError unless record.respond_to?(:censor_approve)
|
22
25
|
|
23
26
|
ret = record.censor_approve
|
@@ -25,6 +28,7 @@ module CensorBear
|
|
25
28
|
end
|
26
29
|
|
27
30
|
def ban_user
|
31
|
+
return if record.blank?
|
28
32
|
raise NoMethodError unless record.respond_to?(:censor_ban_user)
|
29
33
|
|
30
34
|
ret = record.censor_ban_user
|
@@ -16,7 +16,6 @@
|
|
16
16
|
- unless log.labels.blank?
|
17
17
|
- log.labels.each do |label|
|
18
18
|
%span{class: "text-sm bg-red-100 text-red-600 py-1 px-2 rounded-lg"}=t("censor_log.label.#{label}")
|
19
|
-
|
20
19
|
%span{class: "text-sm bg-gray-100 text-gray-600 py-1 px-2 rounded-lg"}= log.created_at
|
21
20
|
%div{class: "flex space-x-2 items-center"}
|
22
21
|
%span
|
@@ -33,5 +32,5 @@
|
|
33
32
|
%div{class: "text-yellow-500 font-meidum text-xl"}
|
34
33
|
- log.mod_words.each do |word|
|
35
34
|
%span [
|
36
|
-
%span= link_to word, stop_words_path(q: word)
|
35
|
+
%span= link_to word, stop_words_path(q: word), data: { turbo: false }, target: "_blank"
|
37
36
|
%span ]
|
@@ -1,11 +1,11 @@
|
|
1
1
|
%div{class: "flex flex-col space-y-2 justify-center"}
|
2
2
|
%div{class: "flex justify-between"}
|
3
3
|
%div
|
4
|
-
= form_with(url:
|
4
|
+
= form_with(url: logs_path, method: :get, class: "flex items-center") do |f|
|
5
5
|
%div{class: "space-x-0.5"}
|
6
6
|
= f.text_field :q, value: params[:q], placeholder: "关键词", class: "border rounded-md m py-0.5 px-1"
|
7
7
|
= f.submit "检索", class: "rounded-md px-2 py-1 text-sm bg-black text-white cursor-pointer"
|
8
|
-
= link_to "重置",
|
8
|
+
= link_to "重置", logs_path, class: "text-sm"
|
9
9
|
|
10
10
|
%div="共 #{@pagy.count} 条"
|
11
11
|
%div
|
@@ -3,7 +3,7 @@
|
|
3
3
|
%div{class: "border rounded-md mb-2 p-2 flex flex-col space-y-1"}
|
4
4
|
%div{class: "flex justify-between"}
|
5
5
|
%div{class: ""}
|
6
|
-
= link_to mod_log.record_path do
|
6
|
+
= link_to mod_log.record_path, data: { turbo: false }, target: "_blank" do
|
7
7
|
%span{class: "text-sm bg-indigo-100 text-indigo-600 py-1 px-2 rounded-lg"}="#{mod_log.record_type.upcase}##{mod_log.record_id}"
|
8
8
|
- unless mod_log.labels.blank?
|
9
9
|
- mod_log.labels.each do |label|
|
@@ -24,7 +24,7 @@
|
|
24
24
|
- if mod_log.status == 2
|
25
25
|
= "暂缓"
|
26
26
|
%span
|
27
|
-
= link_to "详情", mod_log
|
27
|
+
= link_to "详情", mod_log, data: { turbo: false }, target: "_blank"
|
28
28
|
%span
|
29
29
|
= button_to '删除', mod_log, method: :delete, data: { confirm: 'Are you sure?'}, class: "text-red-600 rounded-md px-2 py-0.5"
|
30
30
|
%div{class: "flex justify-between items-center"}
|
@@ -1,18 +1,18 @@
|
|
1
1
|
%div{class: "flex flex-col space-y-2 justify-center"}
|
2
2
|
%div{class: "flex justify-between"}
|
3
3
|
%div
|
4
|
-
= form_with(url:
|
4
|
+
= form_with(url: mod_logs_path, method: :get, class: "flex items-center") do |f|
|
5
5
|
%div{class: "space-x-0.5"}
|
6
6
|
= f.text_field :q, value: params[:q], placeholder: "关键词", class: "border rounded-md m py-0.5 px-1"
|
7
7
|
= f.submit "检索", class: "rounded-md px-2 py-1 text-sm bg-black text-white cursor-pointer"
|
8
|
-
= link_to "重置",
|
8
|
+
= link_to "重置", mod_logs_path, class: "text-sm"
|
9
9
|
|
10
10
|
%div="共 #{@pagy.count} 条"
|
11
11
|
%div
|
12
|
-
- if @
|
12
|
+
- if @mod_logs.blank?
|
13
13
|
%div{class: "flex justify-center text-gray-500 p-8 border rounded-md"} 空空如也
|
14
14
|
- else
|
15
|
-
- @
|
15
|
+
- @mod_logs.each do |log|
|
16
16
|
= render log
|
17
17
|
%div{class: "flex justify-center"}
|
18
18
|
= raw pagy_nav(@pagy)
|
@@ -9,11 +9,11 @@ en:
|
|
9
9
|
pass: 忽略
|
10
10
|
review: 审核
|
11
11
|
stage:
|
12
|
-
aliyun_check:
|
13
|
-
tencent_check:
|
14
|
-
local_check:
|
15
|
-
qq_regex:
|
16
|
-
wechat_regex:
|
12
|
+
aliyun_check: 阿里云检查
|
13
|
+
tencent_check: 腾讯云检查
|
14
|
+
local_check: 本地检查
|
15
|
+
qq_regex: QQ正则检查
|
16
|
+
wechat_regex: 微信正则检查
|
17
17
|
label:
|
18
18
|
normal: 正常文本
|
19
19
|
spam: 含垃圾信息
|
data/lib/censor_bear/censor.rb
CHANGED
@@ -30,15 +30,15 @@ module CensorBear
|
|
30
30
|
return Result.new(@content) unless CensorBear::StopWord::FIELDS.include?(@type)
|
31
31
|
|
32
32
|
# 正则过滤
|
33
|
-
if @content.match(QQ_REG)
|
34
|
-
|
35
|
-
|
36
|
-
end
|
33
|
+
# if @content.match(QQ_REG)
|
34
|
+
# CensorBear.info(@content, @type, 'BANNED', 'qq_regex', ip: @ip, user_id: @user_id)
|
35
|
+
# raise NotPassedException
|
36
|
+
# end
|
37
37
|
|
38
|
-
if @content.match(WX_REG)
|
39
|
-
|
40
|
-
|
41
|
-
end
|
38
|
+
# if @content.match(WX_REG)
|
39
|
+
# CensorBear.info(@content, @type, 'BANNED', 'wx_regex', ip: @ip, user_id: @user_id)
|
40
|
+
# raise NotPassedException
|
41
|
+
# end
|
42
42
|
|
43
43
|
# 本地自定义词库粗查
|
44
44
|
local_check
|
@@ -148,6 +148,7 @@ module CensorBear
|
|
148
148
|
private
|
149
149
|
|
150
150
|
def concat_labels(data)
|
151
|
+
return [] if data.blank?
|
151
152
|
labels = []
|
152
153
|
data.map do |d|
|
153
154
|
next if d['label'].blank?
|
@@ -158,6 +159,7 @@ module CensorBear
|
|
158
159
|
end
|
159
160
|
|
160
161
|
def concat_words(data)
|
162
|
+
return [] if data.blank?
|
161
163
|
words = []
|
162
164
|
data.each do |d|
|
163
165
|
next if d['contexts'].blank?
|
data/lib/censor_bear/version.rb
CHANGED