]> BookStack Code Mirror - bookstack/commitdiff
Replaced use of custom 'baseUrl' helper with 'url'
authorDan Brown <redacted>
Sun, 4 Aug 2019 13:26:39 +0000 (14:26 +0100)
committerDan Brown <redacted>
Sun, 4 Aug 2019 13:26:39 +0000 (14:26 +0100)
Also changed up how base URL setting was being done
by manipulating incoming request URLs instead of
altering then on generation.

67 files changed:
app/Auth/User.php
app/Config/app.php
app/Entities/Book.php
app/Entities/Bookshelf.php
app/Entities/Chapter.php
app/Entities/Page.php
app/Http/Controllers/Auth/LoginController.php
app/Http/Controllers/Auth/RegisterController.php
app/Http/Controllers/PageController.php
app/Http/Controllers/SearchController.php
app/Http/Middleware/Authenticate.php
app/Http/Request.php [new file with mode: 0644]
app/Notifications/ConfirmEmail.php
app/Notifications/ResetPassword.php
app/Providers/AppServiceProvider.php
app/Providers/PaginationServiceProvider.php
app/Uploads/Attachment.php
app/Uploads/ImageService.php
app/UrlGenerator.php [deleted file]
app/helpers.php
public/index.php
resources/views/auth/forms/login/standard.blade.php
resources/views/auth/login.blade.php
resources/views/auth/passwords/email.blade.php
resources/views/auth/passwords/reset.blade.php
resources/views/auth/register.blade.php
resources/views/auth/user-unconfirmed.blade.php
resources/views/base.blade.php
resources/views/books/create.blade.php
resources/views/books/form.blade.php
resources/views/books/index.blade.php
resources/views/books/list.blade.php
resources/views/common/header.blade.php
resources/views/common/home-sidebar.blade.php
resources/views/common/home.blade.php
resources/views/components/expand-toggle.blade.php
resources/views/components/page-picker.blade.php
resources/views/components/tag-list.blade.php
resources/views/components/tag-manager.blade.php
resources/views/errors/404.blade.php
resources/views/errors/500.blade.php
resources/views/pages/edit.blade.php
resources/views/partials/breadcrumbs.blade.php
resources/views/partials/sort.blade.php
resources/views/partials/view-toggle.blade.php
resources/views/search/all.blade.php
resources/views/settings/index.blade.php
resources/views/settings/maintenance.blade.php
resources/views/settings/navbar.blade.php
resources/views/settings/roles/create.blade.php
resources/views/settings/roles/delete.blade.php
resources/views/settings/roles/edit.blade.php
resources/views/settings/roles/form.blade.php
resources/views/settings/roles/index.blade.php
resources/views/shelves/create.blade.php
resources/views/shelves/form.blade.php
resources/views/shelves/index.blade.php
resources/views/shelves/list.blade.php
resources/views/users/create.blade.php
resources/views/users/delete.blade.php
resources/views/users/edit.blade.php
resources/views/users/index.blade.php
resources/views/users/profile.blade.php
resources/views/vendor/notifications/email.blade.php
tests/Auth/AuthTest.php
tests/Unit/HelpersTest.php [deleted file]
tests/Unit/UrlTest.php [new file with mode: 0644]

index 259b8eec01375992d3fa4b0f6466397d3f7cbb5a..e5a8a393147969c42d0b079a3ce036359da61c5a 100644 (file)
@@ -168,14 +168,14 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
      */
     public function getAvatar($size = 50)
     {
-        $default = baseUrl('/user_avatar.png');
+        $default = url('/user_avatar.png');
         $imageId = $this->image_id;
         if ($imageId === 0 || $imageId === '0' || $imageId === null) {
             return $default;
         }
 
         try {
-            $avatar = $this->avatar ? baseUrl($this->avatar->getThumb($size, $size, false)) : $default;
+            $avatar = $this->avatar ? url($this->avatar->getThumb($size, $size, false)) : $default;
         } catch (\Exception $err) {
             $avatar = $default;
         }
@@ -197,7 +197,7 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
      */
     public function getEditUrl()
     {
-        return baseUrl('/settings/users/' . $this->id);
+        return url('/settings/users/' . $this->id);
     }
 
     /**
@@ -206,7 +206,7 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
      */
     public function getProfileUrl()
     {
-        return baseUrl('/user/' . $this->id);
+        return url('/user/' . $this->id);
     }
 
     /**
index aaeafb98df291e6925d6ade1d283d1fcb9804379..0a0c17a53acc1189a0809efba0d3d412540e342a 100755 (executable)
@@ -45,6 +45,10 @@ return [
     // and used by BookStack in URL generation.
     'url' => env('APP_URL', '') === 'http://bookstack.dev' ? '' : env('APP_URL', ''),
 
+    // Rewrite URL, Used to rewrite the base of request URLs
+    // for scenarios
+    'url_base_rewrite' => env('APP_URL_BASE_REWRITE', null),
+
     // Application timezone for back-end date functions.
     'timezone' => env('APP_TIMEZONE', 'UTC'),
 
index decdde9dcf026b7e8c67d8c05b15affbcc96a015..7d3d5e4ae98bf0e670c436dba1df93fb7c86d92b 100644 (file)
@@ -25,9 +25,9 @@ class Book extends Entity
     public function getUrl($path = false)
     {
         if ($path !== false) {
-            return baseUrl('/books/' . urlencode($this->slug) . '/' . trim($path, '/'));
+            return url('/books/' . urlencode($this->slug) . '/' . trim($path, '/'));
         }
-        return baseUrl('/books/' . urlencode($this->slug));
+        return url('/books/' . urlencode($this->slug));
     }
 
     /**
@@ -44,7 +44,7 @@ class Book extends Entity
         }
 
         try {
-            $cover = $this->cover ? baseUrl($this->cover->getThumb($width, $height, false)) : $default;
+            $cover = $this->cover ? url($this->cover->getThumb($width, $height, false)) : $default;
         } catch (\Exception $err) {
             $cover = $default;
         }
index c8f8b990cde9e019b48d354ef86f1fecb1f178fa..db6685688b3bcd2e6c449338f7ac9e83eef58803 100644 (file)
@@ -39,9 +39,9 @@ class Bookshelf extends Entity
     public function getUrl($path = false)
     {
         if ($path !== false) {
-            return baseUrl('/shelves/' . urlencode($this->slug) . '/' . trim($path, '/'));
+            return url('/shelves/' . urlencode($this->slug) . '/' . trim($path, '/'));
         }
-        return baseUrl('/shelves/' . urlencode($this->slug));
+        return url('/shelves/' . urlencode($this->slug));
     }
 
     /**
@@ -59,7 +59,7 @@ class Bookshelf extends Entity
         }
 
         try {
-            $cover = $this->cover ? baseUrl($this->cover->getThumb($width, $height, false)) : $default;
+            $cover = $this->cover ? url($this->cover->getThumb($width, $height, false)) : $default;
         } catch (\Exception $err) {
             $cover = $default;
         }
index 93640475893085adff2cf8e543fb95b662b1c214..b204f1903034663e755a6ca85bb38cf7f26683f3 100644 (file)
@@ -42,10 +42,13 @@ class Chapter extends Entity
     public function getUrl($path = false)
     {
         $bookSlug = $this->getAttribute('bookSlug') ? $this->getAttribute('bookSlug') : $this->book->slug;
+        $fullPath = '/books/' . urlencode($bookSlug) . '/chapter/' . urlencode($this->slug);
+
         if ($path !== false) {
-            return baseUrl('/books/' . urlencode($bookSlug) . '/chapter/' . urlencode($this->slug) . '/' . trim($path, '/'));
+            $fullPath .= '/' . trim($path, '/');
         }
-        return baseUrl('/books/' . urlencode($bookSlug) . '/chapter/' . urlencode($this->slug));
+
+        return url($fullPath);
     }
 
     /**
index 1c2cc5cff69c29daa5385d963bc89ab2ad4612ff..c32417418b7c0a2f0cd2e61f8b4856af17c476c5 100644 (file)
@@ -96,10 +96,10 @@ class Page extends Entity
         $idComponent = $this->draft ? $this->id : urlencode($this->slug);
 
         if ($path !== false) {
-            return baseUrl('/books/' . urlencode($bookSlug) . $midText . $idComponent . '/' . trim($path, '/'));
+            return url('/books/' . urlencode($bookSlug) . $midText . $idComponent . '/' . trim($path, '/'));
         }
 
-        return baseUrl('/books/' . urlencode($bookSlug) . $midText . $idComponent);
+        return url('/books/' . urlencode($bookSlug) . $midText . $idComponent);
     }
 
     /**
index 21ded23552431a0feb3b770df64e037c0ba2c6a5..c739fd9a337387a973ba12d119059f84cf27cd07 100644 (file)
@@ -53,8 +53,8 @@ class LoginController extends Controller
         $this->socialAuthService = $socialAuthService;
         $this->ldapService = $ldapService;
         $this->userRepo = $userRepo;
-        $this->redirectPath = baseUrl('/');
-        $this->redirectAfterLogout = baseUrl('/login');
+        $this->redirectPath = url('/');
+        $this->redirectAfterLogout = url('/login');
         parent::__construct();
     }
 
index d57105b6293385c4dd6ef163196b908f9b9ac7cf..a285899ccb9cfc40eb911933591e18e2d6239df0 100644 (file)
@@ -2,17 +2,23 @@
 
 namespace BookStack\Http\Controllers\Auth;
 
+use BookStack\Auth\Access\EmailConfirmationService;
+use BookStack\Auth\Access\SocialAuthService;
 use BookStack\Auth\SocialAccount;
 use BookStack\Auth\User;
 use BookStack\Auth\UserRepo;
+use BookStack\Exceptions\SocialDriverNotConfigured;
 use BookStack\Exceptions\SocialSignInAccountNotUsed;
 use BookStack\Exceptions\SocialSignInException;
 use BookStack\Exceptions\UserRegistrationException;
 use BookStack\Http\Controllers\Controller;
 use Exception;
 use Illuminate\Foundation\Auth\RegistersUsers;
+use Illuminate\Http\RedirectResponse;
 use Illuminate\Http\Request;
 use Illuminate\Http\Response;
+use Illuminate\Routing\Redirector;
+use Illuminate\View\View;
 use Laravel\Socialite\Contracts\User as SocialUser;
 use Validator;
 
@@ -46,18 +52,18 @@ class RegisterController extends Controller
     /**
      * Create a new controller instance.
      *
-     * @param \BookStack\Auth\Access\SocialAuthService $socialAuthService
+     * @param SocialAuthService $socialAuthService
      * @param \BookStack\Auth\EmailConfirmationService $emailConfirmationService
-     * @param \BookStack\Auth\UserRepo $userRepo
+     * @param UserRepo $userRepo
      */
-    public function __construct(\BookStack\Auth\Access\SocialAuthService $socialAuthService, \BookStack\Auth\Access\EmailConfirmationService $emailConfirmationService, UserRepo $userRepo)
+    public function __construct(SocialAuthService $socialAuthService, EmailConfirmationService $emailConfirmationService, UserRepo $userRepo)
     {
         $this->middleware('guest')->only(['getRegister', 'postRegister', 'socialRegister']);
         $this->socialAuthService = $socialAuthService;
         $this->emailConfirmationService = $emailConfirmationService;
         $this->userRepo = $userRepo;
-        $this->redirectTo = baseUrl('/');
-        $this->redirectPath = baseUrl('/');
+        $this->redirectTo = url('/');
+        $this->redirectPath = url('/');
         parent::__construct();
     }
 
@@ -101,8 +107,8 @@ class RegisterController extends Controller
 
     /**
      * Handle a registration request for the application.
-     * @param Request|\Illuminate\Http\Request $request
-     * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
+     * @param Request|Request $request
+     * @return RedirectResponse|Redirector
      * @throws UserRegistrationException
      */
     public function postRegister(Request $request)
@@ -117,7 +123,7 @@ class RegisterController extends Controller
     /**
      * Create a new user instance after a valid registration.
      * @param  array  $data
-     * @return \BookStack\Auth\User
+     * @return User
      */
     protected function create(array $data)
     {
@@ -133,7 +139,7 @@ class RegisterController extends Controller
      * @param array $userData
      * @param bool|false|SocialAccount $socialAccount
      * @param bool $emailVerified
-     * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
+     * @return RedirectResponse|Redirector
      * @throws UserRegistrationException
      */
     protected function registerUser(array $userData, $socialAccount = false, $emailVerified = false)
@@ -182,7 +188,7 @@ class RegisterController extends Controller
     /**
      * Confirms an email via a token and logs the user into the system.
      * @param $token
-     * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
+     * @return RedirectResponse|Redirector
      * @throws UserRegistrationException
      */
     public function confirmEmail($token)
@@ -200,7 +206,7 @@ class RegisterController extends Controller
     /**
      * Shows a notice that a user's email address has not been confirmed,
      * Also has the option to re-send the confirmation email.
-     * @return \Illuminate\View\View
+     * @return View
      */
     public function showAwaitingConfirmation()
     {
@@ -210,7 +216,7 @@ class RegisterController extends Controller
     /**
      * Resend the confirmation email
      * @param Request $request
-     * @return \Illuminate\View\View
+     * @return View
      */
     public function resendConfirmation(Request $request)
     {
@@ -235,7 +241,7 @@ class RegisterController extends Controller
      * @param $socialDriver
      * @return mixed
      * @throws UserRegistrationException
-     * @throws \BookStack\Exceptions\SocialDriverNotConfigured
+     * @throws SocialDriverNotConfigured
      */
     public function socialRegister($socialDriver)
     {
@@ -248,10 +254,10 @@ class RegisterController extends Controller
      * The callback for social login services.
      * @param $socialDriver
      * @param Request $request
-     * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
+     * @return RedirectResponse|Redirector
      * @throws SocialSignInException
      * @throws UserRegistrationException
-     * @throws \BookStack\Exceptions\SocialDriverNotConfigured
+     * @throws SocialDriverNotConfigured
      */
     public function socialCallback($socialDriver, Request $request)
     {
@@ -292,7 +298,7 @@ class RegisterController extends Controller
     /**
      * Detach a social account from a user.
      * @param $socialDriver
-     * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
+     * @return RedirectResponse|Redirector
      */
     public function detachSocialAccount($socialDriver)
     {
@@ -303,7 +309,7 @@ class RegisterController extends Controller
      * Register a new user after a registration callback.
      * @param string $socialDriver
      * @param SocialUser $socialUser
-     * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
+     * @return RedirectResponse|Redirector
      * @throws UserRegistrationException
      */
     protected function socialRegisterCallback(string $socialDriver, SocialUser $socialUser)
index 16a7d5a5e45df6df1094bfa14df63fb17cb278f3..89fb83fd97f116b2005827b30cce0ff459d81e5b 100644 (file)
@@ -541,7 +541,7 @@ class PageController extends Controller
     public function showRecentlyUpdated()
     {
         // TODO - Still exist?
-        $pages = $this->pageRepo->getRecentlyUpdatedPaginated('page', 20)->setPath(baseUrl('/pages/recently-updated'));
+        $pages = $this->pageRepo->getRecentlyUpdatedPaginated('page', 20)->setPath(url('/pages/recently-updated'));
         return view('pages.detailed-listing', [
             'title' => trans('entities.recently_updated_pages'),
             'pages' => $pages
index 4bcf7b40eff4db0c207f7741438a4da9b52bd113..1691ee9b0bf937f338436305baa8b9beea3bb24f 100644 (file)
@@ -48,7 +48,7 @@ class SearchController extends Controller
         $this->setPageTitle(trans('entities.search_for_term', ['term' => $searchTerm]));
 
         $page = intval($request->get('page', '0')) ?: 1;
-        $nextPageLink = baseUrl('/search?term=' . urlencode($searchTerm) . '&page=' . ($page+1));
+        $nextPageLink = url('/search?term=' . urlencode($searchTerm) . '&page=' . ($page+1));
 
         $results = $this->searchService->searchEntities($searchTerm, 'all', $page, 20);
 
index 1a33843675a97266095cd6c2cb96918369652c9d..d840a9b2e05477c8fca1550dad9e9e81adaa8c2c 100644 (file)
@@ -41,7 +41,7 @@ class Authenticate
             if ($request->ajax()) {
                 return response('Unauthorized.', 401);
             } else {
-                return redirect()->guest(baseUrl('/login'));
+                return redirect()->guest(url('/login'));
             }
         }
 
diff --git a/app/Http/Request.php b/app/Http/Request.php
new file mode 100644 (file)
index 0000000..bd2761a
--- /dev/null
@@ -0,0 +1,26 @@
+<?php namespace BookStack\Http;
+
+use Illuminate\Http\Request as LaravelRequest;
+
+class Request extends LaravelRequest
+{
+
+    /**
+     * Override the default request methods to get the scheme and host
+     * to set the custom APP_URL, if set.
+     * @return \Illuminate\Config\Repository|mixed|string
+     */
+    public function getSchemeAndHttpHost()
+    {
+        $base = config('app.url', null);
+
+        if ($base) {
+            $base = trim($base, '/');
+        } else {
+            $base = $this->getScheme().'://'.$this->getHttpHost();
+        }
+
+        return $base;
+    }
+
+}
\ No newline at end of file
index 7ecadc298f1f4042a7b887584ca6820bec7bb926..229408f5cf9827533a8307727beac5e4768185c7 100644 (file)
@@ -26,6 +26,6 @@ class ConfirmEmail extends MailNotification
                 ->subject(trans('auth.email_confirm_subject', $appName))
                 ->greeting(trans('auth.email_confirm_greeting', $appName))
                 ->line(trans('auth.email_confirm_text'))
-                ->action(trans('auth.email_confirm_action'), baseUrl('/register/confirm/' . $this->token));
+                ->action(trans('auth.email_confirm_action'), url('/register/confirm/' . $this->token));
     }
 }
index 305a7da72dc50236dd82cc8bbd935f891cf8fb27..20875276400f0403d1a9a063459e37195a2cd475 100644 (file)
@@ -29,7 +29,7 @@ class ResetPassword extends MailNotification
             return $this->newMailMessage()
             ->subject(trans('auth.email_reset_subject', ['appName' => setting('app-name')]))
             ->line(trans('auth.email_reset_text'))
-            ->action(trans('auth.reset_password'), baseUrl('password/reset/' . $this->token))
+            ->action(trans('auth.reset_password'), url('password/reset/' . $this->token))
             ->line(trans('auth.email_reset_not_requested'));
     }
 }
index 6bc1f90471503098cb33d2a3638223f1e757664d..a2fc673f488fc1de45bb27a0f4a48e2790bc9cf6 100644 (file)
@@ -8,11 +8,11 @@ use BookStack\Entities\Chapter;
 use BookStack\Entities\Page;
 use BookStack\Settings\Setting;
 use BookStack\Settings\SettingService;
-use BookStack\UrlGenerator;
 use Illuminate\Database\Eloquent\Relations\Relation;
 use Illuminate\Support\Facades\View;
 use Illuminate\Support\ServiceProvider;
 use Schema;
+use URL;
 use Validator;
 
 class AppServiceProvider extends ServiceProvider
@@ -24,6 +24,9 @@ class AppServiceProvider extends ServiceProvider
      */
     public function boot()
     {
+        // Set root URL
+        URL::forceRootUrl(config('app.url'));
+
         // Custom validation methods
         Validator::extend('image_extension', function ($attribute, $value, $parameters, $validator) {
             $validImageExtensions = ['png', 'jpg', 'jpeg', 'bmp', 'gif', 'tiff', 'webp'];
@@ -73,10 +76,5 @@ class AppServiceProvider extends ServiceProvider
         $this->app->singleton(SettingService::class, function ($app) {
             return new SettingService($app->make(Setting::class), $app->make('Illuminate\Contracts\Cache\Repository'));
         });
-
-        $this->app->bind(
-            \Illuminate\Contracts\Routing\UrlGenerator::class,
-            UrlGenerator::class
-        );
     }
 }
index 3a695c5e3dd285c327b74cbdca521e4522ae30b0..1c982b82eacd26610861d49cfdcf71bc1e5a02c3 100644 (file)
@@ -18,7 +18,7 @@ class PaginationServiceProvider extends IlluminatePaginationServiceProvider
         });
 
         Paginator::currentPathResolver(function () {
-            return baseUrl($this->app['request']->path());
+            return url($this->app['request']->path());
         });
 
         Paginator::currentPageResolver(function ($pageName = 'page') {
index eb9a0fe68e02b60eb605911e12d6c8ca40e3fa87..8720d3c098e74eb96c0890dc174089de43f8be70 100644 (file)
@@ -37,6 +37,6 @@ class Attachment extends Ownable
         if ($this->external && strpos($this->path, 'http') !== 0) {
             return $this->path;
         }
-        return baseUrl('/attachments/' . $this->id);
+        return url('/attachments/' . $this->id);
     }
 }
index ae1c6a254786c1c00fd010e181a0970bcc38d238..860230d00f914169969e40d00efdca77e6f0845d 100644 (file)
@@ -417,7 +417,7 @@ class ImageService extends UploadService
         $isLocal = strpos(trim($uri), 'http') !== 0;
 
         // Attempt to find local files even if url not absolute
-        $base = baseUrl('/');
+        $base = url('/');
         if (!$isLocal && strpos($uri, $base) === 0) {
             $isLocal = true;
             $uri = str_replace($base, '', $uri);
@@ -474,7 +474,7 @@ class ImageService extends UploadService
             $this->storageUrl = $storageUrl;
         }
 
-        $basePath = ($this->storageUrl == false) ? baseUrl('/') : $this->storageUrl;
+        $basePath = ($this->storageUrl == false) ? url('/') : $this->storageUrl;
         return rtrim($basePath, '/') . $filePath;
     }
 }
diff --git a/app/UrlGenerator.php b/app/UrlGenerator.php
deleted file mode 100644 (file)
index 471792c..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-<?php
-
-namespace BookStack;
-
-class UrlGenerator extends \Illuminate\Routing\UrlGenerator
-{
-
-    /**
-     * Generate an absolute URL to the given path.
-     *
-     * @param  string  $path
-     * @param  mixed  $extra
-     * @param  bool|null  $secure
-     * @return string
-     */
-    public function to($path, $extra = [], $secure = null)
-    {
-        $tail = implode('/', array_map(
-                'rawurlencode', (array) $this->formatParameters($extra))
-        );
-
-        $defaultRoot = $this->formatRoot($this->formatScheme($secure));
-
-        list($path, $query) = $this->extractQueryString($path);
-
-        return $this->formatWithBase(
-                $defaultRoot, trim($path.'/'.$tail, '/')
-            ).$query;
-    }
-
-    /**
-     * Format the given URL segments into a single URL.
-     *
-     * @param  string  $defaultRoot
-     * @param  string  $path
-     * @return string
-     */
-    public function formatWithBase($defaultRoot, $path)
-    {
-        $isFullPath = strpos($path, 'http') === 0;
-        $setBasePath = trim(config('app.url'), '/');
-
-        if ($isFullPath) {
-            return $path;
-        }
-
-        if (! empty($setBasePath)) {
-            $defaultRoot = $setBasePath;
-        }
-
-        // TODO - Add mechanism to set path correctly for intended() and back() redirects
-        // TODO - Update tests to align with new system
-        // TODO - Clean up helpers and refactor their usage.
-
-        return trim($defaultRoot. '/' .$path, '/');
-    }
-
-}
\ No newline at end of file
index 7bc1165553e1011676aba527aac725650e148973..9bbfcfbf0fc6535a25cec4750d90006c48d444ea 100644 (file)
@@ -1,8 +1,9 @@
 <?php
 
 use BookStack\Auth\Permissions\PermissionService;
-use BookStack\Entities\Entity;
+use BookStack\Auth\User;
 use BookStack\Ownable;
+use BookStack\Settings\SettingService;
 
 /**
  * Get the path to a versioned file.
@@ -11,7 +12,7 @@ use BookStack\Ownable;
  * @return string
  * @throws Exception
  */
-function versioned_asset($file = '')
+function versioned_asset($file = '') : string
 {
     static $version = null;
 
@@ -26,17 +27,17 @@ function versioned_asset($file = '')
     }
 
     $path = $file . '?version=' . urlencode($version) . $additional;
-    return baseUrl($path);
+    return url($path);
 }
 
 /**
  * Helper method to get the current User.
  * Defaults to public 'Guest' user if not logged in.
- * @return \BookStack\Auth\User
+ * @return User
  */
-function user()
+function user() : User
 {
-    return auth()->user() ?: \BookStack\Auth\User::getDefault();
+    return auth()->user() ?: User::getDefault();
 }
 
 /**
@@ -63,9 +64,9 @@ function hasAppAccess() : bool
  * that particular item.
  * @param string $permission
  * @param Ownable $ownable
- * @return mixed
+ * @return bool
  */
-function userCan(string $permission, Ownable $ownable = null)
+function userCan(string $permission, Ownable $ownable = null) : bool
 {
     if ($ownable === null) {
         return user() && user()->can($permission);
@@ -83,7 +84,7 @@ function userCan(string $permission, Ownable $ownable = null)
  * @param string|null $entityClass
  * @return bool
  */
-function userCanOnAny(string $permission, string $entityClass = null)
+function userCanOnAny(string $permission, string $entityClass = null) : bool
 {
     $permissionService = app(PermissionService::class);
     return $permissionService->checkUserHasPermissionOnAnything($permission, $entityClass);
@@ -93,84 +94,27 @@ function userCanOnAny(string $permission, string $entityClass = null)
  * Helper to access system settings.
  * @param $key
  * @param bool $default
- * @return bool|string|\BookStack\Settings\SettingService
+ * @return bool|string|SettingService
  */
 function setting($key = null, $default = false)
 {
-    $settingService = resolve(\BookStack\Settings\SettingService::class);
+    $settingService = resolve(SettingService::class);
     if (is_null($key)) {
         return $settingService;
     }
     return $settingService->get($key, $default);
 }
 
-/**
- * Helper to create url's relative to the applications root path.
- * @param string $path
- * @param bool $forceAppDomain
- * @return string
- */
-function baseUrl($path, $forceAppDomain = false)
-{
-    return url($path);
-    $isFullUrl = strpos($path, 'http') === 0;
-    if ($isFullUrl && !$forceAppDomain) {
-        return $path;
-    }
-
-    $path = trim($path, '/');
-    $base = rtrim(config('app.url'), '/');
-
-    // Remove non-specified domain if forced and we have a domain
-    if ($isFullUrl && $forceAppDomain) {
-        if (!empty($base) && strpos($path, $base) === 0) {
-            $path = mb_substr($path, mb_strlen($base));
-        } else {
-            $explodedPath = explode('/', $path);
-            $path = implode('/', array_splice($explodedPath, 3));
-        }
-    }
-
-    // Return normal url path if not specified in config
-    if (config('app.url') === '') {
-        return url($path);
-    }
-
-    return $base . '/' . ltrim($path, '/');
-}
-
-/**
- * Get an instance of the redirector.
- * Overrides the default laravel redirect helper.
- * Ensures it redirects even when the app is in a subdirectory.
- *
- * @param  string|null  $to
- * @param  int     $status
- * @param  array   $headers
- * @param  bool    $secure
- * @return \Illuminate\Routing\Redirector|\Illuminate\Http\RedirectResponse
- */
-function redirect($to = null, $status = 302, $headers = [], $secure = null)
-{
-    if (is_null($to)) {
-        return app('redirect');
-    }
-
-    $to = baseUrl($to);
-
-    return app('redirect')->to($to, $status, $headers, $secure);
-}
-
 /**
  * Get a path to a theme resource.
  * @param string $path
- * @return string|boolean
+ * @return string
  */
-function theme_path($path = '')
+function theme_path($path = '') : string
 {
     $theme = config('view.theme');
     if (!$theme) {
-        return false;
+        return '';
     }
 
     return base_path('themes/' . $theme .($path ? DIRECTORY_SEPARATOR.$path : $path));
@@ -242,5 +186,5 @@ function sortUrl($path, $data, $overrideData = [])
         return $path;
     }
 
-    return baseUrl($path . '?' . implode('&', $queryStringSections));
+    return url($path . '?' . implode('&', $queryStringSections));
 }
index ad378d7e071ae46d8873169bac808b874615536b..8205764728cdb1dc6bd8bdfb78f20ebec5525ac3 100644 (file)
@@ -34,6 +34,7 @@ require __DIR__.'/../bootstrap/init.php';
 */
 
 $app = require_once __DIR__.'/../bootstrap/app.php';
+$app->alias('request', \BookStack\Http\Request::class);
 
 /*
 |--------------------------------------------------------------------------
@@ -50,7 +51,7 @@ $app = require_once __DIR__.'/../bootstrap/app.php';
 $kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);
 
 $response = $kernel->handle(
-    $request = Illuminate\Http\Request::capture()
+    $request = \BookStack\Http\Request::capture()
 );
 
 $response->send();
index ea63cf7ac1ba764725e7442e5ccd5a5de5534448..dc6081637f784f9a7823d9443eca91d51a0e7f85 100644 (file)
@@ -7,6 +7,6 @@
     <label for="password">{{ trans('auth.password') }}</label>
     @include('form.password', ['name' => 'password', 'tabindex' => 1])
     <span class="block small mt-s">
-        <a href="{{ baseUrl('/password/email') }}">{{ trans('auth.forgot_password') }}</a>
+        <a href="{{ url('/password/email') }}">{{ trans('auth.forgot_password') }}</a>
     </span>
 </div>
index a0e5f716c37d85e8b9999719016ce8a1d9f6239b..76aa3a6e952201e0219bf62a6c239c376fe32d92 100644 (file)
@@ -9,7 +9,7 @@
         <div class="card content-wrap auto-height">
             <h1 class="list-heading">{{ title_case(trans('auth.log_in')) }}</h1>
 
-            <form action="{{ baseUrl('/login') }}" method="POST" id="login-form" class="mt-l">
+            <form action="{{ url('/login') }}" method="POST" id="login-form" class="mt-l">
                 {!! csrf_field() !!}
 
                 <div class="stretch-inputs">
@@ -38,7 +38,7 @@
                 <hr class="my-l">
                 @foreach($socialDrivers as $driver => $name)
                     <div>
-                        <a id="social-login-{{$driver}}" class="button outline block svg" href="{{ baseUrl("/login/service/" . $driver) }}">
+                        <a id="social-login-{{$driver}}" class="button outline block svg" href="{{ url("/login/service/" . $driver) }}">
                             @icon('auth/' . $driver)
                             {{ trans('auth.log_in_with', ['socialDriver' => $name]) }}
                         </a>
@@ -49,7 +49,7 @@
             @if(setting('registration-enabled', false))
                 <div class="text-center pb-s">
                     <hr class="my-l">
-                    <a href="{{ baseUrl('/register') }}">{{ trans('auth.dont_have_account') }}</a>
+                    <a href="{{ url('/register') }}">{{ trans('auth.dont_have_account') }}</a>
                 </div>
             @endif
         </div>
index de4edff0a8e479da8999a802727d7d76c6f1cb72..864b4e7d26b3940f6a4491f5519007126ebc587f 100644 (file)
@@ -7,7 +7,7 @@
 
             <p class="text-muted small">{{ trans('auth.reset_password_send_instructions') }}</p>
 
-            <form action="{{ baseUrl("/password/email") }}" method="POST" class="stretch-inputs">
+            <form action="{{ url("/password/email") }}" method="POST" class="stretch-inputs">
                 {!! csrf_field() !!}
 
                 <div class="form-group">
index fa6ad5b9a327b6cd0945709f27c31616a21913f8..227b39079d75879b517311c7999dd7071b041c21 100644 (file)
@@ -6,7 +6,7 @@
         <div class="card content-wrap auto-height">
             <h1 class="list-heading">{{ trans('auth.reset_password') }}</h1>
 
-            <form action="{{ baseUrl("/password/reset") }}" method="POST" class="stretch-inputs">
+            <form action="{{ url("/password/reset") }}" method="POST" class="stretch-inputs">
                 {!! csrf_field() !!}
                 <input type="hidden" name="token" value="{{ $token }}">
 
index 38904f63bb7ce880d3b5a80ae0731227f63bc83d..9cf34f501e0170571ac6ca2971c3a988889256e3 100644 (file)
@@ -8,7 +8,7 @@
         <div class="card content-wrap auto-height">
             <h1 class="list-heading">{{ title_case(trans('auth.sign_up')) }}</h1>
 
-            <form action="{{ baseUrl("/register") }}" method="POST" class="mt-l stretch-inputs">
+            <form action="{{ url("/register") }}" method="POST" class="mt-l stretch-inputs">
                 {!! csrf_field() !!}
 
                 <div class="form-group">
@@ -28,7 +28,7 @@
 
                 <div class="grid half collapse-xs gap-xl v-center mt-m">
                     <div class="text-small">
-                        <a href="{{ baseUrl('/login') }}">{{ trans('auth.already_have_account') }}</a>
+                        <a href="{{ url('/login') }}">{{ trans('auth.already_have_account') }}</a>
                     </div>
                     <div class="from-group text-right">
                         <button class="button primary">{{ trans('auth.create_account') }}</button>
@@ -42,7 +42,7 @@
                 <hr class="my-l">
                 @foreach($socialDrivers as $driver => $name)
                     <div>
-                        <a id="social-register-{{$driver}}" class="button block outline svg" href="{{ baseUrl("/register/service/" . $driver) }}">
+                        <a id="social-register-{{$driver}}" class="button block outline svg" href="{{ url("/register/service/" . $driver) }}">
                             @icon('auth/' . $driver)
                             {{ trans('auth.sign_up_with', ['socialDriver' => $name]) }}
                         </a>
index 54bf6eda3314ac73d4b07b3de18d645e1f40dfe1..2142a5dcb4afead277b8da223ef58059ec639d29 100644 (file)
@@ -13,7 +13,7 @@
                 {{ trans('auth.email_not_confirmed_resend') }}
             </p>
 
-            <form action="{{ baseUrl("/register/confirm/resend") }}" method="POST" class="stretch-inputs">
+            <form action="{{ url("/register/confirm/resend") }}" method="POST" class="stretch-inputs">
                 {!! csrf_field() !!}
                 <div class="form-group">
                     <label for="email">{{ trans('auth.email') }}</label>
index f5459a717b13e36e72c77966ac3be5aff2ef68d2..da0e6eb44601fb2104a0410a36b2149a4d87c6be 100644 (file)
@@ -6,7 +6,7 @@
     <!-- Meta -->
     <meta name="viewport" content="width=device-width">
     <meta name="token" content="{{ csrf_token() }}">
-    <meta name="base-url" content="{{ baseUrl('/') }}">
+    <meta name="base-url" content="{{ url('/') }}">
     <meta charset="utf-8">
 
     <!-- Styles and Fonts -->
index 40b781441ddda044dc8f59c6f6a4079fe3321277..65958e137e8aa357fb1613115e86edade88c8566 100644 (file)
@@ -27,7 +27,7 @@
 
         <div class="content-wrap card">
             <h1 class="list-heading">{{ trans('entities.books_create') }}</h1>
-            <form action="{{ isset($bookshelf) ? $bookshelf->getUrl('/create-book') : baseUrl('/books') }}" method="POST" enctype="multipart/form-data">
+            <form action="{{ isset($bookshelf) ? $bookshelf->getUrl('/create-book') : url('/books') }}" method="POST" enctype="multipart/form-data">
                 @include('books.form')
             </form>
         </div>
index 4edec240a03e9a961bca643f45c5ba5a518058c0..5d3f11e2e86e85c12ba78ac360a6a19807df610f 100644 (file)
@@ -18,8 +18,8 @@
         <p class="small">{{ trans('common.cover_image_description') }}</p>
 
         @include('components.image-picker', [
-            'defaultImage' => baseUrl('/book_default_cover.png'),
-            'currentImage' => (isset($model) && $model->cover) ? $model->getBookCover() : baseUrl('/book_default_cover.png') ,
+            'defaultImage' => url('/book_default_cover.png'),
+            'currentImage' => (isset($model) && $model->cover) ? $model->getBookCover() : url('/book_default_cover.png') ,
             'name' => 'image',
             'imageClass' => 'cover'
         ])
@@ -36,6 +36,6 @@
 </div>
 
 <div class="form-group text-right">
-    <a href="{{ isset($book) ? $book->getUrl() : baseUrl('/books') }}" class="button outline">{{ trans('common.cancel') }}</a>
+    <a href="{{ isset($book) ? $book->getUrl() : url('/books') }}" class="button outline">{{ trans('common.cancel') }}</a>
     <button type="submit" class="button primary">{{ trans('entities.books_save') }}</button>
 </div>
\ No newline at end of file
index 61d99848955188c3d1e9905ad235277442461429..b9bd987a9c723224eddd35272a5f2ea2a61aa900 100644 (file)
@@ -37,7 +37,7 @@
         <h5>{{ trans('common.actions') }}</h5>
         <div class="icon-list text-primary">
             @if($currentUser->can('book-create-all'))
-                <a href="{{ baseUrl("/create-book") }}" class="icon-list-item">
+                <a href="{{ url("/create-book") }}" class="icon-list-item">
                     <span>@icon('add')</span>
                     <span>{{ trans('entities.books_create') }}</span>
                 </a>
index 93d927ec7cf0a4f5e214dc0702e88d8a7686c2c7..84578e3a59ba5851ca4224143ccf9c96c8e6b10a 100644 (file)
@@ -28,7 +28,7 @@
     @else
         <p class="text-muted">{{ trans('entities.books_empty') }}</p>
         @if(userCan('books-create-all'))
-            <a href="{{ baseUrl("/create-book") }}" class="text-pos">@icon('edit'){{ trans('entities.create_now') }}</a>
+            <a href="{{ url("/create-book") }}" class="text-pos">@icon('edit'){{ trans('entities.create_now') }}</a>
         @endif
     @endif
 </div>
\ No newline at end of file
index 734789899b1e804f65efc8ea2fecbbbc040fbef4..a5336c3f86216e4eb8b6739cd6a597a77668193d 100644 (file)
@@ -2,9 +2,9 @@
     <div class="grid mx-l">
 
         <div>
-            <a href="{{ baseUrl('/') }}" class="logo">
+            <a href="{{ url('/') }}" class="logo">
                 @if(setting('app-logo', '') !== 'none')
-                    <img class="logo-image" src="{{ setting('app-logo', '') === '' ? baseUrl('/logo.png') : baseUrl(setting('app-logo', '')) }}" alt="Logo">
+                    <img class="logo-image" src="{{ setting('app-logo', '') === '' ? url('/logo.png') : url(setting('app-logo', '')) }}" alt="Logo">
                 @endif
                 @if (setting('app-name-header'))
                     <span class="logo-text">{{ setting('app-name') }}</span>
@@ -15,7 +15,7 @@
 
         <div class="header-search hide-under-l">
             @if (hasAppAccess())
-            <form action="{{ baseUrl('/search') }}" method="GET" class="search-box">
+            <form action="{{ url('/search') }}" method="GET" class="search-box">
                 <button id="header-search-box-button" type="submit">@icon('search') </button>
                 <input id="header-search-box-input" type="text" name="term" tabindex="2" placeholder="{{ trans('common.search') }}" value="{{ isset($searchTerm) ? $searchTerm : '' }}">
             </form>
             <div class="header-links">
                 <div class="links text-center">
                     @if (hasAppAccess())
-                        <a class="hide-over-l" href="{{ baseUrl('/search') }}">@icon('search'){{ trans('common.search') }}</a>
+                        <a class="hide-over-l" href="{{ url('/search') }}">@icon('search'){{ trans('common.search') }}</a>
                         @if(userCanOnAny('view', \BookStack\Entities\Bookshelf::class) || userCan('bookshelf-view-all') || userCan('bookshelf-view-own'))
-                            <a href="{{ baseUrl('/shelves') }}">@icon('bookshelf'){{ trans('entities.shelves') }}</a>
+                            <a href="{{ url('/shelves') }}">@icon('bookshelf'){{ trans('entities.shelves') }}</a>
                         @endif
-                        <a href="{{ baseUrl('/books') }}">@icon('books'){{ trans('entities.books') }}</a>
+                        <a href="{{ url('/books') }}">@icon('books'){{ trans('entities.books') }}</a>
                         @if(signedInUser() && userCan('settings-manage'))
-                            <a href="{{ baseUrl('/settings') }}">@icon('settings'){{ trans('settings.settings') }}</a>
+                            <a href="{{ url('/settings') }}">@icon('settings'){{ trans('settings.settings') }}</a>
                         @endif
                         @if(signedInUser() && userCan('users-manage') && !userCan('settings-manage'))
-                            <a href="{{ baseUrl('/settings/users') }}">@icon('users'){{ trans('settings.users') }}</a>
+                            <a href="{{ url('/settings/users') }}">@icon('users'){{ trans('settings.users') }}</a>
                         @endif
                     @endif
 
                     @if(!signedInUser())
                         @if(setting('registration-enabled', false))
-                            <a href="{{ baseUrl('/register') }}">@icon('new-user') {{ trans('auth.sign_up') }}</a>
+                            <a href="{{ url('/register') }}">@icon('new-user') {{ trans('auth.sign_up') }}</a>
                         @endif
-                        <a href="{{ baseUrl('/login') }}">@icon('login') {{ trans('auth.log_in') }}</a>
+                        <a href="{{ url('/login') }}">@icon('login') {{ trans('auth.log_in') }}</a>
                     @endif
                 </div>
                 @if(signedInUser())
                         </span>
                         <ul class="dropdown-menu">
                             <li>
-                                <a href="{{ baseUrl("/user/{$currentUser->id}") }}">@icon('user'){{ trans('common.view_profile') }}</a>
+                                <a href="{{ url("/user/{$currentUser->id}") }}">@icon('user'){{ trans('common.view_profile') }}</a>
                             </li>
                             <li>
-                                <a href="{{ baseUrl("/settings/users/{$currentUser->id}") }}">@icon('edit'){{ trans('common.edit_profile') }}</a>
+                                <a href="{{ url("/settings/users/{$currentUser->id}") }}">@icon('edit'){{ trans('common.edit_profile') }}</a>
                             </li>
                             <li>
-                                <a href="{{ baseUrl('/logout') }}">@icon('logout'){{ trans('auth.logout') }}</a>
+                                <a href="{{ url('/logout') }}">@icon('logout'){{ trans('auth.logout') }}</a>
                             </li>
                         </ul>
                     </div>
index 07eda2cff997ac848a1c7f63b1720d8ce6226212..12adda618905a59033b8b40cd6326ee2ab26cf05 100644 (file)
@@ -15,7 +15,7 @@
 </div>
 
 <div class="mb-xl">
-    <h5><a class="no-color" href="{{ baseUrl("/pages/recently-updated") }}">{{ trans('entities.recently_updated_pages') }}</a></h5>
+    <h5><a class="no-color" href="{{ url("/pages/recently-updated") }}">{{ trans('entities.recently_updated_pages') }}</a></h5>
     <div id="recently-updated-pages">
         @include('partials.entity-list', [
         'entities' => $recentlyUpdatedPages,
index 2f0189f872c3ef86f61f4c66a64c8db2bd60935a..cd27ff5687e006fffa598cb30f4e2243601e4243 100644 (file)
@@ -34,7 +34,7 @@
 
             <div>
                 <div id="recent-pages" class="card mb-xl">
-                    <h3 class="card-title"><a class="no-color" href="{{ baseUrl("/pages/recently-updated") }}">{{ trans('entities.recently_updated_pages') }}</a></h3>
+                    <h3 class="card-title"><a class="no-color" href="{{ url("/pages/recently-updated") }}">{{ trans('entities.recently_updated_pages') }}</a></h3>
                     <div id="recently-updated-pages" class="px-m">
                         @include('partials.entity-list', [
                         'entities' => $recentlyUpdatedPages,
index e8b2220e5cb981445a3666e629b9cfee0863968e..28af63caf3969fb2087729bdd8e1112305f5b4c1 100644 (file)
@@ -4,7 +4,7 @@ $key - Unique key for checking existing stored state.
 --}}
 <?php $isOpen = setting()->getForCurrentUser('section_expansion#'. $key); ?>
 <a expand-toggle="{{ $target }}"
-   expand-toggle-update-endpoint="{{ baseUrl('/settings/users/'. $currentUser->id .'/update-expansion-preference/' . $key) }}"
+   expand-toggle-update-endpoint="{{ url('/settings/users/'. $currentUser->id .'/update-expansion-preference/' . $key) }}"
    expand-toggle-is-open="{{ $isOpen ? 'yes' : 'no' }}"
    class="text-muted icon-list-item text-primary">
     <span>@icon('expand-text')</span>
index 7a3285fa76afe1215c1939c639056e6f53193b8f..e24ea49f1c82a7a374f8c8cf0c51392a40cac943 100644 (file)
@@ -3,7 +3,7 @@
 <div page-picker>
     <div class="input-base">
         <span @if($value) style="display: none" @endif page-picker-default class="text-muted italic">{{ $placeholder }}</span>
-        <a @if(!$value) style="display: none" @endif href="{{ baseUrl('/link/' . $value) }}" target="_blank" class="text-page" page-picker-display>#{{$value}}, {{$value ? \BookStack\Entities\Page::find($value)->name : '' }}</a>
+        <a @if(!$value) style="display: none" @endif href="{{ url('/link/' . $value) }}" target="_blank" class="text-page" page-picker-display>#{{$value}}, {{$value ? \BookStack\Entities\Page::find($value)->name : '' }}</a>
     </div>
     <br>
     <input type="hidden" value="{{$value}}" name="{{$name}}" id="{{$name}}">
index 1d1cc2d806153baa00d770e3ca05b4735fb5177b..f7a9c6c48623c36d92f9e0434532a1388f5753c7 100644 (file)
@@ -1,6 +1,6 @@
 @foreach($entity->tags as $tag)
     <div class="tag-item primary-background-light">
-        <div class="tag-name"><a href="{{ baseUrl('/search?term=%5B' . urlencode($tag->name) .'%5D') }}">@icon('tag'){{ $tag->name }}</a></div>
-        @if($tag->value) <div class="tag-value"><a href="{{ baseUrl('/search?term=%5B' . urlencode($tag->name) .'%3D' . urlencode($tag->value) . '%5D') }}">{{$tag->value}}</a></div> @endif
+        <div class="tag-name"><a href="{{ url('/search?term=%5B' . urlencode($tag->name) .'%5D') }}">@icon('tag'){{ $tag->name }}</a></div>
+        @if($tag->value) <div class="tag-value"><a href="{{ url('/search?term=%5B' . urlencode($tag->name) .'%3D' . urlencode($tag->value) . '%5D') }}">{{$tag->value}}</a></div> @endif
     </div>
 @endforeach
\ No newline at end of file
index 5ae3831986bc8aa8eeee34a09f72275f63f4811a..31585dc41aedb8bede78dba2fd7d6b5d43fa4803 100644 (file)
@@ -7,11 +7,11 @@
             <div v-for="(tag, i) in tags" :key="tag.key" class="card drag-card">
                 <div class="handle" >@icon('grip')</div>
                 <div>
-                    <autosuggest url="{{ baseUrl('/ajax/tags/suggest/names') }}" type="name" class="outline" :name="getTagFieldName(i, 'name')"
+                    <autosuggest url="{{ url('/ajax/tags/suggest/names') }}" type="name" class="outline" :name="getTagFieldName(i, 'name')"
                                  v-model="tag.name" @input="tagChange(tag)" @blur="tagBlur(tag)" placeholder="{{ trans('entities.tag') }}"/>
                 </div>
                 <div>
-                    <autosuggest url="{{ baseUrl('/ajax/tags/suggest/values') }}" type="value" class="outline" :name="getTagFieldName(i, 'value')"
+                    <autosuggest url="{{ url('/ajax/tags/suggest/values') }}" type="value" class="outline" :name="getTagFieldName(i, 'value')"
                                  v-model="tag.value" @change="tagChange(tag)" @blur="tagBlur(tag)" placeholder="{{ trans('entities.tag_value') }}"/>
                 </div>
                 <div v-show="tags.length !== 1" class="text-center drag-card-action text-neg" @click="removeTag(tag)">@icon('close')</div>
index 228c51520e7d92c47a94cf1ef5bbebd3fb1af054..c1937ff23e5ce0311ac7247e8bb7a4e57813625f 100644 (file)
@@ -10,7 +10,7 @@
                 <h5>{{ trans('errors.sorry_page_not_found') }}</h5>
             </div>
             <div class="text-right">
-                <a href="{{ baseUrl('/') }}" class="button outline">{{ trans('errors.return_home') }}</a>
+                <a href="{{ url('/') }}" class="button outline">{{ trans('errors.return_home') }}</a>
             </div>
         </div>
 
index 3745f2292f733ce4c18f1af01d6f9e0130c7c288..8c6822767a1f823e67782a3d0a0fb96ad89cd8e2 100644 (file)
@@ -7,7 +7,7 @@
             <h3 class="text-muted">{{ trans('errors.error_occurred') }}</h3>
             <div class="body">
                 <h5>{{ $message ?? 'An unknown error occurred' }}</h5>
-                <p><a href="{{ baseUrl('/') }}" class="button outline">{{ trans('errors.return_home') }}</a></p>
+                <p><a href="{{ url('/') }}" class="button outline">{{ trans('errors.return_home') }}</a></p>
             </div>
         </div>
     </div>
index 15f5d5d96fdc7646b35716b187280d6374ef0e5b..4930e30a3d5710628cd017d2c7b2350b689b4b37 100644 (file)
@@ -1,7 +1,7 @@
 @extends('base')
 
 @section('head')
-    <script src="{{ baseUrl('/libs/tinymce/tinymce.min.js?ver=4.9.4') }}"></script>
+    <script src="{{ url('/libs/tinymce/tinymce.min.js?ver=4.9.4') }}"></script>
 @stop
 
 @section('body-class', 'flexbox')
index df5d1aa049fce72ba44a9e45a1a8ac73b826f8a6..28c7196ee490c9e0e8a0039f984e200b00e128d6 100644 (file)
@@ -3,7 +3,7 @@
 
     {{-- Show top level books item --}}
     @if (count($crumbs) > 0 && array_first($crumbs) instanceof  \BookStack\Entities\Book)
-        <a href="{{  baseUrl('/books')  }}" class="text-book icon-list-item outline-hover">
+        <a href="{{  url('/books')  }}" class="text-book icon-list-item outline-hover">
             <span>@icon('books')</span>
             <span>{{ trans('entities.books') }}</span>
         </a>
@@ -12,7 +12,7 @@
 
     {{-- Show top level shelves item --}}
     @if (count($crumbs) > 0 && array_first($crumbs) instanceof  \BookStack\Entities\Bookshelf)
-        <a href="{{  baseUrl('/shelves')  }}" class="text-bookshelf icon-list-item outline-hover">
+        <a href="{{  url('/shelves')  }}" class="text-bookshelf icon-list-item outline-hover">
             <span>@icon('bookshelf')</span>
             <span>{{ trans('entities.shelves') }}</span>
         </a>
         @endif
 
         @if (is_string($crumb))
-            <a href="{{  baseUrl($key)  }}">
+            <a href="{{  url($key)  }}">
                 {{ $crumb }}
             </a>
         @elseif (is_array($crumb))
-            <a href="{{  baseUrl($key)  }}" class="icon-list-item outline-hover">
+            <a href="{{  url($key)  }}" class="icon-list-item outline-hover">
                 <span>@icon($crumb['icon'])</span>
                 <span>{{ $crumb['text'] }}</span>
             </a>
index 9544bcee1e3d828763d96b0870eb11ce088282a1..38145df219f4c9d7c70d7a2a5d47f4273b12c287 100644 (file)
@@ -4,7 +4,7 @@
 ?>
 <div class="list-sort-container" list-sort-control>
     <div class="list-sort-label">{{ trans('common.sort') }}</div>
-    <form action="{{ baseUrl("/settings/users/{$currentUser->id}/change-sort/{$type}") }}" method="post">
+    <form action="{{ url("/settings/users/{$currentUser->id}/change-sort/{$type}") }}" method="post">
 
         {!! csrf_field() !!}
         {!! method_field('PATCH') !!}
index 9eb00e1d95261d0b977ca44a8f900bd3d4fa8618..9f911c88231d1775366263e0e29766705690df94 100644 (file)
@@ -1,5 +1,5 @@
 <div>
-    <form action="{{ baseUrl("/settings/users/{$currentUser->id}/switch-${type}-view") }}" method="POST" class="inline">
+    <form action="{{ url("/settings/users/{$currentUser->id}/switch-${type}-view") }}" method="POST" class="inline">
         {!! csrf_field() !!}
         {!! method_field('PATCH') !!}
         <input type="hidden" value="{{ $view === 'list'? 'grid' : 'list' }}" name="view_type">
index 03c0b93e71a9acdc5fe11c4e5aa02fa06a377c9f..7a2cf65bd35694f39ecdf8c60e9dce3905cd4901 100644 (file)
             <div>
                 <div v-pre class="card content-wrap">
                     <h1 class="list-heading">{{ trans('entities.search_results') }}</h1>
-                    <form action="{{ baseUrl('/search') }}" method="GET"  class="search-box flexible hide-over-l">
+                    <form action="{{ url('/search') }}" method="GET"  class="search-box flexible hide-over-l">
                         <input value="{{$searchTerm}}" type="text" name="term" placeholder="{{ trans('common.search') }}">
                         <button type="submit">@icon('search')</button>
                         <button v-if="searching" v-cloak class="search-box-cancel text-neg" v-on:click="clearSearch" type="button">@icon('close')</button>
index 4aa88b047859d1ad75111af0eaecc530eb671f6e..510e3af1bb662f3a95f966a9d7d886684bbb724c 100644 (file)
@@ -15,7 +15,7 @@
 
         <div class="card content-wrap auto-height">
             <h2 class="list-heading">{{ trans('settings.app_features_security') }}</h2>
-            <form action="{{ baseUrl("/settings") }}" method="POST">
+            <form action="{{ url("/settings") }}" method="POST">
                 {!! csrf_field() !!}
 
                 <div class="setting-list">
@@ -27,7 +27,7 @@
                             <p class="small">{!! trans('settings.app_public_access_desc') !!}</p>
                             @if(userCan('users-manage'))
                                 <p class="small mb-none">
-                                    <a href="{{ baseUrl($guestUser->getEditUrl()) }}">{!! trans('settings.app_public_access_desc_guest') !!}</a>
+                                    <a href="{{ url($guestUser->getEditUrl()) }}">{!! trans('settings.app_public_access_desc_guest') !!}</a>
                                 </p>
                             @endif
                         </div>
@@ -79,7 +79,7 @@
 
         <div class="card content-wrap auto-height">
             <h2 class="list-heading">{{ trans('settings.app_customization') }}</h2>
-            <form action="{{ baseUrl("/settings") }}" method="POST" enctype="multipart/form-data">
+            <form action="{{ url("/settings") }}" method="POST" enctype="multipart/form-data">
                 {!! csrf_field() !!}
 
                 <div class="setting-list">
                             @include('components.image-picker', [
                                      'removeName' => 'setting-app-logo',
                                      'removeValue' => 'none',
-                                     'defaultImage' => baseUrl('/logo.png'),
+                                     'defaultImage' => url('/logo.png'),
                                      'currentImage' => setting('app-logo'),
                                      'name' => 'app_logo',
                                      'imageClass' => 'logo-image',
 
         <div class="card content-wrap auto-height">
             <h2 class="list-heading">{{ trans('settings.reg_settings') }}</h2>
-            <form action="{{ baseUrl("/settings") }}" method="POST">
+            <form action="{{ url("/settings") }}" method="POST">
                 {!! csrf_field() !!}
 
                 <div class="setting-list">
index c3ca8c96fbf95102e0a88de8422036fdacfff3cf..6be49cdf2c94479d077ef2258f36bcdd08d1183c 100644 (file)
@@ -21,7 +21,7 @@
                 <p class="small text-muted">{{ trans('settings.maint_image_cleanup_desc') }}</p>
             </div>
             <div>
-                <form method="POST" action="{{ baseUrl('/settings/maintenance/cleanup-images') }}">
+                <form method="POST" action="{{ url('/settings/maintenance/cleanup-images') }}">
                     {!! csrf_field()  !!}
                     <input type="hidden" name="_method" value="DELETE">
                     <div>
index ddbaa3f2a865db53fea0cfd47c0ce1d33133f9dc..51fda5b9031e57f967e895b4b7ab6761f0e65fd4 100644 (file)
@@ -1,13 +1,13 @@
 
 <div class="active-link-list">
     @if($currentUser->can('settings-manage'))
-        <a href="{{ baseUrl('/settings') }}" @if($selected == 'settings') class="active" @endif>@icon('settings'){{ trans('settings.settings') }}</a>
-        <a href="{{ baseUrl('/settings/maintenance') }}" @if($selected == 'maintenance') class="active" @endif>@icon('spanner'){{ trans('settings.maint') }}</a>
+        <a href="{{ url('/settings') }}" @if($selected == 'settings') class="active" @endif>@icon('settings'){{ trans('settings.settings') }}</a>
+        <a href="{{ url('/settings/maintenance') }}" @if($selected == 'maintenance') class="active" @endif>@icon('spanner'){{ trans('settings.maint') }}</a>
     @endif
     @if($currentUser->can('users-manage'))
-        <a href="{{ baseUrl('/settings/users') }}" @if($selected == 'users') class="active" @endif>@icon('users'){{ trans('settings.users') }}</a>
+        <a href="{{ url('/settings/users') }}" @if($selected == 'users') class="active" @endif>@icon('users'){{ trans('settings.users') }}</a>
     @endif
     @if($currentUser->can('user-roles-manage'))
-        <a href="{{ baseUrl('/settings/roles') }}" @if($selected == 'roles') class="active" @endif>@icon('lock-open'){{ trans('settings.roles') }}</a>
+        <a href="{{ url('/settings/roles') }}" @if($selected == 'roles') class="active" @endif>@icon('lock-open'){{ trans('settings.roles') }}</a>
     @endif
 </div>
\ No newline at end of file
index 80a6fc3820d1bffb5c671652d02e0e56f409d391..df902133f3ee514858ae703df5e52b5ab10f934b 100644 (file)
@@ -8,7 +8,7 @@
             @include('settings.navbar', ['selected' => 'roles'])
         </div>
 
-        <form action="{{ baseUrl("/settings/roles/new") }}" method="POST">
+        <form action="{{ url("/settings/roles/new") }}" method="POST">
             @include('settings.roles.form', ['title' => trans('settings.role_create')])
         </form>
     </div>
index a2ea0d7281cd22fb30988048f2965cf0a067315d..e0075fa8ad27d5a4811ec6aa89ac7c25b56ee113 100644 (file)
@@ -12,7 +12,7 @@
 
             <p>{{ trans('settings.role_delete_confirm', ['roleName' => $role->display_name]) }}</p>
 
-            <form action="{{ baseUrl("/settings/roles/delete/{$role->id}") }}" method="POST">
+            <form action="{{ url("/settings/roles/delete/{$role->id}") }}" method="POST">
                 {!! csrf_field() !!}
                 <input type="hidden" name="_method" value="DELETE">
 
@@ -31,7 +31,7 @@
                     </div>
                     <div>
                         <div class="form-group text-right">
-                            <a href="{{ baseUrl("/settings/roles/{$role->id}") }}" class="button outline">{{ trans('common.cancel') }}</a>
+                            <a href="{{ url("/settings/roles/{$role->id}") }}" class="button outline">{{ trans('common.cancel') }}</a>
                             <button type="submit" class="button primary">{{ trans('common.confirm') }}</button>
                         </div>
                     </div>
index a7b81322977c59eb48780d4fd8a8b13a2e23e3ea..0f83bdb0becca1370a8a3085055cf376e2a0b1e3 100644 (file)
@@ -7,7 +7,7 @@
             @include('settings.navbar', ['selected' => 'roles'])
         </div>
 
-        <form action="{{ baseUrl("/settings/roles/{$role->id}") }}" method="POST">
+        <form action="{{ url("/settings/roles/{$role->id}") }}" method="POST">
             <input type="hidden" name="_method" value="PUT">
             @include('settings.roles.form', ['model' => $role, 'title' => trans('settings.role_edit'), 'icon' => 'edit'])
         </form>
index 6d723086714bbc844cdd49ab672571c037324c2c..68b841e034d8be9e09f896f24386eb31960713ea 100644 (file)
     </div>
 
     <div class="form-group text-right">
-        <a href="{{ baseUrl("/settings/roles") }}" class="button outline">{{ trans('common.cancel') }}</a>
+        <a href="{{ url("/settings/roles") }}" class="button outline">{{ trans('common.cancel') }}</a>
         @if (isset($role) && $role->id)
-            <a href="{{ baseUrl("/settings/roles/delete/{$role->id}") }}" class="button outline">{{ trans('settings.role_delete') }}</a>
+            <a href="{{ url("/settings/roles/delete/{$role->id}") }}" class="button outline">{{ trans('settings.role_delete') }}</a>
         @endif
         <button type="submit" class="button primary">{{ trans('settings.role_save') }}</button>
     </div>
                     </div>
                     <div>
                         @if(userCan('users-manage') || $currentUser->id == $user->id)
-                            <a href="{{ baseUrl("/settings/users/{$user->id}") }}">
+                            <a href="{{ url("/settings/users/{$user->id}") }}">
                                 @endif
                                 {{ $user->name }}
                                 @if(userCan('users-manage') || $currentUser->id == $user->id)
index 8eae235daf8a471906ed8d21edeb94f23e7c53a2..47cd8c920fffa07909215e12e8f8d3d5d8dedee9 100644 (file)
@@ -14,7 +14,7 @@
                 <h1 class="list-heading">{{ trans('settings.role_user_roles') }}</h1>
 
                 <div class="text-right">
-                    <a href="{{ baseUrl("/settings/roles/new") }}" class="button outline">{{ trans('settings.role_create') }}</a>
+                    <a href="{{ url("/settings/roles/new") }}" class="button outline">{{ trans('settings.role_create') }}</a>
                 </div>
             </div>
 
@@ -26,7 +26,7 @@
                 </tr>
                 @foreach($roles as $role)
                     <tr>
-                        <td><a href="{{ baseUrl("/settings/roles/{$role->id}") }}">{{ $role->display_name }}</a></td>
+                        <td><a href="{{ url("/settings/roles/{$role->id}") }}">{{ $role->display_name }}</a></td>
                         <td>{{ $role->description }}</td>
                         <td class="text-center">{{ $role->users->count() }}</td>
                     </tr>
index 706e15d07faafcb6f3f6855c8671375d79e46cb5..aee1c5a4299bfe6352dfec6d550c6f982abcde9a 100644 (file)
@@ -19,7 +19,7 @@
 
         <div class="card content-wrap">
             <h1 class="list-heading">{{ trans('entities.shelves_create') }}</h1>
-            <form action="{{ baseUrl("/shelves") }}" method="POST" enctype="multipart/form-data">
+            <form action="{{ url("/shelves") }}" method="POST" enctype="multipart/form-data">
                 @include('shelves.form', ['shelf' => null, 'books' => $books])
             </form>
         </div>
index 5803275df7b25b869071ecdb7c9426bc1cbff5e9..1d152a143459aa411ad6535213ff41b371c6e199 100644 (file)
@@ -47,8 +47,8 @@
         <p class="small">{{ trans('common.cover_image_description') }}</p>
 
         @include('components.image-picker', [
-            'defaultImage' => baseUrl('/book_default_cover.png'),
-            'currentImage' => (isset($shelf) && $shelf->cover) ? $shelf->getBookCover() : baseUrl('/book_default_cover.png') ,
+            'defaultImage' => url('/book_default_cover.png'),
+            'currentImage' => (isset($shelf) && $shelf->cover) ? $shelf->getBookCover() : url('/book_default_cover.png') ,
             'name' => 'image',
             'imageClass' => 'cover'
         ])
@@ -65,6 +65,6 @@
 </div>
 
 <div class="form-group text-right">
-    <a href="{{ isset($shelf) ? $shelf->getUrl() : baseUrl('/shelves') }}" class="button outline">{{ trans('common.cancel') }}</a>
+    <a href="{{ isset($shelf) ? $shelf->getUrl() : url('/shelves') }}" class="button outline">{{ trans('common.cancel') }}</a>
     <button type="submit" class="button primary">{{ trans('entities.shelves_save') }}</button>
 </div>
\ No newline at end of file
index 8cf959b1e49529092107324fff48e9e74bc8185e..98f97f1331b8c9985dd6f869759ac0116571c510 100644 (file)
@@ -10,7 +10,7 @@
         <h5>{{ trans('common.actions') }}</h5>
         <div class="icon-list text-primary">
             @if($currentUser->can('bookshelf-create-all'))
-                <a href="{{ baseUrl("/create-shelf") }}" class="icon-list-item">
+                <a href="{{ url("/create-shelf") }}" class="icon-list-item">
                     <span>@icon('add')</span>
                     <span>{{ trans('entities.shelves_new_action') }}</span>
                 </a>
index 70787f7e805ce9990d5403dadff7b58538d774a5..3f8c266e992b83e23cd261d3860a0d0e6973541e 100644 (file)
@@ -31,7 +31,7 @@
     @else
         <p class="text-muted">{{ trans('entities.shelves_empty') }}</p>
         @if(userCan('bookshelf-create-all'))
-            <a href="{{ baseUrl("/create-shelf") }}" class="button outline">@icon('edit'){{ trans('entities.create_now') }}</a>
+            <a href="{{ url("/create-shelf") }}" class="button outline">@icon('edit'){{ trans('entities.create_now') }}</a>
         @endif
     @endif
 
index cd5d75f8fb9b9da6a7d3e0c0569cab7485c7fb7d..b9f404bb712c9d0674f36ee5ebe51528b572d393 100644 (file)
@@ -11,7 +11,7 @@
         <div class="card content-wrap">
             <h1 class="list-heading">{{ trans('settings.users_add_new') }}</h1>
 
-            <form action="{{ baseUrl("/settings/users/create") }}" method="post">
+            <form action="{{ url("/settings/users/create") }}" method="post">
                 {!! csrf_field() !!}
 
                 <div class="setting-list">
@@ -19,7 +19,7 @@
                 </div>
 
                 <div class="form-group text-right">
-                    <a href="{{  baseUrl($currentUser->can('users-manage') ? "/settings/users" : "/") }}" class="button outline">{{ trans('common.cancel') }}</a>
+                    <a href="{{  url($currentUser->can('users-manage') ? "/settings/users" : "/") }}" class="button outline">{{ trans('common.cancel') }}</a>
                     <button class="button primary" type="submit">{{ trans('common.save') }}</button>
                 </div>
 
index 15ad7a9ec66df6678ed3777f261bb55f7e6dedf2..aa9811bf5fb190013cf20da1facacae8a9ad3373 100644 (file)
             <div class="grid half">
                 <p class="text-neg"><strong>{{ trans('settings.users_delete_confirm') }}</strong></p>
                 <div>
-                    <form action="{{ baseUrl("/settings/users/{$user->id}") }}" method="POST" class="text-right">
+                    <form action="{{ url("/settings/users/{$user->id}") }}" method="POST" class="text-right">
                         {!! csrf_field() !!}
 
                         <input type="hidden" name="_method" value="DELETE">
-                        <a href="{{ baseUrl("/settings/users/{$user->id}") }}" class="button outline">{{ trans('common.cancel') }}</a>
+                        <a href="{{ url("/settings/users/{$user->id}") }}" class="button outline">{{ trans('common.cancel') }}</a>
                         <button type="submit" class="button primary">{{ trans('common.confirm') }}</button>
                     </form>
                 </div>
index 377500193dc7d3b910667224a31e8645585a83e9..92a36c943aa1d25e2d12f4147e686179010ce29c 100644 (file)
@@ -9,7 +9,7 @@
 
         <div class="card content-wrap">
             <h1 class="list-heading">{{ $user->id === $currentUser->id ? trans('settings.users_edit_profile') : trans('settings.users_edit') }}</h1>
-            <form action="{{ baseUrl("/settings/users/{$user->id}") }}" method="post" enctype="multipart/form-data">
+            <form action="{{ url("/settings/users/{$user->id}") }}" method="post" enctype="multipart/form-data">
                 {!! csrf_field() !!}
                 <input type="hidden" name="_method" value="PUT">
 
@@ -26,7 +26,7 @@
                                 'resizeHeight' => '512',
                                 'resizeWidth' => '512',
                                 'showRemove' => false,
-                                'defaultImage' => baseUrl('/user_avatar.png'),
+                                'defaultImage' => url('/user_avatar.png'),
                                 'currentImage' => $user->getAvatar(80),
                                 'currentId' => $user->image_id,
                                 'name' => 'profile_image',
@@ -54,9 +54,9 @@
                 </div>
 
                 <div class="text-right">
-                    <a href="{{  baseUrl($currentUser->can('users-manage') ? "/settings/users" : "/") }}" class="button outline">{{ trans('common.cancel') }}</a>
+                    <a href="{{  url($currentUser->can('users-manage') ? "/settings/users" : "/") }}" class="button outline">{{ trans('common.cancel') }}</a>
                     @if($authMethod !== 'system')
-                        <a href="{{ baseUrl("/settings/users/{$user->id}/delete") }}" class="button outline">{{ trans('settings.users_delete') }}</a>
+                        <a href="{{ url("/settings/users/{$user->id}/delete") }}" class="button outline">{{ trans('settings.users_delete') }}</a>
                     @endif
                     <button class="button primary" type="submit">{{ trans('common.save') }}</button>
                 </div>
@@ -74,9 +74,9 @@
                                 <div>@icon('auth/'. $driver, ['style' => 'width: 56px;height: 56px;'])</div>
                                 <div>
                                     @if($user->hasSocialAccount($driver))
-                                        <a href="{{ baseUrl("/login/service/{$driver}/detach") }}" class="button small outline">{{ trans('settings.users_social_disconnect') }}</a>
+                                        <a href="{{ url("/login/service/{$driver}/detach") }}" class="button small outline">{{ trans('settings.users_social_disconnect') }}</a>
                                     @else
-                                        <a href="{{ baseUrl("/login/service/{$driver}") }}" class="button small outline">{{ trans('settings.users_social_connect') }}</a>
+                                        <a href="{{ url("/login/service/{$driver}") }}" class="button small outline">{{ trans('settings.users_social_connect') }}</a>
                                     @endif
                                 </div>
                             </div>
index af6b4d4f93e70d25c81a7dfff0af76e2479503c1..72db240758f228c7b56d045125b2b01140ec0323 100644 (file)
@@ -14,7 +14,7 @@
 
                 <div class="text-right">
                     <div class="block inline mr-s">
-                        <form method="get" action="{{ baseUrl("/settings/users") }}">
+                        <form method="get" action="{{ url("/settings/users") }}">
                             @foreach(collect($listDetails)->except('search') as $name => $val)
                                 <input type="hidden" name="{{ $name }}" value="{{ $val }}">
                             @endforeach
@@ -22,7 +22,7 @@
                         </form>
                     </div>
                     @if(userCan('users-manage'))
-                        <a href="{{ baseUrl("/settings/users/create") }}" style="margin-top: 0;" class="outline button">{{ trans('settings.users_add_new') }}</a>
+                        <a href="{{ url("/settings/users/create") }}" style="margin-top: 0;" class="outline button">{{ trans('settings.users_add_new') }}</a>
                     @endif
                 </div>
             </div>
@@ -43,7 +43,7 @@
                         <td class="text-center" style="line-height: 0;"><img class="avatar med" src="{{ $user->getAvatar(40)}}" alt="{{ $user->name }}"></td>
                         <td>
                             @if(userCan('users-manage') || $currentUser->id == $user->id)
-                                <a href="{{ baseUrl("/settings/users/{$user->id}") }}">
+                                <a href="{{ url("/settings/users/{$user->id}") }}">
                                     @endif
                                     {{ $user->name }} <br> <span class="text-muted">{{ $user->email }}</span>
                                     @if(userCan('users-manage') || $currentUser->id == $user->id)
@@ -52,7 +52,7 @@
                         </td>
                         <td>
                             @foreach($user->roles as $index => $role)
-                                <small><a href="{{ baseUrl("/settings/roles/{$role->id}") }}">{{$role->display_name}}</a>@if($index !== count($user->roles) -1),@endif</small>
+                                <small><a href="{{ url("/settings/roles/{$role->id}") }}">{{$role->display_name}}</a>@if($index !== count($user->roles) -1),@endif</small>
                             @endforeach
                         </td>
                     </tr>
index e2689790f185516d5d34408ba21dca05c138f3f0..f817e328f410ae6358314b17dc9903ec23bebfd1 100644 (file)
@@ -60,7 +60,7 @@
                     <h2 id="recent-pages" class="list-heading">
                         {{ trans('entities.recently_created_pages') }}
                         @if (count($recentlyCreated['pages']) > 0)
-                            <a href="{{ baseUrl('/search?term=' . urlencode('{created_by:'.$user->id.'} {type:page}') ) }}" class="text-small ml-s">{{ trans('common.view_all') }}</a>
+                            <a href="{{ url('/search?term=' . urlencode('{created_by:'.$user->id.'} {type:page}') ) }}" class="text-small ml-s">{{ trans('common.view_all') }}</a>
                         @endif
                     </h2>
                     @if (count($recentlyCreated['pages']) > 0)
@@ -74,7 +74,7 @@
                     <h2 id="recent-chapters" class="list-heading">
                         {{ trans('entities.recently_created_chapters') }}
                         @if (count($recentlyCreated['chapters']) > 0)
-                            <a href="{{ baseUrl('/search?term=' . urlencode('{created_by:'.$user->id.'} {type:chapter}') ) }}" class="text-small ml-s">{{ trans('common.view_all') }}</a>
+                            <a href="{{ url('/search?term=' . urlencode('{created_by:'.$user->id.'} {type:chapter}') ) }}" class="text-small ml-s">{{ trans('common.view_all') }}</a>
                         @endif
                     </h2>
                     @if (count($recentlyCreated['chapters']) > 0)
@@ -88,7 +88,7 @@
                     <h2 id="recent-books" class="list-heading">
                         {{ trans('entities.recently_created_books') }}
                         @if (count($recentlyCreated['books']) > 0)
-                            <a href="{{ baseUrl('/search?term=' . urlencode('{created_by:'.$user->id.'} {type:book}') ) }}" class="text-small ml-s">{{ trans('common.view_all') }}</a>
+                            <a href="{{ url('/search?term=' . urlencode('{created_by:'.$user->id.'} {type:book}') ) }}" class="text-small ml-s">{{ trans('common.view_all') }}</a>
                         @endif
                     </h2>
                     @if (count($recentlyCreated['books']) > 0)
                     <h2 id="recent-shelves" class="list-heading">
                         {{ trans('entities.recently_created_shelves') }}
                         @if (count($recentlyCreated['shelves']) > 0)
-                            <a href="{{ baseUrl('/search?term=' . urlencode('{created_by:'.$user->id.'} {type:bookshelf}') ) }}" class="text-small ml-s">{{ trans('common.view_all') }}</a>
+                            <a href="{{ url('/search?term=' . urlencode('{created_by:'.$user->id.'} {type:bookshelf}') ) }}" class="text-small ml-s">{{ trans('common.view_all') }}</a>
                         @endif
                     </h2>
                     @if (count($recentlyCreated['shelves']) > 0)
index 3e02cbba9ceb15e7dacc4cac74b3db58ca02fc57..b8a93643ae0424538c88a60b4b27326c345631e5 100644 (file)
@@ -83,7 +83,7 @@ $style = [
                                 <!-- Logo -->
                                 <tr>
                                     <td style="{{ $style['email-masthead'] }}">
-                                        <a style="{{ $fontFamily }} {{ $style['email-masthead_name'] }}" href="{{ baseUrl('/') }}" target="_blank">
+                                        <a style="{{ $fontFamily }} {{ $style['email-masthead_name'] }}" href="{{ url('/') }}" target="_blank">
                                             {{ setting('app-name') }}
                                         </a>
                                     </td>
@@ -186,7 +186,7 @@ $style = [
                                                 <td style="{{ $fontFamily }} {{ $style['email-footer_cell'] }}">
                                                     <p style="{{ $style['paragraph-sub'] }}">
                                                         &copy; {{ date('Y') }}
-                                                        <a style="{{ $style['anchor'] }}" href="{{ baseUrl('/') }}" target="_blank">{{ setting('app-name') }}</a>.
+                                                        <a style="{{ $style['anchor'] }}" href="{{ url('/') }}" target="_blank">{{ setting('app-name') }}</a>.
                                                         {{ trans('common.email_rights') }}
                                                     </p>
                                                 </td>
index 0399f2b818e809121ea45a4cc5fa0d04087d9d87..3d36d85b2e65d926de8c85b9781579eab2cc4f2c 100644 (file)
@@ -341,7 +341,7 @@ class AuthTest extends BrowserKitTest
         $page = Page::query()->first();
 
         $this->visit($page->getUrl())
-            ->seePageUrlIs(baseUrl('/login'));
+            ->seePageUrlIs(url('/login'));
         $this->login('[email protected]', 'password')
             ->seePageUrlIs($page->getUrl());
     }
diff --git a/tests/Unit/HelpersTest.php b/tests/Unit/HelpersTest.php
deleted file mode 100644 (file)
index c8f4ce2..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-<?php namespace Tests;
-
-class HelpersTest extends TestCase
-{
-
-    public function test_base_url_takes_config_into_account()
-    {
-        config()->set('app.url', 'http://example.com/bookstack');
-        $result = baseUrl('/');
-        $this->assertEquals('http://example.com/bookstack/', $result);
-    }
-
-    public function test_base_url_takes_extra_path_into_account_on_forced_domain()
-    {
-        config()->set('app.url', 'http://example.com/bookstack');
-        $result = baseUrl('http://example.com/bookstack/', true);
-        $this->assertEquals('http://example.com/bookstack/', $result);
-    }
-
-    public function test_base_url_force_domain_works_as_expected_with_full_url_given()
-    {
-        config()->set('app.url', 'http://example.com');
-        $result = baseUrl('http://examps.com/books/test/page/cat', true);
-        $this->assertEquals('http://example.com/books/test/page/cat', $result);
-    }
-
-    public function test_base_url_force_domain_works_when_app_domain_is_same_as_given_url()
-    {
-        config()->set('app.url', 'http://example.com');
-        $result = baseUrl('http://example.com/books/test/page/cat', true);
-        $this->assertEquals('http://example.com/books/test/page/cat', $result);
-    }
-}
\ No newline at end of file
diff --git a/tests/Unit/UrlTest.php b/tests/Unit/UrlTest.php
new file mode 100644 (file)
index 0000000..c7d3331
--- /dev/null
@@ -0,0 +1,25 @@
+<?php namespace Tests;
+
+class UrlTest extends TestCase
+{
+
+    public function test_request_url_takes_custom_url_into_account()
+    {
+        config()->set('app.url', 'http://example.com/bookstack');
+        $this->get('/');
+        $this->assertEquals('http://example.com/bookstack', request()->getUri());
+
+        config()->set('app.url', 'http://example.com/docs/content');
+        $this->get('/');
+        $this->assertEquals('http://example.com/docs/content', request()->getUri());
+    }
+
+    public function test_url_helper_takes_custom_url_into_account()
+    {
+        putenv('APP_URL=http://example.com/bookstack');
+        $this->refreshApplication();
+        $this->assertEquals('http://example.com/bookstack/books', url('/books'));
+        putenv('APP_URL=');
+    }
+
+}
\ No newline at end of file