phrasing 4.0.0rc2 → 4.0.0rc3

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
  SHA1:
3
- metadata.gz: b9dcfc2841ec28bd67e4753423cc4b95a6620b4f
4
- data.tar.gz: 9979a2f18909e0e8acf2d1655cf7cc05c5a2f310
3
+ metadata.gz: aa17e70cddb3a13fbaefc3f473d185c93ddad028
4
+ data.tar.gz: 4947a95d4f5c5f1dda178056a589b2f2548fedf9
5
5
  SHA512:
6
- metadata.gz: 626fdf49d11632970a2f55c434dd92c9bbd2cdc25d5a7a58ab365455580d7e723bb24a6cc4f77ff56d82244be3d747ade1f588ad8300eb6bc77f8d56f7947769
7
- data.tar.gz: 6026e75cf96b9b934fde9f798c47462a70de07d51026bfbfa4095eabe8a8cebc1977179040c9ef55083d44062d8d4f5608207da66ec7fa7fdc329a12ca6f3077
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
@@ -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
- ## HTML Sanitization
20
+ ## Loading asset dependencies
21
+
22
+ From phrasing v4.0.0rc3, add your jquery files manually:
21
23
 
22
- There is a posibility we might add html sanitization to prevent ugly copy-pasted html insertion (as well as XSS attacks).
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.
@@ -1,7 +1,4 @@
1
1
  //= require editor
2
- //= require jquery
3
- //= require jquery_ujs
4
- //= require jquery.cookie
5
2
 
6
3
  function StatusBubble(){
7
4
  var $headline = $('#phrasing-edit-mode-bubble #phrasing-saved-status-headline p');
@@ -13,18 +13,7 @@ class PhrasingPhrasesController < Phrasing.parent_controller.constantize
13
13
 
14
14
  def index
15
15
  params[:locale] ||= I18n.default_locale
16
- query = PhrasingPhrase.order("phrasing_phrases.key")
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)
@@ -1,3 +1,3 @@
1
1
  module Phrasing
2
- VERSION = "4.0.0rc2"
2
+ VERSION = "4.0.0rc3"
3
3
  end
@@ -6,5 +6,6 @@
6
6
  //
7
7
  //= require jquery
8
8
  //= require jquery_ujs
9
+ //= require jquery.cookie
9
10
  //= require phrasing
10
11
  //= require_tree .
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.0rc2
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-09 00:00:00.000000000 Z
12
+ date: 2014-10-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails