Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Зуев Егор
/
wiki.dev
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Authored by
Dan Brown
2015-09-29 21:25:03 +0100
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Commit
144eb69cad245734610e0efb6341b0bade78cacc
144eb69c
1 parent
fd3929e8
Added 404 page and extra tests
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
35 additions
and
13 deletions
app/Repos/BookRepo.php
resources/views/books/sort.blade.php
resources/views/errors/404.blade.php
resources/views/public.blade.php
tests/EntityTest.php
app/Repos/BookRepo.php
View file @
144eb69
...
...
@@ -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
;
}
...
...
resources/views/books/sort.blade.php
View file @
144eb69
...
...
@@ -11,16 +11,18 @@
</div>
<div
class=
"col-md-4"
>
<h3>
Show Other Books
</h3>
@foreach($books as $otherBook)
@if($otherBook->id !== $book->id)
<div
id=
"additional-books"
>
<a
href=
"/books/{{ $otherBook->slug }}/sort-item"
class=
"text-book"
><i
class=
"zmdi zmdi-book"
></i>
{{ $otherBook->name }}
</a>
</div>
@endif
@endforeach
</div>
@if(count($books) > 1)
<div
class=
"col-md-4"
>
<h3>
Show Other Books
</h3>
@foreach($books as $otherBook)
@if($otherBook->id !== $book->id)
<div
id=
"additional-books"
>
<a
href=
"/books/{{ $otherBook->slug }}/sort-item"
class=
"text-book"
><i
class=
"zmdi zmdi-book"
></i>
{{ $otherBook->name }}
</a>
</div>
@endif
@endforeach
</div>
@endif
</div>
...
...
resources/views/errors/404.blade.php
0 → 100644
View file @
144eb69
@extends('public')
@section('content')
<h1>
Page Not Found
</h1>
<p>
The page you were looking for could not be found.
</p>
@stop
\ No newline at end of file
resources/views/public.blade.php
View file @
144eb69
...
...
@@ -37,7 +37,7 @@
<div
class=
"links text-center"
>
@yield('header-buttons')
</div>
@if($signedIn)
@if(
isset($signedIn)
&&
$signedIn)
<img
class=
"avatar"
src=
"{{$currentUser->getAvatar(30)}}"
alt=
"{{ $currentUser->name }}"
>
<div
class=
"dropdown-container"
data-dropdown
>
<span
class=
"user-name"
data-dropdown-toggle
>
...
...
tests/EntityTest.php
View file @
144eb69
<?php
use
Illuminate\Support\Facades\DB
;
class
EntityTest
extends
TestCase
{
...
...
@@ -113,6 +115,12 @@ class EntityTest extends TestCase
->
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
;
}
...
...
Please
register
or
sign in
to post a comment