Skip to content
This repository was archived by the owner on Jun 1, 2022. It is now read-only.

Commit 359b4dc

Browse files
committed
Show display URL, not API URL in search results
1 parent 54518b1 commit 359b4dc

File tree

7 files changed

+11
-11
lines changed

7 files changed

+11
-11
lines changed

editorsnotes/main/static/function/all-notes.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ $(function() {
108108

109109
var $facets = $('#note-facets input');
110110
$facets.prop('checked', false);
111-
$facets.live('click', function() {
111+
$facets.on('click', function() {
112112
var $checked = $('#note-facets input:checked');
113113
var $sortingOptions = $('.sort-option');
114114
var queryString = '?filter=1'
@@ -145,13 +145,13 @@ $(function() {
145145

146146

147147
// Toggle faceting options
148-
$('.facet-title').live('click', function() {
148+
$('.facet-title').on('click', function() {
149149
$(this).find('i').toggleClass('fa-plus fa-minus');
150150
$('.facets').slideToggle('fast');
151151
})
152152

153153
// Resort list of notes on click of sort options
154-
$('.sort-option').live('click', function() {
154+
$('.sort-option').on('click', function() {
155155
var $thisOption = $(this);
156156
var $otherOptions = $thisOption.siblings('.sort-option');
157157

editorsnotes/main/templates/filtered-documents.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ <h3>Filters</h3>
5151
<ul class="unstyled model-list" id="document-list">
5252
{% for document in documents %}
5353
<li class="document">
54-
<a href="{{ document.url }}">{{ document.description|safe }}</a>
54+
<a href="{{ document.display_url }}">{{ document.serialized.description|safe }}</a>
5555
</li>
5656
{% endfor %}
5757
</ul>

editorsnotes/main/templates/filtered-notes.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ <h6>Topics</h6>
7070
<div class="span12 row">
7171
<ul class="unstyled span6" id="note-list-1">
7272
{% for note in notes %}
73-
<li class="note" date-modified="{{ note.last_updated }}">
74-
<a href="{{ note.url }}">{{ note.title }}</a>
73+
<li class="note" date-modified="{{ note.serialized.last_updated }}">
74+
<a href="{{ note.display_url }}">{{ note.display_title }}</a>
7575
</li>
7676
{% endfor %}
7777
</ul>

editorsnotes/main/views/documents.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,7 @@ def all_documents(request, project_slug=None):
125125
o['facets'][facet_label] = [ (f['term'], f['term'], f['count'])
126126
for f in facet_vals['terms'] ]
127127

128-
o['documents'] = [ d['_source']['serialized'] for d in
129-
executed_query['hits']['hits'] ]
128+
o['documents'] = [d['_source'] for d in executed_query['hits']['hits']]
130129

131130
return render_to_response(
132131
template, o, context_instance=RequestContext(request))

editorsnotes/main/views/notes.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,7 @@ def all_notes(request, project_slug=None):
125125
status_facets = executed_query['facets']['status_facet']['terms']
126126
o['status_facets'] = status_facets
127127

128-
o['notes'] = [ n['_source']['serialized'] for n in
129-
executed_query['hits']['hits'] ]
128+
o['notes'] = [n['_source'] for n in executed_query['hits']['hits']]
130129

131130
return render_to_response(
132131
template, o, context_instance=RequestContext(request))

editorsnotes/search/templatetags/render_search_results.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,6 @@ def render_search_result(result_dict):
4343
result_body = u''
4444

4545
return TEMPLATE.format(result_type=result_type.title(),
46-
result_url=serialized['url'],
46+
result_url=result_dict['_source'].get('display_url', serialized['url']),
4747
result_display=result_display,
4848
result_body=result_body)

editorsnotes/search/types.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ def get_mapping(self):
4848
mapping = {
4949
self.type_label : {
5050
'properties': {
51+
'display_url': { 'type': 'string', 'index': 'not_analyzed' },
5152
'display_title': {
5253
'search_analyzer': 'analyzer_shingle',
5354
'index_analyzer': 'analyzer_shingle',
@@ -93,6 +94,7 @@ def data_from_object(self, obj, request=None):
9394
data = {
9495
'id': obj.id,
9596
'serialized': obj._rest_serialized,
97+
'display_url': obj.get_absolute_url(),
9698
'display_title': obj.as_text()
9799
}
98100
return data

0 commit comments

Comments
 (0)