JonasBorgstrom: opensearch.patch
| File opensearch.patch, 4.6 kB (added by jonas, 20 months ago) |
|---|
-
trac/search/web_ui.py
65 65 def process_request(self, req): 66 66 req.perm.assert_permission('SEARCH_VIEW') 67 67 68 if req.path_info == '/search/opensearch': 69 return ('opensearch.xml', {}, 70 'application/opensearchdescription+xml') 71 68 72 available_filters = [] 69 73 for source in self.search_sources: 70 74 available_filters += source.get_search_filters(req) -
trac/web/chrome.py
323 323 add_script(fakereq, 'common/js/trac.js') 324 324 add_script(fakereq, 'common/js/search.js') 325 325 326 icon = self.env.project_icon 327 if icon: 328 if not icon.startswith('/') and icon.find('://') == -1: 329 if '/' in icon: 330 icon = req.href.chrome(icon) 331 else: 332 icon = req.href.chrome('common', icon) 333 mimetype = mimeview.get_mimetype(icon) 334 add_link(fakereq, 'icon', icon, mimetype=mimetype) 335 add_link(fakereq, 'shortcut icon', icon, mimetype=mimetype) 326 # Shortcut icon 327 chrome['icon'] = self.get_icon_data(req) 328 if chrome['icon']: 329 src = chrome['icon']['src'] 330 mimetype = chrome['icon']['mimetype'] 331 add_link(fakereq, 'icon', src, mimetype=mimetype) 332 add_link(fakereq, 'shortcut icon', src, mimetype=mimetype) 336 333 337 334 # Logo image 338 335 chrome['logo'] = self.get_logo_data(req.href) … … 369 366 370 367 return chrome 371 368 369 370 def get_icon_data(self, req): 371 icon = {} 372 icon_src = icon_abs_src = self.env.project_icon 373 if icon_src: 374 if not icon_src.startswith('/') and icon_src.find('://') == -1: 375 if '/' in icon_src: 376 icon_abs_src = req.abs_href.chrome(icon_src) 377 icon_src = req.href.chrome(icon_src) 378 else: 379 icon_abs_src = req.abs_href.chrome('common', icon_src) 380 icon_src = req.href.chrome('common', icon_src) 381 mimetype = mimeview.get_mimetype(icon_src) 382 icon = {'src': icon_src, 'abs_src': icon_abs_src, 383 'mimetype': mimetype} 384 return icon 385 372 386 def get_logo_data(self, href): 373 387 logo = {} 374 388 logo_src = self.logo_src -
templates/search.html
7 7 <xi:include href="layout.html" /> 8 8 <head> 9 9 <title>Search<py:if test="query"> Results</py:if></title> 10 <py:if test="results"> 11 <meta name="totalResults" content="$results.num_items"/> 12 <meta name="startIndex" content="${results.span[0] + 1}"/> 13 <meta name="itemsPerPage" content="$results.max_per_page"/> 14 </py:if> 10 15 <script type="text/javascript"> 11 16 $(document).ready(function() {$("#q").get(0).focus()}); 12 17 </script> -
templates/layout.html
16 16 <link rel="${rel}" py:for="link in links" py:attrs="link" /> 17 17 </py:for> 18 18 </py:if> 19 <py:if test="'SEARCH_VIEW' in perm" id="search"> 20 <link type="application/opensearchdescription+xml" rel="search" 21 href="${href.search('opensearch')}" title="Search $project.name"/> 22 </py:if> 19 23 <script py:for="script in chrome.scripts" 20 24 type="${script.type}" src="${script.href}"></script> 21 25 ${select("*[local-name() != 'title']")} -
templates/opensearch.xml
1 <?xml version="1.0"?> 2 <OpenSearchDescription xmlns:py="http://genshi.edgewall.org/" 3 xmlns="http://a9.com/-/spec/opensearch/1.1/"> 4 <ShortName>Search $project.name</ShortName> 5 <InputEncoding>UTF-8</InputEncoding> 6 <Image py:if="chrome.icon.abs_src" width="16" height="16" 7 type="$chrome.icon.mimetype">$chrome.icon.abs_src</Image> 8 <Url type="text/html" 9 template="${abs_href.search()}?q={searchTerms}&page={startPage}"/> 10 </OpenSearchDescription>
