Show More
1 | NO CONTENT: new file 100644 |
|
NO CONTENT: new file 100644 |
@@ -0,0 +1,31 b'' | |||||
|
1 | ##content highligthing | |||
|
2 | ||||
|
3 | %for cnt,sr in enumerate(c.formated_results): | |||
|
4 | %if h.HasRepoPermissionAny('repository.write','repository.read','repository.admin')(sr['repository'],'search results check'): | |||
|
5 | <div class="table"> | |||
|
6 | <div id="body${cnt}" class="codeblock"> | |||
|
7 | <div class="code-header"> | |||
|
8 | <div class="revision">${h.link_to(h.literal('%s » %s' % (sr['repository'],sr['f_path'])), | |||
|
9 | h.url('files_home',repo_name=sr['repository'],revision='tip',f_path=sr['f_path']))}</div> | |||
|
10 | </div> | |||
|
11 | <div class="code-body"> | |||
|
12 | <pre>${h.literal(sr['content_short_hl'])}</pre> | |||
|
13 | </div> | |||
|
14 | </div> | |||
|
15 | </div> | |||
|
16 | %else: | |||
|
17 | %if cnt == 0: | |||
|
18 | <div class="table"> | |||
|
19 | <div id="body${cnt}" class="codeblock"> | |||
|
20 | <div class="error">${_('Permission denied')}</div> | |||
|
21 | </div> | |||
|
22 | </div> | |||
|
23 | %endif | |||
|
24 | ||||
|
25 | %endif | |||
|
26 | %endfor | |||
|
27 | %if c.cur_query and c.formated_results: | |||
|
28 | <div class="pagination-wh pagination-left"> | |||
|
29 | ${c.formated_results.pager('$link_previous ~2~ $link_next')} | |||
|
30 | </div> | |||
|
31 | %endif No newline at end of file |
@@ -0,0 +1,27 b'' | |||||
|
1 | ##path search | |||
|
2 | <div class="search"> | |||
|
3 | %for cnt,sr in enumerate(c.formated_results): | |||
|
4 | %if h.HasRepoPermissionAny('repository.write','repository.read','repository.admin')(sr['repository'],'search results check'): | |||
|
5 | <div class="search_path"> | |||
|
6 | <div class="link"> | |||
|
7 | ${h.link_to(h.literal('%s » %s' % (sr['repository'],sr['f_path'])), | |||
|
8 | h.url('files_home',repo_name=sr['repository'],revision='tip',f_path=sr['f_path']))} | |||
|
9 | </div> | |||
|
10 | </div> | |||
|
11 | %else: | |||
|
12 | %if cnt == 0: | |||
|
13 | <div class="error"> | |||
|
14 | <div class="link"> | |||
|
15 | ${_('Permission denied')} | |||
|
16 | </div> | |||
|
17 | </div> | |||
|
18 | %endif | |||
|
19 | ||||
|
20 | %endif | |||
|
21 | %endfor | |||
|
22 | %if c.cur_query and c.formated_results: | |||
|
23 | <div class="pagination-wh pagination-left"> | |||
|
24 | ${c.formated_results.pager('$link_previous ~2~ $link_next')} | |||
|
25 | </div> | |||
|
26 | %endif | |||
|
27 | </div> No newline at end of file |
1 | NO CONTENT: new file 100644 |
|
NO CONTENT: new file 100644 |
@@ -49,6 +49,14 b' class SearchController(BaseController):' | |||||
49 | c.formated_results = [] |
|
49 | c.formated_results = [] | |
50 | c.runtime = '' |
|
50 | c.runtime = '' | |
51 | c.cur_query = request.GET.get('q', None) |
|
51 | c.cur_query = request.GET.get('q', None) | |
|
52 | c.cur_type = request.GET.get('type', 'source') | |||
|
53 | c.cur_search = search_type = {'content':'content', | |||
|
54 | 'commit':'content', | |||
|
55 | 'path':'path', | |||
|
56 | 'repository':'repository'}\ | |||
|
57 | .get(c.cur_type, 'content') | |||
|
58 | ||||
|
59 | ||||
52 | if c.cur_query: |
|
60 | if c.cur_query: | |
53 | cur_query = c.cur_query.lower() |
|
61 | cur_query = c.cur_query.lower() | |
54 |
|
62 | |||
@@ -59,7 +67,7 b' class SearchController(BaseController):' | |||||
59 | idx = open_dir(IDX_LOCATION, indexname=IDX_NAME) |
|
67 | idx = open_dir(IDX_LOCATION, indexname=IDX_NAME) | |
60 | searcher = idx.searcher() |
|
68 | searcher = idx.searcher() | |
61 |
|
69 | |||
62 |
qp = QueryParser( |
|
70 | qp = QueryParser(search_type, schema=SCHEMA) | |
63 | if c.repo_name: |
|
71 | if c.repo_name: | |
64 | cur_query = u'repository:%s %s' % (c.repo_name, cur_query) |
|
72 | cur_query = u'repository:%s %s' % (c.repo_name, cur_query) | |
65 | try: |
|
73 | try: | |
@@ -82,13 +90,16 b' class SearchController(BaseController):' | |||||
82 | % (res_ln, results.runtime) |
|
90 | % (res_ln, results.runtime) | |
83 |
|
91 | |||
84 | def url_generator(**kw): |
|
92 | def url_generator(**kw): | |
85 |
return update_params("?q=%s" |
|
93 | return update_params("?q=%s&type=%s" \ | |
|
94 | % (c.cur_query, c.cur_search), **kw) | |||
86 |
|
95 | |||
87 | c.formated_results = Page( |
|
96 | c.formated_results = Page( | |
88 |
ResultWrapper(searcher, matcher, |
|
97 | ResultWrapper(search_type, searcher, matcher, | |
|
98 | highlight_items), | |||
89 | page=p, item_count=res_ln, |
|
99 | page=p, item_count=res_ln, | |
90 | items_per_page=10, url=url_generator) |
|
100 | items_per_page=10, url=url_generator) | |
91 |
|
|
101 | ||
|
102 | ||||
92 | except QueryParserError: |
|
103 | except QueryParserError: | |
93 | c.runtime = _('Invalid search query. Try quoting it.') |
|
104 | c.runtime = _('Invalid search query. Try quoting it.') | |
94 | searcher.close() |
|
105 | searcher.close() |
@@ -38,7 +38,7 b' ANALYZER = RegexTokenizer(expression=r"\\' | |||||
38 | #INDEX SCHEMA DEFINITION |
|
38 | #INDEX SCHEMA DEFINITION | |
39 | SCHEMA = Schema(owner=TEXT(), |
|
39 | SCHEMA = Schema(owner=TEXT(), | |
40 | repository=TEXT(stored=True), |
|
40 | repository=TEXT(stored=True), | |
41 |
path= |
|
41 | path=TEXT(stored=True), | |
42 | content=FieldType(format=Characters(ANALYZER), |
|
42 | content=FieldType(format=Characters(ANALYZER), | |
43 | scorable=True, stored=True), |
|
43 | scorable=True, stored=True), | |
44 | modtime=STORED(), extension=TEXT(stored=True)) |
|
44 | modtime=STORED(), extension=TEXT(stored=True)) | |
@@ -49,7 +49,8 b" FORMATTER = HtmlFormatter('span', betwee" | |||||
49 | FRAGMENTER = SimpleFragmenter(200) |
|
49 | FRAGMENTER = SimpleFragmenter(200) | |
50 |
|
50 | |||
51 | class ResultWrapper(object): |
|
51 | class ResultWrapper(object): | |
52 | def __init__(self, searcher, matcher, highlight_items): |
|
52 | def __init__(self, search_type, searcher, matcher, highlight_items): | |
|
53 | self.search_type = search_type | |||
53 | self.searcher = searcher |
|
54 | self.searcher = searcher | |
54 | self.matcher = matcher |
|
55 | self.matcher = matcher | |
55 | self.highlight_items = highlight_items |
|
56 | self.highlight_items = highlight_items | |
@@ -113,7 +114,7 b' class ResultWrapper(object):' | |||||
113 | """ |
|
114 | """ | |
114 | Smart function that implements chunking the content |
|
115 | Smart function that implements chunking the content | |
115 | but not overlap chunks so it doesn't highlight the same |
|
116 | but not overlap chunks so it doesn't highlight the same | |
116 | close occurences twice. |
|
117 | close occurrences twice. | |
117 | @param matcher: |
|
118 | @param matcher: | |
118 | @param size: |
|
119 | @param size: | |
119 | """ |
|
120 | """ | |
@@ -130,6 +131,8 b' class ResultWrapper(object):' | |||||
130 | yield (start_offseted, end_offseted,) |
|
131 | yield (start_offseted, end_offseted,) | |
131 |
|
132 | |||
132 | def highlight(self, content, top=5): |
|
133 | def highlight(self, content, top=5): | |
|
134 | if self.search_type != 'content': | |||
|
135 | return '' | |||
133 | hl = highlight(escape(content), |
|
136 | hl = highlight(escape(content), | |
134 | self.highlight_items, |
|
137 | self.highlight_items, | |
135 | analyzer=ANALYZER, |
|
138 | analyzer=ANALYZER, |
@@ -1318,6 +1318,12 b' div.options a:hover' | |||||
1318 | padding: 0 0 10px 0; |
|
1318 | padding: 0 0 10px 0; | |
1319 | } |
|
1319 | } | |
1320 |
|
1320 | |||
|
1321 | #content div.box div.form div.fields div.field-noborder | |||
|
1322 | { | |||
|
1323 | border-bottom: 0px !important; | |||
|
1324 | } | |||
|
1325 | ||||
|
1326 | ||||
1321 | #content div.box div.form div.fields div.field span.error-message |
|
1327 | #content div.box div.form div.fields div.field span.error-message | |
1322 | { |
|
1328 | { | |
1323 | margin: 8px 0 0 0; |
|
1329 | margin: 8px 0 0 0; | |
@@ -3311,6 +3317,36 b' table.code-browser .browser-dir {' | |||||
3311 | } |
|
3317 | } | |
3312 |
|
3318 | |||
3313 | /* ----------------------------------------------------------- |
|
3319 | /* ----------------------------------------------------------- | |
|
3320 | SEARCH | |||
|
3321 | ----------------------------------------------------------- */ | |||
|
3322 | ||||
|
3323 | .box .search { | |||
|
3324 | clear:both; | |||
|
3325 | margin:0; | |||
|
3326 | overflow:hidden; | |||
|
3327 | padding:0 20px 10px; | |||
|
3328 | } | |||
|
3329 | .box .search div.search_path{ | |||
|
3330 | background:none repeat scroll 0 0 #EEEEEE; | |||
|
3331 | border:1px solid #CCCCCC; | |||
|
3332 | ||||
|
3333 | color:blue; | |||
|
3334 | padding:10px 0; | |||
|
3335 | margin-bottom:10px; | |||
|
3336 | } | |||
|
3337 | .box .search div.search_path div.link{ | |||
|
3338 | font-weight:bold; | |||
|
3339 | margin-left:25px; | |||
|
3340 | } | |||
|
3341 | .box .search div.search_path div.link a{ | |||
|
3342 | color:#0066CC; | |||
|
3343 | cursor:pointer; | |||
|
3344 | text-decoration:none; | |||
|
3345 | } | |||
|
3346 | ||||
|
3347 | ||||
|
3348 | ||||
|
3349 | /* ----------------------------------------------------------- | |||
3314 | ADMIN - SETTINGS |
|
3350 | ADMIN - SETTINGS | |
3315 | ----------------------------------------------------------- */ |
|
3351 | ----------------------------------------------------------- */ | |
3316 | #path_unlock{ |
|
3352 | #path_unlock{ |
@@ -36,51 +36,42 b'' | |||||
36 | %endif |
|
36 | %endif | |
37 | <div class="form"> |
|
37 | <div class="form"> | |
38 | <div class="fields"> |
|
38 | <div class="fields"> | |
|
39 | <div class="field field-first field-noborder"> | |||
|
40 | <div class="label"> | |||
|
41 | <label for="q">${_('Search term')}</label> | |||
|
42 | </div> | |||
|
43 | <div class="input">${h.text('q',c.cur_query,class_="small")}</div> | |||
|
44 | <div class="button highlight"> | |||
|
45 | <input type="submit" value="${_('Search')}" class="ui-button ui-widget ui-state-default ui-corner-all"/> | |||
|
46 | </div> | |||
|
47 | <div style="font-weight: bold;clear:Both;margin-left:200px">${c.runtime}</div> | |||
|
48 | </div> | |||
39 |
|
49 | |||
40 |
<div class="field |
|
50 | <div class="field"> | |
41 |
|
|
51 | <div class="label"> | |
42 |
|
|
52 | <label for="type">${_('Search in')}</label> | |
43 | </div> |
|
53 | </div> | |
44 | <div class="input"> |
|
54 | <div class="select"> | |
45 | ${h.text('q',c.cur_query,class_="small")} |
|
55 | ${h.select('type',c.cur_type,[('content',_('Source codes')), | |
46 | <div class="button highlight"> |
|
56 | ##('commit',_('Commit messages')), | |
47 | <input type="submit" value="${_('Search')}" class="ui-button ui-widget ui-state-default ui-corner-all"/> |
|
57 | ('path',_('File names')), | |
48 | </div> |
|
58 | ##('repository',_('Repository names')), | |
49 | <div style="font-weight: bold;clear:both;padding: 5px">${c.runtime}</div> |
|
59 | ])} | |
50 | </div> |
|
60 | </div> | |
51 | </div> |
|
61 | </div> | |
|
62 | ||||
52 | </div> |
|
63 | </div> | |
53 | </div> |
|
64 | </div> | |
54 | ${h.end_form()} |
|
65 | ${h.end_form()} | |
55 |
|
66 | |||
56 | %for cnt,sr in enumerate(c.formated_results): |
|
67 | %if c.cur_search == 'content': | |
57 | %if h.HasRepoPermissionAny('repository.write','repository.read','repository.admin')(sr['repository'],'search results check'): |
|
68 | <%include file='search_content.html'/> | |
58 | <div class="table"> |
|
69 | %elif c.cur_search == 'path': | |
59 | <div id="body${cnt}" class="codeblock"> |
|
70 | <%include file='search_path.html'/> | |
60 | <div class="code-header"> |
|
71 | %elif c.cur_search == 'commit': | |
61 | <div class="revision">${h.link_to(h.literal('%s » %s' % (sr['repository'],sr['f_path'])), |
|
72 | <%include file='search_commit.html'/> | |
62 | h.url('files_home',repo_name=sr['repository'],revision='tip',f_path=sr['f_path']))}</div> |
|
73 | %elif c.cur_search == 'repository': | |
63 | </div> |
|
74 | <%include file='search_repository.html'/> | |
64 | <div class="code-body"> |
|
|||
65 | <pre>${h.literal(sr['content_short_hl'])}</pre> |
|
|||
66 | </div> |
|
|||
67 | </div> |
|
|||
68 | </div> |
|
|||
69 | %else: |
|
|||
70 | %if cnt == 0: |
|
|||
71 | <div class="table"> |
|
|||
72 | <div id="body${cnt}" class="codeblock"> |
|
|||
73 | <div class="error">${_('Permission denied')}</div> |
|
|||
74 | </div> |
|
|||
75 | </div> |
|
|||
76 | %endif |
|
|||
77 |
|
||||
78 | %endif |
|
|||
79 | %endfor |
|
|||
80 | %if c.cur_query: |
|
|||
81 | <div class="pagination-wh pagination-left"> |
|
|||
82 | ${c.formated_results.pager('$link_previous ~2~ $link_next')} |
|
|||
83 | </div> |
|
|||
84 | %endif |
|
75 | %endif | |
85 | </div> |
|
76 | </div> | |
86 |
|
77 |
General Comments 0
You need to be logged in to leave comments.
Login now