
Search: Polish
@189fdd7157f99d15bde80e57d0d4ff9e6af50af8
--- app/assets/stylesheets/less/_page.less
+++ app/assets/stylesheets/less/_page.less
... | ... | @@ -223,15 +223,6 @@ |
223 | 223 |
} |
224 | 224 |
} |
225 | 225 |
|
226 |
-.search-box-wrap { |
|
227 |
- border-bottom:1px solid #ddd; |
|
228 |
- padding-bottom:20px; |
|
229 |
- |
|
230 |
- input[type="text"] { |
|
231 |
- margin-bottom: 0; |
|
232 |
- } |
|
233 |
-} |
|
234 |
- |
|
235 | 226 |
.gnb-search-form { |
236 | 227 |
margin:0; |
237 | 228 |
padding:0 10px; |
... | ... | @@ -5727,6 +5718,26 @@ |
5727 | 5718 |
} |
5728 | 5719 |
} |
5729 | 5720 |
|
5721 |
+.search-box-wrap { |
|
5722 |
+ padding-bottom:15px; |
|
5723 |
+ border-bottom: 1px solid #ddd; |
|
5724 |
+ |
|
5725 |
+ input[type="text"] { |
|
5726 |
+ margin-bottom: 0; |
|
5727 |
+ } |
|
5728 |
+ |
|
5729 |
+ h3.search-result-title { |
|
5730 |
+ font-size:16px; |
|
5731 |
+ margin-top: 15px; |
|
5732 |
+ font-weight: normal; |
|
5733 |
+ padding:0 15px; |
|
5734 |
+ |
|
5735 |
+ strong { |
|
5736 |
+ color:#f36c22; |
|
5737 |
+ } |
|
5738 |
+ } |
|
5739 |
+} |
|
5740 |
+ |
|
5730 | 5741 |
.search-list-wrap { |
5731 | 5742 |
list-style: none; |
5732 | 5743 |
display: block; |
... | ... | @@ -5736,11 +5747,11 @@ |
5736 | 5747 |
display: block; |
5737 | 5748 |
float: none; |
5738 | 5749 |
margin:0; |
5739 |
- padding:10px 15px 10px 60px; |
|
5750 |
+ padding:15px; |
|
5740 | 5751 |
border-bottom: 1px solid #ddd; |
5741 | 5752 |
|
5742 | 5753 |
&.project { |
5743 |
- padding:10px 15px; |
|
5754 |
+ padding:15px 15px 15px 60px; |
|
5744 | 5755 |
} |
5745 | 5756 |
} |
5746 | 5757 |
|
... | ... | @@ -5773,8 +5784,8 @@ |
5773 | 5784 |
} |
5774 | 5785 |
|
5775 | 5786 |
.title-wrap { |
5776 |
- line-height: 40px; |
|
5777 |
- font-size: 18px; |
|
5787 |
+ line-height: 30px; |
|
5788 |
+ font-size: 16px; |
|
5778 | 5789 |
font-weight: bold; |
5779 | 5790 |
text-overflow: ellipsis; |
5780 | 5791 |
white-space: nowrap; |
... | ... | @@ -5783,9 +5794,7 @@ |
5783 | 5794 |
.post-id { |
5784 | 5795 |
color:#999; |
5785 | 5796 |
font-weight: normal; |
5786 |
- |
|
5787 |
- |
|
5788 |
- } |
|
5797 |
+ } |
|
5789 | 5798 |
|
5790 | 5799 |
.title { |
5791 | 5800 |
color:#333; |
... | ... | @@ -5806,19 +5815,27 @@ |
5806 | 5815 |
.search-content { |
5807 | 5816 |
display: block; |
5808 | 5817 |
font-size: 14px; |
5809 |
- margin-top: 15px; |
|
5810 |
- border-left: 3px solid #DDD; |
|
5811 |
- padding-left:13px; |
|
5818 |
+ padding-left:20px; |
|
5819 |
+ |
|
5820 |
+ &.np { |
|
5821 |
+ padding-left:0 !important; |
|
5822 |
+ } |
|
5823 |
+ |
|
5812 | 5824 |
} |
5813 | 5825 |
|
5814 | 5826 |
.search-content-body { |
5815 | 5827 |
display: block; |
5816 |
- margin-top:15px; |
|
5817 | 5828 |
} |
5818 | 5829 |
|
5819 | 5830 |
.search-meta-info { |
5820 |
- margin-top:15px; |
|
5831 |
+ margin-top:10px; |
|
5821 | 5832 |
font-size: 13px; |
5833 |
+ color:#999; |
|
5834 |
+ padding-left:20px; |
|
5835 |
+ |
|
5836 |
+ &.np { |
|
5837 |
+ padding-left:0 !important; |
|
5838 |
+ } |
|
5822 | 5839 |
|
5823 | 5840 |
.meta-item { |
5824 | 5841 |
line-height: 20px; |
... | ... | @@ -5826,7 +5843,13 @@ |
5826 | 5843 |
} |
5827 | 5844 |
} |
5828 | 5845 |
|
5829 |
- .project-link, .user-link { |
|
5846 |
+ .project-link { |
|
5847 |
+ &:hover { |
|
5848 |
+ color: #3592b5 !important; |
|
5849 |
+ } |
|
5850 |
+ } |
|
5851 |
+ |
|
5852 |
+ .user-link { |
|
5830 | 5853 |
color: #3592b5 !important; |
5831 | 5854 |
font-weight: bold; |
5832 | 5855 |
} |
--- app/controllers/SearchApp.java
+++ app/controllers/SearchApp.java
... | ... | @@ -1,7 +1,25 @@ |
1 |
+/** |
|
2 |
+ * Yobi, Project Hosting SW |
|
3 |
+ * |
|
4 |
+ * Copyright 2014 NAVER Corp. |
|
5 |
+ * http://yobi.io |
|
6 |
+ * |
|
7 |
+ * @Author Keesun Baik |
|
8 |
+ * |
|
9 |
+ * Licensed under the Apache License, Version 2.0 (the "License"); |
|
10 |
+ * you may not use this file except in compliance with the License. |
|
11 |
+ * You may obtain a copy of the License at |
|
12 |
+ * |
|
13 |
+ * http://www.apache.org/licenses/LICENSE-2.0 |
|
14 |
+ * |
|
15 |
+ * Unless required by applicable law or agreed to in writing, software |
|
16 |
+ * distributed under the License is distributed on an "AS IS" BASIS, |
|
17 |
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
18 |
+ * See the License for the specific language governing permissions and |
|
19 |
+ * limitations under the License. |
|
20 |
+ */ |
|
1 | 21 |
package controllers; |
2 | 22 |
|
3 |
-import com.avaje.ebean.ExpressionList; |
|
4 |
-import com.avaje.ebean.Page; |
|
5 | 23 |
import controllers.annotation.IsAllowed; |
6 | 24 |
import models.*; |
7 | 25 |
import models.enumeration.Operation; |
... | ... | @@ -9,40 +27,67 @@ |
9 | 27 |
import org.apache.commons.lang3.StringUtils; |
10 | 28 |
import play.mvc.Controller; |
11 | 29 |
import play.mvc.Result; |
30 |
+import utils.ErrorViews; |
|
12 | 31 |
import views.html.search.*; |
13 |
-import utils.HttpUtil; |
|
14 | 32 |
|
15 |
-import java.util.List; |
|
16 |
- |
|
17 |
-/** |
|
18 |
- * @author Keeun Baik |
|
19 |
- */ |
|
20 | 33 |
public class SearchApp extends Controller { |
21 | 34 |
|
22 | 35 |
private static final PageParam DEFAULT_PAGE = new PageParam(0, 20); |
23 | 36 |
|
24 | 37 |
/** |
25 |
- * Search from all repositories. |
|
38 |
+ * Search contents that current user can read in all projects. |
|
26 | 39 |
* |
27 | 40 |
* @return |
28 | 41 |
*/ |
29 |
- public static Result searchAllRepos() { |
|
42 |
+ public static Result searchInAll() { |
|
30 | 43 |
// SearchCondition from param |
31 | 44 |
String searchTypeValue = request().getQueryString("searchType"); |
32 | 45 |
String keyword = request().getQueryString("keyword"); |
33 |
- setPage(); |
|
46 |
+ PageParam pageParam = getPage(); |
|
34 | 47 |
|
35 | 48 |
if(StringUtils.isEmpty(keyword) || StringUtils.isEmpty(searchTypeValue)) { |
36 |
- return badRequest(); |
|
49 |
+ return badRequest(ErrorViews.BadRequest.render()); |
|
37 | 50 |
} |
38 | 51 |
|
39 | 52 |
User user = UserApp.currentUser(); |
40 | 53 |
SearchType searchType = SearchType.getValue(searchTypeValue); |
41 | 54 |
|
42 | 55 |
if(searchType == SearchType.NA) { |
43 |
- return badRequest(); |
|
56 |
+ return badRequest(ErrorViews.BadRequest.render()); |
|
44 | 57 |
} |
45 | 58 |
|
59 |
+ SearchResult searchResult = getSearchResult(keyword, user, searchType); |
|
60 |
+ |
|
61 |
+ switch (searchType) { |
|
62 |
+ case ISSUE: |
|
63 |
+ searchResult.setIssues(Search.findIssues(keyword, user, pageParam)); |
|
64 |
+ break; |
|
65 |
+ case USER: |
|
66 |
+ searchResult.setUsers(Search.findUsers(keyword, pageParam)); |
|
67 |
+ break; |
|
68 |
+ case PROJECT: |
|
69 |
+ searchResult.setProjects(Search.findProjects(keyword, user, pageParam)); |
|
70 |
+ break; |
|
71 |
+ case POST: |
|
72 |
+ searchResult.setPosts(Search.findPosts(keyword, user, pageParam)); |
|
73 |
+ break; |
|
74 |
+ case MILESTONE: |
|
75 |
+ searchResult.setMilestones(Search.findMilestones(keyword, user, pageParam)); |
|
76 |
+ break; |
|
77 |
+ case ISSUE_COMMENT: |
|
78 |
+ searchResult.setIssueComments(Search.findIssueComments(keyword, user, pageParam)); |
|
79 |
+ break; |
|
80 |
+ case POST_COMMENT: |
|
81 |
+ searchResult.setPostComments(Search.findPostComments(keyword, user, pageParam)); |
|
82 |
+ break; |
|
83 |
+ case REVIEW: |
|
84 |
+ searchResult.setReviews(Search.findReviews(keyword, user, pageParam)); |
|
85 |
+ break; |
|
86 |
+ } |
|
87 |
+ return ok(result.render("title.search", null, null, searchResult)); |
|
88 |
+ } |
|
89 |
+ |
|
90 |
+ private static SearchResult getSearchResult(String keyword, User user, SearchType searchType) { |
|
46 | 91 |
SearchResult searchResult = new SearchResult(); |
47 | 92 |
searchResult.setKeyword(keyword); |
48 | 93 |
searchResult.setSearchType(searchType); |
... | ... | @@ -54,46 +99,19 @@ |
54 | 99 |
searchResult.setIssueCommentsCount(Search.countIssueComments(keyword, user)); |
55 | 100 |
searchResult.setPostCommentsCount(Search.countPostComments(keyword, user)); |
56 | 101 |
searchResult.setReviewsCount(Search.countReviews(keyword, user)); |
57 |
- |
|
58 |
- switch (searchType) { |
|
59 |
- case ISSUE: |
|
60 |
- searchResult.setIssues(Search.findIssues(keyword, user, DEFAULT_PAGE)); |
|
61 |
- break; |
|
62 |
- case USER: |
|
63 |
- searchResult.setUsers(Search.findUsers(keyword, DEFAULT_PAGE)); |
|
64 |
- break; |
|
65 |
- case PROJECT: |
|
66 |
- searchResult.setProjects(Search.findProjects(keyword, user, DEFAULT_PAGE)); |
|
67 |
- break; |
|
68 |
- case POST: |
|
69 |
- searchResult.setPosts(Search.findPosts(keyword, user, DEFAULT_PAGE)); |
|
70 |
- break; |
|
71 |
- case MILESTONE: |
|
72 |
- searchResult.setMilestones(Search.findMilestones(keyword, user, DEFAULT_PAGE)); |
|
73 |
- break; |
|
74 |
- case ISSUE_COMMENT: |
|
75 |
- searchResult.setIssueComments(Search.findIssueComments(keyword, user, DEFAULT_PAGE)); |
|
76 |
- break; |
|
77 |
- case POST_COMMENT: |
|
78 |
- searchResult.setPostComments(Search.findPostComments(keyword, user, DEFAULT_PAGE)); |
|
79 |
- break; |
|
80 |
- case REVIEW: |
|
81 |
- searchResult.setReviews(Search.findReviews(keyword, user, DEFAULT_PAGE)); |
|
82 |
- break; |
|
83 |
- } |
|
84 |
- return ok(result.render("title.search", null, null, searchResult)); |
|
102 |
+ return searchResult; |
|
85 | 103 |
} |
86 | 104 |
|
87 | 105 |
/** |
88 |
- * Search from an {@link models.Organization} |
|
106 |
+ * Search contents that current user can read in a group. |
|
89 | 107 |
* |
90 | 108 |
* @param organizationName |
91 | 109 |
* @return |
92 | 110 |
*/ |
93 |
- public static Result searchGroupRepos(String organizationName) { |
|
111 |
+ public static Result searchInAGroup(String organizationName) { |
|
94 | 112 |
String searchTypeValue = request().getQueryString("searchType"); |
95 | 113 |
String keyword = request().getQueryString("keyword"); |
96 |
- setPage(); |
|
114 |
+ PageParam pageParam = getPage(); |
|
97 | 115 |
|
98 | 116 |
if(StringUtils.isEmpty(organizationName) |
99 | 117 |
|| StringUtils.isEmpty(keyword) |
... | ... | @@ -105,10 +123,43 @@ |
105 | 123 |
User user = UserApp.currentUser(); |
106 | 124 |
SearchType searchType = SearchType.getValue(searchTypeValue); |
107 | 125 |
|
108 |
- if(searchType == SearchType.NA) { |
|
109 |
- return badRequest(); |
|
126 |
+ if(searchType == SearchType.NA || organization == null) { |
|
127 |
+ return badRequest(ErrorViews.BadRequest.render()); |
|
110 | 128 |
} |
111 | 129 |
|
130 |
+ SearchResult searchResult = getSearchResult(keyword, user, organization, searchType); |
|
131 |
+ |
|
132 |
+ switch (searchType) { |
|
133 |
+ case ISSUE: |
|
134 |
+ searchResult.setIssues(Search.findIssues(keyword, user, organization, pageParam)); |
|
135 |
+ break; |
|
136 |
+ case USER: |
|
137 |
+ searchResult.setUsers(Search.findUsers(keyword, organization, pageParam)); |
|
138 |
+ break; |
|
139 |
+ case PROJECT: |
|
140 |
+ searchResult.setProjects(Search.findProjects(keyword, user, organization, pageParam)); |
|
141 |
+ break; |
|
142 |
+ case POST: |
|
143 |
+ searchResult.setPosts(Search.findPosts(keyword, user, organization, pageParam)); |
|
144 |
+ break; |
|
145 |
+ case MILESTONE: |
|
146 |
+ searchResult.setMilestones(Search.findMilestones(keyword, user, organization, pageParam)); |
|
147 |
+ break; |
|
148 |
+ case ISSUE_COMMENT: |
|
149 |
+ searchResult.setIssueComments(Search.findIssueComments(keyword, user, organization, pageParam)); |
|
150 |
+ break; |
|
151 |
+ case POST_COMMENT: |
|
152 |
+ searchResult.setPostComments(Search.findPostComments(keyword, user, organization, pageParam)); |
|
153 |
+ break; |
|
154 |
+ case REVIEW: |
|
155 |
+ searchResult.setReviews(Search.findReviews(keyword, user, organization, pageParam)); |
|
156 |
+ break; |
|
157 |
+ } |
|
158 |
+ |
|
159 |
+ return ok(result.render("title.search", organization, null, searchResult)); |
|
160 |
+ } |
|
161 |
+ |
|
162 |
+ private static SearchResult getSearchResult(String keyword, User user, Organization organization, SearchType searchType) { |
|
112 | 163 |
SearchResult searchResult = new SearchResult(); |
113 | 164 |
searchResult.setSearchType(searchType); |
114 | 165 |
searchResult.setKeyword(keyword); |
... | ... | @@ -120,57 +171,66 @@ |
120 | 171 |
searchResult.setIssueCommentsCount(Search.countIssueComments(keyword, user, organization)); |
121 | 172 |
searchResult.setPostCommentsCount(Search.countPostComments(keyword, user, organization)); |
122 | 173 |
searchResult.setReviewsCount(Search.countReviews(keyword, user, organization)); |
123 |
- |
|
124 |
- switch (searchType) { |
|
125 |
- case ISSUE: |
|
126 |
- searchResult.setIssues(Search.findIssues(keyword, user, organization, DEFAULT_PAGE)); |
|
127 |
- break; |
|
128 |
- case USER: |
|
129 |
- searchResult.setUsers(Search.findUsers(keyword, organization, DEFAULT_PAGE)); |
|
130 |
- break; |
|
131 |
- case PROJECT: |
|
132 |
- searchResult.setProjects(Search.findProjects(keyword, user, organization, DEFAULT_PAGE)); |
|
133 |
- break; |
|
134 |
- case POST: |
|
135 |
- searchResult.setPosts(Search.findPosts(keyword, user, organization, DEFAULT_PAGE)); |
|
136 |
- break; |
|
137 |
- case MILESTONE: |
|
138 |
- searchResult.setMilestones(Search.findMilestones(keyword, user, organization, DEFAULT_PAGE)); |
|
139 |
- break; |
|
140 |
- case ISSUE_COMMENT: |
|
141 |
- searchResult.setIssueComments(Search.findIssueComments(keyword, user, organization, DEFAULT_PAGE)); |
|
142 |
- break; |
|
143 |
- case POST_COMMENT: |
|
144 |
- searchResult.setPostComments(Search.findPostComments(keyword, user, organization, DEFAULT_PAGE)); |
|
145 |
- break; |
|
146 |
- case REVIEW: |
|
147 |
- searchResult.setReviews(Search.findReviews(keyword, user, organization, DEFAULT_PAGE)); |
|
148 |
- break; |
|
149 |
- } |
|
150 |
- |
|
151 |
- return ok(result.render("title.search", organization, null, searchResult)); |
|
174 |
+ return searchResult; |
|
152 | 175 |
} |
153 | 176 |
|
177 |
+ /** |
|
178 |
+ * Search contents that current user can read in a project. |
|
179 |
+ * |
|
180 |
+ * @param loginId |
|
181 |
+ * @param projectName |
|
182 |
+ * @return |
|
183 |
+ */ |
|
154 | 184 |
@IsAllowed(Operation.READ) |
155 |
- public static Result searchProject(String loginId, String projectName) { |
|
185 |
+ public static Result searchInAProject(String loginId, String projectName) { |
|
156 | 186 |
String searchTypeValue = request().getQueryString("searchType"); |
157 | 187 |
String keyword = request().getQueryString("keyword"); |
158 | 188 |
Project project = Project.findByOwnerAndProjectName(loginId, projectName); |
159 |
- setPage(); |
|
189 |
+ PageParam pageParam = getPage(); |
|
160 | 190 |
|
161 | 191 |
if(StringUtils.isEmpty(keyword) |
162 | 192 |
|| StringUtils.isEmpty(searchTypeValue) |
163 | 193 |
|| project == null) { |
164 |
- return badRequest(); |
|
194 |
+ return badRequest(ErrorViews.BadRequest.render()); |
|
165 | 195 |
} |
166 | 196 |
|
167 | 197 |
User user = UserApp.currentUser(); |
168 | 198 |
SearchType searchType = SearchType.getValue(searchTypeValue); |
169 | 199 |
|
170 | 200 |
if(searchType == SearchType.NA || searchType == SearchType.PROJECT) { |
171 |
- return badRequest(); |
|
201 |
+ return badRequest(ErrorViews.BadRequest.render()); |
|
172 | 202 |
} |
173 | 203 |
|
204 |
+ SearchResult searchResult = getSearchResult(keyword, user, project, searchType); |
|
205 |
+ |
|
206 |
+ switch (searchType) { |
|
207 |
+ case ISSUE: |
|
208 |
+ searchResult.setIssues(Search.findIssues(keyword, user, project, pageParam)); |
|
209 |
+ break; |
|
210 |
+ case USER: |
|
211 |
+ searchResult.setUsers(Search.findUsers(keyword, project, pageParam)); |
|
212 |
+ break; |
|
213 |
+ case POST: |
|
214 |
+ searchResult.setPosts(Search.findPosts(keyword, user, project, pageParam)); |
|
215 |
+ break; |
|
216 |
+ case MILESTONE: |
|
217 |
+ searchResult.setMilestones(Search.findMilestones(keyword, user, project, pageParam)); |
|
218 |
+ break; |
|
219 |
+ case ISSUE_COMMENT: |
|
220 |
+ searchResult.setIssueComments(Search.findIssueComments(keyword, user, project, pageParam)); |
|
221 |
+ break; |
|
222 |
+ case POST_COMMENT: |
|
223 |
+ searchResult.setPostComments(Search.findPostComments(keyword, user, project, pageParam)); |
|
224 |
+ break; |
|
225 |
+ case REVIEW: |
|
226 |
+ searchResult.setReviews(Search.findReviews(keyword, user, project, pageParam)); |
|
227 |
+ break; |
|
228 |
+ } |
|
229 |
+ |
|
230 |
+ return ok(result.render("title.search", null, project, searchResult)); |
|
231 |
+ } |
|
232 |
+ |
|
233 |
+ private static SearchResult getSearchResult(String keyword, User user, Project project, SearchType searchType) { |
|
174 | 234 |
SearchResult searchResult = new SearchResult(); |
175 | 235 |
searchResult.setSearchType(searchType); |
176 | 236 |
searchResult.setKeyword(keyword); |
... | ... | @@ -181,41 +241,17 @@ |
181 | 241 |
searchResult.setIssueCommentsCount(Search.countIssueComments(keyword, user, project)); |
182 | 242 |
searchResult.setPostCommentsCount(Search.countPostComments(keyword, user, project)); |
183 | 243 |
searchResult.setReviewsCount(Search.countReviews(keyword, user, project)); |
184 |
- |
|
185 |
- switch (searchType) { |
|
186 |
- case ISSUE: |
|
187 |
- searchResult.setIssues(Search.findIssues(keyword, user, project, DEFAULT_PAGE)); |
|
188 |
- break; |
|
189 |
- case USER: |
|
190 |
- searchResult.setUsers(Search.findUsers(keyword, project, DEFAULT_PAGE)); |
|
191 |
- break; |
|
192 |
- case POST: |
|
193 |
- searchResult.setPosts(Search.findPosts(keyword, user, project, DEFAULT_PAGE)); |
|
194 |
- break; |
|
195 |
- case MILESTONE: |
|
196 |
- searchResult.setMilestones(Search.findMilestones(keyword, user, project, DEFAULT_PAGE)); |
|
197 |
- break; |
|
198 |
- case ISSUE_COMMENT: |
|
199 |
- searchResult.setIssueComments(Search.findIssueComments(keyword, user, project, DEFAULT_PAGE)); |
|
200 |
- break; |
|
201 |
- case POST_COMMENT: |
|
202 |
- searchResult.setPostComments(Search.findPostComments(keyword, user, project, DEFAULT_PAGE)); |
|
203 |
- break; |
|
204 |
- case REVIEW: |
|
205 |
- searchResult.setReviews(Search.findReviews(keyword, user, project, DEFAULT_PAGE)); |
|
206 |
- break; |
|
207 |
- } |
|
208 |
- |
|
209 |
- return ok(result.render("title.search", null, project, searchResult)); |
|
244 |
+ return searchResult; |
|
210 | 245 |
} |
211 | 246 |
|
212 |
- private static void setPage() { |
|
247 |
+ private static PageParam getPage() { |
|
248 |
+ PageParam pageParam = new PageParam(DEFAULT_PAGE.getPage(), DEFAULT_PAGE.getSize()); |
|
213 | 249 |
String pageNumString = request().getQueryString("pageNum"); |
214 |
- |
|
215 | 250 |
if(pageNumString != null) { |
216 | 251 |
int pageNum = Integer.parseInt(pageNumString); |
217 |
- DEFAULT_PAGE.setPage(pageNum - 1); |
|
252 |
+ pageParam.setPage(pageNum - 1); |
|
218 | 253 |
} |
254 |
+ return pageParam; |
|
219 | 255 |
} |
220 | 256 |
|
221 | 257 |
} |
--- app/models/PageParam.java
+++ app/models/PageParam.java
... | ... | @@ -1,7 +1,30 @@ |
1 |
+/** |
|
2 |
+ * Yobi, Project Hosting SW |
|
3 |
+ * |
|
4 |
+ * Copyright 2014 NAVER Corp. |
|
5 |
+ * http://yobi.io |
|
6 |
+ * |
|
7 |
+ * @Author Keesun Baik |
|
8 |
+ * |
|
9 |
+ * Licensed under the Apache License, Version 2.0 (the "License"); |
|
10 |
+ * you may not use this file except in compliance with the License. |
|
11 |
+ * You may obtain a copy of the License at |
|
12 |
+ * |
|
13 |
+ * http://www.apache.org/licenses/LICENSE-2.0 |
|
14 |
+ * |
|
15 |
+ * Unless required by applicable law or agreed to in writing, software |
|
16 |
+ * distributed under the License is distributed on an "AS IS" BASIS, |
|
17 |
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
18 |
+ * See the License for the specific language governing permissions and |
|
19 |
+ * limitations under the License. |
|
20 |
+ */ |
|
1 | 21 |
package models; |
2 | 22 |
|
3 | 23 |
/** |
4 |
- * @author Keeun Baik |
|
24 |
+ * To make paged result, you always have to pass at least two parameters, page and size. |
|
25 |
+ * This class can be used to reduce parameters to pass. |
|
26 |
+ * |
|
27 |
+ * @see {@link Search#findUsers(String, PageParam)} |
|
5 | 28 |
*/ |
6 | 29 |
public class PageParam { |
7 | 30 |
|
--- app/models/Search.java
+++ app/models/Search.java
... | ... | @@ -1,14 +1,34 @@ |
1 |
+/** |
|
2 |
+ * Yobi, Project Hosting SW |
|
3 |
+ * |
|
4 |
+ * Copyright 2014 NAVER Corp. |
|
5 |
+ * http://yobi.io |
|
6 |
+ * |
|
7 |
+ * @Author Keesun Baik |
|
8 |
+ * |
|
9 |
+ * Licensed under the Apache License, Version 2.0 (the "License"); |
|
10 |
+ * you may not use this file except in compliance with the License. |
|
11 |
+ * You may obtain a copy of the License at |
|
12 |
+ * |
|
13 |
+ * http://www.apache.org/licenses/LICENSE-2.0 |
|
14 |
+ * |
|
15 |
+ * Unless required by applicable law or agreed to in writing, software |
|
16 |
+ * distributed under the License is distributed on an "AS IS" BASIS, |
|
17 |
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
18 |
+ * See the License for the specific language governing permissions and |
|
19 |
+ * limitations under the License. |
|
20 |
+ */ |
|
1 | 21 |
package models; |
2 | 22 |
|
3 | 23 |
import com.avaje.ebean.*; |
24 |
+import models.enumeration.Operation; |
|
4 | 25 |
import models.enumeration.ProjectScope; |
5 | 26 |
import models.enumeration.UserState; |
27 |
+import utils.AccessControl; |
|
6 | 28 |
|
29 |
+import java.util.ArrayList; |
|
7 | 30 |
import java.util.List; |
8 | 31 |
|
9 |
-/** |
|
10 |
- * @author Keeun Baik |
|
11 |
- */ |
|
12 | 32 |
public class Search { |
13 | 33 |
|
14 | 34 |
private static final String DEFAULT_PATH_TO_PROJECT = "project"; |
... | ... | @@ -138,20 +158,13 @@ |
138 | 158 |
|
139 | 159 |
private static ExpressionList<Issue> issuesEL(String keyword, User user, Project project) { |
140 | 160 |
ExpressionList<Issue> el = Issue.finder.where().eq("project", project); |
141 |
- |
|
142 |
- if(isAllowed(user, project)) { |
|
143 |
- Junction<Issue> junction = el.disjunction(); |
|
144 |
- containsKeywordIn(keyword, junction, new String[]{"title", "body"}); |
|
145 |
- junction.endJunction(); |
|
146 |
- } else { |
|
161 |
+ if(!AccessControl.isAllowed(user, project.asResource(), Operation.READ)) { |
|
147 | 162 |
Junction<Issue> junction = el.disjunction(); |
148 | 163 |
junction.add(Expr.eq("authorId", user.id)); |
149 | 164 |
junction.add(Expr.eq("assignee.user.id", user.id)); |
150 | 165 |
junction.endJunction(); |
151 |
- containsKeywordIn(keyword, el.conjunction(), new String[]{"title", "body"}); |
|
152 |
- |
|
153 | 166 |
} |
154 |
- |
|
167 |
+ containsKeywordIn(keyword, el.conjunction(), new String[]{"title", "body"}); |
|
155 | 168 |
el.orderBy().desc("createdDate"); |
156 | 169 |
return el; |
157 | 170 |
} |
... | ... | @@ -270,17 +283,10 @@ |
270 | 283 |
private static ExpressionList<Posting> postsEL(String keyword, User user, Project project) { |
271 | 284 |
ExpressionList<Posting> el = Posting.finder.where() |
272 | 285 |
.eq("project", project); |
273 |
- |
|
274 |
- if(isAllowed(user, project)) { |
|
275 |
- Junction<Posting> junction = el.disjunction(); |
|
276 |
- containsKeywordIn(keyword, junction, new String[]{"title", "body"}); |
|
277 |
- junction.endJunction(); |
|
278 |
- equalsUserTemplate(keyword, user, junction, DEFAULT_PATH_TO_AUTHOR, containsKeywordInPosting); |
|
279 |
- } else { |
|
286 |
+ if(!AccessControl.isAllowed(user, project.asResource(), Operation.READ)) { |
|
280 | 287 |
el.eq("authorId", user.id); |
281 |
- containsKeywordIn(keyword, el.conjunction(), new String[]{"title", "body"}); |
|
282 | 288 |
} |
283 |
- |
|
289 |
+ containsKeywordIn(keyword, el.conjunction(), new String[]{"title", "body"}); |
|
284 | 290 |
el.orderBy().desc("createdDate"); |
285 | 291 |
return el; |
286 | 292 |
} |
... | ... | @@ -360,7 +366,7 @@ |
360 | 366 |
} |
361 | 367 |
|
362 | 368 |
/** |
363 |
- * Find all users in a {@code project} who contains the {@code keyword} in name or loginId. |
|
369 |
+ * Finds all users in a {@code project} who contains the {@code keyword} in name or loginId. |
|
364 | 370 |
* |
365 | 371 |
* @param keyword |
366 | 372 |
* @param project |
... | ... | @@ -396,7 +402,7 @@ |
396 | 402 |
} |
397 | 403 |
|
398 | 404 |
/** |
399 |
- * Find all users in an {@code organization} who contains the {@code keyword} in name or loginId. |
|
405 |
+ * Finds all users in an {@code organization} who contains the {@code keyword} in name or loginId. |
|
400 | 406 |
* |
401 | 407 |
* @param keyword |
402 | 408 |
* @param organization |
... | ... | @@ -460,7 +466,7 @@ |
460 | 466 |
} |
461 | 467 |
|
462 | 468 |
/** |
463 |
- * Find all projects in an {@code organization} that contains the {@code keyword} in name or overview. |
|
469 |
+ * Finds all projects in an {@code organization} that contains the {@code keyword} in name or overview. |
|
464 | 470 |
* |
465 | 471 |
* @param keyword |
466 | 472 |
* @param user |
... | ... | @@ -531,10 +537,16 @@ |
531 | 537 |
} |
532 | 538 |
|
533 | 539 |
public static Page<Milestone> findMilestones(String keyword, User user, Project project, PageParam pageParam) { |
540 |
+ if(!AccessControl.isAllowed(user, project.asResource(), Operation.READ)) { |
|
541 |
+ return emptyPage(); |
|
542 |
+ } |
|
534 | 543 |
return milestonesEL(keyword, project).findPagingList(pageParam.getSize()).getPage(pageParam.getPage()); |
535 | 544 |
} |
536 | 545 |
|
537 | 546 |
public static int countMilestones(String keyword, User user, Project project) { |
547 |
+ if(!AccessControl.isAllowed(user, project.asResource(), Operation.READ)) { |
|
548 |
+ return 0; |
|
549 |
+ } |
|
538 | 550 |
return milestonesEL(keyword, project).findRowCount(); |
539 | 551 |
} |
540 | 552 |
|
... | ... | @@ -595,17 +607,10 @@ |
595 | 607 |
private static ExpressionList<IssueComment> issueCommentsEL(String keyword, User user, Project project) { |
596 | 608 |
ExpressionList<IssueComment> el = IssueComment.find.where() |
597 | 609 |
.eq("issue.project", project); |
598 |
- |
|
599 |
- if(isAllowed(user, project)) { |
|
600 |
- Junction<IssueComment> junction = el.disjunction(); |
|
601 |
- containsKeywordIn(keyword, junction, new String[]{"contents"}); |
|
602 |
- junction.endJunction(); |
|
603 |
- equalsUserTemplate(keyword, user, junction, DEFAULT_PATH_TO_AUTHOR, containsKeywordInIssueComment); |
|
604 |
- } else { |
|
610 |
+ if(!AccessControl.isAllowed(user, project.asResource(), Operation.READ)) { |
|
605 | 611 |
el.eq("authorId", user.id); |
606 |
- containsKeywordIn(keyword, el.conjunction(), new String[]{"contents"}); |
|
607 | 612 |
} |
608 |
- |
|
613 |
+ containsKeywordIn(keyword, el.conjunction(), new String[]{"contents"}); |
|
609 | 614 |
el.orderBy().desc("createdDate"); |
610 | 615 |
return el; |
611 | 616 |
} |
... | ... | @@ -659,16 +664,10 @@ |
659 | 664 |
ExpressionList<PostingComment> el = PostingComment.find.where() |
660 | 665 |
.eq("posting.project", project); |
661 | 666 |
|
662 |
- if(isAllowed(user, project)) { |
|
663 |
- Junction<PostingComment> junction = el.disjunction(); |
|
664 |
- containsKeywordIn(keyword, junction, new String[]{"contents"}); |
|
665 |
- junction.endJunction(); |
|
666 |
- equalsUserTemplate(keyword, user, junction, DEFAULT_PATH_TO_AUTHOR, containsKeywordInPostComment); |
|
667 |
- } else { |
|
667 |
+ if(!AccessControl.isAllowed(user, project.asResource(), Operation.READ)) { |
|
668 | 668 |
el.eq("authorId", user.id); |
669 |
- containsKeywordIn(keyword, el.conjunction(), new String[]{"contents"}); |
|
670 | 669 |
} |
671 |
- |
|
670 |
+ containsKeywordIn(keyword, el.conjunction(), new String[]{"contents"}); |
|
672 | 671 |
el.orderBy().desc("createdDate"); |
673 | 672 |
return el; |
674 | 673 |
} |
... | ... | @@ -721,17 +720,10 @@ |
721 | 720 |
private static ExpressionList<ReviewComment> reviewsEL(String keyword, User user, Project project) { |
722 | 721 |
ExpressionList<ReviewComment> el = ReviewComment.find.where() |
723 | 722 |
.eq("thread.project", project); |
724 |
- |
|
725 |
- if(isAllowed(user, project)) { |
|
726 |
- Junction<ReviewComment> junction = el.disjunction(); |
|
727 |
- containsKeywordIn(keyword, junction, new String[]{"contents"}); |
|
728 |
- junction.endJunction(); |
|
729 |
- equalsUserTemplate(keyword, user, junction, "author.id", containsKeywordInReviewComment); |
|
730 |
- } else { |
|
723 |
+ if(!AccessControl.isAllowed(user, project.asResource(), Operation.READ)) { |
|
731 | 724 |
el.eq("author.id", user.id); |
732 |
- containsKeywordIn(keyword, el.conjunction(), new String[]{"contents"}); |
|
733 | 725 |
} |
734 |
- |
|
726 |
+ containsKeywordIn(keyword, el.conjunction(), new String[]{"contents"}); |
|
735 | 727 |
el.orderBy().desc("createdDate"); |
736 | 728 |
return el; |
737 | 729 |
} |
... | ... | @@ -837,10 +829,53 @@ |
837 | 829 |
} |
838 | 830 |
} |
839 | 831 |
|
840 |
- private static boolean isAllowed(User user, Project project) { |
|
841 |
- return project.projectScope == ProjectScope.PUBLIC |
|
842 |
- || ProjectUser.isMember(user.id, project.id) |
|
843 |
- || (project.projectScope == ProjectScope.PROTECTED && OrganizationUser.exist(project.organization.id, user.id)); |
|
832 |
+ private static <T> Page<T> emptyPage() { |
|
833 |
+ return new Page<T>() { |
|
834 |
+ @Override |
|
835 |
+ public List<T> getList() { |
|
836 |
+ return new ArrayList<>(); |
|
837 |
+ } |
|
838 |
+ |
|
839 |
+ @Override |
|
840 |
+ public int getTotalRowCount() { |
|
841 |
+ return 0; |
|
842 |
+ } |
|
843 |
+ |
|
844 |
+ @Override |
|
845 |
+ public int getTotalPageCount() { |
|
846 |
+ return 0; |
|
847 |
+ } |
|
848 |
+ |
|
849 |
+ @Override |
|
850 |
+ public int getPageIndex() { |
|
851 |
+ return 0; |
|
852 |
+ } |
|
853 |
+ |
|
854 |
+ @Override |
|
855 |
+ public boolean hasNext() { |
|
856 |
+ return false; |
|
857 |
+ } |
|
858 |
+ |
|
859 |
+ @Override |
|
860 |
+ public boolean hasPrev() { |
|
861 |
+ return false; |
|
862 |
+ } |
|
863 |
+ |
|
864 |
+ @Override |
|
865 |
+ public Page<T> next() { |
|
866 |
+ return null; |
|
867 |
+ } |
|
868 |
+ |
|
869 |
+ @Override |
|
870 |
+ public Page<T> prev() { |
|
871 |
+ return null; |
|
872 |
+ } |
|
873 |
+ |
|
874 |
+ @Override |
|
875 |
+ public String getDisplayXtoYofZ(String s, String s2) { |
|
876 |
+ return null; |
|
877 |
+ } |
|
878 |
+ }; |
|
844 | 879 |
} |
845 | 880 |
|
846 | 881 |
} |
--- app/models/SearchResult.java
+++ app/models/SearchResult.java
... | ... | @@ -1,3 +1,23 @@ |
1 |
+/** |
|
2 |
+ * Yobi, Project Hosting SW |
|
3 |
+ * |
|
4 |
+ * Copyright 2014 NAVER Corp. |
|
5 |
+ * http://yobi.io |
|
6 |
+ * |
|
7 |
+ * @Author Keesun Baik |
|
8 |
+ * |
|
9 |
+ * Licensed under the Apache License, Version 2.0 (the "License"); |
|
10 |
+ * you may not use this file except in compliance with the License. |
|
11 |
+ * You may obtain a copy of the License at |
|
12 |
+ * |
|
13 |
+ * http://www.apache.org/licenses/LICENSE-2.0 |
|
14 |
+ * |
|
15 |
+ * Unless required by applicable law or agreed to in writing, software |
|
16 |
+ * distributed under the License is distributed on an "AS IS" BASIS, |
|
17 |
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
18 |
+ * See the License for the specific language governing permissions and |
|
19 |
+ * limitations under the License. |
|
20 |
+ */ |
|
1 | 21 |
package models; |
2 | 22 |
|
3 | 23 |
import com.avaje.ebean.Page; |
... | ... | @@ -8,9 +28,6 @@ |
8 | 28 |
import java.util.LinkedList; |
9 | 29 |
import java.util.List; |
10 | 30 |
|
11 |
-/** |
|
12 |
- * @author Keeun Baik |
|
13 |
- */ |
|
14 | 31 |
public class SearchResult { |
15 | 32 |
|
16 | 33 |
private String keyword; |
... | ... | @@ -34,17 +51,17 @@ |
34 | 51 |
private Page<PostingComment> postComments; |
35 | 52 |
private Page<ReviewComment> reviews; |
36 | 53 |
|
37 |
- public List<String> makeSnipets(String contents, int threshold) { |
|
54 |
+ public List<String> makeSnippets(String contents, int threshold) { |
|
38 | 55 |
String lowerCaseContents = contents.toLowerCase(); |
39 |
- String lowerCasekeyword = keyword.toLowerCase(); |
|
56 |
+ String lowerCaseKeyword = keyword.toLowerCase(); |
|
40 | 57 |
|
41 | 58 |
LinkedList<BeginAndEnd> beginAndEnds = new LinkedList<>(); |
42 |
- List<Integer> indexes = findIndexes(lowerCaseContents, lowerCasekeyword); // 6, 40 |
|
59 |
+ List<Integer> indexes = findIndexes(lowerCaseContents, lowerCaseKeyword); // 6, 40 |
|
43 | 60 |
|
44 | 61 |
for(int i = 0 ; i < indexes.size() ; i++) { |
45 | 62 |
int currentIndex = indexes.get(i); |
46 | 63 |
int beginIndex = beginIndex(currentIndex, threshold); |
47 |
- int endIndex = endIndex(currentIndex + lowerCasekeyword.length(), lowerCaseContents.length(), threshold); |
|
64 |
+ int endIndex = endIndex(currentIndex + lowerCaseKeyword.length(), lowerCaseContents.length(), threshold); |
|
48 | 65 |
BeginAndEnd thisOne = new BeginAndEnd(beginIndex, endIndex); |
49 | 66 |
if(i == 0) { |
50 | 67 |
beginAndEnds.push(thisOne); |
... | ... | @@ -62,12 +79,12 @@ |
62 | 79 |
|
63 | 80 |
Collections.reverse(beginAndEnds); |
64 | 81 |
|
65 |
- List<String> snipets = new ArrayList<>(); |
|
82 |
+ List<String> snippets = new ArrayList<>(); |
|
66 | 83 |
for(BeginAndEnd bae : beginAndEnds) { |
67 |
- snipets.add(contents.substring(bae.beginIndex, bae.endIndex)); |
|
84 |
+ snippets.add(contents.substring(bae.beginIndex, bae.endIndex)); |
|
68 | 85 |
} |
69 | 86 |
|
70 |
- return snipets; |
|
87 |
+ return snippets; |
|
71 | 88 |
} |
72 | 89 |
|
73 | 90 |
private List<Integer> findIndexes(String contents, String keyword) { |
--- app/models/enumeration/SearchType.java
+++ app/models/enumeration/SearchType.java
... | ... | @@ -5,7 +5,7 @@ |
5 | 5 |
*/ |
6 | 6 |
public enum SearchType { |
7 | 7 |
|
8 |
- NA("not availeable"), USER("user"), PROJECT("project"), ISSUE("issue"), POST("post"), |
|
8 |
+ NA("not available"), USER("user"), PROJECT("project"), ISSUE("issue"), POST("post"), |
|
9 | 9 |
MILESTONE("milestone"), ISSUE_COMMENT("issue_comment"), POST_COMMENT("post_comment"), REVIEW("review"); |
10 | 10 |
|
11 | 11 |
private String searchType; |
--- app/views/organizationLayout.scala.html
+++ app/views/organizationLayout.scala.html
... | ... | @@ -1,7 +1,7 @@ |
1 | 1 |
@** |
2 | 2 |
* Yobi, Project Hosting SW |
3 | 3 |
* |
4 |
-* Copyright 2013 NAVER Corp. |
|
4 |
+* Copyright 2014 NAVER Corp. |
|
5 | 5 |
* http://yobi.io |
6 | 6 |
* |
7 | 7 |
* @Author Insanehong |
--- app/views/search/partial_issue_comments.scala.html
+++ app/views/search/partial_issue_comments.scala.html
... | ... | @@ -29,29 +29,21 @@ |
29 | 29 |
<ul class="search-list-wrap"> |
30 | 30 |
@for(comment <- page.getList) { |
31 | 31 |
@defining(User.findByLoginId(comment.authorLoginId)){ user => |
32 |
- <li class="search-list-item @if(project != null) {project}"> |
|
33 |
- @if(project == null) { |
|
34 |
- <a href="@routes.ProjectApp.project(comment.issue.project.owner, comment.issue.project.name)" class="avatar-wrap"> |
|
35 |
- <img src="@urlToProjectLogo(comment.issue.project)"> |
|
36 |
- </a> |
|
37 |
- } |
|
32 |
+ <li class="search-list-item"> |
|
38 | 33 |
<div class="title-wrap"> |
39 |
- <span class="state @comment.issue.state.state.toLowerCase">@Messages("issue.state." + comment.issue.state.state.toLowerCase)</span> |
|
40 | 34 |
<span class="post-id">#@comment.issue.getNumber</span> |
41 | 35 |
<a href="@routes.IssueApp.issue(comment.issue.project.owner, comment.issue.project.name, comment.issue.getNumber)#comment-@comment.id"> |
42 | 36 |
Re) @comment.issue.title |
43 | 37 |
</a> |
44 | 38 |
</div> |
45 | 39 |
<div class="search-content"> |
46 |
- @defining(searchResult.makeSnipets(comment.contents, 40)) { snipets => |
|
47 |
- @if(snipets != null && snipets.size > 0) { |
|
48 |
- @for(snipet <- snipets) { |
|
49 |
- <p class="search-content-body"> |
|
50 |
- @snipet @if(snipet.size < comment.contents.size) { ..... } |
|
51 |
- </p> |
|
52 |
- } |
|
53 |
- } |
|
54 |
- } |
|
40 |
+ @defining(searchResult.makeSnippets(comment.contents, 40)) { snippets => |
|
41 |
+ @for(snippet <- snippets) { |
|
42 |
+ <p class="search-content-body"> |
|
43 |
+ @snippet @if(snippet.size < comment.contents.size) { ..... } |
|
44 |
+ </p> |
|
45 |
+ } |
|
46 |
+ } |
|
55 | 47 |
</div> |
56 | 48 |
<div class="search-meta-info"> |
57 | 49 |
@if(project == null) { |
... | ... | @@ -59,13 +51,6 @@ |
59 | 51 |
@comment.issue.project.owner/@comment.issue.project.name |
60 | 52 |
</a> |
61 | 53 |
} |
62 |
- <a href="@routes.UserApp.userInfo(user.loginId)" class="avatar-wrap meta" data-toggle="tooltip" data-placement="top" title="@user.loginId"> |
|
63 |
- @if(user.avatarUrl == UserApp.DEFAULT_AVATAR_URL){ |
|
64 |
- <img src="@urlToPicture(user.email, 16)"> |
|
65 |
- } else { |
|
66 |
- <img src="@user.avatarUrl" alt="@user.name" width="16" height="16"/> |
|
67 |
- } |
|
68 |
- </a> |
|
69 | 54 |
@if(user.name){ |
70 | 55 |
<a href="@routes.UserApp.userInfo(user.loginId)" class="meta-item" data-toggle="tooltip" data-placement="top" title="@user.loginId"> |
71 | 56 |
@user.name |
--- app/views/search/partial_issues.scala.html
+++ app/views/search/partial_issues.scala.html
... | ... | @@ -31,29 +31,21 @@ |
31 | 31 |
<ul class="search-list-wrap"> |
32 | 32 |
@for(issue <- page.getList) { |
33 | 33 |
@defining(User.findByLoginId(issue.authorLoginId)){ user => |
34 |
- <li class="search-list-item @if(project != null) {project}"> |
|
35 |
- @if(project == null) { |
|
36 |
- <a href="@routes.ProjectApp.project(issue.project.owner, issue.project.name)" class="avatar-wrap"> |
|
37 |
- <img src="@urlToProjectLogo(issue.project)"> |
|
38 |
- </a> |
|
39 |
- } |
|
34 |
+ <li class="search-list-item"> |
|
40 | 35 |
<div class="title-wrap"> |
41 |
- <span class="state @issue.state.state.toLowerCase">@Messages("issue.state." + issue.state.state.toLowerCase)</span> |
|
42 | 36 |
<span class="post-id">#@issue.getNumber</span> |
43 | 37 |
<a href="@routes.IssueApp.issue(issue.project.owner, issue.project.name, issue.getNumber)" class="title"> |
44 | 38 |
@issue.title |
45 | 39 |
</a> |
46 | 40 |
</div> |
47 | 41 |
<div class="search-content"> |
48 |
- @defining(searchResult.makeSnipets(issue.body, 40)) { snipets => |
|
49 |
- @if(snipets != null && snipets.size > 0) { |
|
50 |
- @for(snipet <- snipets) { |
|
51 |
- <p class="search-content-body"> |
|
52 |
- @snipet @if(snipet.size < issue.body.size) { ..... } |
|
53 |
- </p> |
|
54 |
- } |
|
55 |
- } |
|
42 |
+ @defining(searchResult.makeSnippets(issue.body, 40)) { snippets => |
|
43 |
+ @for(snippet <- snippets) { |
|
44 |
+ <p class="search-content-body"> |
|
45 |
+ @snippet @if(snippet.size < issue.body.size) { ..... } |
|
46 |
+ </p> |
|
56 | 47 |
} |
48 |
+ } |
|
57 | 49 |
</div> |
58 | 50 |
<div class="search-meta-info"> |
59 | 51 |
@if(project == null) { |
... | ... | @@ -61,13 +53,6 @@ |
61 | 53 |
@issue.project.owner/@issue.project.name |
62 | 54 |
</a> |
63 | 55 |
} |
64 |
- <a href="@routes.UserApp.userInfo(user.loginId)" class="avatar-wrap meta" data-toggle="tooltip" data-placement="top" title="@user.loginId"> |
|
65 |
- @if(user.avatarUrl == UserApp.DEFAULT_AVATAR_URL){ |
|
66 |
- <img src="@urlToPicture(user.email, 16)"> |
|
67 |
- } else { |
|
68 |
- <img src="@user.avatarUrl" alt="@user.name" width="16" height="16"/> |
|
69 |
- } |
|
70 |
- </a> |
|
71 | 56 |
@if(user.name){ |
72 | 57 |
<a href="@routes.UserApp.userInfo(user.loginId)" class="meta-item" data-toggle="tooltip" data-placement="top" title="@user.loginId"> |
73 | 58 |
@user.name |
--- app/views/search/partial_milestones.scala.html
+++ app/views/search/partial_milestones.scala.html
... | ... | @@ -37,26 +37,18 @@ |
37 | 37 |
@if(page.getList.length > 0) { |
38 | 38 |
<ul class="search-list-wrap"> |
39 | 39 |
@for(milestone <- page.getList) { |
40 |
- <li class="search-list-item @if(project != null) {project}"> |
|
41 |
- @if(project == null) { |
|
42 |
- <a href="@routes.ProjectApp.project(milestone.project.owner, milestone.project.name)" class="avatar-wrap"> |
|
43 |
- <img src="@urlToProjectLogo(milestone.project)"> |
|
44 |
- </a> |
|
45 |
- } |
|
40 |
+ <li class="search-list-item"> |
|
46 | 41 |
<div class="title-wrap"> |
47 |
- <span class="state @milestone.state.state.toLowerCase">@Messages("milestone.state." + milestone.state.state.toLowerCase)</span> |
|
48 | 42 |
<a href="@routes.MilestoneApp.milestone(milestone.project.owner, milestone.project.name, milestone.id)" class="title"> |
49 | 43 |
@milestone.title |
50 | 44 |
</a> |
51 | 45 |
</div> |
52 | 46 |
<div class="search-content"> |
53 |
- @defining(searchResult.makeSnipets(milestone.contents, 40)) { snipets => |
|
54 |
- @if(snipets != null && snipets.size > 0) { |
|
55 |
- @for(snipet <- snipets) { |
|
56 |
- <p class="search-content-body"> |
|
57 |
- @snipet @if(snipet.size < milestone.contents.size) { ..... } |
|
58 |
- </p> |
|
59 |
- } |
|
47 |
+ @defining(searchResult.makeSnippets(milestone.contents, 40)) { snippets => |
|
48 |
+ @for(snippet <- snippets) { |
|
49 |
+ <p class="search-content-body"> |
|
50 |
+ @snippet @if(snippet.size < milestone.contents.size) { ..... } |
|
51 |
+ </p> |
|
60 | 52 |
} |
61 | 53 |
} |
62 | 54 |
</div> |
--- app/views/search/partial_post_comments.scala.html
+++ app/views/search/partial_post_comments.scala.html
... | ... | @@ -29,12 +29,7 @@ |
29 | 29 |
<ul class="search-list-wrap"> |
30 | 30 |
@for(comment <- page.getList) { |
31 | 31 |
@defining(User.findByLoginId(comment.authorLoginId)){ user => |
32 |
- <li class="search-list-item @if(project != null) {project}"> |
|
33 |
- @if(project == null) { |
|
34 |
- <a href="@routes.ProjectApp.project(comment.posting.project.owner, comment.posting.project.name)" class="avatar-wrap"> |
|
35 |
- <img src="@urlToProjectLogo(comment.posting.project)"> |
|
36 |
- </a> |
|
37 |
- } |
|
32 |
+ <li class="search-list-item"> |
|
38 | 33 |
<div class="title-wrap"> |
39 | 34 |
<span class="post-id">#@comment.posting.getNumber</span> |
40 | 35 |
<a href="@routes.BoardApp.post(comment.posting.project.owner, comment.posting.project.name, comment.posting.getNumber)#comment-@comment.id"> |
... | ... | @@ -42,15 +37,13 @@ |
42 | 37 |
</a> |
43 | 38 |
</div> |
44 | 39 |
<div class="search-content"> |
45 |
- @defining(searchResult.makeSnipets(comment.contents, 40)) { snipets => |
|
46 |
- @if(snipets != null && snipets.size > 0) { |
|
47 |
- @for(snipet <- snipets) { |
|
48 |
- <p class="search-content-body"> |
|
49 |
- @snipet @if(snipet.size < comment.contents.size) { ..... } |
|
50 |
- </p> |
|
51 |
- } |
|
52 |
- } |
|
53 |
- } |
|
40 |
+ @defining(searchResult.makeSnippets(comment.contents, 40)) { snippets => |
|
41 |
+ @for(snippet <- snippets) { |
|
42 |
+ <p class="search-content-body"> |
|
43 |
+ @snippet @if(snippet.size < comment.contents.size) { ..... } |
|
44 |
+ </p> |
|
45 |
+ } |
|
46 |
+ } |
|
54 | 47 |
</div> |
55 | 48 |
<div class="search-meta-info"> |
56 | 49 |
@if(project == null) { |
... | ... | @@ -58,13 +51,6 @@ |
58 | 51 |
@comment.posting.project.owner/@comment.posting.project.name |
59 | 52 |
</a> |
60 | 53 |
} |
61 |
- <a href="@routes.UserApp.userInfo(user.loginId)" class="avatar-wrap meta" data-toggle="tooltip" data-placement="top" title="@user.loginId"> |
|
62 |
- @if(user.avatarUrl == UserApp.DEFAULT_AVATAR_URL){ |
|
63 |
- <img src="@urlToPicture(user.email, 16)"> |
|
64 |
- } else { |
|
65 |
- <img src="@user.avatarUrl" alt="@user.name" width="16" height="16"/> |
|
66 |
- } |
|
67 |
- </a> |
|
68 | 54 |
@if(user.name){ |
69 | 55 |
<a href="@routes.UserApp.userInfo(user.loginId)" class="meta-item" data-toggle="tooltip" data-placement="top" title="@user.loginId"> |
70 | 56 |
@user.name |
--- app/views/search/partial_posts.scala.html
+++ app/views/search/partial_posts.scala.html
... | ... | @@ -29,12 +29,7 @@ |
29 | 29 |
<ul class="search-list-wrap"> |
30 | 30 |
@for(post <- page.getList) { |
31 | 31 |
@defining(User.findByLoginId(post.authorLoginId)){ user => |
32 |
- <li class="search-list-item @if(project != null) {project}"> |
|
33 |
- @if(project == null) { |
|
34 |
- <a href="@routes.ProjectApp.project(post.project.owner, post.project.name)" class="avatar-wrap"> |
|
35 |
- <img src="@urlToProjectLogo(post.project)"> |
|
36 |
- </a> |
|
37 |
- } |
|
32 |
+ <li class="search-list-item"> |
|
38 | 33 |
<div class="title-wrap"> |
39 | 34 |
<span class="post-id">#@post.getNumber</span> |
40 | 35 |
<a href="@routes.BoardApp.post(post.project.owner, post.project.name, post.getNumber)" class="title"> |
... | ... | @@ -42,15 +37,13 @@ |
42 | 37 |
</a> |
43 | 38 |
</div> |
44 | 39 |
<div class="search-content"> |
45 |
- @defining(searchResult.makeSnipets(post.body, 40)) { snipets => |
|
46 |
- @if(snipets != null && snipets.size > 0) { |
|
47 |
- @for(snipet <- snipets) { |
|
48 |
- <p class="search-content-body"> |
|
49 |
- @snipet @if(snipet.size < post.body.size) { ..... } |
|
50 |
- </p> |
|
51 |
- } |
|
52 |
- } |
|
40 |
+ @defining(searchResult.makeSnippets(post.body, 40)) { snippets => |
|
41 |
+ @for(snippet <- snippets) { |
|
42 |
+ <p class="search-content-body"> |
|
43 |
+ @snippet @if(snippet.size < post.body.size) { ..... } |
|
44 |
+ </p> |
|
53 | 45 |
} |
46 |
+ } |
|
54 | 47 |
</div> |
55 | 48 |
<div class="search-meta-info"> |
56 | 49 |
@if(project == null) { |
... | ... | @@ -58,13 +51,6 @@ |
58 | 51 |
@post.project.owner/@post.project.name |
59 | 52 |
</a> |
60 | 53 |
} |
61 |
- <a href="@routes.UserApp.userInfo(user.loginId)" class="avatar-wrap meta" data-toggle="tooltip" data-placement="top" title="@user.loginId"> |
|
62 |
- @if(user.avatarUrl == UserApp.DEFAULT_AVATAR_URL){ |
|
63 |
- <img src="@urlToPicture(user.email, 32)"> |
|
64 |
- } else { |
|
65 |
- <img src="@user.avatarUrl" alt="@user.name" width="32" height="32"/> |
|
66 |
- } |
|
67 |
- </a> |
|
68 | 54 |
@if(user.name){ |
69 | 55 |
<a href="@routes.UserApp.userInfo(user.loginId)" class="meta-item" data-toggle="tooltip" data-placement="top" title="@user.loginId"> |
70 | 56 |
@user.name |
--- app/views/search/partial_projects.scala.html
+++ app/views/search/partial_projects.scala.html
... | ... | @@ -29,7 +29,7 @@ |
29 | 29 |
<ul class="search-list-wrap"> |
30 | 30 |
@for(project <- page.getList) { |
31 | 31 |
@defining(User.findByLoginId(project.owner)){ user => |
32 |
- <li class="search-list-item"> |
|
32 |
+ <li class="search-list-item project"> |
|
33 | 33 |
<a href="@routes.ProjectApp.project(project.owner, project.name)" class="avatar-wrap"> |
34 | 34 |
<img src="@urlToProjectLogo(project)"> |
35 | 35 |
</a> |
... | ... | @@ -39,7 +39,7 @@ |
39 | 39 |
</a> |
40 | 40 |
</div> |
41 | 41 |
@if(project.isForkedFromOrigin){ |
42 |
- <div class="search-meta-info nm"> |
|
42 |
+ <div class="search-meta-info nm np"> |
|
43 | 43 |
<span> |
44 | 44 |
<i class="yobicon-split yobicon-white vmiddle"></i> |
45 | 45 |
@Messages("fork.original") |
... | ... | @@ -51,12 +51,12 @@ |
51 | 51 |
</span> |
52 | 52 |
</div> |
53 | 53 |
} |
54 |
- <div class="search-content"> |
|
54 |
+ <div class="search-content np"> |
|
55 | 55 |
<p class="search-content-body"> |
56 | 56 |
@project.overview |
57 | 57 |
</p> |
58 | 58 |
</div> |
59 |
- <div class="search-meta-info"> |
|
59 |
+ <div class="search-meta-info np"> |
|
60 | 60 |
<span class="meta-info"> |
61 | 61 |
@Messages("project.create") |
62 | 62 |
<strong title="@getDateString(project.createdDate)">@agoOrDateString(project.createdDate)</strong> |
--- app/views/search/partial_reviews.scala.html
+++ app/views/search/partial_reviews.scala.html
... | ... | @@ -29,31 +29,35 @@ |
29 | 29 |
@if(page.getList.length > 0) { |
30 | 30 |
<ul class="search-list-wrap"> |
31 | 31 |
@for(review <- page.getList) { |
32 |
- <li class="search-list-item @if(project != null) {project}"> |
|
32 |
+ <li class="search-list-item"> |
|
33 | 33 |
@defining(User.findByLoginId(review.author.loginId)){ user => |
34 |
- @if(review.thread.pullRequest != null) { |
|
35 |
- @if(project == null) { |
|
36 |
- <a href="@routes.ProjectApp.project(review.thread.project.owner, review.thread.project.name)" class="avatar-wrap"> |
|
37 |
- <img src="@urlToProjectLogo(review.thread.project)"> |
|
38 |
- </a> |
|
39 |
- } |
|
34 |
+ @if(review.thread.isOnPullRequest()) { |
|
40 | 35 |
<div class="title-wrap"> |
41 | 36 |
<span class="post-id">#@review.thread.pullRequest.number</span> |
42 | 37 |
<a href="@DiffRenderer.urlToCommentThread(review.thread)"> |
43 | 38 |
Re) @review.thread.pullRequest.title |
44 | 39 |
</a> |
45 | 40 |
</div> |
46 |
- } |
|
41 |
+ } |
|
47 | 42 |
<div class="search-content"> |
48 |
- @defining(searchResult.makeSnipets(review.getContents, 40)) { snipets => |
|
49 |
- @if(snipets != null && snipets.size > 0) { |
|
50 |
- @for(snipet <- snipets) { |
|
43 |
+ @defining(searchResult.makeSnippets(review.getContents, 40)) { snippets => |
|
44 |
+ @if(review.thread.isOnPullRequest()) { |
|
45 |
+ @for(snippet <- snippets) { |
|
51 | 46 |
<p class="search-content-body"> |
52 |
- @snipet @if(snipet.size < review.getContents.size) { ..... } |
|
47 |
+ @snippet @if(snippet.size < review.getContents.size) { ..... } |
|
53 | 48 |
</p> |
54 |
- } |
|
55 | 49 |
} |
56 |
- } |
|
50 |
+ } else { |
|
51 |
+ <a href="@DiffRenderer.urlToCommentThread(review.thread)"> |
|
52 |
+ @for(snippet <- snippets) { |
|
53 |
+ <p class="search-content-body"> |
|
54 |
+ @snippet @if(snippet.size < review.getContents.size) { ..... } |
|
55 |
+ </p> |
|
56 |
+ } |
|
57 |
+ </a> |
|
58 |
+ } |
|
59 |
+ |
|
60 |
+ } |
|
57 | 61 |
</div> |
58 | 62 |
<div class="search-meta-info"> |
59 | 63 |
@if(project == null) { |
... | ... | @@ -61,13 +65,6 @@ |
61 | 65 |
@review.thread.project.owner/@review.thread.project.name |
62 | 66 |
</a> |
63 | 67 |
} |
64 |
- <a href="@routes.UserApp.userInfo(user.loginId)" class="avatar-wrap meta" data-toggle="tooltip" data-placement="top" title="@user.loginId"> |
|
65 |
- @if(user.avatarUrl == UserApp.DEFAULT_AVATAR_URL){ |
|
66 |
- <img src="@urlToPicture(user.email, 16)"> |
|
67 |
- } else { |
|
68 |
- <img src="@user.avatarUrl" alt="@user.name" width="16" height="16"/> |
|
69 |
- } |
|
70 |
- </a> |
|
71 | 68 |
@if(user.name){ |
72 | 69 |
<a href="@routes.UserApp.userInfo(user.loginId)" class="meta-item" data-toggle="tooltip" data-placement="top" title="@user.loginId"> |
73 | 70 |
@user.name |
... | ... | @@ -95,4 +92,4 @@ |
95 | 92 |
} else { |
96 | 93 |
<div class="empty-result"></div> |
97 | 94 |
} |
98 |
-}(No newline at end of file) |
|
95 |
+} |
--- app/views/search/partial_search.scala.html
+++ app/views/search/partial_search.scala.html
... | ... | @@ -27,14 +27,41 @@ |
27 | 27 |
|
28 | 28 |
@makeSearchLink() = @{ |
29 | 29 |
if(project != null) { |
30 |
- routes.SearchApp.searchProject(project.owner, project.name) |
|
30 |
+ routes.SearchApp.searchInAProject(project.owner, project.name) |
|
31 | 31 |
} else if (group !=null) { |
32 |
- routes.SearchApp.searchGroupRepos(group.name) |
|
32 |
+ routes.SearchApp.searchInAGroup(group.name) |
|
33 | 33 |
} else { |
34 |
- routes.SearchApp.searchAllRepos() |
|
34 |
+ routes.SearchApp.searchInAll() |
|
35 | 35 |
} |
36 | 36 |
} |
37 | 37 |
|
38 |
+@makeTilte(search_type:SearchType) =@{ |
|
39 |
+ search_type match { |
|
40 |
+ case SearchType.ISSUE => { Messages("search.menu.issues") } |
|
41 |
+ case SearchType.USER => { Messages("search.menu.users") } |
|
42 |
+ case SearchType.PROJECT => { Messages("search.menu.projects") } |
|
43 |
+ case SearchType.POST => { Messages("search.menu.boards") } |
|
44 |
+ case SearchType.MILESTONE => { Messages("search.menu.milestones") } |
|
45 |
+ case SearchType.ISSUE_COMMENT => { Messages("search.menu.issue.comments") } |
|
46 |
+ case SearchType.POST_COMMENT => { Messages("search.menu.board.comments") } |
|
47 |
+ case SearchType.REVIEW => { Messages("search.menu.reviews") } |
|
48 |
+ case SearchType.NA => { } |
|
49 |
+ } |
|
50 |
+} |
|
51 |
+ |
|
52 |
+@getCurrentlySearchCount(search_type:SearchType) =@{ |
|
53 |
+ search_type match { |
|
54 |
+ case SearchType.ISSUE => { searchResult.getIssuesCount } |
|
55 |
+ case SearchType.USER => { searchResult.getUsersCount } |
|
56 |
+ case SearchType.PROJECT => { searchResult.getProjectsCount } |
|
57 |
+ case SearchType.POST => { searchResult.getPostsCount } |
|
58 |
+ case SearchType.MILESTONE => { searchResult.getMilestonesCount } |
|
59 |
+ case SearchType.ISSUE_COMMENT => { searchResult.getIssueCommentsCount } |
|
60 |
+ case SearchType.POST_COMMENT => { searchResult.getPostCommentsCount } |
|
61 |
+ case SearchType.REVIEW => { searchResult.getReviewsCount } |
|
62 |
+ case SearchType.NA => { } |
|
63 |
+ } |
|
64 |
+} |
|
38 | 65 |
<div class="site-breadcrumb-outer"> |
39 | 66 |
<div class="site-breadcrumb-inner"> |
40 | 67 |
<h3> |
... | ... | @@ -107,6 +134,10 @@ |
107 | 134 |
<input type="text" name="keyword" class="span11" value="@searchResult.getKeyword()"> |
108 | 135 |
<button type="submit" class="ybtn">@Messages("title.search")</button> |
109 | 136 |
</form> |
137 |
+ |
|
138 |
+ <h3 class="search-result-title"> |
|
139 |
+ @Html(Messages("search.result.title", getCurrentlySearchCount(searchResult.getSearchType()),makeTilte(searchResult.getSearchType()))) |
|
140 |
+ </h3> |
|
110 | 141 |
</div> |
111 | 142 |
<div class="search-result-wrap"> |
112 | 143 |
@if(searchResult.getSearchType() == SearchType.ISSUE) { |
... | ... | @@ -164,4 +195,4 @@ |
164 | 195 |
$(this).html(content); |
165 | 196 |
}) |
166 | 197 |
}); |
167 |
-</script>(No newline at end of file) |
|
198 |
+</script> |
--- app/views/search/partial_users.scala.html
+++ app/views/search/partial_users.scala.html
... | ... | @@ -28,7 +28,7 @@ |
28 | 28 |
@if(page.getList.length > 0) { |
29 | 29 |
<ul class="search-list-wrap"> |
30 | 30 |
@for(user <- page.getList) { |
31 |
- <li class="search-list-item"> |
|
31 |
+ <li class="search-list-item project"> |
|
32 | 32 |
<a href="@routes.UserApp.userInfo(user.loginId)" class="avatar-wrap" data-toggle="tooltip" data-placement="top" title="@user.loginId"> |
33 | 33 |
@if(user.avatarUrl == UserApp.DEFAULT_AVATAR_URL){ |
34 | 34 |
<img src="@urlToPicture(user.email, 32)"> |
--- conf/messages
+++ conf/messages
... | ... | @@ -666,6 +666,7 @@ |
666 | 666 |
search.menu.projects = projects |
667 | 667 |
search.menu.reviews = Code Reviews |
668 | 668 |
search.menu.users = Users |
669 |
+search.result.title = Found <strong>{0}</strong> result(s) in {1} |
|
669 | 670 |
search.scope.all = All Projects |
670 | 671 |
search.scope.group = This Group |
671 | 672 |
search.scope.porject = This Project |
--- conf/messages.ko
+++ conf/messages.ko
... | ... | @@ -666,6 +666,7 @@ |
666 | 666 |
search.menu.projects = 프로젝트 |
667 | 667 |
search.menu.reviews = 코드 리뷰 |
668 | 668 |
search.menu.users = 사용자 |
669 |
+search.result.title = {1}에서 <strong>{0}</strong> 건이 검색 되었습니다 |
|
669 | 670 |
search.scope.all = 모든 프로젝트 |
670 | 671 |
search.scope.group = 현재 그룹 |
671 | 672 |
search.scope.porject = 현재 프로젝트 |
--- conf/routes
+++ conf/routes
... | ... | @@ -19,7 +19,7 @@ |
19 | 19 |
GET /UIKit controllers.Application.UIKit() |
20 | 20 |
|
21 | 21 |
# Search |
22 |
-GET /search controllers.SearchApp.searchAllRepos() |
|
22 |
+GET /search controllers.SearchApp.searchInAll() |
|
23 | 23 |
|
24 | 24 |
# Import |
25 | 25 |
GET /import controllers.ImportApp.importForm() |
... | ... | @@ -36,7 +36,7 @@ |
36 | 36 |
POST /organizations/:organizationName/member/:userId/edit controllers.OrganizationApp.editMember(organizationName: String, userId: Long) |
37 | 37 |
DELETE /organizations/:organizationName/member/:userId/delete controllers.OrganizationApp.deleteMember(organizationName: String, userId: Long) |
38 | 38 |
DELETE /organizations/:organizationName/member/leave controllers.OrganizationApp.leave(organizationName: String) |
39 |
-GET /organizations/:organizationName/search controllers.SearchApp.searchGroupRepos(organizationName) |
|
39 |
+GET /organizations/:organizationName/search controllers.SearchApp.searchInAGroup(organizationName) |
|
40 | 40 |
|
41 | 41 |
# Enrolling Organization |
42 | 42 |
POST /organizations/:organizationName/enroll controllers.EnrollOrganizationApp.enroll(organizationName) |
... | ... | @@ -139,7 +139,7 @@ |
139 | 139 |
GET /:user/:project/transfer controllers.ProjectApp.transferForm(user, project) |
140 | 140 |
PUT /:user/:project/transfer controllers.ProjectApp.transferProject(user, project) |
141 | 141 |
GET /project/transfer/:id/:key controllers.ProjectApp.acceptTransfer(id: Long, key) |
142 |
-GET /:user/:project/search controllers.SearchApp.searchProject(user, project) |
|
142 |
+GET /:user/:project/search controllers.SearchApp.searchInAProject(user, project) |
|
143 | 143 |
|
144 | 144 |
# Project Review Menu |
145 | 145 |
GET /:user/:project/reviews controllers.ReviewThreadApp.reviewThreads(user, project) |
--- conf/test-data.yml
+++ conf/test-data.yml
... | ... | @@ -3,7 +3,6 @@ |
3 | 3 |
- !!models.User |
4 | 4 |
name: Yobi |
5 | 5 |
loginId: yobi |
6 |
- state: ACTIVE |
|
7 | 6 |
password: ys9gr1Xet/DL9RpmgczOlJg+txPvqnZCaw/z55gb0KU= |
8 | 7 |
passwordSalt: '[B@1032a4' |
9 | 8 |
state: ACTIVE |
--- test/models/SearchResultTests.java
+++ test/models/SearchResultTests.java
... | ... | @@ -20,7 +20,7 @@ |
20 | 20 |
searchResult.setKeyword(keyword); |
21 | 21 |
|
22 | 22 |
// When |
23 |
- List<String> snipets = searchResult.makeSnipets(contents, 10); |
|
23 |
+ List<String> snipets = searchResult.makeSnippets(contents, 10); |
|
24 | 24 |
|
25 | 25 |
// Then |
26 | 26 |
assertThat(snipets.size()).isEqualTo(1); |
... | ... | @@ -36,7 +36,7 @@ |
36 | 36 |
searchResult.setKeyword(keyword); |
37 | 37 |
|
38 | 38 |
// When |
39 |
- List<String> snipets = searchResult.makeSnipets(contents, 40); |
|
39 |
+ List<String> snipets = searchResult.makeSnippets(contents, 40); |
|
40 | 40 |
|
41 | 41 |
// Then |
42 | 42 |
assertThat(snipets.size()).isEqualTo(2); |
--- test/models/SearchTests.java
+++ test/models/SearchTests.java
... | ... | @@ -2,57 +2,63 @@ |
2 | 2 |
|
3 | 3 |
import models.enumeration.ProjectScope; |
4 | 4 |
import models.enumeration.RoleType; |
5 |
-import org.junit.Before; |
|
6 |
-import org.junit.Test; |
|
5 |
+import org.junit.*; |
|
6 |
+import play.test.FakeApplication; |
|
7 |
+import play.test.Helpers; |
|
7 | 8 |
|
8 | 9 |
import java.util.HashSet; |
9 | 10 |
import java.util.List; |
10 | 11 |
|
11 | 12 |
import static org.fest.assertions.Assertions.assertThat; |
12 | 13 |
|
13 |
-public class SearchTests extends ModelTest<Search> { |
|
14 |
+public class SearchTests { |
|
14 | 15 |
|
15 |
- private Organization labs; |
|
16 |
- private Project publicProject; // labs's project |
|
17 |
- private Project protectedProject; // labs's project |
|
18 |
- private Project privateProject; // labs's project |
|
16 |
+ private static Organization labs; |
|
17 |
+ private static Project publicProject; // labs's project |
|
18 |
+ private static Project protectedProject; // labs's project |
|
19 |
+ private static Project privateProject; // labs's project |
|
19 | 20 |
|
20 |
- private User author; // author of a privateProject's post and issue |
|
21 |
- private User projectMember; // member of a privateProject |
|
22 |
- private User groupMember; // member of labs |
|
23 |
- private User groupAndProjectMember; // member of a privateProject and member of labs |
|
24 |
- private User assignee; // assignee of all issues |
|
21 |
+ private static User author; // author of a privateProject's post and issue |
|
22 |
+ private static User projectMember; // member of a privateProject |
|
23 |
+ private static User groupMember; // member of labs |
|
24 |
+ private static User groupAndProjectMember; // member of a privateProject and member of labs |
|
25 |
+ private static User assignee; // assignee of all issues |
|
25 | 26 |
|
26 |
- private Posting publicPost; |
|
27 |
- private Posting protectedPost; |
|
28 |
- private Posting privatePost; |
|
27 |
+ private static Posting publicPost; |
|
28 |
+ private static Posting protectedPost; |
|
29 |
+ private static Posting privatePost; |
|
29 | 30 |
|
30 |
- private Issue privateIssue; |
|
31 |
- private Issue publicIssue; |
|
32 |
- private Issue protectedIssue; |
|
31 |
+ private static Issue privateIssue; |
|
32 |
+ private static Issue publicIssue; |
|
33 |
+ private static Issue protectedIssue; |
|
33 | 34 |
|
34 |
- private Milestone publicMilestone; |
|
35 |
- private Milestone protectedMilestone; |
|
36 |
- private Milestone privateMilestone; |
|
35 |
+ private static Milestone publicMilestone; |
|
36 |
+ private static Milestone protectedMilestone; |
|
37 |
+ private static Milestone privateMilestone; |
|
37 | 38 |
|
38 |
- private IssueComment publicIssueComment; |
|
39 |
- private IssueComment protectedIssueComment; |
|
40 |
- private IssueComment privateIssueComment; |
|
39 |
+ private static IssueComment publicIssueComment; |
|
40 |
+ private static IssueComment protectedIssueComment; |
|
41 |
+ private static IssueComment privateIssueComment; |
|
41 | 42 |
|
42 |
- private PostingComment publicPostComment; |
|
43 |
- private PostingComment protectedPostComment; |
|
44 |
- private PostingComment privatePostComment; |
|
43 |
+ private static PostingComment publicPostComment; |
|
44 |
+ private static PostingComment protectedPostComment; |
|
45 |
+ private static PostingComment privatePostComment; |
|
45 | 46 |
|
46 |
- private ReviewComment publicReviewComment; |
|
47 |
- private ReviewComment protectedReviewComment; |
|
48 |
- private ReviewComment privateReviewComment; |
|
47 |
+ private static ReviewComment publicReviewComment; |
|
48 |
+ private static ReviewComment protectedReviewComment; |
|
49 |
+ private static ReviewComment privateReviewComment; |
|
49 | 50 |
|
50 | 51 |
private PageParam onePageFiveSize = new PageParam(0, 5); |
51 | 52 |
|
52 |
- @Before |
|
53 |
- public void setUp() { |
|
53 |
+ protected static FakeApplication app; |
|
54 |
+ |
|
55 |
+ @BeforeClass |
|
56 |
+ public static void startApp() { |
|
57 |
+ app = support.Helpers.makeTestApplication(); |
|
58 |
+ Helpers.start(app); |
|
59 |
+ |
|
54 | 60 |
// Given |
55 |
- author = User.find.byId(1l); |
|
61 |
+ author = User.find.byId(6l); |
|
56 | 62 |
groupAndProjectMember = User.find.byId(2l); |
57 | 63 |
projectMember = User.find.byId(3l); |
58 | 64 |
groupMember = User.find.byId(4l); |
... | ... | @@ -189,6 +195,11 @@ |
189 | 195 |
privateReviewComment.thread = privateCommentThread; |
190 | 196 |
privateReviewComment.author = new UserIdent(author); |
191 | 197 |
privateReviewComment.save(); |
198 |
+ } |
|
199 |
+ |
|
200 |
+ @AfterClass |
|
201 |
+ public static void stopApp() { |
|
202 |
+ Helpers.stop(app); |
|
192 | 203 |
} |
193 | 204 |
|
194 | 205 |
/** |
... | ... | @@ -1607,4 +1618,4 @@ |
1607 | 1618 |
assertThat(reviews).onProperty("contents").contains("private review"); |
1608 | 1619 |
} |
1609 | 1620 |
|
1610 |
-}(No newline at end of file) |
|
1621 |
+} |
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?