Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
8114d36c
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
8114d36c
编写于
11月 07, 2012
作者:
D
Dmitriy Zaporozhets
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1720 from coagulant/wiki_search
Wiki search
上级
d6a5e3da
e6524a91
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
50 addition
and
2 deletion
+50
-2
app/contexts/search_context.rb
app/contexts/search_context.rb
+3
-1
app/controllers/search_controller.rb
app/controllers/search_controller.rb
+1
-0
app/models/wiki.rb
app/models/wiki.rb
+6
-0
app/views/search/show.html.haml
app/views/search/show.html.haml
+18
-1
features/dashboard/search.feature
features/dashboard/search.feature
+5
-0
features/steps/dashboard/dashboard_search.rb
features/steps/dashboard/dashboard_search.rb
+17
-0
未找到文件。
app/contexts/search_context.rb
浏览文件 @
8114d36c
...
...
@@ -13,6 +13,7 @@ class SearchContext
result
[
:projects
]
=
Project
.
where
(
id:
project_ids
).
search
(
query
).
limit
(
10
)
result
[
:merge_requests
]
=
MergeRequest
.
where
(
project_id:
project_ids
).
search
(
query
).
limit
(
10
)
result
[
:issues
]
=
Issue
.
where
(
project_id:
project_ids
).
search
(
query
).
limit
(
10
)
result
[
:wiki_pages
]
=
Wiki
.
where
(
project_id:
project_ids
).
search
(
query
).
limit
(
10
)
result
end
...
...
@@ -20,7 +21,8 @@ class SearchContext
@result
||=
{
projects:
[],
merge_requests:
[],
issues:
[]
issues:
[],
wiki_pages:
[]
}
end
end
...
...
app/controllers/search_controller.rb
浏览文件 @
8114d36c
...
...
@@ -5,5 +5,6 @@ class SearchController < ApplicationController
@projects
=
result
[
:projects
]
@merge_requests
=
result
[
:merge_requests
]
@issues
=
result
[
:issues
]
@wiki_pages
=
result
[
:wiki_pages
]
end
end
app/models/wiki.rb
浏览文件 @
8114d36c
...
...
@@ -15,6 +15,12 @@ class Wiki < ActiveRecord::Base
slug
end
class
<<
self
def
search
(
query
)
where
(
"title like :query OR content like :query"
,
query:
"%
#{
query
}
%"
)
end
end
protected
def
self
.
regenerate_from
wiki
...
...
app/views/search/show.html.haml
浏览文件 @
8114d36c
...
...
@@ -9,7 +9,7 @@
%br
%h3
Search results
%small
(
#{
@projects
.
count
+
@merge_requests
.
count
+
@issues
.
count
}
)
%small
(
#{
@projects
.
count
+
@merge_requests
.
count
+
@issues
.
count
+
@wiki_pages
.
count
}
)
%hr
.search_results
.row
...
...
@@ -69,6 +69,23 @@
%tr
%td
%h4
.nothing_here_message
No Issues
.span6
%table
%thead
%tr
%th
Wiki
%tbody
-
@wiki_pages
.
each
do
|
wiki_page
|
%tr
%td
=
link_to
project_wiki_path
(
wiki_page
.
project
,
wiki_page
)
do
%strong
.term
=
truncate
wiki_page
.
title
,
length:
40
%strong
.right
%span
.label
=
wiki_page
.
project
.
name
-
if
@wiki_pages
.
blank?
%tr
%td
%h4
.nothing_here_message
No wiki pages
:javascript
$
(
function
()
{
$
(
"
.search_results .term
"
).
highlight
(
"
#{
params
[
:search
]
}
"
);
...
...
features/dashboard/search.feature
浏览文件 @
8114d36c
...
...
@@ -2,8 +2,13 @@ Feature: Dashboard Search
Background
:
Given
I sign in as a user
And
I own project
"Shop"
And
Project
"Shop"
has wiki page
"Contibuting guide"
And
I visit dashboard search page
Scenario
:
I
should see project I am looking for
Given
I search for
"Sho"
Then
I should see
"Shop"
project link
Scenario
:
I
should see wiki page I am looking for
Given
I search for
"Contibuting"
Then
I should see
"Contibuting guide"
wiki link
\ No newline at end of file
features/steps/dashboard/dashboard_search.rb
浏览文件 @
8114d36c
...
...
@@ -15,4 +15,21 @@ class DashboardSearch < Spinach::FeatureSteps
@project
=
Factory
:project
,
:name
=>
"Shop"
@project
.
add_access
(
@user
,
:admin
)
end
Given
'I search for "Contibuting"'
do
fill_in
"dashboard_search"
,
:with
=>
"Contibuting"
click_button
"Search"
end
And
'Project "Shop" has wiki page "Contibuting guide"'
do
@wiki_page
=
Factory
:wiki
,
:project
=>
@project
,
:title
=>
"Contibuting guide"
,
:slug
=>
"contributing"
end
Then
'I should see "Contibuting guide" wiki link'
do
page
.
should
have_link
"Contibuting guide"
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录