Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
iv
gitlab-ce
Commits
ac8247b4
Commit
ac8247b4
authored
Jan 25, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improved search. added filters
parent
f6c482c0
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
117 additions
and
106 deletions
+117
-106
app/assets/stylesheets/common.scss
app/assets/stylesheets/common.scss
+14
-2
app/controllers/search_controller.rb
app/controllers/search_controller.rb
+13
-1
app/helpers/application_helper.rb
app/helpers/application_helper.rb
+20
-20
app/views/layouts/_search.html.haml
app/views/layouts/_search.html.haml
+2
-0
app/views/search/_filter.html.haml
app/views/search/_filter.html.haml
+24
-0
app/views/search/_result.html.haml
app/views/search/_result.html.haml
+34
-79
app/views/search/show.html.haml
app/views/search/show.html.haml
+10
-4
No files found.
app/assets/stylesheets/common.scss
View file @
ac8247b4
...
@@ -277,8 +277,20 @@ p.time {
...
@@ -277,8 +277,20 @@ p.time {
}
}
}
}
.search-holder
{
label
,
input
{
height
:
30px
;
padding
:
0
;
font-size
:
14px
;
}
label
{
line-height
:
30px
;
color
:
#666
;
}
}
.highlight_word
{
.highlight_word
{
b
ackground
:
#EEDC94
;
b
order-bottom
:
2px
solid
#F90
;
}
}
.status_info
{
.status_info
{
...
...
app/controllers/search_controller.rb
View file @
ac8247b4
class
SearchController
<
ApplicationController
class
SearchController
<
ApplicationController
def
show
def
show
result
=
SearchContext
.
new
(
current_user
.
authorized_projects
.
map
(
&
:id
),
params
).
execute
project_id
=
params
[
:project_id
]
group_id
=
params
[
:group_id
]
project_ids
=
current_user
.
authorized_projects
.
map
(
&
:id
)
if
group_id
.
present?
group_project_ids
=
Group
.
find
(
group_id
).
projects
.
map
(
&
:id
)
project_ids
.
select!
{
|
id
|
group_project_ids
.
include?
(
id
)}
elsif
project_id
.
present?
project_ids
.
select!
{
|
id
|
id
==
project_id
.
to_i
}
end
result
=
SearchContext
.
new
(
project_ids
,
params
).
execute
@projects
=
result
[
:projects
]
@projects
=
result
[
:projects
]
@merge_requests
=
result
[
:merge_requests
]
@merge_requests
=
result
[
:merge_requests
]
...
...
app/helpers/application_helper.rb
View file @
ac8247b4
...
@@ -72,8 +72,8 @@ module ApplicationHelper
...
@@ -72,8 +72,8 @@ module ApplicationHelper
end
end
def
search_autocomplete_source
def
search_autocomplete_source
projects
=
current_user
.
authorized_projects
.
map
{
|
p
|
{
label:
p
.
name_with_namespace
,
url:
project_path
(
p
)
}
}
projects
=
current_user
.
authorized_projects
.
map
{
|
p
|
{
label:
"project:
#{
p
.
name_with_namespace
}
"
,
url:
project_path
(
p
)
}
}
groups
=
current_user
.
authorized_groups
.
map
{
|
group
|
{
label:
"
<group>
#{
group
.
name
}
"
,
url:
group_path
(
group
)
}
}
groups
=
current_user
.
authorized_groups
.
map
{
|
group
|
{
label:
"
group:
#{
group
.
name
}
"
,
url:
group_path
(
group
)
}
}
default_nav
=
[
default_nav
=
[
{
label:
"My Profile"
,
url:
profile_path
},
{
label:
"My Profile"
,
url:
profile_path
},
...
@@ -83,29 +83,29 @@ module ApplicationHelper
...
@@ -83,29 +83,29 @@ module ApplicationHelper
]
]
help_nav
=
[
help_nav
=
[
{
label:
"API Help"
,
url:
help_api_path
},
{
label:
"
help:
API Help"
,
url:
help_api_path
},
{
label:
"Markdown Help"
,
url:
help_markdown_path
},
{
label:
"
help:
Markdown Help"
,
url:
help_markdown_path
},
{
label:
"Permissions Help"
,
url:
help_permissions_path
},
{
label:
"
help:
Permissions Help"
,
url:
help_permissions_path
},
{
label:
"Public Access Help"
,
url:
help_public_access_path
},
{
label:
"
help:
Public Access Help"
,
url:
help_public_access_path
},
{
label:
"Rake Tasks Help"
,
url:
help_raketasks_path
},
{
label:
"
help:
Rake Tasks Help"
,
url:
help_raketasks_path
},
{
label:
"SSH Keys Help"
,
url:
help_ssh_path
},
{
label:
"
help:
SSH Keys Help"
,
url:
help_ssh_path
},
{
label:
"System Hooks Help"
,
url:
help_system_hooks_path
},
{
label:
"
help:
System Hooks Help"
,
url:
help_system_hooks_path
},
{
label:
"Web Hooks Help"
,
url:
help_web_hooks_path
},
{
label:
"
help:
Web Hooks Help"
,
url:
help_web_hooks_path
},
{
label:
"Workflow Help"
,
url:
help_workflow_path
},
{
label:
"
help:
Workflow Help"
,
url:
help_workflow_path
},
]
]
project_nav
=
[]
project_nav
=
[]
if
@project
&&
@project
.
repository
&&
@project
.
repository
.
root_ref
if
@project
&&
@project
.
repository
&&
@project
.
repository
.
root_ref
project_nav
=
[
project_nav
=
[
{
label:
"
#{
@project
.
name
}
Issues"
,
url:
project_issues_path
(
@project
)
},
{
label:
"
#{
@project
.
name
_with_namespace
}
-
Issues"
,
url:
project_issues_path
(
@project
)
},
{
label:
"
#{
@project
.
name
}
Commits"
,
url:
project_commits_path
(
@project
,
@ref
||
@project
.
repository
.
root_ref
)
},
{
label:
"
#{
@project
.
name
_with_namespace
}
-
Commits"
,
url:
project_commits_path
(
@project
,
@ref
||
@project
.
repository
.
root_ref
)
},
{
label:
"
#{
@project
.
name
}
Merge Requests"
,
url:
project_merge_requests_path
(
@project
)
},
{
label:
"
#{
@project
.
name
_with_namespace
}
-
Merge Requests"
,
url:
project_merge_requests_path
(
@project
)
},
{
label:
"
#{
@project
.
name
}
Milestones"
,
url:
project_milestones_path
(
@project
)
},
{
label:
"
#{
@project
.
name
_with_namespace
}
-
Milestones"
,
url:
project_milestones_path
(
@project
)
},
{
label:
"
#{
@project
.
name
}
Snippets"
,
url:
project_snippets_path
(
@project
)
},
{
label:
"
#{
@project
.
name
_with_namespace
}
-
Snippets"
,
url:
project_snippets_path
(
@project
)
},
{
label:
"
#{
@project
.
name
}
Team"
,
url:
project_team_index_path
(
@project
)
},
{
label:
"
#{
@project
.
name
_with_namespace
}
-
Team"
,
url:
project_team_index_path
(
@project
)
},
{
label:
"
#{
@project
.
name
}
Tree"
,
url:
project_tree_path
(
@project
,
@ref
||
@project
.
repository
.
root_ref
)
},
{
label:
"
#{
@project
.
name
_with_namespace
}
-
Tree"
,
url:
project_tree_path
(
@project
,
@ref
||
@project
.
repository
.
root_ref
)
},
{
label:
"
#{
@project
.
name
}
Wall"
,
url:
wall_project_path
(
@project
)
},
{
label:
"
#{
@project
.
name
_with_namespace
}
-
Wall"
,
url:
wall_project_path
(
@project
)
},
{
label:
"
#{
@project
.
name
}
Wiki"
,
url:
project_wikis_path
(
@project
)
},
{
label:
"
#{
@project
.
name
_with_namespace
}
-
Wiki"
,
url:
project_wikis_path
(
@project
)
},
]
]
end
end
...
...
app/views/layouts/_search.html.haml
View file @
ac8247b4
.search
.search
=
form_tag
search_path
,
method: :get
,
class:
'navbar-form pull-left'
do
|
f
|
=
form_tag
search_path
,
method: :get
,
class:
'navbar-form pull-left'
do
|
f
|
=
text_field_tag
"search"
,
nil
,
placeholder:
"Search"
,
class:
"search-input"
=
text_field_tag
"search"
,
nil
,
placeholder:
"Search"
,
class:
"search-input"
=
hidden_field_tag
:group_id
,
@group
.
try
(
:id
)
=
hidden_field_tag
:project_id
,
@project
.
try
(
:id
)
:javascript
:javascript
$
(
function
(){
$
(
function
(){
...
...
app/views/search/_filter.html.haml
0 → 100644
View file @
ac8247b4
%fieldset
%legend
Groups:
%ul
.nav.nav-pills.nav-stacked
%li
{
class:
(
"active"
if
params
[
:group_id
].
blank?
)}
=
link_to
search_path
(
group_id:
nil
,
search:
params
[
:search
])
do
Any
-
current_user
.
authorized_groups
.
each
do
|
group
|
%li
{
class:
(
"active"
if
params
[
:group_id
]
==
group
.
id
.
to_s
)}
=
link_to
search_path
(
group_id:
group
.
id
,
search:
params
[
:search
])
do
=
group
.
name
%fieldset
%legend
Projects:
%ul
.nav.nav-pills.nav-stacked
%li
{
class:
(
"active"
if
params
[
:project_id
].
blank?
)}
=
link_to
search_path
(
project_id:
nil
,
search:
params
[
:search
])
do
Any
-
current_user
.
authorized_projects
.
each
do
|
project
|
%li
{
class:
(
"active"
if
params
[
:project_id
]
==
project
.
id
.
to_s
)}
=
link_to
search_path
(
project_id:
project
.
id
,
search:
params
[
:search
])
do
=
project
.
name_with_namespace
=
hidden_field_tag
:group_id
,
params
[
:group_id
]
=
hidden_field_tag
:project_id
,
params
[
:project_id
]
app/views/search/_result.html.haml
View file @
ac8247b4
%
br
%
fieldset
%h3
.page_title
%legend
Search results
Search results
%span
.cgray
(
#{
@projects
.
count
+
@merge_requests
.
count
+
@issues
.
count
+
@wiki_pages
.
count
}
)
%span
.cgray
(
#{
@projects
.
count
+
@merge_requests
.
count
+
@issues
.
count
+
@wiki_pages
.
count
}
)
%hr
.search_results
.search_results
.row
%ul
.well-list
.span6
%table
%thead
%tr
%th
Projects
%tbody
-
@projects
.
each
do
|
project
|
-
@projects
.
each
do
|
project
|
%tr
%li
%td
project:
=
link_to
project
do
=
link_to
project
do
%strong
.term
=
project
.
name_with_namespace
%strong
.term
=
project
.
name_with_namespace
%small
.cgray
last activity at
=
project
.
last_activity_date
.
stamp
(
"Aug 25, 2011"
)
-
if
@projects
.
blank?
%tr
%td
%h4
.nothing_here_message
No Projects
%br
%table
%thead
%tr
%th
Merge Requests
%tbody
-
@merge_requests
.
each
do
|
merge_request
|
-
@merge_requests
.
each
do
|
merge_request
|
%tr
%li
%td
merge request:
=
link_to
[
merge_request
.
project
,
merge_request
]
do
=
link_to
[
merge_request
.
project
,
merge_request
]
do
%span
.badge.badge-info
##{merge_request.id}
%span
##{merge_request.id}
–
%strong
.term
%strong
.term
=
truncate
merge_request
.
title
,
length:
50
=
truncate
merge_request
.
title
,
length:
50
%strong
.right
%span
.light
(
#{
merge_request
.
project
.
name_with_namespace
}
)
%span
.label
=
merge_request
.
project
.
name
-
if
@merge_requests
.
blank?
%tr
%td
%h4
.nothing_here_message
No Merge Requests
.span6
%table
%thead
%tr
%th
Issues
%tbody
-
@issues
.
each
do
|
issue
|
-
@issues
.
each
do
|
issue
|
%tr
%li
%td
issue:
=
link_to
[
issue
.
project
,
issue
]
do
=
link_to
[
issue
.
project
,
issue
]
do
%span
.badge.badge-info
##{issue.id}
%span
##{issue.id}
–
%strong
.term
%strong
.term
=
truncate
issue
.
title
,
length:
40
=
truncate
issue
.
title
,
length:
50
%strong
.right
%span
.light
(
#{
issue
.
project
.
name_with_namespace
}
)
%span
.label
=
issue
.
project
.
name
-
if
@issues
.
blank?
%tr
%td
%h4
.nothing_here_message
No Issues
.span6
%table
%thead
%tr
%th
Wiki
%tbody
-
@wiki_pages
.
each
do
|
wiki_page
|
-
@wiki_pages
.
each
do
|
wiki_page
|
%tr
%li
%td
wiki:
=
link_to
project_wiki_path
(
wiki_page
.
project
,
wiki_page
)
do
=
link_to
project_wiki_path
(
wiki_page
.
project
,
wiki_page
)
do
%strong
.term
=
truncate
wiki_page
.
title
,
length:
40
%strong
.term
%strong
.right
=
truncate
wiki_page
.
title
,
length:
50
%span
.label
=
wiki_page
.
project
.
name
%span
.light
(
#{
wiki_page
.
project
.
name_with_namespace
}
)
-
if
@wiki_pages
.
blank?
%tr
%td
%h4
.nothing_here_message
No wiki pages
:javascript
:javascript
$
(
function
()
{
$
(
function
()
{
$
(
"
.search_results .term
"
).
highlight
(
"
#{
escape_javascript
(
params
[
:search
])
}
"
);
$
(
"
.search_results .term
"
).
highlight
(
"
#{
escape_javascript
(
params
[
:search
])
}
"
);
...
...
app/views/search/show.html.haml
View file @
ac8247b4
=
form_tag
search_path
,
method: :get
,
class:
'form-inline'
do
|
f
|
=
form_tag
search_path
,
method: :get
,
class:
'form-inline'
do
|
f
|
.
padded
.
search-holder
=
label_tag
:search
do
=
label_tag
:search
do
%s
trong
Looking for
%s
pan
Looking for
.input
.input
=
search_field_tag
:search
,
params
[
:search
],
placeholder:
"issue 143"
,
class:
"input-xxlarge search-text-input"
,
id:
"dashboard_search"
=
search_field_tag
:search
,
params
[
:search
],
placeholder:
"issue 143"
,
class:
"input-xxlarge search-text-input"
,
id:
"dashboard_search"
=
submit_tag
'Search'
,
class:
"btn primary wide"
=
submit_tag
'Search'
,
class:
"btn primary wide"
-
if
params
[
:search
].
present?
.clearfix
.row
.span3
=
render
'filter'
,
f:
f
.span9
.results
-
if
params
[
:search
].
present?
=
render
'search/result'
=
render
'search/result'
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