Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the abilitity for users to use a custom CSS URL #66

Merged
merged 4 commits into from Dec 22, 2017
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions app/Http/Controllers/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,13 @@ public function changeSettings($username, $id)
$user = Auth::user();
if (Request::isMethod('post')) {
$user->style = (int)Request::get('theme');
$css_url = Request::get('custom_css');
if (isset($css_url) && filter_var($css_url, FILTER_VALIDATE_URL) === false) {
return redirect()->back()->with(Toastr::warning('The CSS URL is invalid!', 'Error', ['options']));
} else {
$user->custom_css = $css_url;
}

$user->nav = Request::get('sidenav');
$user->hidden = Request::get('onlinehide');
$user->private_profile = Request::get('private_profile');
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class AddCustomCssToUsersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('users', function (Blueprint $table) {
$table->string('custom_css')->nullable();
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('users', function (Blueprint $table) {
//
});
}
}
3 changes: 3 additions & 0 deletions resources/views/layout/default.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
<link rel="stylesheet" href="{{ url('css/main/advbuttons.css?v=02') }}">
<link rel="stylesheet" href="{{ url('css/vendor/vendor.min.css') }}" />
@yield('stylesheets')
@if(isset(Auth::user()->custom_css))
<link rel="stylesheet" href="{{Auth::user()->custom_css}}"/>
@endif

@php $bg = rand(1, 8); $bgchange = $bg.".jpg"; @endphp
</head>
Expand Down
6 changes: 6 additions & 0 deletions resources/views/user/settings.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@
<div class="radio-inline">
<label><input type="radio" name="sidenav" @if($user->nav == 0) checked @endif value="0">Compact</label>
</div>
<br>
<br>
<div class="form-group">
<label for="custom_css" class="control-label">Custom CSS URL</label>
<input type="text" name="custom_css" class="form-control" value="@if($user->custom_css) {{ $user->custom_css }} @else @endif" placeholder="Custom CSS URL">
</div>

<h3>Privacy Settings</h3>
<hr>
Expand Down