Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into config-globals
Browse files Browse the repository at this point in the history
  • Loading branch information
nanaya committed Nov 13, 2023
2 parents 9b88449 + a7f0f23 commit 7fd986c
Show file tree
Hide file tree
Showing 48 changed files with 406 additions and 401 deletions.
6 changes: 5 additions & 1 deletion app/Libraries/ApidocRouteHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ public static function scopeBadge($scope)
{
$scopeLower = strtolower($scope);

return \Html::link("#scope-{$scopeLower}", $scope, ['class' => "badge badge-scope badge-scope-{$scopeLower}"]);
return link_to(
"#scope-{$scopeLower}",
$scope,
['class' => "badge badge-scope badge-scope-{$scopeLower}"],
);
}


Expand Down
3 changes: 2 additions & 1 deletion app/Transformers/SeasonalBackgroundTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

namespace App\Transformers;

use App\Libraries\StorageUrl;
use App\Models\UserContestEntry;

class SeasonalBackgroundTransformer extends TransformerAbstract
Expand All @@ -25,7 +26,7 @@ public function transform(UserContestEntry $entry)
{
return [
// files generated by process separate from osu-web
'url' => $entry->storage()->url("{$entry->fileDir()}/{$entry->hash}_opt.jpg"),
'url' => StorageUrl::make(null, "{$entry->fileDir()}/{$entry->hash}_opt.jpg"),
];
}

Expand Down
55 changes: 30 additions & 25 deletions app/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -622,12 +622,20 @@ function product_quantity_options($product, $selected = null)

$opts = [];
for ($i = 1; $i <= $max; $i++) {
$opts[$i] = osu_trans_choice('common.count.item', $i);
$opts[] = [
'label' => osu_trans_choice('common.count.item', $i),
'selected' => $i === $selected,
'value' => $i,
];
}

// include selected value separately if it's out of range.
if ($selected > $max) {
$opts[$selected] = osu_trans_choice('common.count.item', $selected);
if ($selected !== null && $selected > $max) {
$opts[] = [
'label' => osu_trans_choice('common.count.item', $selected),
'selected' => true,
'value' => $selected,
];
}

return $opts;
Expand Down Expand Up @@ -664,13 +672,16 @@ function request_country($request = null)
: $request->header('CF_IPCOUNTRY');
}

function require_login($text_key, $link_text_key)
function require_login($textKey, $linkTextKey)
{
$title = osu_trans('users.anonymous.login_link');
$link = Html::link('#', osu_trans($link_text_key), ['class' => 'js-user-link', 'title' => $title]);
$text = osu_trans($text_key, ['link' => $link]);

return $text;
return osu_trans($textKey, ['link' => link_to(
'#',
osu_trans($linkTextKey),
[
'class' => 'js-user-link',
'title' => osu_trans('users.anonymous.login_link'),
],
)]);
}

function spinner(?array $modifiers = null)
Expand Down Expand Up @@ -719,22 +730,6 @@ function obscure_email($email)
return mb_substr($email[0], 0, 1).'***'.'@'.$email[1];
}

function countries_array_for_select()
{
$out = [];

foreach (App\Models\Country::forStore()->get() as $country) {
if (!isset($lastDisplay)) {
$lastDisplay = $country->display;
} elseif ($lastDisplay !== $country->display) {
$out['_disabled'] = '---';
}
$out[$country->acronym] = $country->name;
}

return $out;
}

function currency($price, $precision = 2, $zeroShowFree = true)
{
$price = round($price, $precision);
Expand Down Expand Up @@ -933,6 +928,11 @@ function timeago($date)
return "<time class='js-timeago' datetime='{$formatted}'>{$formatted}</time>";
}

function link_to(string $url, HtmlString|string $text, array $attributes = []): HtmlString
{
return blade_safe(tag('a', [...$attributes, 'href' => $url], make_blade_safe($text)));
}

function link_to_user($id, $username = null, $color = null, $classNames = null)
{
if ($id instanceof App\Models\User) {
Expand Down Expand Up @@ -962,6 +962,11 @@ function link_to_user($id, $username = null, $color = null, $classNames = null)
}
}

function make_blade_safe(HtmlString|string $text): HtmlString
{
return $text instanceof HtmlString ? $text : blade_safe(e($text));
}

function issue_icon($issue)
{
switch ($issue) {
Expand Down
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
"laravel/passport": "*",
"laravel/slack-notification-channel": "*",
"laravel/tinker": "*",
"laravelcollective/html": "*",
"league/commonmark": "^2.0",
"league/flysystem-aws-s3-v3": "*",
"league/fractal": "*",
Expand Down
75 changes: 1 addition & 74 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,6 @@
Illuminate\Validation\ValidationServiceProvider::class,
Illuminate\View\ViewServiceProvider::class,

Collective\Html\HtmlServiceProvider::class,
/*
* Package Service Providers...
*/
Expand Down Expand Up @@ -253,9 +252,6 @@
// renamed to avoid conflict with PhpRedis
'LaravelRedis' => Illuminate\Support\Facades\Redis::class,

'Form' => Collective\Html\FormFacade::class,
'Html' => Collective\Html\HtmlFacade::class,

'GitHub' => GrahamCampbell\GitHub\Facades\GitHub::class,

'Datadog' => ChaseConey\LaravelDatadogHelper\Datadog::class,
Expand Down
9 changes: 6 additions & 3 deletions resources/js/beatmaps/search-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,10 @@ export class SearchPanel extends React.Component<Props> {
this.controller.filters.update('query', this.query);
};

private readonly onKeyUp = (event: React.KeyboardEvent<HTMLInputElement>) => {
// TODO: deprecated event. Update to onbeforeinput once safari adds it on normal enter
// (or maybe change to form and intercept onsubmit instead)
// This shouldn't trigger during ime composition
private readonly onKeyPress = (event: React.KeyboardEvent<HTMLInputElement>) => {
if (event.key === 'Enter') {
htmlElementOrNull(event.target)?.blur();
}
Expand Down Expand Up @@ -160,7 +163,7 @@ export class SearchPanel extends React.Component<Props> {
className='beatmapsets-search__input js-beatmapsets-search-input'
name='search'
onChange={this.onChange}
onKeyUp={this.onKeyUp}
onKeyPress={this.onKeyPress}
placeholder={trans('beatmaps.listing.search.prompt')}
type='search'
value={this.query}
Expand Down Expand Up @@ -192,7 +195,7 @@ export class SearchPanel extends React.Component<Props> {
className='beatmapsets-search__input js-beatmapsets-search-input'
name='search'
onChange={this.onChange}
onKeyUp={this.onKeyUp}
onKeyPress={this.onKeyPress}
placeholder={trans('beatmaps.listing.search.prompt')}
type='search'
value={this.query}
Expand Down
4 changes: 2 additions & 2 deletions resources/js/beatmapsets-show/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export default class Header extends React.Component<Props> {
<span className='beatmapset-header__details-text beatmapset-header__details-text--title'>
<a
className='beatmapset-header__details-text-link'
href={route('beatmapsets.index', { q: getTitle(this.controller.beatmapset) })}
href={route('beatmapsets.index', { q: `title=""${getTitle(this.controller.beatmapset)}""` })}
>
{getTitle(this.controller.beatmapset)}
</a>
Expand All @@ -157,7 +157,7 @@ export default class Header extends React.Component<Props> {
<span className='beatmapset-header__details-text beatmapset-header__details-text--artist'>
<a
className='beatmapset-header__details-text-link'
href={route('beatmapsets.index', { q: getArtist(this.controller.beatmapset) })}
href={route('beatmapsets.index', { q: `artist=""${getArtist(this.controller.beatmapset)}""` })}
>
{getArtist(this.controller.beatmapset)}
</a>
Expand Down
2 changes: 1 addition & 1 deletion resources/js/beatmapsets-show/info.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export default class Info extends React.Component<Props> {
</h3>
<a
className='beatmapset-info__link'
href={route('beatmapsets.index', { q: this.controller.beatmapset.source })}
href={route('beatmapsets.index', { q: `source=""${this.controller.beatmapset.source}""` })}
>
{this.controller.beatmapset.source}
</a>
Expand Down
10 changes: 0 additions & 10 deletions resources/js/shared.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,6 @@ $(document).on 'click', '#popup-container, #overlay', (e) ->
$popup.fadeOut null, -> $popup.remove()


###
# Add `disabled` attribute to form element with value _disabled.
# Currently used to work around Form::select (in store checkout -
# new address form - country selection) since it doesn't support
# adding a disabled value.
###
$(document).on 'turbolinks:load', ->
$('[value=_disabled]').attr 'disabled', true


###
# Click anywhere on row to click the main link!
# Usage:
Expand Down
4 changes: 4 additions & 0 deletions resources/lang/en/store.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,10 @@
'username_change' => [
'check' => 'Enter a username to check availability!',
'checking' => 'Checking availability of :username...',
'placeholder' => 'Requested Username',
'label' => 'New Username',
'current' => 'Your current username is ":username".',

'require_login' => [
'_' => 'You need to be :link to change your name!',
'link_text' => 'signed in',
Expand Down
2 changes: 1 addition & 1 deletion resources/lang/hu/notifications.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
'beatmapset_discussion_post_new_empty' => 'Új poszt a ":title"-on :username:-tol',
'beatmapset_discussion_post_new_compact' => 'Új hozzászólás :username által: ":content"',
'beatmapset_discussion_post_new_compact_empty' => 'Új poszt :username által',
'beatmapset_discussion_review_new' => 'Új hozzászolás problémákat tartalmazó tartalomról :username által, ezen a beatmapen: ":title"
'beatmapset_discussion_review_new' => 'Új hozzászolás problémákat tartalmazó tartalomról :username által, ezen a beatmapen: ":title"
:problems, javaslat :suggestions, dícséret: :praises',
'beatmapset_discussion_review_new_compact' => 'Új hozzászolás problémákat tartalmazó tartalomról :username által: :problems, javaslat :suggestions, dícséret: :praises',
'beatmapset_discussion_unlock' => 'A beszélgetést feloldották ezen: ":title"',
Expand Down
13 changes: 6 additions & 7 deletions resources/views/accounts/_edit_country.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,16 @@
@if ($countryChangeTarget !== null)
<p>
{!! osu_trans('accounts.edit.profile.country_change._', [
'update_link' => tag(
'a',
'update_link' => link_to(
route('account.country', ['country_acronym' => $countryChangeTarget]),
osu_trans('accounts.edit.profile.country_change.update_link', [
'country' => app('countries')->byCode($countryChangeTarget)->name,
]),
[
'data-confirm' => osu_trans('common.confirmation'),
'data-method' => 'PUT',
'data-remote' => '1',
'href' => route('account.country', ['country_acronym' => $countryChangeTarget]),
],
osu_trans('accounts.edit.profile.country_change.update_link', [
'country' => Country::find($countryChangeTarget)->name,
]),
]
),
]) !!}
</p>
Expand Down
25 changes: 14 additions & 11 deletions resources/views/accounts/_edit_email.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
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.
--}}
{!! Form::open([
'route' => 'account.email',
'method' => 'PUT',
'data-remote' => true,
'data-skip-ajax-error-popup' => '1',
'class' => 'js-form-error js-form-clear js-account-edit account-edit'
]) !!}
<form
action="{{ route('account.email') }}"
class="js-form-error js-form-clear js-account-edit account-edit"
data-remote
data-skip-ajax-error-popup="1"
method="POST"
>
@csrf
<input name="_method" value="PUT" type="hidden" />
<div class="account-edit__section">
<h2 class="account-edit__section-title">
{{ osu_trans('accounts.edit.email.title') }}
Expand All @@ -20,9 +22,10 @@
<div class="account-edit__input-group">
<div class="account-edit-entry account-edit-entry--no-label">
<div>{!! osu_trans('accounts.edit.email.locked._', [
'accounts' => tag('a', [
'href' => 'mailto:'.$GLOBALS['cfg']['osu']['emails']['account'],
], osu_trans('accounts.edit.email.locked.accounts'))
'accounts' => link_to(
"mailto:{$GLOBALS['cfg']['osu']['emails']['account']}",
osu_trans('accounts.edit.email.locked.accounts')
)
]) !!}</div>
</div>
</div>
Expand Down Expand Up @@ -93,4 +96,4 @@ class="account-edit-entry__input js-form-confirmation"
</div>
@endif
</div>
{!! Form::close() !!}
</form>
Loading

0 comments on commit 7fd986c

Please sign in to comment.