Merge pull request #3624 from pixelfed/staging

Staging
This commit is contained in:
daniel 2022-08-16 03:00:12 -06:00 committed by GitHub
commit e25248b230
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 83 additions and 8 deletions

View file

@ -5,6 +5,7 @@
### New Features ### New Features
- Custom content warnings/spoiler text ([d4864213](https://github.com/pixelfed/pixelfed/commit/d4864213)) - Custom content warnings/spoiler text ([d4864213](https://github.com/pixelfed/pixelfed/commit/d4864213))
- Add NetworkTimelineService cache ([1310d95c](https://github.com/pixelfed/pixelfed/commit/1310d95c)) - Add NetworkTimelineService cache ([1310d95c](https://github.com/pixelfed/pixelfed/commit/1310d95c))
- Customizable Legal Notice page ([0b7d0a96](https://github.com/pixelfed/pixelfed/commit/0b7d0a96))
### Breaking ### Breaking
- Replaced `predis` with `phpredis` as default redis driver due to predis being deprecated, install [phpredis](https://github.com/phpredis/phpredis/blob/develop/INSTALL.markdown) if you're still using predis. - Replaced `predis` with `phpredis` as default redis driver due to predis being deprecated, install [phpredis](https://github.com/phpredis/phpredis/blob/develop/INSTALL.markdown) if you're still using predis.
@ -59,6 +60,7 @@
- Fix AdminStatService cache key, fixes #3612 ([d1dbed89](https://github.com/pixelfed/pixelfed/commit/d1dbed89)) - Fix AdminStatService cache key, fixes #3612 ([d1dbed89](https://github.com/pixelfed/pixelfed/commit/d1dbed89))
- Improve mute/block v1 api endpoints, fixes #3540 ([c3e8a0e4](https://github.com/pixelfed/pixelfed/commit/c3e8a0e4)) - Improve mute/block v1 api endpoints, fixes #3540 ([c3e8a0e4](https://github.com/pixelfed/pixelfed/commit/c3e8a0e4))
- Set Last-Modified header for atom feeds, fixes #2988 ([c18dcde3](https://github.com/pixelfed/pixelfed/commit/c18dcde3)) - Set Last-Modified header for atom feeds, fixes #2988 ([c18dcde3](https://github.com/pixelfed/pixelfed/commit/c18dcde3))
- Add instance post/profile embed config setting ([7734dc03](https://github.com/pixelfed/pixelfed/commit/7734dc03))
- ([](https://github.com/pixelfed/pixelfed/commit/)) - ([](https://github.com/pixelfed/pixelfed/commit/))
## [v0.11.3 (2022-05-09)](https://github.com/pixelfed/pixelfed/compare/v0.11.2...v0.11.3) ## [v0.11.3 (2022-05-09)](https://github.com/pixelfed/pixelfed/compare/v0.11.2...v0.11.3)

View file

@ -5,6 +5,7 @@ namespace App\Http\Controllers;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Auth, Cache; use Auth, Cache;
use App\Page; use App\Page;
use App\Services\ConfigCacheService;
class PageController extends Controller class PageController extends Controller
{ {
@ -18,7 +19,8 @@ class PageController extends Controller
'/site/about' => 'site:about', '/site/about' => 'site:about',
'/site/privacy' => 'site:privacy', '/site/privacy' => 'site:privacy',
'/site/terms' => 'site:terms', '/site/terms' => 'site:terms',
'/site/kb/community-guidelines' => 'site:help:community-guidelines' '/site/kb/community-guidelines' => 'site:help:community-guidelines',
'/site/legal-notice' => 'site:legal-notice'
]; ];
} }
@ -60,10 +62,11 @@ class PageController extends Controller
$page->title = $request->input('title'); $page->title = $request->input('title');
$page->active = (bool) $request->input('active'); $page->active = (bool) $request->input('active');
$page->save(); $page->save();
if($page->cached) { $keys = $this->cacheKeys();
$keys = $this->cacheKeys(); $key = $keys[$page->slug];
$key = $keys[$page->slug]; Cache::forget($key);
Cache::forget($key); if($page->slug === '/site/legal-notice') {
ConfigCacheService::put('instance.has_legal_notice', $page->active);
} }
return response()->json(['msg' => 200]); return response()->json(['msg' => 200]);
} }
@ -75,14 +78,17 @@ class PageController extends Controller
]); ]);
$page = Page::findOrFail($request->input('id')); $page = Page::findOrFail($request->input('id'));
$keys = $this->cacheKeys();
$key = $keys[$page->slug];
$page->delete(); $page->delete();
Cache::forget($key);
return redirect(route('admin.settings.pages')); return redirect(route('admin.settings.pages'));
} }
public function generatePage(Request $request) public function generatePage(Request $request)
{ {
$this->validate($request, [ $this->validate($request, [
'page' => 'required|string|in:about,terms,privacy,community_guidelines', 'page' => 'required|string|in:about,terms,privacy,community_guidelines,legal_notice',
]); ]);
$page = $request->input('page'); $page = $request->input('page');
@ -103,6 +109,10 @@ class PageController extends Controller
case 'community_guidelines': case 'community_guidelines':
Page::firstOrCreate(['slug' => '/site/kb/community-guidelines']); Page::firstOrCreate(['slug' => '/site/kb/community-guidelines']);
break; break;
case 'legal_notice':
Page::firstOrCreate(['slug' => '/site/legal-notice']);
break;
} }
return redirect(route('admin.settings.pages')); return redirect(route('admin.settings.pages'));

View file

@ -243,6 +243,10 @@ class ProfileController extends Controller
{ {
$res = view('profile.embed-removed'); $res = view('profile.embed-removed');
if(!config('instance.embed.profile')) {
return response($res)->withHeaders(['X-Frame-Options' => 'ALLOWALL']);
}
if(strlen($username) > 15 || strlen($username) < 2) { if(strlen($username) > 15 || strlen($username) < 2) {
return response($res)->withHeaders(['X-Frame-Options' => 'ALLOWALL']); return response($res)->withHeaders(['X-Frame-Options' => 'ALLOWALL']);
} }

View file

@ -154,4 +154,14 @@ class SiteController extends Controller
return redirect($url); return redirect($url);
} }
public function legalNotice(Request $request)
{
$page = Cache::remember('site:legal-notice', now()->addDays(120), function() {
$slug = '/site/legal-notice';
return Page::whereSlug($slug)->whereActive(true)->first();
});
abort_if(!$page, 404);
return View::make('site.legal-notice')->with(compact('page'))->render();
}
} }

View file

@ -106,6 +106,11 @@ class StatusController extends Controller
public function showEmbed(Request $request, $username, int $id) public function showEmbed(Request $request, $username, int $id)
{ {
if(!config('instance.embed.post')) {
$res = view('status.embed-removed');
return response($res)->withHeaders(['X-Frame-Options' => 'ALLOWALL']);
}
$profile = Profile::whereNull(['domain','status']) $profile = Profile::whereNull(['domain','status'])
->whereIsPrivate(false) ->whereIsPrivate(false)
->whereUsername($username) ->whereUsername($username)

View file

@ -53,6 +53,8 @@ class ConfigCacheService
'account.autofollow', 'account.autofollow',
'account.autofollow_usernames', 'account.autofollow_usernames',
'config.discover.features', 'config.discover.features',
'instance.has_legal_notice',
// 'system.user_mode' // 'system.user_mode'
]; ];

View file

@ -84,4 +84,11 @@ return [
], ],
'enable_cc' => env('ENABLE_CONFIG_CACHE', false), 'enable_cc' => env('ENABLE_CONFIG_CACHE', false),
'has_legal_notice' => env('INSTANCE_LEGAL_NOTICE', false),
'embed' => [
'profile' => env('INSTANCE_PROFILE_EMBEDS', true),
'post' => env('INSTANCE_POST_EMBEDS', true),
],
]; ];

View file

@ -11,7 +11,7 @@
<p class="lead text-white mt-n4 mb-0">Manage public and custom page content</p> <p class="lead text-white mt-n4 mb-0">Manage public and custom page content</p>
</div> </div>
@if($pages->count() < 4) @if($pages->count() < 5)
<div class="col-12"> <div class="col-12">
<hr> <hr>
<div class="btn-group"> <div class="btn-group">
@ -37,12 +37,19 @@
</form> </form>
@endif @endif
@if(!$pages->contains('slug', '=', '/site/kb/community-guidelines')) @if(!$pages->contains('slug', '=', '/site/kb/community-guidelines'))
<form class="form-inline" method="post" action="/i/admin/settings/pages/create"> <form class="form-inline mr-1" method="post" action="/i/admin/settings/pages/create">
@csrf @csrf
<input type="hidden" name="page" value="community_guidelines"> <input type="hidden" name="page" value="community_guidelines">
<button type="submit" class="btn btn-default font-weight-bold">Customize Guidelines Page</button> <button type="submit" class="btn btn-default font-weight-bold">Customize Guidelines Page</button>
</form> </form>
@endif @endif
@if(!$pages->contains('slug', '=', '/site/legal-notice'))
<form class="form-inline" method="post" action="/i/admin/settings/pages/create">
@csrf
<input type="hidden" name="page" value="legal_notice">
<button type="submit" class="btn btn-default font-weight-bold">Customize Legal Notice Page</button>
</form>
@endif
</div> </div>
</div> </div>
@endif @endif

View file

@ -7,6 +7,9 @@
<a href="{{route('site.terms')}}" class="text-dark p-2">{{__('site.terms')}}</a> <a href="{{route('site.terms')}}" class="text-dark p-2">{{__('site.terms')}}</a>
<a href="{{route('site.privacy')}}" class="text-dark p-2">{{__('site.privacy')}}</a> <a href="{{route('site.privacy')}}" class="text-dark p-2">{{__('site.privacy')}}</a>
<a href="{{route('site.language')}}" class="text-dark p-2">{{__('site.language')}}</a> <a href="{{route('site.language')}}" class="text-dark p-2">{{__('site.language')}}</a>
@if(config_cache('instance.has_legal_notice'))
<a href="/site/legal-notice" class="text-dark p-2">Legal Notice</a>
@endif
</p> </p>
<p class="text-center text-muted small mb-0"> <p class="text-center text-muted small mb-0">
<span class="text-muted">© {{date('Y')}} {{config('pixelfed.domain.app')}}</span> <span class="text-muted">© {{date('Y')}} {{config('pixelfed.domain.app')}}</span>

View file

@ -0,0 +1,19 @@
@extends('layouts.app')
@section('content')
<div class="container mt-5">
<div class="col-12">
<p class="font-weight-bold text-lighter text-uppercase">{{ $page->title ?? 'Legal Notice' }}</p>
<div class="card border shadow-none">
<div class="card-body p-md-5 text-justify mx-md-3" style="white-space: pre-line">
@if($page && $page->content)
{!! $page->content !!}
@endif
</div>
</div>
</div>
</div>
@endsection
@push('meta')
<meta property="og:description" content="{{ $page->title ?? 'Legal Notice' }}">
@endpush

View file

@ -100,6 +100,11 @@ Route::group(['prefix' => 'api'], function() use($middleware) {
Route::group(['prefix' => 'v1.1'], function() use($middleware) { Route::group(['prefix' => 'v1.1'], function() use($middleware) {
Route::post('report', 'Api\ApiV1Dot1Controller@report')->middleware($middleware); Route::post('report', 'Api\ApiV1Dot1Controller@report')->middleware($middleware);
Route::delete('accounts/avatar', 'Api\ApiV1Dot1Controller@deleteAvatar')->middleware($middleware); Route::delete('accounts/avatar', 'Api\ApiV1Dot1Controller@deleteAvatar')->middleware($middleware);
Route::get('direct/thread', 'DirectMessageController@thread')->middleware($middleware);
Route::group(['prefix' => 'stories'], function () use($middleware) {
Route::get('recent', 'StoryController@recent')->middleware($middleware);
});
}); });
Route::group(['prefix' => 'live'], function() use($middleware) { Route::group(['prefix' => 'live'], function() use($middleware) {

View file

@ -513,6 +513,7 @@ Route::domain(config('pixelfed.domain.app'))->middleware(['validemail', 'twofact
Route::get('newsroom/archive', 'NewsroomController@archive'); Route::get('newsroom/archive', 'NewsroomController@archive');
Route::get('newsroom/search', 'NewsroomController@search'); Route::get('newsroom/search', 'NewsroomController@search');
Route::get('newsroom', 'NewsroomController@index'); Route::get('newsroom', 'NewsroomController@index');
Route::get('legal-notice', 'SiteController@legalNotice');
}); });
Route::group(['prefix' => 'timeline'], function () { Route::group(['prefix' => 'timeline'], function () {