Commit 91476ee8 authored by Ujvari Gergely's avatar Ujvari Gergely

Added case_sensitive property for streamer clauses

Now we can set case sensitivity for the streamer search properties. The clause evaluation in the FilterHandler class looks for this property and compares accordingly. The streamfilter.coffee was also extended to handle this new property.
parent 87b688ca
...@@ -12,6 +12,7 @@ class ClauseParser ...@@ -12,6 +12,7 @@ class ClauseParser
'[' : 'one_of' '[' : 'one_of'
'#' : 'matches' '#' : 'matches'
'^' : 'first_of' '^' : 'first_of'
insensitive_operator : 'i'
parse_clauses: (clauses) -> parse_clauses: (clauses) ->
bads = [] bads = []
...@@ -34,14 +35,22 @@ class ClauseParser ...@@ -34,14 +35,22 @@ class ClauseParser
continue continue
field = parts[0] field = parts[0]
if parts[1][0] is @insensitive_operator
sensitive = false
rest = parts[1][1..]
else
sensitive = true
rest = parts[1]
operator_found = false operator_found = false
for operator in @operators for operator in @operators
if (parts[1].indexOf operator) is 0 if (rest.indexOf operator) is 0
oper = @operator_mapping[operator] oper = @operator_mapping[operator]
if operator is '[' if operator is '['
value = parts[1][operator.length..].split ',' value = rest[operator.length..].split ','
else else
value = parts[1][operator.length..] value = rest[operator.length..]
operator_found = true operator_found = true
if field is 'user' if field is 'user'
value = 'acct:' + value + '@' + window.location.hostname value = 'acct:' + value + '@' + window.location.hostname
...@@ -55,6 +64,7 @@ class ClauseParser ...@@ -55,6 +64,7 @@ class ClauseParser
'field' : '/' + field 'field' : '/' + field
'operator': oper 'operator': oper
'value' : value 'value' : value
'case_sensitive': sensitive
[structure, bads] [structure, bads]
...@@ -145,11 +155,12 @@ class StreamFilter ...@@ -145,11 +155,12 @@ class StreamFilter
@filter.clauses.push clause @filter.clauses.push clause
this this
addClause: (field, operator, value) -> addClause: (field, operator, value, case_sensitive = false) ->
@filter.clauses.push @filter.clauses.push
field: field field: field
operator: operator operator: operator
value: value value: value
case_sensitive: case_sensitive
this this
setClausesParse: (clauses_to_parse, error_checking = false) -> setClausesParse: (clauses_to_parse, error_checking = false) ->
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment