From 0954b5a7413f42df5bf9304af0f3006b8e2cc955 Mon Sep 17 00:00:00 2001 From: Bernd Bestel Date: Fri, 15 Jun 2018 20:50:40 +0200 Subject: [PATCH] Add option to not use URL rewriting --- README.md | 2 + config-dist.php | 4 ++ controllers/BaseController.php | 4 +- helpers/UrlManager.php | 11 +++- version.json | 4 +- views/batteriesoverview.blade.php | 2 +- views/components/batterycard.blade.php | 2 +- views/components/datepicker.blade.php | 2 +- views/components/datetimepicker.blade.php | 2 +- views/components/habitcard.blade.php | 2 +- views/components/productcard.blade.php | 2 +- views/habitsoverview.blade.php | 2 +- views/layout/default.blade.php | 70 +++++++++++------------ views/manageapikeys.blade.php | 2 +- views/openapiui.blade.php | 10 ++-- views/stockoverview.blade.php | 2 +- 16 files changed, 68 insertions(+), 55 deletions(-) diff --git a/README.md b/README.md index 18ba21d9..02cd6481 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,8 @@ Default login is user `admin` with password `admin` - see the `data/config.php` If you use nginx as your webserver, please include `try_files $uri /index.php;` in your location block. +If, however, your webserver does not support URL rewriting, set `DISABLE_URL_REWRITING` in `data/config.php`. + ## How to update Just overwrite everything with the latest release while keeping the `/data` directory, check `config-dist.php` for new configuration options and add them to your `data/config.php` (it will show up as an error if something is missing there). diff --git a/config-dist.php b/config-dist.php index 40a97c3b..41ac6b7b 100644 --- a/config-dist.php +++ b/config-dist.php @@ -20,3 +20,7 @@ define('BASE_URL', '/'); # must be the filename without .php extension and must be located in /data/plugins, # see /data/plugins/DemoBarcodeLookupPlugin.php for an example implementation define('STOCK_BARCODE_LOOKUP_PLUGIN', 'DemoBarcodeLookupPlugin'); + +# If, however, your webserver does not support URL rewriting, +# set this to true +define('DISABLE_URL_REWRITING', false); diff --git a/controllers/BaseController.php b/controllers/BaseController.php index ca65c5b7..ff45bc06 100644 --- a/controllers/BaseController.php +++ b/controllers/BaseController.php @@ -23,9 +23,9 @@ class BaseController { return $localizationService->Localize($text, ...$placeholderValues); }); - $container->view->set('U', function($relativePath) use($container) + $container->view->set('U', function($relativePath, $isResource = false) use($container) { - return $container->UrlManager->ConstructUrl($relativePath); + return $container->UrlManager->ConstructUrl($relativePath, $isResource); }); $this->AppContainer = $container; diff --git a/helpers/UrlManager.php b/helpers/UrlManager.php index f5bb271e..b7b0f765 100644 --- a/helpers/UrlManager.php +++ b/helpers/UrlManager.php @@ -18,9 +18,16 @@ class UrlManager protected $BasePath; - public function ConstructUrl($relativePath) + public function ConstructUrl($relativePath, $isResource = false) { - return rtrim($this->BasePath, '/') . $relativePath; + if (DISABLE_URL_REWRITING === false || $isResource === true) + { + return rtrim($this->BasePath, '/') . $relativePath; + } + else // Is not a resource and URL rewriting is disabled + { + return rtrim($this->BasePath, '/') . '/index.php' . $relativePath; + } } private function GetBaseUrl() diff --git a/version.json b/version.json index 3a8d70f8..8d0f5f32 100644 --- a/version.json +++ b/version.json @@ -1,4 +1,4 @@ { - "Version": "1.10.0", - "ReleaseDate": "2018-05-12" + "Version": "1.11.0", + "ReleaseDate": "2018-06-15" } diff --git a/views/batteriesoverview.blade.php b/views/batteriesoverview.blade.php index 923873a5..a015763f 100644 --- a/views/batteriesoverview.blade.php +++ b/views/batteriesoverview.blade.php @@ -5,7 +5,7 @@ @section('viewJsName', 'batteriesoverview') @push('pageScripts') - + @endpush @section('content') diff --git a/views/components/batterycard.blade.php b/views/components/batterycard.blade.php index 89ac8b4d..7bc388c7 100644 --- a/views/components/batterycard.blade.php +++ b/views/components/batterycard.blade.php @@ -1,5 +1,5 @@ @push('componentScripts') - + @endpush
diff --git a/views/components/datepicker.blade.php b/views/components/datepicker.blade.php index f755b245..0f303dd0 100644 --- a/views/components/datepicker.blade.php +++ b/views/components/datepicker.blade.php @@ -1,5 +1,5 @@ @push('componentScripts') - + @endpush
diff --git a/views/components/datetimepicker.blade.php b/views/components/datetimepicker.blade.php index b44198dc..52952ece 100644 --- a/views/components/datetimepicker.blade.php +++ b/views/components/datetimepicker.blade.php @@ -1,5 +1,5 @@ @push('componentScripts') - + @endpush
diff --git a/views/components/habitcard.blade.php b/views/components/habitcard.blade.php index 60289062..ebb0b15d 100644 --- a/views/components/habitcard.blade.php +++ b/views/components/habitcard.blade.php @@ -1,5 +1,5 @@ @push('componentScripts') - + @endpush
diff --git a/views/components/productcard.blade.php b/views/components/productcard.blade.php index 9a593563..3ad5beff 100644 --- a/views/components/productcard.blade.php +++ b/views/components/productcard.blade.php @@ -1,5 +1,5 @@ @push('componentScripts') - + @endpush
diff --git a/views/habitsoverview.blade.php b/views/habitsoverview.blade.php index 58c7adac..afd0d0e8 100644 --- a/views/habitsoverview.blade.php +++ b/views/habitsoverview.blade.php @@ -5,7 +5,7 @@ @section('viewJsName', 'habitsoverview') @push('pageScripts') - + @endpush @section('content') diff --git a/views/layout/default.blade.php b/views/layout/default.blade.php index dd2ae991..e14f6b99 100644 --- a/views/layout/default.blade.php +++ b/views/layout/default.blade.php @@ -9,22 +9,22 @@ - + @yield('title') | grocy - - - - - - - - - - - - + + + + + + + + + + + + @stack('pageStyles') - - - - - @if(!empty($L('bootstrap_datepicker_locale')))@endif - - @if(!empty($L('moment_locale')))@endif - - - - - - - - - - - + + + + + + @if(!empty($L('bootstrap_datepicker_locale')))@endif + + @if(!empty($L('moment_locale')))@endif + + + + + + + + + + + - - + + @stack('pageScripts') @stack('componentScripts') - + @if(file_exists(__DIR__ . '/../../data/add_before_end_body.html')) @php include __DIR__ . '/../../data/add_before_end_body.html' @endphp diff --git a/views/manageapikeys.blade.php b/views/manageapikeys.blade.php index ca30479b..36867fa5 100644 --- a/views/manageapikeys.blade.php +++ b/views/manageapikeys.blade.php @@ -5,7 +5,7 @@ @section('viewJsName', 'manageapikeys') @push('pageScripts') - + @endpush @section('content') diff --git a/views/openapiui.blade.php b/views/openapiui.blade.php index b7f49bdb..f2de5364 100644 --- a/views/openapiui.blade.php +++ b/views/openapiui.blade.php @@ -9,11 +9,11 @@ - + {{ $L('REST API & data model documentation') }} | grocy - + - - + + + @if(file_exists(__DIR__ . '/../../data/add_before_end_body.html')) @php include __DIR__ . '/../../data/add_before_end_body.html' @endphp diff --git a/views/stockoverview.blade.php b/views/stockoverview.blade.php index 9b69aa2f..93d7b52d 100644 --- a/views/stockoverview.blade.php +++ b/views/stockoverview.blade.php @@ -5,7 +5,7 @@ @section('viewJsName', 'stockoverview') @push('pageScripts') - + @endpush @section('content')