Skip to content

Commit a2e0e3f

Browse files
committed
Revert changes in the search api
1 parent c971410 commit a2e0e3f

File tree

3 files changed

+4
-22
lines changed

3 files changed

+4
-22
lines changed

readthedocs/core/static-src/core/js/doc-embed/search.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,10 @@ function attach_elastic_search_query(data) {
3838
var list_item = $('<li style="display: none;"></li>');
3939

4040
// Creating the result from elements
41-
var url = doc.url + '?highlight=' + $.urlencode(query);
41+
var link = doc.link + DOCUMENTATION_OPTIONS.FILE_SUFFIX +
42+
'?highlight=' + $.urlencode(query);
4243

43-
var item = $('<a>', {'href': url});
44+
var item = $('<a>', {'href': link});
4445
item.html(doc.title);
4546
list_item.append(item);
4647

readthedocs/search/api.py

-19
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import logging
2-
import os
32
from pprint import pformat
43

54
from rest_framework import generics, serializers
@@ -24,33 +23,15 @@ class PageSearchSerializer(serializers.Serializer):
2423
version = serializers.CharField()
2524
title = serializers.CharField()
2625
path = serializers.CharField()
27-
# Doc url without extension
2826
link = serializers.SerializerMethodField()
29-
# Doc url with extension
30-
url = serializers.SerializerMethodField()
3127
highlight = serializers.SerializerMethodField()
3228

3329
def get_link(self, obj):
34-
"""
35-
Gets the url without extension.
36-
37-
.. warning::
38-
This is only used to keep compatibility with
39-
the previous search implementation.
40-
Use `url` instead.
41-
"""
4230
projects_url = self.context.get('projects_url')
4331
if projects_url:
4432
docs_url = projects_url[obj.project]
4533
return docs_url + obj.path
4634

47-
def get_url(self, obj):
48-
"""Gets the full url."""
49-
projects_url = self.context.get('projects_url')
50-
if projects_url:
51-
docs_url = projects_url[obj.project]
52-
return docs_url + obj.full_path
53-
5435
def get_highlight(self, obj):
5536
highlight = getattr(obj.meta, 'highlight', None)
5637
if highlight:

readthedocs/templates/search/elastic_search.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ <h3>
210210

211211
{% elif 'page' in result.meta.index %}
212212

213-
<a href="{% doc_url result.project|get_project result.version result.path %}?highlight={{ query }}">
213+
<a href="{% doc_url result.project|get_project result.version result.full_path %}?highlight={{ query }}">
214214
{{ result.project }} - {{ result.title }}
215215
</a>
216216
{% for fragment in result.meta.highlight.content %}

0 commit comments

Comments
 (0)