From 90a2ba19a40ae9ee1400290848bb54ceb19ceba3 Mon Sep 17 00:00:00 2001 From: Evgeny Fadeev Date: Sun, 8 Jan 2012 22:37:48 -0300 Subject: now images and logos can be uploaded to amazon s3 --- askbot/doc/source/changelog.rst | 1 + askbot/skins/common/media/js/editor.js | 7 +++---- askbot/skins/utils.py | 5 +++++ askbot/views/writers.py | 11 ++++++----- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/askbot/doc/source/changelog.rst b/askbot/doc/source/changelog.rst index 45a6f49b..8f9cf9f2 100644 --- a/askbot/doc/source/changelog.rst +++ b/askbot/doc/source/changelog.rst @@ -18,6 +18,7 @@ Development version (not released yet) * replaced setting `ASKBOT_FILE_UPLOAD_DIR` with django's `MEDIA_ROOT` (Evgeny) * replaced setting `ASKBOT_UPLOADED_FILES_URL` with django's `MEDIA_URL` (Evgeny) * allowed changing file storage backend for file uploads by configuration (Evgeny) +* file uploads to amazon S3 now work with proper configuration (Evgeny) 0.7.36 (Dec 20, 2011) --------------------- diff --git a/askbot/skins/common/media/js/editor.js b/askbot/skins/common/media/js/editor.js index f5b1e2af..e580f9f6 100644 --- a/askbot/skins/common/media/js/editor.js +++ b/askbot/skins/common/media/js/editor.js @@ -42,11 +42,11 @@ function ajaxFileUpload(imageUrl, startUploadHandler) url: askbot['urls']['upload'], secureuri:false, fileElementId:'file-upload', - dataType: 'xml', + dataType: 'json', success: function (data, status) { - var fileURL = $(data).find('file_url').text(); - var error = $(data).find('error').text(); + var fileURL = data['file_url']; + var error = data['error']; if(error != ''){ alert(error); if (startUploadHandler){ @@ -57,7 +57,6 @@ function ajaxFileUpload(imageUrl, startUploadHandler) }else{ imageUrl.attr('value', fileURL); } - }, error: function (data, status, e) { diff --git a/askbot/skins/utils.py b/askbot/skins/utils.py index bf041001..50c0d4fb 100644 --- a/askbot/skins/utils.py +++ b/askbot/skins/utils.py @@ -98,6 +98,11 @@ def get_media_url(url, ignore_missing = False): #before = datetime.datetime.now() url = urllib.unquote(unicode(url)) while url[0] == '/': url = url[1:] + + #a hack allowing urls media stored on external locations to + #just pass through unchanged + if url.startswith('http://') or url.startswith('https://'): + return url #todo: handles case of multiple skin directories #if file is in upfiles directory, then give that diff --git a/askbot/views/writers.py b/askbot/views/writers.py index c4d60de9..916c0e17 100644 --- a/askbot/views/writers.py +++ b/askbot/views/writers.py @@ -103,11 +103,12 @@ def upload(request):#ajax upload file to a question or answer result = '' file_url = '' - #%s - xml_template = "%s" - xml = xml_template % (result, error, file_url) - - return HttpResponse(xml, mimetype="application/xml") + data = simplejson.dumps({ + 'result': result, + 'error': error, + 'file_url': file_url + }) + return HttpResponse(data, mimetype = 'application/json') def __import_se_data(dump_file): """non-view function that imports the SE data -- cgit v1.2.3-1-g7c22