phrasing 4.0.0rc2 → 4.0.0rc3
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/README.md +11 -0
- data/Release_notes_version_4.md +13 -2
- data/app/assets/javascripts/phrasing.js.erb +0 -3
- data/app/controllers/phrasing_phrases_controller.rb +1 -12
- data/app/models/phrasing_phrase.rb +14 -0
- data/lib/phrasing/version.rb +1 -1
- data/spec/dummy/app/assets/javascripts/application.js +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aa17e70cddb3a13fbaefc3f473d185c93ddad028
|
4
|
+
data.tar.gz: 4947a95d4f5c5f1dda178056a589b2f2548fedf9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 645b4738ea92b854116bac7cdaef56a797c4121629788a5d7b7b956a11d0869152ccb694a319552ff87ec9938ebc537c64716f419931e60fc6503a9772ac5014
|
7
|
+
data.tar.gz: 01aff8859f2081498e5f274a5239f329b6f5ce0faf16b14b85170dd843edfaaaed5ab9a411874552e60708b662be0d945f60857b9a46eb47efe9fb6a76fbc91a
|
data/README.md
CHANGED
@@ -60,6 +60,15 @@ Include the required **javascript** files:
|
|
60
60
|
//= require phrasing
|
61
61
|
```
|
62
62
|
|
63
|
+
Include the required **javascript** files:
|
64
|
+
|
65
|
+
```javascript
|
66
|
+
//= require jquery
|
67
|
+
//= require jquery_ujs
|
68
|
+
//= require jquery.cookie
|
69
|
+
//= require phrasing
|
70
|
+
```
|
71
|
+
|
63
72
|
Include the required **stylesheet** file:
|
64
73
|
|
65
74
|
```css
|
@@ -102,6 +111,8 @@ If you're experiencing problems with Rails apps using Turbolinks, include the [j
|
|
102
111
|
|
103
112
|
```javascript
|
104
113
|
//= require jquery
|
114
|
+
//= require jquery_ujs
|
115
|
+
//= require jquery.cookie
|
105
116
|
//= require jquery.turbolinks
|
106
117
|
//= require phrasing
|
107
118
|
//= require turbolinks
|
data/Release_notes_version_4.md
CHANGED
@@ -17,10 +17,21 @@ The problem with the interpolation option is that most clients won't understand
|
|
17
17
|
|
18
18
|
If they try to erase parts of it, the developer also might end up being confused and the UI might get broken or at least ugly for some time until the developer fixes the issue.
|
19
19
|
|
20
|
-
##
|
20
|
+
## Loading asset dependencies
|
21
|
+
|
22
|
+
From phrasing v4.0.0rc3, add your jquery files manually:
|
21
23
|
|
22
|
-
|
24
|
+
```javascript
|
25
|
+
//= require jquery
|
26
|
+
//= require jquery_ujs
|
27
|
+
//= require jquery.cookie
|
28
|
+
//= require phrasing
|
29
|
+
```
|
23
30
|
|
24
31
|
## Switching rake tasks with Rails generators
|
25
32
|
|
26
33
|
Since Rails comes with outofbox generators that enable easy existing file detection and similar behaviors, Phrasing 4 will use Rails generators instead of the old rake tasks.
|
34
|
+
|
35
|
+
## HTML Sanitization
|
36
|
+
|
37
|
+
There is a posibility we might add html sanitization to prevent ugly copy-pasted html insertion as well as XSS attacks.
|
@@ -13,18 +13,7 @@ class PhrasingPhrasesController < Phrasing.parent_controller.constantize
|
|
13
13
|
|
14
14
|
def index
|
15
15
|
params[:locale] ||= I18n.default_locale
|
16
|
-
|
17
|
-
query = query.where(locale: params[:locale]) if params[:locale].present?
|
18
|
-
|
19
|
-
@phrasing_phrases = if params[:search].present?
|
20
|
-
key_like = PhrasingPhrase.arel_table[:key].matches("%#{params[:search]}%")
|
21
|
-
value_like = PhrasingPhrase.arel_table[:value].matches("%#{params[:search]}%")
|
22
|
-
query.where(key_like.or(value_like))
|
23
|
-
else
|
24
|
-
# because we want to have non nil values first.
|
25
|
-
query.where("value is not null") + query.where("value is null")
|
26
|
-
end
|
27
|
-
|
16
|
+
@phrasing_phrases = PhrasingPhrase.fuzzy_search(params[:search], params[:locale])
|
28
17
|
@locale_names = PhrasingPhrase.uniq.pluck(:locale)
|
29
18
|
end
|
30
19
|
|
@@ -12,6 +12,20 @@ class PhrasingPhrase < ActiveRecord::Base
|
|
12
12
|
where(key: key, locale: I18n.locale.to_s).first || search_i18n_and_create_phrase(key)
|
13
13
|
end
|
14
14
|
|
15
|
+
def self.fuzzy_search(search_term, locale)
|
16
|
+
query = order("phrasing_phrases.key")
|
17
|
+
query = query.where(locale: locale) if locale.present?
|
18
|
+
|
19
|
+
if search_term.present?
|
20
|
+
key_like = PhrasingPhrase.arel_table[:key].matches("%#{search_term}%")
|
21
|
+
value_like = PhrasingPhrase.arel_table[:value].matches("%#{search_term}%")
|
22
|
+
query.where(key_like.or(value_like))
|
23
|
+
else
|
24
|
+
# because we want to have non nil values first.
|
25
|
+
query.where("value is not null") + query.where("value is null")
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
15
29
|
private
|
16
30
|
|
17
31
|
def self.search_i18n_and_create_phrase(key)
|
data/lib/phrasing/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: phrasing
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.
|
4
|
+
version: 4.0.0rc3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomislav Car
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-10-
|
12
|
+
date: 2014-10-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|