Skip to content

Commit

Permalink
Merge pull request #3325 from HDInnovations/7.x.x
Browse files Browse the repository at this point in the history
(Release) v7.2.0
  • Loading branch information
HDVinnie committed Dec 30, 2023
2 parents cb1f6c2 + 8aad8d5 commit 154fe2b
Show file tree
Hide file tree
Showing 397 changed files with 18,820 additions and 12,061 deletions.
9 changes: 9 additions & 0 deletions .blade.format.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"attributeJsOptions": {
"semi": true
},
"phpOptions": {
"singleQuote": true
},
"useLaravelPint": false
}
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*.blade.php]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
30 changes: 30 additions & 0 deletions .github/workflows/prettier-blade.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Format Blade Files
on: [push, pull_request]
jobs:
format-blade-files:
strategy:
matrix:
operating-system:
- ubuntu-22.04
name: ${{ matrix.operating-system }}
runs-on: ${{ matrix.operating-system }}
steps:
- name: Code Checkout
uses: actions/checkout@v3
with:
fetch-depth: 2
- name: Configure NPM
uses: actions/setup-node@v2
with:
node-version: '18.x'
- name: Install NPM Dependencies
run: npm install
- name: Run Prettier
run: ./node_modules/.bin/prettier -w *
- name: Commit Changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Blade Style Change (Prettier Blade CI)
commit_user_name: HDVinne
commit_user_email: hdinnovations@protonmail.com
commit_author: HDVinnie <hdinnovations@protonmail.com>
14 changes: 14 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# ignore all files
/*

# except /resources/views/**/*.blade.php
!/resources/
/resources/*
!/resources/views/
/resources/views/**/*.*
!/resources/views/**/*.blade.php

# ignored
resources/views/emails
resources/views/rss/show.blade.php
resources/views/vendor
18 changes: 18 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"plugins": [
"prettier-plugin-blade"
],
"overrides": [
{
"files": [
"*.blade.php"
],
"options": {
"parser": "blade",
"printWidth": 100,
"semi": true,
"singleQuote": true
}
}
]
}
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
<p align="center">
<a href="http://laravel.com"><img src="https://img.shields.io/badge/Laravel-10-f4645f.svg" /></a>
<a href="https://github.com/HDInnovations/UNIT3D/blob/master/LICENSE"><img src="https://img.shields.io/badge/License-AGPL%20v3.0-yellow.svg" /></a>
<a href="https://github.com/HDInnovations/UNIT3D-Community-Edition/actions/workflows/lint.yml/badge.svg"><img src="https://github.com/HDInnovations/UNIT3D-Community-Edition/actions/workflows/lint.yml/badge.svg" /></a>
<a href="https://github.com/HDInnovations/UNIT3D-Community-Edition/actions/workflows/phpunit-test.yml/badge.svg"><img src="https://github.com/HDInnovations/UNIT3D-Community-Edition/actions/workflows/phpunit-test.yml/badge.svg" /></a>
<a href="https://github.com/HDInnovations/UNIT3D-Community-Edition/actions/workflows/compile-assets-test.yml/badge.svg"><img src="https://github.com/HDInnovations/UNIT3D-Community-Edition/actions/workflows/compile-assets-test.yml/badge.svg" /></a>
<a href="https://github.com/HDInnovations/UNIT3D-Community-Edition/actions/workflows/larastan.yml/badge.svg"><img src="https://github.com/HDInnovations/UNIT3D-Community-Edition/actions/workflows/larastan.yml/badge.svg" /></a>
<a href="https://github.com/HDInnovations/UNIT3D-Community-Edition/actions/workflows/lint.yml/badge.svg?branch=7.x.x"><img src="https://github.com/HDInnovations/UNIT3D-Community-Edition/actions/workflows/lint.yml/badge.svg?branch=7.x.x" /></a>
<a href="https://github.com/HDInnovations/UNIT3D-Community-Edition/actions/workflows/phpunit-test.yml/badge.svg?branch=7.x.x"><img src="https://github.com/HDInnovations/UNIT3D-Community-Edition/actions/workflows/phpunit-test.yml/badge.svg?branch=7.x.x" /></a>
<a href="https://github.com/HDInnovations/UNIT3D-Community-Edition/actions/workflows/compile-assets-test.yml/badge.svg?branch=7.x.x"><img src="https://github.com/HDInnovations/UNIT3D-Community-Edition/actions/workflows/compile-assets-test.yml/badge.svg?branch=7.x.x" /></a>
<a href="https://github.com/HDInnovations/UNIT3D-Community-Edition/actions/workflows/larastan.yml/badge.svg?branch=7.x.x"><img src="https://github.com/HDInnovations/UNIT3D-Community-Edition/actions/workflows/larastan.yml/badge.svg?branch=7.x.x" /></a>
<a href="https://github.com/HDInnovations/UNIT3D-Community-Edition/actions/workflows/prettier-blade.yml/badge.svg?branch=7.x.x"><img src="https://github.com/HDInnovations/UNIT3D-Community-Edition/actions/workflows/prettier-blade.yml/badge.svg?branch=7.x.x" /></a>
</p>

<p align="center">
Expand Down
4 changes: 2 additions & 2 deletions app/Console/Commands/DemoSeed.php
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ private function fetchMovie($id)
$tmdbScraper = new TMDBScraper();
$tmdbScraper->movie($id);

return (new Movie($id))->getData();
return (new Movie($id))->data;
}

private function fetchTv($id)
Expand All @@ -488,7 +488,7 @@ private function fetchTv($id)
$tmdbScraper = new TMDBScraper();
$tmdbScraper->tv($id);

return (new TV($id))->getData();
return (new TV($id))->data;
}

private function movie_ids(): array
Expand Down
63 changes: 37 additions & 26 deletions app/Helpers/Bbcode.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,18 @@

class Bbcode
{
/**
* @var array<
* string,
* array{
* openBbcode: string,
* closeBbcode: string,
* openHtml: string,
* closeHtml: string,
* block: boolean
* }
* > $parsers.
*/
private array $parsers = [
'h1' => [
'openBbcode' => '/^\[h1\]/i',
Expand Down Expand Up @@ -266,54 +278,54 @@ class Bbcode
/**
* Parses the BBCode string.
*/
public function parse($source, $replaceLineBreaks = true): string
public function parse(?string $source, bool $replaceLineBreaks = true): string
{
// Replace all void elements since they don't have closing tags
$source = str_replace('[*]', '<li>', (string) $source);
$source = preg_replace_callback(
'/\[url\](.*?)\[\/url\]/i',
fn ($matches) => '<a href="'.htmlspecialchars($matches[1]).'">'.htmlspecialchars($matches[1]).'</a>',
'/\[url](.*?)\[\/url]/i',
static fn ($matches) => '<a href="'.htmlspecialchars($matches[1], ENT_QUOTES | ENT_HTML5).'">'.htmlspecialchars($matches[1], ENT_QUOTES | ENT_HTML5).'</a>',
$source
);
$source = preg_replace_callback(
'/\[img\](.*?)\[\/img\]/i',
fn ($matches) => '<img src="'.htmlspecialchars($matches[1]).'" loading="lazy" class="img-responsive" style="display: inline !important;">',
'/\[img](.*?)\[\/img]/i',
static fn ($matches) => '<img src="'.htmlspecialchars($matches[1], ENT_QUOTES | ENT_HTML5).'" loading="lazy" class="img-responsive" style="display: inline !important;">',
$source
);
$source = preg_replace_callback(
'/\[img width=(\d+)\](.*?)\[\/img\]/i',
fn ($matches) => '<img src="'.htmlspecialchars($matches[2]).'" loading="lazy" width="'.$matches[1].'px">',
'/\[img width=(\d+)](.*?)\[\/img]/i',
static fn ($matches) => '<img src="'.htmlspecialchars($matches[2], ENT_QUOTES | ENT_HTML5).'" loading="lazy" width="'.$matches[1].'px">',
$source
);
$source = preg_replace_callback(
'/\[img=(\d+)(?:x\d+)?\](.*?)\[\/img\]/i',
fn ($matches) => '<img src="'.htmlspecialchars($matches[2]).'" loading="lazy" width="'.$matches[1].'px">',
'/\[img=(\d+)(?:x\d+)?](.*?)\[\/img]/i',
static fn ($matches) => '<img src="'.htmlspecialchars($matches[2], ENT_QUOTES | ENT_HTML5).'" loading="lazy" width="'.$matches[1].'px">',
$source
);

// Youtube elements need to be replaced like this because the content inside the two tags
// has to be moved into an html attribute
// YouTube video elements need to be replaced like this because the content inside the two tags
// has to be moved into an HTML attribute
$source = preg_replace_callback(
'/\[youtube\](.*?)\[\/youtube\]/i',
fn ($matches) => '<iframe width="560" height="315" src="https://www.youtube-nocookie.com/embed/'.htmlspecialchars($matches[1]).'?rel=0" allow="autoplay; encrypted-media" allowfullscreen></iframe>',
'/\[youtube]([a-z0-9_-]{11})\[\/youtube]/i',
static fn ($matches) => '<iframe width="560" height="315" src="https://www.youtube-nocookie.com/embed/'.$matches[1].'?rel=0" allow="autoplay; encrypted-media" allowfullscreen></iframe>',
$source
);
$source = preg_replace_callback(
'/\[video\](.*?)\[\/video\]/i',
fn ($matches) => '<iframe width="560" height="315" src="https://www.youtube-nocookie.com/embed/'.htmlspecialchars($matches[1]).'?rel=0" allow="autoplay; encrypted-media" allowfullscreen></iframe>',
'/\[video]([a-z0-9_-]{11})\[\/video]/i',
static fn ($matches) => '<iframe width="560" height="315" src="https://www.youtube-nocookie.com/embed/'.$matches[1].'?rel=0" allow="autoplay; encrypted-media" allowfullscreen></iframe>',
$source
);
$source = preg_replace_callback(
'/\[video="youtube"\](.*?)\[\/video\]/i',
fn ($matches) => '<iframe width="560" height="315" src="https://www.youtube-nocookie.com/embed/'.htmlspecialchars($matches[1]).'?rel=0" allow="autoplay; encrypted-media" allowfullscreen></iframe>',
'/\[video="youtube"]([a-z0-9_-]{11})\[\/video]/i',
static fn ($matches) => '<iframe width="560" height="315" src="https://www.youtube-nocookie.com/embed/'.$matches[1].'?rel=0" allow="autoplay; encrypted-media" allowfullscreen></iframe>',
$source
);

// Common comparison syntax used in other torrent management systems is quite specific
// Common comparison syntax used in other torrent management systems is quite specific,
// so it must be done here instead
$source = preg_replace_callback(
'/\[comparison=(.*?)\]\s*(.*?)\s*\[\/comparison\]/is',
function ($matches) {
'/\[comparison=(.*?)]\s*(.*?)\s*\[\/comparison]/is',
static function ($matches) {
$comparates = preg_split('/\s*,\s*/', $matches[1]);
$urls = preg_split('/\s*(?:,|\s)\s*/', $matches[2]);
$validatedUrls = collect($urls)->filter(fn ($url) => filter_var($url, FILTER_VALIDATE_URL));
Expand Down Expand Up @@ -413,13 +425,12 @@ function ($matches) {
* [/list]
* ```
*
* @param String $source Reference to the source text content currently being converted from bbcode to html.
* @param int $index Reference to the current index of `$source` that the parser must keep track of.
* @param int $tagStartIndex The index of the first character of the tag being parsed inside of `$source`. Should be the `[` character.
* @param int $tagStopIndex The index of the last character of the tag being parsed inside of `$source`. Should be the `]` character.
* @return void
* @param string $source Reference to the source text content currently being converted from bbcode to html.
* @param int $index Reference to the current index of `$source` that the parser must keep track of.
* @param int $tagStartIndex The index of the first character of the tag being parsed inside `$source`. Should be the `[` character.
* @param int $tagStopIndex The index of the last character of the tag being parsed inside `$source`. Should be the `]` character.
*/
private function handleBlockElementSpacing(String &$source, int &$index, int $tagStartIndex, int $tagStopIndex): void
private function handleBlockElementSpacing(string &$source, int &$index, int $tagStartIndex, int $tagStopIndex): void
{
// Remove two line breaks (if they exist) instead of one, since a
// line break after a block element is positioned on the line after
Expand Down
15 changes: 1 addition & 14 deletions app/Helpers/Bencode.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,20 +168,7 @@ public static function bencode($d)
{
if (\is_array($d)) {
$ret = 'l';
$isDict = false;

if (!isset($d['isDct'])) {
foreach (array_keys($d) as $key) {
if (!\is_int($key)) {
$isDict = true;

break;
}
}
} else {
$isDict = (bool) $d['isDct'];
unset($d['isDct']);
}
$isDict = !array_is_list($d);

if ($isDict) {
$ret = 'd';
Expand Down
1 change: 1 addition & 0 deletions app/Http/Controllers/API/TorrentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,7 @@ public function filter(Request $request): TorrentsResource|\Illuminate\Http\Json
->when($request->filled('malId'), fn ($query) => $query->ofMal((int) $request->malId))
->when($request->filled('playlistId'), fn ($query) => $query->ofPlaylist((int) $request->playlistId))
->when($request->filled('collectionId'), fn ($query) => $query->ofCollection((int) $request->collectionId))
->when($request->filled('primaryLanguages'), fn ($query) => $query->ofOriginalLanguage($request->primaryLanguages))
->when($request->filled('free'), fn ($query) => $query->ofFreeleech($request->free))
->when($request->filled('doubleup'), fn ($query) => $query->doubleup())
->when($request->filled('featured'), fn ($query) => $query->featured())
Expand Down
2 changes: 2 additions & 0 deletions app/Http/Controllers/Staff/HomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use App\Helpers\SystemInformation;
use App\Http\Controllers\Controller;
use App\Models\Group;
use App\Services\Unit3dAnnounce;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Spatie\SslCertificate\SslCertificate;
Expand Down Expand Up @@ -76,6 +77,7 @@ public function index(Request $request): \Illuminate\Contracts\View\Factory|\Ill
'avg' => $systemInformation->avg(),
'basic' => $systemInformation->basic(),
'file_permissions' => $systemInformation->directoryPermissions(),
'externalTrackerStats' => Unit3dAnnounce::getStats(),
]);
}
}
15 changes: 8 additions & 7 deletions app/Http/Controllers/Staff/MassActionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,14 @@ public function update(): \Illuminate\Http\RedirectResponse

foreach (User::where('group_id', '=', $validatingGroup[0])->get() as $user) {
$user->update([
'group_id' => $memberGroup[0],
'active' => 1,
'can_upload' => 1,
'can_download' => 1,
'can_request' => 1,
'can_comment' => 1,
'can_invite' => 1,
'group_id' => $memberGroup[0],
'active' => 1,
'can_upload' => 1,
'can_download' => 1,
'can_request' => 1,
'can_comment' => 1,
'can_invite' => 1,
'email_verified_at' => now(),
]);

Unit3dAnnounce::addUser($user);
Expand Down
83 changes: 83 additions & 0 deletions app/Http/Controllers/Staff/WikiCategoryController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?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 HDVinnie <hdinnovations@protonmail.com>
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
*/

namespace App\Http\Controllers\Staff;

use App\Http\Controllers\Controller;
use App\Http\Requests\Staff\StoreWikiCategoryRequest;
use App\Http\Requests\Staff\UpdateWikiCategoryRequest;
use App\Models\WikiCategory;

class WikiCategoryController extends Controller
{
/**
* Display All Categories.
*/
public function index(): \Illuminate\Contracts\View\View|\Illuminate\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\Foundation\Application
{
return view('Staff.wiki_category.index', [
'wikiCategories' => WikiCategory::orderBy('position')->get(),
]);
}

/**
* Show Form For Creating A New Category.
*/
public function create(): \Illuminate\Contracts\View\View|\Illuminate\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\Foundation\Application
{
return view('Staff.wiki_category.create');
}

/**
* Store A Category.
*/
public function store(StoreWikiCategoryRequest $request): \Illuminate\Http\RedirectResponse
{
WikiCategory::create($request->validated());

return to_route('staff.wiki_categories.index')
->withSuccess('Wiki Category Successfully Added');
}

/**
* Category Edit Form.
*/
public function edit(WikiCategory $wikiCategory): \Illuminate\Contracts\View\View|\Illuminate\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\Foundation\Application
{
return view('Staff.wiki_category.edit', [
'wikiCategory' => $wikiCategory,
]);
}

/**
* Update A Category.
*/
public function update(UpdateWikiCategoryRequest $request, WikiCategory $wikiCategory): \Illuminate\Http\RedirectResponse
{
$wikiCategory->update($request->validated());

return to_route('staff.wiki_categories.index')
->withSuccess('Wiki Category Successfully Modified');
}

/**
* Destroy A Category.
*/
public function destroy(WikiCategory $wikiCategory): \Illuminate\Http\RedirectResponse
{
$wikiCategory->delete();

return to_route('staff.wiki_categories.index')
->withSuccess('Wiki Category Successfully Deleted');
}
}

0 comments on commit 154fe2b

Please sign in to comment.