Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
coopwire-hypothesis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
孙灵跃 Leon Sun
coopwire-hypothesis
Commits
fa8e94ba
Commit
fa8e94ba
authored
Sep 22, 2014
by
Randall Leeds
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1481 from hypothesis/1456-fix-user-search-2
Search for usernames
parents
b19827d6
b351d61f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
23 deletions
+3
-23
searchfilters.coffee
h/static/scripts/searchfilters.coffee
+3
-23
No files found.
h/static/scripts/searchfilters.coffee
View file @
fa8e94ba
...
...
@@ -146,7 +146,6 @@ class SearchFilter
# { facet_name : {
# formatter: to format the value (optional)
# path: json path mapping to the annotation field
# exact_match: true|false (default: true)
# case_sensitive: true|false (default: false)
# and_or: and|or for multiple values should it threat them as 'or' or 'and' (def: or)
# operator: if given it'll use this operator regardless of other circumstances
...
...
@@ -164,35 +163,25 @@ class SearchFilter
class
QueryParser
rules
:
user
:
formatter
:
(
user
)
->
if
user
.
indexOf
(
'acct:'
)
!=
0
'acct:'
+
user
+
'@'
+
window
.
location
.
hostname
else
user
path
:
'/user'
exact_match
:
true
case_sensitive
:
false
and_or
:
'or'
text
:
path
:
'/text'
exact_match
:
false
case_sensitive
:
false
and_or
:
'and'
tag
:
path
:
'/tags'
exact_match
:
false
case_sensitive
:
false
and_or
:
'and'
quote
:
path
:
'/quote'
exact_match
:
false
case_sensitive
:
false
and_or
:
'and'
uri
:
formatter
:
(
uri
)
->
uri
.
toLowerCase
()
path
:
'/uri'
exact_match
:
false
case_sensitive
:
false
and_or
:
'or'
options
:
...
...
@@ -214,12 +203,10 @@ class QueryParser
when
'1 year'
then
365
*
24
*
60
*
60
new
Date
(
new
Date
().
valueOf
()
-
seconds
*
1000
)
path
:
'/created'
exact_match
:
false
case_sensitive
:
true
and_or
:
'and'
operator
:
'ge'
any
:
exact_match
:
false
case_sensitive
:
false
and_or
:
'and'
path
:
[
'/quote'
,
'/tags'
,
'/text'
,
'/uri'
,
'/user'
]
...
...
@@ -236,21 +223,16 @@ class QueryParser
unless
@
rules
[
category
]
?
then
continue
terms
=
value
.
terms
unless
terms
.
length
then
continue
rule
=
@
rules
[
category
]
rule
=
@
rules
[
category
]
# Now generate the clause with the help of the rule
exact_match
=
if
rule
.
exact_match
?
then
rule
.
exact_match
else
true
case_sensitive
=
if
rule
.
case_sensitive
?
then
rule
.
case_sensitive
else
false
and_or
=
if
rule
.
and_or
?
then
rule
.
and_or
else
'or'
mapped_field
=
if
rule
.
path
?
then
rule
.
path
else
'/'
+
category
if
and_or
is
'or'
val_list
=
''
first
=
true
oper_part
=
if
rule
.
operator
?
then
rule
.
operator
else
if
exact_match
then
'one_of'
else
'match_of'
oper_part
=
if
rule
.
operator
?
then
rule
.
operator
else
'match_of'
value_part
=
[]
for
term
in
terms
...
...
@@ -259,9 +241,7 @@ class QueryParser
filter
.
addClause
mapped_field
,
oper_part
,
value_part
,
case_sensitive
,
rule
.
options
else
oper_part
=
if
rule
.
operator
?
then
rule
.
operator
else
if
exact_match
then
'equals'
else
'matches'
oper_part
=
if
rule
.
operator
?
then
rule
.
operator
else
'matches'
for
val
in
terms
value_part
=
if
rule
.
formatter
then
rule
.
formatter
val
else
val
filter
.
addClause
mapped_field
,
oper_part
,
value_part
,
case_sensitive
,
rule
.
options
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment