Add custom css to admin dashboard

This commit is contained in:
Daniel Supernault 2024-06-29 18:39:11 -06:00
parent f671fdb16c
commit ecf22b54d5
No known key found for this signature in database
GPG key ID: 23740873EE6F76A1
3 changed files with 569 additions and 495 deletions

View file

@ -2,57 +2,45 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\{ use App\Contact;
AccountInterstitial, use App\Http\Controllers\Admin\AdminAutospamController;
Contact, use App\Http\Controllers\Admin\AdminDirectoryController;
Hashtag, use App\Http\Controllers\Admin\AdminDiscoverController;
Instance, use App\Http\Controllers\Admin\AdminHashtagsController;
Newsroom, use App\Http\Controllers\Admin\AdminInstanceController;
OauthClient, use App\Http\Controllers\Admin\AdminMediaController;
Profile, use App\Http\Controllers\Admin\AdminReportController;
Report, use App\Http\Controllers\Admin\AdminSettingsController;
Status, use App\Http\Controllers\Admin\AdminUserController;
StatusHashtag, use App\Instance;
Story, use App\Models\CustomEmoji;
User use App\Newsroom;
}; use App\OauthClient;
use DB, Cache, Storage; use App\Profile;
use Carbon\Carbon;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Redis;
use App\Http\Controllers\Admin\{
AdminAutospamController,
AdminDirectoryController,
AdminDiscoverController,
AdminHashtagsController,
AdminInstanceController,
AdminReportController,
// AdminGroupsController,
AdminMediaController,
AdminSettingsController,
// AdminStorageController,
AdminSupportController,
AdminUserController
};
use Illuminate\Validation\Rule;
use App\Services\AdminStatsService;
use App\Services\AccountService; use App\Services\AccountService;
use App\Services\AdminStatsService;
use App\Services\ConfigCacheService;
use App\Services\StatusService; use App\Services\StatusService;
use App\Services\StoryService; use App\Services\StoryService;
use App\Models\CustomEmoji; use App\Status;
use App\Story;
use App\User;
use Cache;
use DB;
use Illuminate\Http\Request;
use Illuminate\Validation\Rule;
use Storage;
class AdminController extends Controller class AdminController extends Controller
{ {
use AdminReportController, use AdminAutospamController,
AdminAutospamController,
AdminDirectoryController, AdminDirectoryController,
AdminDiscoverController, AdminDiscoverController,
AdminHashtagsController, AdminHashtagsController,
// AdminGroupsController,
AdminMediaController,
AdminSettingsController,
AdminInstanceController, AdminInstanceController,
// AdminStorageController, AdminMediaController,
AdminReportController,
AdminSettingsController,
AdminUserController; AdminUserController;
public function __construct() public function __construct()
@ -67,9 +55,27 @@ class AdminController extends Controller
return view('admin.home'); return view('admin.home');
} }
public function customCss()
{
return view('admin.settings.customcss');
}
public function saveCustomCss(Request $request)
{
$this->validate($request, [
'css' => 'sometimes|max:5000',
'show' => 'sometimes',
]);
ConfigCacheService::put('uikit.custom.css', $request->input('css'));
ConfigCacheService::put('uikit.show_custom.css', $request->boolean('show'));
return view('admin.settings.customcss');
}
public function stats() public function stats()
{ {
$data = AdminStatsService::get(); $data = AdminStatsService::get();
return view('admin.stats', compact('data')); return view('admin.stats', compact('data'));
} }
@ -83,25 +89,27 @@ class AdminController extends Controller
$users = User::orderByDesc('id')->cursorPaginate(10); $users = User::orderByDesc('id')->cursorPaginate(10);
$res = [ $res = [
"next_page_url" => $users->nextPageUrl(), 'next_page_url' => $users->nextPageUrl(),
"data" => $users->map(function($user) { 'data' => $users->map(function ($user) {
$account = AccountService::get($user->profile_id, true); $account = AccountService::get($user->profile_id, true);
if(!$account) { if (! $account) {
return [ return [
"id" => $user->profile_id, 'id' => $user->profile_id,
"username" => $user->username, 'username' => $user->username,
"status" => "deleted", 'status' => 'deleted',
"avatar" => "/storage/avatars/default.jpg", 'avatar' => '/storage/avatars/default.jpg',
"created_at" => $user->created_at 'created_at' => $user->created_at,
]; ];
} }
$account['user_id'] = $user->id; $account['user_id'] = $user->id;
return $account; return $account;
}) })
->filter(function($user) { ->filter(function ($user) {
return $user; return $user;
}) }),
]; ];
return $res; return $res;
} }
@ -112,14 +120,15 @@ class AdminController extends Controller
->cursorPaginate(10); ->cursorPaginate(10);
$res = [ $res = [
"next_page_url" => $posts->nextPageUrl(), 'next_page_url' => $posts->nextPageUrl(),
"data" => $posts->map(function($post) { 'data' => $posts->map(function ($post) {
$status = StatusService::get($post->id, false); $status = StatusService::get($post->id, false);
if(!$status) { if (! $status) {
return ["id" => $post->id, "created_at" => $post->created_at]; return ['id' => $post->id, 'created_at' => $post->created_at];
} }
return $status; return $status;
}) }),
]; ];
return $res; return $res;
@ -133,13 +142,14 @@ class AdminController extends Controller
public function statuses(Request $request) public function statuses(Request $request)
{ {
$statuses = Status::orderBy('id', 'desc')->cursorPaginate(10); $statuses = Status::orderBy('id', 'desc')->cursorPaginate(10);
$data = $statuses->map(function($status) { $data = $statuses->map(function ($status) {
return StatusService::get($status->id, false); return StatusService::get($status->id, false);
}) })
->filter(function($s) { ->filter(function ($s) {
return $s; return $s;
}) })
->toArray(); ->toArray();
return view('admin.statuses.home', compact('statuses', 'data')); return view('admin.statuses.home', compact('statuses', 'data'));
} }
@ -157,23 +167,24 @@ class AdminController extends Controller
'filter' => [ 'filter' => [
'nullable', 'nullable',
'string', 'string',
Rule::in(['all', 'local', 'remote']) Rule::in(['all', 'local', 'remote']),
] ],
]); ]);
$search = $request->input('search'); $search = $request->input('search');
$filter = $request->input('filter'); $filter = $request->input('filter');
$limit = 12; $limit = 12;
$profiles = Profile::select('id','username') $profiles = Profile::select('id', 'username')
->whereNull('status') ->whereNull('status')
->when($search, function($q, $search) { ->when($search, function ($q, $search) {
return $q->where('username', 'like', "%$search%"); return $q->where('username', 'like', "%$search%");
})->when($filter, function($q, $filter) { })->when($filter, function ($q, $filter) {
if($filter == 'local') { if ($filter == 'local') {
return $q->whereNull('domain'); return $q->whereNull('domain');
} }
if($filter == 'remote') { if ($filter == 'remote') {
return $q->whereNotNull('domain'); return $q->whereNotNull('domain');
} }
return $q; return $q;
})->orderByDesc('id') })->orderByDesc('id')
->simplePaginate($limit); ->simplePaginate($limit);
@ -185,13 +196,14 @@ class AdminController extends Controller
{ {
$profile = Profile::findOrFail($id); $profile = Profile::findOrFail($id);
$user = $profile->user; $user = $profile->user;
return view('admin.profiles.edit', compact('profile', 'user')); return view('admin.profiles.edit', compact('profile', 'user'));
} }
public function appsHome(Request $request) public function appsHome(Request $request)
{ {
$filter = $request->input('filter'); $filter = $request->input('filter');
if($filter == 'revoked') { if ($filter == 'revoked') {
$apps = OauthClient::with('user') $apps = OauthClient::with('user')
->whereNotNull('user_id') ->whereNotNull('user_id')
->whereRevoked(true) ->whereRevoked(true)
@ -203,39 +215,43 @@ class AdminController extends Controller
->orderByDesc('id') ->orderByDesc('id')
->paginate(10); ->paginate(10);
} }
return view('admin.apps.home', compact('apps')); return view('admin.apps.home', compact('apps'));
} }
public function messagesHome(Request $request) public function messagesHome(Request $request)
{ {
$messages = Contact::orderByDesc('id')->paginate(10); $messages = Contact::orderByDesc('id')->paginate(10);
return view('admin.messages.home', compact('messages')); return view('admin.messages.home', compact('messages'));
} }
public function messagesShow(Request $request, $id) public function messagesShow(Request $request, $id)
{ {
$message = Contact::findOrFail($id); $message = Contact::findOrFail($id);
return view('admin.messages.show', compact('message')); return view('admin.messages.show', compact('message'));
} }
public function messagesMarkRead(Request $request) public function messagesMarkRead(Request $request)
{ {
$this->validate($request, [ $this->validate($request, [
'id' => 'required|integer|min:1' 'id' => 'required|integer|min:1',
]); ]);
$id = $request->input('id'); $id = $request->input('id');
$message = Contact::findOrFail($id); $message = Contact::findOrFail($id);
if($message->read_at) { if ($message->read_at) {
return; return;
} }
$message->read_at = now(); $message->read_at = now();
$message->save(); $message->save();
return;
} }
public function newsroomHome(Request $request) public function newsroomHome(Request $request)
{ {
$newsroom = Newsroom::latest()->paginate(10); $newsroom = Newsroom::latest()->paginate(10);
return view('admin.newsroom.home', compact('newsroom')); return view('admin.newsroom.home', compact('newsroom'));
} }
@ -247,6 +263,7 @@ class AdminController extends Controller
public function newsroomEdit(Request $request, $id) public function newsroomEdit(Request $request, $id)
{ {
$news = Newsroom::findOrFail($id); $news = Newsroom::findOrFail($id);
return view('admin.newsroom.edit', compact('news')); return view('admin.newsroom.edit', compact('news'));
} }
@ -254,6 +271,7 @@ class AdminController extends Controller
{ {
$news = Newsroom::findOrFail($id); $news = Newsroom::findOrFail($id);
$news->delete(); $news->delete();
return redirect('/i/admin/newsroom'); return redirect('/i/admin/newsroom');
} }
@ -262,13 +280,13 @@ class AdminController extends Controller
$this->validate($request, [ $this->validate($request, [
'title' => 'required|string|min:1|max:100', 'title' => 'required|string|min:1|max:100',
'summary' => 'nullable|string|max:200', 'summary' => 'nullable|string|max:200',
'body' => 'nullable|string' 'body' => 'nullable|string',
]); ]);
$changed = false; $changed = false;
$changedFields = []; $changedFields = [];
$slug = str_slug($request->input('title')); $slug = str_slug($request->input('title'));
if(Newsroom::whereSlug($slug)->exists()) { if (Newsroom::whereSlug($slug)->exists()) {
$slug = $slug . '-' . str_random(4); $slug = $slug.'-'.str_random(4);
} }
$news = Newsroom::findOrFail($id); $news = Newsroom::findOrFail($id);
$fields = [ $fields = [
@ -280,13 +298,13 @@ class AdminController extends Controller
'auth_only' => 'boolean', 'auth_only' => 'boolean',
'show_link' => 'boolean', 'show_link' => 'boolean',
'force_modal' => 'boolean', 'force_modal' => 'boolean',
'published' => 'published' 'published' => 'published',
]; ];
foreach($fields as $field => $type) { foreach ($fields as $field => $type) {
switch ($type) { switch ($type) {
case 'string': case 'string':
if($request->{$field} != $news->{$field}) { if ($request->{$field} != $news->{$field}) {
if($field == 'title') { if ($field == 'title') {
$news->slug = $slug; $news->slug = $slug;
} }
$news->{$field} = $request->{$field}; $news->{$field} = $request->{$field};
@ -297,7 +315,7 @@ class AdminController extends Controller
case 'boolean': case 'boolean':
$state = $request->{$field} == 'on' ? true : false; $state = $request->{$field} == 'on' ? true : false;
if($state != $news->{$field}) { if ($state != $news->{$field}) {
$news->{$field} = $state; $news->{$field} = $state;
$changed = true; $changed = true;
array_push($changedFields, $field); array_push($changedFields, $field);
@ -306,7 +324,7 @@ class AdminController extends Controller
case 'published': case 'published':
$state = $request->{$field} == 'on' ? true : false; $state = $request->{$field} == 'on' ? true : false;
$published = $news->published_at != null; $published = $news->published_at != null;
if($state != $published) { if ($state != $published) {
$news->published_at = $state ? now() : null; $news->published_at = $state ? now() : null;
$changed = true; $changed = true;
array_push($changedFields, $field); array_push($changedFields, $field);
@ -316,26 +334,26 @@ class AdminController extends Controller
} }
} }
if($changed) { if ($changed) {
$news->save(); $news->save();
} }
$redirect = $news->published_at ? $news->permalink() : $news->editUrl(); $redirect = $news->published_at ? $news->permalink() : $news->editUrl();
return redirect($redirect); return redirect($redirect);
} }
public function newsroomStore(Request $request) public function newsroomStore(Request $request)
{ {
$this->validate($request, [ $this->validate($request, [
'title' => 'required|string|min:1|max:100', 'title' => 'required|string|min:1|max:100',
'summary' => 'nullable|string|max:200', 'summary' => 'nullable|string|max:200',
'body' => 'nullable|string' 'body' => 'nullable|string',
]); ]);
$changed = false; $changed = false;
$changedFields = []; $changedFields = [];
$slug = str_slug($request->input('title')); $slug = str_slug($request->input('title'));
if(Newsroom::whereSlug($slug)->exists()) { if (Newsroom::whereSlug($slug)->exists()) {
$slug = $slug . '-' . str_random(4); $slug = $slug.'-'.str_random(4);
} }
$news = new Newsroom(); $news = new Newsroom();
$fields = [ $fields = [
@ -347,13 +365,13 @@ class AdminController extends Controller
'auth_only' => 'boolean', 'auth_only' => 'boolean',
'show_link' => 'boolean', 'show_link' => 'boolean',
'force_modal' => 'boolean', 'force_modal' => 'boolean',
'published' => 'published' 'published' => 'published',
]; ];
foreach($fields as $field => $type) { foreach ($fields as $field => $type) {
switch ($type) { switch ($type) {
case 'string': case 'string':
if($request->{$field} != $news->{$field}) { if ($request->{$field} != $news->{$field}) {
if($field == 'title') { if ($field == 'title') {
$news->slug = $slug; $news->slug = $slug;
} }
$news->{$field} = $request->{$field}; $news->{$field} = $request->{$field};
@ -364,7 +382,7 @@ class AdminController extends Controller
case 'boolean': case 'boolean':
$state = $request->{$field} == 'on' ? true : false; $state = $request->{$field} == 'on' ? true : false;
if($state != $news->{$field}) { if ($state != $news->{$field}) {
$news->{$field} = $state; $news->{$field} = $state;
$changed = true; $changed = true;
array_push($changedFields, $field); array_push($changedFields, $field);
@ -373,7 +391,7 @@ class AdminController extends Controller
case 'published': case 'published':
$state = $request->{$field} == 'on' ? true : false; $state = $request->{$field} == 'on' ? true : false;
$published = $news->published_at != null; $published = $news->published_at != null;
if($state != $published) { if ($state != $published) {
$news->published_at = $state ? now() : null; $news->published_at = $state ? now() : null;
$changed = true; $changed = true;
array_push($changedFields, $field); array_push($changedFields, $field);
@ -383,10 +401,11 @@ class AdminController extends Controller
} }
} }
if($changed) { if ($changed) {
$news->save(); $news->save();
} }
$redirect = $news->published_at ? $news->permalink() : $news->editUrl(); $redirect = $news->published_at ? $news->permalink() : $news->editUrl();
return redirect($redirect); return redirect($redirect);
} }
@ -398,18 +417,18 @@ class AdminController extends Controller
public function diagnosticsDecrypt(Request $request) public function diagnosticsDecrypt(Request $request)
{ {
$this->validate($request, [ $this->validate($request, [
'payload' => 'required' 'payload' => 'required',
]); ]);
$key = 'exception_report:'; $key = 'exception_report:';
$decrypted = decrypt($request->input('payload')); $decrypted = decrypt($request->input('payload'));
if(!starts_with($decrypted, $key)) { if (! starts_with($decrypted, $key)) {
abort(403, 'Can only decrypt error diagnostics'); abort(403, 'Can only decrypt error diagnostics');
} }
$res = [ $res = [
'decrypted' => substr($decrypted, strlen($key)) 'decrypted' => substr($decrypted, strlen($key)),
]; ];
return response()->json($res); return response()->json($res);
@ -419,71 +438,74 @@ class AdminController extends Controller
{ {
$stories = Story::with('profile')->latest()->paginate(10); $stories = Story::with('profile')->latest()->paginate(10);
$stats = StoryService::adminStats(); $stats = StoryService::adminStats();
return view('admin.stories.home', compact('stories', 'stats')); return view('admin.stories.home', compact('stories', 'stats'));
} }
public function customEmojiHome(Request $request) public function customEmojiHome(Request $request)
{ {
if(!(bool) config_cache('federation.custom_emoji.enabled')) { if (! (bool) config_cache('federation.custom_emoji.enabled')) {
return view('admin.custom-emoji.not-enabled'); return view('admin.custom-emoji.not-enabled');
} }
$this->validate($request, [ $this->validate($request, [
'sort' => 'sometimes|in:all,local,remote,duplicates,disabled,search' 'sort' => 'sometimes|in:all,local,remote,duplicates,disabled,search',
]); ]);
if($request->has('cc')) { if ($request->has('cc')) {
Cache::forget('pf:admin:custom_emoji:stats'); Cache::forget('pf:admin:custom_emoji:stats');
Cache::forget('pf:custom_emoji'); Cache::forget('pf:custom_emoji');
return redirect(route('admin.custom-emoji')); return redirect(route('admin.custom-emoji'));
} }
$sort = $request->input('sort') ?? 'all'; $sort = $request->input('sort') ?? 'all';
if($sort == 'search' && empty($request->input('q'))) { if ($sort == 'search' && empty($request->input('q'))) {
return redirect(route('admin.custom-emoji')); return redirect(route('admin.custom-emoji'));
} }
$pg = config('database.default') == 'pgsql'; $pg = config('database.default') == 'pgsql';
$emojis = CustomEmoji::when($sort, function($query, $sort) use($request, $pg) { $emojis = CustomEmoji::when($sort, function ($query, $sort) use ($request, $pg) {
if($sort == 'all') { if ($sort == 'all') {
if($pg) { if ($pg) {
return $query->latest(); return $query->latest();
} else { } else {
return $query->groupBy('shortcode')->latest(); return $query->groupBy('shortcode')->latest();
} }
} else if($sort == 'local') { } elseif ($sort == 'local') {
return $query->latest()->where('domain', '=', config('pixelfed.domain.app')); return $query->latest()->where('domain', '=', config('pixelfed.domain.app'));
} else if($sort == 'remote') { } elseif ($sort == 'remote') {
return $query->latest()->where('domain', '!=', config('pixelfed.domain.app')); return $query->latest()->where('domain', '!=', config('pixelfed.domain.app'));
} else if($sort == 'duplicates') { } elseif ($sort == 'duplicates') {
return $query->latest()->groupBy('shortcode')->havingRaw('count(*) > 1'); return $query->latest()->groupBy('shortcode')->havingRaw('count(*) > 1');
} else if($sort == 'disabled') { } elseif ($sort == 'disabled') {
return $query->latest()->whereDisabled(true); return $query->latest()->whereDisabled(true);
} else if($sort == 'search') { } elseif ($sort == 'search') {
$q = $query $q = $query
->latest() ->latest()
->where('shortcode', 'like', '%' . $request->input('q') . '%') ->where('shortcode', 'like', '%'.$request->input('q').'%')
->orWhere('domain', 'like', '%' . $request->input('q') . '%'); ->orWhere('domain', 'like', '%'.$request->input('q').'%');
if(!$request->has('dups')) { if (! $request->has('dups')) {
if(!$pg) { if (! $pg) {
$q = $q->groupBy('shortcode'); $q = $q->groupBy('shortcode');
} }
} }
return $q; return $q;
} }
}) })
->simplePaginate(10) ->simplePaginate(10)
->withQueryString(); ->withQueryString();
$stats = Cache::remember('pf:admin:custom_emoji:stats', 43200, function() use($pg) { $stats = Cache::remember('pf:admin:custom_emoji:stats', 43200, function () use ($pg) {
$res = [ $res = [
'total' => CustomEmoji::count(), 'total' => CustomEmoji::count(),
'active' => CustomEmoji::whereDisabled(false)->count(), 'active' => CustomEmoji::whereDisabled(false)->count(),
'remote' => CustomEmoji::where('domain', '!=', config('pixelfed.domain.app'))->count(), 'remote' => CustomEmoji::where('domain', '!=', config('pixelfed.domain.app'))->count(),
]; ];
if($pg) { if ($pg) {
$res['duplicate'] = CustomEmoji::select('shortcode')->groupBy('shortcode')->havingRaw('count(*) > 1')->count(); $res['duplicate'] = CustomEmoji::select('shortcode')->groupBy('shortcode')->havingRaw('count(*) > 1')->count();
} else { } else {
$res['duplicate'] = CustomEmoji::groupBy('shortcode')->havingRaw('count(*) > 1')->count(); $res['duplicate'] = CustomEmoji::groupBy('shortcode')->havingRaw('count(*) > 1')->count();
@ -499,16 +521,18 @@ class AdminController extends Controller
{ {
abort_unless((bool) config_cache('federation.custom_emoji.enabled'), 404); abort_unless((bool) config_cache('federation.custom_emoji.enabled'), 404);
$emoji = CustomEmoji::findOrFail($id); $emoji = CustomEmoji::findOrFail($id);
$emoji->disabled = !$emoji->disabled; $emoji->disabled = ! $emoji->disabled;
$emoji->save(); $emoji->save();
$key = CustomEmoji::CACHE_KEY . str_replace(':', '', $emoji->shortcode); $key = CustomEmoji::CACHE_KEY.str_replace(':', '', $emoji->shortcode);
Cache::forget($key); Cache::forget($key);
return redirect()->back(); return redirect()->back();
} }
public function customEmojiAdd(Request $request) public function customEmojiAdd(Request $request)
{ {
abort_unless((bool) config_cache('federation.custom_emoji.enabled'), 404); abort_unless((bool) config_cache('federation.custom_emoji.enabled'), 404);
return view('admin.custom-emoji.add'); return view('admin.custom-emoji.add');
} }
@ -522,12 +546,12 @@ class AdminController extends Controller
'max:80', 'max:80',
'starts_with::', 'starts_with::',
'ends_with::', 'ends_with::',
Rule::unique('custom_emoji')->where(function ($query) use($request) { Rule::unique('custom_emoji')->where(function ($query) use ($request) {
return $query->whereDomain(config('pixelfed.domain.app')) return $query->whereDomain(config('pixelfed.domain.app'))
->whereShortcode($request->input('shortcode')); ->whereShortcode($request->input('shortcode'));
}) }),
], ],
'emoji' => 'required|file|mimes:jpg,png|max:' . (config('federation.custom_emoji.max_size') / 1000) 'emoji' => 'required|file|mimes:jpg,png|max:'.(config('federation.custom_emoji.max_size') / 1000),
]); ]);
$emoji = new CustomEmoji; $emoji = new CustomEmoji;
@ -535,11 +559,12 @@ class AdminController extends Controller
$emoji->domain = config('pixelfed.domain.app'); $emoji->domain = config('pixelfed.domain.app');
$emoji->save(); $emoji->save();
$fileName = $emoji->id . '.' . $request->emoji->extension(); $fileName = $emoji->id.'.'.$request->emoji->extension();
$request->emoji->storePubliclyAs('public/emoji', $fileName); $request->emoji->storePubliclyAs('public/emoji', $fileName);
$emoji->media_path = 'emoji/' . $fileName; $emoji->media_path = 'emoji/'.$fileName;
$emoji->save(); $emoji->save();
Cache::forget('pf:custom_emoji'); Cache::forget('pf:custom_emoji');
return redirect(route('admin.custom-emoji')); return redirect(route('admin.custom-emoji'));
} }
@ -550,6 +575,7 @@ class AdminController extends Controller
Storage::delete("public/{$emoji->media_path}"); Storage::delete("public/{$emoji->media_path}");
Cache::forget('pf:custom_emoji'); Cache::forget('pf:custom_emoji');
$emoji->delete(); $emoji->delete();
return redirect(route('admin.custom-emoji')); return redirect(route('admin.custom-emoji'));
} }
@ -558,6 +584,7 @@ class AdminController extends Controller
abort_unless((bool) config_cache('federation.custom_emoji.enabled'), 404); abort_unless((bool) config_cache('federation.custom_emoji.enabled'), 404);
$emoji = CustomEmoji::orderBy('id')->whereDisabled(false)->whereShortcode($id)->firstOrFail(); $emoji = CustomEmoji::orderBy('id')->whereDisabled(false)->whereShortcode($id)->firstOrFail();
$emojis = CustomEmoji::whereShortcode($id)->where('id', '!=', $emoji->id)->cursorPaginate(10); $emojis = CustomEmoji::whereShortcode($id)->where('id', '!=', $emoji->id)->cursorPaginate(10);
return view('admin.custom-emoji.duplicates', compact('emoji', 'emojis')); return view('admin.custom-emoji.duplicates', compact('emoji', 'emojis'));
} }
} }

View file

@ -0,0 +1,45 @@
@extends('admin.partial.template-full')
@section('section')
</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 d-inline-block mb-0">Custom CSS</p>
<p class="lead mb-0 text-white">Customize your instance with custom css.</p>
</div>
</div>
</div>
</div>
</div>
<div class="container-fluid mt-4">
<div class="col-12 col-md-6">
<form method="post">
@csrf
<div class="form-group">
<div class="custom-control custom-checkbox">
<input
type="checkbox"
name="show"
class="custom-control-input"
id="customCheck1"
{{ (bool) config_cache('uikit.show_custom.css') ? 'checked' : null}}
>
<label class="custom-control-label" for="customCheck1">Enable Custom CSS</label>
</div>
</div>
<div class="form-group">
<label for="css" class="font-weight-bold">Custom CSS</label>
<textarea
class="form-control"
id="css"
name="css"
rows="5">{!!config_cache('uikit.custom.css')!!}</textarea>
</div>
<button class="btn btn-primary">Save</button>
</form>
</div>
</div>
@endsection

View file

@ -3,6 +3,8 @@
Route::domain(config('pixelfed.domain.admin'))->prefix('i/admin')->group(function () { Route::domain(config('pixelfed.domain.admin'))->prefix('i/admin')->group(function () {
Route::redirect('/', '/dashboard'); Route::redirect('/', '/dashboard');
Route::redirect('timeline', config('app.url').'/timeline'); Route::redirect('timeline', config('app.url').'/timeline');
Route::get('settings/custom-css', 'AdminController@customCss')->name('admin.custom-css');
Route::post('settings/custom-css', 'AdminController@saveCustomCss');
Route::get('dashboard', 'AdminController@home')->name('admin.home'); Route::get('dashboard', 'AdminController@home')->name('admin.home');
Route::get('stats', 'AdminController@stats')->name('admin.stats'); Route::get('stats', 'AdminController@stats')->name('admin.stats');
Route::get('reports', 'AdminController@reports')->name('admin.reports'); Route::get('reports', 'AdminController@reports')->name('admin.reports');