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

Various fixes #3139

Merged
merged 11 commits into from May 8, 2018
4 changes: 4 additions & 0 deletions app/Exceptions/Handler.php
Expand Up @@ -129,6 +129,10 @@ protected function unauthenticated($request, AuthenticationException $exception)

private function exceptionMessage($e)
{
if ($e instanceof ModelNotFoundException) {
return;
}

if ($this->statusCode($e) >= 500) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Users/ModdingHistoryController.php
Expand Up @@ -47,7 +47,7 @@ public function __construct()
abort(404);
}

$this->searchParams = request();
$this->searchParams = request()->all();
$this->searchParams['is_moderator'] = $this->isModerator;

if (!$this->isModerator) {
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/UsersController.php
Expand Up @@ -343,7 +343,7 @@ private function parsePaginationParams()
$this->perPage = 0;
} else {
$perPage = $this->sanitizedLimitParam();
$this->perPage = min($perPage, $this->maxResults + 1 - $this->offset);
$this->perPage = min($perPage, $this->maxResults - $this->offset);
}
}

Expand Down
3 changes: 2 additions & 1 deletion app/Libraries/BBCodeFromDB.php
Expand Up @@ -221,7 +221,8 @@ public function parseProfile($text)
preg_match_all("#\[profile:{$this->uid}\](?<id>.*?)\[/profile:{$this->uid}\]#", $text, $users, PREG_SET_ORDER);

foreach ($users as $user) {
$userLink = link_to_user($user['id'], $user['id'], null);
$username = html_entity_decode_better($user['id']);
$userLink = link_to_user($username, $username, null);
$text = str_replace($user[0], $userLink, $text);
}

Expand Down
2 changes: 1 addition & 1 deletion app/Models/Elasticsearch/TopicTrait.php
Expand Up @@ -46,7 +46,7 @@ public function toEsJson()
'topic_id' => $this->topic_id,
'poster_id' => $this->topic_poster,
'forum_id' => $this->forum_id,
'post_time' => $this->topic_time->toIso8601String(),
'post_time' => json_time($this->topic_time),
'search_content' => $this->topic_title,
'type' => 'topics',
];
Expand Down
Expand Up @@ -200,7 +200,7 @@ class @BeatmapDiscussionHelper

url = new URL(urlString ? document.location.href)
params = url.searchParams
[__, pathBeatmapsets, beatmapsetId, pathDiscussions, beatmapId, mode, filter] = url.pathname.split '/'
[__, pathBeatmapsets, beatmapsetId, pathDiscussions, beatmapId, mode, filter] = url.pathname.split /\/+/

return if pathBeatmapsets != 'beatmapsets' || pathDiscussions != 'discussion'

Expand Down
170 changes: 86 additions & 84 deletions resources/assets/coffee/react/profile-page/main.coffee
Expand Up @@ -60,9 +60,6 @@ class ProfilePage.Main extends React.PureComponent
recentlyReceivedKudosu: @props.extras.recentlyReceivedKudosu
showMorePagination: {}

if @props.user.is_bot
@state.profileOrder = ['me']

for own elem, perPage of @props.perPage
@state.showMorePagination[elem] ?= {}
@state.showMorePagination[elem].hasMore = @state[elem].length > perPage
Expand Down Expand Up @@ -124,34 +121,108 @@ class ProfilePage.Main extends React.PureComponent


render: =>
withMePage = @state.userPage.initialRaw.trim() != '' || @props.withEdit
if @props.user.is_bot
profileOrder = ['me']
else
profileOrder = @state.profileOrder.slice()

profileOrder = @state.profileOrder.slice()
profileOrder.push 'account_standing' if !_.isEmpty @state.user.account_history

extraPageParams =
me:
extraClass: ('hidden' if !withMePage)
if @state.userPage.initialRaw.trim() == '' && !@props.withEdit
_.pull profileOrder, 'me'

div className: 'osu-layout osu-layout--full',
el ProfilePage.Header,
user: @state.user
stats: @state.user.statistics
currentMode: @state.currentMode
withEdit: @props.withEdit
rankHistory: @props.rankHistory

div
className: "hidden-xs page-extra-tabs #{'page-extra-tabs--floating' if @state.tabsSticky}"

div
className: 'js-sticky-header'
'data-sticky-header-target': 'page-extra-tabs'

div
className: 'page-extra-tabs__padding js-sync-height--target'
'data-sync-height-id': 'page-extra-tabs'

div
className: 'page-extra-tabs__floatable js-sync-height--reference js-switchable-mode-page--scrollspy-offset'
'data-sync-height-target': 'page-extra-tabs'
if profileOrder.length > 1
div className: 'osu-page',
div
className: 'page-mode page-mode--page-extra-tabs'
ref: (el) => @tabs = el
for m in profileOrder
a
className: "page-mode__item #{'js-sortable--tab' if @isSortablePage m}"
key: m
'data-page-id': m
onClick: @tabClick
href: "##{m}"
el ProfilePage.ExtraTab,
page: m
currentPage: @state.currentPage
currentMode: @state.currentMode

div
className: 'osu-layout__section osu-layout__section--extra'
div
className: 'osu-layout__row'
ref: (el) => @pages = el
@extraPage name for name in profileOrder


_tabsStick: (_e, target) =>
newState = (target == 'page-extra-tabs')
@setState(tabsSticky: newState) if newState != @state.tabsSticky


extraPage: (name) =>
{extraClass, props, component} = @extraPageParams name
topClassName = 'js-switchable-mode-page--scrollspy js-switchable-mode-page--page'
topClassName += ' js-sortable--page' if @isSortablePage name
props.withEdit = @props.withEdit
props.name = name

@extraPages ?= {}

div
key: name
'data-page-id': name
className: "#{topClassName} #{extraClass}"
ref: (el) => @extraPages[name] = el
el component, props


extraPageParams: (name) =>
switch name
when 'me'
props:
userPage: @state.userPage
user: @state.user
component: ProfilePage.UserPage

recent_activity:
when 'recent_activity'
props:
pagination: @state.showMorePagination
recentActivity: @state.recentActivity
user: @state.user
component: ProfilePage.RecentActivity

kudosu:
when 'kudosu'
props:
user: @state.user
recentlyReceivedKudosu: @state.recentlyReceivedKudosu
pagination: @state.showMorePagination
component: ProfilePage.Kudosu

top_ranks:
when 'top_ranks'
props:
user: @state.user
scoresBest: @state.scoresBest
Expand All @@ -160,7 +231,7 @@ class ProfilePage.Main extends React.PureComponent
pagination: @state.showMorePagination
component: ProfilePage.TopRanks

beatmaps:
when 'beatmaps'
props:
user: @state.user
favouriteBeatmapsets: @state.favouriteBeatmapsets
Expand All @@ -175,15 +246,15 @@ class ProfilePage.Main extends React.PureComponent
pagination: @state.showMorePagination
component: ProfilePage.Beatmaps

medals:
when 'medals'
props:
achievements: @props.achievements
userAchievements: @props.userAchievements
currentMode: @state.currentMode
user: @state.user
component: ProfilePage.Medals

historical:
when 'historical'
props:
beatmapPlaycounts: @state.beatmapPlaycounts
scoresRecent: @state.scoresRecent
Expand All @@ -192,80 +263,11 @@ class ProfilePage.Main extends React.PureComponent
pagination: @state.showMorePagination
component: ProfilePage.Historical

account_standing:
when 'account_standing'
props:
user: @state.user
component: ProfilePage.AccountStanding

div className: 'osu-layout osu-layout--full',
el ProfilePage.Header,
user: @state.user
stats: @state.user.statistics
currentMode: @state.currentMode
withEdit: @props.withEdit
rankHistory: @props.rankHistory

div
className: "hidden-xs page-extra-tabs #{'page-extra-tabs--floating' if @state.tabsSticky}"

div
className: 'js-sticky-header'
'data-sticky-header-target': 'page-extra-tabs'

div
className: 'page-extra-tabs__padding js-sync-height--target'
'data-sync-height-id': 'page-extra-tabs'

div
className: 'page-extra-tabs__floatable js-sync-height--reference js-switchable-mode-page--scrollspy-offset'
'data-sync-height-target': 'page-extra-tabs'
div className: 'osu-page',
div
className: 'page-mode page-mode--page-extra-tabs'
ref: (el) => @tabs = el
for m in profileOrder
continue if m == 'me' && !withMePage

a
className: "page-mode__item #{'js-sortable--tab' if @isSortablePage m}"
key: m
'data-page-id': m
onClick: @tabClick
href: "##{m}"
el ProfilePage.ExtraTab,
page: m
currentPage: @state.currentPage
currentMode: @state.currentMode

div
className: 'osu-layout__section osu-layout__section--extra'
div
className: 'osu-layout__row'
ref: (el) => @pages = el
for name in profileOrder
@extraPage name, extraPageParams[name]


_tabsStick: (_e, target) =>
newState = (target == 'page-extra-tabs')
@setState(tabsSticky: newState) if newState != @state.tabsSticky


extraPage: (name, {extraClass, props, component}) =>
topClassName = 'js-switchable-mode-page--scrollspy js-switchable-mode-page--page'
topClassName += ' js-sortable--page' if @isSortablePage name
props.withEdit = @props.withEdit
props.name = name

@extraPages ?= {}

div
key: name
'data-page-id': name
className: "#{topClassName} #{extraClass}"
ref: (el) => @extraPages[name] = el
el component, props


showMore: (e, {showMoreLink}) =>
propertyName = showMoreLink.dataset.showMore
Expand Down