From 31bc97cf116436e0474d1e054ec097b1fa9445b9 Mon Sep 17 00:00:00 2001 From: HDVinnie Date: Mon, 9 Jul 2018 09:43:14 -0400 Subject: [PATCH] (Update) Initial Changes - vue component smallbookmark needs work still - Poster and IMDB ratings/votes are commented out and will remain so until meta system is refactored. --- app/Helpers/TorrentHelper.php | 224 ------------- app/Http/Controllers/TorrentController.php | 78 ++--- resources/assets/js/app.js | 1 + .../js/components/SmallBookmarkButton.vue | 67 ++++ resources/views/torrent/results.blade.php | 302 ++++++++++++++++++ resources/views/torrent/torrents.blade.php | 297 ++++++++--------- 6 files changed, 536 insertions(+), 433 deletions(-) create mode 100644 resources/assets/js/components/SmallBookmarkButton.vue create mode 100644 resources/views/torrent/results.blade.php diff --git a/app/Helpers/TorrentHelper.php b/app/Helpers/TorrentHelper.php index 625d3ea071..a25eb34aad 100644 --- a/app/Helpers/TorrentHelper.php +++ b/app/Helpers/TorrentHelper.php @@ -12,9 +12,6 @@ namespace App\Helpers; -use App\PersonalFreeleech; -use App\FreeleechToken; -use App\History; use App\Torrent; use App\Message; use App\PrivateMessage; @@ -32,230 +29,9 @@ use App\Achievements\UserMade800Uploads; use App\Achievements\UserMade900Uploads; use App\Bots\IRCAnnounceBot; -use App\Services\MovieScrapper; class TorrentHelper { - public static function view($results) - { - $user = auth()->user(); - $personal_freeleech = PersonalFreeleech::where('user_id', '=', $user->id)->first(); - - $data = []; - - foreach ($results as $list) { - if ($list->sticky == 1) { - $sticky = ""; - } else { - $sticky = ""; - } - - $client = new MovieScrapper(config('api-keys.tmdb'), config('api-keys.tvdb'), config('api-keys.omdb')); - if ($list->category_id == 2) { - if ($list->tmdb || $list->tmdb != 0) { - $movie = $client->scrape('tv', null, $list->tmdb); - } else { - $movie = $client->scrape('tv', 'tt'. $list->imdb); - } - } else { - if ($list->tmdb || $list->tmdb != 0) { - $movie = $client->scrape('movie', null, $list->tmdb); - } else { - $movie = $client->scrape('movie', 'tt'. $list->imdb); - } - } - - if ($user->show_poster == 1 && $list->category->meta == 1) { - $poster = "
Poster
"; - } else { - $poster = ""; - } - - $category_link = route('category', ['slug' => $list->category->slug, 'id' => $list->category->id]); - - $category = ""; - - $torrent_link = route('torrent', ['slug' => $list->slug, 'id' => $list->id]); - $download_check_link = route('download_check', ['slug' => $list->slug, 'id' => $list->id]); - $user_link = route('profile', ['username' => $list->user->username, 'id' => $list->user->id]); - $peers_link = route('peers', ['slug' => $list->slug, 'id' => $list->id]); - $history_link = route('history', ['slug' => $list->slug, 'id' => $list->id]); - - $unbookmark_link = route('unbookmark', ['id' => $list->id]); - $bookmark_link = route('bookmark', ['id' => $list->id]); - if ($user->isBookmarked($list->id)) { - $bookmark = ""; - } else { - $bookmark = ""; - } - - if ($list->anon == 1) { - if ($user->id == $list->user->id || $user->group->is_modo) { - $staff_anon = "({$list->user->username})"; - } else { - $staff_anon = ""; - } - - $anon = "ANONYMOUS {$staff_anon}"; - } else { - $anon = "{$list->user->username}"; - } - - if ($list->category->meta == 1) { - if ($user->ratings == 1) { - $link = "https://anon.to?http://www.imdb.com/title/tt" . $list->imdb; - $rating = $movie->imdbRating; - $votes = $movie->imdbVotes; - } else { - $rating = $movie->tmdbRating; - $votes = $movie->tmdbVotes; - if ($list->category_id == '2') { - $link = "https://www.themoviedb.org/tv/" . $movie->tmdb; - } else { - $link = "https://www.themoviedb.org/movie/" . $movie->tmdb; - } - } - } else { - $link = "#"; - $rating = "0"; - $votes = "0"; - } - - $thank_count = $list->thanks()->count(); - - $icons = ""; - - if ($list->stream == "1") { - $icons .= " Stream Optimized"; - } - - if ($list->featured == "0") { - if ($list->doubleup == "1") { - $icons .= " Double Upload"; - } - - if ($list->free == "1") { - $icons .= " 100% Free"; - } - } - - if ($personal_freeleech) { - $icons .= " Personal FL"; - } - - $freeleech_token = FreeleechToken::where('user_id', '=', $user->id)->where('torrent_id', '=', $list->id)->first(); - if ($freeleech_token) { - $icons .= " Freeleech Token"; - } - - if ($list->featured == "1") { - $icons .= " Featured"; - } - - if ($user->group->is_freeleech == 1) { - $icons .= " Special FL"; - } - - if (config('other.freeleech') == true) { - $icons .= " Global FreeLeech"; - } - - if (config('other.doubleup') == true) { - $icons .= " Global Double Upload"; - } - - if ($list->leechers >= "5") { - $icons .= " Hot"; - } - - if ($list->sticky == 1) { - $icons .= " Sticky"; - } - - if ($user->updated_at->getTimestamp() < $list->created_at->getTimestamp()) { - $icons .= " NEW"; - } - - if ($list->highspeed == 1) { - $icons .= " High Speeds"; - } - - if ($list->sd == 1) { - $icons .= " SD Content"; - } - - $status = ""; - - $history = History::where('user_id', '=', $user->id)->where('info_hash', '=', $list->info_hash)->first(); - - if ($history) { - if ($history->seeder == 1 && $history->active == 1) { - $status .= ""; - } - if ($history->seeder == 0 && $history->active == 1) { - $status .= ""; - } - if ($history->seeder == 0 && $history->active == 0 && $history->completed_at == null) { - $status .= ""; - } - if ($history->seeder == 0 && $history->active == 0 && $history->completed_at != null) { - $status .= ""; - } - } - - $datetime = date('Y-m-d H:m:s', strtotime($list->created_at)); - $datetime_inner = $list->created_at->diffForHumans(); - - $common_times = trans('common.times'); - - - $data[] = $sticky . - "" . $poster . " - -
- {$category} -
-
- {$list->type} -
- - - {$list->name} - - {$bookmark} - {$status} -
- - - By {$anon} - - - - - - - - {$rating}/10 ({$votes} votes) - - - - {$thank_count} - - {$icons} - - - - - " . $list->getSize() . " - {$list->times_completed} {$common_times} - {$list->seeders} - {$list->leechers} - - "; - } - return $data; - } - public static function approveHelper($slug, $id) { $appurl = config('app.url'); diff --git a/app/Http/Controllers/TorrentController.php b/app/Http/Controllers/TorrentController.php index f0b1c13d0a..d5be9814a8 100755 --- a/app/Http/Controllers/TorrentController.php +++ b/app/Http/Controllers/TorrentController.php @@ -67,17 +67,15 @@ public function __construct(TorrentFacetedRepository $faceted, ChatRepository $c public function torrents() { $user = auth()->user(); - $torrents = Torrent::query(); - $alive = Torrent::where('seeders', '>=', 1)->count(); - $dead = Torrent::where('seeders', 0)->count(); + $personal_freeleech = PersonalFreeleech::where('user_id', '=', $user->id)->first(); + $torrents = Torrent::query()->paginate(25); $repository = $this->faceted; return view('torrent.torrents', [ + 'personal_freeleech' => $personal_freeleech, 'repository' => $repository, 'torrents' => $torrents, - 'user' => $user, - 'alive' => $alive, - 'dead' => $dead + 'user' => $user ]); } @@ -162,7 +160,9 @@ public function groupingResults($category_id, $imdb) public function faceted(Request $request, Torrent $torrent) { $user = auth()->user(); + $personal_freeleech = PersonalFreeleech::where('user_id', '=', $user->id)->first(); $search = $request->input('search'); + $description = $request->input('description'); $uploader = $request->input('uploader'); $imdb = $request->input('imdb'); $tvdb = $request->input('tvdb'); @@ -192,10 +192,24 @@ public function faceted(Request $request, Torrent $torrent) $uploader .= '%' . $username . '%'; } + $keywords = explode(' ', $description); + $description = ''; + foreach ($keywords as $keyword) { + $description .= '%' . $keyword . '%'; + } + $torrent = $torrent->newQuery(); - if ($request->has('search') && $request->input('search') != null) { - $torrent->where('name', 'like', $search); + if($request->has('search')){ + $torrent->where(function($query) use($search){ + $query->where('name','like', $search); + }); + } + + if($request->has('description')){ + $torrent->where(function($query) use($description){ + $query->where('description','like', $description)->orWhere('mediainfo','like', $description); + }); } if ($request->has('uploader') && $request->input('uploader') != null) { @@ -266,46 +280,24 @@ public function faceted(Request $request, Torrent $torrent) $torrent->where('seeders', $dead); } - // pagination query starts - $rows = $torrent->count(); - - if ($request->has('page')) { - $page = $request->input('page'); - $qty = $request->input('qty'); - $torrent->skip(($page - 1) * $qty); - $active = $page; - } else { - $active = 1; - } - - if ($request->has('qty')) { - $qty = $request->input('qty'); - $torrent->take($qty); - } else { - $qty = 25; - $torrent->take($qty); - } - // pagination query ends - if ($request->has('sorting') && $request->input('sorting') != null) { $sorting = $request->input('sorting'); $order = $request->input('direction'); $torrent->orderBy($sorting, $order); } - $listings = $torrent->get(); - $count = $torrent->count(); - - $helper = new TorrentHelper(); - $result = $helper->view($listings); + if($request->has('qty')){ + $qty = $request->input('qty'); + $torrents = $torrent->paginate($qty); + }else{ + $torrents = $torrent->paginate(25); + } - return [ - 'result' => $result, - 'rows' => $rows, - 'qty' => $qty, - 'active' => $active, - 'count' => $count - ]; + return view('torrent.results', [ + 'torrents' => $torrents, + 'user' => $user, + 'personal_freeleech' => $personal_freeleech + ])->render(); } /** @@ -356,13 +348,13 @@ public function torrent($slug, $id) $client = new \App\Services\MovieScrapper(config('api-keys.tmdb'), config('api-keys.tvdb'), config('api-keys.omdb')); if ($torrent->category_id == 2) { - if ($torrent->tmdb || $torrent->tmdb != 0) { + if ($torrent->tmdb && $torrent->tmdb != 0) { $movie = $client->scrape('tv', null, $torrent->tmdb); } else { $movie = $client->scrape('tv', 'tt' . $torrent->imdb); } } else { - if ($torrent->tmdb || $torrent->tmdb != 0) { + if ($torrent->tmdb && $torrent->tmdb != 0) { $movie = $client->scrape('movie', null, $torrent->tmdb); } else { $movie = $client->scrape('movie', 'tt' . $torrent->imdb); diff --git a/resources/assets/js/app.js b/resources/assets/js/app.js index 95c8ea2581..169e3c303e 100644 --- a/resources/assets/js/app.js +++ b/resources/assets/js/app.js @@ -22,6 +22,7 @@ Vue.use(VTooltip) Vue.component('version', require('./components/Version')) Vue.component('chatbox', require('./components/chat/Chatbox')) Vue.component('bookmark', require('./components/BookmarkButton')) +Vue.component('smallbookmark', require('./components/SmallBookmarkButton')) const app = new Vue({ el: '#app' diff --git a/resources/assets/js/components/SmallBookmarkButton.vue b/resources/assets/js/components/SmallBookmarkButton.vue new file mode 100644 index 0000000000..2ffbb22a51 --- /dev/null +++ b/resources/assets/js/components/SmallBookmarkButton.vue @@ -0,0 +1,67 @@ + + + \ No newline at end of file diff --git a/resources/views/torrent/results.blade.php b/resources/views/torrent/results.blade.php new file mode 100644 index 0000000000..25f82065d7 --- /dev/null +++ b/resources/views/torrent/results.blade.php @@ -0,0 +1,302 @@ +
+ + + + {{--@if($user->show_poster == 1) + + @else + + @endif--}} + + + + + + + + + + + + @foreach($torrents as $torrent) + + {{--@php $client = new \App\Services\MovieScrapper(config('api-keys.tmdb') , config('api-keys.tvdb') , config('api-keys.omdb')) @endphp + @if ($torrent->category_id == 2) + @if ($torrent->tmdb || $torrent->tmdb != 0) + @php $movie = $client->scrape('tv', null, $torrent->tmdb); @endphp + @else + @php $movie = $client->scrape('tv', 'tt'. $torrent->imdb); @endphp + @endif + @else + @if ($torrent->tmdb || $torrent->tmdb != 0) + @php $movie = $client->scrape('movie', null, $torrent->tmdb); @endphp + @else + @php $movie = $client->scrape('movie', 'tt'. $torrent->imdb); @endphp + @endif + @endif--}} + + @if ($torrent->sticky == 1) + + @else + + @endif + {{----}} + + + + + + + + + + + + @endforeach + +
PosterCategory/Type{{ trans('common.name') }}
+ @if ($user->show_poster == 1) +
+ Poster +
+ @else +
+ @endif +
+ +
+ +
+
+
+ + {{ $torrent->type }} + +
+
+ + {{ $torrent->name }} + + + + + + {{----}} + + @php $history = \App\History::where('user_id', '=', $user->id)->where('info_hash', '=', $torrent->info_hash)->first(); @endphp + @if ($history) + @if ($history->seeder == 1 && $history->active == 1) + + @endif + + @if ($history->seeder == 0 && $history->active == 1) + + @endif + + @if ($history->seeder == 0 && $history->active == 0 && $history->completed_at == null) + + @endif + + @if ($history->seeder == 0 && $history->active == 0 && $history->completed_at != null) + + @endif + @endif + +
+ @if ($torrent->anon == 1) + + By ANONYMOUS USER + @if ($user->id == $torrent->user->id || $user->group->is_modo) + + ({{ $torrent->user->username }}) + + @endif + + @else + + By + + {{ $torrent->user->username }} + + + @endif + + {{--@if ($torrent->category->meta == 1) + @if ($user->ratings == 1) { + + + + + + {{ $movie->imdbRating }}/10 ({{ $movie->imdbVotes }} votes) + + + @else + @if ($torrent->category_id == 2) + + @else + + @endif + + + + + {{ $movie->tmdbRating }}/10 ({{ $movie->tmdbVotes }} votes) + + + @endif + @endif--}} + + + + {{ $torrent->thanks()->count() }} + + + @if ($torrent->stream == 1) + + Stream Optimized + + @endif + + @if ($torrent->featured == 0) + @if ($torrent->doubleup == 1) + + Double Upload + + @endif + @if ($torrent->free == 1) + + 100% Free + + @endif + @endif + + @if ($personal_freeleech) + + Personal FL + + @endif + + @php $freeleech_token = \App\FreeleechToken::where('user_id', '=', $user->id)->where('torrent_id', '=', $torrent->id)->first(); @endphp + @if ($freeleech_token) + + Freeleech Token + + @endif + + @if ($torrent->featured == 1) + + Featured + + @endif + + @if ($user->group->is_freeleech == 1) + + Special FL + + @endif + + @if (config('other.freeleech') == 1) + + Global FreeLeech + + @endif + + @if (config('other.doubleup') == 1) + + Global Double Upload + + @endif + + @if ($torrent->leechers >= 5) + + Hot + + @endif + + @if ($torrent->sticky == 1) + + Sticky + + @endif + + @if ($user->updated_at->getTimestamp() < $torrent->created_at->getTimestamp()) + + NEW + + @endif + + @if ($torrent->highspeed == 1) + + High Speeds + + @endif + + @if ($torrent->sd == 1) + + SD Content + + @endif +
+ + + {{ $torrent->getSize() }} + + + + {{ $torrent->times_completed }} {{ trans('common.times') }} + + + + + + {{ $torrent->seeders }} + + + + + + {{ $torrent->leechers }} + + +
+
+ {{ $torrents->links() }} +
+
+ diff --git a/resources/views/torrent/torrents.blade.php b/resources/views/torrent/torrents.blade.php index 5eab19963a..87563ad9eb 100755 --- a/resources/views/torrent/torrents.blade.php +++ b/resources/views/torrent/torrents.blade.php @@ -17,26 +17,38 @@ @endsection @section('content') -
+

Current Filters

-
{{ Form::open(['action'=>'TorrentController@torrents','method'=>'get','class'=>'form-horizontal form-condensed form-torrent-search form-bordered']) }} +
+ + {{ Form::open(['action'=>'TorrentController@torrents','method'=>'get','class'=>'form-horizontal form-condensed form-torrent-search form-bordered']) }} +
- {{ Form::text('search',null,['id'=>'search','placeholder'=>'Name or Title','class'=>'form-control']) }} + {{ Form::text('search',null,['id'=>'search','placeholder'=>'Name / Title','class'=>'form-control']) }}
+ +
+ +
+ {{ Form::text('description',null,['id'=>'description','placeholder'=>'Mediainfo or Description','class'=>'form-control']) }} +
+
+
{{ Form::text('uploader',null,['id'=>'uploader','placeholder'=>'Uploader Username','class'=>'form-control']) }}
+
@@ -52,190 +64,153 @@ {{ Form::text('mal',null,['id'=>'mal','placeholder'=>'MAL #','class'=>'form-control']) }}
+
@foreach($repository->categories() as $id => $category) - {{ Form::checkbox($category,$id,false,['class'=>'category']) }} + {{ Form::checkbox($category,$id,false,['class'=>'category']) }} {{ Form::label($category,$category,['class'=>'inline']) }} - + @endforeach
+
@foreach($repository->types() as $id => $type) - {{ Form::checkbox($type,$type,false,['class'=>'type']) }} + {{ Form::checkbox($type,$type,false,['class'=>'type']) }} {{ Form::label($type,$type,['class'=>'inline']) }} - + @endforeach
+
- - - - - + + + + + - - + +
+
- - - - - + + - - + + + + +
+
- - - - - + + - - + + + + +
+ {{ Form::close() }} -
-
-
- Extra: - - Torrent Categories - Torrent Catalogs -
-
- View: - Torrent List - Torrent Cards - Torrent Grouping +
+ +
+
+ {{ Form::label('sorting','Sort By:',['class'=>'control-label col-sm-2']) }} +
+ {{ Form::select('sorting',$repository->sorting(),'created_at',['class'=>'form-control','id'=>'sorting','placeholder'=>'Select for sorting']) }} +
+
+ {{ Form::select('direction',$repository->direction(),'desc',['class'=>'form-control','id'=>'direction']) }} +
+ {{ Form::label('qty','Display:',['class'=>'control-label col-sm-2']) }} +
+ {{ Form::select('qty',[25=>25,50=>50,100=>100],25,['class'=>'form-control','id'=>'qty']) }} +
+
+
- - +
-
-
- Stats: - {{ $torrents->count() }} - Torrents - {{ $alive }} Alive - {{ $dead }} Dead +
+
+
+

+ {{ trans('torrent.torrents') }} +

+
+
+
+ @include('torrent.results')
-
+
+
+ +
+
+
Activity Legend: + data-original-title='Currently Seeding!'> + + + data-original-title='Currently Leeching!'> + + + data-original-title='Started Downloading But Never Completed!'> + + + data-original-title='You Completed This Download But Are No Longer Seeding It!'> + +
-
-
-

-
-
-
- {{ Form::label('sorting','Sort By:',['class'=>'control-label col-sm-2']) }} -
- {{ Form::select('sorting',$repository->sorting(),'created_at',['class'=>'form-control','id'=>'sorting','placeholder'=>'Select for sorting']) }} -
-
- {{ Form::select('direction',$repository->direction(),'desc',['class'=>'form-control','id'=>'direction']) }} -
- {{ Form::label('qty','Display:',['class'=>'control-label col-sm-2']) }} -
- {{ Form::select('qty',[25=>25,50=>50,100=>100],25,['class'=>'form-control','id'=>'qty']) }} -
-
-
-
-
- - - - @if($user->show_poster == 1) - - @else - - @endif - - - - - - - - - - - - -
PosterCategory{{ trans('common.name') }}
-
-
- - -
- -
- -
- -
@endsection @@ -246,6 +221,7 @@ class='fa fa-thumbs-down'> function faceted(page) { var csrf = "{{ csrf_token() }}"; var search = $("#search").val(); + var description = $("#description").val(); var uploader = $("#uploader").val(); var imdb = $("#imdb").val(); var tvdb = $("#tvdb").val(); @@ -330,6 +306,7 @@ function faceted(page) { data: { _token: csrf, search: search, + description: description, uploader: uploader, imdb: imdb, tvdb: tvdb, @@ -356,13 +333,8 @@ function faceted(page) { $("#result").html('') } }).done(function (e) { - if (e['count'] == 0) { - $("#count").html('0 Result(s)'); - } else { - $("#count").html(e['count'] + ' Result(s)'); - } - $("#result").html(e['result']); - pagination(e['rows'], e['qty'], e['active']); + $data = $(e); + $("#result").html($data); }); } @@ -374,6 +346,11 @@ function faceted(page) { faceted(); }) + - + @endsection