diff --git a/app/Repos/BookRepo.php b/app/Repos/BookRepo.php
index 9d37cf952..aacf96b06 100644
--- a/app/Repos/BookRepo.php
+++ b/app/Repos/BookRepo.php
@@ -91,9 +91,12 @@ class BookRepo
public function findSuitableSlug($name, $currentId = false)
{
- $slug = Str::slug($name);
+ $originalSlug = Str::slug($name);
+ $slug = $originalSlug;
+ $count = 2;
while($this->doesSlugExist($slug, $currentId)) {
- $slug .= '-' . substr(md5(rand(1, 500)), 0, 3);
+ $slug = $originalSlug . '-' . $count;
+ $count++;
}
return $slug;
}
diff --git a/resources/views/books/sort.blade.php b/resources/views/books/sort.blade.php
index f5c847fe2..e4e68d662 100644
--- a/resources/views/books/sort.blade.php
+++ b/resources/views/books/sort.blade.php
@@ -11,16 +11,18 @@
-
-
Show Other Books
- @foreach($books as $otherBook)
- @if($otherBook->id !== $book->id)
-
- @endif
- @endforeach
-
+ @if(count($books) > 1)
+
+
Show Other Books
+ @foreach($books as $otherBook)
+ @if($otherBook->id !== $book->id)
+
+ @endif
+ @endforeach
+
+ @endif
diff --git a/resources/views/errors/404.blade.php b/resources/views/errors/404.blade.php
new file mode 100644
index 000000000..8f66e2d01
--- /dev/null
+++ b/resources/views/errors/404.blade.php
@@ -0,0 +1,9 @@
+@extends('public')
+
+@section('content')
+
+
+ Page Not Found
+ The page you were looking for could not be found.
+
+@stop
\ No newline at end of file
diff --git a/resources/views/public.blade.php b/resources/views/public.blade.php
index f252ce38c..73c8384fc 100644
--- a/resources/views/public.blade.php
+++ b/resources/views/public.blade.php
@@ -37,7 +37,7 @@
@yield('header-buttons')
- @if($signedIn)
+ @if(isset($signedIn) && $signedIn)
diff --git a/tests/EntityTest.php b/tests/EntityTest.php
index ddbed731e..493f99cac 100644
--- a/tests/EntityTest.php
+++ b/tests/EntityTest.php
@@ -1,5 +1,7 @@
seePageIs('/books/my-first-book')
->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();
return $book;
}