Skip to content

Commit

Permalink
Merge pull request #131 from diging/bug/VGNWB-237
Browse files Browse the repository at this point in the history
Bug/vgnwb 237
  • Loading branch information
jdamerow authored Mar 15, 2018
2 parents acc45a1 + d7b1314 commit 8682c49
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
5 changes: 4 additions & 1 deletion annotations/annotators.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def my_view(request, text_id):
from annotations.utils import basepath
from annotations.models import TextCollection, VogonUserDefaultProject
from urlparse import urlparse
import chardet


class Annotator(object):
Expand Down Expand Up @@ -153,11 +154,13 @@ def render_display(self, context={}):
def get_context(self):
resource = self.get_resource()
request = self.context.get('request')
content = self.get_content(resource)
detect = chardet.detect(content)
return {
'text': self.text,
'textid': self.text.id,
'title': 'Annotate Text',
'content': self.get_content(resource),
'content': content.decode(detect['encoding']).encode('utf-8'), # We are using chardet to guess the encoding becuase giles is returning everyting with a utf-8 header even if it is not utf-8
'baselocation' : basepath(request),
'userid': request.user.id,
'title': self.text.title,
Expand Down
2 changes: 1 addition & 1 deletion annotations/templates/annotations/vue.html
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@
var USER_NAME = '{{ user.username }}';
var PROJECT_ID = '{{ project.id }}';
var PROJECT_NAME = '{{ project.name }}';
var TEXT_CONTENT = `{{ content|safe }}`;
var TEXT_CONTENT = `{{ content|safe }}`; // the safe tag suppresses unicode errors
var BASE_URL = '{{ base_url }}';

// Appellator is the text annotation application. Even though we load
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,5 @@ Unidecode==0.4.20
urllib3==1.19.1
xmltodict==0.10.2
dicttoxml==1.6.6
six==1.10.0
six==1.10.0

0 comments on commit 8682c49

Please sign in to comment.