mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-07-30 04:23:11 +03:00
Added 404 page and extra tests
This commit is contained in:
@ -91,9 +91,12 @@ class BookRepo
|
|||||||
|
|
||||||
public function findSuitableSlug($name, $currentId = false)
|
public function findSuitableSlug($name, $currentId = false)
|
||||||
{
|
{
|
||||||
$slug = Str::slug($name);
|
$originalSlug = Str::slug($name);
|
||||||
|
$slug = $originalSlug;
|
||||||
|
$count = 2;
|
||||||
while($this->doesSlugExist($slug, $currentId)) {
|
while($this->doesSlugExist($slug, $currentId)) {
|
||||||
$slug .= '-' . substr(md5(rand(1, 500)), 0, 3);
|
$slug = $originalSlug . '-' . $count;
|
||||||
|
$count++;
|
||||||
}
|
}
|
||||||
return $slug;
|
return $slug;
|
||||||
}
|
}
|
||||||
|
@ -11,16 +11,18 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-md-4">
|
@if(count($books) > 1)
|
||||||
<h3>Show Other Books</h3>
|
<div class="col-md-4">
|
||||||
@foreach($books as $otherBook)
|
<h3>Show Other Books</h3>
|
||||||
@if($otherBook->id !== $book->id)
|
@foreach($books as $otherBook)
|
||||||
<div id="additional-books">
|
@if($otherBook->id !== $book->id)
|
||||||
<a href="/books/{{ $otherBook->slug }}/sort-item" class="text-book"><i class="zmdi zmdi-book"></i>{{ $otherBook->name }}</a>
|
<div id="additional-books">
|
||||||
</div>
|
<a href="/books/{{ $otherBook->slug }}/sort-item" class="text-book"><i class="zmdi zmdi-book"></i>{{ $otherBook->name }}</a>
|
||||||
@endif
|
</div>
|
||||||
@endforeach
|
@endif
|
||||||
</div>
|
@endforeach
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
9
resources/views/errors/404.blade.php
Normal file
9
resources/views/errors/404.blade.php
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
@extends('public')
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
|
||||||
|
|
||||||
|
<h1>Page Not Found</h1>
|
||||||
|
<p>The page you were looking for could not be found.</p>
|
||||||
|
|
||||||
|
@stop
|
@ -37,7 +37,7 @@
|
|||||||
<div class="links text-center">
|
<div class="links text-center">
|
||||||
@yield('header-buttons')
|
@yield('header-buttons')
|
||||||
</div>
|
</div>
|
||||||
@if($signedIn)
|
@if(isset($signedIn) && $signedIn)
|
||||||
<img class="avatar" src="{{$currentUser->getAvatar(30)}}" alt="{{ $currentUser->name }}">
|
<img class="avatar" src="{{$currentUser->getAvatar(30)}}" alt="{{ $currentUser->name }}">
|
||||||
<div class="dropdown-container" data-dropdown>
|
<div class="dropdown-container" data-dropdown>
|
||||||
<span class="user-name" data-dropdown-toggle>
|
<span class="user-name" data-dropdown-toggle>
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
class EntityTest extends TestCase
|
class EntityTest extends TestCase
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -113,6 +115,12 @@ class EntityTest extends TestCase
|
|||||||
->seePageIs('/books/my-first-book')
|
->seePageIs('/books/my-first-book')
|
||||||
->see($book->name)->see($book->description);
|
->see($book->name)->see($book->description);
|
||||||
|
|
||||||
|
// Ensure duplicate names are given different slugs
|
||||||
|
$this->asAdmin()
|
||||||
|
->visit('/books/create')
|
||||||
|
->submitForm('Save Book', $book->toArray())
|
||||||
|
->seePageIs('/books/my-first-book-2');
|
||||||
|
|
||||||
$book = \BookStack\Book::where('slug', '=', 'my-first-book')->first();
|
$book = \BookStack\Book::where('slug', '=', 'my-first-book')->first();
|
||||||
return $book;
|
return $book;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user