Skip to content
Snippets Groups Projects
Commit 3f9f52c3 authored by Davide's avatar Davide
Browse files

fixed dark mode cookie and added cookie awareness

parent 2f7f1972
No related branches found
No related tags found
3 merge requests!1739Development,!1717Resolve "Major Startpage Redesign",!1713Resolve "Add setting to enable darkmode"
...@@ -72,18 +72,6 @@ class SettingsController extends Controller ...@@ -72,18 +72,6 @@ class SettingsController extends Controller
# Generating link with set cookies # Generating link with set cookies
$cookieLink = LaravelLocalization::getLocalizedURL(LaravelLocalization::getCurrentLocale(), route('loadSettings', $cookies)); $cookieLink = LaravelLocalization::getLocalizedURL(LaravelLocalization::getCurrentLocale(), route('loadSettings', $cookies));
# Checking if dark mode active
$darkmode = 0;
foreach($cookies as $key => $value){
if($key === 'dark_mode'){
if($value === 1)
$darkmode = 1;
elseif($value === 2){
$darkmode = 2;
}
}
}
return view('settings.index') return view('settings.index')
->with('title', trans('titles.settings', ['fokus' => $fokusName])) ->with('title', trans('titles.settings', ['fokus' => $fokusName]))
->with('fokus', $request->input('fokus', '')) ->with('fokus', $request->input('fokus', ''))
...@@ -95,7 +83,7 @@ class SettingsController extends Controller ...@@ -95,7 +83,7 @@ class SettingsController extends Controller
->with('url', $url) ->with('url', $url)
->with('blacklist', $blacklist) ->with('blacklist', $blacklist)
->with('cookieLink', $cookieLink) ->with('cookieLink', $cookieLink)
->with('darkmode', $darkmode); ->with('darkmode', Cookie::get('dark_mode'));
} }
private function getSumas($fokus) private function getSumas($fokus)
...@@ -414,7 +402,7 @@ class SettingsController extends Controller ...@@ -414,7 +402,7 @@ class SettingsController extends Controller
$url = $request->input('url', ''); $url = $request->input('url', '');
$path = \Request::path(); $path = \Request::path();
$cookiePath = "/" . substr($path, 0, strpos($path, "meta/") + 5); $cookiePath = "/";
$cookies = Cookie::get(); $cookies = Cookie::get();
$setCookie = true; $setCookie = true;
......
...@@ -43,15 +43,6 @@ class StartpageController extends Controller ...@@ -43,15 +43,6 @@ class StartpageController extends Controller
$lang = 'all'; $lang = 'all';
} }
$darkmode = 0;
$cookies = Cookie::get();
foreach($cookies as $key => $value){
if($key === 'dark_mode' && $value === 1){
$darkmode = 1;
}
}
return view('index') return view('index')
->with('title', trans('titles.index')) ->with('title', trans('titles.index'))
->with('homeIcon') ->with('homeIcon')
...@@ -63,7 +54,7 @@ class StartpageController extends Controller ...@@ -63,7 +54,7 @@ class StartpageController extends Controller
->with('option_values', $option_values) ->with('option_values', $option_values)
->with('autocomplete', $autocomplete) ->with('autocomplete', $autocomplete)
->with('pluginmodal', $request->input('plugin-modal', 'off')) ->with('pluginmodal', $request->input('plugin-modal', 'off'))
->with('darkmode', $darkmode); ->with('darkmode', Cookie::get('dark_mode'));
} }
public function loadPage($subpage) public function loadPage($subpage)
......
...@@ -22,8 +22,13 @@ ...@@ -22,8 +22,13 @@
<link href="/fonts/liberationsans/stylesheet.css" rel="stylesheet"> <link href="/fonts/liberationsans/stylesheet.css" rel="stylesheet">
<link type="text/css" rel="stylesheet" href="{{ mix('css/fontawesome.css') }}" /> <link type="text/css" rel="stylesheet" href="{{ mix('css/fontawesome.css') }}" />
<link type="text/css" rel="stylesheet" href="{{ mix('css/fontawesome-solid.css') }}" /> <link type="text/css" rel="stylesheet" href="{{ mix('css/fontawesome-solid.css') }}" />
<link type="text/css" rel="stylesheet alternate" href="{{ mix('css/themes/metager-dark.css') }}" title="MetaGer Dark"/>
@if($darkmode === "2")
<link type="text/css" rel="stylesheet" href="{{ mix('css/themes/metager-dark.css') }}" title="MetaGer Dark"/>
@else
<link type="text/css" rel="stylesheet" href="{{ mix('css/themes/metager.css') }}" title="MetaGer"/> <link type="text/css" rel="stylesheet" href="{{ mix('css/themes/metager.css') }}" title="MetaGer"/>
@endif
@endif @endif
<title>{{ $eingabe }} - MetaGer</title> <title>{{ $eingabe }} - MetaGer</title>
<meta content="width=device-width, initial-scale=1.0, user-scalable=no" name="viewport" /> <meta content="width=device-width, initial-scale=1.0, user-scalable=no" name="viewport" />
......
...@@ -26,8 +26,13 @@ ...@@ -26,8 +26,13 @@
@else @else
<link rel="search" type="application/opensearchdescription+xml" title="{{ trans('staticPages.opensearch') }}" href="{{ LaravelLocalization::getLocalizedURL(LaravelLocalization::getCurrentLocale(), action('StartpageController@loadPlugin', ['key' => Cookie::get('key')])) }}"> <link rel="search" type="application/opensearchdescription+xml" title="{{ trans('staticPages.opensearch') }}" href="{{ LaravelLocalization::getLocalizedURL(LaravelLocalization::getCurrentLocale(), action('StartpageController@loadPlugin', ['key' => Cookie::get('key')])) }}">
@endif @endif
<link type="text/css" rel="stylesheet alternate" href="{{ mix('css/themes/metager-dark.css') }}" title="MetaGer Dark"/>
<link type="text/css" rel="stylesheet" href="{{ mix('css/themes/metager.css') }}" title="MetaGer"/> @if($darkmode === "2")
<link type="text/css" rel="stylesheet" href="{{ mix('css/themes/metager-dark.css') }}" title="MetaGer Dark"/>
@else
<link type="text/css" rel="stylesheet" href="{{ mix('css/themes/metager.css') }}" title="MetaGer"/>
@endif
<link type="text/css" rel="stylesheet" href="{{ mix('css/utility.css') }}" /> <link type="text/css" rel="stylesheet" href="{{ mix('css/utility.css') }}" />
<link href="/fonts/liberationsans/stylesheet.css" rel="stylesheet"> <link href="/fonts/liberationsans/stylesheet.css" rel="stylesheet">
<link type="text/css" rel="stylesheet" href="{{ mix('css/fontawesome.css') }}" /> <link type="text/css" rel="stylesheet" href="{{ mix('css/fontawesome.css') }}" />
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment