feat(torrents): show topOne music info at home page

This commit is contained in:
OldHawk
2017-10-03 00:24:49 +08:00
parent 767cb7ae15
commit 598987d2d7
15 changed files with 159 additions and 29 deletions

View File

@@ -6,10 +6,12 @@
.controller('HomeController', HomeController);
HomeController.$inject = ['$scope', '$state', '$translate', 'Authentication', 'TorrentsService', 'Notification', 'MeanTorrentConfig',
'getStorageLangService', 'DownloadService', '$timeout', 'localStorageService', 'ScrapeService', 'TorrentGetInfoServices'];
'getStorageLangService', 'DownloadService', '$timeout', 'localStorageService', 'ScrapeService', 'TorrentGetInfoServices', 'DebugConsoleService',
'marked'];
function HomeController($scope, $state, $translate, Authentication, TorrentsService, Notification, MeanTorrentConfig, getStorageLangService,
DownloadService, $timeout, localStorageService, ScrapeService, TGI) {
DownloadService, $timeout, localStorageService, ScrapeService, TGI, mtDebug,
marked) {
var vm = this;
vm.TGI = TGI;
vm.tmdbConfig = MeanTorrentConfig.meanTorrentConfig.tmdbConfig;
@@ -64,6 +66,15 @@
}
};
/**
* initTopOneMusicInfo
*/
vm.initTopOneMusicInfo = function () {
if (vm.musicTopOne.resource_detail_info.cover) {
$('.music-backdrop').css('backgroundImage', 'url(/modules/torrents/client/uploads/cover/' + vm.musicTopOne.resource_detail_info.cover + ')');
}
};
/**
* getTorrentTypeEnabled
*/
@@ -166,7 +177,7 @@
}
});
vm.moviesInfo = TorrentsService.get({
vm.tvsInfo = TorrentsService.get({
torrent_status: 'reviewed',
torrent_type: 'tvserial',
newest: true,
@@ -182,6 +193,47 @@
});
};
/**
* getMusicTopInfo
*/
vm.getMusicTopInfo = function () {
vm.musicInfo = TorrentsService.get({
torrent_status: 'reviewed',
torrent_type: 'music',
limit: 9
}, function (items) {
if (items.rows.length > 0) {
mtDebug.info(items);
vm.musicTopOne = items.rows[0];
items.rows.splice(0, 1);
vm.musicTopList = items.rows;
vm.initTopOneMusicInfo();
if (!vm.announce.privateTorrentCmsMode && vm.scrapeConfig.onTorrentInHome) {
ScrapeService.scrapeTorrent(vm.musicTopOne);
ScrapeService.scrapeTorrent(vm.musicTopList);
}
}
});
vm.musicInfo = TorrentsService.get({
torrent_status: 'reviewed',
torrent_type: 'music',
newest: true,
limit: 14
}, function (items) {
if (items.rows.length > 0) {
vm.musicNewList = items.rows;
if (!vm.announce.privateTorrentCmsMode && vm.scrapeConfig.onTorrentInHome) {
ScrapeService.scrapeTorrent(vm.musicNewList);
}
}
});
};
/**
* openTorrentInfo
* @param id
@@ -210,5 +262,18 @@
});
});
};
/**
* getOverviewMarkedContent
* @param t
* @returns {*}
*/
vm.getOverviewMarkedContent = function (c) {
if (c) {
return marked(c, {sanitize: true});
} else {
return '';
}
};
}
}());

View File

@@ -63,8 +63,8 @@ body {
color: #fff;
opacity: 0.15;
position: absolute;
right: 10px;
top: -20px;
right: 20px;
top: -10px;
font-size: 100px;
font-weight: bold;
}
@@ -141,7 +141,7 @@ body {
}
}
}
.music-overview {
.music-detail {
p {
> img {
max-width: 100% !important;
@@ -150,6 +150,20 @@ body {
}
}
}
.music-overview {
max-height: 400px;
overflow: auto;
padding-right: 5px;
&::-webkit-scrollbar {
width: 5px;
}
&::-webkit-scrollbar-track {
background-color: #000;
}
&::-webkit-scrollbar-thumb {
background-color: #555;
}
}
}
}

View File

@@ -423,6 +423,57 @@
</div>
</div>
<div ng-if="vm.getTorrentTypeEnabled('music')" ng-init="vm.getMusicTopInfo();">
<div class="backdrop music-backdrop" ng-show="vm.musicTopOne">
<div class="filter">
<div class="type-flag">{{'MENU_TORRENTS_SUB.MUSIC' | translate}}</div>
<div class="container">
<div class="topone">
<div class="col-md-3">
<img class="img-thumbnail center-block" music-disk="vm.musicTopOne.torrent_type=='music'"
ng-src="{{vm.TGI.getTorrentTopOneImage(vm.musicTopOne)}}"
alt="{{vm.TGI.getTorrentTitle(vm.musicTopOne)}}" onload="this.style.opacity='1';"
ng-click="vm.openTorrentInfo(vm.TVTopOne._id);">
<div class="down-torrent">
<button class="btn btn-success btn-block" ng-click="vm.downloadTorrent(vm.musicTopOne._id)"
translate="DOWNLOAD_TORRENT"></button>
</div>
</div>
<div class="col-md-9">
<dl class="dl-horizontal">
<dt class="h-line">{{ 'TMDB_FIELDS.TITLE' | translate}}</dt>
<dd class="h-line">{{vm.TGI.getTorrentTitle(vm.musicTopOne)}}</dd>
<dt class="h-line">{{ 'TMDB_FIELDS.SUB_TITLE' | translate}}</dt>
<dd class="h-line">{{vm.musicTopOne.resource_detail_info.subtitle}}</dd>
<dt class="h-line">{{ 'TMDB_FIELDS.ARTIST' | translate}}</dt>
<dd class="h-line">{{vm.musicTopOne.resource_detail_info.artist}}</dd>
<dt class="h-line">{{ 'TMDB_FIELDS.VOTE_AVERAGE' | translate}}</dt>
<dd class="h-line">
<span ng-show="vm.musicTopOne">
<span class="torrent-votes">
<kbd>{{vm.TGI.getVoteTitle(vm.musicTopOne)}}</kbd>
</span> {{vm.musicTopOne.resource_detail_info.vote_average}} / {{vm.musicTopOne.resource_detail_info.vote_count}} {{ 'TMDB_FIELDS.VOTE_UNIT' | translate}}
</span>
</dd>
<dt class="h-line">{{ 'TMDB_FIELDS.OVERVIEW' | translate}}</dt>
<dd class="h-line">
<div class="music-overview" id="overview_markdown" data-provide="markdown"
ng-bind-html="vm.getOverviewMarkedContent(vm.TGI.getTorrentOverview(vm.musicTopOne))">
</div>
</dd>
</dl>
</div>
</div>
</div>
</div>
</div>
</div>
<div id="warning_popup" style="display: none;">
<div class="row padding-top-50 padding-bottom-30">
<div class="col-xs-10 col-xs-offset-1 col-sm-8 col-sm-offset-2">

View File

@@ -37,7 +37,7 @@
function getTorrentTitle(item) {
var result = null;
if (item.resource_detail_info) {
if (item && item.resource_detail_info) {
switch (item.torrent_type) {
case 'movie':
result = item.resource_detail_info.original_title;
@@ -61,7 +61,7 @@
function getTorrentOriginalTitle(item) {
var result = null;
if (item.resource_detail_info) {
if (item && item.resource_detail_info) {
switch (item.torrent_type) {
case 'movie':
if (item.resource_detail_info.original_title !== item.resource_detail_info.title) {
@@ -86,7 +86,7 @@
function getTorrentListImage(item) {
var result = null;
if (item.resource_detail_info) {
if (item && item.resource_detail_info) {
switch (item.torrent_type) {
case 'movie':
case 'tvserial':
@@ -108,7 +108,7 @@
function getTorrentListTopImage(item) {
var result = null;
if (item.resource_detail_info) {
if (item && item.resource_detail_info) {
switch (item.torrent_type) {
case 'movie':
case 'tvserial':
@@ -130,7 +130,7 @@
function getTorrentTopOneImage(item) {
var result = null;
if (item.resource_detail_info) {
if (item && item.resource_detail_info) {
switch (item.torrent_type) {
case 'movie':
case 'tvserial':
@@ -152,7 +152,7 @@
function getTorrentBackdropImage(item) {
var result = null;
if (item.resource_detail_info) {
if (item && item.resource_detail_info) {
switch (item.torrent_type) {
case 'movie':
case 'tvserial':
@@ -172,7 +172,7 @@
* @returns {string}
*/
function getVoteTitle(item) {
if (item.resource_detail_info) {
if (item && item.resource_detail_info) {
return item.resource_detail_info.vote_average ? voteTitleConfig.imdb : voteTitleConfig.mt;
} else {
return null;
@@ -187,7 +187,7 @@
function getMovieDirector(item) {
var result = null;
if (item.resource_detail_info && item.resource_detail_info.credits) {
if (item && item.resource_detail_info && item.resource_detail_info.credits) {
angular.forEach(item.resource_detail_info.credits.crew, function (sitem) {
if (sitem.job === 'Director') {
result = sitem.name;
@@ -205,7 +205,7 @@
function getTorrentLanguage(item) {
var result = null;
if (item.resource_detail_info) {
if (item && item.resource_detail_info) {
result = item.resource_detail_info.original_language;
}
return result;
@@ -219,7 +219,7 @@
function getTorrentOverview(item) {
var result = null;
if (item.resource_detail_info) {
if (item && item.resource_detail_info) {
result = item.resource_detail_info.overview || item.resource_detail_info.detail || null;
}
return result;

View File

@@ -159,7 +159,7 @@
<td class="col-md-7 td-text-overflow-admin">
<div class="media">
<div class="media-left">
<img class="media-object" ng-class="{'music': vm.selectedType=='music'}" music-disk="{{vm.selectedType=='music'}}"
<img class="media-object" music-disk="{{vm.selectedType=='music'}}"
ng-src="{{vm.TGI.getTorrentListImage(item)}}"
alt="...">

View File

@@ -6,7 +6,7 @@
<div data-ng-if="$index != 0 && $index % 6 == 0" class="clearfix visible-md-block visible-lg-block"></div>
<div class="col-xs-6 col-sm-4 col-md-2 col-small-padding">
<div class="thumbnail torrent-post-info" ng-click="vm.openTorrentInfo(item._id);">
<img class="img-responsive" ng-class="{'music': item.torrent_type=='music'}" music-disk="item.torrent_type=='music'"
<img class="img-responsive" music-disk="item.torrent_type=='music'"
ng-src="{{vm.TGI.getTorrentListTopImage(item)}}"
alt="{{vm.TGI.getTorrentTitle(item)}}">
@@ -155,7 +155,7 @@
<td class="col-md-7 td-text-overflow">
<div class="media">
<div class="media-left">
<img class="media-object" ng-class="{'music': item.torrent_type=='music'}" music-disk="item.torrent_type=='music'"
<img class="media-object" music-disk="item.torrent_type=='music'"
ng-src="{{vm.TGI.getTorrentListImage(item)}}"
alt="...">

View File

@@ -4,7 +4,7 @@
<div class="container">
<div class="topone">
<div class="col-md-3 text-center">
<img class="img-thumbnail center-block" ng-class="{'music': vm.torrentLocalInfo.torrent_type=='music'}" music-disk="vm.torrentLocalInfo.torrent_type=='music'"
<img class="img-thumbnail center-block" music-disk="vm.torrentLocalInfo.torrent_type=='music'"
ng-src="{{vm.TGI.getTorrentTopOneImage(vm.torrentLocalInfo)}}"
alt="{{vm.TGI.getTorrentTitle(vm.torrentLocalInfo)}}" onload="this.style.opacity='1';">
@@ -13,7 +13,7 @@
translate="DOWNLOAD_TORRENT"></button>
</div>
</div>
<div class="col-md-9" ng-class="{'music-overview': vm.torrentLocalInfo.torrent_type=='music'}">
<div class="col-md-9" ng-class="{'music-detail': vm.torrentLocalInfo.torrent_type=='music'}">
<dl class="dl-horizontal">
<div ng-if="vm.TGI.getTorrentTitle(vm.torrentLocalInfo)">
<dt class="h-line">{{ 'TMDB_FIELDS.TITLE' | translate}}</dt>

View File

@@ -34,7 +34,7 @@
<td class="col-md-7 td-text-overflow">
<div class="media">
<div class="media-left">
<img class="media-object" ng-class="{'music': item.torrent.torrent_type=='music'}" music-disk="{{item.torrent.torrent_type=='music'}}"
<img class="media-object" music-disk="{{item.torrent.torrent_type=='music'}}"
ng-src="{{vm.TGI.getTorrentListImage(item.torrent)}}"
alt="...">

View File

@@ -33,7 +33,7 @@
<td class="col-md-7 td-text-overflow">
<div class="media">
<div class="media-left">
<img class="media-object" ng-class="{'music': item.torrent.torrent_type=='music'}" music-disk="{{item.torrent.torrent_type=='music'}}"
<img class="media-object" music-disk="{{item.torrent.torrent_type=='music'}}"
ng-src="{{vm.TGI.getTorrentListImage(item.torrent)}}"
alt="...">

View File

@@ -29,7 +29,7 @@
<td class="col-md-7 td-text-overflow">
<div class="media">
<div class="media-left">
<img class="media-object" ng-class="{'music': item.torrent_type=='music'}" music-disk="{{item.torrent_type=='music'}}"
<img class="media-object" music-disk="{{item.torrent_type=='music'}}"
ng-src="{{vm.TGI.getTorrentListImage(item)}}"
alt="...">

View File

@@ -31,7 +31,7 @@
<td class="col-md-7 td-text-overflow">
<div class="media">
<div class="media-left">
<img class="media-object" ng-class="{'music': item.torrent.torrent_type=='music'}" music-disk="{{item.torrent.torrent_type=='music'}}"
<img class="media-object" music-disk="{{item.torrent.torrent_type=='music'}}"
ng-src="{{vm.TGI.getTorrentListImage(item.torrent)}}"
alt="...">

View File

@@ -49,7 +49,7 @@
<td class="col-md-7 td-text-overflow">
<div class="media">
<div class="media-left">
<img class="media-object" ng-class="{'music': item.torrent.torrent_type=='music'}" music-disk="{{item.torrent.torrent_type=='music'}}"
<img class="media-object" music-disk="{{item.torrent.torrent_type=='music'}}"
ng-src="{{vm.TGI.getTorrentListImage(item.torrent)}}"
alt="...">

View File

@@ -49,7 +49,7 @@
<td class="col-md-7 td-text-overflow">
<div class="media">
<div class="media-left">
<img class="media-object" ng-class="{'music': item.torrent.torrent_type=='music'}" music-disk="{{item.torrent.torrent_type=='music'}}"
<img class="media-object" music-disk="{{item.torrent.torrent_type=='music'}}"
ng-src="{{vm.TGI.getTorrentListImage(item.torrent)}}"
alt="...">

View File

@@ -46,7 +46,7 @@
<td class="col-md-7 td-text-overflow">
<div class="media">
<div class="media-left">
<img class="media-object" ng-class="{'music': item.torrent_type=='music'}" music-disk="{{item.torrent_type=='music'}}"
<img class="media-object" music-disk="{{item.torrent_type=='music'}}"
ng-src="{{vm.TGI.getTorrentListImage(item)}}"
alt="...">

View File

@@ -41,7 +41,7 @@
<td class="col-md-7 td-text-overflow">
<div class="media">
<div class="media-left">
<img class="media-object" ng-class="{'music': item.torrent.torrent_type=='music'}" music-disk="{{item.torrent.torrent_type=='music'}}"
<img class="media-object" music-disk="{{item.torrent.torrent_type=='music'}}"
ng-src="{{vm.TGI.getTorrentListImage(item.torrent)}}"
alt="...">