mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-04-26 05:07:19 +00:00
Added link functionality
This commit is contained in:
parent
46217a5880
commit
787ad20ce7
10 changed files with 84 additions and 19 deletions
app/Http
resources
|
@ -126,6 +126,12 @@ class PageController extends Controller
|
||||||
return redirect($page->getUrl());
|
return redirect($page->getUrl());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function redirectFromLink($pageId)
|
||||||
|
{
|
||||||
|
$page = $this->pageRepo->getById($pageId);
|
||||||
|
return redirect($page->getUrl());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove the specified resource from storage.
|
* Remove the specified resource from storage.
|
||||||
*
|
*
|
||||||
|
|
|
@ -35,6 +35,8 @@ Route::get('/images/all', 'ImageController@getAll');
|
||||||
Route::get('/images/all/{page}', 'ImageController@getAll');
|
Route::get('/images/all/{page}', 'ImageController@getAll');
|
||||||
Route::get('/images/{any}', 'ImageController@getImage')->where('any', '.*');
|
Route::get('/images/{any}', 'ImageController@getImage')->where('any', '.*');
|
||||||
|
|
||||||
|
Route::get('/link/{id}', 'PageController@redirectFromLink');
|
||||||
|
|
||||||
Route::get('/', function () {
|
Route::get('/', function () {
|
||||||
return view('base');
|
return view('base');
|
||||||
});
|
});
|
||||||
|
|
|
@ -29,6 +29,8 @@ h4 {
|
||||||
|
|
||||||
h1, h2, h3, h4 {
|
h1, h2, h3, h4 {
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
|
position: relative;
|
||||||
|
display: block;
|
||||||
.subheader {
|
.subheader {
|
||||||
display: block;
|
display: block;
|
||||||
font-size: 0.5em;
|
font-size: 0.5em;
|
||||||
|
|
|
@ -116,6 +116,8 @@ header .menu {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.overlay {
|
.overlay {
|
||||||
background-color: rgba(0, 0, 0, 0.2);
|
background-color: rgba(0, 0, 0, 0.2);
|
||||||
position: fixed;
|
position: fixed;
|
||||||
|
@ -180,4 +182,21 @@ header .menu {
|
||||||
padding-top: $-xl*1.2;
|
padding-top: $-xl*1.2;
|
||||||
color: #666;
|
color: #666;
|
||||||
border-top: 2px solid $primary;
|
border-top: 2px solid $primary;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Link hooks & popovers
|
||||||
|
a.link-hook {
|
||||||
|
position: absolute;
|
||||||
|
display: inline-block;
|
||||||
|
top: $-xs;
|
||||||
|
left: -$-xl+2px;
|
||||||
|
font-size: 20px;
|
||||||
|
line-height: 20px;
|
||||||
|
color: #BBB;
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
h1, h2, h3, h4, h5, h6 {
|
||||||
|
&:hover a.link-hook {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -10,6 +10,7 @@
|
||||||
<script src="/bower/bootstrap/dist/js/bootstrap.js"></script>
|
<script src="/bower/bootstrap/dist/js/bootstrap.js"></script>
|
||||||
<script>
|
<script>
|
||||||
$.fn.smoothScrollTo = function() {
|
$.fn.smoothScrollTo = function() {
|
||||||
|
if(this.length === 0) return;
|
||||||
$('body').animate({
|
$('body').animate({
|
||||||
scrollTop: this.offset().top - 60 // Adjust to change final scroll position top margin
|
scrollTop: this.offset().top - 60 // Adjust to change final scroll position top margin
|
||||||
}, 800); // Adjust to change animations speed (ms)
|
}, 800); // Adjust to change animations speed (ms)
|
||||||
|
@ -35,5 +36,6 @@
|
||||||
@yield('content')
|
@yield('content')
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
@yield('bottom')
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -16,4 +16,8 @@
|
||||||
$('#html').editable({inlineMode: false});
|
$('#html').editable({inlineMode: false});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
@stop
|
||||||
|
|
||||||
|
@section('bottom')
|
||||||
|
@include('pages/image-manager')
|
||||||
@stop
|
@stop
|
|
@ -15,4 +15,8 @@
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@stop
|
||||||
|
|
||||||
|
@section('bottom')
|
||||||
|
@include('pages/image-manager')
|
||||||
@stop
|
@stop
|
|
@ -18,25 +18,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<section class="overlay" style="display:none;">
|
|
||||||
<div id="image-manager">
|
|
||||||
<div class="image-manager-left">
|
|
||||||
<div class="image-manager-header">
|
|
||||||
<button type="button" class="button neg float right" data-action="close">Close</button>
|
|
||||||
<div class="image-manager-title">Image Library</div>
|
|
||||||
</div>
|
|
||||||
<div class="image-manager-display">
|
|
||||||
</div>
|
|
||||||
<form action="/upload/image" class="image-manager-dropzone">
|
|
||||||
{{ csrf_field() }}
|
|
||||||
Drag images or click here to upload
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
{{--<div class="sidebar">--}}
|
|
||||||
|
|
||||||
{{--</div>--}}
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
$(function() {
|
$(function() {
|
||||||
|
@ -49,7 +31,7 @@
|
||||||
relative_urls: false,
|
relative_urls: false,
|
||||||
height: 600,
|
height: 600,
|
||||||
plugins: "image table textcolor paste link imagetools",
|
plugins: "image table textcolor paste link imagetools",
|
||||||
toolbar: "undo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | table | fontsizeselect full",
|
toolbar: "undo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | table image link | fontsizeselect full",
|
||||||
content_style: "body {padding-left: 15px !important; padding-right: 15px !important; margin:0!important}",
|
content_style: "body {padding-left: 15px !important; padding-right: 15px !important; margin:0!important}",
|
||||||
file_browser_callback: function(field_name, url, type, win) {
|
file_browser_callback: function(field_name, url, type, win) {
|
||||||
ImageManager.show('#image-manager', function(image) {
|
ImageManager.show('#image-manager', function(image) {
|
||||||
|
|
19
resources/views/pages/image-manager.blade.php
Normal file
19
resources/views/pages/image-manager.blade.php
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
<section class="overlay" style="display:none;">
|
||||||
|
<div id="image-manager">
|
||||||
|
<div class="image-manager-left">
|
||||||
|
<div class="image-manager-header">
|
||||||
|
<button type="button" class="button neg float right" data-action="close">Close</button>
|
||||||
|
<div class="image-manager-title">Image Library</div>
|
||||||
|
</div>
|
||||||
|
<div class="image-manager-display">
|
||||||
|
</div>
|
||||||
|
<form action="/upload/image" class="image-manager-dropzone">
|
||||||
|
{{ csrf_field() }}
|
||||||
|
Drag images or click here to upload
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
{{--<div class="sidebar">--}}
|
||||||
|
|
||||||
|
{{--</div>--}}
|
||||||
|
</div>
|
||||||
|
</section>
|
|
@ -50,6 +50,31 @@
|
||||||
header.smoothScrollTo();
|
header.smoothScrollTo();
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Set up link hooks
|
||||||
|
var pageId = {{$page->id}};
|
||||||
|
headers.each(function() {
|
||||||
|
var text = $(this).text().trim();
|
||||||
|
var link = '/link/' + pageId + '#' + encodeURIComponent(text);
|
||||||
|
var linkHook = $('<a class="link-hook"><i class="fa fa-link"></i></a>')
|
||||||
|
.attr({"data-content": link, href: link, target: '_blank'});
|
||||||
|
linkHook.click(function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
goToText(text);
|
||||||
|
});
|
||||||
|
$(this).append(linkHook);
|
||||||
|
});
|
||||||
|
|
||||||
|
function goToText(text) {
|
||||||
|
$('.page-content').find(':contains("'+text+'")').smoothScrollTo();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(window.location.hash) {
|
||||||
|
var text = window.location.hash.replace(/\%20/g, ' ').substr(1);
|
||||||
|
goToText(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
//$('[data-toggle="popover"]').popover()
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
@stop
|
@stop
|
||||||
|
|
Loading…
Add table
Reference in a new issue