Merge pull request #4049 from pixelfed/staging

Staging
This commit is contained in:
daniel 2022-12-31 00:40:46 -07:00 committed by GitHub
commit 9de3163af6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 173 additions and 162 deletions

View file

@ -74,6 +74,8 @@
- Update lexer/extractor to handle banned hashtags ([909a8a5a](https://github.com/pixelfed/pixelfed/commit/909a8a5a)) - Update lexer/extractor to handle banned hashtags ([909a8a5a](https://github.com/pixelfed/pixelfed/commit/909a8a5a))
- Update FederationController, fix double lock bug ([9fcccca9](https://github.com/pixelfed/pixelfed/commit/9fcccca9)) - Update FederationController, fix double lock bug ([9fcccca9](https://github.com/pixelfed/pixelfed/commit/9fcccca9))
- Update AdminInvite component, fix email regex ([2aea77d3](https://github.com/pixelfed/pixelfed/commit/2aea77d3)) - Update AdminInvite component, fix email regex ([2aea77d3](https://github.com/pixelfed/pixelfed/commit/2aea77d3))
- Update database config, use single transaction and skip lock tables for mysql dump ([936f1e7a](https://github.com/pixelfed/pixelfed/commit/936f1e7a))
- Update database config, add sticky flag https://laravel.com/docs/9.x/database#the-sticky-option ([10b65980](https://github.com/pixelfed/pixelfed/commit/10b65980))
- ([](https://github.com/pixelfed/pixelfed/commit/)) - ([](https://github.com/pixelfed/pixelfed/commit/))
## [v0.11.4 (2022-10-04)](https://github.com/pixelfed/pixelfed/compare/v0.11.3...v0.11.4) ## [v0.11.4 (2022-10-04)](https://github.com/pixelfed/pixelfed/compare/v0.11.3...v0.11.4)

View file

@ -264,6 +264,10 @@ class AdminController extends Controller
]); ]);
$changed = false; $changed = false;
$changedFields = []; $changedFields = [];
$slug = str_slug($request->input('title'));
if(Newsroom::whereSlug($slug)->exists()) {
$slug = $slug . '-' . str_random(4);
}
$news = Newsroom::findOrFail($id); $news = Newsroom::findOrFail($id);
$fields = [ $fields = [
'title' => 'string', 'title' => 'string',
@ -281,7 +285,7 @@ class AdminController extends Controller
case 'string': case 'string':
if($request->{$field} != $news->{$field}) { if($request->{$field} != $news->{$field}) {
if($field == 'title') { if($field == 'title') {
$news->slug = str_slug($request->{$field}); $news->slug = $slug;
} }
$news->{$field} = $request->{$field}; $news->{$field} = $request->{$field};
$changed = true; $changed = true;
@ -327,6 +331,10 @@ class AdminController extends Controller
]); ]);
$changed = false; $changed = false;
$changedFields = []; $changedFields = [];
$slug = str_slug($request->input('title'));
if(Newsroom::whereSlug($slug)->exists()) {
$slug = $slug . '-' . str_random(4);
}
$news = new Newsroom(); $news = new Newsroom();
$fields = [ $fields = [
'title' => 'string', 'title' => 'string',
@ -344,7 +352,7 @@ class AdminController extends Controller
case 'string': case 'string':
if($request->{$field} != $news->{$field}) { if($request->{$field} != $news->{$field}) {
if($field == 'title') { if($field == 'title') {
$news->slug = str_slug($request->{$field}); $news->slug = $slug;
} }
$news->{$field} = $request->{$field}; $news->{$field} = $request->{$field};
$changed = true; $changed = true;

View file

@ -48,6 +48,7 @@ return [
'username' => env('DB_USERNAME', 'forge'), 'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''), 'password' => env('DB_PASSWORD', ''),
'unix_socket' => env('DB_SOCKET', ''), 'unix_socket' => env('DB_SOCKET', ''),
'sticky' => true,
'charset' => 'utf8mb4', 'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci', 'collation' => 'utf8mb4_unicode_ci',
'prefix' => '', 'prefix' => '',

View file

@ -1,114 +1,81 @@
@extends('admin.partial.template-full') @extends('admin.partial.template-full')
@section('section') @section('section')
<div class="row"> </div>
<div class="col-12"> <div class="header bg-primary pb-3 mt-n4">
<div class="d-flex justify-content-between align-items-center"> <div class="container-fluid">
<div class="header-body">
<div class="row align-items-center py-4">
<div class="col-lg-6 col-7">
<p class="display-1 text-white mb-0">Newsroom - Edit</p>
<p class="lead text-white my-0">Editing #{{$news->id}}</p>
</div>
<div class="title"> <div class="col-lg-6 col-5">
<p class="h1 font-weight-bold">Newsroom</p> <div class="text-right">
<p class="lead mb-0">Edit Announcement</p> <button class="btn btn-danger px-4 mr-3 mb-1" style="font-size:13px;" id="btn-delete">Delete</button>
</div> @if($news->published_at)
<div> <a class="btn btn-dark px-4 mr-3 mb-1" style="font-size:13px;" href="{{$news->permalink()}}">View</a>
<a class="btn btn-outline-secondary px-2" style="font-size:13px;" href="{{route('admin.newsroom.home')}}"><i class="fas fa-chevron-left fa-sm text-lighter mr-1"></i> Back to Newsroom </a> @endif
</div> <button class="btn btn-success px-5 mb-1" style="font-size:13px;" onclick="saveForm()">Save</button>
</div> </div>
<hr> </div>
</div> </div>
<div class="col-md-7 border-right"> </div>
<div> </div>
<form method="post"> </div>
@csrf <div class="container-fluid mt-4">
<div class="form-group"> <div class="row justify-content-center">
<label for="title" class="small font-weight-bold text-muted text-uppercase">Title</label> <div class="col-md-6 col-12">
<input type="text" class="form-control" id="title" name="title" value="{{$news->title}}"> <div>
<p class="help-text mb-0 small font-weight-bold text-lighter">We recommend titles shorter than 80 characters.</p> <form method="post" id="editForm">
</div> @csrf
<div class="form-group"> <div class="form-group">
<label for="summary" class="small font-weight-bold text-muted text-uppercase">Summary</label> <label for="title" class="small font-weight-bold text-muted text-uppercase">Title</label>
<textarea class="form-control" id="summary" name="summary" rows="3">{{$news->summary}}</textarea> <input type="text" class="form-control" id="title" name="title" value="{{$news->title}}">
</div> <p class="help-text mb-0 small font-weight-bold text-lighter">We recommend titles shorter than 80 characters.</p>
<div class="form-group"> </div>
<label for="body" class="small font-weight-bold text-muted text-uppercase">Body</label> <div class="form-group">
<textarea class="form-control" id="body" name="body" rows="6">{{$news->body}}</textarea> <label for="summary" class="small font-weight-bold text-muted text-uppercase">Summary</label>
<p class="help-text mb-0 small font-weight-bold text-lighter">Click <a href="#">here</a> to enable the rich text editor.</p> <textarea class="form-control" id="summary" name="summary" rows="3">{{$news->summary}}</textarea>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="category" class="small font-weight-bold text-muted text-uppercase">Category</label> <label for="body" class="small font-weight-bold text-muted text-uppercase">Body</label>
<input type="text" class="form-control" id="category" name="category" value="{{$news->category}}"> <textarea class="form-control" id="body" name="body" rows="6">{{$news->body}}</textarea>
</div> </div>
</div> <div class="form-group">
<label for="category" class="small font-weight-bold text-muted text-uppercase">Category</label>
<input type="text" class="form-control" id="category" name="category" value="{{$news->category}}">
</div>
</div> <div class="form-group">
<div class="col-md-5"> <div class="custom-control custom-switch ml-5">
<label class="small font-weight-bold text-muted text-uppercase">Preview</label> <input type="checkbox" class="custom-control-input" id="published" name="published" {{$news->published_at ? 'checked="checked"' : ''}}>
<div class="card border shadow-none mb-3"> <label class="custom-control-label font-weight-bold text-uppercase text-muted" for="published">Published</label>
<div class="card-body"> </div>
<div class="card-title mb-0"> </div>
<span class="font-weight-bold" id="preview_title">{{$news->title}}</span> <div class="form-group">
<span class="float-right cursor-pointer" title="Close"><i class="fas fa-times text-lighter"></i></span> <div class="custom-control custom-switch ml-5">
</div> <input type="checkbox" class="custom-control-input" id="show_timeline" name="show_timeline" {{$news->show_timeline ? 'checked="checked"' : ''}}>
<p class="card-text"> <label class="custom-control-label font-weight-bold text-uppercase text-muted" for="show_timeline">Show On Timelines</label>
<span style="font-size:13px;" id="preview_summary">{{$news->summary}}</span> </div>
</p> </div>
<p class="d-flex align-items-center justify-content-between mb-0"> <div class="form-group">
<a href="#" class="small font-weight-bold mb-0">Read more</a> <div class="custom-control custom-switch ml-5">
<span> <input type="checkbox" class="custom-control-input" id="auth_only" name="auth_only" {{$news->auth_only ? 'checked="checked"' : ''}}>
<span class="btn btn-outline-secondary btn-sm py-0 disabled"> <label class="custom-control-label font-weight-bold text-uppercase text-muted" for="auth_only">Logged in users only</label>
<i class="fas fa-chevron-left fa-sm"></i> </div>
</span> </div>
<span class="btn btn-outline-success btn-sm py-0 mx-1" title="Mark as Read" data-toggle="tooltip" data-placement="bottom"> <div class="form-group">
<i class="fas fa-check fa-sm"></i> <div class="custom-control custom-switch ml-5">
</span> <input type="checkbox" class="custom-control-input" id="show_link" name="show_link" {{$news->show_link ? 'checked="checked"' : ''}}>
<span class="btn btn-outline-secondary btn-sm py-0"> <label class="custom-control-label font-weight-bold text-uppercase text-muted" for="show_link">Show Read More Link</label>
<i class="fas fa-chevron-right fa-sm"></i> </div>
</span> </div>
</span> </form>
</p> </div>
</div> </div>
</div> </div>
<hr>
<p class="mt-3">
<button type="submit" class="btn btn-primary btn-block font-weight-bold py-1 px-4">Save</button>
</p>
<div class="form-group">
<div class="custom-control custom-switch">
<input type="checkbox" class="custom-control-input" id="published" name="published" {{$news->published_at ? 'checked="checked"' : ''}}>
<label class="custom-control-label font-weight-bold text-uppercase text-muted" for="published">Published</label>
</div>
</div>
<div class="form-group">
<div class="custom-control custom-switch">
<input type="checkbox" class="custom-control-input" id="show_timeline" name="show_timeline" {{$news->show_timeline ? 'checked="checked"' : ''}}>
<label class="custom-control-label font-weight-bold text-uppercase text-muted" for="show_timeline">Show On Timelines</label>
</div>
</div>
<div class="form-group">
<div class="custom-control custom-switch">
<input type="checkbox" class="custom-control-input" id="auth_only" name="auth_only" {{$news->auth_only ? 'checked="checked"' : ''}}>
<label class="custom-control-label font-weight-bold text-uppercase text-muted" for="auth_only">Logged in users only</label>
</div>
</div>
<div class="form-group">
<div class="custom-control custom-switch">
<input type="checkbox" class="custom-control-input" id="show_link" name="show_link" {{$news->show_link ? 'checked="checked"' : ''}}>
<label class="custom-control-label font-weight-bold text-uppercase text-muted" for="show_link">Show Read More Link</label>
</div>
</div>
{{-- <div class="form-group">
<div class="custom-control custom-switch">
<input type="checkbox" class="custom-control-input" id="force_modal" name="force_modal" {{$news->force_modal ? 'checked="checked"' : ''}}>
<label class="custom-control-label font-weight-bold text-uppercase text-muted" for="force_modal">Show Modal on timelines</label>
</div>
</div> --}}
<hr>
</form>
<p class="mt-1 d-flex justify-content-between">
<button type="button" class="btn btn-outline-secondary btn-sm font-weight-bold py-1 px-3">Preview</button>
<button type="button" class="btn btn-outline-danger btn-sm font-weight-bold py-1 px-3" id="btn-delete">Delete</button>
</p>
</div>
</div> </div>
<form id="delete-form" method="post"> <form id="delete-form" method="post">
@method('delete') @method('delete')
@ -118,6 +85,12 @@
@push('scripts') @push('scripts')
<script type="text/javascript"> <script type="text/javascript">
function saveForm() {
if(!window.confirm('Are you sure you want to save?')) {
return;
}
document.getElementById('editForm').submit();
}
$('#title').on('change keyup paste',function(e) { $('#title').on('change keyup paste',function(e) {
let el = $(this); let el = $(this);
let title = el.val() let title = el.val()

View file

@ -1,62 +1,89 @@
@extends('admin.partial.template-full') @extends('admin.partial.template-full')
@section('section') @section('section')
<div class="d-flex justify-content-between align-items-center"> </div>
<div class="header bg-primary pb-3 mt-n4">
<div class="container-fluid">
<div class="header-body">
<div class="row align-items-center py-4">
<div class="col-lg-6 col-7">
<p class="display-1 text-white mb-0">Newsroom</p>
<p class="lead text-white my-0">Manage News and Platform Tips</p>
</div>
<div class="title"> <div class="col-lg-6 col-5">
<p class="h1 font-weight-bold">Newsroom</p> <div class="text-right">
<p class="lead mb-0">Manage News and Platform Tips</p> <a class="btn btn-danger px-4" style="font-size:13px;" href="{{route('admin.newsroom.create')}}">New Announcement</a>
</div> <a class="btn btn-dark px-4 mr-3" style="font-size:13px;" href="/site/newsroom">View Newsroom <i class="fas fa-chevron-right fa-sm text-lighter ml-1"></i></a>
</div>
<div> </div>
<a class="btn btn-outline-success px-4" style="font-size:13px;" href="{{route('admin.newsroom.create')}}">New Announcement</a> </div>
<a class="btn btn-outline-secondary px-2 mr-3" style="font-size:13px;" href="/site/newsroom">View Newsroom <i class="fas fa-chevron-right fa-sm text-lighter ml-1"></i></a> </div>
</div> </div>
</div> </div>
<div class="my-5 row"> <div class="container-fluid mt-4">
<div class="col-md-8 offset-md-2"> <div class="row mb-3 justify-content-between">
<div class="card"> <div class="col-12">
<div class="card-header bg-light lead font-weight-bold"> @if($newsroom->count() > 0)
Announcements <div class="table-responsive">
</div> <table class="table table-dark">
@if($newsroom->count() > 0) <thead class="thead-dark">
<ul class="list-group list-group-flush"> <tr>
@foreach($newsroom as $news) <th scope="col">ID</th>
<li class="list-group-item d-flex align-items-center justify-content-between"> <th scope="col">Title</th>
<div> <th scope="col">Slug</th>
<p class="mb-0 font-weight-bold">{{str_limit($news->title,30)}}</p> <th scope="col">Status</th>
<p class="mb-0 small">{{str_limit($news->summary, 40)}}</p> <th scope="col">Updated</th>
</div> </tr>
<div> </thead>
@if($news->published_at != null) <tbody>
<span class="btn btn-success btn-sm px-2 py-0 font-weight-bold mr-3">PUBLISHED</span> @foreach($newsroom as $news)
@else <tr>
<span class="btn btn-outline-secondary btn-sm px-2 py-0 font-weight-bold mr-3">DRAFT</span> <td class="font-weight-bold text-monospace text-muted">
@endif <a href="{{$news->editUrl()}}">
<a class="btn btn-outline-lighter btn-sm mr-2" title="Edit Post" data-toggle="tooltip" data-placement="bottom" href="{{$news->editUrl()}}"> {{ $news->id }}
<i class="fas fa-edit"></i> </a>
</a> </td>
@if($news->published_at) <td class="font-weight-bold">
<a class="btn btn-outline-lighter btn-sm" title="View Post" data-toggle="tooltip" data-placement="bottom" href="{{$news->permalink()}}"> <div>
<i class="fas fa-eye"></i> <p class="mb-0 font-weight-bold">{{str_limit($news->title, 50)}}</p>
</a> {{-- <p class="mb-0 small">{{str_limit($news->summary, 80)}}</p> --}}
@endif </div>
</div> </td>
</li> <td class="text-muted">
@endforeach @if($news->published_at)
</ul> <a href="{{$news->permalink()}}" class="font-weight-bold" target="_blank">{{$news->slug}}</a>
@else @else
<div class="card-body text-center"> {{ $news->slug }}
<p class="lead mb-0 p-5">No Announcements Found!</p> @endif
</div> </td>
@endif <td class="font-weight-bold">
</div> @if($news->published_at != null)
<div class="d-flex justify-content-center mt-4"> <span class="badge badge-success font-weight-bold mr-3">PUBLISHED</span>
{!!$newsroom->links()!!} @else
</div> <span class="badge badge-dark font-weight-bold mr-3">DRAFT</span>
</div> @endif
</td>
<td class="font-weight-bold">
{{ $news->updated_at->diffForHumans() }}
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
<div class="d-flex justify-content-center mt-4">
{!!$newsroom->links()!!}
</div>
@else
<div class="card-body text-center">
<p class="lead mb-0 p-5">No Announcements Found!</p>
</div>
@endif
</div>
</div>
</div> </div>
@endsection @endsection