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-12-05 14:41:51 +0000
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Commit
c32d70abc4f3cca4a8b3533d45b09d2a830d6a57
c32d70ab
1 parent
f1c2866f
Added custom meta titles to many pages. Closes #30.
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
56 additions
and
11 deletions
app/Entity.php
app/Http/Controllers/BookController.php
app/Http/Controllers/ChapterController.php
app/Http/Controllers/Controller.php
app/Http/Controllers/PageController.php
app/Http/Controllers/SearchController.php
app/Http/Controllers/SettingController.php
app/Http/Controllers/UserController.php
app/Page.php
resources/views/base.blade.php
resources/views/books/sort-box.blade.php
resources/views/pages/show.blade.php
resources/views/pages/sidebar-tree-list.blade.php
app/Entity.php
View file @
c32d70a
...
...
@@ -97,19 +97,30 @@ abstract class Entity extends Model
*/
public
static
function
isA
(
$type
)
{
return
static
::
getName
()
===
strtolower
(
$type
);
return
static
::
get
Class
Name
()
===
strtolower
(
$type
);
}
/**
* Gets the class name.
* @return string
*/
public
static
function
getName
()
public
static
function
get
Class
Name
()
{
return
strtolower
(
array_slice
(
explode
(
'\\'
,
static
::
class
),
-
1
,
1
)[
0
]);
}
/**
*Gets a limited-length version of the entities name.
* @param int $length
* @return string
*/
public
function
getShortName
(
$length
=
25
)
{
if
(
strlen
(
$this
->
name
)
<=
$length
)
return
$this
->
name
;
return
substr
(
$this
->
name
,
0
,
$length
-
3
)
.
'...'
;
}
/**
* Perform a full-text search on this entity.
* @param string[] $fieldsToSearch
* @param string[] $terms
...
...
app/Http/Controllers/BookController.php
View file @
c32d70a
...
...
@@ -44,6 +44,7 @@ class BookController extends Controller
$books
=
$this
->
bookRepo
->
getAllPaginated
(
10
);
$recents
=
$this
->
signedIn
?
$this
->
bookRepo
->
getRecentlyViewed
(
4
,
0
)
:
false
;
$popular
=
$this
->
bookRepo
->
getPopular
(
4
,
0
);
$this
->
setPageTitle
(
'Books'
);
return
view
(
'books/index'
,
[
'books'
=>
$books
,
'recents'
=>
$recents
,
'popular'
=>
$popular
]);
}
...
...
@@ -55,6 +56,7 @@ class BookController extends Controller
public
function
create
()
{
$this
->
checkPermission
(
'book-create'
);
$this
->
setPageTitle
(
'Create New Book'
);
return
view
(
'books/create'
);
}
...
...
@@ -89,8 +91,9 @@ class BookController extends Controller
public
function
show
(
$slug
)
{
$book
=
$this
->
bookRepo
->
getBySlug
(
$slug
);
Views
::
add
(
$book
);
$bookChildren
=
$this
->
bookRepo
->
getChildren
(
$book
);
Views
::
add
(
$book
);
$this
->
setPageTitle
(
$book
->
getShortName
());
return
view
(
'books/show'
,
[
'book'
=>
$book
,
'current'
=>
$book
,
'bookChildren'
=>
$bookChildren
]);
}
...
...
@@ -104,6 +107,7 @@ class BookController extends Controller
{
$this
->
checkPermission
(
'book-update'
);
$book
=
$this
->
bookRepo
->
getBySlug
(
$slug
);
$this
->
setPageTitle
(
'Edit Book '
.
$book
->
getShortName
());
return
view
(
'books/edit'
,
[
'book'
=>
$book
,
'current'
=>
$book
]);
}
...
...
@@ -139,6 +143,7 @@ class BookController extends Controller
{
$this
->
checkPermission
(
'book-delete'
);
$book
=
$this
->
bookRepo
->
getBySlug
(
$bookSlug
);
$this
->
setPageTitle
(
'Delete Book '
.
$book
->
getShortName
());
return
view
(
'books/delete'
,
[
'book'
=>
$book
,
'current'
=>
$book
]);
}
...
...
@@ -153,9 +158,16 @@ class BookController extends Controller
$book
=
$this
->
bookRepo
->
getBySlug
(
$bookSlug
);
$bookChildren
=
$this
->
bookRepo
->
getChildren
(
$book
);
$books
=
$this
->
bookRepo
->
getAll
();
$this
->
setPageTitle
(
'Sort Book '
.
$book
->
getShortName
());
return
view
(
'books/sort'
,
[
'book'
=>
$book
,
'current'
=>
$book
,
'books'
=>
$books
,
'bookChildren'
=>
$bookChildren
]);
}
/**
* Shows the sort box for a single book.
* Used via AJAX when loading in extra books to a sort.
* @param $bookSlug
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public
function
getSortItem
(
$bookSlug
)
{
$book
=
$this
->
bookRepo
->
getBySlug
(
$bookSlug
);
...
...
app/Http/Controllers/ChapterController.php
View file @
c32d70a
...
...
@@ -40,6 +40,7 @@ class ChapterController extends Controller
{
$this
->
checkPermission
(
'chapter-create'
);
$book
=
$this
->
bookRepo
->
getBySlug
(
$bookSlug
);
$this
->
setPageTitle
(
'Create New Chapter'
);
return
view
(
'chapters/create'
,
[
'book'
=>
$book
,
'current'
=>
$book
]);
}
...
...
@@ -79,6 +80,7 @@ class ChapterController extends Controller
$chapter
=
$this
->
chapterRepo
->
getBySlug
(
$chapterSlug
,
$book
->
id
);
$sidebarTree
=
$this
->
bookRepo
->
getChildren
(
$book
);
Views
::
add
(
$chapter
);
$this
->
setPageTitle
(
$chapter
->
getShortName
());
return
view
(
'chapters/show'
,
[
'book'
=>
$book
,
'chapter'
=>
$chapter
,
'current'
=>
$chapter
,
'sidebarTree'
=>
$sidebarTree
]);
}
...
...
@@ -93,6 +95,7 @@ class ChapterController extends Controller
$this
->
checkPermission
(
'chapter-update'
);
$book
=
$this
->
bookRepo
->
getBySlug
(
$bookSlug
);
$chapter
=
$this
->
chapterRepo
->
getBySlug
(
$chapterSlug
,
$book
->
id
);
$this
->
setPageTitle
(
'Edit Chapter'
.
$chapter
->
getShortName
());
return
view
(
'chapters/edit'
,
[
'book'
=>
$book
,
'chapter'
=>
$chapter
,
'current'
=>
$chapter
]);
}
...
...
@@ -127,6 +130,7 @@ class ChapterController extends Controller
$this
->
checkPermission
(
'chapter-delete'
);
$book
=
$this
->
bookRepo
->
getBySlug
(
$bookSlug
);
$chapter
=
$this
->
chapterRepo
->
getBySlug
(
$chapterSlug
,
$book
->
id
);
$this
->
setPageTitle
(
'Delete Chapter'
.
$chapter
->
getShortName
());
return
view
(
'chapters/delete'
,
[
'book'
=>
$book
,
'chapter'
=>
$chapter
,
'current'
=>
$chapter
]);
}
...
...
app/Http/Controllers/Controller.php
View file @
c32d70a
...
...
@@ -43,6 +43,15 @@ abstract class Controller extends BaseController
}
/**
* Adds the page title into the view.
* @param $title
*/
public
function
setPageTitle
(
$title
)
{
view
()
->
share
(
'pageTitle'
,
$title
);
}
/**
* Checks for a permission.
*
* @param $permissionName
...
...
app/Http/Controllers/PageController.php
View file @
c32d70a
...
...
@@ -46,6 +46,7 @@ class PageController extends Controller
$this
->
checkPermission
(
'page-create'
);
$book
=
$this
->
bookRepo
->
getBySlug
(
$bookSlug
);
$chapter
=
$chapterSlug
?
$this
->
chapterRepo
->
getBySlug
(
$chapterSlug
,
$book
->
id
)
:
false
;
$this
->
setPageTitle
(
'Create New Page'
);
return
view
(
'pages/create'
,
[
'book'
=>
$book
,
'chapter'
=>
$chapter
]);
}
...
...
@@ -89,6 +90,7 @@ class PageController extends Controller
$page
=
$this
->
pageRepo
->
getBySlug
(
$pageSlug
,
$book
->
id
);
$sidebarTree
=
$this
->
bookRepo
->
getChildren
(
$book
);
Views
::
add
(
$page
);
$this
->
setPageTitle
(
$page
->
getShortName
());
return
view
(
'pages/show'
,
[
'page'
=>
$page
,
'book'
=>
$book
,
'current'
=>
$page
,
'sidebarTree'
=>
$sidebarTree
]);
}
...
...
@@ -104,6 +106,7 @@ class PageController extends Controller
$this
->
checkPermission
(
'page-update'
);
$book
=
$this
->
bookRepo
->
getBySlug
(
$bookSlug
);
$page
=
$this
->
pageRepo
->
getBySlug
(
$pageSlug
,
$book
->
id
);
$this
->
setPageTitle
(
'Editing Page '
.
$page
->
getShortName
());
return
view
(
'pages/edit'
,
[
'page'
=>
$page
,
'book'
=>
$book
,
'current'
=>
$page
]);
}
...
...
@@ -148,6 +151,7 @@ class PageController extends Controller
$this
->
checkPermission
(
'page-delete'
);
$book
=
$this
->
bookRepo
->
getBySlug
(
$bookSlug
);
$page
=
$this
->
pageRepo
->
getBySlug
(
$pageSlug
,
$book
->
id
);
$this
->
setPageTitle
(
'Delete Page '
.
$page
->
getShortName
());
return
view
(
'pages/delete'
,
[
'book'
=>
$book
,
'page'
=>
$page
,
'current'
=>
$page
]);
}
...
...
@@ -179,6 +183,7 @@ class PageController extends Controller
{
$book
=
$this
->
bookRepo
->
getBySlug
(
$bookSlug
);
$page
=
$this
->
pageRepo
->
getBySlug
(
$pageSlug
,
$book
->
id
);
$this
->
setPageTitle
(
'Revisions For '
.
$page
->
getShortName
());
return
view
(
'pages/revisions'
,
[
'page'
=>
$page
,
'book'
=>
$book
,
'current'
=>
$page
]);
}
...
...
@@ -195,6 +200,7 @@ class PageController extends Controller
$page
=
$this
->
pageRepo
->
getBySlug
(
$pageSlug
,
$book
->
id
);
$revision
=
$this
->
pageRepo
->
getRevisionById
(
$revisionId
);
$page
->
fill
(
$revision
->
toArray
());
$this
->
setPageTitle
(
'Page Revision For '
.
$page
->
getShortName
());
return
view
(
'pages/revision'
,
[
'page'
=>
$page
,
'book'
=>
$book
]);
}
...
...
app/Http/Controllers/SearchController.php
View file @
c32d70a
...
...
@@ -45,6 +45,7 @@ class SearchController extends Controller
$pages
=
$this
->
pageRepo
->
getBySearch
(
$searchTerm
);
$books
=
$this
->
bookRepo
->
getBySearch
(
$searchTerm
);
$chapters
=
$this
->
chapterRepo
->
getBySearch
(
$searchTerm
);
$this
->
setPageTitle
(
'Search For '
.
$searchTerm
);
return
view
(
'search/all'
,
[
'pages'
=>
$pages
,
'books'
=>
$books
,
'chapters'
=>
$chapters
,
'searchTerm'
=>
$searchTerm
]);
}
...
...
app/Http/Controllers/SettingController.php
View file @
c32d70a
...
...
@@ -18,6 +18,7 @@ class SettingController extends Controller
public
function
index
()
{
$this
->
checkPermission
(
'settings-update'
);
$this
->
setPageTitle
(
'Settings'
);
return
view
(
'settings/index'
);
}
...
...
app/Http/Controllers/UserController.php
View file @
c32d70a
...
...
@@ -35,6 +35,7 @@ class UserController extends Controller
public
function
index
()
{
$users
=
$this
->
user
->
all
();
$this
->
setPageTitle
(
'Users'
);
return
view
(
'users/index'
,
[
'users'
=>
$users
]);
}
...
...
@@ -90,6 +91,7 @@ class UserController extends Controller
$user
=
$this
->
user
->
findOrFail
(
$id
);
$activeSocialDrivers
=
$socialAuthService
->
getActiveDrivers
();
$this
->
setPageTitle
(
'User Profile'
);
return
view
(
'users/edit'
,
[
'user'
=>
$user
,
'activeSocialDrivers'
=>
$activeSocialDrivers
]);
}
...
...
@@ -139,6 +141,7 @@ class UserController extends Controller
return
$this
->
currentUser
->
id
==
$id
;
});
$user
=
$this
->
user
->
findOrFail
(
$id
);
$this
->
setPageTitle
(
'Delete User '
.
$user
->
name
);
return
view
(
'users/delete'
,
[
'user'
=>
$user
]);
}
...
...
app/Page.php
View file @
c32d70a
...
...
@@ -32,7 +32,6 @@ class Page extends Entity
return
$this
->
chapter
()
->
count
()
>
0
;
}
public
function
revisions
()
{
return
$this
->
hasMany
(
'BookStack\PageRevision'
)
->
orderBy
(
'created_at'
,
'desc'
);
...
...
@@ -40,7 +39,6 @@ class Page extends Entity
public
function
getUrl
()
{
// TODO - Extract this and share with chapters
$bookSlug
=
$this
->
getAttribute
(
'bookSlug'
)
?
$this
->
getAttribute
(
'bookSlug'
)
:
$this
->
book
->
slug
;
return
'/books/'
.
$bookSlug
.
'/page/'
.
$this
->
slug
;
}
...
...
resources/views/base.blade.php
View file @
c32d70a
<!DOCTYPE html>
<html>
<head>
<title>
BookStack
</title>
<title>
{{ isset($pageTitle) ? $pageTitle . ' | ' : '' }}{{ Setting::get('app-name', 'BookStack') }}
</title>
<!-- Meta -->
<meta
name=
"viewport"
content=
"width=device-width"
>
...
...
resources/views/books/sort-box.blade.php
View file @
c32d70a
...
...
@@ -2,7 +2,7 @@
<h3
class=
"text-book"
><i
class=
"zmdi zmdi-book"
></i>
{{ $book->name }}
</h3>
<ul
class=
"sortable-page-list sort-list"
>
@foreach($bookChildren as $bookChild)
<li
data-id=
"{{$bookChild->id}}"
data-type=
"{{ $bookChild->get
Name() }}"
class=
"text-{{ $bookChild->get
Name() }}"
>
<li
data-id=
"{{$bookChild->id}}"
data-type=
"{{ $bookChild->get
ClassName() }}"
class=
"text-{{ $bookChild->getClass
Name() }}"
>
<i
class=
"zmdi {{ $bookChild->isA('chapter') ? 'zmdi-collection-bookmark':'zmdi-file-text'}}"
></i>
{{ $bookChild->name }}
@if($bookChild->isA('chapter'))
<ul>
...
...
resources/views/pages/show.blade.php
View file @
c32d70a
...
...
@@ -7,12 +7,12 @@
<div
class=
"row"
>
<div
class=
"col-sm-6 faded"
>
<div
class=
"breadcrumbs"
>
<a
href=
"{{$book->getUrl()}}"
class=
"text-book text-button"
><i
class=
"zmdi zmdi-book"
></i>
{{ $book->
name
}}
</a>
<a
href=
"{{$book->getUrl()}}"
class=
"text-book text-button"
><i
class=
"zmdi zmdi-book"
></i>
{{ $book->
getShortName()
}}
</a>
@if($page->hasChapter())
<span
class=
"sep"
>
»
</span>
<a
href=
"{{ $page->chapter->getUrl() }}"
class=
"text-chapter text-button"
>
<i
class=
"zmdi zmdi-collection-bookmark"
></i>
{{$page->chapter->
name
}}
{{$page->chapter->
getShortName()
}}
</a>
@endif
</div>
...
...
resources/views/pages/sidebar-tree-list.blade.php
View file @
c32d70a
...
...
@@ -6,8 +6,8 @@
@foreach($sidebarTree as $bookChild)
<li
class=
"list-item-{{ $bookChild->get
Name() }} {{ $bookChild->get
Name() }}"
>
<a
href=
"{{$bookChild->getUrl()}}"
class=
"{{ $bookChild->getName() }} {{ $current->matches($bookChild)? 'selected' : '' }}"
>
<li
class=
"list-item-{{ $bookChild->get
ClassName() }} {{ $bookChild->getClass
Name() }}"
>
<a
href=
"{{$bookChild->getUrl()}}"
class=
"{{ $bookChild->get
Class
Name() }} {{ $current->matches($bookChild)? 'selected' : '' }}"
>
@if($bookChild->isA('chapter'))
<i
class=
"zmdi zmdi-collection-bookmark"
></i>
@else
<i
class=
"zmdi zmdi-file-text"
></i>
@endif{{ $bookChild->name }}
</a>
...
...
Please
register
or
sign in
to post a comment