]> BookStack Code Mirror - bookstack/blob - resources/views/pages/show.blade.php
Vastly improved design and cleaned text input
[bookstack] / resources / views / pages / show.blade.php
1 @extends('base')
2
3 @section('sidebar')
4     <div class="book-tree">
5         <h4><a href="/books/{{$sidebarBookTree['slug']}}"><i class="fa fa-book"></i>{{$sidebarBookTree['name']}}</a></h4>
6         @if($sidebarBookTree['hasChildren'])
7             @include('pages/sidebar-tree-list', ['pageTree' => $sidebarBookTree['pages']])
8         @endif
9     </div>
10 @stop
11
12 @section('content')
13
14     <div class="row faded-small">
15         <div class="col-md-6 faded">
16             <div class="breadcrumbs padded-horizontal">
17                 <a href="{{$book->getUrl()}}"><i class="fa fa-book"></i>{{ $book->name }}</a>
18                 @if($breadCrumbs)
19                     @foreach($breadCrumbs as $parentPage)
20                         <span class="sep">&gt;</span>
21                         <a href="{{$parentPage->getUrl()}}">{{ $parentPage->name }}</a>
22                     @endforeach
23                 @endif
24             </div>
25         </div>
26         <div class="col-md-6 faded">
27             <div class="action-buttons">
28                 <a href="{{$page->getUrl() . '/edit'}}" ><i class="fa fa-pencil"></i>Edit this page</a>
29                 <a href="{{$page->getUrl() . '/create'}}"><i class="fa fa-file-o"></i>Create Sub-page</a>
30             </div>
31         </div>
32     </div>
33
34     <div class="side-nav faded">
35         <h4>Page Navigation</h4>
36         <ul class="page-nav-list">
37         </ul>
38     </div>
39
40
41     <div class="page-content">
42         <h1>{{$page->name}}</h1>
43         @if(count($page->children) > 0)
44             <h4 class="text-muted">Sub-pages</h4>
45             <div class="page-list">
46                 @foreach($page->children as $childPage)
47                     <a href="{{ $childPage->getUrl() }}">{{ $childPage->name }}</a>
48                 @endforeach
49             </div>
50         @endif
51         {!! $page->html !!}
52     </div>
53
54
55     <script>
56         $(document).ready(function() {
57
58             // Set up document navigation
59             var pageNav = $('.page-nav-list');
60             var pageContent = $('.page-content');
61             var headers = pageContent.find('h1, h2, h3, h4, h5, h6');
62             headers.each(function() {
63                 var header = $(this);
64                 var tag = header.prop('tagName');
65                 var listElem = $('<li></li>').addClass('nav-'+tag);
66                 var link = $('<a></a>').text(header.text().trim()).attr('href', '#');
67                 listElem.append(link);
68                 pageNav.append(listElem);
69                 link.click(function(e) {
70                     e.preventDefault();
71                     header.smoothScrollTo();
72                 })
73             });
74
75             // Set up link hooks
76             var pageId = {{$page->id}};
77             headers.each(function() {
78                 var text = $(this).text().trim();
79                 var link = '/link/' + pageId + '#' + encodeURIComponent(text);
80                 var linkHook = $('<a class="link-hook"><i class="fa fa-link"></i></a>')
81                         .attr({"data-content": link, href: link, target: '_blank'});
82                 linkHook.click(function(e) {
83                     e.preventDefault();
84                     goToText(text);
85                 });
86                 $(this).append(linkHook);
87             });
88
89             function goToText(text) {
90                 $('.page-content').find(':contains("'+text+'")').smoothScrollTo();
91             }
92
93             if(window.location.hash) {
94                 var text = window.location.hash.replace(/\%20/g, ' ').substr(1);
95                 goToText(text);
96             }
97
98             //$('[data-toggle="popover"]').popover()
99         });
100     </script>
101 @stop