Skip to content

Commit

Permalink
Merge pull request #1208 from shikorism/develop
Browse files Browse the repository at this point in the history
Release 2024.6.2
  • Loading branch information
shibafu528 authored Jun 25, 2024
2 parents f280f64 + a3788f9 commit a2a83dc
Show file tree
Hide file tree
Showing 70 changed files with 3,160 additions and 3,066 deletions.
2 changes: 1 addition & 1 deletion app/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Collection extends Model
use HasFactory;

/** @var int ユーザーごとの作成数制限 */
const PER_USER_LIMIT = 100;
const PER_USER_LIMIT = 500;

protected $fillable = [
'title',
Expand Down
8 changes: 7 additions & 1 deletion app/Http/Controllers/Api/V1/CollectionItemController.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public function store(Request $request, Collection $collection)
$item = DB::transaction(function () use ($collection, $validated) {
$item = new CollectionItem($validated);
$collection->items()->save($item);
$collection->touch();

$tagIds = [];
if (!empty($validated['tags'])) {
Expand Down Expand Up @@ -119,6 +120,7 @@ public function update(Request $request, Collection $collection, CollectionItem

DB::transaction(function () use ($item, $validated) {
$item->save();
$item->collection->touch();

if (isset($validated['tags'])) {
$tagIds = [];
Expand All @@ -143,7 +145,11 @@ public function update(Request $request, Collection $collection, CollectionItem
public function destroy(Collection $collection, CollectionItem $item)
{
$this->authorize('edit', $item);
$item->delete();

DB::transaction(function () use ($item) {
$item->collection->touch();
$item->delete();
});

return response()->noContent();
}
Expand Down
1 change: 1 addition & 0 deletions app/Http/Resources/CollectionResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public function toArray($request)
'user_name' => $this->user->name,
'title' => $this->title,
'is_private' => $this->is_private,
'updated_at' => $this->updated_at,
];
}
}
20 changes: 14 additions & 6 deletions app/MetadataResolver/FanzaResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,20 +70,28 @@ public function resolve(string $url): Metadata

$metadata = new Metadata();
$metadata->title = $crawler->filter('meta[property="og:title"]')->attr('content');
$metadata->description = trim($crawler->filter('.summary__txt')->text(''));
$metadata->description = trim($crawler->filter('.summary__txt')->text('', false));
$metadata->image = $crawler->filter('meta[property="og:image"]')->attr('content');
$metadata->tags = array_merge($genre, [$crawler->filter('.circleName__txt')->text('')]);

return $metadata;
}

// 電子書籍
if (mb_strpos($url, 'book.dmm.co.jp/detail/') !== false) {
if (mb_strpos($url, 'book.dmm.co.jp/product/') !== false || mb_strpos($url, 'book.dmm.co.jp/detail/') !== false) {
$json = $crawler->filter('script[type="application/ld+json"]')->first()->text('', false);
$data = json_decode($json, true);

// DomCrawler内でjson内の日本語がHTMLエンティティに変換されるので、全要素に対してhtml_entity_decode
array_walk_recursive($data, function (&$v) {
$v = html_entity_decode($v);
});

$metadata = new Metadata();
$metadata->title = trim($crawler->filter('#title')->text(''));
$metadata->description = trim($crawler->filter('.m-boxDetailProduct__info__story')->text(''));
$metadata->title = $data['name'];
$metadata->description = $data['description'];
$metadata->image = preg_replace("~(pr|ps)\.jpg$~", 'pl.jpg', $crawler->filter('meta[property="og:image"]')->attr('content'));
$metadata->tags = $this->array_finish($crawler->filter('.m-boxDetailProductInfoMainList__description__list__item, .m-boxDetailProductInfo__list__description__item a')->extract(['_text']));
$metadata->tags = $this->array_finish([...$data['subjectOf']['author']['name'], $data['subjectOf']['publisher']['name'], ...$data['subjectOf']['genre']]);

return $metadata;
}
Expand All @@ -92,7 +100,7 @@ public function resolve(string $url): Metadata
if (mb_strpos($url, 'dlsoft.dmm.co.jp/detail/') !== false) {
$metadata = new Metadata();
$metadata->title = trim($crawler->filter('#title')->text(''));
$metadata->description = trim($crawler->filter('.area-detail-read .text-overflow')->text(''));
$metadata->description = trim($crawler->filter('.area-detail-read .text-overflow')->text('', false));
$metadata->image = preg_replace("~(pr|ps)\.jpg$~", 'pl.jpg', $crawler->filter('meta[property="og:image"]')->attr('content'));
$metadata->tags = $this->array_finish($crawler->filter('.container02 table a[href*="list/article="]')->extract(['_text']));

Expand Down
2 changes: 1 addition & 1 deletion app/MetadataResolver/HentaiFoundryResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function resolve(string $url): Metadata
$metadata->title = $crawler->filter('#picBox .boxtitle .imageTitle')->text();
$metadata->description = 'by ' . $author . PHP_EOL . $description;
$metadata->image = 'https:' . $crawler->filter('img[src^="//picture"]')->attr('src');
$metadata->tags = $crawler->filter('a[rel="tag"]')->extract('_text');
$metadata->tags = $crawler->filter('a[rel="tag"]')->extract(['_text']);

return $metadata;
}
Expand Down
4 changes: 2 additions & 2 deletions app/MetadataResolver/Kb10uyShortStoryServerResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ public function resolve(string $url): Metadata

$metadata = new Metadata();
$metadata->title = $infoElement->filter('h1')->text();
$metadata->description = trim($infoElement->filter('p.summary')->text());
$metadata->tags = array_values(array_diff($infoElement->filter('ul.tags > li.tag > a')->extract('_text'), self::EXCLUDED_TAGS));
$metadata->description = trim($infoElement->filter('p.summary')->text('', false));
$metadata->tags = array_values(array_diff($infoElement->filter('ul.tags > li.tag > a')->extract(['_text']), self::EXCLUDED_TAGS));

return $metadata;
}
Expand Down
2 changes: 1 addition & 1 deletion app/MetadataResolver/MGStageResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function resolve(string $url): Metadata

$metadata = new Metadata();
$metadata->title = trim($crawler->filter('.tag')->text(''));
$metadata->description = trim(strip_tags($crawler->filter('.txt.introduction')->text('')));
$metadata->description = trim(strip_tags($crawler->filter('.txt.introduction')->text('', false)));
$metadata->image = $crawler->filter('meta[property="og:image"]')->attr('content');

// 作品に設定されているジャンルをトリム後に重複排除し、昇順ソートしてタグへ設定する
Expand Down
4 changes: 2 additions & 2 deletions app/MetadataResolver/NijieResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function resolve(string $url): Metadata
$metadata = $this->ogpResolver->parse($html);
$crawler = new Crawler($html);

$json = $crawler->filter('script[type="application/ld+json"]')->first()->text();
$json = $crawler->filter('script[type="application/ld+json"]')->first()->text(null, false);

// 改行がそのまま入っていることがあるのでデコード前にエスケープが必要
$data = json_decode(preg_replace('/\r?\n/', '\n', $json), true);
Expand All @@ -57,7 +57,7 @@ public function resolve(string $url): Metadata
// サムネイルからメイン画像に
$metadata->image = str_replace('__s_rs_l160x160/', '__s_rs_l0x0/', $data['thumbnailUrl']);
}
$metadata->tags = $crawler->filter('#view-tag span.tag_name')->extract('_text');
$metadata->tags = $crawler->filter('#view-tag span.tag_name')->extract(['_text']);

return $metadata;
}
Expand Down
2 changes: 1 addition & 1 deletion app/Parser/SearchQuery/SearchQueryBaseListener.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/*
* Generated from resources/grammar/SearchQuery.g4 by ANTLR 4.10.1
* Generated from resources/grammar/SearchQuery.g4 by ANTLR 4.13.1
*/

namespace App\Parser\SearchQuery;
Expand Down
4 changes: 2 additions & 2 deletions app/Parser/SearchQuery/SearchQueryLexer.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/*
* Generated from resources/grammar/SearchQuery.g4 by ANTLR 4.10.1
* Generated from resources/grammar/SearchQuery.g4 by ANTLR 4.13.1
*/

namespace App\Parser\SearchQuery {
Expand Down Expand Up @@ -96,7 +96,7 @@ private static function initialize(): void
return;
}

RuntimeMetaData::checkVersion('4.10.1', RuntimeMetaData::VERSION);
RuntimeMetaData::checkVersion('4.13.1', RuntimeMetaData::VERSION);

$atn = (new ATNDeserializer())->deserialize(self::SERIALIZED_ATN);

Expand Down
2 changes: 1 addition & 1 deletion app/Parser/SearchQuery/SearchQueryListener.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/*
* Generated from resources/grammar/SearchQuery.g4 by ANTLR 4.10.1
* Generated from resources/grammar/SearchQuery.g4 by ANTLR 4.13.1
*/

namespace App\Parser\SearchQuery;
Expand Down
4 changes: 2 additions & 2 deletions app/Parser/SearchQuery/SearchQueryParser.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/*
* Generated from resources/grammar/SearchQuery.g4 by ANTLR 4.10.1
* Generated from resources/grammar/SearchQuery.g4 by ANTLR 4.13.1
*/

namespace App\Parser\SearchQuery {
Expand Down Expand Up @@ -92,7 +92,7 @@ private static function initialize(): void
return;
}

RuntimeMetaData::checkVersion('4.10.1', RuntimeMetaData::VERSION);
RuntimeMetaData::checkVersion('4.13.1', RuntimeMetaData::VERSION);

$atn = (new ATNDeserializer())->deserialize(self::SERIALIZED_ATN);

Expand Down
1 change: 1 addition & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ services:
command: php artisan schedule:work
ports: []
antlr:
image: tissue-antlr:4.13.1
build:
context: .
dockerfile: docker/development/antlr.dockerfile
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"ext-mbstring": "*",
"ext-pdo": "*",
"anhskohbo/no-captcha": "^3.0",
"antlr/antlr4-php-runtime": "^0.7.0",
"antlr/antlr4-php-runtime": "^0.9.1",
"doctrine/dbal": "^3.7",
"erusev/parsedown": "^1.7",
"guzzlehttp/guzzle": "^7.4.5",
Expand All @@ -34,8 +34,8 @@
"openpear/stream_filter_mbstring": "dev-master",
"sentry/sentry-laravel": "^4.1.0",
"staudenmeir/eloquent-eager-limit": "~1.7.1",
"symfony/css-selector": "^4.3",
"symfony/dom-crawler": "4.4.37",
"symfony/css-selector": "^6.0",
"symfony/dom-crawler": "^6.0",
"t1gor/robots-txt-parser": "^0.2.4"
},
"require-dev": {
Expand Down
Loading

0 comments on commit a2a83dc

Please sign in to comment.