From 061b145b54f964c5c00eebbfb37a07a8582c4093 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Thu, 20 May 2021 20:26:26 -0600 Subject: [PATCH 1/3] Update ComposeController, bail on empty attachments --- app/Http/Controllers/ComposeController.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/Http/Controllers/ComposeController.php b/app/Http/Controllers/ComposeController.php index 5058a786d..f25822697 100644 --- a/app/Http/Controllers/ComposeController.php +++ b/app/Http/Controllers/ComposeController.php @@ -480,6 +480,8 @@ class ComposeController extends Controller array_push($mimes, $m->mime); } + abort_if(empty($attachments), 422); + $mediaType = StatusController::mimeTypeCheck($mimes); if(in_array($mediaType, ['photo', 'video', 'photo:album']) == false) { From 92dc7af69b1c6ce658dbf35d59db0ae261a0ce4d Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 23 May 2021 23:09:26 -0600 Subject: [PATCH 2/3] Update landing and about page --- app/Http/Controllers/SiteController.php | 235 +++++++------ resources/views/site/about.blade.php | 358 ++++++++++++-------- resources/views/site/index.blade.php | 417 +++++++----------------- 3 files changed, 466 insertions(+), 544 deletions(-) diff --git a/app/Http/Controllers/SiteController.php b/app/Http/Controllers/SiteController.php index 2563acbbf..23b81d6a0 100644 --- a/app/Http/Controllers/SiteController.php +++ b/app/Http/Controllers/SiteController.php @@ -13,143 +13,130 @@ use App\Util\ActivityPub\Helpers; class SiteController extends Controller { - public function home(Request $request) - { - if (Auth::check()) { - return $this->homeTimeline($request); - } else { - return $this->homeGuest(); - } - } + public function home(Request $request) + { + if (Auth::check()) { + return $this->homeTimeline($request); + } else { + return $this->homeGuest(); + } + } - public function homeGuest() - { - $data = Cache::remember('site:landing:data', now()->addHours(3), function() { - return [ - 'stats' => [ - 'posts' => App\Util\Lexer\PrettyNumber::convert(App\Status::count()), - 'likes' => App\Util\Lexer\PrettyNumber::convert(App\Like::count()), - 'hashtags' => App\Util\Lexer\PrettyNumber::convert(App\StatusHashtag::count()) - ], - ]; - }); - return view('site.index', compact('data')); - } + public function homeGuest() + { + return view('site.index'); + } - public function homeTimeline(Request $request) - { - $this->validate($request, [ - 'layout' => 'nullable|string|in:grid,feed' - ]); - $layout = $request->input('layout', 'feed'); - return view('timeline.home', compact('layout')); - } + public function homeTimeline(Request $request) + { + $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) - { - // todo: add other locales after pushing new l10n strings - $locales = Localization::languages(); - if(in_array($locale, $locales)) { - if($request->user()) { - $user = $request->user(); - $user->language = $locale; - $user->save(); - } - session()->put('locale', $locale); - } + public function changeLocale(Request $request, $locale) + { + // todo: add other locales after pushing new l10n strings + $locales = Localization::languages(); + if(in_array($locale, $locales)) { + if($request->user()) { + $user = $request->user(); + $user->language = $locale; + $user->save(); + } + session()->put('locale', $locale); + } - return redirect(route('site.language')); - } + return redirect(route('site.language')); + } - public function about() - { - $page = Page::whereSlug('/site/about')->whereActive(true)->first(); - $stats = Cache::remember('site:about:stats-v1', now()->addHours(12), function() { - return [ - 'posts' => Status::count(), - 'users' => User::whereNull('status')->count(), - 'admin' => User::whereIsAdmin(true)->first() - ]; - }); - $path = $page ? 'site.about-custom' : 'site.about'; - return view($path, compact('page', 'stats')); - } + public function about() + { + return Cache::remember('site.about_v2', now()->addMinutes(15), function() { + $user_count = number_format(User::count()); + $post_count = number_format(Status::count()); + $rules = config_cache('app.rules') ? json_decode(config_cache('app.rules'), true) : null; + return view('site.about', compact('rules', 'user_count', 'post_count'))->render(); + }); + } - public function language() - { - return view('site.language'); - } + public function language() + { + return view('site.language'); + } - public function communityGuidelines(Request $request) - { - return Cache::remember('site:help:community-guidelines', now()->addDays(120), function() { - $slug = '/site/kb/community-guidelines'; - $page = Page::whereSlug($slug)->whereActive(true)->first(); - return View::make('site.help.community-guidelines')->with(compact('page'))->render(); - }); - } + public function communityGuidelines(Request $request) + { + return Cache::remember('site:help:community-guidelines', now()->addDays(120), function() { + $slug = '/site/kb/community-guidelines'; + $page = Page::whereSlug($slug)->whereActive(true)->first(); + return View::make('site.help.community-guidelines')->with(compact('page'))->render(); + }); + } - public function privacy(Request $request) - { - $page = Cache::remember('site:privacy', now()->addDays(120), function() { - $slug = '/site/privacy'; - $page = Page::whereSlug($slug)->whereActive(true)->first(); - }); - return View::make('site.privacy')->with(compact('page'))->render(); - } + public function privacy(Request $request) + { + $page = Cache::remember('site:privacy', now()->addDays(120), function() { + $slug = '/site/privacy'; + $page = Page::whereSlug($slug)->whereActive(true)->first(); + }); + return View::make('site.privacy')->with(compact('page'))->render(); + } - public function terms(Request $request) - { - $page = Cache::remember('site:terms', now()->addDays(120), function() { - $slug = '/site/terms'; - return Page::whereSlug($slug)->whereActive(true)->first(); - }); - return View::make('site.terms')->with(compact('page'))->render(); - } + public function terms(Request $request) + { + $page = Cache::remember('site:terms', now()->addDays(120), function() { + $slug = '/site/terms'; + return Page::whereSlug($slug)->whereActive(true)->first(); + }); + return View::make('site.terms')->with(compact('page'))->render(); + } - public function redirectUrl(Request $request) - { - abort_if(!$request->user(), 404); - $this->validate($request, [ - 'url' => 'required|url' - ]); - $url = request()->input('url'); - abort_if(Helpers::validateUrl($url) == false, 404); - return view('site.redirect', compact('url')); - } + public function redirectUrl(Request $request) + { + abort_if(!$request->user(), 404); + $this->validate($request, [ + 'url' => 'required|url' + ]); + $url = request()->input('url'); + abort_if(Helpers::validateUrl($url) == false, 404); + return view('site.redirect', compact('url')); + } - public function followIntent(Request $request) - { - $this->validate($request, [ - 'user' => 'string|min:1|max:15|exists:users,username', - ]); - $profile = Profile::whereUsername($request->input('user'))->firstOrFail(); - $user = $request->user(); - abort_if($user && $profile->id == $user->profile_id, 404); - $following = $user != null ? FollowerService::follows($user->profile_id, $profile->id) : false; - return view('site.intents.follow', compact('profile', 'user', 'following')); - } + public function followIntent(Request $request) + { + $this->validate($request, [ + 'user' => 'string|min:1|max:15|exists:users,username', + ]); + $profile = Profile::whereUsername($request->input('user'))->firstOrFail(); + $user = $request->user(); + abort_if($user && $profile->id == $user->profile_id, 404); + $following = $user != null ? FollowerService::follows($user->profile_id, $profile->id) : false; + return view('site.intents.follow', compact('profile', 'user', 'following')); + } - public function legacyProfileRedirect(Request $request, $username) - { - $username = Str::contains($username, '@') ? '@' . $username : $username; - if(str_contains($username, '@')) { - $profile = Profile::whereUsername($username) - ->firstOrFail(); + public function legacyProfileRedirect(Request $request, $username) + { + $username = Str::contains($username, '@') ? '@' . $username : $username; + if(str_contains($username, '@')) { + $profile = Profile::whereUsername($username) + ->firstOrFail(); - if($profile->domain == null) { - $url = "/$profile->username"; - } else { - $url = "/i/web/profile/_/{$profile->id}"; - } + if($profile->domain == null) { + $url = "/$profile->username"; + } else { + $url = "/i/web/profile/_/{$profile->id}"; + } - } else { - $profile = Profile::whereUsername($username) - ->whereNull('domain') - ->firstOrFail(); - $url = "/$profile->username"; - } + } else { + $profile = Profile::whereUsername($username) + ->whereNull('domain') + ->firstOrFail(); + $url = "/$profile->username"; + } - return redirect($url); - } + return redirect($url); + } } diff --git a/resources/views/site/about.blade.php b/resources/views/site/about.blade.php index 04f505118..abe918416 100644 --- a/resources/views/site/about.blade.php +++ b/resources/views/site/about.blade.php @@ -1,138 +1,238 @@ -@extends('layouts.anon') + + + -@section('content') -
-
-

About

-

Pixelfed is an image sharing platform, an ethical alternative to centralized platforms.

-
-
-
-
-
-
- - - username - + + + + + {{ config('app.name', 'Pixelfed') }} + + + + + + + + + + + + + + +
+
+

+ Home + Newsroom +

+
+
+ + + +

{{ config_cache('about.title') ?? 'Photo Sharing. For Everyone' }}

+
+

+ {!! config_cache('app.description') ?? config_cache('app.short_description') ?? 'Pixelfed is an image sharing platform, an ethical alternative to centralized platforms.'!!} +

-
- -
- -
-
-
-
-
-
-

- Ad Free -

-

No Ads or Trackers

-
-
-
-
-
-
-

- Chronological -

-

Timelines in order

-
-
-
-
-
-
-

- Federated -

-

A network of millions

-
-
-
-
-
-
-

- Discover -

-

Discover popular posts

-
-
-
-
-
-
-

- Photo Filters -

-

Add an optional filter

-
-
-
-
-
-
-

- Stories -

-

Coming Soon!

-
+ @endif
-
-
-@endsection -@push('meta') - -@endpush \ No newline at end of file +
+
+
+
+ @include('layouts.partial.footer') + + diff --git a/resources/views/site/index.blade.php b/resources/views/site/index.blade.php index c98a2fb43..d08fc4c48 100644 --- a/resources/views/site/index.blade.php +++ b/resources/views/site/index.blade.php @@ -1,309 +1,144 @@ - - - - - - + + + + - {{ config('app.name', 'Laravel') }} + - - - - - + {{ config('app.name', 'Laravel') }} - - - - - - - + + + + + + + + + + + + + -
-
-
-
-
-
-

Photo Sharing

-

For Everyone.

-
-
-
-
-
- - Pixelfed -
-
-

Photo Sharing. For Everyone

-
-
-
-
-

Account Login

-
-
-
- @csrf -
+
+
+
+
+
+
+

Photo Sharing

+

For Everyone.

+
+
+
+
+
+ + Pixelfed +
+
+

Photo Sharing. For Everyone

+
+
+
+
+

Account Login

+
+
+ + @csrf +
-
- +
+ - @if ($errors->has('email')) - - {{ $errors->first('email') }} - - @endif -
-
+ @if ($errors->has('email')) + + {{ $errors->first('email') }} + + @endif +
+
-
+
-
- +
+ - @if ($errors->has('password')) - - {{ $errors->first('password') }} - - @endif -
-
+ @if ($errors->has('password')) + + {{ $errors->first('password') }} + + @endif +
+
-
-
-
- -
-
-
- @if(config('captcha.enabled')) -
- {!! Captcha::display() !!} -
- @endif -
-
- +
+
+
+ +
+
+
+ @if(config('captcha.enabled')) +
+ {!! Captcha::display() !!} +
+ @endif +
+
+ -
-
- -
-
-
-
-

- @if(config('pixelfed.open_registration')) - Register - · - @endif - Password Reset -

-
-
-
-
-
-
-
-
-
-
-
- -
-
-
-
- -
-
-
-
- -
-
-
-
- -
-
-
-
- -
-
-
-
- -
-
-
-
- -
-
-
-
- -
-
-
-
- -
-
-
-
-
-
-
-
-

Simple. Powerful.

-
-
-
- - {{$data['stats']['posts']}} - Posts - - - {{$data['stats']['likes']}} - Likes - - - {{$data['stats']['hashtags']}} - Hashtags Used - -
-
-
-

A free and ethical photo sharing platform.

-
-
-
-
-
-
-
-

Feature Packed.

-
-
-

The best for the brightest.

-
-
-
-
-
-
-
-
- -
-
-

Albums

- Create an album with up to {{config('pixelfed.max_album_length')}} photos -
-
-
-
-
-
- -
-
-

Collections

- Organize your posts -
-
-
-
-
-
- -
-
-

Filters

- Add a filter to your photos -
-
-
- -
-
-
-
-
- -
-
-

Comments

- Comment on a post, or send a reply -
-
-
-
-
-
- -
-
-

Discover

- Explore categories, hashtags and topics -
-
-
- @if(config('instance.stories.enabled')) -
-
-
- -
-
-

Stories

- Share posts that disappear after 24h -
-
-
- @endif -
-
-
-
- @include('layouts.partial.footer') +
+
+ +
+
+
+
+

+ @if(config('pixelfed.open_registration')) + Register + · + @endif + Password Reset +

+
+
+
+
+ + + @include('layouts.partial.footer') From 444c6d5163967eca60cca8947ae89de0e1a1bf09 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 23 May 2021 23:09:59 -0600 Subject: [PATCH 3/3] Update changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c2119eb3c..2a189e95e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -91,6 +91,8 @@ - Updated admin settings, add rules. ([a4efbb75](https://github.com/pixelfed/pixelfed/commit/a4efbb75)) - Updated LikeService, fix authentication bug. ([c9abd70e](https://github.com/pixelfed/pixelfed/commit/c9abd70e)) - Updated StatusTransformer, fix missing tags attribute. ([dac326e9](https://github.com/pixelfed/pixelfed/commit/dac326e9)) +- Updated ComposeController, bail on empty attachments. ([061b145b](https://github.com/pixelfed/pixelfed/commit/061b145b)) +- Updated landing and about page. ([92dc7af6](https://github.com/pixelfed/pixelfed/commit/92dc7af6)) - ([](https://github.com/pixelfed/pixelfed/commit/)) ## [v0.10.10 (2021-01-28)](https://github.com/pixelfed/pixelfed/compare/v0.10.9...v0.10.10)