Changed post editing

Post editing no longer encapsulates file content in base64.
This commit is contained in:
Marcin Kurczewski 2014-11-22 14:36:37 +01:00
parent f2b1e3bedb
commit 2458935fdf
2 changed files with 14 additions and 19 deletions

View file

@ -75,15 +75,11 @@ App.Presenters.PostEditPresenter = function(
} }
function postContentChanged(files) { function postContentChanged(files) {
postContentFileDropper.readAsDataURL(files[0], function(content) { postContent = files[0];
postContent = content;
});
} }
function postThumbnailChanged(files) { function postThumbnailChanged(files) {
postThumbnailFileDropper.readAsDataURL(files[0], function(content) { postThumbnail = files[0];
postThumbnail = content;
});
} }
function getPrivileges() { function getPrivileges() {
@ -92,37 +88,36 @@ App.Presenters.PostEditPresenter = function(
function editPost() { function editPost() {
var $form = $target.find('form'); var $form = $target.find('form');
var formData = {}; var formData = new FormData();
formData.seenEditTime = post.lastEditTime; formData.append('seenEditTime', post.lastEditTime);
formData.flags = {};
if (privileges.canChangeContent && postContent) { if (privileges.canChangeContent && postContent) {
formData.content = postContent; formData.append('content', postContent);
} }
if (privileges.canChangeThumbnail && postThumbnail) { if (privileges.canChangeThumbnail && postThumbnail) {
formData.thumbnail = postThumbnail; formData.append('thumbnail', postThumbnail);
} }
if (privileges.canChangeSource) { if (privileges.canChangeSource) {
formData.source = $form.find('[name=source]').val(); formData.append('source', $form.find('[name=source]').val());
} }
if (privileges.canChangeSafety) { if (privileges.canChangeSafety) {
formData.safety = $form.find('[name=safety]:checked').val(); formData.append('safety', $form.find('[name=safety]:checked').val());
} }
if (privileges.canChangeTags) { if (privileges.canChangeTags) {
formData.tags = tagInput.getTags().join(' '); formData.append('tags', tagInput.getTags().join(' '));
} }
if (privileges.canChangeRelations) { if (privileges.canChangeRelations) {
formData.relations = $form.find('[name=relations]').val(); formData.append('relations', $form.find('[name=relations]').val());
} }
if (privileges.canChangeFlags) { if (privileges.canChangeFlags) {
if (post.contentType === 'video') { 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);
} }
} }

View file

@ -20,8 +20,8 @@ class PostEditFormData implements IValidatable
{ {
if ($inputReader !== null) if ($inputReader !== null)
{ {
$this->content = $inputReader->decodeBase64($inputReader->content); $this->content = $inputReader->readFile('content');
$this->thumbnail = $inputReader->decodeBase64($inputReader->thumbnail); $this->thumbnail = $inputReader->readFile('thumbnail');
if ($inputReader->safety) if ($inputReader->safety)
$this->safety = EnumHelper::postSafetyFromString($inputReader->safety); $this->safety = EnumHelper::postSafetyFromString($inputReader->safety);
if ($inputReader->source !== null) if ($inputReader->source !== null)
@ -31,7 +31,7 @@ class PostEditFormData implements IValidatable
$this->relations = array_filter(preg_split('/[\s+]/', $inputReader->relations)); $this->relations = array_filter(preg_split('/[\s+]/', $inputReader->relations));
$this->seenEditTime = $inputReader->seenEditTime; $this->seenEditTime = $inputReader->seenEditTime;
$this->flags = new \StdClass; $this->flags = new \StdClass;
$this->flags->loop = !empty($inputReader->flags['loop']); $this->flags->loop = !empty($inputReader->loop);
} }
} }