Merge branch 'master' into release

This commit is contained in:
Dan Brown 2015-12-01 21:15:08 +00:00
commit 448ac1405b
9 changed files with 97 additions and 37 deletions

@ -110,7 +110,11 @@ class ImageController extends Controller
public function upload(Request $request)
{
$this->checkPermission('image-create');
$this->validate($request, [
'file' => 'image|mimes:jpeg,gif,png'
]);
$imageUpload = $request->file('file');
$name = str_replace(' ', '-', $imageUpload->getClientOriginalName());
$storageName = substr(sha1(time()), 0, 10) . '-' . $name;
$imagePath = '/uploads/images/' . Date('Y-m-M') . '/';

@ -27,6 +27,7 @@ class ViewService
*/
public function add(Entity $entity)
{
if($this->user === null) return 0;
$view = $entity->views()->where('user_id', '=', $this->user->id)->first();
// Add view if model exists
if ($view) {
@ -52,6 +53,7 @@ class ViewService
*/
public function getUserRecentlyViewed($count = 10, $page = 0, $filterModel = false)
{
if($this->user === null) return collect();
$skipCount = $count * $page;
$query = $this->view->where('user_id', '=', auth()->user()->id);

@ -2,35 +2,40 @@
A platform to create documentation/wiki content. General information about BookStack can be found at https://www.bookstackapp.com/
**BookStack is currently in rapid development so use now is heavily cautioned as future updates my break existing installations.**
## Requirements
BookStack has the similar requirements to Laravel. On top of those are some front-end build tools which the requirement of will be removed once out of beta release.
BookStack has the similar requirements to Laravel. On top of those are some front-end build tools which are only required when developing.
* PHP >= 5.5.9
* OpenSSL PHP Extension
* PDO PHP Extension
* Mbstring PHP Extension
* MBstring PHP Extension
* Tokenizer PHP Extension
* MySQL >= 5.6
* Git (Not strictly required but helps manage updates)
* [Composer](https://getcomposer.org/)
* [Node.js](https://nodejs.org/en/) **To be removed in future**
* [Bower](http://bower.io/) **To be removed in future**
* [Gulp](http://gulpjs.com/) **To be removed in future**
* [Node.js](https://nodejs.org/en/) **Development Only**
* [Gulp](http://gulpjs.com/) **Development Only**
## Installation
Ensure the requirements are met before installing.
The installation is currently somewhat complicated. Some PHP/Laravel experience will benefit. This will be streamlined in the future.
This project currently uses the `release` branch of this repository as a stable channel for providing updates.
1. Clone the repository into a folder.
2. `cd` into folder and run `composer install` followed by `npm install` and `bower install`.
3. Run `gulp --production` to compile the JavaScript and css files.
4. Copy the `.env.example` file to `.env` and fill with your own database and mail details.
5. Ensure the `storage` & `bootstrap/cache` folders are writable by the web server.
The installation is currently somewhat complicated. Some PHP/Laravel experience will benefit.
1. Clone the release branch of this repository into a folder.
```
git clone https://github.com/ssddanbrown/BookStack.git --branch release --single-branch
```
2. `cd` into the application folder and run `composer install`.
3. Copy the `.env.example` file to `.env` and fill with your own database and mail details.
4. Ensure the `storage` & `bootstrap/cache` folders are writable by the web server.
5. In the application root, Run `php artisan key:generate` to generate a unique application key.
6. If not using apache or `.htaccess` files are disable you will have to create some URL rewrite rules as shown below.
7. Run `php migrate` to update the database.

@ -110,6 +110,12 @@
dz.removeFile(file);
});
});
this.on('error', function(file, errorMessage, xhr) {
if(errorMessage.file) {
$(file.previewElement).find('[data-dz-errormessage]').text(errorMessage.file[0]);
}
console.log(errorMessage);
});
}
});
},

@ -19,12 +19,16 @@
max-width: 840px;
overflow-wrap: break-word;
.align-left {
float: left !important;
text-align: left;
}
img.align-left, table.align-left {
float: left !important;
margin: $-xs $-s $-xs 0;
}
.align-right {
float: right !important;
}
img.align-right, table.align-right {
text-align: right;
margin: $-xs 0 $-xs $-s;
}

@ -3,7 +3,7 @@
<head>
<title>BookStack</title>
<!-- Meta-->
<!-- Meta -->
<meta name="viewport" content="width=device-width">
<meta name="token" content="{{ csrf_token() }}">
<meta charset="utf-8">
@ -21,17 +21,7 @@
</head>
<body class="@yield('body-class')" id="app">
@if(Session::has('success'))
<div class="notification anim pos">
<i class="zmdi zmdi-mood"></i> <span>{{ Session::get('success') }}</span>
</div>
@endif
@if(Session::has('error'))
<div class="notification anim neg stopped">
<i class="zmdi zmdi-alert-circle"></i> <span>{{ Session::get('error') }}</span>
</div>
@endif
@include('partials/notifications')
<header id="header">
<div class="container">

@ -0,0 +1,11 @@
@if(Session::has('success'))
<div class="notification anim pos">
<i class="zmdi zmdi-mood"></i> <span>{{ Session::get('success') }}</span>
</div>
@endif
@if(Session::has('error'))
<div class="notification anim neg stopped">
<i class="zmdi zmdi-alert-circle"></i> <span>{{ Session::get('error') }}</span>
</div>
@endif

@ -2,27 +2,24 @@
<html>
<head>
<title>BookStack</title>
<!-- Meta -->
<meta name="viewport" content="width=device-width">
<meta charset="utf-8">
<!-- Styles and Fonts -->
<link rel="stylesheet" href="{{ elixir('css/styles.css') }}">
<link rel="stylesheet" media="print" href="{{ elixir('css/print-styles.css') }}">
<link href='//fonts.googleapis.com/css?family=Roboto:400,400italic,500,500italic,700,700italic,300italic,100,300' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="/bower/material-design-iconic-font/dist/css/material-design-iconic-font.min.css">
<link rel="stylesheet" href="/libs/material-design-iconic-font/css/material-design-iconic-font.min.css">
<!-- Scripts -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
</head>
<body class="@yield('body-class')" id="app">
@if(Session::has('success'))
<div class="notification anim pos">
<i class="zmdi zmdi-mood"></i> <span>{{ Session::get('success') }}</span>
</div>
@endif
@if(Session::has('error'))
<div class="notification anim neg stopped">
<i class="zmdi zmdi-alert-circle"></i> <span>{{ Session::get('error') }}</span>
</div>
@endif
@include('partials/notifications')
<header id="header">
<div class="container">

41
tests/PublicViewTest.php Normal file

@ -0,0 +1,41 @@
<?php
class PublicViewTest extends TestCase
{
public function testBooksViewable()
{
$this->setSettings(['app-public' => 'true']);
$books = \BookStack\Book::orderBy('name', 'asc')->take(10)->get();
$bookToVisit = $books[1];
// Check books index page is showing
$this->visit('/books')
->seeStatusCode(200)
->see($books[0]->name)
// Check indavidual book page is showing and it's child contents are visible.
->click($bookToVisit->name)
->seePageIs($bookToVisit->getUrl())
->see($bookToVisit->name)
->see($bookToVisit->chapters()->first()->name);
}
public function testChaptersViewable()
{
$this->setSettings(['app-public' => 'true']);
$chapterToVisit = \BookStack\Chapter::first();
$pageToVisit = $chapterToVisit->pages()->first();
// Check chapters index page is showing
$this->visit($chapterToVisit->getUrl())
->seeStatusCode(200)
->see($chapterToVisit->name)
// Check indavidual chapter page is showing and it's child contents are visible.
->see($pageToVisit->name)
->click($pageToVisit->name)
->see($chapterToVisit->book->name)
->see($chapterToVisit->name)
->seePageIs($pageToVisit->getUrl());
}
}