From d4b5612deeda8943c09c1514ea03311b16b2d7bc Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 9 Dec 2018 15:34:05 -0700 Subject: [PATCH 01/22] Update PostComponent.vue --- .../assets/js/components/PostComponent.vue | 33 +++++++++++++++---- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/resources/assets/js/components/PostComponent.vue b/resources/assets/js/components/PostComponent.vue index 41cade86..90f6cd82 100644 --- a/resources/assets/js/components/PostComponent.vue +++ b/resources/assets/js/components/PostComponent.vue @@ -4,12 +4,26 @@ max-height: 70vh; overflow-y: scroll; } + +.postPresenterContainer { + background: #000; +} + +.status-comments, +.reactions, +.col-md-4 { + background: #fff; +} + +.postPresenterContainer { + min-height: 600px; +} From cdee4f863f8cb1e6a7cd6280b7b7d1ccfd145d1b Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 9 Dec 2018 22:43:47 -0700 Subject: [PATCH 12/22] Update Timeline.vue component, add video album and photo video album renderers --- resources/assets/js/components/Timeline.vue | 40 ++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/resources/assets/js/components/Timeline.vue b/resources/assets/js/components/Timeline.vue index 7f0ae06d..c9026817 100644 --- a/resources/assets/js/components/Timeline.vue +++ b/resources/assets/js/components/Timeline.vue @@ -72,7 +72,7 @@
-
+
+ + + + + +
+ +
+ + + + + + + +

Error: Problem rendering preview.

+ +
+
+
+

Error: Problem rendering preview.

From 45f52ece0a0d7c8154fed0238c9c6f333b13b4ff Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 9 Dec 2018 22:59:38 -0700 Subject: [PATCH 13/22] Update Timeline.vue component, remove posts after muting or blocking an account --- resources/assets/js/components/Timeline.vue | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/resources/assets/js/components/Timeline.vue b/resources/assets/js/components/Timeline.vue index c9026817..e2b3b81f 100644 --- a/resources/assets/js/components/Timeline.vue +++ b/resources/assets/js/components/Timeline.vue @@ -405,11 +405,11 @@ if($('body').hasClass('loggedIn') == false) { return; } - axios.post('/i/mute', { type: 'user', item: status.account.id }).then(res => { + this.feed = this.feed.filter(s => s.account.id !== status.account.id); swal('Success', 'You have successfully muted ' + status.account.acct, 'success'); }).catch(err => { swal('Error', 'Something went wrong. Please try again later.', 'error'); @@ -425,7 +425,8 @@ type: 'user', item: status.account.id }).then(res => { - swal('Success', 'You have successfully blocked ' + status.account.acct, 'success.'); + this.feed = this.feed.filter(s => s.account.id !== status.account.id); + swal('Success', 'You have successfully blocked ' + status.account.acct, 'success'); }).catch(err => { swal('Error', 'Something went wrong. Please try again later.', 'error'); }); @@ -440,8 +441,8 @@ type: 'status', item: status.id }).then(res => { - swal('Success', 'You have successfully deleted this post', 'success'); this.feed.splice(index,1); + swal('Success', 'You have successfully deleted this post', 'success'); }).catch(err => { swal('Error', 'Something went wrong. Please try again later.', 'error'); }); From 8d930964470b8713a2269a83db6a894cc667fd8b Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 9 Dec 2018 23:53:25 -0700 Subject: [PATCH 14/22] Update Timeline.vue component, add CW to other types and prevent carousel from automatically rotating --- resources/assets/js/components/Timeline.vue | 151 +++++++++++++++----- 1 file changed, 112 insertions(+), 39 deletions(-) diff --git a/resources/assets/js/components/Timeline.vue b/resources/assets/js/components/Timeline.vue index e2b3b81f..47787135 100644 --- a/resources/assets/js/components/Timeline.vue +++ b/resources/assets/js/components/Timeline.vue @@ -72,55 +72,128 @@
- - - - - +
+
+ +

{{ status.spoiler_text ? status.spoiler_text : 'CW / NSFW / Hidden Media'}}

+

(click to show)

+
+ + + + + +
+
+
+ + + + + +
- - - - - +
+
+ +

{{ status.spoiler_text ? status.spoiler_text : 'CW / NSFW / Hidden Media'}}

+

(click to show)

+
+ + + + + +
+
+
+ + + + + +
- - +
+
+ +

{{ status.spoiler_text ? status.spoiler_text : 'CW / NSFW / Hidden Media'}}

+

(click to show)

+
+ + - + - + -

Error: Problem rendering preview.

+

Error: Problem rendering preview.

-
-
+ + +
+
+
+ + + + + + + +

Error: Problem rendering preview.

+ +
+
+
From 0870b72a9761e19ac357115a97f6431cc6bbef8b Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Mon, 10 Dec 2018 12:00:50 -0700 Subject: [PATCH 15/22] Update NotificationTransformer --- app/Transformer/Api/NotificationTransformer.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/Transformer/Api/NotificationTransformer.php b/app/Transformer/Api/NotificationTransformer.php index d5afa1b6..16d537c9 100644 --- a/app/Transformer/Api/NotificationTransformer.php +++ b/app/Transformer/Api/NotificationTransformer.php @@ -45,6 +45,7 @@ class NotificationTransformer extends Fractal\TransformerAbstract 'mention' => 'mention', 'reblog' => 'share', 'like' => 'favourite', + 'comment' => 'comment', ]; return $verbs[$verb]; } From a774ad7373b5ee279b07d702e3cbad5e969f0388 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Mon, 10 Dec 2018 20:36:27 -0700 Subject: [PATCH 16/22] Update InternalApiController --- .../Controllers/InternalApiController.php | 31 ------------------- 1 file changed, 31 deletions(-) diff --git a/app/Http/Controllers/InternalApiController.php b/app/Http/Controllers/InternalApiController.php index fbab7a46..fb4cdcde 100644 --- a/app/Http/Controllers/InternalApiController.php +++ b/app/Http/Controllers/InternalApiController.php @@ -94,37 +94,6 @@ class InternalApiController extends Controller return $status->url(); } - public function notifications(Request $request) - { - $this->validate($request, [ - 'page' => 'nullable|min:1|max:3', - ]); - - $profile = Auth::user()->profile; - $timeago = Carbon::now()->subMonths(6); - $notifications = Notification::with('actor') - ->whereProfileId($profile->id) - ->whereDate('created_at', '>', $timeago) - ->orderBy('id', 'desc') - ->simplePaginate(30); - $notifications = $notifications->map(function($k, $v) { - return [ - 'id' => $k->id, - 'action' => $k->action, - 'message' => $k->message, - 'rendered' => $k->rendered, - 'actor' => [ - 'avatar' => $k->actor->avatarUrl(), - 'username' => $k->actor->username, - 'url' => $k->actor->url(), - ], - 'url' => $k->item->url(), - 'read_at' => $k->read_at, - ]; - }); - return response()->json($notifications, 200, [], JSON_PRETTY_PRINT); - } - // deprecated public function discover(Request $request) { From 90e41d98557035b3a4445f7f32e4dace685ac7c8 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Mon, 10 Dec 2018 20:36:53 -0700 Subject: [PATCH 17/22] Update BaseApiController --- app/Http/Controllers/Api/BaseApiController.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/app/Http/Controllers/Api/BaseApiController.php b/app/Http/Controllers/Api/BaseApiController.php index a5afff73..ad717dfe 100644 --- a/app/Http/Controllers/Api/BaseApiController.php +++ b/app/Http/Controllers/Api/BaseApiController.php @@ -8,6 +8,7 @@ use App\Http\Controllers\{ AvatarController }; use Auth, Cache, URL; +use Carbon\Carbon; use App\{ Avatar, Notification, @@ -50,6 +51,21 @@ class BaseApiController extends Controller return response()->json($res); } + public function notifications(Request $request) + { + $pid = Auth::user()->profile->id; + $timeago = Carbon::now()->subMonths(6); + $notifications = Notification::with('actor') + ->whereProfileId($pid) + ->whereDate('created_at', '>', $timeago) + ->orderBy('created_at','desc') + ->paginate(10); + $resource = new Fractal\Resource\Collection($notifications, new NotificationTransformer()); + $res = $this->fractal->createData($resource)->toArray(); + + return response()->json($res); + } + public function accounts(Request $request, $id) { $profile = Profile::findOrFail($id); From 582c4913d511c7996959f7def086af3294d0c55d Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Mon, 10 Dec 2018 20:41:41 -0700 Subject: [PATCH 18/22] Update timeline controllers and routes --- app/Http/Controllers/SiteController.php | 23 +----------------- app/Http/Controllers/TimelineController.php | 26 +-------------------- routes/web.php | 15 ++++++------ 3 files changed, 10 insertions(+), 54 deletions(-) diff --git a/app/Http/Controllers/SiteController.php b/app/Http/Controllers/SiteController.php index d7ab9648..fa12c939 100644 --- a/app/Http/Controllers/SiteController.php +++ b/app/Http/Controllers/SiteController.php @@ -31,28 +31,7 @@ class SiteController extends Controller public function homeTimeline() { - $pid = Auth::user()->profile->id; - // TODO: Use redis for timelines - - $following = Follower::whereProfileId($pid)->pluck('following_id'); - $following->push($pid)->toArray(); - - $filtered = UserFilter::whereUserId($pid) - ->whereFilterableType('App\Profile') - ->whereIn('filter_type', ['mute', 'block']) - ->pluck('filterable_id')->toArray(); - - $timeline = Status::whereIn('profile_id', $following) - ->whereNotIn('profile_id', $filtered) - ->whereHas('media') - ->whereVisibility('public') - ->orderBy('created_at', 'desc') - ->withCount(['comments', 'likes', 'shares']) - ->simplePaginate(20); - - $type = 'personal'; - - return view('timeline.template', compact('timeline', 'type')); + return view('timeline.home'); } public function changeLocale(Request $request, $locale) diff --git a/app/Http/Controllers/TimelineController.php b/app/Http/Controllers/TimelineController.php index 5ce51eb8..41769285 100644 --- a/app/Http/Controllers/TimelineController.php +++ b/app/Http/Controllers/TimelineController.php @@ -20,30 +20,6 @@ class TimelineController extends Controller public function local(Request $request) { - $this->validate($request,[ - 'page' => 'nullable|integer|max:20' - ]); - // TODO: Use redis for timelines - // $timeline = Timeline::build()->local(); - $pid = Auth::user()->profile->id; - - $private = Profile::whereIsPrivate(true)->where('id', '!=', $pid)->pluck('id'); - $filters = UserFilter::whereUserId($pid) - ->whereFilterableType('App\Profile') - ->whereIn('filter_type', ['mute', 'block']) - ->pluck('filterable_id')->toArray(); - $filtered = array_merge($private->toArray(), $filters); - - $timeline = Status::whereHas('media') - ->whereNotIn('profile_id', $filtered) - ->whereNull('in_reply_to_id') - ->whereNull('reblog_of_id') - ->whereVisibility('public') - ->withCount(['comments', 'likes']) - ->orderBy('created_at', 'desc') - ->simplePaginate(10); - $type = 'local'; - - return view('timeline.template', compact('timeline', 'type')); + return view('timeline.local'); } } diff --git a/routes/web.php b/routes/web.php index 9e2b5a0c..35fc8997 100644 --- a/routes/web.php +++ b/routes/web.php @@ -38,15 +38,16 @@ Route::domain(config('pixelfed.domain.app'))->middleware(['validemail', 'twofact Route::get('nodeinfo/2.0.json', 'FederationController@nodeinfo'); Route::group(['prefix' => 'v1'], function () { + Route::get('accounts/verify_credentials', 'ApiController@verifyCredentials'); Route::post('avatar/update', 'ApiController@avatarUpdate'); Route::get('likes', 'ApiController@hydrateLikes'); - Route::post('media', 'ApiController@uploadMedia')->middleware('throttle:250,1440'); + Route::post('media', 'ApiController@uploadMedia')->middleware('throttle:500,1440'); + Route::get('notifications', 'ApiController@notifications'); + Route::get('timelines/public', 'PublicApiController@publicTimelineApi'); + Route::get('timelines/home', 'PublicApiController@homeTimelineApi'); }); Route::group(['prefix' => 'v2'], function() { - Route::get('notifications', 'InternalApiController@notifications'); - Route::post('notifications', 'InternalApiController@notificationMarkAllRead'); Route::get('discover', 'InternalApiController@discover'); - // Route::get('discover/people', 'InternalApiController@discoverPeople'); Route::get('discover/posts', 'InternalApiController@discoverPosts'); Route::get('profile/{username}/status/{postid}', 'PublicApiController@status'); Route::get('comments/{username}/status/{postId}', 'PublicApiController@statusComments'); @@ -56,7 +57,7 @@ Route::domain(config('pixelfed.domain.app'))->middleware(['validemail', 'twofact Route::group(['prefix' => 'local'], function () { Route::get('i/follow-suggestions', 'ApiController@followSuggestions'); Route::post('i/more-comments', 'ApiController@loadMoreComments'); - Route::post('status/compose', 'InternalApiController@compose')->middleware('throttle:250,1440'); + Route::post('status/compose', 'InternalApiController@compose')->middleware('throttle:500,1440'); }); }); @@ -67,8 +68,8 @@ Route::domain(config('pixelfed.domain.app'))->middleware(['validemail', 'twofact Route::get('compose', 'StatusController@compose')->name('compose'); Route::post('comment', 'CommentController@store')->middleware('throttle:1000,1440'); Route::post('delete', 'StatusController@delete')->middleware('throttle:1000,1440'); - Route::post('mute', 'AccountController@mute')->middleware('throttle:100,1440'); - Route::post('block', 'AccountController@block')->middleware('throttle:100,1440'); + Route::post('mute', 'AccountController@mute'); + Route::post('block', 'AccountController@block'); Route::post('like', 'LikeController@store')->middleware('throttle:1000,1440'); Route::post('share', 'StatusController@storeShare')->middleware('throttle:1000,1440'); Route::post('follow', 'FollowerController@store')->middleware('throttle:250,1440'); From 21ec1704df0b753a70ae2dbfc697d0320545ea4e Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Mon, 10 Dec 2018 20:44:41 -0700 Subject: [PATCH 19/22] Update nav menu --- resources/views/layouts/partial/nav.blade.php | 45 +++++-------------- 1 file changed, 12 insertions(+), 33 deletions(-) diff --git a/resources/views/layouts/partial/nav.blade.php b/resources/views/layouts/partial/nav.blade.php index 2710e8bb..11e567fd 100644 --- a/resources/views/layouts/partial/nav.blade.php +++ b/resources/views/layouts/partial/nav.blade.php @@ -19,32 +19,19 @@
  • {{ __('Login') }}
  • {{ __('Register') }}
  • @else -
  • + + {{ __('Home') }} + +
  • +
  • + + {{ __('Local') }} +
  • - {{-- --}}