From 2458935fdf4373ea4e6763960f1131aa24db6d1a Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Sat, 22 Nov 2014 14:36:37 +0100 Subject: [PATCH] Changed post editing Post editing no longer encapsulates file content in base64. --- .../js/Presenters/PostEditPresenter.js | 27 ++++++++----------- src/FormData/PostEditFormData.php | 6 ++--- 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/public_html/js/Presenters/PostEditPresenter.js b/public_html/js/Presenters/PostEditPresenter.js index aaeba32f..94e4b02d 100644 --- a/public_html/js/Presenters/PostEditPresenter.js +++ b/public_html/js/Presenters/PostEditPresenter.js @@ -75,15 +75,11 @@ App.Presenters.PostEditPresenter = function( } function postContentChanged(files) { - postContentFileDropper.readAsDataURL(files[0], function(content) { - postContent = content; - }); + postContent = files[0]; } function postThumbnailChanged(files) { - postThumbnailFileDropper.readAsDataURL(files[0], function(content) { - postThumbnail = content; - }); + postThumbnail = files[0]; } function getPrivileges() { @@ -92,37 +88,36 @@ App.Presenters.PostEditPresenter = function( function editPost() { var $form = $target.find('form'); - var formData = {}; - formData.seenEditTime = post.lastEditTime; - formData.flags = {}; + var formData = new FormData(); + formData.append('seenEditTime', post.lastEditTime); if (privileges.canChangeContent && postContent) { - formData.content = postContent; + formData.append('content', postContent); } if (privileges.canChangeThumbnail && postThumbnail) { - formData.thumbnail = postThumbnail; + formData.append('thumbnail', postThumbnail); } if (privileges.canChangeSource) { - formData.source = $form.find('[name=source]').val(); + formData.append('source', $form.find('[name=source]').val()); } if (privileges.canChangeSafety) { - formData.safety = $form.find('[name=safety]:checked').val(); + formData.append('safety', $form.find('[name=safety]:checked').val()); } if (privileges.canChangeTags) { - formData.tags = tagInput.getTags().join(' '); + formData.append('tags', tagInput.getTags().join(' ')); } if (privileges.canChangeRelations) { - formData.relations = $form.find('[name=relations]').val(); + formData.append('relations', $form.find('[name=relations]').val()); } if (privileges.canChangeFlags) { if (post.contentType === 'video') { - formData.flags.loop = $form.find('[name=loop]').is(':checked') ? 1 : 0; + formData.append('loop', $form.find('[name=loop]').is(':checked') ? 1 : 0); } } diff --git a/src/FormData/PostEditFormData.php b/src/FormData/PostEditFormData.php index 686d28d6..f7a2691e 100644 --- a/src/FormData/PostEditFormData.php +++ b/src/FormData/PostEditFormData.php @@ -20,8 +20,8 @@ class PostEditFormData implements IValidatable { if ($inputReader !== null) { - $this->content = $inputReader->decodeBase64($inputReader->content); - $this->thumbnail = $inputReader->decodeBase64($inputReader->thumbnail); + $this->content = $inputReader->readFile('content'); + $this->thumbnail = $inputReader->readFile('thumbnail'); if ($inputReader->safety) $this->safety = EnumHelper::postSafetyFromString($inputReader->safety); if ($inputReader->source !== null) @@ -31,7 +31,7 @@ class PostEditFormData implements IValidatable $this->relations = array_filter(preg_split('/[\s+]/', $inputReader->relations)); $this->seenEditTime = $inputReader->seenEditTime; $this->flags = new \StdClass; - $this->flags->loop = !empty($inputReader->flags['loop']); + $this->flags->loop = !empty($inputReader->loop); } }