-
Notifications
You must be signed in to change notification settings - Fork 384
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
base: master
Are you sure you want to change the base?
Add platform issue tags #11428
Changes from all commits
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 |
---|---|---|
|
@@ -103,6 +103,12 @@ class Topic extends Model implements AfterCommit | |
'topic_title' => 100, | ||
]; | ||
|
||
const PLATFORM_ISSUE_TAGS = [ | ||
'lazer', | ||
'stable', | ||
'web', | ||
]; | ||
|
||
const VIEW_COUNT_INTERVAL = 86400; // 1 day | ||
|
||
protected $table = 'phpbb_topics'; | ||
|
@@ -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
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. probably move this logic to its own method cuz it comes up 3 times ( alternatively include the prefix in each PLATFORM_ISSUE_TAGS |
||
|
||
if (!$this->hasIssueTag($tag)) { | ||
$this->topic_title = "[{$tag}] {$this->topic_title}"; | ||
} | ||
|
@@ -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( | ||
'/ +/', | ||
' ', | ||
|
@@ -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; | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -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'; | ||||||
} | ||||||
} | ||||||
|
||||||
|
@@ -1100,6 +1100,15 @@ function concat_path($paths) | |||||
return implode('/', array_filter($paths, 'present')); | ||||||
} | ||||||
|
||||||
function platform_issue_text($issue) | ||||||
{ | ||||||
return match ($issue) { | ||||||
'lazer' => 'laz', | ||||||
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.
Suggested change
|
||||||
'stable' => 'stb', | ||||||
'web' => 'web', | ||||||
}; | ||||||
} | ||||||
|
||||||
function proxy_media($url) | ||||||
{ | ||||||
if (!present($url)) { | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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)) | ||
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. view |
||
<i class="{{ issue_icon($issueTag) }}"></i> | ||
@elseif (in_array($issueTag, $topic::PLATFORM_ISSUE_TAGS, true)) | ||
{{ platform_issue_text($issueTag) }} | ||
@endif | ||
</span> | ||
</button> |
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', | ||
]) |
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', | ||
]) |
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', | ||
]) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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}") | ||
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. or @include('forum.topics._issue_tag', ['issueTag' => $type]) and no extra blade templates |
||
@endforeach | ||
@endif | ||
|
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.
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)