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
83e1f6cb
Commit
83e1f6cb
authored
Sep 13, 2013
by
Ujvari Gergely
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
StreamSearch uri formatter bugfix
parent
5c8b9aec
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
7 deletions
+16
-7
streamsearch.coffee
h/js/streamsearch.coffee
+16
-7
No files found.
h/js/streamsearch.coffee
View file @
83e1f6cb
...
...
@@ -13,6 +13,7 @@ get_quote = (annotation) ->
# It expects the following dict format as rules
# { 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)
...
...
@@ -51,13 +52,14 @@ class SearchHelper
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
values
.
length
is
1
oper_part
=
if
rule
.
operator
?
then
rule
.
operator
else
if
exact_match
then
'equals'
else
'matches'
value_part
=
if
rule
.
formatter
then
rule
.
formatter
values
[
0
]
else
values
[
0
]
filter
.
addClause
'/'
+
category
,
oper_part
,
value_part
,
case_sensitive
filter
.
addClause
mapped_field
,
oper_part
,
value_part
,
case_sensitive
else
if
and_or
is
'or'
val_list
=
''
...
...
@@ -65,18 +67,18 @@ class SearchHelper
for
val
in
values
unless
first
then
val_list
+=
','
else
first
=
false
value_part
=
if
rule
.
formatter
then
rule
.
formatter
val
else
val
val
ue
_list
+=
value_part
val_list
+=
value_part
oper_part
=
if
rule
.
operator
?
then
rule
.
operator
else
if
exact_match
then
'one_of'
else
'match_of'
filter
.
addClause
'/'
+
category
,
oper_part
,
value_par
t
,
case_sensitive
filter
.
addClause
mapped_field
,
oper_part
,
val_lis
t
,
case_sensitive
else
oper_part
=
if
rule
.
operator
?
then
rule
.
operator
else
if
exact_match
then
'equals'
else
'matches'
for
val
in
values
value_part
=
if
rule
.
formatter
then
rule
.
formatter
val
else
val
filter
.
addClause
'/'
+
category
,
oper_part
,
value_part
,
case_sensitive
filter
.
addClause
mapped_field
,
oper_part
,
value_part
,
case_sensitive
filter
.
getFilter
()
...
...
@@ -85,28 +87,33 @@ class StreamSearch
user
:
formatter
:
(
user
)
->
'acct:'
+
user
+
'@'
+
window
.
location
.
hostname
path
:
'/user'
exact_match
:
true
case_sensitive
:
false
and_or
:
'or'
text
:
path
:
'/text'
exact_match
:
false
case_sensitive
:
false
and_or
:
'and'
tags
:
path
:
'/tags'
exact_match
:
false
case_sensitive
:
false
and_or
:
'or'
quote
:
path
:
"/quote"
exact_match
:
false
case_sensitive
:
false
and_or
:
'and'
uri
:
formatter
:
(
uri
)
->
uri
=
uri
.
toLowerCase
()
if
ur
l
.
match
(
/http:\/\//
)
then
url
=
url
.
substring
(
7
)
if
ur
l
.
match
(
/https:\/\//
)
then
url
=
url
.
substring
(
8
)
if
ur
l
.
match
(
/^www\./
)
then
url
=
url
.
substring
(
4
)
if
ur
i
.
match
(
/http:\/\//
)
then
uri
=
uri
.
substring
(
7
)
if
ur
i
.
match
(
/https:\/\//
)
then
uri
=
uri
.
substring
(
8
)
if
ur
i
.
match
(
/^www\./
)
then
uri
=
uri
.
substring
(
4
)
uri
path
:
'/uri'
exact_match
:
false
case_sensitive
:
false
and_or
:
'or'
...
...
@@ -123,6 +130,7 @@ class StreamSearch
when
'1 month'
then
30
*
24
*
60
*
60
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'
...
...
@@ -165,6 +173,7 @@ class StreamSearch
.
noClauses
()
filter
=
new
SearchHelper
().
populateFilter
filter
,
searchCollection
.
models
,
@
rules
console
.
log
filter
$scope
.
initStream
filter
# Update the parameters
...
...
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