censor_bear 0.1.12 → 0.1.13
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/controllers/censor_bear/stop_words_controller.rb +11 -2
- data/app/views/censor_bear/logs/_log.html.haml +1 -1
- data/app/views/censor_bear/logs/index.html.haml +1 -1
- data/app/views/censor_bear/mod_logs/index.html.haml +1 -1
- data/app/views/censor_bear/stop_words/index.html.haml +2 -1
- data/app/views/layouts/censor_bear/application.html.haml +2 -2
- data/config/locales/censor_bear.yml +1 -0
- data/lib/censor_bear/censor.rb +1 -1
- data/lib/censor_bear/configuration.rb +2 -0
- data/lib/censor_bear/version.rb +1 -1
- data/lib/censor_bear.rb +2 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a3bf3dd6d88b6f7ece7434deabf56aa6322c305536e44d5ead4bae5c1aa94111
|
4
|
+
data.tar.gz: 9484d90389880990a519229d851394f7a484455972316f90f3d9891dda32851d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e283297831488e216fe57089166d37084725ef93a387ea615d6897298d95616b181880af06c19e1ce3caf536ac29bdaedf1a25408f7392719390da40d721be8d
|
7
|
+
data.tar.gz: 11568a082cc47a024aecb4bd7a2b1f09e785b7690e88bba1bb6acb5445b7eb31ac4f4834f4a63c5429fe8a2c1c40ae6e6c72c21efd130903d3cdb4df81a25d16
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require_dependency
|
1
|
+
require_dependency 'censor_bear/application_controller'
|
2
2
|
|
3
3
|
module CensorBear
|
4
4
|
class StopWordsController < ApplicationController
|
@@ -46,7 +46,16 @@ module CensorBear
|
|
46
46
|
|
47
47
|
def load_stop_words
|
48
48
|
builder ||= stop_word_scope
|
49
|
-
builder = builder.where(
|
49
|
+
builder = builder.where('key ilike ?', "%#{params[:q]}%") if params[:q].present?
|
50
|
+
case params[:filter]
|
51
|
+
when 'size_one'
|
52
|
+
builder = builder.where('length(key) = 1')
|
53
|
+
when 'size_two'
|
54
|
+
builder = builder.where('length(key) = 2')
|
55
|
+
when 'size_three'
|
56
|
+
builder = builder.where('length(key) = 3')
|
57
|
+
end
|
58
|
+
builder = builder.where('key ilike ?', "%#{params[:q]}%")
|
50
59
|
builder = builder.order(id: :desc)
|
51
60
|
|
52
61
|
@pagy, @stop_words = pagy(builder)
|
@@ -32,5 +32,5 @@
|
|
32
32
|
%div{class: "text-yellow-500 font-meidum text-xl"}
|
33
33
|
- log.mod_words.each do |word|
|
34
34
|
%span [
|
35
|
-
%span= link_to word, stop_words_path(q: word), data: { turbo: false }
|
35
|
+
%span= link_to word, stop_words_path(q: word), data: { turbo: false }
|
36
36
|
%span ]
|
@@ -7,7 +7,7 @@
|
|
7
7
|
= f.submit "检索", class: "rounded-md px-2 py-1 text-sm bg-black text-white cursor-pointer"
|
8
8
|
= link_to "重置", logs_path, class: "text-sm"
|
9
9
|
|
10
|
-
%div="共 #{@pagy.count} 条"
|
10
|
+
%div{class: "text-sm text-gray-600"}="共 #{@pagy.count} 条"
|
11
11
|
%div
|
12
12
|
- if @logs.blank?
|
13
13
|
%div{class: "flex justify-center text-gray-500 p-8 border rounded-md"} 空空如也
|
@@ -7,7 +7,7 @@
|
|
7
7
|
= f.submit "检索", class: "rounded-md px-2 py-1 text-sm bg-black text-white cursor-pointer"
|
8
8
|
= link_to "重置", mod_logs_path, class: "text-sm"
|
9
9
|
|
10
|
-
%div="共 #{@pagy.count} 条"
|
10
|
+
%div{class: "text-sm text-gray-600"}="共 #{@pagy.count} 条"
|
11
11
|
%div
|
12
12
|
- if @mod_logs.blank?
|
13
13
|
%div{class: "flex justify-center text-gray-500 p-8 border rounded-md"} 空空如也
|
@@ -4,10 +4,11 @@
|
|
4
4
|
= form_with(url: stop_words_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
|
+
= f.select :filter, options_for_select([%w[长度为1 size_one], %w[长度为2 size_two], %w[长度为3 size_three]], params[:filter]), {include_blank: "-- 按敏感词长度筛选 --"}, class: "border rounded-md m py-0.5 px-1"
|
7
8
|
= f.submit "检索", class: "rounded-md px-2 py-1 text-sm bg-black text-white cursor-pointer"
|
8
9
|
= link_to "重置", stop_words_path, class: "text-sm"
|
9
|
-
|
10
10
|
%div
|
11
|
+
%span{class: "text-sm text-gray-600"}="共 #{@pagy.count} 条"
|
11
12
|
= link_to '批量导入', "#", class: "text-sm"
|
12
13
|
= link_to '新增', new_stop_word_path, class: "rounded-md px-2 py-1 text-sm bg-black text-white cursor-pointer"
|
13
14
|
%div
|
@@ -10,9 +10,9 @@
|
|
10
10
|
%body{class: "flex flex-col space-y-6 p-4"}
|
11
11
|
%ul{class: "flex justify-end items-center space-x-2 text-blue-600"}
|
12
12
|
%li= link_to "审查(#{CensorBear::ModLog.pending.count})", mod_logs_path
|
13
|
-
%li= link_to "敏感词", stop_words_path
|
14
13
|
%li= link_to "日志", logs_path
|
15
|
-
%li= link_to "
|
14
|
+
%li= link_to "敏感词", stop_words_path
|
15
|
+
%li= link_to "控制台", main_app.send(CensorBear.config.main_app_root_path_method.to_sym)
|
16
16
|
%li= current_user.email
|
17
17
|
%div
|
18
18
|
= yield
|
data/lib/censor_bear/censor.rb
CHANGED
@@ -115,7 +115,7 @@ module CensorBear
|
|
115
115
|
rate = r['rate']
|
116
116
|
@mod_words = concat_words(r['details'])
|
117
117
|
@labels = concat_labels(r['details'])
|
118
|
-
if action == 'block' && rate >= 70 && %w[politics terrorism
|
118
|
+
if action == 'block' && rate >= 70 && %w[politics terrorism].include?(r['label'])
|
119
119
|
CensorBear.info(
|
120
120
|
d['content'], @type, action, 'aliyun_check',
|
121
121
|
filtered_content: d['filteredContent'],
|
data/lib/censor_bear/version.rb
CHANGED
data/lib/censor_bear.rb
CHANGED
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.
|
4
|
+
version: 0.1.13
|
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-
|
11
|
+
date: 2021-12-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|