mirror of
https://github.com/taobataoma/meanTorrent.git
synced 2026-02-26 08:11:01 +01:00
feat(torrents): new feature for upload torrent screenshots images
This commit is contained in:
2
config/env/torrents.js
vendored
2
config/env/torrents.js
vendored
@@ -1284,7 +1284,7 @@ module.exports = {
|
||||
* @resourcesLanguage: settings for language of dropdown resource info
|
||||
*/
|
||||
tmdbConfig: {
|
||||
key: 'this is access key from tmdb',
|
||||
key: '7888f0042a366f63289ff571b68b7ce0',
|
||||
tmdbHome: 'https://www.themoviedb.org',
|
||||
tmdbMovieLinkUrl: 'https://www.themoviedb.org/movie/',
|
||||
tmdbTvserialLinkUrl: 'https://www.themoviedb.org/tv/',
|
||||
|
||||
@@ -4,6 +4,13 @@ var path = require('path'),
|
||||
fs = require('fs'),
|
||||
config = require(path.resolve('./config/config'));
|
||||
|
||||
/**
|
||||
* file filter
|
||||
* @param req
|
||||
* @param file
|
||||
* @param callback
|
||||
* @returns {*}
|
||||
*/
|
||||
module.exports.imageFileFilter = function (req, file, callback) {
|
||||
if (file.mimetype !== 'image/png' && file.mimetype !== 'image/jpg' && file.mimetype !== 'image/jpeg' && file.mimetype !== 'image/gif' && file.mimetype !== 'image/bmp') {
|
||||
var err = new Error();
|
||||
@@ -33,6 +40,12 @@ module.exports.subtitleFileFilter = function (req, file, callback) {
|
||||
callback(null, true);
|
||||
};
|
||||
|
||||
/**
|
||||
* createUploadFilename
|
||||
* @param req
|
||||
* @param file
|
||||
* @param cb
|
||||
*/
|
||||
module.exports.createUploadFilename = function (req, file, cb) {
|
||||
//var regex = new RegExp(',', 'g');
|
||||
//var filename = file.originalname.replace(regex, ' ');
|
||||
@@ -76,6 +89,12 @@ module.exports.getUploadDestination = function (req, file, cb) {
|
||||
cb(null, config.uploads.torrent.file.temp);
|
||||
};
|
||||
|
||||
/**
|
||||
* createUploadAttachFilename
|
||||
* @param req
|
||||
* @param file
|
||||
* @param cb
|
||||
*/
|
||||
module.exports.createUploadAttachFilename = function (req, file, cb) {
|
||||
var RexStr = /\(|\)|\[|\]|\,/g;
|
||||
var filename = file.originalname.replace(RexStr, function (MatchStr) {
|
||||
@@ -119,6 +138,12 @@ module.exports.getUploadAttachDestination = function (req, file, cb) {
|
||||
cb(null, config.uploads.attach.file.temp);
|
||||
};
|
||||
|
||||
/**
|
||||
* createUploadSubtitleFilename
|
||||
* @param req
|
||||
* @param file
|
||||
* @param cb
|
||||
*/
|
||||
module.exports.createUploadSubtitleFilename = function (req, file, cb) {
|
||||
var regex = new RegExp(',', 'g');
|
||||
var filename = file.originalname.replace(regex, ' ');
|
||||
@@ -136,7 +161,12 @@ module.exports.getUploadSubtitleDestination = function (req, file, cb) {
|
||||
cb(null, config.uploads.subtitle.file.dest);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* createUploadCoverImageFilename
|
||||
* @param req
|
||||
* @param file
|
||||
* @param cb
|
||||
*/
|
||||
module.exports.createUploadCoverImageFilename = function (req, file, cb) {
|
||||
var RexStr = /\(|\)|\[|\]|\,/g;
|
||||
var filename = file.originalname.replace(RexStr, function (MatchStr) {
|
||||
@@ -175,6 +205,12 @@ module.exports.getUploadCoverImageDestination = function (req, file, cb) {
|
||||
cb(null, config.uploads.torrent.cover.temp);
|
||||
};
|
||||
|
||||
/**
|
||||
* createUploadTorrentImageFilename
|
||||
* @param req
|
||||
* @param file
|
||||
* @param cb
|
||||
*/
|
||||
module.exports.createUploadTorrentImageFilename = function (req, file, cb) {
|
||||
var RexStr = /\(|\)|\[|\]|\,/g;
|
||||
var filename = file.originalname.replace(RexStr, function (MatchStr) {
|
||||
@@ -213,7 +249,12 @@ module.exports.getUploadTorrentImageDestination = function (req, file, cb) {
|
||||
cb(null, config.uploads.torrent.image.temp);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* createUploadTicketImageFilename
|
||||
* @param req
|
||||
* @param file
|
||||
* @param cb
|
||||
*/
|
||||
module.exports.createUploadTicketImageFilename = function (req, file, cb) {
|
||||
var RexStr = /\(|\)|\[|\]|\,/g;
|
||||
var filename = file.originalname.replace(RexStr, function (MatchStr) {
|
||||
|
||||
@@ -558,6 +558,7 @@
|
||||
TMDB_IS_LOADING: 'Loading the resource info, please wait...',
|
||||
SELECT_SE: '• Please select number of seasons and input number of episodes',
|
||||
SELECT_TAGS: '• Please select any tags for the resources',
|
||||
SELECT_SCREEN_SHOTS: '• Please select any screenshots for the resources',
|
||||
ENTER_VIDEO_NFO: '• Please enter video and audio NFO',
|
||||
SELECT_MAKER_GROUP: '• Please select resources group upload from and anonymous option',
|
||||
MAKER_NULL: 'NULL',
|
||||
@@ -587,6 +588,12 @@
|
||||
SELECT_RESOURCE_IMAGE: '• Please select resource cover image',
|
||||
ENTER_RESOURCE_DETAIL_INFO: '• Please enter the resource detail info',
|
||||
|
||||
IMAGES_UPLOAD_TOOLTIP1: 'Image files by dragging & dropping or ',
|
||||
IMAGES_UPLOAD_TOOLTIP2: 'select them',
|
||||
IMAGES_UPLOADING: 'Uploading',
|
||||
UPLOAD_IMAGES_SUCCESSFULLY: 'Upload image file successfully',
|
||||
UPLOAD_IMAGES_FAILED: 'Upload image file failed',
|
||||
|
||||
//ranking view
|
||||
PAGE_HEADER_RANKING_UPLOAD: 'Uploaded Ranking',
|
||||
PAGE_HEADER_RANKING_DOWNLOAD: 'Downloaded Ranking',
|
||||
|
||||
@@ -0,0 +1,130 @@
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
angular.module('core')
|
||||
.directive('mtImagesUploader', mtImagesUploader);
|
||||
|
||||
mtImagesUploader.$inject = ['localStorageService', '$compile', 'NotifycationService', '$translate', 'DebugConsoleService', '$timeout'];
|
||||
|
||||
function mtImagesUploader(localStorageService, $compile, NotifycationService, $translate, mtDebug, $timeout) {
|
||||
var directive = {
|
||||
restrict: 'A',
|
||||
require: 'ngModel',
|
||||
scope: {ngModel: '='},
|
||||
replace: true,
|
||||
link: link
|
||||
};
|
||||
|
||||
return directive;
|
||||
|
||||
function link(scope, element, attrs, ngModel) {
|
||||
if (attrs.uploadMethod) {
|
||||
initVariable();
|
||||
|
||||
var eleUploadList = angular.element('<div class="upload-image-list" ng-show="uResourceImages.length"><span class="image-item" ng-repeat="f in uResourceImages track by $index"><img ng-src="{{f}}"><i class="fa fa-times" ng-click="removeImage($index)" mt-scale-by-mouse="{scale: 1.5, duration: \'.3s\'}"></i></img></span></div>');
|
||||
var eleUploadTip = angular.element('<div class="upload-image-info" ng-show="!uFile"><div class="upload-tooltip text-long"><span>{{\'IMAGES_UPLOAD_TOOLTIP1\' | translate}}</span><input type="file" class="manual-file-chooser" ng-model="selectedFile" ngf-select="onFileSelected($event);"><span class="btn-link manual-file-chooser-text">{{\'IMAGES_UPLOAD_TOOLTIP2\' | translate}}</span></div></div>');
|
||||
var eleUploadBegin = angular.element('<div class="upload-info" ng-show="uFile"><i class="fa fa-cog fa-spin fa-lg fa-fw"></i> <div class="upload-progress" style="width: {{uProgress}}%"></div><div class="upload-filename">{{\'IMAGES_UPLOADING\' | translate}}: {{uFile.name}}</div></div>');
|
||||
|
||||
element.append(eleUploadList);
|
||||
element.append(eleUploadTip);
|
||||
element.append(eleUploadBegin);
|
||||
|
||||
scope.removeImage = function (idx) {
|
||||
scope.ngModel.splice(idx, 1);
|
||||
scope.uResourceImages.splice(idx, 1);
|
||||
};
|
||||
|
||||
scope.onFileSelected = function (evt) {
|
||||
doUpload(scope.selectedFile);
|
||||
};
|
||||
|
||||
element.bind('dragenter', function (evt) {
|
||||
evt.stopPropagation();
|
||||
evt.preventDefault();
|
||||
});
|
||||
element.bind('dragover', function (evt) {
|
||||
evt.stopPropagation();
|
||||
evt.preventDefault();
|
||||
});
|
||||
|
||||
element.bind('drop', function (evt) {
|
||||
evt.stopPropagation();
|
||||
evt.preventDefault();
|
||||
|
||||
doUpload(evt.originalEvent.dataTransfer.files[0]);
|
||||
return false;
|
||||
});
|
||||
|
||||
//define method called from parent scope
|
||||
//init all variable
|
||||
scope.$parent.clearResourceImages = function () {
|
||||
initVariable();
|
||||
};
|
||||
scope.$parent.$parent.clearResourceImages = scope.$parent.clearResourceImages;
|
||||
|
||||
$compile(element.contents())(scope);
|
||||
}
|
||||
|
||||
/**
|
||||
* initVariable
|
||||
*/
|
||||
function initVariable() {
|
||||
scope.ngModel = [];
|
||||
scope.uFile = undefined;
|
||||
scope.uProgress = 0;
|
||||
scope.uResourceImages = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* doUpload
|
||||
* @param sFile
|
||||
*/
|
||||
function doUpload(sFile) {
|
||||
if (!sFile) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (sFile.type !== 'image/png' && sFile.type !== 'image/jpg' && sFile.type !== 'image/jpeg' && sFile.type !== 'image/gif' && sFile.type !== 'image/bmp') {
|
||||
NotifycationService.showErrorNotify($translate.instant('ERROR_ONLY_IMAGE'), 'ERROR');
|
||||
console.error($translate.instant('ERROR_ONLY_IMAGE'));
|
||||
return;
|
||||
}
|
||||
|
||||
if (attrs.uploadMethod) {
|
||||
scope.uFile = sFile;
|
||||
scope.uProgress = 0;
|
||||
|
||||
if (!attrs.uploadDir) {
|
||||
console.error('uploadMethod must has a uploadDir attr!');
|
||||
return;
|
||||
}
|
||||
|
||||
scope.$parent.$eval(attrs.uploadMethod, {
|
||||
ufile: scope.uFile,
|
||||
progressback: function (pr) {
|
||||
scope.uProgress = pr;
|
||||
},
|
||||
callback: function (fn) {
|
||||
var uFile = {
|
||||
name: fn,
|
||||
size: scope.uFile.size
|
||||
};
|
||||
|
||||
scope.ngModel.push(uFile.name);
|
||||
scope.uResourceImages.push(attrs.uploadDir + uFile.name);
|
||||
|
||||
scope.uFile = undefined;
|
||||
scope.uProgress = 0;
|
||||
NotifycationService.showSuccessNotify('UPLOAD_IMAGES_SUCCESSFULLY');
|
||||
},
|
||||
errback: function (err) {
|
||||
scope.uFile = undefined;
|
||||
scope.uProgress = 0;
|
||||
NotifycationService.showErrorNotify(err.data, 'UPLOAD_IMAGES_FAILED');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}());
|
||||
@@ -104,10 +104,10 @@
|
||||
|
||||
//define method called from parent scope
|
||||
//init all variable
|
||||
scope.$parent.clearnAttach = function () {
|
||||
scope.$parent.clearAttach = function () {
|
||||
initVariable();
|
||||
};
|
||||
scope.$parent.$parent.clearnAttach = scope.$parent.clearnAttach;
|
||||
scope.$parent.$parent.clearAttach = scope.$parent.clearAttach;
|
||||
|
||||
//hide preview
|
||||
scope.$parent.hidePreview = function () {
|
||||
|
||||
@@ -592,7 +592,7 @@
|
||||
vm.pageChanged();
|
||||
|
||||
$scope.$broadcast('show-errors-reset', 'vm.replyForm');
|
||||
$scope.clearnAttach();
|
||||
$scope.clearAttach();
|
||||
$scope.hidePreview();
|
||||
NotifycationService.showSuccessNotify('FORUMS.POST_REPLY_SUCCESSFULLY');
|
||||
}
|
||||
|
||||
@@ -157,7 +157,7 @@
|
||||
vm.pageChanged();
|
||||
|
||||
$scope.$broadcast('show-errors-reset', 'vm.replyForm');
|
||||
$scope.clearnAttach();
|
||||
$scope.clearAttach();
|
||||
$scope.hidePreview();
|
||||
NotifycationService.showSuccessNotify('FORUMS.POST_REPLY_SUCCESSFULLY');
|
||||
}
|
||||
|
||||
@@ -47,6 +47,7 @@
|
||||
vm.anonymous = false;
|
||||
vm.videoNfo = '';
|
||||
vm.customTorrent = {};
|
||||
vm.resourceImagesList = [];
|
||||
|
||||
$rootScope.uploadPopupNotShowNextTime = localStorageService.get('upload_popup_not_show_next_time');
|
||||
$rootScope.announceConfig = vm.announceConfig;
|
||||
@@ -196,7 +197,7 @@
|
||||
if (response.data.params) {
|
||||
response.data.message = $translate.instant(response.data.message, response.data.params);
|
||||
}
|
||||
console.log(response.data.message);
|
||||
mtDebug.info(response.data.message);
|
||||
|
||||
NotifycationService.showErrorNotify(response.data.message, 'TORRENTS_UPLOAD_FAILED');
|
||||
}
|
||||
@@ -274,6 +275,34 @@
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* uploadTorrentScreenshotsImage
|
||||
* @param ufile
|
||||
* @param progressback
|
||||
* @param callback
|
||||
* @param errback
|
||||
*/
|
||||
vm.uploadTorrentScreenshotsImage = function (ufile, progressback, callback, errback) {
|
||||
Upload.upload({
|
||||
url: '/api/torrents/uploadTorrentImage',
|
||||
data: {
|
||||
newTorrentImageFile: ufile
|
||||
}
|
||||
}).then(function (res) {
|
||||
if (callback) {
|
||||
callback(res.data.filename);
|
||||
}
|
||||
}, function (res) {
|
||||
if (errback && res.status > 0) {
|
||||
errback(res);
|
||||
}
|
||||
}, function (evt) {
|
||||
if (progressback) {
|
||||
progressback(parseInt(100.0 * evt.loaded / evt.total, 10));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* onTMDBIDKeyDown
|
||||
* @param evt
|
||||
@@ -323,6 +352,7 @@
|
||||
vm.inputedEpisodesError = undefined;
|
||||
vm.inputedEpisodesOK = false;
|
||||
vm.showResourceTitleInput = false;
|
||||
vm.showResourceScreenShots = false;
|
||||
vm.showResourcesTag = false;
|
||||
|
||||
vm.movieinfo = undefined;
|
||||
@@ -455,6 +485,7 @@
|
||||
vm.tmdb_info_ok = true;
|
||||
vm.tmdb_isloading = false;
|
||||
vm.showResourceTitleInput = true;
|
||||
vm.showResourceScreenShots = true;
|
||||
vm.showResourcesTag = true;
|
||||
vm.showVideoNfo = true;
|
||||
vm.showAgreeAndSubmit = true;
|
||||
@@ -533,6 +564,7 @@
|
||||
} else {
|
||||
vm.inputedEpisodesError = false;
|
||||
vm.inputedEpisodesOK = true;
|
||||
vm.showResourceScreenShots = true;
|
||||
vm.showResourcesTag = true;
|
||||
vm.showResourceTitleInput = true;
|
||||
vm.showVideoNfo = true;
|
||||
@@ -583,7 +615,8 @@
|
||||
isAnonymous: vm.anonymous,
|
||||
reqId: $state.params.reqId || undefined,
|
||||
|
||||
resource_detail_info: vm.movieinfo
|
||||
resource_detail_info: vm.movieinfo,
|
||||
screenshots_image: vm.resourceImagesList
|
||||
});
|
||||
|
||||
torrent.$save(function (response) {
|
||||
@@ -593,6 +626,7 @@
|
||||
});
|
||||
|
||||
function successCallback(res) {
|
||||
mtDebug.info(res);
|
||||
vm.isCreating = false;
|
||||
vm.showUploadedPopup(res);
|
||||
}
|
||||
@@ -631,7 +665,8 @@
|
||||
isAnonymous: vm.anonymous,
|
||||
reqId: $state.params.reqId || undefined,
|
||||
|
||||
resource_detail_info: vm.tvinfo
|
||||
resource_detail_info: vm.tvinfo,
|
||||
screenshots_image: vm.resourceImagesList
|
||||
});
|
||||
|
||||
torrent.$save(function (response) {
|
||||
@@ -641,6 +676,7 @@
|
||||
});
|
||||
|
||||
function successCallback(res) {
|
||||
mtDebug.info(res);
|
||||
vm.isCreating = false;
|
||||
vm.showUploadedPopup(res);
|
||||
}
|
||||
|
||||
@@ -121,6 +121,93 @@
|
||||
}
|
||||
}
|
||||
|
||||
.resourceScreenshots {
|
||||
.upload-image-info {
|
||||
color: #666;
|
||||
height: 40px;
|
||||
background-color: #f5f5f5;
|
||||
border-top: 1px dashed #ddd;
|
||||
.upload-tooltip {
|
||||
margin: 8px;
|
||||
.manual-file-chooser {
|
||||
position: absolute;
|
||||
width: 200px;
|
||||
padding: 5px;
|
||||
margin-left: 150px;
|
||||
margin-top: -23px;
|
||||
cursor: pointer;
|
||||
opacity: 0.00001;
|
||||
}
|
||||
.manual-file-chooser-text {
|
||||
cursor: pointer;
|
||||
&:hover {
|
||||
color: @mt-base-color;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
.upload-image-list {
|
||||
color: #666;
|
||||
background-color: #f5f5f5;
|
||||
border-top: 1px dashed #ddd;
|
||||
overflow-x: scroll;
|
||||
.image-item {
|
||||
position: relative;
|
||||
display: table-cell;
|
||||
&:last-child {
|
||||
padding-right: 5px !important;
|
||||
.fa {
|
||||
right: 10px;
|
||||
}
|
||||
}
|
||||
img {
|
||||
height: 150px;
|
||||
width: auto;
|
||||
margin-top: 5px;
|
||||
margin-bottom: 5px;
|
||||
margin-left: 5px;
|
||||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
.fa {
|
||||
cursor: pointer;
|
||||
position: absolute;
|
||||
right: 5px;
|
||||
top: 5px;
|
||||
text-shadow: 0 0 0.1em #fff,-0 -0 0.1em #fff;
|
||||
&:hover {
|
||||
color: @mt-base-color;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.upload-info {
|
||||
position: relative;
|
||||
color: #666;
|
||||
height: 40px;
|
||||
background-color: #f5f5f5;
|
||||
border-top: 1px dashed #ddd;
|
||||
i {
|
||||
color: @mt-base-color;
|
||||
float: left;
|
||||
margin: 11px 5px;
|
||||
}
|
||||
.upload-progress {
|
||||
height: 30px;
|
||||
margin: 4px 30px;
|
||||
max-width: ~"calc(100% - 40px)";
|
||||
background-color: @brand-info;
|
||||
}
|
||||
.upload-filename {
|
||||
position: absolute;
|
||||
top: 8px;
|
||||
margin-left: 35px;
|
||||
background-color: transparent;
|
||||
}
|
||||
}
|
||||
|
||||
/* csslint ignore:start */
|
||||
.film-strip {
|
||||
border-top: solid 26px;
|
||||
@@ -353,6 +440,7 @@ pre.prettyprint {
|
||||
word-break: break-all;
|
||||
}
|
||||
}
|
||||
|
||||
/* csslint ignore:end */
|
||||
|
||||
//popup overlay----------------------------------------------
|
||||
|
||||
@@ -309,7 +309,17 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row margin-bottom-30" ng-show="vm.showResourcesTag">
|
||||
<div class="row margin-bottom-40" ng-show="vm.showResourceScreenShots">
|
||||
<div class="col-md-12 col-sm-12 col-xs-12">
|
||||
<legend class="small-legend" translate="SELECT_SCREEN_SHOTS"></legend>
|
||||
<div class="resourceScreenshots" id="resourceScreenshots" name="resourceScreenshots"
|
||||
mt-images-uploader="resourceScreenshots" ng-model="vm.resourceImagesList"
|
||||
upload-dir="/modules/torrents/client/uploads/temp/"
|
||||
upload-method="vm.uploadTorrentScreenshotsImage(ufile, progressback, callback, errback);"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row margin-bottom-40" ng-show="vm.showResourcesTag">
|
||||
<div class="col-md-12 col-sm-12 col-xs-12">
|
||||
<legend class="small-legend" translate="SELECT_TAGS"></legend>
|
||||
<div ng-if="vm.getTagsFilterCount()<=0">
|
||||
@@ -533,7 +543,17 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row margin-bottom-30" ng-show="vm.showResourcesTag">
|
||||
<div class="row margin-bottom-40" ng-show="vm.showResourceScreenShots">
|
||||
<div class="col-md-12 col-sm-12 col-xs-12">
|
||||
<legend class="small-legend" translate="SELECT_SCREEN_SHOTS"></legend>
|
||||
<div class="resourceScreenshots" id="resourceScreenshots" name="resourceScreenshots"
|
||||
mt-images-uploader="resourceScreenshots" ng-model="vm.resourceImagesList"
|
||||
upload-dir="/modules/torrents/client/uploads/temp/"
|
||||
upload-method="vm.uploadTorrentScreenshotsImage(ufile, progressback, callback, errback);"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row margin-bottom-40" ng-show="vm.showResourcesTag">
|
||||
<div class="col-md-12 col-sm-12 col-xs-12">
|
||||
<legend class="small-legend" translate="SELECT_TAGS"></legend>
|
||||
<div ng-if="vm.getTagsFilterCount()<=0">
|
||||
@@ -655,7 +675,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row margin-bottom-30" ng-show="vm.customTorrent.detail">
|
||||
<div class="row margin-bottom-40" ng-show="vm.customTorrent.detail">
|
||||
<div class="col-md-12 col-sm-12 col-xs-12">
|
||||
<legend class="small-legend" translate="SELECT_TAGS"></legend>
|
||||
<div ng-if="vm.getTagsFilterCount()<=0">
|
||||
@@ -763,8 +783,8 @@
|
||||
<div class="col-md-12 col-sm-12 col-xs-12">
|
||||
<legend class="small-legend" translate="ENTER_RESOURCE_DETAIL_INFO"></legend>
|
||||
<div class="col-xs-12">
|
||||
<textarea id="sportsDetail" name="sportsDetail" ng-model="vm.customTorrent.detail"
|
||||
mt-markdown-editor="sportsDetail"
|
||||
<textarea id="defaultDetail" name="defaultDetail" ng-model="vm.customTorrent.detail"
|
||||
mt-markdown-editor="defaultDetail"
|
||||
upload-dir="/modules/torrents/client/uploads/temp/"
|
||||
upload-only-image="true"
|
||||
upload-method="vm.uploadTorrentImage(editor, ufile, progressback, callback, errback);"></textarea>
|
||||
@@ -773,7 +793,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row margin-bottom-30" ng-show="vm.customTorrent.detail">
|
||||
<div class="row margin-bottom-40" ng-show="vm.customTorrent.detail">
|
||||
<div class="col-md-12 col-sm-12 col-xs-12">
|
||||
<legend class="small-legend" translate="SELECT_TAGS"></legend>
|
||||
<div ng-if="vm.getTagsFilterCount()<=0">
|
||||
|
||||
@@ -374,7 +374,7 @@ exports.uploadTorrentImage = function (req, res) {
|
||||
var upload = multer({
|
||||
storage: storage,
|
||||
fileFilter: fileFilter,
|
||||
limits: config.uploads.torrent.cover.limits
|
||||
limits: config.uploads.torrent.image.limits
|
||||
}).single('newTorrentImageFile');
|
||||
|
||||
if (user) {
|
||||
@@ -684,8 +684,10 @@ exports.create = function (req, res) {
|
||||
fs.unlinkSync(oc);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//move temp torrent image file to dest directory
|
||||
//move temp torrent image file to dest directory
|
||||
if (req.body._uImage && req.body._uImage.length > 0) {
|
||||
req.body._uImage.forEach(function (f) {
|
||||
var oi = config.uploads.torrent.image.temp + f;
|
||||
var ni = config.uploads.torrent.image.dest + f;
|
||||
@@ -707,6 +709,31 @@ exports.create = function (req, res) {
|
||||
});
|
||||
}
|
||||
|
||||
//move temp torrent resource screenshots image file to dest directory
|
||||
if (req.body.screenshots_image && req.body.screenshots_image.length > 0) {
|
||||
req.body.screenshots_image.forEach(function (f, key) {
|
||||
var os = config.uploads.torrent.image.temp + f;
|
||||
var ns = config.uploads.torrent.image.dest + f;
|
||||
var cs = config.uploads.torrent.image.crop + f;
|
||||
|
||||
torrent.screenshots_image[key] = dst + f;
|
||||
|
||||
move(os, ns, function (err) {
|
||||
if (err) {
|
||||
mtDebug.debugRed(err);
|
||||
} else {
|
||||
sharp(ns)
|
||||
.resize(200)
|
||||
.toFile(cs, function (err) {
|
||||
if (err) {
|
||||
mtDebug.debugError(err);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
torrent.save(function (err) {
|
||||
if (err) {
|
||||
return res.status(422).send({
|
||||
|
||||
@@ -141,6 +141,8 @@ var TorrentSchema = new Schema({
|
||||
_ratings: [CommonSchema.RatingSchema],
|
||||
_other_torrents: [],
|
||||
_all_files: [],
|
||||
|
||||
screenshots_image: [String],
|
||||
//resource info
|
||||
resource_detail_info: Object,
|
||||
|
||||
|
||||
Reference in New Issue
Block a user