##// END OF EJS Templates
search: pre-select menu entry when doing specialized searches for repository.
marcink -
r3783:0fee1faa default
parent child Browse files
Show More
@@ -1,216 +1,217 b''
1 ## -*- coding: utf-8 -*-
1 ## -*- coding: utf-8 -*-
2 <%inherit file="/base/base.mako"/>
2 <%inherit file="/base/base.mako"/>
3
3
4 <%def name="title()">
4 <%def name="title()">
5 %if c.repo_name:
5 %if c.repo_name:
6 ${_('Search inside repository {repo_name}').format(repo_name=c.repo_name)}
6 ${_('Search inside repository {repo_name}').format(repo_name=c.repo_name)}
7 %elif c.repo_group_name:
7 %elif c.repo_group_name:
8 ${_('Search inside repository group {repo_group_name}').format(repo_group_name=c.repo_group_name)}
8 ${_('Search inside repository group {repo_group_name}').format(repo_group_name=c.repo_group_name)}
9 %else:
9 %else:
10 ${_('Search inside all accessible repositories')}
10 ${_('Search inside all accessible repositories')}
11 %endif
11 %endif
12 %if c.rhodecode_name:
12 %if c.rhodecode_name:
13 &middot; ${h.branding(c.rhodecode_name)}
13 &middot; ${h.branding(c.rhodecode_name)}
14 %endif
14 %endif
15 </%def>
15 </%def>
16
16
17 <%def name="breadcrumbs_links()">
17 <%def name="breadcrumbs_links()">
18 %if c.repo_name:
18 %if c.repo_name:
19 ${_('Search inside repository {repo_name}').format(repo_name=c.repo_name)}
19 ${_('Search inside repository {repo_name}').format(repo_name=c.repo_name)}
20 %elif c.repo_group_name:
20 %elif c.repo_group_name:
21 ${_('Search inside repository group {repo_group_name}').format(repo_group_name=c.repo_group_name)}
21 ${_('Search inside repository group {repo_group_name}').format(repo_group_name=c.repo_group_name)}
22 %else:
22 %else:
23 ${_('Search inside all accessible repositories')}
23 ${_('Search inside all accessible repositories')}
24 %endif
24 %endif
25
25
26 </%def>
26 </%def>
27
27
28 <%def name="menu_bar_nav()">
28 <%def name="menu_bar_nav()">
29 %if c.repo_name:
29 %if c.repo_name:
30 ${self.menu_items(active='search')}
30 ${self.menu_items(active='search')}
31 %elif c.repo_group_name:
31 %elif c.repo_group_name:
32 ${self.menu_items(active='search')}
32 ${self.menu_items(active='search')}
33 %else:
33 %else:
34 ${self.menu_items(active='search')}
34 ${self.menu_items(active='search')}
35 %endif
35 %endif
36 </%def>
36 </%def>
37
37
38 <%def name="menu_bar_subnav()">
38 <%def name="menu_bar_subnav()">
39 %if c.repo_name:
39 %if c.repo_name:
40 ${self.repo_menu(active='summary')}
40 <% active_entry = {'content':'files', 'path':'files', 'commit':'commits'}.get(c.search_type, 'summary')%>
41 ${self.repo_menu(active=active_entry)}
41 %elif c.repo_group_name:
42 %elif c.repo_group_name:
42 ${self.repo_group_menu(active='home')}
43 ${self.repo_group_menu(active='home')}
43 %endif
44 %endif
44 </%def>
45 </%def>
45
46
46 <%def name="repo_icon(db_repo)">
47 <%def name="repo_icon(db_repo)">
47 %if h.is_hg(db_repo):
48 %if h.is_hg(db_repo):
48 <i class="icon-hg"></i>
49 <i class="icon-hg"></i>
49 %endif
50 %endif
50 %if h.is_git(db_repo):
51 %if h.is_git(db_repo):
51 <i class="icon-git"></i>
52 <i class="icon-git"></i>
52 %endif
53 %endif
53 %if h.is_svn(db_repo):
54 %if h.is_svn(db_repo):
54 <i class="icon-svn"></i>
55 <i class="icon-svn"></i>
55 %endif
56 %endif
56 </%def>
57 </%def>
57
58
58 <%def name="repo_group_icon()">
59 <%def name="repo_group_icon()">
59 <i class="icon-repo-group"></i>
60 <i class="icon-repo-group"></i>
60 </%def>
61 </%def>
61
62
62 <%def name="main()">
63 <%def name="main()">
63 <div class="box">
64 <div class="box">
64 %if c.repo_name:
65 %if c.repo_name:
65 <!-- box / title -->
66 <!-- box / title -->
66 ${h.form(h.route_path('search_repo',repo_name=c.repo_name),method='get')}
67 ${h.form(h.route_path('search_repo',repo_name=c.repo_name),method='get')}
67 %elif c.repo_group_name:
68 %elif c.repo_group_name:
68 <!-- box / title -->
69 <!-- box / title -->
69 ${h.form(h.route_path('search_repo_group',repo_group_name=c.repo_group_name),method='get')}
70 ${h.form(h.route_path('search_repo_group',repo_group_name=c.repo_group_name),method='get')}
70 %else:
71 %else:
71 <!-- box / title -->
72 <!-- box / title -->
72 <div class="title">
73 <div class="title">
73 ${self.breadcrumbs()}
74 ${self.breadcrumbs()}
74 <ul class="links">&nbsp;</ul>
75 <ul class="links">&nbsp;</ul>
75 </div>
76 </div>
76 <!-- end box / title -->
77 <!-- end box / title -->
77 ${h.form(h.route_path('search'), method='get')}
78 ${h.form(h.route_path('search'), method='get')}
78 %endif
79 %endif
79 <div class="form search-form">
80 <div class="form search-form">
80 <div class="fields">
81 <div class="fields">
81
82
82 ${h.text('q', c.cur_query, placeholder="Enter query...")}
83 ${h.text('q', c.cur_query, placeholder="Enter query...")}
83
84
84 ${h.select('type',c.search_type,[('content',_('Files')), ('path',_('File path')),('commit',_('Commits'))],id='id_search_type')}
85 ${h.select('type',c.search_type,[('content',_('Files')), ('path',_('File path')),('commit',_('Commits'))],id='id_search_type')}
85 ${h.hidden('max_lines', '10')}
86 ${h.hidden('max_lines', '10')}
86
87
87 <input type="submit" value="${_('Search')}" class="btn"/>
88 <input type="submit" value="${_('Search')}" class="btn"/>
88 <br/>
89 <br/>
89
90
90 <div class="search-tags">
91 <div class="search-tags">
91 <span class="tag tag8">
92 <span class="tag tag8">
92 %if c.repo_name:
93 %if c.repo_name:
93 <a href="${h.route_path('search', _query={'q': c.cur_query, 'type': request.GET.get('type', 'content')})}">${_('Global Search')}</a>
94 <a href="${h.route_path('search', _query={'q': c.cur_query, 'type': request.GET.get('type', 'content')})}">${_('Global Search')}</a>
94 %elif c.repo_group_name:
95 %elif c.repo_group_name:
95 <a href="${h.route_path('search', _query={'q': c.cur_query, 'type': request.GET.get('type', 'content')})}">${_('Global Search')}</a>
96 <a href="${h.route_path('search', _query={'q': c.cur_query, 'type': request.GET.get('type', 'content')})}">${_('Global Search')}</a>
96 % else:
97 % else:
97 ${_('Global Search')}
98 ${_('Global Search')}
98 %endif
99 %endif
99 </span>
100 </span>
100
101
101 %if c.repo_name:
102 %if c.repo_name:
102 Β»
103 Β»
103 <span class="tag tag8">
104 <span class="tag tag8">
104 ${repo_icon(c.rhodecode_db_repo)}
105 ${repo_icon(c.rhodecode_db_repo)}
105 ${c.repo_name}
106 ${c.repo_name}
106 </span>
107 </span>
107
108
108 %elif c.repo_group_name:
109 %elif c.repo_group_name:
109 Β»
110 Β»
110 <span class="tag tag8">
111 <span class="tag tag8">
111 ${repo_group_icon()}
112 ${repo_group_icon()}
112 ${c.repo_group_name}
113 ${c.repo_group_name}
113 </span>
114 </span>
114 %endif
115 %endif
115
116
116
117
117 % for search_tag in c.search_tags:
118 % for search_tag in c.search_tags:
118 <br/><span class="tag disabled" style="margin-top: 3px">${search_tag}</span>
119 <br/><span class="tag disabled" style="margin-top: 3px">${search_tag}</span>
119 % endfor
120 % endfor
120
121
121 </div>
122 </div>
122
123
123 <div class="search-feedback-items">
124 <div class="search-feedback-items">
124 % for error in c.errors:
125 % for error in c.errors:
125 <span class="error-message">
126 <span class="error-message">
126 % for k,v in error.asdict().items():
127 % for k,v in error.asdict().items():
127 ${k} - ${v}
128 ${k} - ${v}
128 % endfor
129 % endfor
129 </span>
130 </span>
130 % endfor
131 % endfor
131 <div class="field">
132 <div class="field">
132 <p class="filterexample" style="position: inherit" onclick="$('#search-help').toggle()">${_('Query Langague examples')}</p>
133 <p class="filterexample" style="position: inherit" onclick="$('#search-help').toggle()">${_('Query Langague examples')}</p>
133 <pre id="search-help" style="display: none">\
134 <pre id="search-help" style="display: none">\
134
135
135 % if c.searcher.name == 'whoosh':
136 % if c.searcher.name == 'whoosh':
136 Example filter terms for `Whoosh` search:
137 Example filter terms for `Whoosh` search:
137 query lang: <a href="${c.searcher.query_lang_doc}">Whoosh Query Language</a>
138 query lang: <a href="${c.searcher.query_lang_doc}">Whoosh Query Language</a>
138 Whoosh has limited query capabilities. For advanced search use ElasticSearch 6 from RhodeCode EE edition.
139 Whoosh has limited query capabilities. For advanced search use ElasticSearch 6 from RhodeCode EE edition.
139
140
140 Generate wildcards using '*' character:
141 Generate wildcards using '*' character:
141 "repo_name:vcs*" - search everything starting with 'vcs'
142 "repo_name:vcs*" - search everything starting with 'vcs'
142 "repo_name:*vcs*" - search for repository containing 'vcs'
143 "repo_name:*vcs*" - search for repository containing 'vcs'
143
144
144 Optional AND / OR operators in queries
145 Optional AND / OR operators in queries
145 "repo_name:vcs OR repo_name:test"
146 "repo_name:vcs OR repo_name:test"
146 "owner:test AND repo_name:test*" AND extension:py
147 "owner:test AND repo_name:test*" AND extension:py
147
148
148 Move advanced search is available via ElasticSearch6 backend in EE edition.
149 Move advanced search is available via ElasticSearch6 backend in EE edition.
149 % elif c.searcher.name == 'elasticsearch' and c.searcher.es_version == '2':
150 % elif c.searcher.name == 'elasticsearch' and c.searcher.es_version == '2':
150 Example filter terms for `ElasticSearch-${c.searcher.es_version}`search:
151 Example filter terms for `ElasticSearch-${c.searcher.es_version}`search:
151 ElasticSearch-2 has limited query capabilities. For advanced search use ElasticSearch 6 from RhodeCode EE edition.
152 ElasticSearch-2 has limited query capabilities. For advanced search use ElasticSearch 6 from RhodeCode EE edition.
152
153
153 search type: content (File Content)
154 search type: content (File Content)
154 indexed fields: content
155 indexed fields: content
155
156
156 # search for `fix` string in all files
157 # search for `fix` string in all files
157 fix
158 fix
158
159
159 search type: commit (Commit message)
160 search type: commit (Commit message)
160 indexed fields: message
161 indexed fields: message
161
162
162 search type: path (File name)
163 search type: path (File name)
163 indexed fields: path
164 indexed fields: path
164
165
165 % else:
166 % else:
166 Example filter terms for `ElasticSearch-${c.searcher.es_version}`search:
167 Example filter terms for `ElasticSearch-${c.searcher.es_version}`search:
167 query lang: <a href="${c.searcher.query_lang_doc}">ES 6 Query Language</a>
168 query lang: <a href="${c.searcher.query_lang_doc}">ES 6 Query Language</a>
168 The reserved characters needed espace by `\`: + - = && || > < ! ( ) { } [ ] ^ " ~ * ? : \ /
169 The reserved characters needed espace by `\`: + - = && || > < ! ( ) { } [ ] ^ " ~ * ? : \ /
169 % for handler in c.searcher.get_handlers().values():
170 % for handler in c.searcher.get_handlers().values():
170
171
171 search type: ${handler.search_type_label}
172 search type: ${handler.search_type_label}
172 *indexed fields*: ${', '.join( [('\n ' if x[0]%4==0 else '')+x[1] for x in enumerate(handler.es_6_field_names)])}
173 *indexed fields*: ${', '.join( [('\n ' if x[0]%4==0 else '')+x[1] for x in enumerate(handler.es_6_field_names)])}
173 % for entry in handler.es_6_example_queries:
174 % for entry in handler.es_6_example_queries:
174 ${entry.rstrip()}
175 ${entry.rstrip()}
175 % endfor
176 % endfor
176 % endfor
177 % endfor
177
178
178 % endif
179 % endif
179 </pre>
180 </pre>
180 </div>
181 </div>
181
182
182 <div class="field">${c.runtime}</div>
183 <div class="field">${c.runtime}</div>
183 </div>
184 </div>
184 </div>
185 </div>
185 </div>
186 </div>
186
187
187 ${h.end_form()}
188 ${h.end_form()}
188 <div class="search">
189 <div class="search">
189 % if c.search_type == 'content':
190 % if c.search_type == 'content':
190 <%include file='search_content.mako'/>
191 <%include file='search_content.mako'/>
191 % elif c.search_type == 'path':
192 % elif c.search_type == 'path':
192 <%include file='search_path.mako'/>
193 <%include file='search_path.mako'/>
193 % elif c.search_type == 'commit':
194 % elif c.search_type == 'commit':
194 <%include file='search_commit.mako'/>
195 <%include file='search_commit.mako'/>
195 % elif c.search_type == 'repository':
196 % elif c.search_type == 'repository':
196 <%include file='search_repository.mako'/>
197 <%include file='search_repository.mako'/>
197 % endif
198 % endif
198 </div>
199 </div>
199 </div>
200 </div>
200 <script>
201 <script>
201 $(document).ready(function(){
202 $(document).ready(function(){
202 $("#id_search_type").select2({
203 $("#id_search_type").select2({
203 'containerCssClass': "drop-menu",
204 'containerCssClass': "drop-menu",
204 'dropdownCssClass': "drop-menu-dropdown",
205 'dropdownCssClass': "drop-menu-dropdown",
205 'dropdownAutoWidth': true,
206 'dropdownAutoWidth': true,
206 'minimumResultsForSearch': -1
207 'minimumResultsForSearch': -1
207 });
208 });
208
209
209 $('#q').autoGrowInput({maxWidth: 920});
210 $('#q').autoGrowInput({maxWidth: 920});
210
211
211 setTimeout(function() {
212 setTimeout(function() {
212 $('#q').keyup()
213 $('#q').keyup()
213 }, 1);
214 }, 1);
214 })
215 })
215 </script>
216 </script>
216 </%def>
217 </%def>
General Comments 0
You need to be logged in to leave comments. Login now