Changeset - 666fc6ac9ce5
[Not reviewed]
beta
0 4 0
Mads Kiilerich - 13 years ago 2013-01-30 21:17:03
madski@unity3d.com
Transplanted from: 12830f6a6d31
search: repo search is a repo thing - show it that way in ui and url
4 files changed with 40 insertions and 32 deletions:
0 comments (0 inline, 0 general)
rhodecode/config/routing.py
Show inline comments
 
@@ -380,26 +380,30 @@ def make_map(config):
 
                 action="public_journal_atom")
 

	
 
    rmap.connect('public_journal_atom_old',
 
                 '%s/public_journal_atom' % ADMIN_PREFIX, controller='journal',
 
                 action="public_journal_atom")
 

	
 
    rmap.connect('toggle_following', '%s/toggle_following' % ADMIN_PREFIX,
 
                 controller='journal', action='toggle_following',
 
                 conditions=dict(method=["POST"]))
 

	
 
    #SEARCH
 
    rmap.connect('search', '%s/search' % ADMIN_PREFIX, controller='search',)
 
    rmap.connect('search_repo', '%s/search/{search_repo:.*}' % ADMIN_PREFIX,
 
                  controller='search')
 
    rmap.connect('search_repo_admin', '%s/search/{repo_name:.*}' % ADMIN_PREFIX,
 
                 controller='search')
 
    rmap.connect('search_repo', '/{repo_name:.*?}/search',
 
                 controller='search',
 
                 conditions=dict(function=check_repo),
 
                 )
 

	
 
    #LOGIN/LOGOUT/REGISTER/SIGN IN
 
    rmap.connect('login_home', '%s/login' % ADMIN_PREFIX, controller='login')
 
    rmap.connect('logout_home', '%s/logout' % ADMIN_PREFIX, controller='login',
 
                 action='logout')
 

	
 
    rmap.connect('register', '%s/register' % ADMIN_PREFIX, controller='login',
 
                 action='register')
 

	
 
    rmap.connect('reset_password', '%s/password_reset' % ADMIN_PREFIX,
 
                 controller='login', action='password_reset')
 

	
rhodecode/controllers/search.py
Show inline comments
 
@@ -20,49 +20,49 @@
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
# GNU General Public License for more details.
 
#
 
# You should have received a copy of the GNU General Public License
 
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
import logging
 
import traceback
 
import urllib
 
from pylons.i18n.translation import _
 
from pylons import request, config, tmpl_context as c
 

	
 
from rhodecode.lib.auth import LoginRequired
 
from rhodecode.lib.base import BaseController, render
 
from rhodecode.lib.base import BaseRepoController, render
 
from rhodecode.lib.indexers import CHGSETS_SCHEMA, SCHEMA, CHGSET_IDX_NAME, \
 
    IDX_NAME, WhooshResultWrapper
 

	
 
from webhelpers.paginate import Page
 
from webhelpers.util import update_params
 

	
 
from whoosh.index import open_dir, EmptyIndexError
 
from whoosh.qparser import QueryParser, QueryParserError
 
from whoosh.query import Phrase, Wildcard, Term, Prefix
 
from rhodecode.model.repo import RepoModel
 
from rhodecode.lib.utils2 import safe_str, safe_int
 

	
 

	
 
log = logging.getLogger(__name__)
 

	
 

	
 
class SearchController(BaseController):
 
class SearchController(BaseRepoController):
 

	
 
    @LoginRequired()
 
    def __before__(self):
 
        super(SearchController, self).__before__()
 

	
 
    def index(self, search_repo=None):
 
        c.repo_name = search_repo
 
    def index(self, repo_name=None):
 
        c.repo_name = repo_name
 
        c.formated_results = []
 
        c.runtime = ''
 
        c.cur_query = request.GET.get('q', None)
 
        c.cur_type = request.GET.get('type', 'content')
 
        c.cur_search = search_type = {'content': 'content',
 
                                      'commit': 'message',
 
                                      'path': 'path',
 
                                      'repository': 'repository'
 
                                      }.get(c.cur_type, 'content')
 

	
 
        index_name = {
 
            'content': IDX_NAME,
rhodecode/templates/base/base.html
Show inline comments
 
@@ -212,25 +212,25 @@
 
                 %else:
 
                     <li>${h.link_to(_('repository settings'),h.url('repo_settings_home',repo_name=c.repo_name),class_='settings')}</li>
 
                 %endif
 
               %endif
 

	
 
                <li>${h.link_to(_('fork'),h.url('repo_fork_home',repo_name=c.repo_name),class_='fork')}</li>
 
                %if h.is_hg(c.rhodecode_repo):
 
                 <li>${h.link_to(_('open new pull request'),h.url('pullrequest_home',repo_name=c.repo_name),class_='pull_request')}</li>
 
                %endif
 
                %if c.rhodecode_db_repo.fork:
 
                 <li>${h.link_to(_('compare fork'),h.url('compare_url',repo_name=c.repo_name,org_ref_type='branch',org_ref=request.GET.get('branch') or 'default',other_ref_type='branch',other_ref='default',repo=c.rhodecode_db_repo.fork.repo_name),class_='compare_request')}</li>
 
                %endif
 
                <li>${h.link_to(_('search'),h.url('search_repo',search_repo=c.repo_name),class_='search')}</li>
 
                <li>${h.link_to(_('search'),h.url('search_repo',repo_name=c.repo_name),class_='search')}</li>
 

	
 
                %if h.HasRepoPermissionAny('repository.write','repository.admin')(c.repo_name) and c.rhodecode_db_repo.enable_locking:
 
                  %if c.rhodecode_db_repo.locked[0]:
 
                    <li>${h.link_to(_('unlock'), h.url('toggle_locking',repo_name=c.repo_name),class_='locking_del')}</li>
 
                  %else:
 
                    <li>${h.link_to(_('lock'), h.url('toggle_locking',repo_name=c.repo_name),class_='locking_add')}</li>
 
                  %endif
 
                %endif
 

	
 
                % if h.HasPermissionAll('hg.admin')('access admin main page'):
 
                 <li>
 
                   ${h.link_to(_('admin'),h.url('admin_home'),class_='admin')}
rhodecode/templates/search/search.html
Show inline comments
 
## -*- coding: utf-8 -*-
 
<%inherit file="/base/base.html"/>
 

	
 
<%def name="title()">
 
   %if c.cur_query:
 
  %if c.repo_name:
 
    ${_('Search repository')} ${c.repo_name} - ${c.rhodecode_name}
 
  %else:
 
    ${_('Search in all repositories')}
 
  %endif
 
</%def>
 

	
 
<%def name="breadcrumbs_links()">
 
  %if c.repo_name:
 
    ${h.link_to(_(u'Home'),h.url('/'))}
 
    &raquo;
 
    ${h.link_to(c.repo_name,h.url('summary_home',repo_name=c.repo_name))}
 
    &raquo;
 
    ${_('Search')}
 
  %else:
 
    ${_('Search in all repositories')}
 
  %endif
 
  %if c.cur_query:
 
    &raquo;
 
    ${c.cur_query}
 
  %endif
 
</%def>
 

	
 
<%def name="page_nav()">
 
    %if c.repo_name:
 
        ${_('Search "%s" in repository: %s') % (c.cur_query, c.repo_name)}
 
    %else:
 
        ${_('Search "%s" in all repositories') % c.cur_query}
 
    %endif
 
   %else:
 
    %if c.repo_name:
 
        ${_('Search in repository: %s') % c.repo_name}
 
    ${self.menu('options')}
 
    %else:
 
        ${_('Search in all repositories')}
 
    ${self.menu('search')}
 
    %endif
 
   %endif
 
    - ${c.rhodecode_name}
 
</%def>
 
<%def name="breadcrumbs()">
 
    ${c.rhodecode_name}
 
</%def>
 
<%def name="page_nav()">
 
    ${self.menu('search')}
 
</%def>
 
<%def name="main()">
 

	
 
<div class="box">
 
    <!-- box / title -->
 
    <div class="title">
 
        <h5>
 
        %if c.repo_name:
 
            ${_('Search in repository: %s') % c.repo_name}
 
        %else:
 
            ${_('Search in all repositories')}
 
        %endif
 
        </h5>
 
        ${self.breadcrumbs()}
 
    </div>
 
    <!-- end box / title -->
 
    %if c.repo_name:
 
        ${h.form(h.url('search_repo',search_repo=c.repo_name),method='get')}
 
        ${h.form(h.url('search_repo',repo_name=c.repo_name),method='get')}
 
    %else:
 
        ${h.form(h.url('search'),method='get')}
 
    %endif
 
    <div class="form">
 
        <div class="fields">
 
            <div class="field field-first field-noborder">
 
             <div class="label">
 
                 <label for="q">${_('Search term')}</label>
 
             </div>
 
                <div class="input">${h.text('q',c.cur_query,class_="small")}
 
                    <div class="button highlight">
 
                        <input type="submit" value="${_('Search')}" class="ui-button"/>
0 comments (0 inline, 0 general)