Skip to content
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

Add platform issue tags #11428

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion app/Http/Controllers/Forum/TopicsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,11 @@ public function issueTag($id)
$state = get_bool(Request::input('state'));
$type = 'issue_tag_'.$issueTag;

if ($issueTag === null || !$topic->isIssue() || !in_array($issueTag, $topic::ISSUE_TAGS, true)) {
if (
$issueTag === null
|| !$topic->isIssue()
|| !in_array($issueTag, array_merge($topic::ISSUE_TAGS, $topic::PLATFORM_ISSUE_TAGS), true)
) {
abort(422);
}

Expand Down
18 changes: 18 additions & 0 deletions app/Models/Forum/Topic.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ class Topic extends Model implements AfterCommit
'topic_title' => 100,
];

const PLATFORM_ISSUE_TAGS = [
'lazer',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

str_slug the type (class name, translation, filename) and use the actual tag string everywhere else instead? The icon helper can just generate the full content (stb etc string for the new tags and <i ...> for everything else)

'stable',
'web',
];

const VIEW_COUNT_INTERVAL = 86400; // 1 day

protected $table = 'phpbb_topics';
Expand Down Expand Up @@ -811,6 +817,10 @@ public function setIssueTag($tag)
{
$this->topic_type = static::typeInt($tag === 'confirmed' ? 'sticky' : 'normal');

if (in_array($tag, static::PLATFORM_ISSUE_TAGS, true)) {
$tag = "osu!{$tag}";
}
Comment on lines +820 to +822
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably move this logic to its own method cuz it comes up 3 times (tagForTopicTitle() or something)

alternatively include the prefix in each PLATFORM_ISSUE_TAGS


if (!$this->hasIssueTag($tag)) {
$this->topic_title = "[{$tag}] {$this->topic_title}";
}
Expand All @@ -822,6 +832,10 @@ public function unsetIssueTag($tag)
{
$this->topic_type = static::typeInt($tag === 'resolved' ? 'sticky' : 'normal');

if (in_array($tag, static::PLATFORM_ISSUE_TAGS, true)) {
$tag = "osu!{$tag}";
}

$this->topic_title = preg_replace(
'/ +/',
' ',
Expand All @@ -833,6 +847,10 @@ public function unsetIssueTag($tag)

public function hasIssueTag($tag)
{
if (in_array($tag, static::PLATFORM_ISSUE_TAGS, true)) {
$tag = "osu!{$tag}";
}

return strpos($this->topic_title, "[{$tag}]") !== false;
}

Expand Down
13 changes: 11 additions & 2 deletions app/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -1023,12 +1023,12 @@ function issue_icon($issue)
return 'fas fa-user';
case 'confirmed':
return 'fas fa-exclamation-triangle';
case 'resolved':
return 'far fa-check-circle';
case 'duplicate':
return 'fas fa-copy';
case 'invalid':
return 'far fa-times-circle';
case 'resolved':
return 'far fa-check-circle';
}
}

Expand Down Expand Up @@ -1100,6 +1100,15 @@ function concat_path($paths)
return implode('/', array_filter($paths, 'present'));
}

function platform_issue_text($issue)
{
return match ($issue) {
'lazer' => 'laz',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lzr feels like a better acronym than laz, thoughts?

Suggested change
'lazer' => 'laz',
'lazer' => 'lzr',

'stable' => 'stb',
'web' => 'web',
};
}

function proxy_media($url)
{
if (!present($url)) {
Expand Down
21 changes: 21 additions & 0 deletions resources/lang/en/forum.php
Original file line number Diff line number Diff line change
Expand Up @@ -287,13 +287,34 @@
'to_1_done' => 'Added "invalid" tag',
],

'issue_tag_lazer' => [
'to_0' => 'Remove "osu!lazer" tag',
'to_0_done' => 'Removed "osu!lazer" tag',
'to_1' => 'Add "osu!lazer" tag',
'to_1_done' => 'Added "osu!lazer" tag',
],

'issue_tag_resolved' => [
'to_0' => 'Remove "resolved" tag',
'to_0_done' => 'Removed "resolved" tag',
'to_1' => 'Add "resolved" tag',
'to_1_done' => 'Added "resolved" tag',
],

'issue_tag_stable' => [
'to_0' => 'Remove "osu!stable" tag',
'to_0_done' => 'Removed "osu!stable" tag',
'to_1' => 'Add "osu!stable" tag',
'to_1_done' => 'Added "osu!stable" tag',
],

'issue_tag_web' => [
'to_0' => 'Remove "osu!web" tag',
'to_0_done' => 'Removed "osu!web" tag',
'to_1' => 'Add "osu!web" tag',
'to_1_done' => 'Added "osu!web" tag',
],

'lock' => [
'is_locked' => 'This topic is locked and can not be replied to',
'to_0' => 'Unlock topic',
Expand Down
6 changes: 5 additions & 1 deletion resources/views/forum/topics/_issue_tag.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ class="
data-method="post"
>
<span class="btn-circle__content">
<i class="{{ issue_icon($issueTag) }}"></i>
@if (in_array($issueTag, $topic::ISSUE_TAGS, true))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

view forum.forums._topic also needs adjustment

<i class="{{ issue_icon($issueTag) }}"></i>
@elseif (in_array($issueTag, $topic::PLATFORM_ISSUE_TAGS, true))
{{ platform_issue_text($issueTag) }}
@endif
</span>
</button>
7 changes: 7 additions & 0 deletions resources/views/forum/topics/_issue_tag_lazer.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{{--
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.
--}}
@include('forum.topics._issue_tag', [
'issueTag' => 'lazer',
])
7 changes: 7 additions & 0 deletions resources/views/forum/topics/_issue_tag_stable.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{{--
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.
--}}
@include('forum.topics._issue_tag', [
'issueTag' => 'stable',
])
7 changes: 7 additions & 0 deletions resources/views/forum/topics/_issue_tag_web.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{{--
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.
--}}
@include('forum.topics._issue_tag', [
'issueTag' => 'web',
])
2 changes: 1 addition & 1 deletion resources/views/forum/topics/_nav.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
@include('forum.topics._moderate_move', compact('topic'))

@if ($topic->isIssue())
@foreach ($topic::ISSUE_TAGS as $type)
@foreach (array_merge($topic::ISSUE_TAGS, $topic::PLATFORM_ISSUE_TAGS) as $type)
@include("forum.topics._issue_tag_{$type}")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or

@include('forum.topics._issue_tag', ['issueTag' => $type])

and no extra blade templates

@endforeach
@endif
Expand Down