Skip to content

Commit a08d80e

Browse files
committed
Merge branch 'master' into release
2 parents 6258175 + b711bc6 commit a08d80e

40 files changed

+918
-817
lines changed

.github/ISSUE_TEMPLATE.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,18 @@ Desired Feature:
44

55
### For Bug Reports
66

7-
* BookStack Version:
7+
* BookStack Version *(Found in settings, Please don't put 'latest')*:
88
* PHP Version:
99
* MySQL Version:
1010

1111
##### Expected Behavior
1212

13-
##### Actual Behavior
13+
14+
15+
##### Current Behavior
16+
17+
18+
19+
##### Steps to Reproduce
20+
21+

app/Console/Commands/RegenerateSearch.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class RegenerateSearch extends Command
1919
*
2020
* @var string
2121
*/
22-
protected $description = 'Command description';
22+
protected $description = 'Re-index all content for searching';
2323

2424
protected $searchService;
2525

app/Http/Kernel.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ class Kernel extends HttpKernel
1313
*/
1414
protected $middleware = [
1515
\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
16-
\Illuminate\Session\Middleware\StartSession::class,
17-
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
16+
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
17+
\BookStack\Http\Middleware\TrimStrings::class,
1818
];
1919

2020
/**
@@ -26,6 +26,8 @@ class Kernel extends HttpKernel
2626
'web' => [
2727
\BookStack\Http\Middleware\EncryptCookies::class,
2828
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
29+
\Illuminate\Session\Middleware\StartSession::class,
30+
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
2931
\BookStack\Http\Middleware\VerifyCsrfToken::class,
3032
\Illuminate\Routing\Middleware\SubstituteBindings::class,
3133
\BookStack\Http\Middleware\Localization::class
@@ -42,7 +44,7 @@ class Kernel extends HttpKernel
4244
* @var array
4345
*/
4446
protected $routeMiddleware = [
45-
'can' => \Illuminate\Auth\Middleware\Authorize::class,
47+
'can' => \Illuminate\Auth\Middleware\Authorize::class,
4648
'auth' => \BookStack\Http\Middleware\Authenticate::class,
4749
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
4850
'guest' => \BookStack\Http\Middleware\RedirectIfAuthenticated::class,
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace BookStack\Http\Middleware;
4+
5+
use Illuminate\Foundation\Http\Middleware\TrimStrings as BaseTrimmer;
6+
7+
class TrimStrings extends BaseTrimmer
8+
{
9+
/**
10+
* The names of the attributes that should not be trimmed.
11+
*
12+
* @var array
13+
*/
14+
protected $except = [
15+
'password',
16+
'password_confirmation',
17+
'password-confirm',
18+
];
19+
}

app/Providers/EventServiceProvider.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ class EventServiceProvider extends ServiceProvider
1616
protected $listen = [
1717
SocialiteWasCalled::class => [
1818
'SocialiteProviders\Slack\SlackExtendSocialite@handle',
19+
'SocialiteProviders\Azure\AzureExtendSocialite@handle',
1920
],
2021
];
2122

app/Services/SearchService.php

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -382,11 +382,13 @@ public function deleteEntityTerms(Entity $entity)
382382
protected function generateTermArrayFromText($text, $scoreAdjustment = 1)
383383
{
384384
$tokenMap = []; // {TextToken => OccurrenceCount}
385-
$splitText = explode(' ', $text);
386-
foreach ($splitText as $token) {
387-
if ($token === '') continue;
385+
$splitChars = " \n\t.,";
386+
$token = strtok($text, $splitChars);
387+
388+
while ($token !== false) {
388389
if (!isset($tokenMap[$token])) $tokenMap[$token] = 0;
389390
$tokenMap[$token]++;
391+
$token = strtok($splitChars);
390392
}
391393

392394
$terms = [];
@@ -479,4 +481,23 @@ protected function filterNotViewedByMe(\Illuminate\Database\Eloquent\Builder $qu
479481
});
480482
}
481483

484+
protected function filterSortBy(\Illuminate\Database\Eloquent\Builder $query, Entity $model, $input)
485+
{
486+
$functionName = camel_case('sort_by_' . $input);
487+
if (method_exists($this, $functionName)) $this->$functionName($query, $model);
488+
}
489+
490+
491+
/**
492+
* Sorting filter options
493+
*/
494+
495+
protected function sortByLastCommented(\Illuminate\Database\Eloquent\Builder $query, Entity $model)
496+
{
497+
$commentsTable = $this->db->getTablePrefix() . 'comments';
498+
$morphClass = str_replace('\\', '\\\\', $model->getMorphClass());
499+
$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');
500+
501+
$query->join($commentQuery, $model->getTable() . '.id', '=', 'comments.entity_id')->orderBy('last_commented', 'desc');
502+
}
482503
}

app/Services/SocialAuthService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class SocialAuthService
1414
protected $socialite;
1515
protected $socialAccount;
1616

17-
protected $validSocialDrivers = ['google', 'github', 'facebook', 'slack', 'twitter'];
17+
protected $validSocialDrivers = ['google', 'github', 'facebook', 'slack', 'twitter', 'azure'];
1818

1919
/**
2020
* SocialAuthService constructor.

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
"gathercontent/htmldiff": "^0.2.1",
1919
"barryvdh/laravel-snappy": "^0.3.1",
2020
"laravel/browser-kit-testing": "^1.0",
21-
"socialiteproviders/slack": "^3.0"
21+
"socialiteproviders/slack": "^3.0",
22+
"socialiteproviders/microsoft-azure": "^3.0"
2223
},
2324
"require-dev": {
2425
"fzaninotto/faker": "~1.4",

composer.lock

Lines changed: 39 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/services.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,14 @@
7272
'name' => 'Twitter',
7373
],
7474

75+
'azure' => [
76+
'client_id' => env('AZURE_APP_ID', false),
77+
'client_secret' => env('AZURE_APP_SECRET', false),
78+
'tenant' => env('AZURE_TENANT', false),
79+
'redirect' => env('APP_URL') . '/login/service/azure/callback',
80+
'name' => 'Microsoft Azure',
81+
],
82+
7583
'ldap' => [
7684
'server' => env('LDAP_SERVER', false),
7785
'dn' => env('LDAP_DN', false),

0 commit comments

Comments
 (0)