From 589332afb3df98e5aafedc6a632120220020ff8c Mon Sep 17 00:00:00 2001 From: xiaomlove Date: Sun, 4 Sep 2022 15:56:19 +0800 Subject: [PATCH] skip offer + pt-gen fill subtitle --- app/Filament/Resources/Torrent/TagResource.php | 18 +++++++++++++++--- .../Torrent/TagResource/Pages/ListTags.php | 9 +++++++++ app/Models/Tag.php | 5 +++++ include/constants.php | 2 +- lang/chs/lang_offers.php | 1 + lang/chs/lang_settings.php | 2 ++ lang/cht/lang_offers.php | 1 + lang/cht/lang_settings.php | 2 ++ lang/en/lang_offers.php | 1 + lang/en/lang_settings.php | 2 ++ nexus/Install/settings.default.php | 1 + public/ajax.php | 4 ++-- public/js/ptgen.js | 9 ++++++++- public/offers.php | 4 ++++ public/settings.php | 4 +++- public/upload.php | 14 +++++++++++--- resources/lang/en/admin.php | 3 +++ resources/lang/en/label.php | 1 + resources/lang/zh_CN/admin.php | 3 +++ resources/lang/zh_CN/label.php | 1 + resources/lang/zh_TW/admin.php | 3 +++ resources/lang/zh_TW/label.php | 1 + 22 files changed, 80 insertions(+), 11 deletions(-) diff --git a/app/Filament/Resources/Torrent/TagResource.php b/app/Filament/Resources/Torrent/TagResource.php index bd008994..c1403150 100644 --- a/app/Filament/Resources/Torrent/TagResource.php +++ b/app/Filament/Resources/Torrent/TagResource.php @@ -61,15 +61,14 @@ class TagResource extends Resource Tables\Columns\TextColumn::make('padding')->label(__('label.tag.padding')), Tables\Columns\TextColumn::make('border_radius')->label(__('label.tag.border_radius')), Tables\Columns\TextColumn::make('priority')->label(__('label.priority'))->sortable(), + Tables\Columns\TextColumn::make('torrents_count')->label(__('label.tag.torrents_count')), Tables\Columns\TextColumn::make('updated_at')->dateTime()->label(__('label.updated_at')), ]) ->defaultSort('priority', 'desc') ->filters([ // ]) - ->actions([ - Tables\Actions\EditAction::make(), - ]) + ->actions(self::getActions()) ->bulkActions([ Tables\Actions\DeleteBulkAction::make(), ]); @@ -90,4 +89,17 @@ class TagResource extends Resource 'edit' => Pages\EditTag::route('/{record}/edit'), ]; } + + private static function getActions(): array + { + $actions = []; + $actions[] = Tables\Actions\Action::make('detach_torrents') + ->label(__('admin.resources.tag.detach_torrents')) + ->requiresConfirmation() + ->action(function ($record) { + $record->torrent_tags()->delete(); + }); + $actions[] = Tables\Actions\EditAction::make(); + return $actions; + } } diff --git a/app/Filament/Resources/Torrent/TagResource/Pages/ListTags.php b/app/Filament/Resources/Torrent/TagResource/Pages/ListTags.php index 1e4814aa..5030e7ce 100644 --- a/app/Filament/Resources/Torrent/TagResource/Pages/ListTags.php +++ b/app/Filament/Resources/Torrent/TagResource/Pages/ListTags.php @@ -4,8 +4,10 @@ namespace App\Filament\Resources\Torrent\TagResource\Pages; use App\Filament\PageList; use App\Filament\Resources\Torrent\TagResource; +use App\Models\Tag; use Filament\Pages\Actions; use Filament\Resources\Pages\ListRecords; +use Illuminate\Database\Eloquent\Builder; class ListTags extends PageList { @@ -17,4 +19,11 @@ class ListTags extends PageList Actions\CreateAction::make(), ]; } + + + protected function getTableQuery(): Builder + { + return Tag::query()->withCount('torrents'); + } + } diff --git a/app/Models/Tag.php b/app/Models/Tag.php index 51ea03c6..b9d42700 100644 --- a/app/Models/Tag.php +++ b/app/Models/Tag.php @@ -53,6 +53,11 @@ class Tag extends NexusModel return $this->belongsToMany(Torrent::class, 'torrent_tags', 'tag_id', 'torrent_id'); } + public function torrent_tags(): \Illuminate\Database\Eloquent\Relations\HasMany + { + return $this->hasMany(TorrentTag::class, 'tag_id'); + } + } diff --git a/include/constants.php b/include/constants.php index 30e8fd44..d4690a2a 100644 --- a/include/constants.php +++ b/include/constants.php @@ -1,6 +1,6 @@ "小时后未被通过,它将被删除。", 'text_rule_four_one' => "如在候选通过后", 'text_rule_four_two' => "小时内用户没有发布种子,通过的候选将被删除。", + 'text_rule_skip_offer' => "当用户通过的候选数大于等于%d时,可直接发布种子,无需经过候选。", ); ?> diff --git a/lang/chs/lang_settings.php b/lang/chs/lang_settings.php index ca679690..c3dcb295 100644 --- a/lang/chs/lang_settings.php +++ b/lang/chs/lang_settings.php @@ -769,6 +769,8 @@ $lang_settings = array 'row_harem_addition' => '后宫加成', 'text_user_would_get_by_harem' => '用户将获得直属后宫魔力值的', 'text_harem_addition_note' => '倍作为奖励(系数,如填入 0.01,后宫获得 100 魔力则奖励用户 100 * 0.01 = 1)', + 'row_offer_skip_approved_count' => '直接发布候选通过数', + 'text_offer_skip_approved_count_note' => '当通过的候选数大于等于此数值时,可直接发布不用提交候选。', ); ?> diff --git a/lang/cht/lang_offers.php b/lang/cht/lang_offers.php index 76d7efcc..e5369cb0 100644 --- a/lang/cht/lang_offers.php +++ b/lang/cht/lang_offers.php @@ -137,6 +137,7 @@ $lang_offers = array 'text_rule_three_two' => "小時后未被通過,它將被移除。", 'text_rule_four_one' => "如在候選通過后", 'text_rule_four_two' => "小時內用戶沒有發布種子,通過的候選將被移除。", + 'text_rule_skip_offer' => "當用戶通過的候選數大於等於%d時,可直接發布種子,無需經過候選。", ); ?> diff --git a/lang/cht/lang_settings.php b/lang/cht/lang_settings.php index bf0695d2..9701895b 100644 --- a/lang/cht/lang_settings.php +++ b/lang/cht/lang_settings.php @@ -769,6 +769,8 @@ $lang_settings = array 'row_harem_addition' => '後宮加成', 'text_user_would_get_by_harem' => '用戶將獲得直屬後宮魔力值的', 'text_harem_addition_note' => '倍作為獎勵(系數,如填入 0.01,後宮獲得 100 魔力則獎勵用戶 100 * 0.01 = 1)', + 'row_offer_skip_approved_count' => '直接發布候選通過數', + 'text_offer_skip_approved_count_note' => '當通過的候選數大於等於此數值時,可直接發布不用提交候選。', ); ?> diff --git a/lang/en/lang_offers.php b/lang/en/lang_offers.php index 22ed8a61..1659ace2 100644 --- a/lang/en/lang_offers.php +++ b/lang/en/lang_offers.php @@ -137,6 +137,7 @@ $lang_offers = array 'text_rule_three_two' => " hours after added.", 'text_rule_four_one' => "Offers will be deleted if not uploaded ", 'text_rule_four_two' => " hours after being approved.", + 'text_rule_skip_offer' => "When the number of offers passed by the user is greater than or equal to %d, user can upload torrents directly without going through offers section.", ); ?> diff --git a/lang/en/lang_settings.php b/lang/en/lang_settings.php index 947be7da..9a049d52 100644 --- a/lang/en/lang_settings.php +++ b/lang/en/lang_settings.php @@ -769,6 +769,8 @@ $lang_settings = array 'row_harem_addition' => 'Harem addition', 'text_user_would_get_by_harem' => 'The user will receive the bonus value of the direct harem', 'text_harem_addition_note' => 'times as reward (factor, e.g. fill in 0.01, if harem gets 100 bonus then reward user 100 * 0.01 = 1)', + 'row_offer_skip_approved_count' => 'Direct upload offer allow count', + 'text_offer_skip_approved_count_note' => 'When the number of approved offer is greater than or equal to this value, you can upload directly without submitting offers.', ); ?> diff --git a/nexus/Install/settings.default.php b/nexus/Install/settings.default.php index e3011dff..10acad0f 100644 --- a/nexus/Install/settings.default.php +++ b/nexus/Install/settings.default.php @@ -91,6 +91,7 @@ return array ( 'site_language_enabled' => \App\Models\Language::DEFAULT_ENABLED, 'show_top_uploader' => 'no', 'imdb_language' => 'en-US', + 'offer_skip_approved_count' => 5, ), 'smtp' => array ( diff --git a/public/ajax.php b/public/ajax.php index 914f0ae6..97115177 100644 --- a/public/ajax.php +++ b/public/ajax.php @@ -39,9 +39,9 @@ function getPtGen($params) $rep = new Nexus\PTGen\PTGen(); $result = $rep->generate($params['url']); if ($rep->isRawPTGen($result)) { - return $result['format']; + return $result; } elseif ($rep->isIyuu($result)) { - return $result['data']['format']; + return $result['data']; } else { return ''; } diff --git a/public/js/ptgen.js b/public/js/ptgen.js index 2c15a997..f2bebbcc 100644 --- a/public/js/ptgen.js +++ b/public/js/ptgen.js @@ -1,5 +1,6 @@ jQuery('.btn-get-pt-gen').on('click', function () { let input = jQuery(this).closest('td').find('[data-pt-gen]') + let form = jQuery(this).closest('form') let value = input.val().trim() if (value == '') { return @@ -17,6 +18,12 @@ jQuery('.btn-get-pt-gen').on('click', function () { alert(response.msg) return } - doInsert(response.data, '', false) + doInsert(response.data.format, '', false) + if (response.data.aka) { + form.find("input[name=small_descr]").val(response.data.aka.join("/")) + } + if (response.data.imdb_link) { + form.find("input[name=url]").val(response.data.imdb_link) + } }, 'json') }) diff --git a/public/offers.php b/public/offers.php index 9e287834..cd5ca2be 100644 --- a/public/offers.php +++ b/public/offers.php @@ -699,6 +699,10 @@ begin_frame($lang_offers['text_offers_section'], true,10,"100%","center"); print("

".$lang_offers['text_rules']."

\n"); print("