Skip to content

Commit

Permalink
Merge branch 'master' of git://github.com/BookStackApp/BookStack into…
Browse files Browse the repository at this point in the history
… BookStackApp-master

Conflicts:
	app/Http/Controllers/BookController.php
	resources/lang/en/common.php
	resources/views/books/create.blade.php
	resources/views/books/form.blade.php
	resources/views/books/index.blade.php
	resources/views/users/edit.blade.php
	tests/Entity/EntityTest.php
  • Loading branch information
Bharadwaja G committed Aug 29, 2017
2 parents 7f902e4 + 0a402e3 commit 6200948
Show file tree
Hide file tree
Showing 99 changed files with 2,552 additions and 1,976 deletions.
1 change: 0 additions & 1 deletion app/Http/Controllers/Auth/RegisterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,6 @@ public function resendConfirmation(Request $request)
return redirect('/register/confirm');
}

$this->emailConfirmationService->sendConfirmation($user);
session()->flash('success', trans('auth.email_confirm_resent'));
return redirect('/register/confirm');
}
Expand Down
20 changes: 15 additions & 5 deletions app/Http/Controllers/BookController.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,17 @@ public function __construct(EntityRepo $entityRepo, UserRepo $userRepo, ExportSe
*/
public function index()
{
$books = $this->entityRepo->getAllPaginated('book', 16);
$books = $this->entityRepo->getAllPaginated('book', 20);
$recents = $this->signedIn ? $this->entityRepo->getRecentlyViewed('book', 4, 0) : false;
$popular = $this->entityRepo->getPopular('book', 3, 0);
$books_display = $this->currentUser->books_display;
$popular = $this->entityRepo->getPopular('book', 4, 0);
$new = $this->entityRepo->getRecentlyCreated('book', 4, 0);
$this->setPageTitle('Books');
return view('books/index', ['books' => $books, 'recents' => $recents, 'popular' => $popular, 'books_display' => $books_display] );
return view('books/index', [
'books' => $books,
'recents' => $recents,
'popular' => $popular,
'new' => $new
]);
}

/**
Expand Down Expand Up @@ -85,7 +90,12 @@ public function show($slug)
$bookChildren = $this->entityRepo->getBookChildren($book);
Views::add($book);
$this->setPageTitle($book->getShortName());
return view('books/show', ['book' => $book, 'current' => $book, 'bookChildren' => $bookChildren]);
return view('books/show', [
'book' => $book,
'current' => $book,
'bookChildren' => $bookChildren,
'activity' => Activity::entityActivity($book, 20, 0)
]);
}

/**
Expand Down
22 changes: 16 additions & 6 deletions app/Http/Controllers/HomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,25 @@ public function index()
$activity = Activity::latest(10);
$draftPages = $this->signedIn ? $this->entityRepo->getUserDraftPages(6) : [];
$recentFactor = count($draftPages) > 0 ? 0.5 : 1;
$recents = $this->signedIn ? Views::getUserRecentlyViewed(12*$recentFactor, 0) : $this->entityRepo->getRecentlyCreated('book', 10*$recentFactor);
$recentlyCreatedPages = $this->entityRepo->getRecentlyCreated('page', 5);
$recentlyUpdatedPages = $this->entityRepo->getRecentlyUpdated('page', 5);
return view('home', [
$recents = $this->signedIn ? Views::getUserRecentlyViewed(12*$recentFactor, 0) : $this->entityRepo->getRecentlyCreated('book', 12*$recentFactor);
$recentlyUpdatedPages = $this->entityRepo->getRecentlyUpdated('page', 12);

// Custom homepage
$customHomepage = false;
$homepageSetting = setting('app-homepage');
if ($homepageSetting) {
$id = intval(explode(':', $homepageSetting)[0]);
$customHomepage = $this->entityRepo->getById('page', $id, false, true);
$this->entityRepo->renderPage($customHomepage, true);
}

$view = $customHomepage ? 'home-custom' : 'home';
return view($view, [
'activity' => $activity,
'recents' => $recents,
'recentlyCreatedPages' => $recentlyCreatedPages,
'recentlyUpdatedPages' => $recentlyUpdatedPages,
'draftPages' => $draftPages
'draftPages' => $draftPages,
'customHomepage' => $customHomepage
]);
}

Expand Down
4 changes: 3 additions & 1 deletion app/Http/Controllers/PageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public function show($bookSlug, $pageSlug)
return view('pages/show', [
'page' => $page,'book' => $page->book,
'current' => $page, 'sidebarTree' => $sidebarTree,
'pageNav' => $pageNav, 'pageContent' => $pageContent]);
'pageNav' => $pageNav]);
}

/**
Expand Down Expand Up @@ -380,6 +380,7 @@ public function showRevision($bookSlug, $pageSlug, $revisionId)
return view('pages/revision', [
'page' => $page,
'book' => $page->book,
'revision' => $revision
]);
}

Expand Down Expand Up @@ -409,6 +410,7 @@ public function showRevisionChanges($bookSlug, $pageSlug, $revisionId)
'page' => $page,
'book' => $page->book,
'diff' => $diff,
'revision' => $revision
]);
}

Expand Down
12 changes: 12 additions & 0 deletions app/PageRevision.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,16 @@ public function getPrevious()
return null;
}

/**
* Allows checking of the exact class, Used to check entity type.
* Included here to align with entities in similar use cases.
* (Yup, Bit of an awkward hack)
* @param $type
* @return bool
*/
public static function isA($type)
{
return $type === 'revision';
}

}
13 changes: 10 additions & 3 deletions app/Repos/EntityRepo.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,15 @@ public function exists($type, $id)
* @param string $type
* @param integer $id
* @param bool $allowDrafts
* @param bool $ignorePermissions
* @return Entity
*/
public function getById($type, $id, $allowDrafts = false)
public function getById($type, $id, $allowDrafts = false, $ignorePermissions = false)
{
if ($ignorePermissions) {
$entity = $this->getEntity($type);
return $entity->newQuery()->find($id);
}
return $this->entityQuery($type, $allowDrafts)->find($id);
}

Expand Down Expand Up @@ -671,9 +676,10 @@ protected function formatHtml($htmlText)
/**
* Render the page for viewing, Parsing and performing features such as page transclusion.
* @param Page $page
* @param bool $ignorePermissions
* @return mixed|string
*/
public function renderPage(Page $page)
public function renderPage(Page $page, $ignorePermissions = false)
{
$content = $page->html;
$matches = [];
Expand All @@ -685,7 +691,7 @@ public function renderPage(Page $page)
$pageId = intval($splitInclude[0]);
if (is_nan($pageId)) continue;

$page = $this->getById('page', $pageId);
$page = $this->getById('page', $pageId, false, $ignorePermissions);
if ($page === null) {
$content = str_replace($matches[0][$index], '', $content);
continue;
Expand All @@ -710,6 +716,7 @@ public function renderPage(Page $page)
$content = str_replace($matches[0][$index], trim($innerContent), $content);
}

$page->renderedHTML = $content;
return $content;
}

Expand Down
8 changes: 4 additions & 4 deletions app/Services/ExportService.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ public function __construct(EntityRepo $entityRepo)
*/
public function pageToContainedHtml(Page $page)
{
$this->entityRepo->renderPage($page);
$pageHtml = view('pages/export', [
'page' => $page,
'pageContent' => $this->entityRepo->renderPage($page)
'page' => $page
])->render();
return $this->containHtml($pageHtml);
}
Expand Down Expand Up @@ -74,9 +74,9 @@ public function bookToContainedHtml(Book $book)
*/
public function pageToPdf(Page $page)
{
$this->entityRepo->renderPage($page);
$html = view('pages/pdf', [
'page' => $page,
'pageContent' => $this->entityRepo->renderPage($page)
'page' => $page
])->render();
return $this->htmlToPdf($html);
}
Expand Down
2 changes: 1 addition & 1 deletion app/Services/SearchService.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public function searchEntities($searchString, $entityType = 'all', $page = 1, $c
return [
'total' => $total,
'count' => count($results),
'results' => $results->sortByDesc('score')
'results' => $results->sortByDesc('score')->values()
];
}

Expand Down
2 changes: 1 addition & 1 deletion app/Services/ViewService.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function getPopular($count = 10, $page = 0, $filterModel = false)
$query->whereIn('viewable_type', $filterModel);
} else if ($filterModel) {
$query->where('viewable_type', '=', get_class($filterModel));
};
}

return $query->with('viewable')->skip($skipCount)->take($count)->get()->pluck('viewable');
}
Expand Down
8 changes: 7 additions & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,20 @@
const argv = require('yargs').argv;
const gulp = require('gulp'),
plumber = require('gulp-plumber');

const autoprefixer = require('gulp-autoprefixer');
const uglify = require('gulp-uglify');
const minifycss = require('gulp-clean-css');
const sass = require('gulp-sass');
const sourcemaps = require('gulp-sourcemaps');

const browserify = require("browserify");
const source = require('vinyl-source-stream');
const buffer = require('vinyl-buffer');
const babelify = require("babelify");
const watchify = require("watchify");
const envify = require("envify");
const uglify = require('gulp-uglify');

const gutil = require("gulp-util");
const liveReload = require('gulp-livereload');

Expand All @@ -21,6 +25,7 @@ let isProduction = argv.production || process.env.NODE_ENV === 'production';

gulp.task('styles', () => {
let chain = gulp.src(['resources/assets/sass/**/*.scss'])
.pipe(sourcemaps.init())
.pipe(plumber({
errorHandler: function (error) {
console.log(error.message);
Expand All @@ -29,6 +34,7 @@ gulp.task('styles', () => {
.pipe(sass())
.pipe(autoprefixer('last 2 versions'));
if (isProduction) chain = chain.pipe(minifycss());
chain = chain.pipe(sourcemaps.write());
return chain.pipe(gulp.dest('public/css/')).pipe(liveReload());
});

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"clipboard": "^1.7.1",
"codemirror": "^5.26.0",
"dropzone": "^4.0.1",
"gulp-sourcemaps": "^2.6.1",
"gulp-util": "^3.0.8",
"markdown-it": "^8.3.1",
"markdown-it-task-lists": "^2.0.0",
Expand Down
10 changes: 8 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# BookStack

[![GitHub release](https://img.shields.io/github/release/BookStackApp/BookStack.svg?maxAge=2592000)](https://github.com/BookStackApp/BookStack/releases/latest)
[![license](https://img.shields.io/github/license/BookStackApp/BookStack.svg?maxAge=2592000)](https://github.com/BookStackApp/BookStack/blob/master/LICENSE)
[![GitHub release](https://img.shields.io/github/release/BookStackApp/BookStack.svg)](https://github.com/BookStackApp/BookStack/releases/latest)
[![license](https://img.shields.io/github/license/BookStackApp/BookStack.svg)](https://github.com/BookStackApp/BookStack/blob/master/LICENSE)
[![Build Status](https://travis-ci.org/BookStackApp/BookStack.svg)](https://travis-ci.org/BookStackApp/BookStack)

A platform for storing and organising information and documentation. General information and documentation for BookStack can be found at https://www.bookstackapp.com/.
Expand All @@ -13,6 +13,12 @@ A platform for storing and organising information and documentation. General inf
* *Password: `password`*
* [BookStack Blog](https://www.bookstackapp.com/blog)

## Project Definition

BookStack is an opinionated wiki system that provides a pleasant and simple out of the box experience. New users to an instance should find the experience intuitive and only basic word-processing skills should be required to get involved in creating content on BookStack. The platform should provide advanced power features to those that desire it but they should not interfere with the core simple user experience.

BookStack is not designed as an extensible platform to be used for purposes that differ to the statement above.

## Development & Testing

All development on BookStack is currently done on the master branch. When it's time for a release the master branch is merged into release with built & minified CSS & JS then tagged at it's version. Here are the current development requirements:
Expand Down
47 changes: 47 additions & 0 deletions resources/assets/js/components/entity-selector-popup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@

class EntitySelectorPopup {

constructor(elem) {
this.elem = elem;
window.EntitySelectorPopup = this;

this.callback = null;
this.selection = null;

this.selectButton = elem.querySelector('.entity-link-selector-confirm');
this.selectButton.addEventListener('click', this.onSelectButtonClick.bind(this));

window.$events.listen('entity-select-change', this.onSelectionChange.bind(this));
window.$events.listen('entity-select-confirm', this.onSelectionConfirm.bind(this));
}

show(callback) {
this.callback = callback;
this.elem.components.overlay.show();
}

hide() {
this.elem.components.overlay.hide();
}

onSelectButtonClick() {
this.hide();
if (this.selection !== null && this.callback) this.callback(this.selection);
}

onSelectionConfirm(entity) {
this.hide();
if (this.callback && entity) this.callback(entity);
}

onSelectionChange(entity) {
this.selection = entity;
if (entity === null) {
this.selectButton.setAttribute('disabled', 'true');
} else {
this.selectButton.removeAttribute('disabled');
}
}
}

module.exports = EntitySelectorPopup;
Loading

0 comments on commit 6200948

Please sign in to comment.