Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Netzschleuder
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Furkan Gursoy
Netzschleuder
Commits
98479a62
Commit
98479a62
authored
Sep 13, 2020
by
Tiago Peixoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for multiple regexp search
parent
619c2ec8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
10 deletions
+21
-10
net_site.py
net_site.py
+18
-7
templates/main.html
templates/main.html
+3
-3
No files found.
net_site.py
View file @
98479a62
...
...
@@ -92,21 +92,32 @@ def main_page():
if
tags
is
None
or
len
(
set
(
entry
.
tags
)
&
tags
)
>
0
]
else
:
fentries
=
entries
.
values
()
search
=
request
.
args
.
get
(
'search'
,
None
)
if
search
==
""
:
search
=
None
if
search
is
not
None
:
match
=
re
.
compile
(
search
)
def
score
(
vals
):
search
=
request
.
args
.
get
(
'search'
,
""
)
search
=
search
.
strip
()
if
search
!=
""
:
match
=
[]
for
s
in
re
.
split
(
r
'(?<!\\)&'
,
search
):
try
:
match
.
append
(
re
.
compile
(
s
.
strip
(),
re
.
IGNORECASE
))
except
re
.
error
:
pass
def
score_match
(
m
,
vals
):
n
=
0
for
v
in
vals
:
if
v
is
None
:
continue
if
isinstance
(
v
,
str
):
n
+=
len
(
m
atch
.
findall
(
v
))
n
+=
len
(
m
.
findall
(
v
))
else
:
n
+=
score
(
v
)
return
n
def
score
(
vals
):
n
=
1
for
m
in
match
:
n
*=
score_match
(
m
,
vals
)
if
n
==
0
:
break
return
n
fentries
=
[(
entry
,
score
([
entry
.
name
,
entry
.
title
,
entry
.
description
,
entry
.
url
,
entry
.
upstream_prefix
,
entry
.
citation
,
entry
.
upstream_license
,
...
...
templates/main.html
View file @
98479a62
...
...
@@ -14,8 +14,8 @@ active
<div
class=
"control-group all-100"
style=
"margin-bottom: 0"
>
<div
class=
"control append-button"
role=
"search"
>
<span>
{% if search
is none
%}
<input
type=
"text"
name=
"search"
id=
"search"
placeholder=
"
Enter arbitrary regexp term
"
>
{% if search
== ""
%}
<input
type=
"text"
name=
"search"
id=
"search"
placeholder=
"
Multiple regexp terms separated by '&'
"
>
{% else %}
<input
type=
"text"
name=
"search"
id=
"search"
,
value=
"{{search}}"
>
{% endif %}
...
...
@@ -32,7 +32,7 @@ active
{% endfor %}
<br/>
{% endif %}
{% if search
is not none
%}
{% if search
!= ""
%}
Showing only entries that match regexp: {{search}}
<br/>
{% endif %}
<span
style=
"font-size:x-small"
>
Tip: click on the table header to sort the list. Hover your mouse to obtain a legend.
</span>
...
...
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