implemented django version of devhub search page (bug 711197)
This commit is contained in:
Родитель
0cbab1b248
Коммит
f317206ba9
|
@ -0,0 +1,29 @@
|
|||
{% extends 'devhub/base_impala.html' %}
|
||||
|
||||
{% if query %}
|
||||
{% set title = _('{0} :: Search')|f(query) %}
|
||||
{% else %}
|
||||
{% set title = _('Search') %}
|
||||
{% endif %}
|
||||
{% block title %}{{ dev_page_title(title) }}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
{{ docs_breadcrumbs(items=[(None, _('Search Results'))]) }}
|
||||
{% if query %}
|
||||
<h1>{{ _('Search Results for "{0}"')|f(query) }}</h1>
|
||||
{% else %}
|
||||
<h1>{{ _('Search Results') }}</h1>
|
||||
{% endif %}
|
||||
|
||||
<div id="search-results" role="main" class="listing island hero c">
|
||||
<div id="resultcount" class="hidden">{{ _('Please enter some search terms.') }}</div>
|
||||
<div id="cse">
|
||||
<p>{{ _('Loading results…') }}</p>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
{% block js_extras %}
|
||||
<!-- Google Custom Search Element -->
|
||||
<script src="https://www.google.com/jsapi"></script>
|
||||
<script src="{{ media('js/zamboni/devhub_search.js') }}"></script>
|
||||
{% endblock %}
|
|
@ -3573,3 +3573,16 @@ class TestRemoveLocale(amo.tests.TestCase):
|
|||
doc = pq(res.content)
|
||||
# There's 2 fields, one for en-us, one for init.
|
||||
eq_(len(doc('div.trans textarea')), 2)
|
||||
|
||||
|
||||
class TestSearch(amo.tests.TestCase):
|
||||
|
||||
def test_search_titles(self):
|
||||
r = self.client.get(reverse('devhub.search'), {'q': 'davor'})
|
||||
self.assertContains(r, '"davor"</h1>')
|
||||
self.assertContains(r, '<title>davor :: Search ::')
|
||||
|
||||
def test_search_titles_default(self):
|
||||
r = self.client.get(reverse('devhub.search'))
|
||||
self.assertContains(r, '<title>Search ::')
|
||||
self.assertContains(r, '<h1>Search Results</h1>')
|
||||
|
|
|
@ -169,6 +169,7 @@ redirect_patterns = patterns('',
|
|||
('^versions/validate/(\d+)', views.validator_redirect),
|
||||
)
|
||||
|
||||
|
||||
urlpatterns = decorate(write, patterns('',
|
||||
url('^$', views.index, name='devhub.index'),
|
||||
url('', include(redirect_patterns)),
|
||||
|
@ -256,4 +257,6 @@ urlpatterns = decorate(write, patterns('',
|
|||
# PayPal Checker
|
||||
url('^check_paypal$', views.check_paypal, name='devhub.check_paypal'),
|
||||
|
||||
# Search
|
||||
url(r'^search$', views.search, name='devhub.search'),
|
||||
))
|
||||
|
|
|
@ -1776,3 +1776,8 @@ def check_paypal(request):
|
|||
|
||||
return {'valid': bool(paykey and valid_paypal), 'message': message}
|
||||
|
||||
|
||||
def search(request):
|
||||
query = request.GET.get('q', '')
|
||||
return jingo.render(request, 'devhub/devhub_search.html', {'query': query})
|
||||
|
||||
|
|
|
@ -0,0 +1,135 @@
|
|||
@import '../impala/lib';
|
||||
|
||||
#search-results {
|
||||
// Outer row
|
||||
.gsc-webResult {
|
||||
color: @note-gray;
|
||||
padding: 0;
|
||||
width: 100%;
|
||||
|
||||
// Inner row
|
||||
.gs-result {
|
||||
padding: 20px 1em;
|
||||
&:hover {
|
||||
background-color: @faded-blue;
|
||||
}
|
||||
.gs-title {
|
||||
font-size: 16px;
|
||||
font-weight: bold;
|
||||
line-height: 18px;
|
||||
text-decoration: none;
|
||||
a {
|
||||
color: @link;
|
||||
text-decoration: none;
|
||||
b {
|
||||
color: @orange;
|
||||
}
|
||||
&:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
* {
|
||||
text-decoration: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
.gs-title, .gs-snippet {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
.gs-snippet {
|
||||
color: @medium-gray;
|
||||
margin-top: .5em;
|
||||
font-size: 12px;
|
||||
line-height: 1.3em;
|
||||
}
|
||||
.gs-per-result-labels {
|
||||
margin-top: 5px;
|
||||
font-size: 11px;
|
||||
a {
|
||||
color: @medium-gray;
|
||||
font-weight: bold;
|
||||
text-decoration: none;
|
||||
&:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
}
|
||||
}
|
||||
.gs-visibleUrl {
|
||||
color: @green;
|
||||
}
|
||||
}
|
||||
.gsc-result {
|
||||
border-bottom: 1px dotted @border-blue;
|
||||
}
|
||||
}
|
||||
.gsc-result-info {
|
||||
padding: .5em 0 1em 0;
|
||||
font-size: 11px;
|
||||
border-bottom: 1px dotted @border-blue;
|
||||
}
|
||||
.gsc-tabHeader {
|
||||
border: 0;
|
||||
font-size: 11px;
|
||||
margin-right: 0;
|
||||
&.gsc-tabhActive, &.gsc-tabhInactive {
|
||||
border: 0;
|
||||
border-left: 1px solid @light-gray;
|
||||
&:first-child {
|
||||
border-left: 0;
|
||||
}
|
||||
}
|
||||
&.gsc-tabhActive {
|
||||
color: @orange;
|
||||
font-weight: bold;
|
||||
}
|
||||
&.gsc-tabhInactive {
|
||||
background: transparent;
|
||||
color: @link;
|
||||
&:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
}
|
||||
&:first-child {
|
||||
padding-left: 0;
|
||||
}
|
||||
}
|
||||
.gsc-cursor-box {
|
||||
margin-top: 1em;
|
||||
}
|
||||
.gsc-cursor-page {
|
||||
color: @dark-gray;
|
||||
text-decoration: none;
|
||||
margin: 0 8px 0 0;
|
||||
padding: 5px;
|
||||
&.gsc-cursor-current-page {
|
||||
color: @orange;
|
||||
}
|
||||
&:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
}
|
||||
.gsc-result .gs-title {
|
||||
height: auto;
|
||||
}
|
||||
.gsc-tabsArea {
|
||||
margin-bottom: .5em;
|
||||
.gs-spacer {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
.html-rtl #search-results {
|
||||
.gsc-cursor-page {
|
||||
margin: 0 0 0 8px;
|
||||
}
|
||||
.gsc-tabHeader {
|
||||
margin-left: 0;
|
||||
&.gsc-tabhActive, &.gsc-tabhInactive {
|
||||
border-left: 0;
|
||||
border-right: 1px solid @light-gray;
|
||||
}
|
||||
}
|
||||
.gsc-tabsArea div .gsc-tabHeader:first-child {
|
||||
border-right: 0 !important;
|
||||
padding: 0 0 0 6px;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
google.load('search', '1', {'language' : $('html').attr('lang')});
|
||||
google.setOnLoadCallback(function() {
|
||||
var qry = $('.header-search input[name="q"]'),
|
||||
opt = new google.search.DrawOptions();
|
||||
|
||||
opt.setInput(qry.get(0));
|
||||
sc = new google.search.CustomSearchControl('007182852441266509516:fnsg3w7luc4');
|
||||
sc.setNoResultsString(gettext('No results found.'));
|
||||
sc.setSearchStartingCallback(null, function(sc, searcher, qry) {
|
||||
sc.maxResultCount = 0;
|
||||
});
|
||||
|
||||
sc.setSearchCompleteCallback(null, function(sc, searcher) {
|
||||
if (searcher.results.length) {
|
||||
var cur = searcher.cursor,
|
||||
total = parseInt(cur.estimatedResultCount, 10);
|
||||
if (total > sc.maxResultCount) {
|
||||
sc.maxResultCount = total;
|
||||
$('#cse').show();
|
||||
window.scroll(0, 0);
|
||||
}
|
||||
} else {
|
||||
$('#resultcount').hide();
|
||||
}
|
||||
});
|
||||
|
||||
$('#cse').hide();
|
||||
sc.draw('cse', opt);
|
||||
|
||||
if (!qry.val()) {
|
||||
$('#resultcount').show();
|
||||
}
|
||||
|
||||
$('#searchbox').submit(_pd(function(e) {
|
||||
sc.execute();
|
||||
}));
|
||||
}, true);
|
|
@ -517,6 +517,7 @@ MINIFY_BUNDLES = {
|
|||
'css/devhub/dashboard.less',
|
||||
'css/devhub/forms.less',
|
||||
'css/devhub/submission.less',
|
||||
'css/devhub/search.less',
|
||||
),
|
||||
'zamboni/editors': (
|
||||
'css/zamboni/editors.css',
|
||||
|
|
Загрузка…
Ссылка в новой задаче