censor_bear 0.1.12 → 0.1.13

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: 58d7a9f6214a5f560794d6bca513cf288d01e7444aa293e243a3cf3e33e8e8d8
4
- data.tar.gz: c1385ce54281b8d764f191f262c7941b32c0590b304d57976ef8e661f24c49ec
3
+ metadata.gz: a3bf3dd6d88b6f7ece7434deabf56aa6322c305536e44d5ead4bae5c1aa94111
4
+ data.tar.gz: 9484d90389880990a519229d851394f7a484455972316f90f3d9891dda32851d
5
5
  SHA512:
6
- metadata.gz: 97924df8a0ab45a7afc36d483e20bba15ecd98c23134d629bb4c93e44c233eff45e935871579303b68f107ba3b555d5b595c7f5e0a129bf107b4b213b4827272
7
- data.tar.gz: e964103ec3434614e1d7eea7829efebf1bc66b6ad2b8bec9c8e6b2c8868b637c13baa2aad85ccc7f3427437ba3e04eb5a8f649f4f8c85dc947246d50c1bd4494
6
+ metadata.gz: e283297831488e216fe57089166d37084725ef93a387ea615d6897298d95616b181880af06c19e1ce3caf536ac29bdaedf1a25408f7392719390da40d721be8d
7
+ data.tar.gz: 11568a082cc47a024aecb4bd7a2b1f09e785b7690e88bba1bb6acb5445b7eb31ac4f4834f4a63c5429fe8a2c1c40ae6e6c72c21efd130903d3cdb4df81a25d16
@@ -1,4 +1,4 @@
1
- require_dependency "censor_bear/application_controller"
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("key ilike ?", "%#{params[:q]}%") if params[:q].present?
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 }, target: "_blank"
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
@@ -9,6 +9,7 @@ en:
9
9
  pass: 忽略
10
10
  review: 审核
11
11
  stage:
12
+ check_search: 搜索检查
12
13
  aliyun_check: 阿里云检查
13
14
  tencent_check: 腾讯云检查
14
15
  local_check: 本地检查
@@ -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 abuse].include?(r['label'])
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'],
@@ -17,5 +17,7 @@ module CensorBear
17
17
  attr_accessor :aliyun_green_access_key_id
18
18
  attr_accessor :aliyun_green_access_key_secret
19
19
  attr_accessor :aliyun_green_enable_internal
20
+
21
+ attr_accessor :main_app_root_path_method
20
22
  end
21
23
  end
@@ -1,3 +1,3 @@
1
1
  module CensorBear
2
- VERSION = '0.1.12'.freeze
2
+ VERSION = '0.1.13'.freeze
3
3
  end
data/lib/censor_bear.rb CHANGED
@@ -24,6 +24,8 @@ module CensorBear
24
24
  @config.aliyun_green_access_key_id = ''
25
25
  @config.aliyun_green_access_key_secret = ''
26
26
  @config.aliyun_green_enable_internal = false
27
+ @config.main_app_root_path_method = 'root_path'
28
+
27
29
  @config
28
30
  end
29
31
 
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.12
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-08 00:00:00.000000000 Z
11
+ date: 2021-12-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails