From d11e82c3d9ed6d961faf663e8ae6c04a0562f539 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Fri, 22 Nov 2019 21:21:53 -0700 Subject: [PATCH 01/40] Update landing page, add age check --- .../Controllers/Auth/RegisterController.php | 3 ++- resources/views/site/index.blade.php | 18 ++++++++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.php index 713ffe63e..738171ded 100644 --- a/app/Http/Controllers/Auth/RegisterController.php +++ b/app/Http/Controllers/Auth/RegisterController.php @@ -63,7 +63,7 @@ class RegisterController extends Controller 'unique:users', function ($attribute, $value, $fail) { if (!ctype_alpha($value[0])) { - return $fail('Username is invalid. Username must be alpha-numeric and start with a letter.'); + return $fail('Username is invalid. Must start with a letter or number.'); } $val = str_replace(['_', '-', '.'], '', $value); if(!ctype_alnum($val)) { @@ -73,6 +73,7 @@ class RegisterController extends Controller ]; $rules = [ + 'agecheck' => 'required|accepted', 'name' => 'nullable|string|max:'.config('pixelfed.max_name_length'), 'username' => $usernameRules, 'email' => 'required|string|email|max:255|unique:users', diff --git a/resources/views/site/index.blade.php b/resources/views/site/index.blade.php index 03be6fd9c..d623792da 100644 --- a/resources/views/site/index.blade.php +++ b/resources/views/site/index.blade.php @@ -75,7 +75,7 @@
-
+
@@ -86,7 +86,7 @@
@if(true === config('pixelfed.open_registration')) -
+ @csrf
@@ -102,7 +102,7 @@
- + @if ($errors->has('username')) @@ -141,6 +141,16 @@
+
+
+
+ + +
+
+
-
+

Have an account? Log in

From 574074633925183a7d2702672cd0540b498aef83 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Fri, 22 Nov 2019 21:23:38 -0700 Subject: [PATCH 02/40] Update APIV1Controller, add ```mobile_apis``` to /api/v1/instance endpoint --- app/Http/Controllers/Api/ApiV1Controller.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/Api/ApiV1Controller.php b/app/Http/Controllers/Api/ApiV1Controller.php index ad8772230..61948f945 100644 --- a/app/Http/Controllers/Api/ApiV1Controller.php +++ b/app/Http/Controllers/Api/ApiV1Controller.php @@ -906,7 +906,9 @@ class ApiV1Controller extends Controller 'max_avatar_size' => config('pixelfed.max_avatar_size'), 'max_caption_length' => config('pixelfed.max_caption_length'), 'max_bio_length' => config('pixelfed.max_bio_length'), - 'max_album_length' => config('pixelfed.max_album_length') + 'max_album_length' => config('pixelfed.max_album_length'), + 'mobile_apis' => config('pixelfed.oauth_enabled') + ] ]; return response()->json($res, 200, [], JSON_PRETTY_PRINT); From 885a1258e89de0f8adb54dce2585c725ad5534da Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Fri, 22 Nov 2019 22:34:56 -0700 Subject: [PATCH 03/40] Add AccountService --- app/Services/AccountService.php | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 app/Services/AccountService.php diff --git a/app/Services/AccountService.php b/app/Services/AccountService.php new file mode 100644 index 000000000..e14aadf80 --- /dev/null +++ b/app/Services/AccountService.php @@ -0,0 +1,29 @@ +addHours(12); + + return Cache::remember($key, $ttl, function() use($id) { + $fractal = new Fractal\Manager(); + $fractal->setSerializer(new ArraySerializer()); + $profile = Profile::whereNull('status')->findOrFail($id); + $resource = new Fractal\Resource\Item($profile, new AccountTransformer()); + return $fractal->createData($resource)->toArray(); + }); + } + +} \ No newline at end of file From 7b00eba398482092df63207b3b4dc8e9cea81bdc Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Fri, 22 Nov 2019 22:40:29 -0700 Subject: [PATCH 04/40] Update PublicTimelineService, add video media scopes --- app/Services/PublicTimelineService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Services/PublicTimelineService.php b/app/Services/PublicTimelineService.php index ded2fa247..49d0eb598 100644 --- a/app/Services/PublicTimelineService.php +++ b/app/Services/PublicTimelineService.php @@ -52,7 +52,7 @@ class PublicTimelineService { $ids = Status::whereNull('uri') ->whereNull('in_reply_to_id') ->whereNull('reblog_of_id') - ->whereIn('type', ['photo', 'photo:album']) + ->whereIn('type', ['photo', 'photo:album', 'video', 'video:album', 'photo:video:album']) ->whereScope('public') ->latest() ->limit($limit) From 5ebd2c8a1bedc2c615e2d9beefcb01cddbd3b3d3 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Fri, 22 Nov 2019 22:43:20 -0700 Subject: [PATCH 05/40] Update PublicApiController, add AccountService --- app/Http/Controllers/PublicApiController.php | 142 ++++--------------- 1 file changed, 29 insertions(+), 113 deletions(-) diff --git a/app/Http/Controllers/PublicApiController.php b/app/Http/Controllers/PublicApiController.php index 4003615ec..fd343a961 100644 --- a/app/Http/Controllers/PublicApiController.php +++ b/app/Http/Controllers/PublicApiController.php @@ -22,7 +22,11 @@ use App\Transformer\Api\{ RelationshipTransformer, StatusTransformer, }; -use App\Services\UserFilterService; +use App\Services\{ + AccountService, + PublicTimelineService, + UserFilterService +}; use App\Jobs\StatusPipeline\NewStatusPipeline; use League\Fractal\Serializer\ArraySerializer; use League\Fractal\Pagination\IlluminatePaginatorAdapter; @@ -38,17 +42,12 @@ class PublicApiController extends Controller $this->fractal->setSerializer(new ArraySerializer()); } - protected function getUserData() + protected function getUserData($user) { - if(false == Auth::check()) { + if(!$user) { return []; } else { - $profile = Auth::user()->profile; - if($profile->status) { - return []; - } - $user = new Fractal\Resource\Item($profile, new AccountTransformer()); - return $this->fractal->createData($user)->toArray(); + return AccountService::get($user->profile_id); } } @@ -90,7 +89,7 @@ class PublicApiController extends Controller $item = new Fractal\Resource\Item($status, new StatusTransformer()); $res = [ 'status' => $this->fractal->createData($item)->toArray(), - 'user' => $this->getUserData(), + 'user' => $this->getUserData($request->user()), 'likes' => $this->getLikes($status), 'shares' => $this->getShares($status), 'reactions' => [ @@ -235,12 +234,13 @@ class PublicApiController extends Controller $max = $request->input('max_id'); $limit = $request->input('limit') ?? 3; - // $private = Cache::remember('profiles:private', now()->addMinutes(1440), function() { - // return Profile::whereIsPrivate(true) - // ->orWhere('unlisted', true) - // ->orWhere('status', '!=', null) - // ->pluck('id'); - // }); + $private = Cache::remember('profiles:private', now()->addMinutes(1440), function() { + return Profile::whereIsPrivate(true) + ->orWhere('unlisted', true) + ->orWhere('status', '!=', null) + ->pluck('id') + ->toArray(); + }); // if(Auth::check()) { // // $pid = Auth::user()->profile->id; @@ -255,7 +255,17 @@ class PublicApiController extends Controller // $filtered = []; // } - $filtered = Auth::check() ? UserFilterService::filters(Auth::user()->profile_id) : []; + $filtered = Auth::check() ? array_merge($private, UserFilterService::filters(Auth::user()->profile_id)) : []; + if($max == 0) { + $res = PublicTimelineService::count(); + if($res == 0) { + PublicTimelineService::warmCache(); + $res = PublicTimelineService::get(0,4); + } else { + $res = PublicTimelineService::get(0,4); + } + return response($res); + } if($min || $max) { $dir = $min ? '>' : '<'; @@ -439,98 +449,7 @@ class PublicApiController extends Controller public function networkTimelineApi(Request $request) { - if(!Auth::check()) { - return abort(403); - } - - $this->validate($request,[ - 'page' => 'nullable|integer|max:40', - 'min_id' => 'nullable|integer|min:0|max:' . PHP_INT_MAX, - 'max_id' => 'nullable|integer|min:0|max:' . PHP_INT_MAX, - 'limit' => 'nullable|integer|max:20' - ]); - - $page = $request->input('page'); - $min = $request->input('min_id'); - $max = $request->input('max_id'); - $limit = $request->input('limit') ?? 3; - - // TODO: Use redis for timelines - // $timeline = Timeline::build()->local(); - $pid = Auth::user()->profile->id; - - $private = Cache::remember('profiles:private', now()->addMinutes(1440), function() { - return Profile::whereIsPrivate(true) - ->orWhere('unlisted', true) - ->orWhere('status', '!=', null) - ->pluck('id'); - }); - $filters = UserFilter::whereUserId($pid) - ->whereFilterableType('App\Profile') - ->whereIn('filter_type', ['mute', 'block']) - ->pluck('filterable_id')->toArray(); - $filtered = array_merge($private->toArray(), $filters); - - if($min || $max) { - $dir = $min ? '>' : '<'; - $id = $min ?? $max; - $timeline = Status::select( - 'id', - 'uri', - 'caption', - 'rendered', - 'profile_id', - 'type', - 'in_reply_to_id', - 'reblog_of_id', - 'is_nsfw', - 'scope', - 'local', - 'reply_count', - 'comments_disabled', - 'created_at', - 'updated_at' - )->where('id', $dir, $id) - ->whereIn('type', ['photo', 'photo:album', 'video', 'video:album']) - ->whereNotIn('profile_id', $filtered) - ->whereNotNull('uri') - ->whereNull('in_reply_to_id') - ->whereNull('reblog_of_id') - ->whereVisibility('public') - ->latest() - ->limit($limit) - ->get(); - } else { - $timeline = Status::select( - 'id', - 'uri', - 'caption', - 'rendered', - 'profile_id', - 'type', - 'in_reply_to_id', - 'reblog_of_id', - 'is_nsfw', - 'scope', - 'local', - 'reply_count', - 'comments_disabled', - 'created_at', - 'updated_at' - )->whereIn('type', ['photo', 'photo:album', 'video', 'video:album']) - ->whereNotIn('profile_id', $filtered) - ->whereNull('in_reply_to_id') - ->whereNull('reblog_of_id') - ->whereNotNull('uri') - ->whereVisibility('public') - ->latest() - ->simplePaginate($limit); - } - - $fractal = new Fractal\Resource\Collection($timeline, new StatusTransformer()); - $res = $this->fractal->createData($fractal)->toArray(); - return response()->json($res); - + return response()->json([]); } public function relationships(Request $request) @@ -555,10 +474,7 @@ class PublicApiController extends Controller public function account(Request $request, $id) { - $profile = Profile::whereNull('status')->findOrFail($id); - $resource = new Fractal\Resource\Item($profile, new AccountTransformer()); - $res = $this->fractal->createData($resource)->toArray(); - + $res = AccountService::get($id); return response()->json($res); } From 9fe113c3eb8846dbfb5c87da4ccfaf64e6e07421 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Fri, 22 Nov 2019 22:44:13 -0700 Subject: [PATCH 06/40] Update changelog --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 53b6e45a2..096c481ab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ ### Added - Added drafts API endpoint for Camera Roll ([bad2ecde](https://github.com/pixelfed/pixelfed/commit/bad2ecde)) +- Added AccountService ([885a1258](https://github.com/pixelfed/pixelfed/commit/885a1258)) ### Fixed - Fixed like and share/reblog count on profiles ([86cb7d09](https://github.com/pixelfed/pixelfed/commit/86cb7d09)) @@ -45,6 +46,10 @@ - Updated StatusTransformer, added ```local``` attribute ([484bb509](https://github.com/pixelfed/pixelfed/commit/484bb509)) - Updated PostComponent, fix bug affecting MomentUI and non authenticated users ([7b3fe215](https://github.com/pixelfed/pixelfed/commit/7b3fe215)) - Updated FixUsernames command to allow usernames containing ```.``` ([e5d77c6d](https://github.com/pixelfed/pixelfed/commit/e5d77c6d)) +- Updated landing page, add age check ([d11e82c3](https://github.com/pixelfed/pixelfed/commit/d11e82c3)) +- Updated ApiV1Controller, add ```mobile_apis``` to /api/v1/instance endpoint ([57407463](https://github.com/pixelfed/pixelfed/commit/57407463)) +- Updated PublicTimelineService, add video media scopes ([7b00eba3](https://github.com/pixelfed/pixelfed/commit/7b00eba3)) +- Updated PublicApiController, add AccountService ([5ebd2c8a](https://github.com/pixelfed/pixelfed/commit/5ebd2c8a)) ## Deprecated From 744435cdf53f4c07e9cb03120067de6d96f1838c Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Fri, 22 Nov 2019 22:53:51 -0700 Subject: [PATCH 07/40] Update PublicApiController --- app/Http/Controllers/PublicApiController.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/Http/Controllers/PublicApiController.php b/app/Http/Controllers/PublicApiController.php index fd343a961..fb8824eee 100644 --- a/app/Http/Controllers/PublicApiController.php +++ b/app/Http/Controllers/PublicApiController.php @@ -264,7 +264,7 @@ class PublicApiController extends Controller } else { $res = PublicTimelineService::get(0,4); } - return response($res); + return $res; } if($min || $max) { @@ -331,7 +331,6 @@ class PublicApiController extends Controller $fractal = new Fractal\Resource\Collection($timeline, new StatusTransformer()); $res = $this->fractal->createData($fractal)->toArray(); - // $res = $timeline; return response()->json($res); } From 0c4d270f0288c730f94028669d2a84e7a3273292 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Fri, 22 Nov 2019 22:57:09 -0700 Subject: [PATCH 08/40] Update PublicApiController --- app/Http/Controllers/PublicApiController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/PublicApiController.php b/app/Http/Controllers/PublicApiController.php index fb8824eee..81214b223 100644 --- a/app/Http/Controllers/PublicApiController.php +++ b/app/Http/Controllers/PublicApiController.php @@ -264,7 +264,7 @@ class PublicApiController extends Controller } else { $res = PublicTimelineService::get(0,4); } - return $res; + return response()->json($res); } if($min || $max) { From 7311e813824282d1eb8b569b4bd03c3512cf65ba Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Fri, 22 Nov 2019 23:00:43 -0700 Subject: [PATCH 09/40] Update PublicApiController --- app/Http/Controllers/PublicApiController.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/app/Http/Controllers/PublicApiController.php b/app/Http/Controllers/PublicApiController.php index 81214b223..908fa06cd 100644 --- a/app/Http/Controllers/PublicApiController.php +++ b/app/Http/Controllers/PublicApiController.php @@ -256,16 +256,16 @@ class PublicApiController extends Controller // } $filtered = Auth::check() ? array_merge($private, UserFilterService::filters(Auth::user()->profile_id)) : []; - if($max == 0) { - $res = PublicTimelineService::count(); - if($res == 0) { - PublicTimelineService::warmCache(); - $res = PublicTimelineService::get(0,4); - } else { - $res = PublicTimelineService::get(0,4); - } - return response()->json($res); - } + // if($max == 0) { + // $res = PublicTimelineService::count(); + // if($res == 0) { + // PublicTimelineService::warmCache(); + // $res = PublicTimelineService::get(0,4); + // } else { + // $res = PublicTimelineService::get(0,4); + // } + // return response()->json($res); + // } if($min || $max) { $dir = $min ? '>' : '<'; From d2c53dc56a56bc6d0b2824cfebe540f88d3e8b9f Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Fri, 22 Nov 2019 23:33:47 -0700 Subject: [PATCH 10/40] Update SiteController --- app/Http/Controllers/SiteController.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/SiteController.php b/app/Http/Controllers/SiteController.php index 9d8563f25..68d92fc30 100644 --- a/app/Http/Controllers/SiteController.php +++ b/app/Http/Controllers/SiteController.php @@ -10,10 +10,10 @@ use App\Util\Localization\Localization; class SiteController extends Controller { - public function home() + public function home(Request $request) { if (Auth::check()) { - return $this->homeTimeline(); + return $this->homeTimeline($request); } else { return $this->homeGuest(); } @@ -24,9 +24,13 @@ class SiteController extends Controller return view('site.index'); } - public function homeTimeline() + public function homeTimeline(Request $request) { - return view('timeline.home'); + $this->validate($request, [ + 'layout' => 'nullable|string|in:grid,feed' + ]); + $layout = $request->input('layout', 'feed'); + return view('timeline.home', compact('layout')); } public function changeLocale(Request $request, $locale) From 98ad5936543097633d4b1417c637519e6d9ff82b Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Fri, 22 Nov 2019 23:35:13 -0700 Subject: [PATCH 11/40] Update StatusController --- app/Http/Controllers/StatusController.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/StatusController.php b/app/Http/Controllers/StatusController.php index 364ca21a8..7327cc0a4 100644 --- a/app/Http/Controllers/StatusController.php +++ b/app/Http/Controllers/StatusController.php @@ -51,6 +51,12 @@ class StatusController extends Controller } } + if($status->type == 'archived') { + if(Auth::user()->profile_id !== $status->profile_id) { + abort(404); + } + } + if ($request->wantsJson() && config('federation.activitypub.enabled')) { return $this->showActivityPub($request, $status); } @@ -72,7 +78,7 @@ class StatusController extends Controller { abort(404); $profile = Profile::whereNull('status')->whereUsername($username)->first(); - $status = Status::whereScope('private')->find($id); + $status = Status::whereProfileId($profile->id)->whereScope('public')->find($id); if(!$profile || !$status) { return view('status.embed-removed'); } From 1856dd962d8c371d701af7f266e2f81e157cf474 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Fri, 22 Nov 2019 23:35:51 -0700 Subject: [PATCH 12/40] Add SeasonalController --- app/Http/Controllers/SeasonalController.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 app/Http/Controllers/SeasonalController.php diff --git a/app/Http/Controllers/SeasonalController.php b/app/Http/Controllers/SeasonalController.php new file mode 100644 index 000000000..2dbb50788 --- /dev/null +++ b/app/Http/Controllers/SeasonalController.php @@ -0,0 +1,20 @@ +middleware('auth'); + } + + public function yearInReview() + { + $profile = Auth::user()->profile; + return view('account.yir', compact('profile')); + } +} From 1fecf7170ce76251006ff50731a82a957a137933 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sat, 23 Nov 2019 21:44:41 -0700 Subject: [PATCH 13/40] Add post embeds --- app/Http/Controllers/StatusController.php | 20 +- public/embed.js | 1 + .../views/status/embed-removed.blade.php | 46 +++++ resources/views/status/embed.blade.php | 178 ++++++++++++++++++ routes/web.php | 1 + 5 files changed, 241 insertions(+), 5 deletions(-) create mode 100644 public/embed.js create mode 100644 resources/views/status/embed-removed.blade.php create mode 100644 resources/views/status/embed.blade.php diff --git a/app/Http/Controllers/StatusController.php b/app/Http/Controllers/StatusController.php index 7327cc0a4..f8e37a296 100644 --- a/app/Http/Controllers/StatusController.php +++ b/app/Http/Controllers/StatusController.php @@ -76,13 +76,23 @@ class StatusController extends Controller public function showEmbed(Request $request, $username, int $id) { - abort(404); - $profile = Profile::whereNull('status')->whereUsername($username)->first(); - $status = Status::whereProfileId($profile->id)->whereScope('public')->find($id); - if(!$profile || !$status) { + $profile = Profile::whereNull(['domain','status'])->whereUsername($username)->first(); + if(!$profile) { return view('status.embed-removed'); } - return view('status.embed', compact('status')); + $status = Status::whereProfileId($profile->id) + ->whereNull('uri') + ->whereScope('public') + ->whereIsNsfw(false) + ->whereIn('type', ['photo', 'video']) + ->find($id); + if(!$status) { + return view('status.embed-removed'); + } + $showLikes = $request->filled('likes') && $request->likes == true; + $showCaption = $request->filled('caption') && $request->caption !== false; + $layout = $request->filled('layout') && $request->layout == 'compact' ? 'compact' : 'full'; + return view('status.embed', compact('status', 'showLikes', 'showCaption', 'layout')); } public function showObject(Request $request, $username, int $id) diff --git a/public/embed.js b/public/embed.js new file mode 100644 index 000000000..5acc20efe --- /dev/null +++ b/public/embed.js @@ -0,0 +1 @@ +!function(){var e;e=function(){var e=[];window.addEventListener("message",function(t){var n=t.data||{};"setHeight"===n.type&&e[n.id]&&(e[n.id].height=n.height)}),[].forEach.call(document.querySelectorAll("iframe.pixelfed__embed"),function(t){t.scrolling="no",t.style.overflow="hidden",e.push(t);var n=e.length-1;t.onload=function(){t.contentWindow.postMessage({type:"setHeight",id:n},"*")},t.onload()})},-1!==["interactive","complete"].indexOf(document.readyState)?e():document.addEventListener("DOMContentLoaded",e)}(); \ No newline at end of file diff --git a/resources/views/status/embed-removed.blade.php b/resources/views/status/embed-removed.blade.php new file mode 100644 index 000000000..3e147ec89 --- /dev/null +++ b/resources/views/status/embed-removed.blade.php @@ -0,0 +1,46 @@ + + + + + + + + + + Pixelfed | 404 Embed Not Found + + + + + + + + + + + + +
+
+
+ +

Pixelfed

+

The link to this photo or video may be broken, or the post may have been removed.

+

Visit Pixelfed

+
+
+
+ + + diff --git a/resources/views/status/embed.blade.php b/resources/views/status/embed.blade.php new file mode 100644 index 000000000..42f9a2594 --- /dev/null +++ b/resources/views/status/embed.blade.php @@ -0,0 +1,178 @@ + + + + + + + + + + {{ $title ?? config('app.name', 'Pixelfed') }} + + + + + + + + + + + + + + +
+ @php($item = $status) +
+ + + @php($status = $item) + @switch($status->viewType()) + @case('photo') + @case('image') + @if($status->is_nsfw) +
+ +

CW / NSFW / Hidden Media

+

(click to show)

+
+
+ + +
+ @else +
+ +
+ @endif + @break + @case('album') + @if($status->is_nsfw) + + @else + + @endif + @break + @case('video') + @if($status->is_nsfw) +
+ +

CW / NSFW / Hidden Media

+

(click to show)

+
+
+ +
+
+ @else +
+ +
+ @endif + @break + @case('video-album') + @if($status->is_nsfw) +
+ +

CW / NSFW / Hidden Media

+

(click to show)

+
+
+ +
+
+ @else +
+ +
+ @endif + @break + @endswitch + + @if($layout != 'compact') +
+ +
+ @if($showLikes) + + @endif +
+

+ + {{$item->profile->username}} + + @if($showCaption) + {!! $item->rendered ?? e($item->caption) !!} + @endif +

+
+
+ @endif + +
+
+ + + + diff --git a/routes/web.php b/routes/web.php index 08593aa01..1774e7cbb 100644 --- a/routes/web.php +++ b/routes/web.php @@ -373,6 +373,7 @@ Route::domain(config('pixelfed.domain.app'))->middleware(['validemail', 'twofact Route::get('c/{collection}', 'CollectionController@show'); Route::get('p/{username}/{id}/c', 'CommentController@showAll'); + Route::get('p/{username}/{id}/embed', 'StatusController@showEmbed'); Route::get('p/{username}/{id}/edit', 'StatusController@edit'); Route::post('p/{username}/{id}/edit', 'StatusController@editStore'); Route::get('p/{username}/{id}.json', 'StatusController@showObject'); From 540c9615290eedd89d7dce3aad371ef5e54baf42 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sat, 23 Nov 2019 21:45:25 -0700 Subject: [PATCH 14/40] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 096c481ab..00b045b5f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ### Added - Added drafts API endpoint for Camera Roll ([bad2ecde](https://github.com/pixelfed/pixelfed/commit/bad2ecde)) - Added AccountService ([885a1258](https://github.com/pixelfed/pixelfed/commit/885a1258)) +- Added post embeds ([1fecf717](https://github.com/pixelfed/pixelfed/commit/1fecf717)) ### Fixed - Fixed like and share/reblog count on profiles ([86cb7d09](https://github.com/pixelfed/pixelfed/commit/86cb7d09)) From cdff55313afdac0e85ecfc4a79c4f77d47f2f5df Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sat, 23 Nov 2019 21:56:16 -0700 Subject: [PATCH 15/40] Update StatusController --- app/Http/Controllers/StatusController.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/StatusController.php b/app/Http/Controllers/StatusController.php index f8e37a296..8014ed53e 100644 --- a/app/Http/Controllers/StatusController.php +++ b/app/Http/Controllers/StatusController.php @@ -78,7 +78,8 @@ class StatusController extends Controller { $profile = Profile::whereNull(['domain','status'])->whereUsername($username)->first(); if(!$profile) { - return view('status.embed-removed'); + $content = view('status.embed-removed'); + return response($content)->header('X-Frame-Options', 'ALLOWALL'); } $status = Status::whereProfileId($profile->id) ->whereNull('uri') @@ -87,12 +88,14 @@ class StatusController extends Controller ->whereIn('type', ['photo', 'video']) ->find($id); if(!$status) { - return view('status.embed-removed'); + $content = view('status.embed-removed'); + return response($content)->header('X-Frame-Options', 'ALLOWALL'); } $showLikes = $request->filled('likes') && $request->likes == true; $showCaption = $request->filled('caption') && $request->caption !== false; $layout = $request->filled('layout') && $request->layout == 'compact' ? 'compact' : 'full'; - return view('status.embed', compact('status', 'showLikes', 'showCaption', 'layout')); + $content = view('status.embed', compact('status', 'showLikes', 'showCaption', 'layout')); + return response($content)->header('X-Frame-Options', 'ALLOWALL'); } public function showObject(Request $request, $username, int $id) From 6c97b2162c6b65e78b8b49f394345810e3690d2a Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sat, 23 Nov 2019 22:03:20 -0700 Subject: [PATCH 16/40] Update StatusController --- app/Http/Controllers/StatusController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/StatusController.php b/app/Http/Controllers/StatusController.php index 8014ed53e..5296cf0a3 100644 --- a/app/Http/Controllers/StatusController.php +++ b/app/Http/Controllers/StatusController.php @@ -95,7 +95,7 @@ class StatusController extends Controller $showCaption = $request->filled('caption') && $request->caption !== false; $layout = $request->filled('layout') && $request->layout == 'compact' ? 'compact' : 'full'; $content = view('status.embed', compact('status', 'showLikes', 'showCaption', 'layout')); - return response($content)->header('X-Frame-Options', 'ALLOWALL'); + return response($content)->withHeaders(['x-frame-options' => 'ALLOWALL']); } public function showObject(Request $request, $username, int $id) From 026b59f025afa89aa351667a40b9d2539e281d82 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sat, 23 Nov 2019 22:18:51 -0700 Subject: [PATCH 17/40] Update StatusController --- app/Http/Controllers/StatusController.php | 2 +- app/Http/Kernel.php | 1 + app/Http/Middleware/FrameGuard.php | 26 +++++++++++++++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 app/Http/Middleware/FrameGuard.php diff --git a/app/Http/Controllers/StatusController.php b/app/Http/Controllers/StatusController.php index 5296cf0a3..465ef381a 100644 --- a/app/Http/Controllers/StatusController.php +++ b/app/Http/Controllers/StatusController.php @@ -95,7 +95,7 @@ class StatusController extends Controller $showCaption = $request->filled('caption') && $request->caption !== false; $layout = $request->filled('layout') && $request->layout == 'compact' ? 'compact' : 'full'; $content = view('status.embed', compact('status', 'showLikes', 'showCaption', 'layout')); - return response($content)->withHeaders(['x-frame-options' => 'ALLOWALL']); + return response($content)->withHeaders(['X-Frame-Options' => 'ALLOWALL']); } public function showObject(Request $request, $username, int $id) diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index 7a8c91efe..33ed320a7 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -29,6 +29,7 @@ class Kernel extends HttpKernel protected $middlewareGroups = [ 'web' => [ \App\Http\Middleware\EncryptCookies::class, + \App\Http\Middleware\FrameGuard::class, \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, \Illuminate\Session\Middleware\StartSession::class, // \Illuminate\Session\Middleware\AuthenticateSession::class, diff --git a/app/Http/Middleware/FrameGuard.php b/app/Http/Middleware/FrameGuard.php new file mode 100644 index 000000000..9fa377e3b --- /dev/null +++ b/app/Http/Middleware/FrameGuard.php @@ -0,0 +1,26 @@ +headers->has('X-Frame-Options')) { + $response->headers->set('X-Frame-Options', 'SAMEORIGIN', false); + } + + return $response; + } +} From d5d960e2f0f3c83d8abe4fbb50767447ff30bb9c Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 24 Nov 2019 00:42:59 -0700 Subject: [PATCH 18/40] Update StatusController --- app/Http/Controllers/StatusController.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/StatusController.php b/app/Http/Controllers/StatusController.php index 465ef381a..a5e9e09da 100644 --- a/app/Http/Controllers/StatusController.php +++ b/app/Http/Controllers/StatusController.php @@ -76,7 +76,10 @@ class StatusController extends Controller public function showEmbed(Request $request, $username, int $id) { - $profile = Profile::whereNull(['domain','status'])->whereUsername($username)->first(); + $profile = Profile::whereNull(['domain','status']) + ->whereIsPrivate(false) + ->whereUsername($username) + ->first(); if(!$profile) { $content = view('status.embed-removed'); return response($content)->header('X-Frame-Options', 'ALLOWALL'); From 81ab02ecc4048221e8cf3d6f7097f4ea2cbe7bad Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 24 Nov 2019 00:49:58 -0700 Subject: [PATCH 19/40] Update app.js, add embed helper --- resources/assets/js/app.js | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/resources/assets/js/app.js b/resources/assets/js/app.js index d3f7d4ecc..e11123cc9 100644 --- a/resources/assets/js/app.js +++ b/resources/assets/js/app.js @@ -76,7 +76,21 @@ window.App.util = { ['Walden','filter-walden'], ['Willow','filter-willow'], ['X-Pro II','filter-xpro-ii'] - ], - emoji: ['๐Ÿ˜‚','๐Ÿ’ฏ','โค๏ธ','๐Ÿ™Œ','๐Ÿ‘','๐Ÿ‘Œ','๐Ÿ˜','๐Ÿ˜ฏ','๐Ÿ˜ข','๐Ÿ˜…','๐Ÿ˜','๐Ÿ™‚','๐Ÿ˜Ž','๐Ÿ˜€','๐Ÿคฃ','๐Ÿ˜ƒ','๐Ÿ˜„','๐Ÿ˜†','๐Ÿ˜‰','๐Ÿ˜Š','๐Ÿ˜‹','๐Ÿ˜˜','๐Ÿ˜—','๐Ÿ˜™','๐Ÿ˜š','๐Ÿค—','๐Ÿคฉ','๐Ÿค”','๐Ÿคจ','๐Ÿ˜','๐Ÿ˜‘','๐Ÿ˜ถ','๐Ÿ™„','๐Ÿ˜','๐Ÿ˜ฃ','๐Ÿ˜ฅ','๐Ÿ˜ฎ','๐Ÿค','๐Ÿ˜ช','๐Ÿ˜ซ','๐Ÿ˜ด','๐Ÿ˜Œ','๐Ÿ˜›','๐Ÿ˜œ','๐Ÿ˜','๐Ÿคค','๐Ÿ˜’','๐Ÿ˜“','๐Ÿ˜”','๐Ÿ˜•','๐Ÿ™ƒ','๐Ÿค‘','๐Ÿ˜ฒ','๐Ÿ™','๐Ÿ˜–','๐Ÿ˜ž','๐Ÿ˜Ÿ','๐Ÿ˜ค','๐Ÿ˜ญ','๐Ÿ˜ฆ','๐Ÿ˜ง','๐Ÿ˜จ','๐Ÿ˜ฉ','๐Ÿคฏ','๐Ÿ˜ฌ','๐Ÿ˜ฐ','๐Ÿ˜ฑ','๐Ÿ˜ณ','๐Ÿคช','๐Ÿ˜ต','๐Ÿ˜ก','๐Ÿ˜ ','๐Ÿคฌ','๐Ÿ˜ท','๐Ÿค’','๐Ÿค•','๐Ÿคข','๐Ÿคฎ','๐Ÿคง','๐Ÿ˜‡','๐Ÿค ','๐Ÿคก','๐Ÿคฅ','๐Ÿคซ','๐Ÿคญ','๐Ÿง','๐Ÿค“','๐Ÿ˜ˆ','๐Ÿ‘ฟ','๐Ÿ‘น','๐Ÿ‘บ','๐Ÿ’€','๐Ÿ‘ป','๐Ÿ‘ฝ','๐Ÿค–','๐Ÿ’ฉ','๐Ÿ˜บ','๐Ÿ˜ธ','๐Ÿ˜น','๐Ÿ˜ป','๐Ÿ˜ผ','๐Ÿ˜ฝ','๐Ÿ™€','๐Ÿ˜ฟ','๐Ÿ˜พ','๐Ÿคฒ','๐Ÿ‘','๐Ÿค','๐Ÿ‘','๐Ÿ‘Ž','๐Ÿ‘Š','โœŠ','๐Ÿค›','๐Ÿคœ','๐Ÿคž','โœŒ๏ธ','๐ŸคŸ','๐Ÿค˜','๐Ÿ‘ˆ','๐Ÿ‘‰','๐Ÿ‘†','๐Ÿ‘‡','โ˜๏ธ','โœ‹','๐Ÿคš','๐Ÿ–','๐Ÿ––','๐Ÿ‘‹','๐Ÿค™','๐Ÿ’ช','๐Ÿ–•','โœ๏ธ','๐Ÿ™','๐Ÿ’','๐Ÿ’„','๐Ÿ’‹','๐Ÿ‘„','๐Ÿ‘…','๐Ÿ‘‚','๐Ÿ‘ƒ','๐Ÿ‘ฃ','๐Ÿ‘','๐Ÿ‘€','๐Ÿง ','๐Ÿ—ฃ','๐Ÿ‘ค','๐Ÿ‘ฅ' - ], + ], + emoji: ['๐Ÿ˜‚','๐Ÿ’ฏ','โค๏ธ','๐Ÿ™Œ','๐Ÿ‘','๐Ÿ‘Œ','๐Ÿ˜','๐Ÿ˜ฏ','๐Ÿ˜ข','๐Ÿ˜…','๐Ÿ˜','๐Ÿ™‚','๐Ÿ˜Ž','๐Ÿ˜€','๐Ÿคฃ','๐Ÿ˜ƒ','๐Ÿ˜„','๐Ÿ˜†','๐Ÿ˜‰','๐Ÿ˜Š','๐Ÿ˜‹','๐Ÿ˜˜','๐Ÿ˜—','๐Ÿ˜™','๐Ÿ˜š','๐Ÿค—','๐Ÿคฉ','๐Ÿค”','๐Ÿคจ','๐Ÿ˜','๐Ÿ˜‘','๐Ÿ˜ถ','๐Ÿ™„','๐Ÿ˜','๐Ÿ˜ฃ','๐Ÿ˜ฅ','๐Ÿ˜ฎ','๐Ÿค','๐Ÿ˜ช','๐Ÿ˜ซ','๐Ÿ˜ด','๐Ÿ˜Œ','๐Ÿ˜›','๐Ÿ˜œ','๐Ÿ˜','๐Ÿคค','๐Ÿ˜’','๐Ÿ˜“','๐Ÿ˜”','๐Ÿ˜•','๐Ÿ™ƒ','๐Ÿค‘','๐Ÿ˜ฒ','๐Ÿ™','๐Ÿ˜–','๐Ÿ˜ž','๐Ÿ˜Ÿ','๐Ÿ˜ค','๐Ÿ˜ญ','๐Ÿ˜ฆ','๐Ÿ˜ง','๐Ÿ˜จ','๐Ÿ˜ฉ','๐Ÿคฏ','๐Ÿ˜ฌ','๐Ÿ˜ฐ','๐Ÿ˜ฑ','๐Ÿ˜ณ','๐Ÿคช','๐Ÿ˜ต','๐Ÿ˜ก','๐Ÿ˜ ','๐Ÿคฌ','๐Ÿ˜ท','๐Ÿค’','๐Ÿค•','๐Ÿคข','๐Ÿคฎ','๐Ÿคง','๐Ÿ˜‡','๐Ÿค ','๐Ÿคก','๐Ÿคฅ','๐Ÿคซ','๐Ÿคญ','๐Ÿง','๐Ÿค“','๐Ÿ˜ˆ','๐Ÿ‘ฟ','๐Ÿ‘น','๐Ÿ‘บ','๐Ÿ’€','๐Ÿ‘ป','๐Ÿ‘ฝ','๐Ÿค–','๐Ÿ’ฉ','๐Ÿ˜บ','๐Ÿ˜ธ','๐Ÿ˜น','๐Ÿ˜ป','๐Ÿ˜ผ','๐Ÿ˜ฝ','๐Ÿ™€','๐Ÿ˜ฟ','๐Ÿ˜พ','๐Ÿคฒ','๐Ÿ‘','๐Ÿค','๐Ÿ‘','๐Ÿ‘Ž','๐Ÿ‘Š','โœŠ','๐Ÿค›','๐Ÿคœ','๐Ÿคž','โœŒ๏ธ','๐ŸคŸ','๐Ÿค˜','๐Ÿ‘ˆ','๐Ÿ‘‰','๐Ÿ‘†','๐Ÿ‘‡','โ˜๏ธ','โœ‹','๐Ÿคš','๐Ÿ–','๐Ÿ––','๐Ÿ‘‹','๐Ÿค™','๐Ÿ’ช','๐Ÿ–•','โœ๏ธ','๐Ÿ™','๐Ÿ’','๐Ÿ’„','๐Ÿ’‹','๐Ÿ‘„','๐Ÿ‘…','๐Ÿ‘‚','๐Ÿ‘ƒ','๐Ÿ‘ฃ','๐Ÿ‘','๐Ÿ‘€','๐Ÿง ','๐Ÿ—ฃ','๐Ÿ‘ค','๐Ÿ‘ฅ' + ], + embed: { + post: (function(url, caption = true, likes = false, layout = 'full') { + let u = url + '/embed?'; + u += caption ? 'caption=true&' : 'caption=false&'; + u += likes ? 'likes=true&' : 'likes=false&'; + u += layout == 'compact' ? 'layout=compact' : 'layout=full'; + return ' From a5ce06f8b6460ecd5bdea29054f1284a5aef0601 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 24 Nov 2019 15:53:24 -0700 Subject: [PATCH 26/40] Update DiscoverComponent --- .../js/components/DiscoverComponent.vue | 40 ++++++++++++++++--- 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/resources/assets/js/components/DiscoverComponent.vue b/resources/assets/js/components/DiscoverComponent.vue index a22c3b0d3..172ee6b88 100644 --- a/resources/assets/js/components/DiscoverComponent.vue +++ b/resources/assets/js/components/DiscoverComponent.vue @@ -4,10 +4,10 @@
-
+ +
-
-
+ + @@ -351,7 +351,7 @@

@@ -547,6 +547,10 @@ .momentui .carousel-item { background: #000 !important; } + .reply-btn[disabled] { + opacity: .3; + color: #3897f0; + } \ No newline at end of file From f440400dc1da3bcd07d4ee52742fca525c6b7fdd Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 24 Nov 2019 15:58:05 -0700 Subject: [PATCH 30/40] Update Timeline.vue --- resources/assets/js/components/Timeline.vue | 165 ++++++++++++++------ 1 file changed, 116 insertions(+), 49 deletions(-) diff --git a/resources/assets/js/components/Timeline.vue b/resources/assets/js/components/Timeline.vue index 85c8b51c6..0bb2bb072 100644 --- a/resources/assets/js/components/Timeline.vue +++ b/resources/assets/js/components/Timeline.vue @@ -1,6 +1,6 @@