Compare commits
No commits in common. "e7292a59897a1114a1560f507852eb9c7e02d89c" and "83df2c0011fb013d0b7443f94aec68d67d476dde" have entirely different histories.
e7292a5989
...
83df2c0011
4 changed files with 5 additions and 22 deletions
|
@ -312,14 +312,6 @@
|
||||||
"autocomplete": true,
|
"autocomplete": true,
|
||||||
"columnWidth": 128
|
"columnWidth": 128
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"id": "fulltext",
|
|
||||||
"operator": "+",
|
|
||||||
"title": "Fulltext",
|
|
||||||
"type": "text",
|
|
||||||
"fulltext": true,
|
|
||||||
"find": true
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"id": "created",
|
"id": "created",
|
||||||
"operator": "-",
|
"operator": "-",
|
||||||
|
|
|
@ -310,14 +310,6 @@
|
||||||
"autocomplete": true,
|
"autocomplete": true,
|
||||||
"columnWidth": 128
|
"columnWidth": 128
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"id": "fulltext",
|
|
||||||
"operator": "+",
|
|
||||||
"title": "Fulltext",
|
|
||||||
"type": "text",
|
|
||||||
"fulltext": true,
|
|
||||||
"find": true
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"id": "created",
|
"id": "created",
|
||||||
"operator": "-",
|
"operator": "-",
|
||||||
|
|
|
@ -42,6 +42,7 @@ def ocr_image(path):
|
||||||
|
|
||||||
class FulltextMixin:
|
class FulltextMixin:
|
||||||
_ES_INDEX = "document-index"
|
_ES_INDEX = "document-index"
|
||||||
|
_ES_DOC_TYPE = "document"
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def elasticsearch(cls):
|
def elasticsearch(cls):
|
||||||
|
@ -66,7 +67,7 @@ class FulltextMixin:
|
||||||
if self.has_fulltext_key():
|
if self.has_fulltext_key():
|
||||||
from elasticsearch.exceptions import NotFoundError
|
from elasticsearch.exceptions import NotFoundError
|
||||||
try:
|
try:
|
||||||
res = self.elasticsearch().delete(index=self._ES_INDEX, id=self.id)
|
res = self.elasticsearch().delete(index=self._ES_INDEX, doc_type=self._ES_DOC_TYPE, id=self.id)
|
||||||
except NotFoundError:
|
except NotFoundError:
|
||||||
pass
|
pass
|
||||||
except:
|
except:
|
||||||
|
@ -79,7 +80,7 @@ class FulltextMixin:
|
||||||
doc = {
|
doc = {
|
||||||
'text': text.lower()
|
'text': text.lower()
|
||||||
}
|
}
|
||||||
res = self.elasticsearch().index(index=self._ES_INDEX, id=self.id, body=doc)
|
res = self.elasticsearch().index(index=self._ES_INDEX, doc_type=self._ES_DOC_TYPE, id=self.id, body=doc)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def find_fulltext(cls, query):
|
def find_fulltext(cls, query):
|
||||||
|
@ -175,6 +176,7 @@ class FulltextMixin:
|
||||||
|
|
||||||
class FulltextPageMixin(FulltextMixin):
|
class FulltextPageMixin(FulltextMixin):
|
||||||
_ES_INDEX = "document-page-index"
|
_ES_INDEX = "document-page-index"
|
||||||
|
_DOC_TYPE = 'page'
|
||||||
|
|
||||||
def extract_fulltext(self):
|
def extract_fulltext(self):
|
||||||
if self.document.file:
|
if self.document.file:
|
||||||
|
|
|
@ -1289,15 +1289,12 @@ def atom_xml(request):
|
||||||
'application/atom+xml'
|
'application/atom+xml'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def oembed(request):
|
def oembed(request):
|
||||||
format = request.GET.get('format', 'json')
|
format = request.GET.get('format', 'json')
|
||||||
maxwidth = int(request.GET.get('maxwidth', 640))
|
maxwidth = int(request.GET.get('maxwidth', 640))
|
||||||
maxheight = int(request.GET.get('maxheight', 480))
|
maxheight = int(request.GET.get('maxheight', 480))
|
||||||
|
|
||||||
url = request.GET.get('url')
|
url = request.GET['url']
|
||||||
if not url:
|
|
||||||
raise Http404
|
|
||||||
parts = urlparse(url).path.split('/')
|
parts = urlparse(url).path.split('/')
|
||||||
if len(parts) < 2:
|
if len(parts) < 2:
|
||||||
raise Http404
|
raise Http404
|
||||||
|
|
Loading…
Reference in a new issue