-
Notifications
You must be signed in to change notification settings - Fork 387
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Show legacy forum icons on topic listing, posts, and post search #11277
base: master
Are you sure you want to change the base?
Changes from all commits
6c6a7b8
077f8bf
891581d
72b88e3
b7c6b0b
c0a70b9
2d90599
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the GNU Affero General Public License v3.0. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
namespace App\Models\Forum; | ||
|
||
/** | ||
* Icons used to label various models from phpBB. On the old website, they were | ||
* available for use, but now they are read-only. | ||
* | ||
* @property bool $display_on_posting | ||
* @property int $icons_height | ||
* @property int $icons_id | ||
* @property int $icons_order | ||
* @property string $icons_url | ||
* @property int $icons_width | ||
*/ | ||
class LegacyIcon extends Model | ||
{ | ||
public $timestamps = false; | ||
|
||
protected $casts = ['display_on_posting' => 'boolean']; | ||
protected $primaryKey = 'icons_id'; | ||
protected $table = 'phpbb_icons'; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the GNU Affero General Public License v3.0. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Singletons; | ||
|
||
use App\Models\Forum\LegacyIcon; | ||
use App\Traits\Memoizes; | ||
use Illuminate\Database\Eloquent\Collection; | ||
|
||
class ForumLegacyIcons | ||
{ | ||
use Memoizes; | ||
|
||
/** | ||
* Get a legacy forum icon by its ID. | ||
*/ | ||
public function byId(int $id): ?LegacyIcon | ||
{ | ||
return $this->allById()->get($id); | ||
} | ||
|
||
/** | ||
* @return Collection<int, LegacyIcon> | ||
*/ | ||
private function allById(): Collection | ||
{ | ||
return $this->memoize(__FUNCTION__, fn () => LegacyIcon::all()->keyBy('icons_id')); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the GNU Affero General Public License v3.0. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
declare(strict_types=1); | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
return new class extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
*/ | ||
public function up(): void | ||
{ | ||
if (Schema::hasTable('phpbb_icons')) { | ||
return; | ||
} | ||
|
||
Schema::create('phpbb_icons', function (Blueprint $table) { | ||
$table->mediumIncrements('icons_id'); | ||
$table->string('icons_url')->default(''); | ||
$table->tinyInteger('icons_width')->default(0); | ||
$table->tinyInteger('icons_height')->default(0); | ||
$table->unsignedMediumInteger('icons_order')->default(0); | ||
$table->boolean('display_on_posting')->default(true); | ||
|
||
$table->index(['display_on_posting'], 'display_on_posting'); | ||
Comment on lines
+24
to
+31
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could use a double-check for accuracy bc I just copied thsi from phpbb3.0 |
||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
*/ | ||
public function down(): void | ||
{ | ||
Schema::drop('phpbb_icons'); | ||
} | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the GNU Affero General Public License v3.0. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
.forum-legacy-icon { | ||
margin: 0 5px; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this can use gap on __icons instead |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{{-- | ||
Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the GNU Affero General Public License v3.0. | ||
See the LICENCE file in the repository root for full licence text. | ||
--}} | ||
<img | ||
alt="" | ||
class="forum-legacy-icon" | ||
src="{{ osu_url('forum_legacy_icons') }}/{{ $icon->icons_url }}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the url generation should be the icon's method |
||
width="{{ $icon->icons_width }}" | ||
height="{{ $icon->icons_height }}" | ||
/> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,11 @@ | |
> | ||
<img class="search-forum-post__avatar-image" src="{{ $user->user_avatar }}"> | ||
</a> | ||
|
||
@if ($post->legacyIcon() !== null) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Icons should go before or after the title, or in the information lines at the bottom, imo. It should definitely not be shifting the layout of entire blocks. |
||
@include('forum._legacy_icon', ['icon' => $post->legacyIcon()]) | ||
@endif | ||
|
||
<div class="search-forum-post__content"> | ||
@if (isset($title)) | ||
<div class="search-forum-post__text search-forum-post__text--title"> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't seem it's used frequently enough to warrant this (and all the usage seems involve querying the post/topic)