#111: Fleshed out the content of the Explore Photographers page. Also added a redirect to the activity feed if accessing the dashboard and logging in

This commit is contained in:
Andy Heathershaw 2018-11-18 09:07:13 +00:00
parent 42a1e4b770
commit 386bd30208
10 changed files with 181 additions and 8 deletions

View File

@ -96,6 +96,16 @@ class MiscHelper
];
}
public static function ensureHasTrailingSlash($string)
{
if (strlen($string) > 0 && substr($string, strlen($string) - 1, 1) != '/')
{
$string .= '/';
}
return $string;
}
public static function getEnvironmentFilePath()
{
return sprintf('%s/.env', dirname(dirname(__DIR__)));

View File

@ -4,6 +4,7 @@ namespace App\Http\Controllers\Auth;
use App\Facade\Theme;
use App\Facade\UserConfig;
use App\Helpers\MiscHelper;
use App\Http\Controllers\Controller;
use App\User;
use Illuminate\Contracts\Routing\UrlGenerator;
@ -30,6 +31,9 @@ class LoginController extends Controller
use AuthenticatesUsers;
/**
* @var UrlGenerator
*/
protected $generator;
/**
@ -37,7 +41,7 @@ class LoginController extends Controller
*
* @var string
*/
protected $redirectTo = '/';
protected $redirectTo = '/me';
/**
* Create a new controller instance.
@ -101,7 +105,15 @@ class LoginController extends Controller
*/
public function showLoginForm(Request $request)
{
$request->getSession()->put('url.intended', $this->generator->previous(false));
$previousUrl = MiscHelper::ensureHasTrailingSlash($this->generator->previous(false));
$homeUrl = MiscHelper::ensureHasTrailingSlash(route('home'));
if (UserConfig::get('social_user_feeds') && (empty($previousUrl) || $previousUrl == $homeUrl))
{
$previousUrl = route('userActivityFeed');
}
$request->getSession()->put('url.intended', $previousUrl);
return Theme::render('auth.v2_unified', [
'active_tab' => 'login',

View File

@ -0,0 +1,41 @@
<?php
namespace App\Http\Controllers\Gallery;
use App\Facade\Theme;
use App\Facade\UserConfig;
use App\Http\Controllers\Controller;
use App\User;
use App\UserFollower;
class ExploreController extends Controller
{
public function users()
{
if (!UserConfig::get('social_user_profiles'))
{
return redirect(route('home'));
}
$users = User::where([
'is_activated' => true,
'enable_profile_page' => true
])
->orderBy('name')
->paginate(UserConfig::get('items_per_page'));
$usersFollowing = UserFollower::where('user_id', $this->getUser()->id)
->select('following_user_id')
->get()
->map(function($f)
{
return $f->following_user_id;
})
->toArray();
return Theme::render('gallery.explore_users', [
'users' => $users,
'users_following' => $usersFollowing
]);
}
}

9
app/UserFollower.php Normal file
View File

@ -0,0 +1,9 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class UserFollower extends Model
{
}

View File

@ -0,0 +1,17 @@
<?php
use App\DataMigration;
use Illuminate\Support\Facades\DB;
class DataMigrationV2_2_0_alpha_1 extends DataMigration
{
public function getVersion()
{
return '2.2.0-alpha.1';
}
public function run($currentVersion)
{
//DB::insert('INSERT INTO user_activity ()')
}
}

View File

@ -15,6 +15,13 @@ return [
'child_albums' => 'more album|more albums',
'date_taken' => 'Date taken:',
'date_uploaded' => 'Date uploaded:',
'explore_users' => [
'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.',
'title' => 'Explore Photographers'
],
'file_name' => 'File name:',
'focal_length' => 'Focal length:',
'focal_length_units' => ':valuemm',
@ -78,9 +85,10 @@ return [
'uploaded_12_months' => 'Photos uploaded in the last 12 months',
],
'user_activity_feed' => [
'explore_photographers_link' => 'Explore Photographers',
'no_activity_p1' => 'Nothing to see here',
'no_activity_p2' => 'There is no recent activity to show you.',
'no_activity_p3' => 'Find someone new to follow on the :l_explore_startPhotographer Explorer:l_explore_end page.',
'no_activity_p3' => 'Find someone new to follow on the :l_explore_startExplore Photographers:l_explore_end page.',
'title' => 'My Activity Feed'
],
'user_feed_type' => [

View File

@ -23,6 +23,7 @@ return [
'edit_storage' => 'Edit storage location',
'edit_user' => 'Edit user',
'exif_data' => 'Exif Data',
'explore_users' => 'Explore Photographers',
'groups' => 'Groups',
'home' => 'Gallery',
'labels' => 'Labels',

View File

@ -0,0 +1,74 @@
@extends(Theme::viewName('layout'))
@section('title', trans('gallery.explore_users.title'))
@section('breadcrumb')
<li class="breadcrumb-item"><a href="{{ route('home') }}"><i class="fa fa-fw fa-home"></i></a></li>
<li class="breadcrumb-item active">@lang('navigation.breadcrumb.explore_users')</li>
@endsection
@section('content')
<div class="container" id="user-app">
<div class="row">
<div class="col">
@if ($users->count() > 0)
<h1>@yield('title')</h1>
<p class="mb-1">@lang('gallery.explore_users.intro_p1')</p>
<p>@lang('gallery.explore_users.intro_p2')</p>
<hr class="mt-4 mb-4"/>
@foreach ($users as $user)
<div class="row">
<div id="user-avatar" class="col-sm-3 col-md-2 col-xl-1 mb-3">
<img src="{{ Theme::gravatarUrl($user->email, 64) }}" title="{{ $user->name }}" class="rounded">
</div>
<div class="col-sm-9 col-md-10 col-xl-11">
@if ($user->id != Auth::user()->id)
@if (in_array($user->id, $users_following))
<button class="btn btn-outline-primary pull-right"><i class="fa fa-fw fa-check"></i> @lang('gallery.explore_users.following_button')</button>
@else
<button class="btn btn-primary pull-right">@lang('gallery.explore_users.follow_button')</button>
@endif
@endif
<h2 class="h3"><a href="{{ $user->profileUrl() }}">{{ $user->name }}</a></h2>
<h3 class="h5 text-muted mt-1">{{ $user->profile_alias }}</h3>
</div>
</div>
@if (!$loop->last)
<hr class="mt-2 mb-4"/>
@endif
@endforeach
<div class="row mt-3">
<div class="col text-center">
{{ $users->links() }}
</div>
</div>
@else
<div class="text-center">
<h4 class="text-danger"><b>@lang('gallery.user_activity_feed.no_activity_p1')</b></h4>
<p>@lang('gallery.user_activity_feed.no_activity_p2')</p>
<p>@lang('gallery.user_activity_feed.no_activity_p3', [
'l_explore_start' => sprintf('<a href="%s">', route('exploreUsers')),
'l_explore_end' => '</a>'
])</p>
<p class="mt-4"><a href="{{ route('exploreUsers') }}" class="btn btn-primary btn-lg"><i class="fa fa-fw fa-search"></i> @lang('gallery.user_activity_feed.explore_photographers_link')</a></p>
</div>
@endif
</div>
</div>
</div>
@endsection
@push('scripts')
<script type="text/javascript">
var viewModel = new UserViewModel({
current_url: '{{ url()->current() }}',
feed_url: '{{ $user->feedJsonUrl() }}',
follow_user_url: '{{ $user->followUrl() }}',
unfollow_user_url: '{{ $user->unFollowUrl() }}'
});
var app = new Vue(viewModel);
app.user_id = '{{ Auth::user()->id }}';
</script>
@endpush

View File

@ -35,9 +35,10 @@
<h4 class="text-danger"><b>@lang('gallery.user_activity_feed.no_activity_p1')</b></h4>
<p>@lang('gallery.user_activity_feed.no_activity_p2')</p>
<p>@lang('gallery.user_activity_feed.no_activity_p3', [
'l_explore_start' => sprintf('<a href="%s">', route('userExplore')),
'l_explore_start' => sprintf('<a href="%s">', route('exploreUsers')),
'l_explore_end' => '</a>'
])</p>
<p class="mt-4"><a href="{{ route('exploreUsers') }}" class="btn btn-primary btn-lg"><i class="fa fa-fw fa-search"></i> @lang('gallery.user_activity_feed.explore_photographers_link')</a></p>
</div>
</div>
</div>

View File

@ -152,14 +152,14 @@ Route::post('u/{idOrAlias}/unfollow', 'Gallery\UserController@unFollowUser', ['m
Route::get('u/{idOrAlias}', 'Gallery\UserController@show')
->name('viewUser')
->where('idOrAlias', '.*');
Route::get('me', 'Gallery\UserController@activityFeed')
Route::get('activity', 'Gallery\UserController@activityFeed')
->name('userActivityFeed')
->middleware('auth');
Route::get('explore', 'Gallery\UserController@exploreProfiles')
->name('userExplore');
Route::get('me.json', 'Gallery\UserController@activityFeedJson')
Route::get('activity.json', 'Gallery\UserController@activityFeedJson')
->name('userActivityFeedJson')
->middleware('auth');
Route::get('explore/users', 'Gallery\ExploreController@users')
->name('exploreUsers');
Route::get('me/confirm-email-change', 'Gallery\UserController@confirmEmailChangeState')
->name('userSettings.confirmEmailChangeState')
->middleware('auth');