add: standalone stylesheet option

This commit is contained in:
HDVinnie
2021-07-11 10:35:44 -04:00
parent 425df823f1
commit 36332d04cc
3 changed files with 64 additions and 4 deletions
+12 -3
View File
@@ -261,12 +261,21 @@ class UserController extends Controller
// Style Settings
$user->style = (int) $request->input('theme');
$cssUrl = $request->input('custom_css');
if (isset($cssUrl) && ! \filter_var($cssUrl, FILTER_VALIDATE_URL)) {
$customCss = $request->input('custom_css');
if (isset($customCss) && ! \filter_var($customCss, FILTER_VALIDATE_URL)) {
return \redirect()->route('users.show', ['username' => $user->username])
->withErrors('The URL for the external CSS stylesheet is invalid, try it again with a valid URL.');
}
$user->custom_css = $cssUrl;
$user->custom_css = $customCss;
$standaloneCss = $request->input('standalone_css');
if (isset($standaloneCss) && ! \filter_var($standaloneCss, FILTER_VALIDATE_URL)) {
return \redirect()->route('users.show', ['username' => $user->username])
->withErrors('The URL for the external CSS stylesheet is invalid, try it again with a valid URL.');
}
$user->standalone_css = $standaloneCss;
$user->nav = $request->input('sidenav');
// Torrent Settings
@@ -0,0 +1,43 @@
<?php
/**
* NOTICE OF LICENSE.
*
* UNIT3D Community Edition is open-sourced software licensed under the GNU Affero General Public License v3.0
* The details is bundled with this project in the file LICENSE.txt.
*
* @project UNIT3D Community Edition
*
* @author HDVinnie <hdinnovations@protonmail.com>
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
*/
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddStandaloneCssToUsersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('users', function (Blueprint $table) {
$table->string('standalone_css')->after('custom_css')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('users', function (Blueprint $table) {
//
});
}
}
+9 -1
View File
@@ -70,13 +70,21 @@
</select>
</div>
<div class="form-group">
<label for="custom_css" class="control-label">External CSS Stylesheet</label>
<label for="custom_css" class="control-label">External CSS Stylesheet (Stacks on top of above theme)</label>
<label>
<input type="text" name="custom_css" class="form-control"
value="@if ($user->custom_css) {{ $user->custom_css }}@endif"
placeholder="CSS URL">
</label>
</div>
<div class="form-group">
<label for="standalone_css" class="control-label">Standalone CSS Stylesheet (No site theme used)</label>
<label>
<input type="text" name="standalone_css" class="form-control"
value="@if ($user->standalone_css) {{ $user->standalone_css }}@endif"
placeholder="CSS URL">
</label>
</div>
<label for="sidenav" class="control-label">Side Navigation</label>
<div class="radio-inline">
<label><input type="radio" name="sidenav" @if ($user->nav == 1) checked