Skip to content

Commit

Permalink
Merge pull request #2300 from HDInnovations/6.x.x
Browse files Browse the repository at this point in the history
(Release) v6.2.2
  • Loading branch information
HDVinnie authored Jul 6, 2022
2 parents 41595b4 + 9178336 commit a5cd46c
Show file tree
Hide file tree
Showing 41 changed files with 1,959 additions and 809 deletions.
10 changes: 7 additions & 3 deletions app/Console/Commands/GitUpdater.php
Original file line number Diff line number Diff line change
Expand Up @@ -341,11 +341,15 @@ private function validatePath($path): void
private function createBackupPath($path): void
{
if (! \is_dir(\storage_path(\sprintf('gitupdate/%s', $path))) && ! \is_file(\base_path($path))) {
\throw_if(! \mkdir($concurrentDirectory = \storage_path(\sprintf('gitupdate/%s', $path)), 0775, true) && ! \is_dir($concurrentDirectory), new \RuntimeException(\sprintf('Directory "%s" was not created', $concurrentDirectory)));
if (! \mkdir($concurrentDirectory = \storage_path(\sprintf('gitupdate/%s', $path)), 0775, true) && ! \is_dir($concurrentDirectory)) {
throw new \RuntimeException(\sprintf('Directory "%s" was not created', $concurrentDirectory));
}
} elseif (\is_file(\base_path($path)) && \dirname($path) !== '.') {
$path = \dirname($path);
\throw_if(! \is_dir(\storage_path(\sprintf('gitupdate/%s', $path))) && ! \mkdir($concurrentDirectory = \storage_path(\sprintf('gitupdate/%s',
$path)), 0775, true) && ! \is_dir($concurrentDirectory), new \RuntimeException(\sprintf('Directory "%s" was not created', $concurrentDirectory)));
if (! \is_dir(\storage_path(\sprintf('gitupdate/%s', $path))) && ! \mkdir($concurrentDirectory = \storage_path(\sprintf('gitupdate/%s',
$path)), 0775, true) && ! \is_dir($concurrentDirectory)) {
throw new \RuntimeException(\sprintf('Directory "%s" was not created', $concurrentDirectory));
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/StatsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ public function leechers(): \Illuminate\Contracts\View\Factory|\Illuminate\View\
public function uploaders(): \Illuminate\Contracts\View\Factory|\Illuminate\View\View
{
// Fetch Top Uploaders
$uploaders = Torrent::with('user')->select(DB::raw('user_id, count(*) as value'))->groupBy('user_id')->latest('value')->take(100)->get();
$uploaders = Torrent::with('user')->where('anon', '=', 0)->select(DB::raw('user_id, count(*) as value'))->groupBy('user_id')->latest('value')->take(100)->get();

return \view('stats.users.uploaders', ['uploaders' => $uploaders]);
}
Expand Down
17 changes: 13 additions & 4 deletions app/Http/Controllers/TorrentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ public function edit(Request $request, int $id): \Illuminate\Contracts\View\Fact
'resolutions' => Resolution::all()->sortBy('position'),
'regions' => Region::all()->sortBy('position'),
'distributors' => Distributor::all()->sortBy('position'),
'keywords' => Keyword::where('torrent_id', '=', $torrent->id)->pluck('name'),
'torrent' => $torrent,
'user' => $user,
]);
Expand Down Expand Up @@ -266,6 +267,14 @@ public function update(Request $request, int $id): \Illuminate\Http\RedirectResp
Image::make($image_cover->getRealPath())->fit(960, 540)->encode('jpg', 90)->save($path_cover);
}

// Torrent Keywords System
Keyword::where('torrent_id', '=', $torrent->id)->delete();

foreach (TorrentTools::parseKeywords($request->input('keywords')) as $keyword) {
Keyword::upsert(['torrent_id' => $torrent->id, 'name' => $keyword], ['torrent_id' => 'name'], ['name']);
}

// TMDB Meta
$tmdbScraper = new TMDBScraper();
if ($torrent->category->tv_meta && ($torrent->tmdb || $torrent->tmdb != 0)) {
$tmdbScraper->tv($torrent->tmdb);
Expand Down Expand Up @@ -549,9 +558,11 @@ public function store(Request $request): \Illuminate\Http\RedirectResponse

// Save The Torrent
$torrent->save();

// Count and save the torrent number in this category
$category->num_torrent = $category->torrents_count;
$category->save();

// Backup the files contained in the torrent
foreach (TorrentTools::getTorrentFiles($decodedTorrent) as $file) {
$torrentFile = new TorrentFile();
Expand All @@ -562,6 +573,7 @@ public function store(Request $request): \Illuminate\Http\RedirectResponse
unset($torrentFile);
}

// TMDB Meta
$tmdbScraper = new TMDBScraper();
if ($torrent->category->tv_meta !== 0 && ($torrent->tmdb || $torrent->tmdb != 0)) {
$tmdbScraper->tv($torrent->tmdb);
Expand All @@ -573,10 +585,7 @@ public function store(Request $request): \Illuminate\Http\RedirectResponse

// Torrent Keywords System
foreach (TorrentTools::parseKeywords($request->input('keywords')) as $keyword) {
$tag = new Keyword();
$tag->name = $keyword;
$tag->torrent_id = $torrent->id;
$tag->save();
Keyword::upsert(['torrent_id' => $torrent->id, 'name' => $keyword], ['torrent_id' => 'name'], ['name']);
}

// Cover Image for No-Meta Torrents
Expand Down
52 changes: 52 additions & 0 deletions app/Http/Livewire/BbcodeInput.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php
/**
* NOTICE OF LICENSE.
*
* UNIT3D Community Edition is open-sourced software licensed under the GNU Affero General Public License v3.0
* The details is bundled with this project in the file LICENSE.txt.
*
* @project UNIT3D Community Edition
*
* @author Raordom <[email protected]>
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
*/

namespace App\Http\Livewire;

use App\Helpers\Bbcode;
use Livewire\Component;

class BbcodeInput extends Component
{
public string $label = '';

public string $name = '';

public bool $isPreviewEnabled = false;

public string $contentBbcode = '';

public string $contentHtml = '';

final public function mount($name, $label)
{
$this->name = $name;
$this->label = $label;
$this->contentBbcode = old($name) ?? '';
}

final public function updatedIsPreviewEnabled(): void
{
if ($this->isPreviewEnabled) {
$this->contentHtml = (new Bbcode())->parse($this->contentBbcode);
}
}

final public function render(): \Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View|\Illuminate\Contracts\Foundation\Application
{
return \view('livewire.bbcode-input', [
'contentHtml' => $this->contentHtml,
'label' => $this->label,
]);
}
}
9 changes: 9 additions & 0 deletions app/Models/Keyword.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@

class Keyword extends Model
{
/**
* The Attributes That Are Mass Assignable.
*
* @var array
*/
protected $fillable = [
'name',
];

/**
* Indicates If The Model Should Be Timestamped.
*
Expand Down
Loading

0 comments on commit a5cd46c

Please sign in to comment.