From 3ccfa0e7fc58451f71022c443e6393d8f70ae915 Mon Sep 17 00:00:00 2001 From: Dan Brown Date: Mon, 30 Jan 2017 19:31:24 +0000 Subject: [PATCH 1/4] Fixed readme badge links & added contributing block --- readme.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index 63d43e4b7..65dcbe7b1 100644 --- a/readme.md +++ b/readme.md @@ -1,7 +1,7 @@ # BookStack -[![GitHub release](https://img.shields.io/github/release/ssddanbrown/BookStack.svg?maxAge=2592000)](https://github.com/ssddanbrown/BookStack/releases/latest) -[![license](https://img.shields.io/github/license/ssddanbrown/BookStack.svg?maxAge=2592000)](https://github.com/ssddanbrown/BookStack/blob/master/LICENSE) +[![GitHub release](https://img.shields.io/github/release/BookStackApp/BookStack.svg?maxAge=2592000)](https://github.com/BookStackApp/BookStack/releases/latest) +[![license](https://img.shields.io/github/license/BookStackApp/BookStack.svg?maxAge=2592000)](https://github.com/BookStackApp/BookStack/blob/master/LICENSE) [![Build Status](https://travis-ci.org/BookStackApp/BookStack.svg)](https://travis-ci.org/BookStackApp/BookStack) A platform for storing and organising information and documentation. General information and documentation for BookStack can be found at https://www.bookstackapp.com/. @@ -45,6 +45,12 @@ 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`. 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 + +Feel free to create issues to request new features or to report bugs and problems. Just please follow the template given when creating the issue. + +Pull requests are very welcome. If the scope of your pull request is very large it may be best to open the pull request early or create an issue for it to discuss how it will fit in to the project and plan out the merge. ## Website, Docs & Blog From 9eecaea31a0f9a5f79bdf7792838e956174a3e71 Mon Sep 17 00:00:00 2001 From: Dan Brown Date: Wed, 1 Feb 2017 22:16:32 +0000 Subject: [PATCH 2/4] Attempt to fix bookchildren and user getThumb Hopefully Fixes #292 and #294 and #287 --- app/Repos/EntityRepo.php | 4 ++-- app/User.php | 2 +- composer.json | 4 +++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/Repos/EntityRepo.php b/app/Repos/EntityRepo.php index f1428735c..8a8740d76 100644 --- a/app/Repos/EntityRepo.php +++ b/app/Repos/EntityRepo.php @@ -332,12 +332,12 @@ class EntityRepo $parents[$key] = $entities[$index]; $parents[$key]->setAttribute('pages', collect()); } - if ($entities[$index]->chapter_id === 0) $tree[] = $entities[$index]; + if ($entities[$index]->chapter_id === 0 || $entities[$index]->chapter_id === '0') $tree[] = $entities[$index]; $entities[$index]->book = $book; } foreach ($entities as $entity) { - if ($entity->chapter_id === 0) continue; + if ($entity->chapter_id === 0 || $entity->chapter_id === '0') continue; $parentKey = 'BookStack\\Chapter:' . $entity->chapter_id; $chapter = $parents[$parentKey]; $chapter->pages->push($entity); diff --git a/app/User.php b/app/User.php index afcd9af70..8033557e4 100644 --- a/app/User.php +++ b/app/User.php @@ -165,7 +165,7 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon if ($imageId === 0 || $imageId === '0' || $imageId === null) return $default; try { - $avatar = baseUrl($this->avatar->getThumb($size, $size, false)); + $avatar = $this->avatar ? baseUrl($this->avatar->getThumb($size, $size, false)) : $default; } catch (\Exception $err) { $avatar = $default; } diff --git a/composer.json b/composer.json index 5a8fd67ae..8d963022c 100644 --- a/composer.json +++ b/composer.json @@ -47,7 +47,9 @@ ], "post-install-cmd": [ "Illuminate\\Foundation\\ComposerScripts::postInstall", - "php artisan optimize" + "php artisan optimize", + "php artisan cache:clear", + "php artisan view:clear" ], "post-update-cmd": [ "Illuminate\\Foundation\\ComposerScripts::postUpdate", From 80f844139c0fe8a9ec00c44ea90a95830c2eb27b Mon Sep 17 00:00:00 2001 From: Dan Brown Date: Wed, 1 Feb 2017 22:20:44 +0000 Subject: [PATCH 3/4] Fixed missing subscript styling Closes #284 --- resources/assets/sass/_text.scss | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/resources/assets/sass/_text.scss b/resources/assets/sass/_text.scss index 74eb6875a..aac4298ea 100644 --- a/resources/assets/sass/_text.scss +++ b/resources/assets/sass/_text.scss @@ -119,6 +119,11 @@ sup, .superscript { font-size: 0.8em; } +sub, .subscript { + vertical-align: sub; + font-size: 0.8em; +} + pre { font-family: monospace; white-space:pre; From 076693efc9705937464f29b134397abd1040d821 Mon Sep 17 00:00:00 2001 From: Dan Brown Date: Sat, 4 Feb 2017 11:01:49 +0000 Subject: [PATCH 4/4] Added facebook, slack & twitter sign in options. Also added icon svg blade helper. Closes #125. Starts #213. Requires documentation. --- app/Providers/AppServiceProvider.php | 4 ++ app/Providers/EventServiceProvider.php | 5 +- app/Providers/SocialiteServiceProvider.php | 36 ---------- app/Services/SocialAuthService.php | 3 +- app/helpers.php | 12 +++- composer.json | 3 +- composer.lock | 83 +++++++++++++++++++++- config/app.php | 2 +- config/services.php | 18 +++++ resources/assets/icons/facebook.svg | 1 + resources/assets/icons/github.svg | 1 + resources/assets/icons/google.svg | 1 + resources/assets/icons/slack.svg | 1 + resources/assets/icons/twitter.svg | 1 + resources/assets/sass/_text.scss | 10 ++- resources/views/auth/login.blade.php | 10 ++- resources/views/auth/register.blade.php | 10 ++- resources/views/public.blade.php | 4 +- resources/views/users/edit.blade.php | 24 ++----- 19 files changed, 150 insertions(+), 79 deletions(-) delete mode 100644 app/Providers/SocialiteServiceProvider.php create mode 100644 resources/assets/icons/facebook.svg create mode 100644 resources/assets/icons/github.svg create mode 100644 resources/assets/icons/google.svg create mode 100644 resources/assets/icons/slack.svg create mode 100644 resources/assets/icons/twitter.svg diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 40a1eef3d..118271f51 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -17,6 +17,10 @@ class AppServiceProvider extends ServiceProvider $imageMimes = ['image/png', 'image/bmp', 'image/gif', 'image/jpeg', 'image/jpg', 'image/tiff', 'image/webp']; return in_array($value->getMimeType(), $imageMimes); }); + + \Blade::directive('icon', function($expression) { + return ""; + }); } /** diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php index 3802f20c0..d82a560f9 100644 --- a/app/Providers/EventServiceProvider.php +++ b/app/Providers/EventServiceProvider.php @@ -4,6 +4,7 @@ namespace BookStack\Providers; use Illuminate\Contracts\Events\Dispatcher as DispatcherContract; use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider; +use SocialiteProviders\Manager\SocialiteWasCalled; class EventServiceProvider extends ServiceProvider { @@ -13,8 +14,8 @@ class EventServiceProvider extends ServiceProvider * @var array */ protected $listen = [ - 'BookStack\Events\SomeEvent' => [ - 'BookStack\Listeners\EventListener', + SocialiteWasCalled::class => [ + 'SocialiteProviders\Slack\SlackExtendSocialite@handle', ], ]; diff --git a/app/Providers/SocialiteServiceProvider.php b/app/Providers/SocialiteServiceProvider.php deleted file mode 100644 index f7fb30f81..000000000 --- a/app/Providers/SocialiteServiceProvider.php +++ /dev/null @@ -1,36 +0,0 @@ -app->bindShared('Laravel\Socialite\Contracts\Factory', function ($app) { - return new SocialiteManager($app); - }); - } - - /** - * Get the services provided by the provider. - * - * @return array - */ - public function provides() - { - return ['Laravel\Socialite\Contracts\Factory']; - } -} \ No newline at end of file diff --git a/app/Services/SocialAuthService.php b/app/Services/SocialAuthService.php index 5edd4cad7..710f95696 100644 --- a/app/Services/SocialAuthService.php +++ b/app/Services/SocialAuthService.php @@ -14,7 +14,7 @@ class SocialAuthService protected $socialite; protected $socialAccount; - protected $validSocialDrivers = ['google', 'github']; + protected $validSocialDrivers = ['google', 'github', 'facebook', 'slack', 'twitter']; /** * SocialAuthService constructor. @@ -211,7 +211,6 @@ class SocialAuthService */ public function detachSocialAccount($socialDriver) { - session(); user()->socialAccounts()->where('driver', '=', $socialDriver)->delete(); session()->flash('success', trans('settings.users_social_disconnected', ['socialAccount' => title_case($socialDriver)])); return redirect(user()->getEditUrl()); diff --git a/app/helpers.php b/app/helpers.php index 6decb08e9..8103ad1ff 100644 --- a/app/helpers.php +++ b/app/helpers.php @@ -117,6 +117,16 @@ function redirect($to = null, $status = 302, $headers = [], $secure = null) return app('redirect')->to($to, $status, $headers, $secure); } +function icon($name, $attrs = []) { + $iconPath = resource_path('assets/icons/' . $name . '.svg'); + $attrString = ' '; + foreach ($attrs as $attrName => $attr) { + $attrString .= $attrName . '="' . $attr . '" '; + } + $fileContents = file_get_contents($iconPath); + return str_replace(' env('APP_URL') . '/login/service/google/callback', ], + 'slack' => [ + 'client_id' => env('SLACK_APP_ID', false), + 'client_secret' => env('SLACK_APP_SECRET', false), + 'redirect' => env('APP_URL') . '/login/service/slack/callback', + ], + + 'facebook' => [ + 'client_id' => env('FACEBOOK_APP_ID', false), + 'client_secret' => env('FACEBOOK_APP_SECRET', false), + 'redirect' => env('APP_URL') . '/login/service/facebook/callback', + ], + + 'twitter' => [ + 'client_id' => env('TWITTER_APP_ID', false), + 'client_secret' => env('TWITTER_APP_SECRET', false), + 'redirect' => env('APP_URL') . '/login/service/twitter/callback', + ], + 'ldap' => [ 'server' => env('LDAP_SERVER', false), 'dn' => env('LDAP_DN', false), diff --git a/resources/assets/icons/facebook.svg b/resources/assets/icons/facebook.svg new file mode 100644 index 000000000..7bfafd226 --- /dev/null +++ b/resources/assets/icons/facebook.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/resources/assets/icons/github.svg b/resources/assets/icons/github.svg new file mode 100644 index 000000000..ae6dc6f7f --- /dev/null +++ b/resources/assets/icons/github.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/resources/assets/icons/google.svg b/resources/assets/icons/google.svg new file mode 100644 index 000000000..34ed1603b --- /dev/null +++ b/resources/assets/icons/google.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/resources/assets/icons/slack.svg b/resources/assets/icons/slack.svg new file mode 100644 index 000000000..5280f971f --- /dev/null +++ b/resources/assets/icons/slack.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/resources/assets/icons/twitter.svg b/resources/assets/icons/twitter.svg new file mode 100644 index 000000000..fa4d59efd --- /dev/null +++ b/resources/assets/icons/twitter.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/resources/assets/sass/_text.scss b/resources/assets/sass/_text.scss index aac4298ea..79d3c3a92 100644 --- a/resources/assets/sass/_text.scss +++ b/resources/assets/sass/_text.scss @@ -16,7 +16,7 @@ h2 { } h3 { font-size: 2.333em; - line-height: 1.571428572em; + line-height: 1.221428572em; margin-top: 0.78571429em; margin-bottom: 0.43137255em; } @@ -71,6 +71,13 @@ a, .link { padding-right: 0; padding-left: $-s; } + &.icon { + display: inline-block; + } + svg { + position: relative; + display: inline-block; + } } /* @@ -84,7 +91,6 @@ p, ul, ol, pre, table, blockquote { hr { border: 0; height: 1px; - border: 0; background: #EAEAEA; margin-bottom: $-l; &.faded { diff --git a/resources/views/auth/login.blade.php b/resources/views/auth/login.blade.php index 928565156..6c8b1720c 100644 --- a/resources/views/auth/login.blade.php +++ b/resources/views/auth/login.blade.php @@ -33,12 +33,10 @@ @if(count($socialDrivers) > 0)

{{ trans('auth.social_login') }}

- @if(isset($socialDrivers['google'])) - - @endif - @if(isset($socialDrivers['github'])) - - @endif + @foreach($socialDrivers as $driver => $enabled) + @icon($driver, ['width' => 56]) +   + @endforeach @endif diff --git a/resources/views/auth/register.blade.php b/resources/views/auth/register.blade.php index 7a119ddba..860508df0 100644 --- a/resources/views/auth/register.blade.php +++ b/resources/views/auth/register.blade.php @@ -37,12 +37,10 @@

{{ trans('auth.social_registration') }}

{{ trans('auth.social_registration_text') }}

- @if(isset($socialDrivers['google'])) - - @endif - @if(isset($socialDrivers['github'])) - - @endif + @foreach($socialDrivers as $driver => $enabled) + @icon($driver, ['width' => 56]) +   + @endforeach @endif diff --git a/resources/views/public.blade.php b/resources/views/public.blade.php index 05cf043fd..ea2069b86 100644 --- a/resources/views/public.blade.php +++ b/resources/views/public.blade.php @@ -30,7 +30,7 @@