mirror of
https://github.com/BookStackApp/BookStack.git
synced 2026-02-16 11:19:37 +03:00
Compare commits
149 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
22df25a480 | ||
|
|
8b30c7f02e | ||
|
|
03eb63ec77 | ||
|
|
3ed5426315 | ||
|
|
90bf13c1ab | ||
|
|
d17eb0f54c | ||
|
|
ac7e3977de | ||
|
|
d7edc389a6 | ||
|
|
56d5af1336 | ||
|
|
06cf175b08 | ||
|
|
b65abd25e0 | ||
|
|
a5e49f642b | ||
|
|
91444e83fd | ||
|
|
6063ac4a11 | ||
|
|
02fd1c48ed | ||
|
|
6ee35f55cc | ||
|
|
261e57fc4e | ||
|
|
bc1302a8d8 | ||
|
|
eeb2b8cbe5 | ||
|
|
b167ae795e | ||
|
|
6ebe8bf619 | ||
|
|
009af9736e | ||
|
|
7668a999a2 | ||
|
|
ed88c623d6 | ||
|
|
873b1099f8 | ||
|
|
6a54733f2b | ||
|
|
7a5bd23909 | ||
|
|
6bb7b5465f | ||
|
|
0b967d84ad | ||
|
|
2261308415 | ||
|
|
7b5edb4d62 | ||
|
|
8378f06889 | ||
|
|
10dc851697 | ||
|
|
757cdddc7c | ||
|
|
65579214e2 | ||
|
|
d89440d198 | ||
|
|
08e58bab79 | ||
|
|
d29b177c84 | ||
|
|
151d72e42c | ||
|
|
711ba258f1 | ||
|
|
df4d4f30f1 | ||
|
|
f094837709 | ||
|
|
e27cbb9dce | ||
|
|
bdba25b6f2 | ||
|
|
6b2581de63 | ||
|
|
1031c61d0c | ||
|
|
46fc0e5026 | ||
|
|
332f678ed0 | ||
|
|
df95e99680 | ||
|
|
5a6d544db7 | ||
|
|
0d5d77d8ab | ||
|
|
db51cee2d8 | ||
|
|
a988438946 | ||
|
|
3bf7cac030 | ||
|
|
79c3a07e9a | ||
|
|
16117d329c | ||
|
|
9758872baf | ||
|
|
e90da18ada | ||
|
|
a08d80e1cc | ||
|
|
b711bc6816 | ||
|
|
247e6dba85 | ||
|
|
2b3d6e4e4a | ||
|
|
6b1980c4f3 | ||
|
|
9ba29770e1 | ||
|
|
3d375fae55 | ||
|
|
c99a50de2c | ||
|
|
1a32b25b5e | ||
|
|
481aa5b5b0 | ||
|
|
c943eb4d0d | ||
|
|
aca6de49b0 | ||
|
|
5fd04fa470 | ||
|
|
87339e4cd0 | ||
|
|
a9eb058dad | ||
|
|
61fad6a665 | ||
|
|
fa4bee2d98 | ||
|
|
ce63260fa6 | ||
|
|
a3557d5bb2 | ||
|
|
9ca22976c3 | ||
|
|
9e2934fe17 | ||
|
|
2259263214 | ||
|
|
762cf5f183 | ||
|
|
07175f2b3e | ||
|
|
5034f21394 | ||
|
|
e02fcbe983 | ||
|
|
1c88d21abf | ||
|
|
c1a1bc0135 | ||
|
|
6200948eec | ||
|
|
7f902e41c7 | ||
|
|
3079a9f4de | ||
|
|
a7d2cfdee2 | ||
|
|
a149e87ca7 | ||
|
|
854fd52a27 | ||
|
|
3d808ac75f | ||
|
|
39b924f158 | ||
|
|
a488ef6b00 | ||
|
|
6d66c38c12 | ||
|
|
922964ecf2 | ||
|
|
0c70416b5c | ||
|
|
770f30c3a8 | ||
|
|
b4044e6c3a | ||
|
|
9872767f20 | ||
|
|
dd4d2f4696 | ||
|
|
e5dc0e6bb8 | ||
|
|
85fbe820c4 | ||
|
|
832f8eaa94 | ||
|
|
3435dcc91e | ||
|
|
1ed74b8598 | ||
|
|
fd36978c13 | ||
|
|
1278a0b818 | ||
|
|
6a6516ddd5 | ||
|
|
1fe8f13503 | ||
|
|
8f3adcda5d | ||
|
|
21a8df78ee | ||
|
|
7f8351e044 | ||
|
|
afc1ecafe9 | ||
|
|
ab6ff5fda2 | ||
|
|
b0ba1a43a9 | ||
|
|
e919cab3d1 | ||
|
|
f37509062e | ||
|
|
24ee78ccd8 | ||
|
|
d37b398e79 | ||
|
|
7a724f9134 | ||
|
|
f3b2e0fb91 | ||
|
|
844976c85b | ||
|
|
f0d914abbf | ||
|
|
0ed3023b42 | ||
|
|
3fd61a3600 | ||
|
|
a663fc8aa8 | ||
|
|
d84315fff8 | ||
|
|
144a6e469d | ||
|
|
c5f11e4516 | ||
|
|
16a09e8ff6 | ||
|
|
f51db4b9f6 | ||
|
|
6ad24a6bee | ||
|
|
5b736c3b36 | ||
|
|
cc553cc93d | ||
|
|
e88a06291e | ||
|
|
6eccb3d5b9 | ||
|
|
026de8c5ca | ||
|
|
e10d4b91cf | ||
|
|
d089eaf754 | ||
|
|
bb2d85965f | ||
|
|
d99fd1fd65 | ||
|
|
947c58f227 | ||
|
|
bce5fdd5cd | ||
|
|
fdf139edb2 | ||
|
|
af72f0d490 | ||
|
|
8924618d12 | ||
|
|
6557fbb666 |
@@ -46,6 +46,9 @@ GITHUB_APP_ID=false
|
||||
GITHUB_APP_SECRET=false
|
||||
GOOGLE_APP_ID=false
|
||||
GOOGLE_APP_SECRET=false
|
||||
OKTA_BASE_URL=false
|
||||
OKTA_KEY=false
|
||||
OKTA_SECRET=false
|
||||
|
||||
# External services such as Gravatar
|
||||
DISABLE_EXTERNAL_SERVICES=false
|
||||
|
||||
12
.github/ISSUE_TEMPLATE.md
vendored
12
.github/ISSUE_TEMPLATE.md
vendored
@@ -4,10 +4,18 @@ Desired Feature:
|
||||
|
||||
### For Bug Reports
|
||||
|
||||
* BookStack Version:
|
||||
* BookStack Version *(Found in settings, Please don't put 'latest')*:
|
||||
* PHP Version:
|
||||
* MySQL Version:
|
||||
|
||||
##### Expected Behavior
|
||||
|
||||
##### Actual Behavior
|
||||
|
||||
|
||||
##### Current Behavior
|
||||
|
||||
|
||||
|
||||
##### Steps to Reproduce
|
||||
|
||||
|
||||
|
||||
7
.gitignore
vendored
7
.gitignore
vendored
@@ -2,8 +2,10 @@
|
||||
/node_modules
|
||||
Homestead.yaml
|
||||
.env
|
||||
/public/dist
|
||||
.idea
|
||||
npm-debug.log
|
||||
yarn-error.log
|
||||
/public/dist
|
||||
/public/plugins
|
||||
/public/css/*.map
|
||||
/public/js/*.map
|
||||
@@ -18,5 +20,4 @@ yarn.lock
|
||||
nbproject
|
||||
.buildpath
|
||||
.project
|
||||
.settings/org.eclipse.wst.common.project.facet.core.xml
|
||||
.settings/org.eclipse.php.core.prefs
|
||||
.settings/
|
||||
|
||||
@@ -2,7 +2,8 @@ dist: trusty
|
||||
sudo: false
|
||||
language: php
|
||||
php:
|
||||
- 7.0.7
|
||||
- 7.0.20
|
||||
- 7.1.9
|
||||
|
||||
cache:
|
||||
directories:
|
||||
@@ -14,7 +15,6 @@ before_script:
|
||||
- mysql -u root -e "GRANT ALL ON \`bookstack-test\`.* TO 'bookstack-test'@'localhost';"
|
||||
- mysql -u root -e "FLUSH PRIVILEGES;"
|
||||
- phpenv config-rm xdebug.ini
|
||||
- composer dump-autoload --no-interaction
|
||||
- composer install --prefer-dist --no-interaction
|
||||
- php artisan clear-compiled -n
|
||||
- php artisan optimize -n
|
||||
|
||||
29
app/Book.php
29
app/Book.php
@@ -3,7 +3,7 @@
|
||||
class Book extends Entity
|
||||
{
|
||||
|
||||
protected $fillable = ['name', 'description'];
|
||||
protected $fillable = ['name', 'description', 'image_id'];
|
||||
|
||||
/**
|
||||
* Get the url for this book.
|
||||
@@ -18,6 +18,33 @@ class Book extends Entity
|
||||
return baseUrl('/books/' . urlencode($this->slug));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns book cover image, if book cover not exists return default cover image.
|
||||
* @param int $width - Width of the image
|
||||
* @param int $height - Height of the image
|
||||
* @return string
|
||||
*/
|
||||
public function getBookCover($width = 440, $height = 250)
|
||||
{
|
||||
$default = baseUrl('/book_default_cover.png');
|
||||
if (!$this->image_id) return $default;
|
||||
|
||||
try {
|
||||
$cover = $this->cover ? baseUrl($this->cover->getThumb($width, $height, false)) : $default;
|
||||
} catch (\Exception $err) {
|
||||
$cover = $default;
|
||||
}
|
||||
return $cover;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the cover image of the book
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function cover()
|
||||
{
|
||||
return $this->belongsTo(Image::class, 'image_id');
|
||||
}
|
||||
/*
|
||||
* Get the edit url for this book.
|
||||
* @return string
|
||||
|
||||
@@ -19,7 +19,7 @@ class RegenerateSearch extends Command
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Command description';
|
||||
protected $description = 'Re-index all content for searching';
|
||||
|
||||
protected $searchService;
|
||||
|
||||
|
||||
@@ -11,12 +11,7 @@ class Kernel extends ConsoleKernel
|
||||
* @var array
|
||||
*/
|
||||
protected $commands = [
|
||||
Commands\ClearViews::class,
|
||||
Commands\ClearActivity::class,
|
||||
Commands\ClearRevisions::class,
|
||||
Commands\RegeneratePermissions::class,
|
||||
Commands\RegenerateSearch::class,
|
||||
Commands\UpgradeDatabaseEncoding::class
|
||||
//
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -29,4 +24,14 @@ class Kernel extends ConsoleKernel
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the commands for the application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function commands()
|
||||
{
|
||||
$this->load(__DIR__.'/Commands');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,10 +26,10 @@ class Handler extends ExceptionHandler
|
||||
|
||||
/**
|
||||
* Report or log an exception.
|
||||
*
|
||||
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
|
||||
*
|
||||
* @param \Exception $e
|
||||
* @return mixed
|
||||
*/
|
||||
public function report(Exception $e)
|
||||
{
|
||||
@@ -103,4 +103,16 @@ class Handler extends ExceptionHandler
|
||||
|
||||
return redirect()->guest('login');
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a validation exception into a JSON response.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Illuminate\Validation\ValidationException $exception
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
protected function invalidJson($request, ValidationException $exception)
|
||||
{
|
||||
return response()->json($exception->errors(), $exception->status);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,13 +72,13 @@ class LoginController extends Controller
|
||||
// Explicitly log them out for now if they do no exist.
|
||||
if (!$user->exists) auth()->logout($user);
|
||||
|
||||
if (!$user->exists && $user->email === null && !$request->has('email')) {
|
||||
if (!$user->exists && $user->email === null && !$request->filled('email')) {
|
||||
$request->flash();
|
||||
session()->flash('request-email', true);
|
||||
return redirect('/login');
|
||||
}
|
||||
|
||||
if (!$user->exists && $user->email === null && $request->has('email')) {
|
||||
if (!$user->exists && $user->email === null && $request->filled('email')) {
|
||||
$user->email = $request->get('email');
|
||||
}
|
||||
|
||||
@@ -102,12 +102,21 @@ class LoginController extends Controller
|
||||
|
||||
/**
|
||||
* Show the application login form.
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function getLogin()
|
||||
public function getLogin(Request $request)
|
||||
{
|
||||
$socialDrivers = $this->socialAuthService->getActiveDrivers();
|
||||
$authMethod = config('auth.method');
|
||||
|
||||
if ($request->has('email')) {
|
||||
session()->flashInput([
|
||||
'email' => $request->get('email'),
|
||||
'password' => (config('app.env') === 'demo') ? $request->get('password', '') : ''
|
||||
]);
|
||||
}
|
||||
|
||||
return view('auth/login', ['socialDrivers' => $socialDrivers, 'authMethod' => $authMethod]);
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ class RegisterController extends Controller
|
||||
*/
|
||||
public function __construct(SocialAuthService $socialAuthService, EmailConfirmationService $emailConfirmationService, UserRepo $userRepo)
|
||||
{
|
||||
$this->middleware('guest')->except(['socialCallback', 'detachSocialAccount']);
|
||||
$this->middleware('guest')->only(['getRegister', 'postRegister', 'socialRegister']);
|
||||
$this->socialAuthService = $socialAuthService;
|
||||
$this->emailConfirmationService = $emailConfirmationService;
|
||||
$this->userRepo = $userRepo;
|
||||
@@ -250,15 +250,27 @@ class RegisterController extends Controller
|
||||
/**
|
||||
* The callback for social login services.
|
||||
* @param $socialDriver
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
||||
* @throws SocialSignInException
|
||||
* @throws UserRegistrationException
|
||||
* @throws \BookStack\Exceptions\SocialDriverNotConfigured
|
||||
* @throws ConfirmationEmailException
|
||||
*/
|
||||
public function socialCallback($socialDriver)
|
||||
public function socialCallback($socialDriver, Request $request)
|
||||
{
|
||||
if (!session()->has('social-callback')) {
|
||||
throw new SocialSignInException(trans('errors.social_no_action_defined'), '/login');
|
||||
}
|
||||
|
||||
// Check request for error information
|
||||
if ($request->has('error') && $request->has('error_description')) {
|
||||
throw new SocialSignInException(trans('errors.social_login_bad_response', [
|
||||
'socialAccount' => $socialDriver,
|
||||
'error' => $request->get('error_description'),
|
||||
]), '/login');
|
||||
}
|
||||
|
||||
$action = session()->pull('social-callback');
|
||||
if ($action == 'login') return $this->socialAuthService->handleLoginCallback($socialDriver);
|
||||
if ($action == 'register') return $this->socialRegisterCallback($socialDriver);
|
||||
@@ -279,7 +291,9 @@ class RegisterController extends Controller
|
||||
* Register a new user after a registration callback.
|
||||
* @param $socialDriver
|
||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
||||
* @throws ConfirmationEmailException
|
||||
* @throws UserRegistrationException
|
||||
* @throws \BookStack\Exceptions\SocialDriverNotConfigured
|
||||
*/
|
||||
protected function socialRegisterCallback($socialDriver)
|
||||
{
|
||||
|
||||
@@ -40,12 +40,14 @@ class BookController extends Controller
|
||||
$recents = $this->signedIn ? $this->entityRepo->getRecentlyViewed('book', 4, 0) : false;
|
||||
$popular = $this->entityRepo->getPopular('book', 4, 0);
|
||||
$new = $this->entityRepo->getRecentlyCreated('book', 4, 0);
|
||||
$this->setPageTitle('Books');
|
||||
$booksViewType = setting()->getUser($this->currentUser, 'books_view_type', 'list');
|
||||
$this->setPageTitle(trans('entities.books'));
|
||||
return view('books/index', [
|
||||
'books' => $books,
|
||||
'recents' => $recents,
|
||||
'popular' => $popular,
|
||||
'new' => $new
|
||||
'new' => $new,
|
||||
'booksViewType' => $booksViewType
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -125,9 +127,9 @@ class BookController extends Controller
|
||||
'name' => 'required|string|max:255',
|
||||
'description' => 'string|max:1000'
|
||||
]);
|
||||
$book = $this->entityRepo->updateFromInput('book', $book, $request->all());
|
||||
Activity::add($book, 'book_update', $book->id);
|
||||
return redirect($book->getUrl());
|
||||
$book = $this->entityRepo->updateFromInput('book', $book, $request->all());
|
||||
Activity::add($book, 'book_update', $book->id);
|
||||
return redirect($book->getUrl());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -183,7 +185,7 @@ class BookController extends Controller
|
||||
$this->checkOwnablePermission('book-update', $book);
|
||||
|
||||
// Return if no map sent
|
||||
if (!$request->has('sort-tree')) {
|
||||
if (!$request->filled('sort-tree')) {
|
||||
return redirect($book->getUrl());
|
||||
}
|
||||
|
||||
|
||||
@@ -54,6 +54,7 @@ class HomeController extends Controller
|
||||
/**
|
||||
* Get a js representation of the current translations
|
||||
* @return \Illuminate\Contracts\Routing\ResponseFactory|\Symfony\Component\HttpFoundation\Response
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function getTranslations() {
|
||||
$locale = app()->getLocale();
|
||||
@@ -86,4 +87,13 @@ class HomeController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom head HTML, Used in ajax calls to show in editor.
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function customHeadContent()
|
||||
{
|
||||
return view('partials/custom-head-content');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ class ImageController extends Controller
|
||||
$imageUpload = $request->file('file');
|
||||
|
||||
try {
|
||||
$uploadedTo = $request->has('uploaded_to') ? $request->get('uploaded_to') : 0;
|
||||
$uploadedTo = $request->filled('uploaded_to') ? $request->get('uploaded_to') : 0;
|
||||
$image = $this->imageRepo->saveNew($imageUpload, $type, $uploadedTo);
|
||||
} catch (ImageUploadException $e) {
|
||||
return response($e->getMessage(), 500);
|
||||
@@ -162,7 +162,7 @@ class ImageController extends Controller
|
||||
$this->checkOwnablePermission('image-delete', $image);
|
||||
|
||||
// Check if this image is used on any pages
|
||||
$isForced = ($request->has('force') && ($request->get('force') === 'true') || $request->get('force') === true);
|
||||
$isForced = in_array($request->get('force', ''), [true, 'true']);
|
||||
if (!$isForced) {
|
||||
$pageSearch = $entityRepo->searchForImage($image->url);
|
||||
if ($pageSearch !== false) {
|
||||
|
||||
@@ -161,14 +161,22 @@ class PageController extends Controller
|
||||
$page->html = $this->entityRepo->renderPage($page);
|
||||
$sidebarTree = $this->entityRepo->getBookChildren($page->book);
|
||||
$pageNav = $this->entityRepo->getPageNav($page->html);
|
||||
$page->load(['comments.createdBy']);
|
||||
|
||||
// check if the comment's are enabled
|
||||
$commentsEnabled = !setting('app-disable-comments');
|
||||
if ($commentsEnabled) {
|
||||
$page->load(['comments.createdBy']);
|
||||
}
|
||||
|
||||
Views::add($page);
|
||||
$this->setPageTitle($page->getShortName());
|
||||
return view('pages/show', [
|
||||
'page' => $page,'book' => $page->book,
|
||||
'current' => $page, 'sidebarTree' => $sidebarTree,
|
||||
'pageNav' => $pageNav]);
|
||||
'current' => $page,
|
||||
'sidebarTree' => $sidebarTree,
|
||||
'commentsEnabled' => $commentsEnabled,
|
||||
'pageNav' => $pageNav
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -324,9 +332,10 @@ class PageController extends Controller
|
||||
$page = $this->entityRepo->getBySlug('page', $pageSlug, $bookSlug);
|
||||
$book = $page->book;
|
||||
$this->checkOwnablePermission('page-delete', $page);
|
||||
$this->entityRepo->destroyPage($page);
|
||||
|
||||
Activity::addMessage('page_delete', $book->id, $page->name);
|
||||
session()->flash('success', trans('entities.pages_delete_success'));
|
||||
$this->entityRepo->destroyPage($page);
|
||||
return redirect($book->getUrl());
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ class SearchController extends Controller
|
||||
$searchTerm = $request->get('term');
|
||||
$this->setPageTitle(trans('entities.search_for_term', ['term' => $searchTerm]));
|
||||
|
||||
$page = $request->has('page') && is_int(intval($request->get('page'))) ? intval($request->get('page')) : 1;
|
||||
$page = intval($request->get('page', '0')) ?: 1;
|
||||
$nextPageLink = baseUrl('/search?term=' . urlencode($searchTerm) . '&page=' . ($page+1));
|
||||
|
||||
$results = $this->searchService->searchEntities($searchTerm, 'all', $page, 20);
|
||||
@@ -88,8 +88,8 @@ class SearchController extends Controller
|
||||
*/
|
||||
public function searchEntitiesAjax(Request $request)
|
||||
{
|
||||
$entityTypes = $request->has('types') ? collect(explode(',', $request->get('types'))) : collect(['page', 'chapter', 'book']);
|
||||
$searchTerm = ($request->has('term') && trim($request->get('term')) !== '') ? $request->get('term') : false;
|
||||
$entityTypes = $request->filled('types') ? collect(explode(',', $request->get('types'))) : collect(['page', 'chapter', 'book']);
|
||||
$searchTerm = $request->get('term', false);
|
||||
|
||||
// Search for entities otherwise show most popular
|
||||
if ($searchTerm !== false) {
|
||||
|
||||
@@ -37,7 +37,7 @@ class TagController extends Controller
|
||||
*/
|
||||
public function getNameSuggestions(Request $request)
|
||||
{
|
||||
$searchTerm = $request->has('search') ? $request->get('search') : false;
|
||||
$searchTerm = $request->get('search', false);
|
||||
$suggestions = $this->tagRepo->getNameSuggestions($searchTerm);
|
||||
return response()->json($suggestions);
|
||||
}
|
||||
@@ -49,8 +49,8 @@ class TagController extends Controller
|
||||
*/
|
||||
public function getValueSuggestions(Request $request)
|
||||
{
|
||||
$searchTerm = $request->has('search') ? $request->get('search') : false;
|
||||
$tagName = $request->has('name') ? $request->get('name') : false;
|
||||
$searchTerm = $request->get('search', false);
|
||||
$tagName = $request->get('name', false);
|
||||
$suggestions = $this->tagRepo->getValueSuggestions($searchTerm, $tagName);
|
||||
return response()->json($suggestions);
|
||||
}
|
||||
|
||||
@@ -34,9 +34,9 @@ class UserController extends Controller
|
||||
{
|
||||
$this->checkPermission('users-manage');
|
||||
$listDetails = [
|
||||
'order' => $request->has('order') ? $request->get('order') : 'asc',
|
||||
'search' => $request->has('search') ? $request->get('search') : '',
|
||||
'sort' => $request->has('sort') ? $request->get('sort') : 'name',
|
||||
'order' => $request->get('order', 'asc'),
|
||||
'search' => $request->get('search', ''),
|
||||
'sort' => $request->get('sort', 'name'),
|
||||
];
|
||||
$users = $this->userRepo->getAllUsersPaginatedAndSorted(20, $listDetails);
|
||||
$this->setPageTitle(trans('settings.users'));
|
||||
@@ -88,7 +88,7 @@ class UserController extends Controller
|
||||
|
||||
$user->save();
|
||||
|
||||
if ($request->has('roles')) {
|
||||
if ($request->filled('roles')) {
|
||||
$roles = $request->get('roles');
|
||||
$user->roles()->sync($roles);
|
||||
}
|
||||
@@ -155,24 +155,24 @@ class UserController extends Controller
|
||||
$user->fill($request->all());
|
||||
|
||||
// Role updates
|
||||
if (userCan('users-manage') && $request->has('roles')) {
|
||||
if (userCan('users-manage') && $request->filled('roles')) {
|
||||
$roles = $request->get('roles');
|
||||
$user->roles()->sync($roles);
|
||||
}
|
||||
|
||||
// Password updates
|
||||
if ($request->has('password') && $request->get('password') != '') {
|
||||
if ($request->filled('password')) {
|
||||
$password = $request->get('password');
|
||||
$user->password = bcrypt($password);
|
||||
}
|
||||
|
||||
// External auth id updates
|
||||
if ($this->currentUser->can('users-manage') && $request->has('external_auth_id')) {
|
||||
if ($this->currentUser->can('users-manage') && $request->filled('external_auth_id')) {
|
||||
$user->external_auth_id = $request->get('external_auth_id');
|
||||
}
|
||||
|
||||
// Save an user-specific settings
|
||||
if ($request->has('setting')) {
|
||||
if ($request->filled('setting')) {
|
||||
foreach ($request->get('setting') as $key => $value) {
|
||||
setting()->putUser($user, $key, $value);
|
||||
}
|
||||
|
||||
@@ -13,8 +13,9 @@ class Kernel extends HttpKernel
|
||||
*/
|
||||
protected $middleware = [
|
||||
\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
|
||||
\Illuminate\Session\Middleware\StartSession::class,
|
||||
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
|
||||
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
|
||||
\BookStack\Http\Middleware\TrimStrings::class,
|
||||
\BookStack\Http\Middleware\TrustProxies::class,
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -26,6 +27,8 @@ class Kernel extends HttpKernel
|
||||
'web' => [
|
||||
\BookStack\Http\Middleware\EncryptCookies::class,
|
||||
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
|
||||
\Illuminate\Session\Middleware\StartSession::class,
|
||||
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
|
||||
\BookStack\Http\Middleware\VerifyCsrfToken::class,
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
\BookStack\Http\Middleware\Localization::class
|
||||
@@ -42,10 +45,11 @@ class Kernel extends HttpKernel
|
||||
* @var array
|
||||
*/
|
||||
protected $routeMiddleware = [
|
||||
'can' => \Illuminate\Auth\Middleware\Authorize::class,
|
||||
'auth' => \BookStack\Http\Middleware\Authenticate::class,
|
||||
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
|
||||
'can' => \Illuminate\Auth\Middleware\Authorize::class,
|
||||
'guest' => \BookStack\Http\Middleware\RedirectIfAuthenticated::class,
|
||||
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
|
||||
'perm' => \BookStack\Http\Middleware\PermissionMiddleware::class
|
||||
];
|
||||
}
|
||||
|
||||
@@ -30,8 +30,11 @@ class Authenticate
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
if ($this->auth->check() && setting('registration-confirmation') && !$this->auth->user()->email_confirmed) {
|
||||
return redirect(baseUrl('/register/confirm/awaiting'));
|
||||
if ($this->auth->check()) {
|
||||
$requireConfirmation = (setting('registration-confirmation') || setting('registration-restrict'));
|
||||
if ($requireConfirmation && !$this->auth->user()->email_confirmed) {
|
||||
return redirect('/register/confirm/awaiting');
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->auth->guest() && !setting('app-public')) {
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
namespace BookStack\Http\Middleware;
|
||||
|
||||
use Illuminate\Cookie\Middleware\EncryptCookies as BaseEncrypter;
|
||||
use Illuminate\Cookie\Middleware\EncryptCookies as Middleware;
|
||||
|
||||
class EncryptCookies extends BaseEncrypter
|
||||
class EncryptCookies extends Middleware
|
||||
{
|
||||
/**
|
||||
* The names of the cookies that should not be encrypted.
|
||||
|
||||
19
app/Http/Middleware/TrimStrings.php
Normal file
19
app/Http/Middleware/TrimStrings.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace BookStack\Http\Middleware;
|
||||
|
||||
use Illuminate\Foundation\Http\Middleware\TrimStrings as Middleware;
|
||||
|
||||
class TrimStrings extends Middleware
|
||||
{
|
||||
/**
|
||||
* The names of the attributes that should not be trimmed.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $except = [
|
||||
'password',
|
||||
'password_confirmation',
|
||||
'password-confirm',
|
||||
];
|
||||
}
|
||||
47
app/Http/Middleware/TrustProxies.php
Normal file
47
app/Http/Middleware/TrustProxies.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace BookStack\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Fideloper\Proxy\TrustProxies as Middleware;
|
||||
|
||||
class TrustProxies extends Middleware
|
||||
{
|
||||
/**
|
||||
* The trusted proxies for this application.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $proxies;
|
||||
|
||||
/**
|
||||
* The current proxy header mappings.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $headers = [
|
||||
Request::HEADER_FORWARDED => 'FORWARDED',
|
||||
Request::HEADER_X_FORWARDED_FOR => 'X_FORWARDED_FOR',
|
||||
Request::HEADER_X_FORWARDED_HOST => 'X_FORWARDED_HOST',
|
||||
Request::HEADER_X_FORWARDED_PORT => 'X_FORWARDED_PORT',
|
||||
Request::HEADER_X_FORWARDED_PROTO => 'X_FORWARDED_PROTO',
|
||||
];
|
||||
|
||||
/**
|
||||
* Handle the request, Set the correct user-configured proxy information.
|
||||
* @param Request $request
|
||||
* @param Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
$setProxies = config('app.proxies');
|
||||
if ($setProxies !== '**' && $setProxies !== '*' && $setProxies !== '') {
|
||||
$setProxies = explode(',', $setProxies);
|
||||
}
|
||||
$this->proxies = $setProxies;
|
||||
|
||||
return parent::handle($request, $next);
|
||||
}
|
||||
}
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
namespace BookStack\Http\Middleware;
|
||||
|
||||
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as BaseVerifier;
|
||||
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
|
||||
|
||||
class VerifyCsrfToken extends BaseVerifier
|
||||
class VerifyCsrfToken extends Middleware
|
||||
{
|
||||
/**
|
||||
* The URIs that should be excluded from CSRF verification.
|
||||
|
||||
@@ -16,6 +16,8 @@ class EventServiceProvider extends ServiceProvider
|
||||
protected $listen = [
|
||||
SocialiteWasCalled::class => [
|
||||
'SocialiteProviders\Slack\SlackExtendSocialite@handle',
|
||||
'SocialiteProviders\Azure\AzureExtendSocialite@handle',
|
||||
'SocialiteProviders\Okta\OktaExtendSocialite@handle',
|
||||
],
|
||||
];
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ use BookStack\Book;
|
||||
use BookStack\Chapter;
|
||||
use BookStack\Entity;
|
||||
use BookStack\Exceptions\NotFoundException;
|
||||
use BookStack\Exceptions\NotifyException;
|
||||
use BookStack\Page;
|
||||
use BookStack\PageRevision;
|
||||
use BookStack\Services\AttachmentService;
|
||||
@@ -441,9 +442,10 @@ class EntityRepo
|
||||
*/
|
||||
public function updateEntityPermissionsFromRequest($request, Entity $entity)
|
||||
{
|
||||
$entity->restricted = $request->has('restricted') && $request->get('restricted') === 'true';
|
||||
$entity->restricted = $request->get('restricted', '') === 'true';
|
||||
$entity->permissions()->delete();
|
||||
if ($request->has('restrictions')) {
|
||||
|
||||
if ($request->filled('restrictions')) {
|
||||
foreach ($request->get('restrictions') as $roleId => $restrictions) {
|
||||
foreach ($restrictions as $action => $value) {
|
||||
$entity->permissions()->create([
|
||||
@@ -453,6 +455,7 @@ class EntityRepo
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$entity->save();
|
||||
$this->permissionService->buildJointPermissionsForEntity($entity);
|
||||
}
|
||||
@@ -552,8 +555,9 @@ class EntityRepo
|
||||
*/
|
||||
protected function nameToSlug($name)
|
||||
{
|
||||
$slug = str_replace(' ', '-', strtolower($name));
|
||||
$slug = preg_replace('/[\+\/\\\?\@\}\{\.\,\=\[\]\#\&\!\*\'\;\:\$\%]/', '', $slug);
|
||||
$slug = preg_replace('/[\+\/\\\?\@\}\{\.\,\=\[\]\#\&\!\*\'\;\:\$\%]/', '', mb_strtolower($name));
|
||||
$slug = preg_replace('/\s{2,}/', ' ', $slug);
|
||||
$slug = str_replace(' ', '-', $slug);
|
||||
if ($slug === "") $slug = substr(md5(rand(1, 500)), 0, 5);
|
||||
return $slug;
|
||||
}
|
||||
@@ -1073,6 +1077,7 @@ class EntityRepo
|
||||
/**
|
||||
* Destroy a given page along with its dependencies.
|
||||
* @param Page $page
|
||||
* @throws NotifyException
|
||||
*/
|
||||
public function destroyPage(Page $page)
|
||||
{
|
||||
@@ -1084,6 +1089,12 @@ class EntityRepo
|
||||
$this->permissionService->deleteJointPermissionsForEntity($page);
|
||||
$this->searchService->deleteEntityTerms($page);
|
||||
|
||||
// Check if set as custom homepage
|
||||
$customHome = setting('app-homepage', '0:');
|
||||
if (intval($page->id) === intval(explode(':', $customHome)[0])) {
|
||||
throw new NotifyException(trans('errors.page_custom_home_deletion'), $page->getUrl());
|
||||
}
|
||||
|
||||
// Delete Attached Files
|
||||
$attachmentService = app(AttachmentService::class);
|
||||
foreach ($page->attachments as $attachment) {
|
||||
|
||||
@@ -127,7 +127,7 @@ class ExportService
|
||||
$pdf = \SnappyPDF::loadHTML($containedHtml);
|
||||
$pdf->setOption('print-media-type', true);
|
||||
} else {
|
||||
$pdf = \PDF::loadHTML($containedHtml);
|
||||
$pdf = \DomPDF::loadHTML($containedHtml);
|
||||
}
|
||||
return $pdf->output();
|
||||
}
|
||||
@@ -136,6 +136,7 @@ class ExportService
|
||||
* Bundle of the contents of a html file to be self-contained.
|
||||
* @param $htmlContent
|
||||
* @return mixed|string
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function containHtml($htmlContent)
|
||||
{
|
||||
@@ -153,9 +154,27 @@ class ExportService
|
||||
} else {
|
||||
$pathString = $srcString;
|
||||
}
|
||||
|
||||
// Attempt to find local files even if url not absolute
|
||||
$base = baseUrl('/');
|
||||
if (strpos($srcString, $base) === 0) {
|
||||
$isLocal = true;
|
||||
$relString = str_replace($base, '', $srcString);
|
||||
$pathString = public_path(trim($relString, '/'));
|
||||
}
|
||||
|
||||
if ($isLocal && !file_exists($pathString)) continue;
|
||||
try {
|
||||
$imageContent = file_get_contents($pathString);
|
||||
if ($isLocal) {
|
||||
$imageContent = file_get_contents($pathString);
|
||||
} else {
|
||||
$ch = curl_init();
|
||||
curl_setopt_array($ch, [CURLOPT_URL => $pathString, CURLOPT_RETURNTRANSFER => 1, CURLOPT_CONNECTTIMEOUT => 5]);
|
||||
$imageContent = curl_exec($ch);
|
||||
$err = curl_error($ch);
|
||||
curl_close($ch);
|
||||
if ($err) throw new \Exception("Image fetch failed, Received error: " . $err);
|
||||
}
|
||||
$imageEncoded = 'data:image/' . pathinfo($pathString, PATHINFO_EXTENSION) . ';base64,' . base64_encode($imageContent);
|
||||
$newImageString = str_replace($srcString, $imageEncoded, $oldImgString);
|
||||
} catch (\ErrorException $e) {
|
||||
|
||||
@@ -205,12 +205,17 @@ class PermissionService
|
||||
}
|
||||
|
||||
$entities[] = $entity->book;
|
||||
if ($entity->isA('page') && $entity->chapter_id) $entities[] = $entity->chapter;
|
||||
|
||||
if ($entity->isA('page') && $entity->chapter_id) {
|
||||
$entities[] = $entity->chapter;
|
||||
}
|
||||
|
||||
if ($entity->isA('chapter')) {
|
||||
foreach ($entity->pages as $page) {
|
||||
$entities[] = $page;
|
||||
}
|
||||
}
|
||||
|
||||
$this->deleteManyJointPermissionsForEntities($entities);
|
||||
$this->buildJointPermissionsForEntities(collect($entities));
|
||||
}
|
||||
|
||||
@@ -382,11 +382,13 @@ class SearchService
|
||||
protected function generateTermArrayFromText($text, $scoreAdjustment = 1)
|
||||
{
|
||||
$tokenMap = []; // {TextToken => OccurrenceCount}
|
||||
$splitText = explode(' ', $text);
|
||||
foreach ($splitText as $token) {
|
||||
if ($token === '') continue;
|
||||
$splitChars = " \n\t.,!?:;()[]{}<>`'\"";
|
||||
$token = strtok($text, $splitChars);
|
||||
|
||||
while ($token !== false) {
|
||||
if (!isset($tokenMap[$token])) $tokenMap[$token] = 0;
|
||||
$tokenMap[$token]++;
|
||||
$token = strtok($splitChars);
|
||||
}
|
||||
|
||||
$terms = [];
|
||||
@@ -479,4 +481,23 @@ class SearchService
|
||||
});
|
||||
}
|
||||
|
||||
protected function filterSortBy(\Illuminate\Database\Eloquent\Builder $query, Entity $model, $input)
|
||||
{
|
||||
$functionName = camel_case('sort_by_' . $input);
|
||||
if (method_exists($this, $functionName)) $this->$functionName($query, $model);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sorting filter options
|
||||
*/
|
||||
|
||||
protected function sortByLastCommented(\Illuminate\Database\Eloquent\Builder $query, Entity $model)
|
||||
{
|
||||
$commentsTable = $this->db->getTablePrefix() . 'comments';
|
||||
$morphClass = str_replace('\\', '\\\\', $model->getMorphClass());
|
||||
$commentQuery = $this->db->raw('(SELECT c1.entity_id, c1.entity_type, c1.created_at as last_commented FROM '.$commentsTable.' c1 LEFT JOIN '.$commentsTable.' c2 ON (c1.entity_id = c2.entity_id AND c1.entity_type = c2.entity_type AND c1.created_at < c2.created_at) WHERE c1.entity_type = \''. $morphClass .'\' AND c2.created_at IS NULL) as comments');
|
||||
|
||||
$query->join($commentQuery, $model->getTable() . '.id', '=', 'comments.entity_id')->orderBy('last_commented', 'desc');
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php namespace BookStack\Services;
|
||||
|
||||
use BookStack\Http\Requests\Request;
|
||||
use GuzzleHttp\Exception\ClientException;
|
||||
use Laravel\Socialite\Contracts\Factory as Socialite;
|
||||
use BookStack\Exceptions\SocialDriverNotConfigured;
|
||||
use BookStack\Exceptions\SocialSignInException;
|
||||
@@ -14,7 +16,7 @@ class SocialAuthService
|
||||
protected $socialite;
|
||||
protected $socialAccount;
|
||||
|
||||
protected $validSocialDrivers = ['google', 'github', 'facebook', 'slack', 'twitter'];
|
||||
protected $validSocialDrivers = ['google', 'github', 'facebook', 'slack', 'twitter', 'azure', 'okta'];
|
||||
|
||||
/**
|
||||
* SocialAuthService constructor.
|
||||
@@ -91,7 +93,6 @@ class SocialAuthService
|
||||
public function handleLoginCallback($socialDriver)
|
||||
{
|
||||
$driver = $this->validateDriver($socialDriver);
|
||||
|
||||
// Get user details from social driver
|
||||
$socialUser = $this->socialite->driver($driver)->user();
|
||||
$socialId = $socialUser->getId();
|
||||
@@ -135,7 +136,7 @@ class SocialAuthService
|
||||
$message .= trans('errors.social_account_register_instructions', ['socialAccount' => title_case($socialDriver)]);
|
||||
}
|
||||
|
||||
throw new SocialSignInException($message . '.', '/login');
|
||||
throw new SocialSignInException($message, '/login');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
16
artisan
16
artisan
@@ -1,19 +1,19 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
define('LARAVEL_START', microtime(true));
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Register The Auto Loader
|
||||
| Initialize The App
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Composer provides a convenient, automatically generated class loader
|
||||
| for our application. We just need to utilize it! We'll require it
|
||||
| into the script here so that we do not have to worry about the
|
||||
| loading of any our classes "manually". Feels great to relax.
|
||||
| We need to get things going before we start up the app.
|
||||
| The init file loads everything in, in the correct order.
|
||||
|
|
||||
*/
|
||||
|
||||
require __DIR__.'/bootstrap/autoload.php';
|
||||
require __DIR__.'/bootstrap/init.php';
|
||||
|
||||
$app = require_once __DIR__.'/bootstrap/app.php';
|
||||
|
||||
@@ -40,7 +40,7 @@ $status = $kernel->handle(
|
||||
| Shutdown The Application
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Once Artisan has finished running. We will fire off the shutdown events
|
||||
| Once Artisan has finished running, we will fire off the shutdown events
|
||||
| so that any final work may be done by the application before we shut
|
||||
| down the process. This is the last thing to happen to the request.
|
||||
|
|
||||
@@ -48,4 +48,4 @@ $status = $kernel->handle(
|
||||
|
||||
$kernel->terminate($input, $status);
|
||||
|
||||
exit($status);
|
||||
exit($status);
|
||||
@@ -1,6 +1,15 @@
|
||||
<?php
|
||||
|
||||
define('LARAVEL_START', microtime(true));
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Load Our Own Helpers
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This custom function loads any helpers, before the Laravel Framework
|
||||
| is built so we can override any helpers as we please.
|
||||
|
|
||||
*/
|
||||
require __DIR__.'/../app/helpers.php';
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
@@ -13,23 +22,4 @@ define('LARAVEL_START', microtime(true));
|
||||
| loading of any our classes "manually". Feels great to relax.
|
||||
|
|
||||
*/
|
||||
|
||||
require __DIR__.'/../app/helpers.php';
|
||||
require __DIR__.'/../vendor/autoload.php';
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Include The Compiled Class File
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| To dramatically increase your application's performance, you may use a
|
||||
| compiled class file which contains all of the classes commonly used
|
||||
| by a request. The Artisan "optimize" is used to create this file.
|
||||
|
|
||||
*/
|
||||
|
||||
$compiledPath = __DIR__.'/cache/compiled.php';
|
||||
|
||||
if (file_exists($compiledPath)) {
|
||||
require $compiledPath;
|
||||
}
|
||||
require __DIR__.'/../vendor/autoload.php';
|
||||
@@ -1,31 +1,35 @@
|
||||
{
|
||||
"name": "ssddanbrown/bookstack",
|
||||
"name": "bookstackapp/bookstack",
|
||||
"description": "BookStack documentation platform",
|
||||
"keywords": ["BookStack", "Documentation"],
|
||||
"license": "MIT",
|
||||
"type": "project",
|
||||
"require": {
|
||||
"php": ">=5.6.4",
|
||||
"laravel/framework": "5.4.*",
|
||||
"php": ">=7.0.0",
|
||||
"laravel/framework": "5.5.*",
|
||||
"fideloper/proxy": "~3.3",
|
||||
"ext-tidy": "*",
|
||||
"intervention/image": "^2.3",
|
||||
"intervention/image": "^2.4",
|
||||
"laravel/socialite": "^3.0",
|
||||
"barryvdh/laravel-ide-helper": "^2.2.3",
|
||||
"barryvdh/laravel-debugbar": "^2.3.2",
|
||||
"league/flysystem-aws-s3-v3": "^1.0",
|
||||
"barryvdh/laravel-dompdf": "^0.8",
|
||||
"barryvdh/laravel-dompdf": "^0.8.1",
|
||||
"predis/predis": "^1.1",
|
||||
"gathercontent/htmldiff": "^0.2.1",
|
||||
"barryvdh/laravel-snappy": "^0.3.1",
|
||||
"laravel/browser-kit-testing": "^1.0",
|
||||
"socialiteproviders/slack": "^3.0"
|
||||
"barryvdh/laravel-snappy": "^0.4.0",
|
||||
"socialiteproviders/slack": "^3.0",
|
||||
"socialiteproviders/microsoft-azure": "^3.0",
|
||||
"socialiteproviders/okta": "^1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"filp/whoops": "~2.0",
|
||||
"fzaninotto/faker": "~1.4",
|
||||
"mockery/mockery": "0.9.*",
|
||||
"phpunit/phpunit": "~5.0",
|
||||
"mockery/mockery": "~1.0",
|
||||
"phpunit/phpunit": "~6.0",
|
||||
"symfony/css-selector": "3.1.*",
|
||||
"symfony/dom-crawler": "3.1.*"
|
||||
"symfony/dom-crawler": "3.1.*",
|
||||
"laravel/browser-kit-testing": "^2.0",
|
||||
"barryvdh/laravel-ide-helper": "^2.4.1",
|
||||
"barryvdh/laravel-debugbar": "^3.1.0"
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
@@ -56,14 +60,12 @@
|
||||
"php -r \"!file_exists('bootstrap/cache/compiled.php') || @unlink('bootstrap/cache/compiled.php');\""
|
||||
],
|
||||
"post-install-cmd": [
|
||||
"Illuminate\\Foundation\\ComposerScripts::postInstall",
|
||||
"php artisan optimize",
|
||||
"php artisan cache:clear",
|
||||
"php artisan view:clear"
|
||||
],
|
||||
"post-update-cmd": [
|
||||
"Illuminate\\Foundation\\ComposerScripts::postUpdate",
|
||||
"php artisan optimize"
|
||||
"post-autoload-dump": [
|
||||
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
|
||||
"@php artisan package:discover"
|
||||
],
|
||||
"refresh-test-database": [
|
||||
"php artisan migrate:refresh --database=mysql_testing",
|
||||
@@ -71,6 +73,10 @@
|
||||
]
|
||||
},
|
||||
"config": {
|
||||
"preferred-install": "dist"
|
||||
"optimize-autoloader": true,
|
||||
"preferred-install": "dist",
|
||||
"platform": {
|
||||
"php": "7.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
5864
composer.lock
generated
5864
composer.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -219,7 +219,7 @@ return [
|
||||
*/
|
||||
|
||||
'ImageTool' => Intervention\Image\Facades\Image::class,
|
||||
'PDF' => Barryvdh\DomPDF\Facade::class,
|
||||
'DomPDF' => Barryvdh\DomPDF\Facade::class,
|
||||
'SnappyPDF' => Barryvdh\Snappy\Facades\SnappyPdf::class,
|
||||
'Debugbar' => Barryvdh\Debugbar\Facade::class,
|
||||
|
||||
@@ -234,4 +234,6 @@ return [
|
||||
|
||||
],
|
||||
|
||||
'proxies' => env('APP_PROXIES', ''),
|
||||
|
||||
];
|
||||
|
||||
@@ -72,6 +72,22 @@ return [
|
||||
'name' => 'Twitter',
|
||||
],
|
||||
|
||||
'azure' => [
|
||||
'client_id' => env('AZURE_APP_ID', false),
|
||||
'client_secret' => env('AZURE_APP_SECRET', false),
|
||||
'tenant' => env('AZURE_TENANT', false),
|
||||
'redirect' => env('APP_URL') . '/login/service/azure/callback',
|
||||
'name' => 'Microsoft Azure',
|
||||
],
|
||||
|
||||
'okta' => [
|
||||
'client_id' => env('OKTA_APP_ID'),
|
||||
'client_secret' => env('OKTA_APP_SECRET'),
|
||||
'redirect' => env('APP_URL') . '/login/service/okta/callback',
|
||||
'base_url' => env('OKTA_BASE_URL'),
|
||||
'name' => 'Okta',
|
||||
],
|
||||
|
||||
'ldap' => [
|
||||
'server' => env('LDAP_SERVER', false),
|
||||
'dn' => env('LDAP_DN', false),
|
||||
|
||||
@@ -29,7 +29,7 @@ return [
|
||||
|
|
||||
*/
|
||||
|
||||
'lifetime' => 120,
|
||||
'lifetime' => env('SESSION_LIFETIME', 120),
|
||||
|
||||
'expire_on_close' => false,
|
||||
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class AddCoverImageDisplay extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('books', function (Blueprint $table) {
|
||||
$table->integer('image_id')->nullable()->default(null);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('books', function (Blueprint $table) {
|
||||
$table->dropColumn('image_id');
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -11,25 +11,31 @@ class DummyContentSeeder extends Seeder
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$user = factory(\BookStack\User::class)->create();
|
||||
$role = \BookStack\Role::getRole('editor');
|
||||
$user->attachRole($role);
|
||||
// Create an editor user
|
||||
$editorUser = factory(\BookStack\User::class)->create();
|
||||
$editorRole = \BookStack\Role::getRole('editor');
|
||||
$editorUser->attachRole($editorRole);
|
||||
|
||||
factory(\BookStack\Book::class, 20)->create(['created_by' => $user->id, 'updated_by' => $user->id])
|
||||
->each(function($book) use ($user) {
|
||||
$chapters = factory(\BookStack\Chapter::class, 5)->create(['created_by' => $user->id, 'updated_by' => $user->id])
|
||||
->each(function($chapter) use ($user, $book){
|
||||
$pages = factory(\BookStack\Page::class, 5)->make(['created_by' => $user->id, 'updated_by' => $user->id, 'book_id' => $book->id]);
|
||||
// Create a viewer user
|
||||
$viewerUser = factory(\BookStack\User::class)->create();
|
||||
$role = \BookStack\Role::getRole('viewer');
|
||||
$viewerUser->attachRole($role);
|
||||
|
||||
factory(\BookStack\Book::class, 20)->create(['created_by' => $editorUser->id, 'updated_by' => $editorUser->id])
|
||||
->each(function($book) use ($editorUser) {
|
||||
$chapters = factory(\BookStack\Chapter::class, 5)->create(['created_by' => $editorUser->id, 'updated_by' => $editorUser->id])
|
||||
->each(function($chapter) use ($editorUser, $book){
|
||||
$pages = factory(\BookStack\Page::class, 5)->make(['created_by' => $editorUser->id, 'updated_by' => $editorUser->id, 'book_id' => $book->id]);
|
||||
$chapter->pages()->saveMany($pages);
|
||||
});
|
||||
$pages = factory(\BookStack\Page::class, 3)->make(['created_by' => $user->id, 'updated_by' => $user->id]);
|
||||
$pages = factory(\BookStack\Page::class, 3)->make(['created_by' => $editorUser->id, 'updated_by' => $editorUser->id]);
|
||||
$book->chapters()->saveMany($chapters);
|
||||
$book->pages()->saveMany($pages);
|
||||
});
|
||||
|
||||
$largeBook = factory(\BookStack\Book::class)->create(['name' => 'Large book' . str_random(10), 'created_by' => $user->id, 'updated_by' => $user->id]);
|
||||
$pages = factory(\BookStack\Page::class, 200)->make(['created_by' => $user->id, 'updated_by' => $user->id]);
|
||||
$chapters = factory(\BookStack\Chapter::class, 50)->make(['created_by' => $user->id, 'updated_by' => $user->id]);
|
||||
$largeBook = factory(\BookStack\Book::class)->create(['name' => 'Large book' . str_random(10), 'created_by' => $editorUser->id, 'updated_by' => $editorUser->id]);
|
||||
$pages = factory(\BookStack\Page::class, 200)->make(['created_by' => $editorUser->id, 'updated_by' => $editorUser->id]);
|
||||
$chapters = factory(\BookStack\Chapter::class, 50)->make(['created_by' => $editorUser->id, 'updated_by' => $editorUser->id]);
|
||||
$largeBook->pages()->saveMany($pages);
|
||||
$largeBook->chapters()->saveMany($chapters);
|
||||
app(\BookStack\Services\PermissionService::class)->buildJointPermissions();
|
||||
|
||||
5977
package-lock.json
generated
Normal file
5977
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -25,11 +25,6 @@
|
||||
"yargs": "^7.1.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"angular": "^1.5.5",
|
||||
"angular-animate": "^1.5.5",
|
||||
"angular-resource": "^1.5.5",
|
||||
"angular-sanitize": "^1.5.5",
|
||||
"angular-ui-sortable": "^0.17.0",
|
||||
"axios": "^0.16.1",
|
||||
"babel-polyfill": "^6.23.0",
|
||||
"babel-preset-es2015": "^6.24.1",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit backupGlobals="false"
|
||||
backupStaticAttributes="false"
|
||||
bootstrap="bootstrap/autoload.php"
|
||||
bootstrap="bootstrap/init.php"
|
||||
colors="true"
|
||||
convertErrorsToExceptions="true"
|
||||
convertNoticesToExceptions="true"
|
||||
|
||||
BIN
public/book_default_cover.png
Normal file
BIN
public/book_default_cover.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.5 KiB |
4
public/css/export-styles.css
vendored
4
public/css/export-styles.css
vendored
File diff suppressed because one or more lines are too long
4
public/css/styles.css
vendored
4
public/css/styles.css
vendored
File diff suppressed because one or more lines are too long
@@ -4,22 +4,22 @@
|
||||
* Laravel - A PHP Framework For Web Artisans
|
||||
*
|
||||
* @package Laravel
|
||||
* @author Taylor Otwell <taylorotwell@gmail.com>
|
||||
* @author Taylor Otwell <taylor@laravel.com>
|
||||
*/
|
||||
|
||||
define('LARAVEL_START', microtime(true));
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Register The Auto Loader
|
||||
| Initialize The App
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Composer provides a convenient, automatically generated class loader for
|
||||
| our application. We just need to utilize it! We'll simply require it
|
||||
| into the script here so that we don't have to worry about manual
|
||||
| loading any of our classes later on. It feels nice to relax.
|
||||
| We need to get things going before we start up the app.
|
||||
| The init file loads everything in, in the correct order.
|
||||
|
|
||||
*/
|
||||
|
||||
require __DIR__.'/../bootstrap/autoload.php';
|
||||
require __DIR__.'/../bootstrap/init.php';
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
@@ -55,4 +55,4 @@ $response = $kernel->handle(
|
||||
|
||||
$response->send();
|
||||
|
||||
$kernel->terminate($request, $response);
|
||||
$kernel->terminate($request, $response);
|
||||
File diff suppressed because one or more lines are too long
14
readme.md
14
readme.md
@@ -54,8 +54,19 @@ Once done you can run `phpunit` in the application root directory to run all tes
|
||||
As part of BookStack v0.14 support for translations has been built in. All text strings can be found in the `resources/lang` folder where each language option has its own folder. To add a new language you should copy the `en` folder to an new folder (eg. `fr` for french) then go through and translate all text strings in those files, leaving the keys and file-names intact. If a language string is missing then the `en` translation will be used. To show the language option in the user preferences language drop-down you will need to add your language to the options found at the bottom of the `resources/lang/en/settings.php` file. A system-wide language can also be set in the `.env` file like so: `APP_LANG=en`.
|
||||
|
||||
You will also need to add the language to the `locales` array in the `config/app.php` file.
|
||||
|
||||
There is a script available which compares translation content to `en` files to see what items are missing or redundant. This can be ran like so from your BookStack install folder:
|
||||
|
||||
```bash
|
||||
# Syntax
|
||||
php resources/lang/check.php <lang>
|
||||
|
||||
# Examples
|
||||
php resources/lang/check.php fr
|
||||
php resources/lang/check.php pt_BR
|
||||
```
|
||||
|
||||
Some strings have colon-prefixed variables in such as `:userName`. Leave these values as they are as they will be replaced at run-time.
|
||||
Some strings have colon-prefixed variables in such as `:userName`. Leave these values as they are as they will be replaced at run-time.
|
||||
|
||||
## Contributing
|
||||
|
||||
@@ -76,7 +87,6 @@ The BookStack source is provided under the MIT License.
|
||||
These are the great open-source projects used to help build BookStack:
|
||||
|
||||
* [Laravel](http://laravel.com/)
|
||||
* [AngularJS](https://angularjs.org/)
|
||||
* [jQuery](https://jquery.com/)
|
||||
* [TinyMCE](https://www.tinymce.com/)
|
||||
* [CodeMirror](https://codemirror.net)
|
||||
|
||||
1
resources/assets/icons/azure.svg
Normal file
1
resources/assets/icons/azure.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 129 129"><path fill="#f25022" d="M0 0h61.3v61.3H0z"/><path fill="#7fba00" d="M67.7 0H129v61.3H67.7z"/><path fill="#00a4ef" d="M0 67.7h61.3V129H0z"/><path fill="#ffb900" d="M67.7 67.7H129V129H67.7z"/></svg>
|
||||
|
After Width: | Height: | Size: 258 B |
1
resources/assets/icons/okta.svg
Normal file
1
resources/assets/icons/okta.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414"><path d="M12 0A12 12 0 0 0 0 12a12 12 0 0 0 12 12 12 12 0 0 0 12-12A12 12 0 0 0 12 0zm-.035 5.537a6.427 6.427 0 0 1 6.428 6.428 6.427 6.427 0 0 1-6.428 6.428 6.427 6.427 0 0 1-6.428-6.428 6.427 6.427 0 0 1 6.428-6.428z" fill="#007dc1"/></svg>
|
||||
|
After Width: | Height: | Size: 392 B |
37
resources/assets/js/components/collapsible.js
Normal file
37
resources/assets/js/components/collapsible.js
Normal file
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* Collapsible
|
||||
* Provides some simple logic to allow collapsible sections.
|
||||
*/
|
||||
class Collapsible {
|
||||
|
||||
constructor(elem) {
|
||||
this.elem = elem;
|
||||
this.trigger = elem.querySelector('[collapsible-trigger]');
|
||||
this.content = elem.querySelector('[collapsible-content]');
|
||||
|
||||
if (!this.trigger) return;
|
||||
|
||||
this.trigger.addEventListener('click', this.toggle.bind(this));
|
||||
}
|
||||
|
||||
open() {
|
||||
this.elem.classList.add('open');
|
||||
$(this.content).slideDown(400);
|
||||
}
|
||||
|
||||
close() {
|
||||
this.elem.classList.remove('open');
|
||||
$(this.content).slideUp(400);
|
||||
}
|
||||
|
||||
toggle() {
|
||||
if (this.elem.classList.contains('open')) {
|
||||
this.close();
|
||||
} else {
|
||||
this.open();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = Collapsible;
|
||||
47
resources/assets/js/components/editor-toolbox.js
Normal file
47
resources/assets/js/components/editor-toolbox.js
Normal file
@@ -0,0 +1,47 @@
|
||||
class EditorToolbox {
|
||||
|
||||
constructor(elem) {
|
||||
// Elements
|
||||
this.elem = elem;
|
||||
this.buttons = elem.querySelectorAll('[toolbox-tab-button]');
|
||||
this.contentElements = elem.querySelectorAll('[toolbox-tab-content]');
|
||||
this.toggleButton = elem.querySelector('[toolbox-toggle]');
|
||||
|
||||
// Toolbox toggle button click
|
||||
this.toggleButton.addEventListener('click', this.toggle.bind(this));
|
||||
// Tab button click
|
||||
this.elem.addEventListener('click', event => {
|
||||
let button = event.target.closest('[toolbox-tab-button]');
|
||||
if (button === null) return;
|
||||
let name = button.getAttribute('toolbox-tab-button');
|
||||
this.setActiveTab(name, true);
|
||||
});
|
||||
|
||||
// Set the first tab as active on load
|
||||
this.setActiveTab(this.contentElements[0].getAttribute('toolbox-tab-content'));
|
||||
}
|
||||
|
||||
toggle() {
|
||||
this.elem.classList.toggle('open');
|
||||
}
|
||||
|
||||
setActiveTab(tabName, openToolbox = false) {
|
||||
// Set button visibility
|
||||
for (let i = 0, len = this.buttons.length; i < len; i++) {
|
||||
this.buttons[i].classList.remove('active');
|
||||
let bName = this.buttons[i].getAttribute('toolbox-tab-button');
|
||||
if (bName === tabName) this.buttons[i].classList.add('active');
|
||||
}
|
||||
// Set content visibility
|
||||
for (let i = 0, len = this.contentElements.length; i < len; i++) {
|
||||
this.contentElements[i].style.display = 'none';
|
||||
let cName = this.contentElements[i].getAttribute('toolbox-tab-content');
|
||||
if (cName === tabName) this.contentElements[i].style.display = 'block';
|
||||
}
|
||||
|
||||
if (openToolbox) this.elem.classList.add('open');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = EditorToolbox;
|
||||
59
resources/assets/js/components/image-picker.js
Normal file
59
resources/assets/js/components/image-picker.js
Normal file
@@ -0,0 +1,59 @@
|
||||
|
||||
class ImagePicker {
|
||||
|
||||
constructor(elem) {
|
||||
this.elem = elem;
|
||||
this.imageElem = elem.querySelector('img');
|
||||
this.input = elem.querySelector('input');
|
||||
|
||||
this.isUsingIds = elem.getAttribute('data-current-id') !== '';
|
||||
this.isResizing = elem.getAttribute('data-resize-height') && elem.getAttribute('data-resize-width');
|
||||
this.isResizeCropping = elem.getAttribute('data-resize-crop') !== '';
|
||||
|
||||
let selectButton = elem.querySelector('button[data-action="show-image-manager"]');
|
||||
selectButton.addEventListener('click', this.selectImage.bind(this));
|
||||
|
||||
let resetButton = elem.querySelector('button[data-action="reset-image"]');
|
||||
resetButton.addEventListener('click', this.reset.bind(this));
|
||||
|
||||
let removeButton = elem.querySelector('button[data-action="remove-image"]');
|
||||
if (removeButton) {
|
||||
removeButton.addEventListener('click', this.removeImage.bind(this));
|
||||
}
|
||||
}
|
||||
|
||||
selectImage() {
|
||||
window.ImageManager.show(image => {
|
||||
if (!this.isResizing) {
|
||||
this.setImage(image);
|
||||
return;
|
||||
}
|
||||
|
||||
let requestString = '/images/thumb/' + image.id + '/' + this.elem.getAttribute('data-resize-width') + '/' + this.elem.getAttribute('data-resize-height') + '/' + (this.isResizeCropping ? 'true' : 'false');
|
||||
|
||||
window.$http.get(window.baseUrl(requestString)).then(resp => {
|
||||
image.url = resp.data.url;
|
||||
this.setImage(image);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
reset() {
|
||||
this.setImage({id: 0, url: this.elem.getAttribute('data-default-image')});
|
||||
}
|
||||
|
||||
setImage(image) {
|
||||
this.imageElem.src = image.url;
|
||||
this.input.value = this.isUsingIds ? image.id : image.url;
|
||||
this.imageElem.classList.remove('none');
|
||||
}
|
||||
|
||||
removeImage() {
|
||||
this.imageElem.src = this.elem.getAttribute('data-default-image');
|
||||
this.imageElem.classList.add('none');
|
||||
this.input.value = 'none';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = ImagePicker;
|
||||
@@ -11,6 +11,11 @@ let componentMapping = {
|
||||
'sidebar': require('./sidebar'),
|
||||
'page-picker': require('./page-picker'),
|
||||
'page-comments': require('./page-comments'),
|
||||
'wysiwyg-editor': require('./wysiwyg-editor'),
|
||||
'markdown-editor': require('./markdown-editor'),
|
||||
'editor-toolbox': require('./editor-toolbox'),
|
||||
'image-picker': require('./image-picker'),
|
||||
'collapsible': require('./collapsible'),
|
||||
};
|
||||
|
||||
window.components = {};
|
||||
|
||||
295
resources/assets/js/components/markdown-editor.js
Normal file
295
resources/assets/js/components/markdown-editor.js
Normal file
@@ -0,0 +1,295 @@
|
||||
const MarkdownIt = require("markdown-it");
|
||||
const mdTasksLists = require('markdown-it-task-lists');
|
||||
const code = require('../code');
|
||||
|
||||
class MarkdownEditor {
|
||||
|
||||
constructor(elem) {
|
||||
this.elem = elem;
|
||||
this.markdown = new MarkdownIt({html: true});
|
||||
this.markdown.use(mdTasksLists, {label: true});
|
||||
|
||||
this.display = this.elem.querySelector('.markdown-display');
|
||||
this.input = this.elem.querySelector('textarea');
|
||||
this.htmlInput = this.elem.querySelector('input[name=html]');
|
||||
this.cm = code.markdownEditor(this.input);
|
||||
|
||||
this.onMarkdownScroll = this.onMarkdownScroll.bind(this);
|
||||
this.init();
|
||||
}
|
||||
|
||||
init() {
|
||||
|
||||
// Prevent markdown display link click redirect
|
||||
this.display.addEventListener('click', event => {
|
||||
let link = event.target.closest('a');
|
||||
if (link === null) return;
|
||||
|
||||
event.preventDefault();
|
||||
window.open(link.getAttribute('href'));
|
||||
});
|
||||
|
||||
// Button actions
|
||||
this.elem.addEventListener('click', event => {
|
||||
let button = event.target.closest('button[data-action]');
|
||||
if (button === null) return;
|
||||
|
||||
let action = button.getAttribute('data-action');
|
||||
if (action === 'insertImage') this.actionInsertImage();
|
||||
if (action === 'insertLink') this.actionShowLinkSelector();
|
||||
});
|
||||
|
||||
window.$events.listen('editor-markdown-update', value => {
|
||||
this.cm.setValue(value);
|
||||
this.updateAndRender();
|
||||
});
|
||||
|
||||
this.codeMirrorSetup();
|
||||
}
|
||||
|
||||
// Update the input content and render the display.
|
||||
updateAndRender() {
|
||||
let content = this.cm.getValue();
|
||||
this.input.value = content;
|
||||
let html = this.markdown.render(content);
|
||||
window.$events.emit('editor-html-change', html);
|
||||
window.$events.emit('editor-markdown-change', content);
|
||||
this.display.innerHTML = html;
|
||||
this.htmlInput.value = html;
|
||||
}
|
||||
|
||||
onMarkdownScroll(lineCount) {
|
||||
let elems = this.display.children;
|
||||
if (elems.length <= lineCount) return;
|
||||
|
||||
let topElem = (lineCount === -1) ? elems[elems.length-1] : elems[lineCount];
|
||||
// TODO - Replace jQuery
|
||||
$(this.display).animate({
|
||||
scrollTop: topElem.offsetTop
|
||||
}, {queue: false, duration: 200, easing: 'linear'});
|
||||
}
|
||||
|
||||
codeMirrorSetup() {
|
||||
let cm = this.cm;
|
||||
// Custom key commands
|
||||
let metaKey = code.getMetaKey();
|
||||
const extraKeys = {};
|
||||
// Insert Image shortcut
|
||||
extraKeys[`${metaKey}-Alt-I`] = function(cm) {
|
||||
let selectedText = cm.getSelection();
|
||||
let newText = ``;
|
||||
let cursorPos = cm.getCursor('from');
|
||||
cm.replaceSelection(newText);
|
||||
cm.setCursor(cursorPos.line, cursorPos.ch + newText.length -1);
|
||||
};
|
||||
// Save draft
|
||||
extraKeys[`${metaKey}-S`] = cm => {window.$events.emit('editor-save-draft')};
|
||||
// Save page
|
||||
extraKeys[`${metaKey}-Enter`] = cm => {window.$events.emit('editor-save-page')};
|
||||
// Show link selector
|
||||
extraKeys[`Shift-${metaKey}-K`] = cm => {this.actionShowLinkSelector()};
|
||||
// Insert Link
|
||||
extraKeys[`${metaKey}-K`] = cm => {insertLink()};
|
||||
// FormatShortcuts
|
||||
extraKeys[`${metaKey}-1`] = cm => {replaceLineStart('##');};
|
||||
extraKeys[`${metaKey}-2`] = cm => {replaceLineStart('###');};
|
||||
extraKeys[`${metaKey}-3`] = cm => {replaceLineStart('####');};
|
||||
extraKeys[`${metaKey}-4`] = cm => {replaceLineStart('#####');};
|
||||
extraKeys[`${metaKey}-5`] = cm => {replaceLineStart('');};
|
||||
extraKeys[`${metaKey}-d`] = cm => {replaceLineStart('');};
|
||||
extraKeys[`${metaKey}-6`] = cm => {replaceLineStart('>');};
|
||||
extraKeys[`${metaKey}-q`] = cm => {replaceLineStart('>');};
|
||||
extraKeys[`${metaKey}-7`] = cm => {wrapSelection('\n```\n', '\n```');};
|
||||
extraKeys[`${metaKey}-8`] = cm => {wrapSelection('`', '`');};
|
||||
extraKeys[`Shift-${metaKey}-E`] = cm => {wrapSelection('`', '`');};
|
||||
extraKeys[`${metaKey}-9`] = cm => {wrapSelection('<p class="callout info">', '</p>');};
|
||||
cm.setOption('extraKeys', extraKeys);
|
||||
|
||||
// Update data on content change
|
||||
cm.on('change', (instance, changeObj) => {
|
||||
this.updateAndRender();
|
||||
});
|
||||
|
||||
// Handle scroll to sync display view
|
||||
cm.on('scroll', instance => {
|
||||
// Thanks to http://liuhao.im/english/2015/11/10/the-sync-scroll-of-markdown-editor-in-javascript.html
|
||||
let scroll = instance.getScrollInfo();
|
||||
let atEnd = scroll.top + scroll.clientHeight === scroll.height;
|
||||
if (atEnd) {
|
||||
this.onMarkdownScroll(-1);
|
||||
return;
|
||||
}
|
||||
|
||||
let lineNum = instance.lineAtHeight(scroll.top, 'local');
|
||||
let range = instance.getRange({line: 0, ch: null}, {line: lineNum, ch: null});
|
||||
let parser = new DOMParser();
|
||||
let doc = parser.parseFromString(this.markdown.render(range), 'text/html');
|
||||
let totalLines = doc.documentElement.querySelectorAll('body > *');
|
||||
this.onMarkdownScroll(totalLines.length);
|
||||
});
|
||||
|
||||
// Handle image paste
|
||||
cm.on('paste', (cm, event) => {
|
||||
if (!event.clipboardData || !event.clipboardData.items) return;
|
||||
for (let i = 0; i < event.clipboardData.items.length; i++) {
|
||||
uploadImage(event.clipboardData.items[i].getAsFile());
|
||||
}
|
||||
});
|
||||
|
||||
// Handle images on drag-drop
|
||||
cm.on('drop', (cm, event) => {
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
let cursorPos = cm.coordsChar({left: event.pageX, top: event.pageY});
|
||||
cm.setCursor(cursorPos);
|
||||
if (!event.dataTransfer || !event.dataTransfer.files) return;
|
||||
for (let i = 0; i < event.dataTransfer.files.length; i++) {
|
||||
uploadImage(event.dataTransfer.files[i]);
|
||||
}
|
||||
});
|
||||
|
||||
// Helper to replace editor content
|
||||
function replaceContent(search, replace) {
|
||||
let text = cm.getValue();
|
||||
let cursor = cm.listSelections();
|
||||
cm.setValue(text.replace(search, replace));
|
||||
cm.setSelections(cursor);
|
||||
}
|
||||
|
||||
// Helper to replace the start of the line
|
||||
function replaceLineStart(newStart) {
|
||||
let cursor = cm.getCursor();
|
||||
let lineContent = cm.getLine(cursor.line);
|
||||
let lineLen = lineContent.length;
|
||||
let lineStart = lineContent.split(' ')[0];
|
||||
|
||||
// Remove symbol if already set
|
||||
if (lineStart === newStart) {
|
||||
lineContent = lineContent.replace(`${newStart} `, '');
|
||||
cm.replaceRange(lineContent, {line: cursor.line, ch: 0}, {line: cursor.line, ch: lineLen});
|
||||
cm.setCursor({line: cursor.line, ch: cursor.ch - (newStart.length + 1)});
|
||||
return;
|
||||
}
|
||||
|
||||
let alreadySymbol = /^[#>`]/.test(lineStart);
|
||||
let posDif = 0;
|
||||
if (alreadySymbol) {
|
||||
posDif = newStart.length - lineStart.length;
|
||||
lineContent = lineContent.replace(lineStart, newStart).trim();
|
||||
} else if (newStart !== '') {
|
||||
posDif = newStart.length + 1;
|
||||
lineContent = newStart + ' ' + lineContent;
|
||||
}
|
||||
cm.replaceRange(lineContent, {line: cursor.line, ch: 0}, {line: cursor.line, ch: lineLen});
|
||||
cm.setCursor({line: cursor.line, ch: cursor.ch + posDif});
|
||||
}
|
||||
|
||||
function wrapLine(start, end) {
|
||||
let cursor = cm.getCursor();
|
||||
let lineContent = cm.getLine(cursor.line);
|
||||
let lineLen = lineContent.length;
|
||||
let newLineContent = lineContent;
|
||||
|
||||
if (lineContent.indexOf(start) === 0 && lineContent.slice(-end.length) === end) {
|
||||
newLineContent = lineContent.slice(start.length, lineContent.length - end.length);
|
||||
} else {
|
||||
newLineContent = `${start}${lineContent}${end}`;
|
||||
}
|
||||
|
||||
cm.replaceRange(newLineContent, {line: cursor.line, ch: 0}, {line: cursor.line, ch: lineLen});
|
||||
cm.setCursor({line: cursor.line, ch: cursor.ch + start.length});
|
||||
}
|
||||
|
||||
function wrapSelection(start, end) {
|
||||
let selection = cm.getSelection();
|
||||
if (selection === '') return wrapLine(start, end);
|
||||
|
||||
let newSelection = selection;
|
||||
let frontDiff = 0;
|
||||
let endDiff = 0;
|
||||
|
||||
if (selection.indexOf(start) === 0 && selection.slice(-end.length) === end) {
|
||||
newSelection = selection.slice(start.length, selection.length - end.length);
|
||||
endDiff = -(end.length + start.length);
|
||||
} else {
|
||||
newSelection = `${start}${selection}${end}`;
|
||||
endDiff = start.length + end.length;
|
||||
}
|
||||
|
||||
let selections = cm.listSelections()[0];
|
||||
cm.replaceSelection(newSelection);
|
||||
let headFirst = selections.head.ch <= selections.anchor.ch;
|
||||
selections.head.ch += headFirst ? frontDiff : endDiff;
|
||||
selections.anchor.ch += headFirst ? endDiff : frontDiff;
|
||||
cm.setSelections([selections]);
|
||||
}
|
||||
|
||||
// Handle image upload and add image into markdown content
|
||||
function uploadImage(file) {
|
||||
if (file === null || file.type.indexOf('image') !== 0) return;
|
||||
let ext = 'png';
|
||||
|
||||
if (file.name) {
|
||||
let fileNameMatches = file.name.match(/\.(.+)$/);
|
||||
if (fileNameMatches.length > 1) ext = fileNameMatches[1];
|
||||
}
|
||||
|
||||
// Insert image into markdown
|
||||
let id = "image-" + Math.random().toString(16).slice(2);
|
||||
let placeholderImage = window.baseUrl(`/loading.gif#upload${id}`);
|
||||
let selectedText = cm.getSelection();
|
||||
let placeHolderText = ``;
|
||||
cm.replaceSelection(placeHolderText);
|
||||
|
||||
let remoteFilename = "image-" + Date.now() + "." + ext;
|
||||
let formData = new FormData();
|
||||
formData.append('file', file, remoteFilename);
|
||||
|
||||
window.$http.post('/images/gallery/upload', formData).then(resp => {
|
||||
replaceContent(placeholderImage, resp.data.thumbs.display);
|
||||
}).catch(err => {
|
||||
events.emit('error', trans('errors.image_upload_error'));
|
||||
replaceContent(placeHolderText, selectedText);
|
||||
console.log(err);
|
||||
});
|
||||
}
|
||||
|
||||
function insertLink() {
|
||||
let cursorPos = cm.getCursor('from');
|
||||
let selectedText = cm.getSelection() || '';
|
||||
let newText = `[${selectedText}]()`;
|
||||
cm.focus();
|
||||
cm.replaceSelection(newText);
|
||||
let cursorPosDiff = (selectedText === '') ? -3 : -1;
|
||||
cm.setCursor(cursorPos.line, cursorPos.ch + newText.length+cursorPosDiff);
|
||||
}
|
||||
|
||||
this.updateAndRender();
|
||||
}
|
||||
|
||||
actionInsertImage() {
|
||||
let cursorPos = this.cm.getCursor('from');
|
||||
window.ImageManager.show(image => {
|
||||
let selectedText = this.cm.getSelection();
|
||||
let newText = "";
|
||||
this.cm.focus();
|
||||
this.cm.replaceSelection(newText);
|
||||
this.cm.setCursor(cursorPos.line, cursorPos.ch + newText.length);
|
||||
});
|
||||
}
|
||||
|
||||
// Show the popup link selector and insert a link when finished
|
||||
actionShowLinkSelector() {
|
||||
let cursorPos = this.cm.getCursor('from');
|
||||
window.EntitySelectorPopup.show(entity => {
|
||||
let selectedText = this.cm.getSelection() || entity.name;
|
||||
let newText = `[${selectedText}](${entity.link})`;
|
||||
this.cm.focus();
|
||||
this.cm.replaceSelection(newText);
|
||||
this.cm.setCursor(cursorPos.line, cursorPos.ch + newText.length);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = MarkdownEditor ;
|
||||
11
resources/assets/js/components/wysiwyg-editor.js
Normal file
11
resources/assets/js/components/wysiwyg-editor.js
Normal file
@@ -0,0 +1,11 @@
|
||||
class WysiwygEditor {
|
||||
|
||||
constructor(elem) {
|
||||
this.elem = elem;
|
||||
this.options = require("../pages/page-form");
|
||||
tinymce.init(this.options);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = WysiwygEditor;
|
||||
@@ -1,147 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
const moment = require('moment');
|
||||
require('moment/locale/en-gb');
|
||||
const editorOptions = require("./pages/page-form");
|
||||
|
||||
moment.locale('en-gb');
|
||||
|
||||
module.exports = function (ngApp, events) {
|
||||
|
||||
|
||||
ngApp.controller('PageEditController', ['$scope', '$http', '$attrs', '$interval', '$timeout', '$sce',
|
||||
function ($scope, $http, $attrs, $interval, $timeout, $sce) {
|
||||
|
||||
$scope.editorOptions = editorOptions();
|
||||
$scope.editContent = '';
|
||||
$scope.draftText = '';
|
||||
let pageId = Number($attrs.pageId);
|
||||
let isEdit = pageId !== 0;
|
||||
let autosaveFrequency = 30; // AutoSave interval in seconds.
|
||||
let isMarkdown = $attrs.editorType === 'markdown';
|
||||
$scope.draftsEnabled = $attrs.draftsEnabled === 'true';
|
||||
$scope.isUpdateDraft = Number($attrs.pageUpdateDraft) === 1;
|
||||
$scope.isNewPageDraft = Number($attrs.pageNewDraft) === 1;
|
||||
|
||||
// Set initial header draft text
|
||||
if ($scope.isUpdateDraft || $scope.isNewPageDraft) {
|
||||
$scope.draftText = trans('entities.pages_editing_draft');
|
||||
} else {
|
||||
$scope.draftText = trans('entities.pages_editing_page');
|
||||
}
|
||||
|
||||
let autoSave = false;
|
||||
|
||||
let currentContent = {
|
||||
title: false,
|
||||
html: false
|
||||
};
|
||||
|
||||
if (isEdit && $scope.draftsEnabled) {
|
||||
setTimeout(() => {
|
||||
startAutoSave();
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
// Actions specifically for the markdown editor
|
||||
if (isMarkdown) {
|
||||
$scope.displayContent = '';
|
||||
// Editor change event
|
||||
$scope.editorChange = function (content) {
|
||||
$scope.displayContent = $sce.trustAsHtml(content);
|
||||
}
|
||||
}
|
||||
|
||||
if (!isMarkdown) {
|
||||
$scope.editorChange = function() {};
|
||||
}
|
||||
|
||||
let lastSave = 0;
|
||||
|
||||
/**
|
||||
* Start the AutoSave loop, Checks for content change
|
||||
* before performing the costly AJAX request.
|
||||
*/
|
||||
function startAutoSave() {
|
||||
currentContent.title = $('#name').val();
|
||||
currentContent.html = $scope.editContent;
|
||||
|
||||
autoSave = $interval(() => {
|
||||
// Return if manually saved recently to prevent bombarding the server
|
||||
if (Date.now() - lastSave < (1000*autosaveFrequency)/2) return;
|
||||
let newTitle = $('#name').val();
|
||||
let newHtml = $scope.editContent;
|
||||
|
||||
if (newTitle !== currentContent.title || newHtml !== currentContent.html) {
|
||||
currentContent.html = newHtml;
|
||||
currentContent.title = newTitle;
|
||||
saveDraft();
|
||||
}
|
||||
|
||||
}, 1000 * autosaveFrequency);
|
||||
}
|
||||
|
||||
let draftErroring = false;
|
||||
/**
|
||||
* Save a draft update into the system via an AJAX request.
|
||||
*/
|
||||
function saveDraft() {
|
||||
if (!$scope.draftsEnabled) return;
|
||||
let data = {
|
||||
name: $('#name').val(),
|
||||
html: isMarkdown ? $sce.getTrustedHtml($scope.displayContent) : $scope.editContent
|
||||
};
|
||||
|
||||
if (isMarkdown) data.markdown = $scope.editContent;
|
||||
|
||||
let url = window.baseUrl('/ajax/page/' + pageId + '/save-draft');
|
||||
$http.put(url, data).then(responseData => {
|
||||
draftErroring = false;
|
||||
let updateTime = moment.utc(moment.unix(responseData.data.timestamp)).toDate();
|
||||
$scope.draftText = responseData.data.message + moment(updateTime).format('HH:mm');
|
||||
if (!$scope.isNewPageDraft) $scope.isUpdateDraft = true;
|
||||
showDraftSaveNotification();
|
||||
lastSave = Date.now();
|
||||
}, errorRes => {
|
||||
if (draftErroring) return;
|
||||
events.emit('error', trans('errors.page_draft_autosave_fail'));
|
||||
draftErroring = true;
|
||||
});
|
||||
}
|
||||
|
||||
function showDraftSaveNotification() {
|
||||
$scope.draftUpdated = true;
|
||||
$timeout(() => {
|
||||
$scope.draftUpdated = false;
|
||||
}, 2000)
|
||||
}
|
||||
|
||||
$scope.forceDraftSave = function() {
|
||||
saveDraft();
|
||||
};
|
||||
|
||||
// Listen to save draft events from editor
|
||||
$scope.$on('save-draft', saveDraft);
|
||||
|
||||
/**
|
||||
* Discard the current draft and grab the current page
|
||||
* content from the system via an AJAX request.
|
||||
*/
|
||||
$scope.discardDraft = function () {
|
||||
let url = window.baseUrl('/ajax/page/' + pageId);
|
||||
$http.get(url).then(responseData => {
|
||||
if (autoSave) $interval.cancel(autoSave);
|
||||
$scope.draftText = trans('entities.pages_editing_page');
|
||||
$scope.isUpdateDraft = false;
|
||||
$scope.$broadcast('html-update', responseData.data.html);
|
||||
$scope.$broadcast('markdown-update', responseData.data.markdown || responseData.data.html);
|
||||
$('#name').val(responseData.data.name);
|
||||
$timeout(() => {
|
||||
startAutoSave();
|
||||
}, 1000);
|
||||
events.emit('success', trans('entities.pages_draft_discarded'));
|
||||
});
|
||||
};
|
||||
|
||||
}]);
|
||||
};
|
||||
@@ -1,393 +0,0 @@
|
||||
"use strict";
|
||||
const MarkdownIt = require("markdown-it");
|
||||
const mdTasksLists = require('markdown-it-task-lists');
|
||||
const code = require('./code');
|
||||
|
||||
module.exports = function (ngApp, events) {
|
||||
|
||||
/**
|
||||
* TinyMCE
|
||||
* An angular wrapper around the tinyMCE editor.
|
||||
*/
|
||||
ngApp.directive('tinymce', ['$timeout', function ($timeout) {
|
||||
return {
|
||||
restrict: 'A',
|
||||
scope: {
|
||||
tinymce: '=',
|
||||
mceModel: '=',
|
||||
mceChange: '='
|
||||
},
|
||||
link: function (scope, element, attrs) {
|
||||
|
||||
function tinyMceSetup(editor) {
|
||||
editor.on('ExecCommand change input NodeChange ObjectResized', (e) => {
|
||||
let content = editor.getContent();
|
||||
$timeout(() => {
|
||||
scope.mceModel = content;
|
||||
});
|
||||
scope.mceChange(content);
|
||||
});
|
||||
|
||||
editor.on('keydown', (event) => {
|
||||
if (event.keyCode === 83 && (navigator.platform.match("Mac") ? event.metaKey : event.ctrlKey)) {
|
||||
event.preventDefault();
|
||||
scope.$emit('save-draft', event);
|
||||
}
|
||||
});
|
||||
|
||||
editor.on('init', (e) => {
|
||||
scope.mceModel = editor.getContent();
|
||||
});
|
||||
|
||||
scope.$on('html-update', (event, value) => {
|
||||
editor.setContent(value);
|
||||
editor.selection.select(editor.getBody(), true);
|
||||
editor.selection.collapse(false);
|
||||
scope.mceModel = editor.getContent();
|
||||
});
|
||||
}
|
||||
|
||||
scope.tinymce.extraSetups.push(tinyMceSetup);
|
||||
tinymce.init(scope.tinymce);
|
||||
}
|
||||
}
|
||||
}]);
|
||||
|
||||
const md = new MarkdownIt({html: true});
|
||||
md.use(mdTasksLists, {label: true});
|
||||
|
||||
/**
|
||||
* Markdown input
|
||||
* Handles the logic for just the editor input field.
|
||||
*/
|
||||
ngApp.directive('markdownInput', ['$timeout', function ($timeout) {
|
||||
return {
|
||||
restrict: 'A',
|
||||
scope: {
|
||||
mdModel: '=',
|
||||
mdChange: '='
|
||||
},
|
||||
link: function (scope, element, attrs) {
|
||||
|
||||
// Codemirror Setup
|
||||
element = element.find('textarea').first();
|
||||
let cm = code.markdownEditor(element[0]);
|
||||
|
||||
// Custom key commands
|
||||
let metaKey = code.getMetaKey();
|
||||
const extraKeys = {};
|
||||
// Insert Image shortcut
|
||||
extraKeys[`${metaKey}-Alt-I`] = function(cm) {
|
||||
let selectedText = cm.getSelection();
|
||||
let newText = ``;
|
||||
let cursorPos = cm.getCursor('from');
|
||||
cm.replaceSelection(newText);
|
||||
cm.setCursor(cursorPos.line, cursorPos.ch + newText.length -1);
|
||||
};
|
||||
// Save draft
|
||||
extraKeys[`${metaKey}-S`] = function(cm) {scope.$emit('save-draft');};
|
||||
// Show link selector
|
||||
extraKeys[`Shift-${metaKey}-K`] = function(cm) {showLinkSelector()};
|
||||
// Insert Link
|
||||
extraKeys[`${metaKey}-K`] = function(cm) {insertLink()};
|
||||
// FormatShortcuts
|
||||
extraKeys[`${metaKey}-1`] = function(cm) {replaceLineStart('##');};
|
||||
extraKeys[`${metaKey}-2`] = function(cm) {replaceLineStart('###');};
|
||||
extraKeys[`${metaKey}-3`] = function(cm) {replaceLineStart('####');};
|
||||
extraKeys[`${metaKey}-4`] = function(cm) {replaceLineStart('#####');};
|
||||
extraKeys[`${metaKey}-5`] = function(cm) {replaceLineStart('');};
|
||||
extraKeys[`${metaKey}-d`] = function(cm) {replaceLineStart('');};
|
||||
extraKeys[`${metaKey}-6`] = function(cm) {replaceLineStart('>');};
|
||||
extraKeys[`${metaKey}-q`] = function(cm) {replaceLineStart('>');};
|
||||
extraKeys[`${metaKey}-7`] = function(cm) {wrapSelection('\n```\n', '\n```');};
|
||||
extraKeys[`${metaKey}-8`] = function(cm) {wrapSelection('`', '`');};
|
||||
extraKeys[`Shift-${metaKey}-E`] = function(cm) {wrapSelection('`', '`');};
|
||||
extraKeys[`${metaKey}-9`] = function(cm) {wrapSelection('<p class="callout info">', '</p>');};
|
||||
cm.setOption('extraKeys', extraKeys);
|
||||
|
||||
// Update data on content change
|
||||
cm.on('change', (instance, changeObj) => {
|
||||
update(instance);
|
||||
});
|
||||
|
||||
// Handle scroll to sync display view
|
||||
cm.on('scroll', instance => {
|
||||
// Thanks to http://liuhao.im/english/2015/11/10/the-sync-scroll-of-markdown-editor-in-javascript.html
|
||||
let scroll = instance.getScrollInfo();
|
||||
let atEnd = scroll.top + scroll.clientHeight === scroll.height;
|
||||
if (atEnd) {
|
||||
scope.$emit('markdown-scroll', -1);
|
||||
return;
|
||||
}
|
||||
let lineNum = instance.lineAtHeight(scroll.top, 'local');
|
||||
let range = instance.getRange({line: 0, ch: null}, {line: lineNum, ch: null});
|
||||
let parser = new DOMParser();
|
||||
let doc = parser.parseFromString(md.render(range), 'text/html');
|
||||
let totalLines = doc.documentElement.querySelectorAll('body > *');
|
||||
scope.$emit('markdown-scroll', totalLines.length);
|
||||
});
|
||||
|
||||
// Handle image paste
|
||||
cm.on('paste', (cm, event) => {
|
||||
if (!event.clipboardData || !event.clipboardData.items) return;
|
||||
for (let i = 0; i < event.clipboardData.items.length; i++) {
|
||||
uploadImage(event.clipboardData.items[i].getAsFile());
|
||||
}
|
||||
});
|
||||
|
||||
// Handle images on drag-drop
|
||||
cm.on('drop', (cm, event) => {
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
let cursorPos = cm.coordsChar({left: event.pageX, top: event.pageY});
|
||||
cm.setCursor(cursorPos);
|
||||
if (!event.dataTransfer || !event.dataTransfer.files) return;
|
||||
for (let i = 0; i < event.dataTransfer.files.length; i++) {
|
||||
uploadImage(event.dataTransfer.files[i]);
|
||||
}
|
||||
});
|
||||
|
||||
// Helper to replace editor content
|
||||
function replaceContent(search, replace) {
|
||||
let text = cm.getValue();
|
||||
let cursor = cm.listSelections();
|
||||
cm.setValue(text.replace(search, replace));
|
||||
cm.setSelections(cursor);
|
||||
}
|
||||
|
||||
// Helper to replace the start of the line
|
||||
function replaceLineStart(newStart) {
|
||||
let cursor = cm.getCursor();
|
||||
let lineContent = cm.getLine(cursor.line);
|
||||
let lineLen = lineContent.length;
|
||||
let lineStart = lineContent.split(' ')[0];
|
||||
|
||||
// Remove symbol if already set
|
||||
if (lineStart === newStart) {
|
||||
lineContent = lineContent.replace(`${newStart} `, '');
|
||||
cm.replaceRange(lineContent, {line: cursor.line, ch: 0}, {line: cursor.line, ch: lineLen});
|
||||
cm.setCursor({line: cursor.line, ch: cursor.ch - (newStart.length + 1)});
|
||||
return;
|
||||
}
|
||||
|
||||
let alreadySymbol = /^[#>`]/.test(lineStart);
|
||||
let posDif = 0;
|
||||
if (alreadySymbol) {
|
||||
posDif = newStart.length - lineStart.length;
|
||||
lineContent = lineContent.replace(lineStart, newStart).trim();
|
||||
} else if (newStart !== '') {
|
||||
posDif = newStart.length + 1;
|
||||
lineContent = newStart + ' ' + lineContent;
|
||||
}
|
||||
cm.replaceRange(lineContent, {line: cursor.line, ch: 0}, {line: cursor.line, ch: lineLen});
|
||||
cm.setCursor({line: cursor.line, ch: cursor.ch + posDif});
|
||||
}
|
||||
|
||||
function wrapLine(start, end) {
|
||||
let cursor = cm.getCursor();
|
||||
let lineContent = cm.getLine(cursor.line);
|
||||
let lineLen = lineContent.length;
|
||||
let newLineContent = lineContent;
|
||||
|
||||
if (lineContent.indexOf(start) === 0 && lineContent.slice(-end.length) === end) {
|
||||
newLineContent = lineContent.slice(start.length, lineContent.length - end.length);
|
||||
} else {
|
||||
newLineContent = `${start}${lineContent}${end}`;
|
||||
}
|
||||
|
||||
cm.replaceRange(newLineContent, {line: cursor.line, ch: 0}, {line: cursor.line, ch: lineLen});
|
||||
cm.setCursor({line: cursor.line, ch: cursor.ch + start.length});
|
||||
}
|
||||
|
||||
function wrapSelection(start, end) {
|
||||
let selection = cm.getSelection();
|
||||
if (selection === '') return wrapLine(start, end);
|
||||
|
||||
let newSelection = selection;
|
||||
let frontDiff = 0;
|
||||
let endDiff = 0;
|
||||
|
||||
if (selection.indexOf(start) === 0 && selection.slice(-end.length) === end) {
|
||||
newSelection = selection.slice(start.length, selection.length - end.length);
|
||||
endDiff = -(end.length + start.length);
|
||||
} else {
|
||||
newSelection = `${start}${selection}${end}`;
|
||||
endDiff = start.length + end.length;
|
||||
}
|
||||
|
||||
let selections = cm.listSelections()[0];
|
||||
cm.replaceSelection(newSelection);
|
||||
let headFirst = selections.head.ch <= selections.anchor.ch;
|
||||
selections.head.ch += headFirst ? frontDiff : endDiff;
|
||||
selections.anchor.ch += headFirst ? endDiff : frontDiff;
|
||||
cm.setSelections([selections]);
|
||||
}
|
||||
|
||||
// Handle image upload and add image into markdown content
|
||||
function uploadImage(file) {
|
||||
if (file === null || file.type.indexOf('image') !== 0) return;
|
||||
let ext = 'png';
|
||||
|
||||
if (file.name) {
|
||||
let fileNameMatches = file.name.match(/\.(.+)$/);
|
||||
if (fileNameMatches.length > 1) ext = fileNameMatches[1];
|
||||
}
|
||||
|
||||
// Insert image into markdown
|
||||
let id = "image-" + Math.random().toString(16).slice(2);
|
||||
let placeholderImage = window.baseUrl(`/loading.gif#upload${id}`);
|
||||
let selectedText = cm.getSelection();
|
||||
let placeHolderText = ``;
|
||||
cm.replaceSelection(placeHolderText);
|
||||
|
||||
let remoteFilename = "image-" + Date.now() + "." + ext;
|
||||
let formData = new FormData();
|
||||
formData.append('file', file, remoteFilename);
|
||||
|
||||
window.$http.post('/images/gallery/upload', formData).then(resp => {
|
||||
replaceContent(placeholderImage, resp.data.thumbs.display);
|
||||
}).catch(err => {
|
||||
events.emit('error', trans('errors.image_upload_error'));
|
||||
replaceContent(placeHolderText, selectedText);
|
||||
console.log(err);
|
||||
});
|
||||
}
|
||||
|
||||
// Show the popup link selector and insert a link when finished
|
||||
function showLinkSelector() {
|
||||
let cursorPos = cm.getCursor('from');
|
||||
window.EntitySelectorPopup.show(entity => {
|
||||
let selectedText = cm.getSelection() || entity.name;
|
||||
let newText = `[${selectedText}](${entity.link})`;
|
||||
cm.focus();
|
||||
cm.replaceSelection(newText);
|
||||
cm.setCursor(cursorPos.line, cursorPos.ch + newText.length);
|
||||
});
|
||||
}
|
||||
|
||||
function insertLink() {
|
||||
let cursorPos = cm.getCursor('from');
|
||||
let selectedText = cm.getSelection() || '';
|
||||
let newText = `[${selectedText}]()`;
|
||||
cm.focus();
|
||||
cm.replaceSelection(newText);
|
||||
let cursorPosDiff = (selectedText === '') ? -3 : -1;
|
||||
cm.setCursor(cursorPos.line, cursorPos.ch + newText.length+cursorPosDiff);
|
||||
}
|
||||
|
||||
// Show the image manager and handle image insertion
|
||||
function showImageManager() {
|
||||
let cursorPos = cm.getCursor('from');
|
||||
window.ImageManager.show(image => {
|
||||
let selectedText = cm.getSelection();
|
||||
let newText = "";
|
||||
cm.focus();
|
||||
cm.replaceSelection(newText);
|
||||
cm.setCursor(cursorPos.line, cursorPos.ch + newText.length);
|
||||
});
|
||||
}
|
||||
|
||||
// Update the data models and rendered output
|
||||
function update(instance) {
|
||||
let content = instance.getValue();
|
||||
element.val(content);
|
||||
$timeout(() => {
|
||||
scope.mdModel = content;
|
||||
scope.mdChange(md.render(content));
|
||||
});
|
||||
}
|
||||
update(cm);
|
||||
|
||||
// Listen to commands from parent scope
|
||||
scope.$on('md-insert-link', showLinkSelector);
|
||||
scope.$on('md-insert-image', showImageManager);
|
||||
scope.$on('markdown-update', (event, value) => {
|
||||
cm.setValue(value);
|
||||
element.val(value);
|
||||
scope.mdModel = value;
|
||||
scope.mdChange(md.render(value));
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
}]);
|
||||
|
||||
/**
|
||||
* Markdown Editor
|
||||
* Handles all functionality of the markdown editor.
|
||||
*/
|
||||
ngApp.directive('markdownEditor', ['$timeout', '$rootScope', function ($timeout, $rootScope) {
|
||||
return {
|
||||
restrict: 'A',
|
||||
link: function (scope, element, attrs) {
|
||||
|
||||
// Editor Elements
|
||||
const $display = element.find('.markdown-display').first();
|
||||
const $insertImage = element.find('button[data-action="insertImage"]');
|
||||
const $insertEntityLink = element.find('button[data-action="insertEntityLink"]');
|
||||
|
||||
// Prevent markdown display link click redirect
|
||||
$display.on('click', 'a', function(event) {
|
||||
event.preventDefault();
|
||||
window.open(this.getAttribute('href'));
|
||||
});
|
||||
|
||||
// Editor UI Actions
|
||||
$insertEntityLink.click(e => {scope.$broadcast('md-insert-link');});
|
||||
$insertImage.click(e => {scope.$broadcast('md-insert-image');});
|
||||
|
||||
// Handle scroll sync event from editor scroll
|
||||
$rootScope.$on('markdown-scroll', (event, lineCount) => {
|
||||
let elems = $display[0].children[0].children;
|
||||
if (elems.length > lineCount) {
|
||||
let topElem = (lineCount === -1) ? elems[elems.length-1] : elems[lineCount];
|
||||
$display.animate({
|
||||
scrollTop: topElem.offsetTop
|
||||
}, {queue: false, duration: 200, easing: 'linear'});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}]);
|
||||
|
||||
/**
|
||||
* Page Editor Toolbox
|
||||
* Controls all functionality for the sliding toolbox
|
||||
* on the page edit view.
|
||||
*/
|
||||
ngApp.directive('toolbox', [function () {
|
||||
return {
|
||||
restrict: 'A',
|
||||
link: function (scope, elem, attrs) {
|
||||
|
||||
// Get common elements
|
||||
const $buttons = elem.find('[toolbox-tab-button]');
|
||||
const $content = elem.find('[toolbox-tab-content]');
|
||||
const $toggle = elem.find('[toolbox-toggle]');
|
||||
|
||||
// Handle toolbox toggle click
|
||||
$toggle.click((e) => {
|
||||
elem.toggleClass('open');
|
||||
});
|
||||
|
||||
// Set an active tab/content by name
|
||||
function setActive(tabName, openToolbox) {
|
||||
$buttons.removeClass('active');
|
||||
$content.hide();
|
||||
$buttons.filter(`[toolbox-tab-button="${tabName}"]`).addClass('active');
|
||||
$content.filter(`[toolbox-tab-content="${tabName}"]`).show();
|
||||
if (openToolbox) elem.addClass('open');
|
||||
}
|
||||
|
||||
// Set the first tab content active on load
|
||||
setActive($content.first().attr('toolbox-tab-content'), false);
|
||||
|
||||
// Handle tab button click
|
||||
$buttons.click(function (e) {
|
||||
let name = $(this).attr('toolbox-tab-button');
|
||||
setActive(name, true);
|
||||
});
|
||||
}
|
||||
}
|
||||
}]);
|
||||
};
|
||||
@@ -58,16 +58,6 @@ window.$http = axiosInstance;
|
||||
Vue.prototype.$http = axiosInstance;
|
||||
Vue.prototype.$events = window.$events;
|
||||
|
||||
|
||||
// AngularJS - Create application and load components
|
||||
const angular = require("angular");
|
||||
require("angular-resource");
|
||||
require("angular-animate");
|
||||
require("angular-sanitize");
|
||||
require("angular-ui-sortable");
|
||||
|
||||
let ngApp = angular.module('bookStack', ['ngResource', 'ngAnimate', 'ngSanitize', 'ui.sortable']);
|
||||
|
||||
// Translation setup
|
||||
// Creates a global function with name 'trans' to be used in the same way as Laravel's translation system
|
||||
const Translations = require("./translations");
|
||||
@@ -79,11 +69,6 @@ window.trans_choice = translator.getPlural.bind(translator);
|
||||
require("./vues/vues");
|
||||
require("./components");
|
||||
|
||||
// Load in angular specific items
|
||||
const Directives = require('./directives');
|
||||
const Controllers = require('./controllers');
|
||||
Directives(ngApp, window.$events);
|
||||
Controllers(ngApp, window.$events);
|
||||
|
||||
//Global jQuery Config & Extensions
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
"use strict";
|
||||
|
||||
const Code = require('../code');
|
||||
|
||||
/**
|
||||
@@ -66,6 +65,17 @@ function registerEditorShortcuts(editor) {
|
||||
editor.shortcuts.add('meta+e', '', ['codeeditor', false, 'pre']);
|
||||
editor.shortcuts.add('meta+8', '', ['FormatBlock', false, 'code']);
|
||||
editor.shortcuts.add('meta+shift+E', '', ['FormatBlock', false, 'code']);
|
||||
|
||||
// Save draft shortcut
|
||||
editor.shortcuts.add('meta+S', '', () => {
|
||||
window.$events.emit('editor-save-draft');
|
||||
});
|
||||
|
||||
// Save page shortcut
|
||||
editor.shortcuts.add('meta+13', '', () => {
|
||||
window.$events.emit('editor-save-page');
|
||||
});
|
||||
|
||||
// Loop through callout styles
|
||||
editor.shortcuts.add('meta+9', '', function() {
|
||||
let selectedNode = editor.selection.getNode();
|
||||
@@ -84,8 +94,20 @@ function registerEditorShortcuts(editor) {
|
||||
}
|
||||
editor.formatter.apply('p');
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Load custom HTML head content from the settings into the editor.
|
||||
* @param editor
|
||||
*/
|
||||
function loadCustomHeadContent(editor) {
|
||||
window.$http.get(window.baseUrl('/custom-head-content')).then(resp => {
|
||||
if (!resp.data) return;
|
||||
let head = editor.getDoc().querySelector('head');
|
||||
head.innerHTML += resp.data;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Create and enable our custom code plugin
|
||||
@@ -196,189 +218,195 @@ function codePlugin() {
|
||||
|
||||
});
|
||||
}
|
||||
codePlugin();
|
||||
|
||||
function hrPlugin() {
|
||||
window.tinymce.PluginManager.add('customhr', function (editor) {
|
||||
editor.addCommand('InsertHorizontalRule', function () {
|
||||
let hrElem = document.createElement('hr');
|
||||
let cNode = editor.selection.getNode();
|
||||
let parentNode = cNode.parentNode;
|
||||
parentNode.insertBefore(hrElem, cNode);
|
||||
});
|
||||
|
||||
editor.addButton('hr', {
|
||||
icon: 'hr',
|
||||
tooltip: 'Horizontal line',
|
||||
cmd: 'InsertHorizontalRule'
|
||||
});
|
||||
|
||||
editor.addMenuItem('hr', {
|
||||
icon: 'hr',
|
||||
text: 'Horizontal line',
|
||||
cmd: 'InsertHorizontalRule',
|
||||
context: 'insert'
|
||||
});
|
||||
window.tinymce.PluginManager.add('customhr', function (editor) {
|
||||
editor.addCommand('InsertHorizontalRule', function () {
|
||||
let hrElem = document.createElement('hr');
|
||||
let cNode = editor.selection.getNode();
|
||||
let parentNode = cNode.parentNode;
|
||||
parentNode.insertBefore(hrElem, cNode);
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = function() {
|
||||
hrPlugin();
|
||||
codePlugin();
|
||||
let settings = {
|
||||
selector: '#html-editor',
|
||||
content_css: [
|
||||
window.baseUrl('/css/styles.css'),
|
||||
window.baseUrl('/libs/material-design-iconic-font/css/material-design-iconic-font.min.css')
|
||||
],
|
||||
branding: false,
|
||||
body_class: 'page-content',
|
||||
browser_spellcheck: true,
|
||||
relative_urls: false,
|
||||
remove_script_host: false,
|
||||
document_base_url: window.baseUrl('/'),
|
||||
statusbar: false,
|
||||
menubar: false,
|
||||
paste_data_images: false,
|
||||
extended_valid_elements: 'pre[*]',
|
||||
automatic_uploads: false,
|
||||
valid_children: "-div[p|h1|h2|h3|h4|h5|h6|blockquote],+div[pre]",
|
||||
plugins: "image table textcolor paste link autolink fullscreen imagetools code customhr autosave lists codeeditor",
|
||||
imagetools_toolbar: 'imageoptions',
|
||||
toolbar: "undo redo | styleselect | bold italic underline strikethrough superscript subscript | forecolor backcolor | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | table image-insert link hr | removeformat code fullscreen",
|
||||
content_style: "body {padding-left: 15px !important; padding-right: 15px !important; margin:0!important; margin-left:auto!important;margin-right:auto!important;}",
|
||||
style_formats: [
|
||||
{title: "Header Large", format: "h2"},
|
||||
{title: "Header Medium", format: "h3"},
|
||||
{title: "Header Small", format: "h4"},
|
||||
{title: "Header Tiny", format: "h5"},
|
||||
{title: "Paragraph", format: "p", exact: true, classes: ''},
|
||||
{title: "Blockquote", format: "blockquote"},
|
||||
{title: "Code Block", icon: "code", cmd: 'codeeditor', format: 'codeeditor'},
|
||||
{title: "Inline Code", icon: "code", inline: "code"},
|
||||
{title: "Callouts", items: [
|
||||
{title: "Info", format: 'calloutinfo'},
|
||||
{title: "Success", format: 'calloutsuccess'},
|
||||
{title: "Warning", format: 'calloutwarning'},
|
||||
{title: "Danger", format: 'calloutdanger'}
|
||||
]},
|
||||
],
|
||||
style_formats_merge: false,
|
||||
formats: {
|
||||
codeeditor: {selector: 'p,h1,h2,h3,h4,h5,h6,td,th,div'},
|
||||
alignleft: {selector: 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img', classes: 'align-left'},
|
||||
aligncenter: {selector: 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img', classes: 'align-center'},
|
||||
alignright: {selector: 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img', classes: 'align-right'},
|
||||
calloutsuccess: {block: 'p', exact: true, attributes: {class: 'callout success'}},
|
||||
calloutinfo: {block: 'p', exact: true, attributes: {class: 'callout info'}},
|
||||
calloutwarning: {block: 'p', exact: true, attributes: {class: 'callout warning'}},
|
||||
calloutdanger: {block: 'p', exact: true, attributes: {class: 'callout danger'}}
|
||||
},
|
||||
file_browser_callback: function (field_name, url, type, win) {
|
||||
editor.addButton('hr', {
|
||||
icon: 'hr',
|
||||
tooltip: 'Horizontal line',
|
||||
cmd: 'InsertHorizontalRule'
|
||||
});
|
||||
|
||||
if (type === 'file') {
|
||||
window.EntitySelectorPopup.show(function(entity) {
|
||||
let originalField = win.document.getElementById(field_name);
|
||||
originalField.value = entity.link;
|
||||
$(originalField).closest('.mce-form').find('input').eq(2).val(entity.name);
|
||||
editor.addMenuItem('hr', {
|
||||
icon: 'hr',
|
||||
text: 'Horizontal line',
|
||||
cmd: 'InsertHorizontalRule',
|
||||
context: 'insert'
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
module.exports = {
|
||||
selector: '#html-editor',
|
||||
content_css: [
|
||||
window.baseUrl('/css/styles.css'),
|
||||
window.baseUrl('/libs/material-design-iconic-font/css/material-design-iconic-font.min.css')
|
||||
],
|
||||
branding: false,
|
||||
body_class: 'page-content',
|
||||
browser_spellcheck: true,
|
||||
relative_urls: false,
|
||||
remove_script_host: false,
|
||||
document_base_url: window.baseUrl('/'),
|
||||
statusbar: false,
|
||||
menubar: false,
|
||||
paste_data_images: false,
|
||||
extended_valid_elements: 'pre[*]',
|
||||
automatic_uploads: false,
|
||||
valid_children: "-div[p|h1|h2|h3|h4|h5|h6|blockquote],+div[pre]",
|
||||
plugins: "image table textcolor paste link autolink fullscreen imagetools code customhr autosave lists codeeditor",
|
||||
imagetools_toolbar: 'imageoptions',
|
||||
toolbar: "undo redo | styleselect | bold italic underline strikethrough superscript subscript | forecolor backcolor | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | table image-insert link hr | removeformat code fullscreen",
|
||||
content_style: "body {padding-left: 15px !important; padding-right: 15px !important; margin:0!important; margin-left:auto!important;margin-right:auto!important;}",
|
||||
style_formats: [
|
||||
{title: "Header Large", format: "h2"},
|
||||
{title: "Header Medium", format: "h3"},
|
||||
{title: "Header Small", format: "h4"},
|
||||
{title: "Header Tiny", format: "h5"},
|
||||
{title: "Paragraph", format: "p", exact: true, classes: ''},
|
||||
{title: "Blockquote", format: "blockquote"},
|
||||
{title: "Code Block", icon: "code", cmd: 'codeeditor', format: 'codeeditor'},
|
||||
{title: "Inline Code", icon: "code", inline: "code"},
|
||||
{title: "Callouts", items: [
|
||||
{title: "Info", format: 'calloutinfo'},
|
||||
{title: "Success", format: 'calloutsuccess'},
|
||||
{title: "Warning", format: 'calloutwarning'},
|
||||
{title: "Danger", format: 'calloutdanger'}
|
||||
]},
|
||||
],
|
||||
style_formats_merge: false,
|
||||
formats: {
|
||||
codeeditor: {selector: 'p,h1,h2,h3,h4,h5,h6,td,th,div'},
|
||||
alignleft: {selector: 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img', classes: 'align-left'},
|
||||
aligncenter: {selector: 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img', classes: 'align-center'},
|
||||
alignright: {selector: 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img', classes: 'align-right'},
|
||||
calloutsuccess: {block: 'p', exact: true, attributes: {class: 'callout success'}},
|
||||
calloutinfo: {block: 'p', exact: true, attributes: {class: 'callout info'}},
|
||||
calloutwarning: {block: 'p', exact: true, attributes: {class: 'callout warning'}},
|
||||
calloutdanger: {block: 'p', exact: true, attributes: {class: 'callout danger'}}
|
||||
},
|
||||
file_browser_callback: function (field_name, url, type, win) {
|
||||
|
||||
if (type === 'file') {
|
||||
window.EntitySelectorPopup.show(function(entity) {
|
||||
let originalField = win.document.getElementById(field_name);
|
||||
originalField.value = entity.link;
|
||||
$(originalField).closest('.mce-form').find('input').eq(2).val(entity.name);
|
||||
});
|
||||
}
|
||||
|
||||
if (type === 'image') {
|
||||
// Show image manager
|
||||
window.ImageManager.show(function (image) {
|
||||
|
||||
// Set popover link input to image url then fire change event
|
||||
// to ensure the new value sticks
|
||||
win.document.getElementById(field_name).value = image.url;
|
||||
if ("createEvent" in document) {
|
||||
let evt = document.createEvent("HTMLEvents");
|
||||
evt.initEvent("change", false, true);
|
||||
win.document.getElementById(field_name).dispatchEvent(evt);
|
||||
} else {
|
||||
win.document.getElementById(field_name).fireEvent("onchange");
|
||||
}
|
||||
|
||||
// Replace the actively selected content with the linked image
|
||||
let html = `<a href="${image.url}" target="_blank">`;
|
||||
html += `<img src="${image.thumbs.display}" alt="${image.name}">`;
|
||||
html += '</a>';
|
||||
win.tinyMCE.activeEditor.execCommand('mceInsertContent', false, html);
|
||||
});
|
||||
}
|
||||
|
||||
},
|
||||
paste_preprocess: function (plugin, args) {
|
||||
let content = args.content;
|
||||
if (content.indexOf('<img src="file://') !== -1) {
|
||||
args.content = '';
|
||||
}
|
||||
},
|
||||
init_instance_callback: function(editor) {
|
||||
loadCustomHeadContent(editor);
|
||||
},
|
||||
setup: function (editor) {
|
||||
|
||||
editor.on('init ExecCommand change input NodeChange ObjectResized', editorChange);
|
||||
|
||||
function editorChange() {
|
||||
let content = editor.getContent();
|
||||
window.$events.emit('editor-html-change', content);
|
||||
}
|
||||
|
||||
window.$events.listen('editor-html-update', html => {
|
||||
editor.setContent(html);
|
||||
editor.selection.select(editor.getBody(), true);
|
||||
editor.selection.collapse(false);
|
||||
editorChange(html);
|
||||
});
|
||||
|
||||
registerEditorShortcuts(editor);
|
||||
|
||||
let wrap;
|
||||
|
||||
function hasTextContent(node) {
|
||||
return node && !!( node.textContent || node.innerText );
|
||||
}
|
||||
|
||||
editor.on('dragstart', function () {
|
||||
let node = editor.selection.getNode();
|
||||
|
||||
if (node.nodeName !== 'IMG') return;
|
||||
wrap = editor.dom.getParent(node, '.mceTemp');
|
||||
|
||||
if (!wrap && node.parentNode.nodeName === 'A' && !hasTextContent(node.parentNode)) {
|
||||
wrap = node.parentNode;
|
||||
}
|
||||
});
|
||||
|
||||
editor.on('drop', function (event) {
|
||||
let dom = editor.dom,
|
||||
rng = tinymce.dom.RangeUtils.getCaretRangeFromPoint(event.clientX, event.clientY, editor.getDoc());
|
||||
|
||||
// Don't allow anything to be dropped in a captioned image.
|
||||
if (dom.getParent(rng.startContainer, '.mceTemp')) {
|
||||
event.preventDefault();
|
||||
} else if (wrap) {
|
||||
event.preventDefault();
|
||||
|
||||
editor.undoManager.transact(function () {
|
||||
editor.selection.setRng(rng);
|
||||
editor.selection.setNode(wrap);
|
||||
dom.remove(wrap);
|
||||
});
|
||||
}
|
||||
|
||||
if (type === 'image') {
|
||||
// Show image manager
|
||||
wrap = null;
|
||||
});
|
||||
|
||||
// Custom Image picker button
|
||||
editor.addButton('image-insert', {
|
||||
title: 'My title',
|
||||
icon: 'image',
|
||||
tooltip: 'Insert an image',
|
||||
onclick: function () {
|
||||
window.ImageManager.show(function (image) {
|
||||
|
||||
// Set popover link input to image url then fire change event
|
||||
// to ensure the new value sticks
|
||||
win.document.getElementById(field_name).value = image.url;
|
||||
if ("createEvent" in document) {
|
||||
let evt = document.createEvent("HTMLEvents");
|
||||
evt.initEvent("change", false, true);
|
||||
win.document.getElementById(field_name).dispatchEvent(evt);
|
||||
} else {
|
||||
win.document.getElementById(field_name).fireEvent("onchange");
|
||||
}
|
||||
|
||||
// Replace the actively selected content with the linked image
|
||||
let html = `<a href="${image.url}" target="_blank">`;
|
||||
html += `<img src="${image.thumbs.display}" alt="${image.name}">`;
|
||||
html += '</a>';
|
||||
win.tinyMCE.activeEditor.execCommand('mceInsertContent', false, html);
|
||||
editor.execCommand('mceInsertContent', false, html);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
},
|
||||
paste_preprocess: function (plugin, args) {
|
||||
let content = args.content;
|
||||
if (content.indexOf('<img src="file://') !== -1) {
|
||||
args.content = '';
|
||||
}
|
||||
},
|
||||
extraSetups: [],
|
||||
setup: function (editor) {
|
||||
|
||||
// Run additional setup actions
|
||||
// Used by the angular side of things
|
||||
for (let i = 0; i < settings.extraSetups.length; i++) {
|
||||
settings.extraSetups[i](editor);
|
||||
}
|
||||
|
||||
registerEditorShortcuts(editor);
|
||||
|
||||
let wrap;
|
||||
|
||||
function hasTextContent(node) {
|
||||
return node && !!( node.textContent || node.innerText );
|
||||
}
|
||||
|
||||
editor.on('dragstart', function () {
|
||||
let node = editor.selection.getNode();
|
||||
|
||||
if (node.nodeName !== 'IMG') return;
|
||||
wrap = editor.dom.getParent(node, '.mceTemp');
|
||||
|
||||
if (!wrap && node.parentNode.nodeName === 'A' && !hasTextContent(node.parentNode)) {
|
||||
wrap = node.parentNode;
|
||||
}
|
||||
});
|
||||
|
||||
editor.on('drop', function (event) {
|
||||
let dom = editor.dom,
|
||||
rng = tinymce.dom.RangeUtils.getCaretRangeFromPoint(event.clientX, event.clientY, editor.getDoc());
|
||||
|
||||
// Don't allow anything to be dropped in a captioned image.
|
||||
if (dom.getParent(rng.startContainer, '.mceTemp')) {
|
||||
event.preventDefault();
|
||||
} else if (wrap) {
|
||||
event.preventDefault();
|
||||
|
||||
editor.undoManager.transact(function () {
|
||||
editor.selection.setRng(rng);
|
||||
editor.selection.setNode(wrap);
|
||||
dom.remove(wrap);
|
||||
});
|
||||
}
|
||||
|
||||
wrap = null;
|
||||
});
|
||||
|
||||
// Custom Image picker button
|
||||
editor.addButton('image-insert', {
|
||||
title: 'My title',
|
||||
icon: 'image',
|
||||
tooltip: 'Insert an image',
|
||||
onclick: function () {
|
||||
window.ImageManager.show(function (image) {
|
||||
let html = `<a href="${image.url}" target="_blank">`;
|
||||
html += `<img src="${image.thumbs.display}" alt="${image.name}">`;
|
||||
html += '</a>';
|
||||
editor.execCommand('mceInsertContent', false, html);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Paste image-uploads
|
||||
editor.on('paste', event => { editorPaste(event, editor) });
|
||||
}
|
||||
};
|
||||
return settings;
|
||||
// Paste image-uploads
|
||||
editor.on('paste', event => { editorPaste(event, editor) });
|
||||
}
|
||||
};
|
||||
@@ -102,23 +102,28 @@ let setupPageShow = window.setupPageShow = function (pageId) {
|
||||
let $window = $(window);
|
||||
let $sidebar = $("#sidebar .scroll-body");
|
||||
let $bookTreeParent = $sidebar.parent();
|
||||
|
||||
// Check the page is scrollable and the content is taller than the tree
|
||||
let pageScrollable = ($(document).height() > $window.height()) && ($sidebar.height() < $('.page-content').height());
|
||||
|
||||
// Get current tree's width and header height
|
||||
let headerHeight = $("#header").height() + $(".toolbar").height();
|
||||
let isFixed = $window.scrollTop() > headerHeight;
|
||||
// Function to fix the tree as a sidebar
|
||||
|
||||
// Fix the tree as a sidebar
|
||||
function stickTree() {
|
||||
$sidebar.width($bookTreeParent.width() + 15);
|
||||
$sidebar.addClass("fixed");
|
||||
isFixed = true;
|
||||
}
|
||||
// Function to un-fix the tree back into position
|
||||
|
||||
// Un-fix the tree back into position
|
||||
function unstickTree() {
|
||||
$sidebar.css('width', 'auto');
|
||||
$sidebar.removeClass("fixed");
|
||||
isFixed = false;
|
||||
}
|
||||
|
||||
// Checks if the tree stickiness state should change
|
||||
function checkTreeStickiness(skipCheck) {
|
||||
let shouldBeFixed = $window.scrollTop() > headerHeight;
|
||||
@@ -150,6 +155,59 @@ let setupPageShow = window.setupPageShow = function (pageId) {
|
||||
unstickTree();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Check if support is present for IntersectionObserver
|
||||
if ('IntersectionObserver' in window &&
|
||||
'IntersectionObserverEntry' in window &&
|
||||
'intersectionRatio' in window.IntersectionObserverEntry.prototype) {
|
||||
addPageHighlighting();
|
||||
}
|
||||
|
||||
function addPageHighlighting() {
|
||||
let pageNav = document.querySelector('.sidebar-page-nav');
|
||||
|
||||
// fetch all the headings.
|
||||
let headings = document.querySelector('.page-content').querySelectorAll('h1, h2, h3, h4, h5, h6');
|
||||
// if headings are present, add observers.
|
||||
if (headings.length > 0 && pageNav !== null) {
|
||||
addNavObserver(headings);
|
||||
}
|
||||
|
||||
function addNavObserver(headings) {
|
||||
// Setup the intersection observer.
|
||||
let intersectOpts = {
|
||||
rootMargin: '0px 0px 0px 0px',
|
||||
threshold: 1.0
|
||||
};
|
||||
let pageNavObserver = new IntersectionObserver(headingVisibilityChange, intersectOpts);
|
||||
|
||||
// observe each heading
|
||||
for (let i = 0; i !== headings.length; ++i) {
|
||||
pageNavObserver.observe(headings[i]);
|
||||
}
|
||||
}
|
||||
|
||||
function headingVisibilityChange(entries, observer) {
|
||||
for (let i = 0; i < entries.length; i++) {
|
||||
let currentEntry = entries[i];
|
||||
let isVisible = (currentEntry.intersectionRatio === 1);
|
||||
toggleAnchorHighlighting(currentEntry.target.id, isVisible);
|
||||
}
|
||||
}
|
||||
|
||||
function toggleAnchorHighlighting(elementId, shouldHighlight) {
|
||||
let anchorsToHighlight = pageNav.querySelectorAll('a[href="#' + elementId + '"]');
|
||||
for (let i = 0; i < anchorsToHighlight.length; i++) {
|
||||
// Change below to use classList.toggle when IE support is dropped.
|
||||
if (shouldHighlight) {
|
||||
anchorsToHighlight[i].classList.add('current-heading');
|
||||
} else {
|
||||
anchorsToHighlight[i].classList.remove('current-heading');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = setupPageShow;
|
||||
@@ -125,6 +125,4 @@ const methods = {
|
||||
|
||||
};
|
||||
|
||||
const computed = [];
|
||||
|
||||
module.exports = {template, data, props, methods, computed};
|
||||
module.exports = {template, data, props, methods};
|
||||
153
resources/assets/js/vues/page-editor.js
Normal file
153
resources/assets/js/vues/page-editor.js
Normal file
@@ -0,0 +1,153 @@
|
||||
const moment = require('moment');
|
||||
require('moment/locale/en-gb');
|
||||
moment.locale('en-gb');
|
||||
|
||||
let autoSaveFrequency = 30;
|
||||
|
||||
let autoSave = false;
|
||||
let draftErroring = false;
|
||||
|
||||
let currentContent = {
|
||||
title: false,
|
||||
html: false
|
||||
};
|
||||
|
||||
let lastSave = 0;
|
||||
|
||||
function mounted() {
|
||||
let elem = this.$el;
|
||||
this.draftsEnabled = elem.getAttribute('drafts-enabled') === 'true';
|
||||
this.editorType = elem.getAttribute('editor-type');
|
||||
this.pageId= Number(elem.getAttribute('page-id'));
|
||||
this.isNewDraft = Number(elem.getAttribute('page-new-draft')) === 1;
|
||||
this.isUpdateDraft = Number(elem.getAttribute('page-update-draft')) === 1;
|
||||
|
||||
if (this.pageId !== 0 && this.draftsEnabled) {
|
||||
window.setTimeout(() => {
|
||||
this.startAutoSave();
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
if (this.isUpdateDraft || this.isNewDraft) {
|
||||
this.draftText = trans('entities.pages_editing_draft');
|
||||
} else {
|
||||
this.draftText = trans('entities.pages_editing_page');
|
||||
}
|
||||
|
||||
// Listen to save events from editor
|
||||
window.$events.listen('editor-save-draft', this.saveDraft);
|
||||
window.$events.listen('editor-save-page', this.savePage);
|
||||
|
||||
// Listen to content changes from the editor
|
||||
window.$events.listen('editor-html-change', html => {
|
||||
this.editorHTML = html;
|
||||
});
|
||||
window.$events.listen('editor-markdown-change', markdown => {
|
||||
this.editorMarkdown = markdown;
|
||||
});
|
||||
}
|
||||
|
||||
let data = {
|
||||
draftsEnabled: false,
|
||||
editorType: 'wysiwyg',
|
||||
pagedId: 0,
|
||||
isNewDraft: false,
|
||||
isUpdateDraft: false,
|
||||
|
||||
draftText: '',
|
||||
draftUpdated : false,
|
||||
changeSummary: '',
|
||||
|
||||
editorHTML: '',
|
||||
editorMarkdown: '',
|
||||
};
|
||||
|
||||
let methods = {
|
||||
|
||||
startAutoSave() {
|
||||
currentContent.title = document.getElementById('name').value.trim();
|
||||
currentContent.html = this.editorHTML;
|
||||
|
||||
autoSave = window.setInterval(() => {
|
||||
// Return if manually saved recently to prevent bombarding the server
|
||||
if (Date.now() - lastSave < (1000 * autoSaveFrequency)/2) return;
|
||||
let newTitle = document.getElementById('name').value.trim();
|
||||
let newHtml = this.editorHTML;
|
||||
|
||||
if (newTitle !== currentContent.title || newHtml !== currentContent.html) {
|
||||
currentContent.html = newHtml;
|
||||
currentContent.title = newTitle;
|
||||
this.saveDraft();
|
||||
}
|
||||
|
||||
}, 1000 * autoSaveFrequency);
|
||||
},
|
||||
|
||||
saveDraft() {
|
||||
if (!this.draftsEnabled) return;
|
||||
|
||||
let data = {
|
||||
name: document.getElementById('name').value.trim(),
|
||||
html: this.editorHTML
|
||||
};
|
||||
|
||||
if (this.editorType === 'markdown') data.markdown = this.editorMarkdown;
|
||||
|
||||
let url = window.baseUrl(`/ajax/page/${this.pageId}/save-draft`);
|
||||
window.$http.put(url, data).then(response => {
|
||||
draftErroring = false;
|
||||
let updateTime = moment.utc(moment.unix(response.data.timestamp)).toDate();
|
||||
if (!this.isNewDraft) this.isUpdateDraft = true;
|
||||
this.draftNotifyChange(response.data.message + moment(updateTime).format('HH:mm'));
|
||||
lastSave = Date.now();
|
||||
}, errorRes => {
|
||||
if (draftErroring) return;
|
||||
window.$events('error', trans('errors.page_draft_autosave_fail'));
|
||||
draftErroring = true;
|
||||
});
|
||||
},
|
||||
|
||||
savePage() {
|
||||
this.$el.closest('form').submit();
|
||||
},
|
||||
|
||||
draftNotifyChange(text) {
|
||||
this.draftText = text;
|
||||
this.draftUpdated = true;
|
||||
window.setTimeout(() => {
|
||||
this.draftUpdated = false;
|
||||
}, 2000);
|
||||
},
|
||||
|
||||
discardDraft() {
|
||||
let url = window.baseUrl(`/ajax/page/${this.pageId}`);
|
||||
window.$http.get(url).then(response => {
|
||||
if (autoSave) window.clearInterval(autoSave);
|
||||
|
||||
this.draftText = trans('entities.pages_editing_page');
|
||||
this.isUpdateDraft = false;
|
||||
window.$events.emit('editor-html-update', response.data.html);
|
||||
window.$events.emit('editor-markdown-update', response.data.markdown || response.data.html);
|
||||
|
||||
document.getElementById('name').value = response.data.name;
|
||||
window.setTimeout(() => {
|
||||
this.startAutoSave();
|
||||
}, 1000);
|
||||
window.$events.emit('success', trans('entities.pages_draft_discarded'));
|
||||
});
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
let computed = {
|
||||
changeSummaryShort() {
|
||||
let len = this.changeSummary.length;
|
||||
if (len === 0) return trans('entities.pages_edit_set_changelog');
|
||||
if (len <= 16) return this.changeSummary;
|
||||
return this.changeSummary.slice(0, 16) + '...';
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
mounted, data, methods, computed,
|
||||
};
|
||||
@@ -9,8 +9,6 @@ let data = {
|
||||
const components = {draggable, autosuggest};
|
||||
const directives = {};
|
||||
|
||||
let computed = {};
|
||||
|
||||
let methods = {
|
||||
|
||||
addEmptyTag() {
|
||||
@@ -64,5 +62,5 @@ function mounted() {
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
data, computed, methods, mounted, components, directives
|
||||
data, methods, mounted, components, directives
|
||||
};
|
||||
@@ -11,6 +11,7 @@ let vueMapping = {
|
||||
'image-manager': require('./image-manager'),
|
||||
'tag-manager': require('./tag-manager'),
|
||||
'attachment-manager': require('./attachment-manager'),
|
||||
'page-editor': require('./page-editor'),
|
||||
};
|
||||
|
||||
window.vues = {};
|
||||
|
||||
@@ -195,10 +195,13 @@
|
||||
font-weight: 400;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
h3 a {
|
||||
line-height: 1;
|
||||
}
|
||||
.body, p.empty-text {
|
||||
padding: $-m;
|
||||
}
|
||||
a {
|
||||
a, p {
|
||||
word-wrap: break-word;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
@@ -370,6 +370,7 @@ span.CodeMirror-selectedtext { background: none; }
|
||||
.cm-s-base16-light span.cm-keyword { color: #ac4142; }
|
||||
.cm-s-base16-light span.cm-string { color: #e09c3c; }
|
||||
|
||||
.cm-s-base16-light span.cm-builtin { color: #4c7f9e; }
|
||||
.cm-s-base16-light span.cm-variable { color: #90a959; }
|
||||
.cm-s-base16-light span.cm-variable-2 { color: #6a9fb5; }
|
||||
.cm-s-base16-light span.cm-def { color: #d28445; }
|
||||
|
||||
@@ -63,9 +63,10 @@
|
||||
padding: 0 $-m 0;
|
||||
margin-left: -1px;
|
||||
overflow-y: scroll;
|
||||
.page-content {
|
||||
margin: 0 auto;
|
||||
}
|
||||
}
|
||||
.markdown-display.page-content {
|
||||
margin: 0 auto;
|
||||
max-width: 100%;
|
||||
}
|
||||
}
|
||||
.editor-toolbar {
|
||||
@@ -190,6 +191,41 @@ input:checked + .toggle-switch {
|
||||
}
|
||||
}
|
||||
|
||||
.form-group[collapsible] {
|
||||
margin-left: -$-m;
|
||||
margin-right: -$-m;
|
||||
padding: 0 $-m;
|
||||
border-top: 1px solid #DDD;
|
||||
border-bottom: 1px solid #DDD;
|
||||
.collapse-title {
|
||||
margin-left: -$-m;
|
||||
margin-right: -$-m;
|
||||
padding: $-s $-m;
|
||||
}
|
||||
.collapse-title, .collapse-title label {
|
||||
cursor: pointer;
|
||||
}
|
||||
.collapse-title label {
|
||||
padding-bottom: 0;
|
||||
margin-bottom: 0;
|
||||
color: inherit;
|
||||
}
|
||||
.collapse-title label:before {
|
||||
display: inline-block;
|
||||
content: '▸';
|
||||
margin-right: $-m;
|
||||
transition: all ease-in-out 400ms;
|
||||
transform: rotate(0);
|
||||
}
|
||||
.collapse-content {
|
||||
display: none;
|
||||
padding-bottom: $-m;
|
||||
}
|
||||
&.open .collapse-title label:before {
|
||||
transform: rotate(90deg);
|
||||
}
|
||||
}
|
||||
|
||||
.inline-input-style {
|
||||
display: block;
|
||||
width: 100%;
|
||||
|
||||
@@ -19,6 +19,7 @@ body.flexbox {
|
||||
display: flex;
|
||||
align-items: stretch;
|
||||
min-height: 0;
|
||||
max-width: 100%;
|
||||
position: relative;
|
||||
&.rows {
|
||||
flex-direction: row;
|
||||
@@ -134,7 +135,7 @@ body.flexbox {
|
||||
width: 30%;
|
||||
left: 0;
|
||||
height: 100%;
|
||||
overflow-y: scroll;
|
||||
overflow-y: auto;
|
||||
-ms-overflow-style: none;
|
||||
//background-color: $primary-faded;
|
||||
border-left: 1px solid #DDD;
|
||||
@@ -194,6 +195,14 @@ div[class^="col-"] img {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
@include larger-than(991px) {
|
||||
.row.auto-clear .col-md-4:nth-child(3n+1){clear:left;}
|
||||
}
|
||||
|
||||
@include smaller-than(992px) {
|
||||
.row.auto-clear .col-xs-6:nth-child(2n+1){clear:left;}
|
||||
}
|
||||
|
||||
.col-xs-1, .col-sm-1, .col-md-1, .col-lg-1, .col-xs-2, .col-sm-2, .col-md-2, .col-lg-2, .col-xs-3, .col-sm-3, .col-md-3, .col-lg-3, .col-xs-4, .col-sm-4, .col-md-4, .col-lg-4, .col-xs-5, .col-sm-5, .col-md-5, .col-lg-5, .col-xs-6, .col-sm-6, .col-md-6, .col-lg-6, .col-xs-7, .col-sm-7, .col-md-7, .col-lg-7, .col-xs-8, .col-sm-8, .col-md-8, .col-lg-8, .col-xs-9, .col-sm-9, .col-md-9, .col-lg-9, .col-xs-10, .col-sm-10, .col-md-10, .col-lg-10, .col-xs-11, .col-sm-11, .col-md-11, .col-lg-11, .col-xs-12, .col-sm-12, .col-md-12, .col-lg-12 {
|
||||
position: relative;
|
||||
min-height: 1px;
|
||||
|
||||
@@ -82,6 +82,9 @@
|
||||
.h6 {
|
||||
margin-left: $nav-indent*4;
|
||||
}
|
||||
.current-heading {
|
||||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
|
||||
// Sidebar list
|
||||
@@ -373,3 +376,51 @@ ul.pagination {
|
||||
border-bottom: 1px solid #DDD;
|
||||
}
|
||||
}
|
||||
|
||||
// Books grid view
|
||||
.featured-image-container {
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
background: #F2F2F2;
|
||||
border: 1px solid #ddd;
|
||||
border-bottom: 0;
|
||||
img {
|
||||
display: block;
|
||||
max-width: 100%;
|
||||
height: auto;
|
||||
transition: all .5s ease;
|
||||
}
|
||||
img:hover {
|
||||
transform: scale(1.15);
|
||||
opacity: .5;
|
||||
}
|
||||
}
|
||||
|
||||
.book-grid-content {
|
||||
padding: 30px;
|
||||
border: 1px solid #ddd;
|
||||
border-top: 0;
|
||||
border-bottom-width: 2px;
|
||||
h2 {
|
||||
font-size: 1.5em;
|
||||
margin: 0 0 10px;
|
||||
}
|
||||
h2 a {
|
||||
display: block;
|
||||
line-height: 1.2;
|
||||
color: #009688;;
|
||||
text-decoration: none;
|
||||
}
|
||||
p {
|
||||
font-size: .85em;
|
||||
margin: 0 0 10px;
|
||||
line-height: 1.6em;
|
||||
}
|
||||
p.small {
|
||||
font-size: .8em;
|
||||
}
|
||||
}
|
||||
|
||||
.book-grid-item {
|
||||
margin-bottom : 20px;
|
||||
}
|
||||
|
||||
@@ -1,16 +1,13 @@
|
||||
|
||||
|
||||
.mce-tinymce.mce-container.fullscreen {
|
||||
.mce-tinymce.mce-container.mce-fullscreen {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
height: 100%;
|
||||
width: 825px;
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
margin-left: -$-s;
|
||||
box-shadow: 0 0 4px 2px rgba(0, 0, 0, 0.08);
|
||||
z-index: 100;
|
||||
}
|
||||
|
||||
|
||||
.mce-tinymce {
|
||||
.mce-panel {
|
||||
background-color: #FFF;
|
||||
|
||||
@@ -231,7 +231,4 @@ $btt-size: 40px;
|
||||
input {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
114
resources/lang/check.php
Executable file
114
resources/lang/check.php
Executable file
@@ -0,0 +1,114 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Compares translation files to find missing and redundant content.
|
||||
*/
|
||||
|
||||
$args = array_slice($argv, 1);
|
||||
|
||||
if (count($args) === 0) {
|
||||
errorOut("Please provide a language code as the first argument (./check.php fr)");
|
||||
}
|
||||
|
||||
|
||||
// Get content from files
|
||||
$lang = formatLang($args[0]);
|
||||
$enContent = loadLang('en');
|
||||
$langContent = loadLang($lang);
|
||||
|
||||
if (count($langContent) === 0) {
|
||||
errorOut("No language content found for '{$lang}'");
|
||||
}
|
||||
|
||||
info("Checking '{$lang}' translation content against 'en'");
|
||||
|
||||
// Track missing lang strings
|
||||
$missingLangStrings = [];
|
||||
foreach ($enContent as $enKey => $enStr) {
|
||||
if (strpos($enKey, 'settings.language_select.') === 0) {
|
||||
unset($langContent[$enKey]);
|
||||
continue;
|
||||
}
|
||||
if (!isset($langContent[$enKey])) {
|
||||
$missingLangStrings[$enKey] = $enStr;
|
||||
continue;
|
||||
}
|
||||
unset($langContent[$enKey]);
|
||||
}
|
||||
|
||||
if (count($missingLangStrings) > 0) {
|
||||
info("\n========================");
|
||||
info("Missing language content");
|
||||
info("========================");
|
||||
outputFlatArray($missingLangStrings, $lang);
|
||||
}
|
||||
|
||||
if (count($langContent) > 0) {
|
||||
info("\n==========================");
|
||||
info("Redundant language content");
|
||||
info("==========================");
|
||||
outputFlatArray($langContent, $lang);
|
||||
}
|
||||
|
||||
function outputFlatArray($arr, $lang) {
|
||||
$grouped = [];
|
||||
foreach ($arr as $key => $val) {
|
||||
$explodedKey = explode('.', $key);
|
||||
$group = $explodedKey[0];
|
||||
$path = implode('.', array_slice($explodedKey, 1));
|
||||
if (!isset($grouped[$group])) $grouped[$group] = [];
|
||||
$grouped[$group][$path] = $val;
|
||||
}
|
||||
foreach ($grouped as $filename => $arr) {
|
||||
echo "\e[36m" . $lang . '/' . $filename . ".php\e[0m\n";
|
||||
echo json_encode($arr, JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE) . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
function formatLang($lang) {
|
||||
$langParts = explode('_', strtoupper($lang));
|
||||
$langParts[0] = strtolower($langParts[0]);
|
||||
return implode('_', $langParts);
|
||||
}
|
||||
|
||||
function loadLang(string $lang) {
|
||||
$dir = __DIR__ . "/{$lang}";
|
||||
if (!file_exists($dir)) {
|
||||
errorOut("Expected directory '{$dir}' does not exist");
|
||||
}
|
||||
$files = scandir($dir);
|
||||
$data = [];
|
||||
foreach ($files as $file) {
|
||||
if (substr($file, -4) !== '.php') continue;
|
||||
$fileData = include ($dir . '/' . $file);
|
||||
$name = substr($file, 0, -4);
|
||||
$data[$name] = $fileData;
|
||||
}
|
||||
return flattenArray($data);
|
||||
}
|
||||
|
||||
function flattenArray(array $arr) {
|
||||
$data = [];
|
||||
foreach ($arr as $key => $arrItem) {
|
||||
if (!is_array($arrItem)) {
|
||||
$data[$key] = $arrItem;
|
||||
continue;
|
||||
}
|
||||
|
||||
$toUse = flattenArray($arrItem);
|
||||
foreach ($toUse as $innerKey => $item) {
|
||||
$data[$key . '.' . $innerKey] = $item;
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
function info($text) {
|
||||
echo "\e[34m" . $text . "\e[0m\n";
|
||||
}
|
||||
|
||||
function errorOut($text) {
|
||||
echo "\e[31m" . $text . "\e[0m\n";
|
||||
exit(1);
|
||||
}
|
||||
@@ -17,6 +17,8 @@ return [
|
||||
'name' => 'Name',
|
||||
'description' => 'Beschreibung',
|
||||
'role' => 'Rolle',
|
||||
'cover_image' => 'Titelbild',
|
||||
'cover_image_description' => 'Das Bild sollte eine Auflösung von 300x170px haben.',
|
||||
|
||||
/**
|
||||
* Actions
|
||||
@@ -43,7 +45,7 @@ return [
|
||||
'no_items' => 'Keine Einträge gefunden.',
|
||||
'back_to_top' => 'nach oben',
|
||||
'toggle_details' => 'Details zeigen/verstecken',
|
||||
|
||||
'toggle_thumbnails' => 'Thumbnails zeigen/verstecken',
|
||||
/**
|
||||
* Header
|
||||
*/
|
||||
|
||||
@@ -31,6 +31,8 @@ return [
|
||||
'app_logo_desc' => "Dieses Bild sollte 43px hoch sein.\nGrößere Bilder werden verkleinert.",
|
||||
'app_primary_color' => 'Primäre Anwendungsfarbe',
|
||||
'app_primary_color_desc' => "Dies sollte ein HEX Wert sein.\nWenn Sie nicht eingeben, wird die Anwendung auf die Standardfarbe zurückgesetzt.",
|
||||
'app_disable_comments' => 'Kommentare deaktivieren',
|
||||
'app_disable_comments_desc' => 'Deaktiviert Kommentare über alle Seiten in der Anwendung. Vorhandene Kommentare werden nicht angezeigt.',
|
||||
|
||||
/**
|
||||
* Registration settings
|
||||
@@ -96,6 +98,7 @@ return [
|
||||
'users_delete_warning' => 'Der Benutzer ":userName" wird aus dem System gelöscht.',
|
||||
'users_delete_confirm' => 'Sind Sie sicher, dass Sie diesen Benutzer löschen möchten?',
|
||||
'users_delete_success' => 'Benutzer erfolgreich gelöscht.',
|
||||
'users_books_view_type' => 'Bevorzugtes Display-Layout für Bücher',
|
||||
'users_edit' => 'Benutzer bearbeiten',
|
||||
'users_edit_profile' => 'Profil bearbeiten',
|
||||
'users_edit_success' => 'Benutzer erfolgreich aktualisisert',
|
||||
|
||||
@@ -18,7 +18,9 @@ return [
|
||||
'name' => 'Name',
|
||||
'description' => 'Description',
|
||||
'role' => 'Role',
|
||||
|
||||
'cover_image' => 'Cover image',
|
||||
'cover_image_description' => 'This image should be approx 440x250px.',
|
||||
|
||||
/**
|
||||
* Actions
|
||||
*/
|
||||
@@ -45,6 +47,7 @@ return [
|
||||
'no_items' => 'No items available',
|
||||
'back_to_top' => 'Back to top',
|
||||
'toggle_details' => 'Toggle Details',
|
||||
'toggle_thumbnails' => 'Toggle Thumbnails',
|
||||
'details' => 'Details',
|
||||
|
||||
/**
|
||||
|
||||
@@ -20,6 +20,7 @@ return [
|
||||
'ldap_extension_not_installed' => 'LDAP PHP extension not installed',
|
||||
'ldap_cannot_connect' => 'Cannot connect to ldap server, Initial connection failed',
|
||||
'social_no_action_defined' => 'No action defined',
|
||||
'social_login_bad_response' => "Error received during :socialAccount login: \n:error",
|
||||
'social_account_in_use' => 'This :socialAccount account is already in use, Try logging in via the :socialAccount option.',
|
||||
'social_account_email_in_use' => 'The email :email is already in use. If you already have an account you can connect your :socialAccount account from your profile settings.',
|
||||
'social_account_existing' => 'This :socialAccount is already attached to your profile.',
|
||||
@@ -41,6 +42,7 @@ return [
|
||||
|
||||
// Pages
|
||||
'page_draft_autosave_fail' => 'Failed to save draft. Ensure you have internet connection before saving this page',
|
||||
'page_custom_home_deletion' => 'Cannot delete a page while it is set as a homepage',
|
||||
|
||||
// Entities
|
||||
'entity_not_found' => 'Entity not found',
|
||||
|
||||
@@ -34,6 +34,8 @@ return [
|
||||
'app_homepage' => 'Application Homepage',
|
||||
'app_homepage_desc' => 'Select a page to show on the homepage instead of the default view. Page permissions are ignored for selected pages.',
|
||||
'app_homepage_default' => 'Default homepage view chosen',
|
||||
'app_disable_comments' => 'Disable comments',
|
||||
'app_disable_comments_desc' => 'Disable comments across all pages in the application. Existing comments are not shown.',
|
||||
|
||||
/**
|
||||
* Registration settings
|
||||
@@ -94,6 +96,7 @@ return [
|
||||
'users_external_auth_id' => 'External Authentication ID',
|
||||
'users_password_warning' => 'Only fill the below if you would like to change your password:',
|
||||
'users_system_public' => 'This user represents any guest users that visit your instance. It cannot be used to log in but is assigned automatically.',
|
||||
'users_books_view_type' => 'Preferred layout for books viewing',
|
||||
'users_delete' => 'Delete User',
|
||||
'users_delete_named' => 'Delete user :userName',
|
||||
'users_delete_warning' => 'This will fully delete this user with the name \':userName\' from the system.',
|
||||
|
||||
@@ -17,7 +17,8 @@ return [
|
||||
'name' => 'Nombre',
|
||||
'description' => 'Descripción',
|
||||
'role' => 'Rol',
|
||||
|
||||
'cover_image' => 'Imagen de portada',
|
||||
'cover_image_description' => 'Esta imagen debe ser aproximadamente 300x170px.',
|
||||
/**
|
||||
* Actions
|
||||
*/
|
||||
@@ -43,6 +44,7 @@ return [
|
||||
'no_items' => 'No hay items disponibles',
|
||||
'back_to_top' => 'Volver arriba',
|
||||
'toggle_details' => 'Alternar detalles',
|
||||
'toggle_thumbnails' => 'Alternar miniaturas',
|
||||
|
||||
/**
|
||||
* Header
|
||||
|
||||
@@ -31,6 +31,8 @@ return [
|
||||
'app_logo_desc' => 'Esta imagen debería de ser 43px en altura. <br>Iágenes grandes seán escaladas.',
|
||||
'app_primary_color' => 'Color primario de la aplicación',
|
||||
'app_primary_color_desc' => 'Esto debería ser un valor hexadecimal. <br>Deje el valor vaío para reiniciar al valor por defecto.',
|
||||
'app_disable_comments' => 'Deshabilitar comentarios',
|
||||
'app_disable_comments_desc' => 'Deshabilita los comentarios en todas las páginas de la aplicación. Los comentarios existentes no se muestran. ',
|
||||
|
||||
/**
|
||||
* Registration settings
|
||||
@@ -91,6 +93,7 @@ return [
|
||||
'users_external_auth_id' => 'ID externo de autenticación',
|
||||
'users_password_warning' => 'Solo rellene a continuación si desea cambiar su password:',
|
||||
'users_system_public' => 'Este usuario representa cualquier usuario invitado que visita la aplicación. No puede utilizarse para hacer login sio que es asignado automáticamente.',
|
||||
'users_books_view_type' => 'Diseño de pantalla preferido para libros',
|
||||
'users_delete' => 'Borrar usuario',
|
||||
'users_delete_named' => 'Borrar usuario :userName',
|
||||
'users_delete_warning' => 'Se borrará completamente el usuario con el nombre \':userName\' del sistema.',
|
||||
|
||||
@@ -17,7 +17,8 @@ return [
|
||||
'name' => 'Nom',
|
||||
'description' => 'Description',
|
||||
'role' => 'Rôle',
|
||||
|
||||
'cover_image' => 'Image de couverture',
|
||||
'cover_image_description' => 'Cette image doit être environ 300x170px.',
|
||||
/**
|
||||
* Actions
|
||||
*/
|
||||
@@ -43,6 +44,7 @@ return [
|
||||
'no_items' => 'Aucun élément',
|
||||
'back_to_top' => 'Retour en haut',
|
||||
'toggle_details' => 'Afficher les détails',
|
||||
'toggle_thumbnails' => 'Afficher les vignettes',
|
||||
|
||||
/**
|
||||
* Header
|
||||
|
||||
@@ -31,7 +31,8 @@ return [
|
||||
'app_logo_desc' => 'Cette image doit faire 43px de hauteur. <br>Les images plus larges seront réduites.',
|
||||
'app_primary_color' => 'Couleur principale de l\'application',
|
||||
'app_primary_color_desc' => 'Cela devrait être une valeur hexadécimale. <br>Laisser vide pour rétablir la couleur par défaut.',
|
||||
|
||||
'app_disable_comments' => 'Désactiver les commentaires',
|
||||
'app_disable_comments_desc' => 'Désactive les commentaires sur toutes les pages de l\'application. Les commentaires existants ne sont pas affichés.',
|
||||
/**
|
||||
* Registration settings
|
||||
*/
|
||||
@@ -91,6 +92,7 @@ return [
|
||||
'users_external_auth_id' => 'Identifiant d\'authentification externe',
|
||||
'users_password_warning' => 'Remplissez ce fomulaire uniquement si vous souhaitez changer de mot de passe:',
|
||||
'users_system_public' => 'Cet utilisateur représente les invités visitant votre instance. Il est assigné automatiquement aux invités.',
|
||||
'users_books_view_type' => 'Disposition d\'affichage préférée pour les livres',
|
||||
'users_delete' => 'Supprimer un utilisateur',
|
||||
'users_delete_named' => 'Supprimer l\'utilisateur :userName',
|
||||
'users_delete_warning' => 'Ceci va supprimer \':userName\' du système.',
|
||||
|
||||
@@ -37,4 +37,6 @@ return [
|
||||
'book_sort' => 'ha ordinato il libro',
|
||||
'book_sort_notification' => 'Libro Riordinato Correttamente',
|
||||
|
||||
// Other
|
||||
'commented_on' => 'ha commentato in',
|
||||
];
|
||||
|
||||
@@ -29,6 +29,7 @@ return [
|
||||
'edit' => 'Modifica',
|
||||
'sort' => 'Ordina',
|
||||
'move' => 'Muovi',
|
||||
'reply' => 'Rispondi',
|
||||
'delete' => 'Elimina',
|
||||
'search' => 'Cerca',
|
||||
'search_clear' => 'Pulisci Ricerca',
|
||||
|
||||
@@ -19,7 +19,6 @@ return [
|
||||
'meta_created_name' => 'Creato :timeLength da :user',
|
||||
'meta_updated' => 'Aggiornato :timeLength',
|
||||
'meta_updated_name' => 'Aggiornato :timeLength da :user',
|
||||
'x_pages' => ':count Pagine',
|
||||
'entity_select' => 'Selezione Entità',
|
||||
'images' => 'Immagini',
|
||||
'my_recent_drafts' => 'Bozze Recenti',
|
||||
@@ -70,6 +69,7 @@ return [
|
||||
*/
|
||||
'book' => 'Libro',
|
||||
'books' => 'Libri',
|
||||
'x_books' => ':count Libro|:count Libri',
|
||||
'books_empty' => 'Nessun libro è stato creato',
|
||||
'books_popular' => 'Libri Popolari',
|
||||
'books_recent' => 'Libri Recenti',
|
||||
@@ -105,6 +105,7 @@ return [
|
||||
*/
|
||||
'chapter' => 'Capitolo',
|
||||
'chapters' => 'Capitoli',
|
||||
'x_chapters' => ':count Capitolo|:count Capitoli',
|
||||
'chapters_popular' => 'Capitoli Popolari',
|
||||
'chapters_new' => 'Nuovo Capitolo',
|
||||
'chapters_create' => 'Crea un nuovo capitolo',
|
||||
@@ -129,20 +130,21 @@ return [
|
||||
*/
|
||||
'page' => 'Pagina',
|
||||
'pages' => 'Pagine',
|
||||
'x_pages' => ':count Pagina|:count Pagine',
|
||||
'pages_popular' => 'Pagine Popolari',
|
||||
'pages_new' => 'Nuova Pagina',
|
||||
'pages_attachments' => 'Allegati',
|
||||
'pages_navigation' => 'Page Navigation',
|
||||
'pages_navigation' => 'Navigazione Pagine',
|
||||
'pages_delete' => 'Elimina Pagina',
|
||||
'pages_delete_named' => 'Elimina la pagina :pageName',
|
||||
'pages_delete_draft_named' => 'Delete Draft Page :pageName',
|
||||
'pages_delete_draft_named' => 'Elimina bozza della pagina :pageName',
|
||||
'pages_delete_draft' => 'Elimina Bozza Pagina',
|
||||
'pages_delete_success' => 'Pagina eliminata',
|
||||
'pages_delete_draft_success' => 'Bozza di una pagina eliminata',
|
||||
'pages_delete_confirm' => 'Sei sicuro di voler eliminare questa pagina?',
|
||||
'pages_delete_draft_confirm' => 'Sei sicuro di voler eliminare la bozza di questa pagina?',
|
||||
'pages_editing_named' => 'Modifica :pageName',
|
||||
'pages_edit_toggle_header' => 'Toggle header',
|
||||
'pages_edit_toggle_header' => 'Mostra/Nascondi header',
|
||||
'pages_edit_save_draft' => 'Salva Bozza',
|
||||
'pages_edit_draft' => 'Modifica Bozza della pagina',
|
||||
'pages_editing_draft' => 'Modifica Bozza',
|
||||
@@ -164,7 +166,7 @@ return [
|
||||
'pages_move' => 'Muovi Pagina',
|
||||
'pages_move_success' => 'Pagina mossa in ":parentName"',
|
||||
'pages_permissions' => 'Permessi Pagina',
|
||||
'pages_permissions_success' => 'Page permissions updated',
|
||||
'pages_permissions_success' => 'Permessi pagina aggiornati',
|
||||
'pages_revision' => 'Versione',
|
||||
'pages_revisions' => 'Versioni Pagina',
|
||||
'pages_revisions_named' => 'Versioni della pagina :pageName',
|
||||
@@ -242,10 +244,17 @@ return [
|
||||
*/
|
||||
'comment' => 'Commento',
|
||||
'comments' => 'Commenti',
|
||||
'comment_count' => '1 Commento|:count Commenti',
|
||||
'comment_placeholder' => 'Scrivi un commento',
|
||||
'comment_count' => '{0} Nessun Commento|{1} 1 Commento|[2,*] :count Commenti',
|
||||
'comment_save' => 'Salva Commento',
|
||||
'comment_saving' => 'Salvataggio commento...',
|
||||
'comment_deleting' => 'Eliminazione commento...',
|
||||
'comment_new' => 'Nuovo Commento',
|
||||
'comment_created' => 'ha commentato :createDiff',
|
||||
'comment_updated' => 'Aggiornato :updateDiff da :username',
|
||||
'comment_deleted_success' => 'Commento eliminato',
|
||||
'comment_created_success' => 'Commento aggiunto',
|
||||
'comment_updated_success' => 'Commento aggiornato',
|
||||
'comment_delete_confirm' => 'Questo rimuoverà il contenuto del commento?',
|
||||
'comment_delete_confirm' => 'Sei sicuro di voler elminare questo commento?',
|
||||
'comment_in_reply_to' => 'In risposta a :commentId',
|
||||
];
|
||||
@@ -34,11 +34,12 @@ return [
|
||||
'app_homepage' => 'Homepage Applicazione',
|
||||
'app_homepage_desc' => 'Seleziona una pagina da mostrare nella home anzichè quella di default. I permessi della pagina sono ignorati per quella selezionata.',
|
||||
'app_homepage_default' => 'Homepage di default scelta',
|
||||
'app_disable_comments' => 'Disattiva commenti',
|
||||
'app_disable_comments_desc' => 'Disabilita i commenti su tutte le pagine nell\'applicazione. I commenti esistenti non sono mostrati. ',
|
||||
|
||||
/**
|
||||
* Registration settings
|
||||
*/
|
||||
|
||||
'reg_settings' => 'Impostazioni Registrazione',
|
||||
'reg_allow' => 'Consentire Registrazione?',
|
||||
'reg_default_role' => 'Ruolo predefinito dopo la registrazione',
|
||||
|
||||
@@ -17,7 +17,7 @@ return [
|
||||
'name' => '名称',
|
||||
'description' => '概要',
|
||||
'role' => '権限',
|
||||
|
||||
'cover_image_description' => 'この画像は約 300x170px をする必要があります。',
|
||||
/**
|
||||
* Actions
|
||||
*/
|
||||
|
||||
@@ -31,6 +31,8 @@ return [
|
||||
'app_logo_desc' => '高さ43pxで表示されます。これを上回る場合、自動で縮小されます。',
|
||||
'app_primary_color' => 'プライマリカラー',
|
||||
'app_primary_color_desc' => '16進数カラーコードで入力します。空にした場合、デフォルトの色にリセットされます。',
|
||||
'app_disable_comments' => 'コメントを無効にする',
|
||||
'app_disable_comments_desc' => 'アプリケーション内のすべてのページのコメントを無効にします。既存のコメントは表示されません。',
|
||||
|
||||
/**
|
||||
* Registration settings
|
||||
@@ -108,5 +110,5 @@ return [
|
||||
'users_social_disconnect' => 'アカウントを接続解除',
|
||||
'users_social_connected' => '「:socialAccount」がプロフィールに接続されました。',
|
||||
'users_social_disconnected' => '「:socialAccount」がプロフィールから接続解除されました。'
|
||||
|
||||
|
||||
];
|
||||
|
||||
@@ -37,4 +37,6 @@ return [
|
||||
'book_sort' => 'sorteerde boek',
|
||||
'book_sort_notification' => 'Boek Succesvol Gesorteerd',
|
||||
|
||||
// Other
|
||||
'commented_on' => 'reactie op',
|
||||
];
|
||||
|
||||
@@ -10,6 +10,7 @@ return [
|
||||
'save' => 'Opslaan',
|
||||
'continue' => 'Doorgaan',
|
||||
'select' => 'Kies',
|
||||
'more' => 'Meer',
|
||||
|
||||
/**
|
||||
* Form Labels
|
||||
@@ -17,7 +18,8 @@ return [
|
||||
'name' => 'Naam',
|
||||
'description' => 'Beschrijving',
|
||||
'role' => 'Rol',
|
||||
|
||||
'cover_image' => 'Omslagfoto',
|
||||
'cover_image_description' => 'Deze afbeelding moet ongeveer 300x170px zijn.',
|
||||
/**
|
||||
* Actions
|
||||
*/
|
||||
@@ -33,7 +35,7 @@ return [
|
||||
'search_clear' => 'Zoekopdracht wissen',
|
||||
'reset' => 'Reset',
|
||||
'remove' => 'Verwijderen',
|
||||
|
||||
'add' => 'Toevoegen',
|
||||
|
||||
/**
|
||||
* Misc
|
||||
@@ -43,6 +45,7 @@ return [
|
||||
'no_items' => 'Geen items beschikbaar',
|
||||
'back_to_top' => 'Terug naar boven',
|
||||
'toggle_details' => 'Details Weergeven',
|
||||
'toggle_thumbnails' => 'Thumbnails Weergeven',
|
||||
|
||||
/**
|
||||
* Header
|
||||
|
||||
@@ -20,5 +20,12 @@ return [
|
||||
'image_preview' => 'Afbeelding Voorbeeld',
|
||||
'image_upload_success' => 'Afbeelding succesvol geüpload',
|
||||
'image_update_success' => 'Afbeeldingsdetails succesvol verwijderd',
|
||||
'image_delete_success' => 'Afbeelding succesvol verwijderd'
|
||||
];
|
||||
'image_delete_success' => 'Afbeelding succesvol verwijderd',
|
||||
/**
|
||||
* Code editor
|
||||
*/
|
||||
'code_editor' => 'Code invoegen',
|
||||
'code_language' => 'Code taal',
|
||||
'code_content' => 'Code',
|
||||
'code_save' => 'Sla code op',
|
||||
];
|
||||
|
||||
@@ -14,6 +14,7 @@ return [
|
||||
'recent_activity' => 'Recente Activiteit',
|
||||
'create_now' => 'Maak er zelf één',
|
||||
'revisions' => 'Revisies',
|
||||
'meta_revision' => 'Revisie #:revisionCount',
|
||||
'meta_created' => 'Aangemaakt :timeLength',
|
||||
'meta_created_name' => 'Aangemaakt: :timeLength door :user',
|
||||
'meta_updated' => ':timeLength Aangepast',
|
||||
@@ -43,18 +44,37 @@ return [
|
||||
* Search
|
||||
*/
|
||||
'search_results' => 'Zoekresultaten',
|
||||
'search_total_results_found' => ':count resultaten gevonden|:count resultaten gevonden',
|
||||
'search_clear' => 'Zoekopdracht wissen',
|
||||
'search_no_pages' => 'Er zijn geen pagina\'s gevonden',
|
||||
'search_for_term' => 'Zoeken op :term',
|
||||
'search_more' => 'Meer resultaten',
|
||||
'search_filters' => 'Zoek filters',
|
||||
'search_content_type' => 'Content Type',
|
||||
'search_exact_matches' => 'Exacte Matches',
|
||||
'search_tags' => 'Zoek tags',
|
||||
'search_viewed_by_me' => 'Bekeken door mij',
|
||||
'search_not_viewed_by_me' => 'Niet bekeken door mij',
|
||||
'search_permissions_set' => 'Permissies gezet',
|
||||
'search_created_by_me' => 'Door mij gemaakt',
|
||||
'search_updated_by_me' => 'Door mij geupdate',
|
||||
'search_updated_before' => 'Geupdate voor',
|
||||
'search_updated_after' => 'Geupdate na',
|
||||
'search_created_before' => 'Gecreeerd voor',
|
||||
'search_created_after' => 'Gecreeerd na',
|
||||
'search_set_date' => 'Zet datum',
|
||||
'search_update' => 'Update zoekresultaten',
|
||||
|
||||
/**
|
||||
* Books
|
||||
*/
|
||||
'book' => 'Boek',
|
||||
'books' => 'Boeken',
|
||||
'x_books' => ':count Boek|:count Boeken',
|
||||
'books_empty' => 'Er zijn geen boeken aangemaakt',
|
||||
'books_popular' => 'Populaire Boeken',
|
||||
'books_recent' => 'Recente Boeken',
|
||||
'books_new' => 'Nieuwe Boeken',
|
||||
'books_popular_empty' => 'De meest populaire boeken worden hier weergegeven.',
|
||||
'books_create' => 'Nieuw Boek Aanmaken',
|
||||
'books_delete' => 'Boek Verwijderen',
|
||||
@@ -85,6 +105,7 @@ return [
|
||||
*/
|
||||
'chapter' => 'Hoofdstuk',
|
||||
'chapters' => 'Hoofdstukken',
|
||||
'x_chapters' => ':count Hoofdstuk|:count Hoofdstukken',
|
||||
'chapters_popular' => 'Populaire Hoofdstukken',
|
||||
'chapters_new' => 'Nieuw Hoofdstuk',
|
||||
'chapters_create' => 'Hoofdstuk Toevoegen',
|
||||
@@ -103,12 +124,14 @@ return [
|
||||
'chapters_empty' => 'Er zijn geen pagina\'s in dit hoofdstuk aangemaakt.',
|
||||
'chapters_permissions_active' => 'Hoofdstuk Permissies Actief',
|
||||
'chapters_permissions_success' => 'Hoofdstuk Permissies Bijgewerkt',
|
||||
'chapters_search_this' => 'Doorzoek dit hoofdstuk',
|
||||
|
||||
/**
|
||||
* Pages
|
||||
*/
|
||||
'page' => 'Pagina',
|
||||
'pages' => 'Pagina\'s',
|
||||
'x_pages' => ':count Pagina|:count Pagina\'s',
|
||||
'pages_popular' => 'Populaire Pagina\'s',
|
||||
'pages_new' => 'Nieuwe Pagina',
|
||||
'pages_attachments' => 'Bijlages',
|
||||
@@ -122,7 +145,7 @@ return [
|
||||
'pages_delete_confirm' => 'Weet je zeker dat je deze pagina wilt verwijderen?',
|
||||
'pages_delete_draft_confirm' => 'Weet je zeker dat je dit concept wilt verwijderen?',
|
||||
'pages_editing_named' => 'Pagina :pageName Bewerken',
|
||||
'pages_edit_toggle_header' => 'Toggle header',
|
||||
'pages_edit_toggle_header' => 'Wissel header',
|
||||
'pages_edit_save_draft' => 'Concept opslaan',
|
||||
'pages_edit_draft' => 'Paginaconcept Bewerken',
|
||||
'pages_editing_draft' => 'Concept Bewerken',
|
||||
@@ -132,12 +155,12 @@ return [
|
||||
'pages_edit_discard_draft' => 'Concept Verwijderen',
|
||||
'pages_edit_set_changelog' => 'Changelog',
|
||||
'pages_edit_enter_changelog_desc' => 'Geef een korte omschrijving van de wijzingen die je gemaakt hebt.',
|
||||
'pages_edit_enter_changelog' => 'Enter Changelog',
|
||||
'pages_edit_enter_changelog' => 'Zie logboek',
|
||||
'pages_save' => 'Pagina Opslaan',
|
||||
'pages_title' => 'Pagina Titel',
|
||||
'pages_name' => 'Pagina Naam',
|
||||
'pages_md_editor' => 'Bewerker',
|
||||
'pages_md_preview' => 'Preview',
|
||||
'pages_md_preview' => 'Voorbeeld',
|
||||
'pages_md_insert_image' => 'Afbeelding Invoegen',
|
||||
'pages_md_insert_link' => 'Entity Link Invoegen',
|
||||
'pages_not_in_chapter' => 'Deze pagina staat niet in een hoofdstuk',
|
||||
@@ -145,11 +168,13 @@ return [
|
||||
'pages_move_success' => 'Pagina verplaatst naar ":parentName"',
|
||||
'pages_permissions' => 'Pagina Permissies',
|
||||
'pages_permissions_success' => 'Pagina Permissies bijgwerkt',
|
||||
'pages_revision' => 'Revisie',
|
||||
'pages_revisions' => 'Pagina Revisies',
|
||||
'pages_revisions_named' => 'Pagina Revisies voor :pageName',
|
||||
'pages_revision_named' => 'Pagina Revisie voor :pageName',
|
||||
'pages_revisions_created_by' => 'Aangemaakt door',
|
||||
'pages_revisions_date' => 'Revisiedatum',
|
||||
'pages_revisions_number' => '#',
|
||||
'pages_revisions_changelog' => 'Changelog',
|
||||
'pages_revisions_changes' => 'Wijzigingen',
|
||||
'pages_revisions_current' => 'Huidige Versie',
|
||||
|
||||
@@ -60,6 +60,12 @@ return [
|
||||
'role_system_cannot_be_deleted' => 'Dit is een systeemrol en kan niet verwijderd worden',
|
||||
'role_registration_default_cannot_delete' => 'Deze rol kan niet verwijerd worden zolang dit de standaardrol na registratie is.',
|
||||
|
||||
// Comments
|
||||
'comment_list' => 'Er is een fout opgetreden tijdens het ophalen van de reacties.',
|
||||
'cannot_add_comment_to_draft' => 'U kunt geen reacties toevoegen aan een concept.',
|
||||
'comment_add' => 'Er is een fout opgetreden tijdens het toevoegen van de reactie.',
|
||||
'comment_delete' => 'Er is een fout opgetreden tijdens het verwijderen van de reactie.',
|
||||
'empty_comment' => 'Kan geen lege reactie toevoegen.',
|
||||
// Error pages
|
||||
'404_page_not_found' => 'Pagina Niet Gevonden',
|
||||
'sorry_page_not_found' => 'Sorry, de pagina die je zocht is niet beschikbaar.',
|
||||
@@ -67,11 +73,4 @@ return [
|
||||
'error_occurred' => 'Er Ging Iets Fout',
|
||||
'app_down' => ':appName is nu niet beschikbaar',
|
||||
'back_soon' => 'Komt snel weer online.',
|
||||
|
||||
// Comments
|
||||
'comment_list' => 'Er is een fout opgetreden tijdens het ophalen van de reacties.',
|
||||
'cannot_add_comment_to_draft' => 'U kunt geen reacties toevoegen aan een ontwerp.',
|
||||
'comment_add' => 'Er is een fout opgetreden tijdens het toevoegen van de reactie.',
|
||||
'comment_delete' => 'Er is een fout opgetreden tijdens het verwijderen van de reactie.',
|
||||
'empty_comment' => 'Kan geen lege reactie toevoegen.',
|
||||
];
|
||||
@@ -31,6 +31,8 @@ return [
|
||||
'app_logo_desc' => 'De afbeelding moet 43px hoog zijn. <br>Grotere afbeeldingen worden geschaald.',
|
||||
'app_primary_color' => 'Applicatie hoofdkleur',
|
||||
'app_primary_color_desc' => 'Geef een hexadecimale waarde. <br>Als je niks invult wordt de standaardkleur gebruikt.',
|
||||
'app_disable_comments' => 'Reacties uitschakelen',
|
||||
'app_disable_comments_desc' => 'Schakel opmerkingen uit op alle pagina\'s in de applicatie. Bestaande opmerkingen worden niet getoond.',
|
||||
|
||||
/**
|
||||
* Registration settings
|
||||
@@ -91,6 +93,7 @@ return [
|
||||
'users_external_auth_id' => 'External Authentication ID',
|
||||
'users_password_warning' => 'Vul onderstaande formulier alleen in als je het wachtwoord wilt aanpassen:',
|
||||
'users_system_public' => 'De eigenschappen van deze gebruiker worden voor elke gastbezoeker gebruikt. Er kan niet mee ingelogd worden en wordt automatisch toegewezen.',
|
||||
'users_books_view_type' => 'Voorkeursuitleg voor het weergeven van boeken',
|
||||
'users_delete' => 'Verwijder gebruiker',
|
||||
'users_delete_named' => 'Verwijder gebruiker :userName',
|
||||
'users_delete_warning' => 'Dit zal de gebruiker \':userName\' volledig uit het systeem verwijderen.',
|
||||
|
||||
@@ -17,7 +17,9 @@ return [
|
||||
'name' => 'Nazwa',
|
||||
'description' => 'Opis',
|
||||
'role' => 'Rola',
|
||||
|
||||
'cover_image' => 'Zdjęcie z okładki',
|
||||
'cover_image_description' => 'Ten obraz powinien wynosić około 300 x 170 piksli.',
|
||||
|
||||
/**
|
||||
* Actions
|
||||
*/
|
||||
|
||||
@@ -31,6 +31,8 @@ return [
|
||||
'app_logo_desc' => 'Ten obrazek powinien mieć nie więcej niż 43px w pionie. <br>Większe obrazki będą skalowane w dół.',
|
||||
'app_primary_color' => 'Podstawowy kolor aplikacji',
|
||||
'app_primary_color_desc' => 'To powinna być wartość HEX. <br>Zostaw to pole puste, by powrócić do podstawowego koloru.',
|
||||
'app_disable_comments' => 'Wyłącz komentarze',
|
||||
'app_disable_comments_desc' => 'Wyłącz komentarze na wszystkich stronach w aplikacji. Istniejące komentarze nie są pokazywane.',
|
||||
|
||||
/**
|
||||
* Registration settings
|
||||
|
||||
@@ -36,5 +36,7 @@ return [
|
||||
'book_delete_notification' => 'Livro excluído com sucesso',
|
||||
'book_sort' => 'livro classificado',
|
||||
'book_sort_notification' => 'Livro reclassificado com sucesso',
|
||||
|
||||
|
||||
// Other
|
||||
'commented_on' => 'comentou em',
|
||||
];
|
||||
|
||||
@@ -18,6 +18,8 @@ return [
|
||||
*/
|
||||
'sign_up' => 'Registrar-se',
|
||||
'log_in' => 'Entrar',
|
||||
'log_in_with' => 'Entrar com :socialDriver',
|
||||
'sign_up_with' => 'Registrar com :socialDriver',
|
||||
'logout' => 'Sair',
|
||||
|
||||
'name' => 'Nome',
|
||||
|
||||
@@ -10,6 +10,7 @@ return [
|
||||
'save' => 'Salvar',
|
||||
'continue' => 'Continuar',
|
||||
'select' => 'Selecionar',
|
||||
'more' => 'Mais',
|
||||
|
||||
/**
|
||||
* Form Labels
|
||||
@@ -17,7 +18,8 @@ return [
|
||||
'name' => 'Nome',
|
||||
'description' => 'Descrição',
|
||||
'role' => 'Regra',
|
||||
|
||||
'cover_image' => 'Imagem de capa',
|
||||
'cover_image_description' => 'Esta imagem deve ser aproximadamente 300x170px.',
|
||||
/**
|
||||
* Actions
|
||||
*/
|
||||
@@ -28,12 +30,13 @@ return [
|
||||
'edit' => 'Editar',
|
||||
'sort' => 'Ordenar',
|
||||
'move' => 'Mover',
|
||||
'reply' => 'Responder',
|
||||
'delete' => 'Excluir',
|
||||
'search' => 'Pesquisar',
|
||||
'search_clear' => 'Limpar Pesquisa',
|
||||
'reset' => 'Resetar',
|
||||
'remove' => 'Remover',
|
||||
|
||||
'add' => 'Adicionar',
|
||||
|
||||
/**
|
||||
* Misc
|
||||
@@ -43,6 +46,8 @@ return [
|
||||
'no_items' => 'Nenhum item disponível',
|
||||
'back_to_top' => 'Voltar ao topo',
|
||||
'toggle_details' => 'Alternar Detalhes',
|
||||
'toggle_thumbnails' => 'Alternar Miniaturas',
|
||||
'details' => 'Detalhes',
|
||||
|
||||
/**
|
||||
* Header
|
||||
|
||||
@@ -20,5 +20,13 @@ return [
|
||||
'image_preview' => 'Virtualização de Imagem',
|
||||
'image_upload_success' => 'Upload de imagem efetuado com sucesso',
|
||||
'image_update_success' => 'Upload de detalhes da imagem efetuado com sucesso',
|
||||
'image_delete_success' => 'Imagem excluída com sucesso'
|
||||
'image_delete_success' => 'Imagem excluída com sucesso',
|
||||
|
||||
/**
|
||||
* Code editor
|
||||
*/
|
||||
'code_editor' => 'Editar Código',
|
||||
'code_language' => 'Linguagem do Código',
|
||||
'code_content' => 'Código',
|
||||
'code_save' => 'Salvar Código',
|
||||
];
|
||||
@@ -14,11 +14,11 @@ return [
|
||||
'recent_activity' => 'Atividade recente',
|
||||
'create_now' => 'Criar um agora',
|
||||
'revisions' => 'Revisões',
|
||||
'meta_revision' => 'Revisão #:revisionCount',
|
||||
'meta_created' => 'Criado em :timeLength',
|
||||
'meta_created_name' => 'Criado em :timeLength por :user',
|
||||
'meta_updated' => 'Atualizado em :timeLength',
|
||||
'meta_updated_name' => 'Atualizado em :timeLength por :user',
|
||||
'x_pages' => ':count Páginas',
|
||||
'entity_select' => 'Seleção de Entidade',
|
||||
'images' => 'Imagens',
|
||||
'my_recent_drafts' => 'Meus rascunhos recentes',
|
||||
@@ -43,19 +43,39 @@ return [
|
||||
* Search
|
||||
*/
|
||||
'search_results' => 'Resultado(s) da Pesquisa',
|
||||
'search_total_results_found' => ':count resultado encontrado|:count resultados encontrados',
|
||||
'search_clear' => 'Limpar Pesquisa',
|
||||
'search_no_pages' => 'Nenhuma página corresponde à pesquisa',
|
||||
'search_for_term' => 'Pesquisar por :term',
|
||||
'search_more' => 'Mais Resultados',
|
||||
'search_filters' => 'Filtros de Pesquisa',
|
||||
'search_content_type' => 'Tipo de Conteúdo',
|
||||
'search_exact_matches' => 'Correspondências Exatas',
|
||||
'search_tags' => 'Tags',
|
||||
'search_viewed_by_me' => 'Visto por mim',
|
||||
'search_not_viewed_by_me' => 'Não visto por mim',
|
||||
'search_permissions_set' => 'Permissão definida',
|
||||
'search_created_by_me' => 'Criado por mim',
|
||||
'search_updated_by_me' => 'Atualizado por mim',
|
||||
'search_updated_before' => 'Atualizado antes de',
|
||||
'search_updated_after' => 'Atualizado depois de',
|
||||
'search_created_before' => 'Criado antes de',
|
||||
'search_created_after' => 'Criado depois de',
|
||||
'search_set_date' => 'Definir data',
|
||||
'search_update' => 'Refazer Pesquisa',
|
||||
|
||||
/**
|
||||
* Books
|
||||
*/
|
||||
'book' => 'Livro',
|
||||
'books' => 'Livros',
|
||||
'x_books' => ':count Livro|:count Livros',
|
||||
'books_empty' => 'Nenhum livro foi criado',
|
||||
'books_popular' => 'Livros populares',
|
||||
'books_recent' => 'Livros recentes',
|
||||
'books_new' => 'Livros novos',
|
||||
'books_popular_empty' => 'Os livros mais populares aparecerão aqui.',
|
||||
'books_new_empty' => 'Os livros criados mais recentemente aparecerão aqui.',
|
||||
'books_create' => 'Criar novo Livro',
|
||||
'books_delete' => 'Excluir Livro',
|
||||
'books_delete_named' => 'Excluir Livro :bookName',
|
||||
@@ -83,18 +103,18 @@ return [
|
||||
/**
|
||||
* Chapters
|
||||
*/
|
||||
'chapter' => 'Capitulo',
|
||||
'chapter' => 'Capítulo',
|
||||
'chapters' => 'Capítulos',
|
||||
'x_chapters' => ':count Capítulo|:count Capítulos',
|
||||
'chapters_popular' => 'Capítulos Populares',
|
||||
'chapters_new' => 'Novo Capítulo',
|
||||
'chapters_create' => 'Criar novo Capítulo',
|
||||
'chapters_delete' => 'Excluír Capítulo',
|
||||
'chapters_delete_named' => 'Excluir Capítulo :chapterName',
|
||||
'chapters_delete_explain' => 'A ação vai excluír o capítulo de nome \':chapterName\'. Todas as páginas do capítulo serão removidas
|
||||
e adicionadas diretamente ao livro pai.',
|
||||
'chapters_delete_confirm' => 'Tem certeza que deseja excluír o capitulo?',
|
||||
'chapters_delete_explain' => 'A ação vai excluír o capítulo de nome \':chapterName\'. Todas as páginas do capítulo serão removidas e adicionadas diretamente ao livro pai.',
|
||||
'chapters_delete_confirm' => 'Tem certeza que deseja excluír o capítulo?',
|
||||
'chapters_edit' => 'Editar Capítulo',
|
||||
'chapters_edit_named' => 'Editar capitulo :chapterName',
|
||||
'chapters_edit_named' => 'Editar capítulo :chapterName',
|
||||
'chapters_save' => 'Salvar Capítulo',
|
||||
'chapters_move' => 'Mover Capítulo',
|
||||
'chapters_move_named' => 'Mover Capítulo :chapterName',
|
||||
@@ -103,12 +123,14 @@ return [
|
||||
'chapters_empty' => 'Nenhuma página existente nesse capítulo.',
|
||||
'chapters_permissions_active' => 'Permissões de Capítulo ativadas',
|
||||
'chapters_permissions_success' => 'Permissões de Capítulo atualizadas',
|
||||
'chapters_search_this' => 'Pesquisar este Capítulo',
|
||||
|
||||
/**
|
||||
* Pages
|
||||
*/
|
||||
'page' => 'Página',
|
||||
'pages' => 'Páginas',
|
||||
'x_pages' => ':count Página|:count Páginas',
|
||||
'pages_popular' => 'Páginas Popular',
|
||||
'pages_new' => 'Nova Página',
|
||||
'pages_attachments' => 'Anexos',
|
||||
@@ -145,11 +167,13 @@ return [
|
||||
'pages_move_success' => 'Pagina movida para ":parentName"',
|
||||
'pages_permissions' => 'Permissões de Página',
|
||||
'pages_permissions_success' => 'Permissões de Página atualizadas',
|
||||
'pages_revision' => 'Revisão',
|
||||
'pages_revisions' => 'Revisões de Página',
|
||||
'pages_revisions_named' => 'Revisões de Página para :pageName',
|
||||
'pages_revision_named' => 'Revisão de Página para :pageName',
|
||||
'pages_revisions_created_by' => 'Criado por',
|
||||
'pages_revisions_date' => 'Data da Revisão',
|
||||
'pages_revisions_number' => '#',
|
||||
'pages_revisions_changelog' => 'Changelog',
|
||||
'pages_revisions_changes' => 'Mudanças',
|
||||
'pages_revisions_current' => 'Versão atual',
|
||||
@@ -218,8 +242,19 @@ return [
|
||||
/**
|
||||
* Comments
|
||||
*/
|
||||
'comentário' => 'Comentário',
|
||||
'comentários' => 'Comentários',
|
||||
'comment' => 'Comentário',
|
||||
'comments' => 'Comentários',
|
||||
'comment_placeholder' => 'Digite seus comentários aqui',
|
||||
'comment_count' => '{0} Nenhum comentário|{1} 1 Comentário|[2,*] :count Comentários',
|
||||
'comment_save' => 'Salvar comentário',
|
||||
'comment_saving' => 'Salvando comentário...',
|
||||
'comment_deleting' => 'Removendo comentário...',
|
||||
'comment_new' => 'Novo comentário',
|
||||
'comment_created' => 'comentado :createDiff',
|
||||
'comment_updated' => 'Editado :updateDiff por :username',
|
||||
'comment_deleted_success' => 'Comentário removido',
|
||||
'comment_created_success' => 'Comentário adicionado',
|
||||
'comment_updated_success' => 'Comentário editado',
|
||||
'comment_delete_confirm' => 'Você tem certeza de que quer deletar este comentário?',
|
||||
'comment_in_reply_to' => 'Em resposta à :commentId',
|
||||
];
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user