Added the ability to easily customize the control panel logo and documentation pages without overwriting defaults during updates

This commit is contained in:
Pinga 2024-11-21 13:32:13 +02:00
parent eac3d77b8c
commit 120ff607dc
11 changed files with 35 additions and 14 deletions

View file

@ -328,11 +328,19 @@ class SupportController extends Controller
public function docs(Request $request, Response $response) public function docs(Request $request, Response $response)
{ {
return view($response,'admin/support/docs.twig'); $basePath = '/var/www/cp/resources/views/';
$template = file_exists($basePath . 'admin/support/docs.custom.twig')
? 'admin/support/docs.custom.twig'
: 'admin/support/docs.twig';
return view($response, $template);
} }
public function mediakit(Request $request, Response $response) public function mediakit(Request $request, Response $response)
{ {
return view($response,'admin/support/mediakit.twig'); $basePath = '/var/www/cp/resources/views/';
$template = file_exists($basePath . 'admin/support/mediakit.custom.twig')
? 'admin/support/mediakit.custom.twig'
: 'admin/support/mediakit.twig';
return view($response, $template);
} }
} }

View file

@ -121,6 +121,17 @@ $container->set('view', function ($container) {
$view->getEnvironment()->addGlobal('uiLang', $uiLang); $view->getEnvironment()->addGlobal('uiLang', $uiLang);
$view->getEnvironment()->addGlobal('lang', $lang); $view->getEnvironment()->addGlobal('lang', $lang);
$view->getEnvironment()->addGlobal('flash', $container->get('flash')); $view->getEnvironment()->addGlobal('flash', $container->get('flash'));
$staticDir = '/var/www/cp/public/static';
if (file_exists($staticDir . '/logo.svg')) {
$logoPath = '/static/logo.svg';
} elseif (file_exists($staticDir . '/logo.png')) {
$logoPath = '/static/logo.png';
} else {
$logoPath = '/static/logo.default.svg';
}
$view->getEnvironment()->addGlobal('logoPath', $logoPath);
if (isset($_SESSION['_screen_mode'])) { if (isset($_SESSION['_screen_mode'])) {
$view->getEnvironment()->addGlobal('screen_mode', $_SESSION['_screen_mode']); $view->getEnvironment()->addGlobal('screen_mode', $_SESSION['_screen_mode']);
} else { } else {

View file

Before

Width:  |  Height:  |  Size: 7 KiB

After

Width:  |  Height:  |  Size: 7 KiB

Before After
Before After

View file

@ -37,8 +37,9 @@
<!-- ... Add more sections as needed ... --> <!-- ... Add more sections as needed ... -->
<footer> <footer class="mt-4 text-muted">
<p class="text-muted">Replace or remove this footer as necessary. Add any relevant information or links here.</p> <p>To customize this documentation page:</p>
<p>Copy <code>docs.twig</code> from <code>/var/www/cp/resources/views/admin/support</code> to <code>docs.custom.twig</code> and edit the file as required.</p>
</footer> </footer>
</div> </div>
</div> </div>

View file

@ -31,8 +31,8 @@
<h3>Logos</h3> <h3>Logos</h3>
<p>{{ logos_intro|default('Provide guidelines on how to use your registry logos correctly.') }}</p> <p>{{ logos_intro|default('Provide guidelines on how to use your registry logos correctly.') }}</p>
<!-- Placeholder for logos. You can use a loop in Twig to iterate through and display multiple logos. -->
<img src="{{ logo_image_path|default('/static/logo.svg') }}" alt="Registry Logo" class="img-fluid mb-3" style="max-width:50%;"> <img src="{{ logoPath }}" alt="Registry Logo" class="img-fluid mb-3" style="max-width:50%;">
<h3>Branding Guidelines</h3> <h3>Branding Guidelines</h3>
<p>{{ branding_guidelines|default('Detail any color schemes, typography, or design patterns related to your TLD registry brand here.') }}</p> <p>{{ branding_guidelines|default('Detail any color schemes, typography, or design patterns related to your TLD registry brand here.') }}</p>
@ -42,8 +42,9 @@
<!-- ... Add more sections as needed ... --> <!-- ... Add more sections as needed ... -->
<footer> <footer class="mt-4 text-muted">
<p class="text-muted">Replace or remove this footer as necessary. Add any relevant information or links here.</p> <p>To customize this documentation page:</p>
<p>Copy <code>mediakit.twig</code> from <code>/var/www/cp/resources/views/admin/support</code> to <code>mediakit.custom.twig</code> and edit the file as required.</p>
</footer> </footer>
</div> </div>
</div> </div>

View file

@ -6,7 +6,7 @@
<div class="page page-center"> <div class="page page-center">
<div class="container container-tight py-4"> <div class="container container-tight py-4">
<div class="text-center mb-4"> <div class="text-center mb-4">
<a href="." class="navbar-brand navbar-brand-autodark"><img src="./static/logo-bw.svg" height="36" alt=""></a> <a href="." class="navbar-brand navbar-brand-autodark"><img src="{{ logoPath }}" height="36" alt=""></a>
{% include 'partials/flash.twig' %} {% include 'partials/flash.twig' %}
</div> </div>
<div class="card card-md"> <div class="card card-md">

View file

@ -6,7 +6,7 @@
<div class="page page-center"> <div class="page page-center">
<div class="container container-tight py-4"> <div class="container container-tight py-4">
<div class="text-center mb-4"> <div class="text-center mb-4">
<a href="." class="navbar-brand navbar-brand-autodark"><img src="./static/logo-bw.svg" height="36" alt=""></a> <a href="." class="navbar-brand navbar-brand-autodark"><img src="{{ logoPath }}" height="36" alt=""></a>
{% include 'partials/flash.twig' %} {% include 'partials/flash.twig' %}
</div> </div>
<form class="card card-md" action="{{route('forgot.password')}}" name="register" method="post" autocomplete="off" novalidate> <form class="card card-md" action="{{route('forgot.password')}}" name="register" method="post" autocomplete="off" novalidate>

View file

@ -6,7 +6,7 @@
<div class="page page-center"> <div class="page page-center">
<div class="container container-tight py-4"> <div class="container container-tight py-4">
<div class="text-center mb-4"> <div class="text-center mb-4">
<a href="." class="navbar-brand navbar-brand-autodark"><img src="./static/logo-bw.svg" height="36" alt=""></a> <a href="." class="navbar-brand navbar-brand-autodark"><img src="{{ logoPath }}" height="36" alt=""></a>
{% include 'partials/flash.twig' %} {% include 'partials/flash.twig' %}
</div> </div>
<form class="card card-md" action="{{route('update.password')}}" name="register" method="post" autocomplete="off"> <form class="card card-md" action="{{route('update.password')}}" name="register" method="post" autocomplete="off">

View file

@ -6,7 +6,7 @@
<div class="page page-center"> <div class="page page-center">
<div class="container container-tight py-4"> <div class="container container-tight py-4">
<div class="text-center mb-4"> <div class="text-center mb-4">
<a href="." class="navbar-brand navbar-brand-autodark"><img src="./static/logo-bw.svg" height="36" alt=""></a> <a href="." class="navbar-brand navbar-brand-autodark"><img src="{{ logoPath }}" height="36" alt=""></a>
{% include 'partials/flash.twig' %} {% include 'partials/flash.twig' %}
</div> </div>
<form class="card card-md" action="{{route('login')}}" id="login" method="post" autocomplete="off" novalidate> <form class="card card-md" action="{{route('login')}}" id="login" method="post" autocomplete="off" novalidate>

View file

@ -35,7 +35,7 @@
<header> <header>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark"> <nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<div class="container"> <div class="container">
<a class="navbar-brand" href="."><img src="static/logo.svg" width="100" /></a> <a class="navbar-brand" href="."><img src="{{ logoPath }}" width="100" /></a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbar" aria-controls="navbar" aria-expanded="false" aria-label="Toggle navigation"> <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbar" aria-controls="navbar" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span> <span class="navbar-toggler-icon"></span>
</button> </button>

View file

@ -24,7 +24,7 @@
</button> </button>
<h1 class="navbar-brand d-none-navbar-horizontal pe-0 pe-md-3"> <h1 class="navbar-brand d-none-navbar-horizontal pe-0 pe-md-3">
<a href="{{route('home')}}"> <a href="{{route('home')}}">
<img src="/static/logo.svg" width="110" height="32" alt="Namingo" class="navbar-brand-image"> <img src="{{ logoPath }}" width="110" height="32" alt="Namingo" class="navbar-brand-image">
</a> </a>
</h1> </h1>
<div class="navbar-nav flex-row order-md-last"> <div class="navbar-nav flex-row order-md-last">