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
- Custom content warnings/spoiler text ([d4864213](https://github.com/pixelfed/pixelfed/commit/d4864213))
- Add NetworkTimelineService cache ([1310d95c](https://github.com/pixelfed/pixelfed/commit/1310d95c))
- Customizable Legal Notice page ([0b7d0a96](https://github.com/pixelfed/pixelfed/commit/0b7d0a96))
### 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.
@ -59,6 +60,7 @@
- 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))
- 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/))
## [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 Auth, Cache;
use App\Page;
use App\Services\ConfigCacheService;
class PageController extends Controller
{
@ -18,7 +19,8 @@ class PageController extends Controller
'/site/about' => 'site:about',
'/site/privacy' => 'site:privacy',
'/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->active = (bool) $request->input('active');
$page->save();
if($page->cached) {
$keys = $this->cacheKeys();
$key = $keys[$page->slug];
Cache::forget($key);
$keys = $this->cacheKeys();
$key = $keys[$page->slug];
Cache::forget($key);
if($page->slug === '/site/legal-notice') {
ConfigCacheService::put('instance.has_legal_notice', $page->active);
}
return response()->json(['msg' => 200]);
}
@ -75,14 +78,17 @@ class PageController extends Controller
]);
$page = Page::findOrFail($request->input('id'));
$keys = $this->cacheKeys();
$key = $keys[$page->slug];
$page->delete();
Cache::forget($key);
return redirect(route('admin.settings.pages'));
}
public function generatePage(Request $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');
@ -103,6 +109,10 @@ class PageController extends Controller
case 'community_guidelines':
Page::firstOrCreate(['slug' => '/site/kb/community-guidelines']);
break;
case 'legal_notice':
Page::firstOrCreate(['slug' => '/site/legal-notice']);
break;
}
return redirect(route('admin.settings.pages'));

View File

@ -243,6 +243,10 @@ class ProfileController extends Controller
{
$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) {
return response($res)->withHeaders(['X-Frame-Options' => 'ALLOWALL']);
}

View File

@ -154,4 +154,14 @@ class SiteController extends Controller
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)
{
if(!config('instance.embed.post')) {
$res = view('status.embed-removed');
return response($res)->withHeaders(['X-Frame-Options' => 'ALLOWALL']);
}
$profile = Profile::whereNull(['domain','status'])
->whereIsPrivate(false)
->whereUsername($username)

View File

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

View File

@ -84,4 +84,11 @@ return [
],
'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>
</div>
@if($pages->count() < 4)
@if($pages->count() < 5)
<div class="col-12">
<hr>
<div class="btn-group">
@ -37,12 +37,19 @@
</form>
@endif
@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
<input type="hidden" name="page" value="community_guidelines">
<button type="submit" class="btn btn-default font-weight-bold">Customize Guidelines Page</button>
</form>
@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>
@endif

View File

@ -7,6 +7,9 @@
<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.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 class="text-center text-muted small mb-0">
<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::post('report', 'Api\ApiV1Dot1Controller@report')->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) {

View File

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