diff --git a/app/User.php b/app/User.php index b4e4a8d..92a25f3 100644 --- a/app/User.php +++ b/app/User.php @@ -75,7 +75,7 @@ class User extends Authenticatable public function followUrl() { return route('followUser', [ - 'idOrAlias' => (!empty($this->profile_alias) ? trim(strtolower($this->profile_alias)) : $this->id) + 'idOrAlias' => $this->profileAliasForUrl() ]); } @@ -89,10 +89,15 @@ class User extends Authenticatable return $this->id == -1 && $this->name == 'Anonymous'; } + public function profileAliasForUrl() + { + return (!empty($this->profile_alias) ? trim(strtolower($this->profile_alias)) : $this->id); + } + public function profileUrl() { return route('viewUser', [ - 'idOrAlias' => (!empty($this->profile_alias) ? trim(strtolower($this->profile_alias)) : $this->id) + 'idOrAlias' => $this->profileAliasForUrl() ]); } @@ -104,7 +109,7 @@ class User extends Authenticatable public function unFollowUrl() { return route('unFollowUser', [ - 'idOrAlias' => (!empty($this->profile_alias) ? trim(strtolower($this->profile_alias)) : $this->id) + 'idOrAlias' => $this->profileAliasForUrl() ]); } } diff --git a/resources/assets/js/gallery.js b/resources/assets/js/gallery.js index 9fa8bb6..8dee7fa 100644 --- a/resources/assets/js/gallery.js +++ b/resources/assets/js/gallery.js @@ -1,3 +1,47 @@ +/** + * This model is used by gallery/explore_users.blade.php, to handle following/unfollowing users profiles. + * @constructor + */ +function ExploreUsersViewModel(urls) +{ + this.el = '#explore-users-app'; + + this.data = { + }; + + this.computed = { + }; + + this.methods = { + followUser: function(e) + { + var userIDToFollow = $(e.target).data('user-id'); + var urlToPost = urls.follow_user_url.replace('/-1/', '/' + userIDToFollow + '/'); + + $.post(urlToPost, '', function(data) + { + window.location.reload(true); + }); + + e.preventDefault(); + return false; + }, + unFollowUser: function(e) + { + var userIDToUnfollow = $(e.target).data('user-id'); + var urlToPost = urls.unfollow_user_url.replace('/-1/', '/' + userIDToUnfollow + '/'); + + $.post(urlToPost, '', function(data) + { + window.location.reload(true); + }); + + e.preventDefault(); + return false; + } + }; +} + /** * This model is used by gallery/photo.blade.php, to handle comments and individual photo actions. * @constructor diff --git a/resources/lang/en/gallery.php b/resources/lang/en/gallery.php index 9c2a606..bed4f39 100644 --- a/resources/lang/en/gallery.php +++ b/resources/lang/en/gallery.php @@ -19,7 +19,8 @@ return [ 'follow_button' => 'Follow', 'following_button' => 'Following', 'intro_p1' => 'The users listed below have registered on this site and enabled their public profile.', - 'intro_p2' => 'Click a name to view their profile, or click the Follow button to follow them and see their activity in your activity feed.', + 'intro_p2' => 'Click a name to view their profile', + 'intro_p2_logged_in' => ', or click the Follow button to follow them and see their activity in your activity feed', 'title' => 'Explore Photographers' ], 'file_name' => 'File name:', diff --git a/resources/views/themes/base/gallery/explore_users.blade.php b/resources/views/themes/base/gallery/explore_users.blade.php index fda541b..5c2bf05 100644 --- a/resources/views/themes/base/gallery/explore_users.blade.php +++ b/resources/views/themes/base/gallery/explore_users.blade.php @@ -7,13 +7,15 @@ @endsection @section('content') -
+
@if ($users->count() > 0)

@yield('title')

@lang('gallery.explore_users.intro_p1')

-

@lang('gallery.explore_users.intro_p2')

+

+ @lang('gallery.explore_users.intro_p2')@if (!Auth::guest())@lang('gallery.explore_users.intro_p2_logged_in')@endif. +


@foreach ($users as $user) @@ -22,11 +24,11 @@
- @if ($user->id != Auth::user()->id) + @if (!Auth::guest() && $user->id != Auth::user()->id) @if (in_array($user->id, $users_following)) - + @else - + @endif @endif

{{ $user->name }}

@@ -61,14 +63,11 @@ @push('scripts') @endpush \ No newline at end of file