From 4b390ea536ad5faa69c6e833e70175c22f8e10be Mon Sep 17 00:00:00 2001 From: Miguel Nogueira Date: Sat, 11 Jul 2020 05:34:12 +0100 Subject: [PATCH] Added full Vacancy description Also added support for Markdown --- app/Http/Controllers/VacancyController.php | 4 + app/Http/Requests/VacancyRequest.php | 1 + app/Vacancy.php | 1 + composer.json | 1 + composer.lock | 69 +++++++- config/app.php | 5 +- config/markdown.php | 158 ++++++++++++++++++ ...43_add_detailed_description_to_vacancy.php | 32 ++++ .../administration/positions.blade.php | 3 + resources/views/dashboard/dashboard.blade.php | 34 +++- resources/views/home.blade.php | 37 ++++ 11 files changed, 342 insertions(+), 3 deletions(-) create mode 100644 config/markdown.php create mode 100644 database/migrations/2020_07_11_020743_add_detailed_description_to_vacancy.php diff --git a/app/Http/Controllers/VacancyController.php b/app/Http/Controllers/VacancyController.php index 1b6bafd..3863932 100644 --- a/app/Http/Controllers/VacancyController.php +++ b/app/Http/Controllers/VacancyController.php @@ -8,10 +8,13 @@ use App\User; use App\Form; use App\Notifications\VacancyClosed; +use GrahamCampbell\Markdown\Facades\Markdown; + use Illuminate\Http\Request; use Illuminate\Support\Str; use Illuminate\Support\Facades\Auth; + class VacancyController extends Controller { public function index() @@ -35,6 +38,7 @@ class VacancyController extends Controller 'vacancyName' => $request->vacancyName, 'vacancyDescription' => $request->vacancyDescription, + 'vacancyFullDescription' => Markdown::convertToHTML($request->vacancyFullDescription), 'vacancySlug' => Str::slug($request->vacancyName), 'permissionGroupName' => $request->permissionGroup, 'discordRoleID' => $request->discordRole, diff --git a/app/Http/Requests/VacancyRequest.php b/app/Http/Requests/VacancyRequest.php index 02e22b3..176610d 100644 --- a/app/Http/Requests/VacancyRequest.php +++ b/app/Http/Requests/VacancyRequest.php @@ -26,6 +26,7 @@ class VacancyRequest extends FormRequest return [ 'vacancyName' => 'required|string', 'vacancyDescription' => 'required|string', + 'vacancyFullDescription' => 'nullable|string', 'permissionGroup' => 'required|string', 'discordRole' => 'required|string', 'vacancyCount' => 'required|integer', diff --git a/app/Vacancy.php b/app/Vacancy.php index 8f4995d..5029bdf 100644 --- a/app/Vacancy.php +++ b/app/Vacancy.php @@ -13,6 +13,7 @@ class Vacancy extends Model 'permissionGroupName', 'vacancyName', 'vacancyDescription', + 'vacancyFullDescription', 'discordRoleID', 'vacancyFormID', 'vacancyCount', diff --git a/composer.json b/composer.json index 060fcea..b36fdd9 100644 --- a/composer.json +++ b/composer.json @@ -15,6 +15,7 @@ "fideloper/proxy": "^4.2", "fruitcake/laravel-cors": "^1.0", "geo-sot/laravel-env-editor": "^0.9.9", + "graham-campbell/markdown": "^12.0", "guzzlehttp/guzzle": "^6.5", "jeroennoten/laravel-adminlte": "^3.2", "laravel/framework": "^7.0", diff --git a/composer.lock b/composer.lock index bbe774f..38beddb 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "16e8efbacd91ef3417b21bd2648e1629", + "content-hash": "51429857899e8134bbe6b4fa61145cc3", "packages": [ { "name": "almasaeed2010/adminlte", @@ -1091,6 +1091,73 @@ ], "time": "2020-04-17T23:33:36+00:00" }, + { + "name": "graham-campbell/markdown", + "version": "v12.0.2", + "source": { + "type": "git", + "url": "https://github.com/GrahamCampbell/Laravel-Markdown.git", + "reference": "584eb9f24004238b80ee98b6e7be82f0933554dd" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/GrahamCampbell/Laravel-Markdown/zipball/584eb9f24004238b80ee98b6e7be82f0933554dd", + "reference": "584eb9f24004238b80ee98b6e7be82f0933554dd", + "shasum": "" + }, + "require": { + "illuminate/contracts": "^6.0|^7.0", + "illuminate/support": "^6.0|^7.0", + "illuminate/view": "^6.0|^7.0", + "league/commonmark": "^1.3", + "php": "^7.2.5" + }, + "require-dev": { + "graham-campbell/analyzer": "^3.0", + "graham-campbell/testbench": "^5.4", + "mockery/mockery": "^1.3.1", + "phpunit/phpunit": "^8.5|^9.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "12.0-dev" + }, + "laravel": { + "providers": [ + "GrahamCampbell\\Markdown\\MarkdownServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "GrahamCampbell\\Markdown\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Graham Campbell", + "email": "graham@alt-three.com" + } + ], + "description": "Markdown Is A CommonMark Wrapper For Laravel", + "keywords": [ + "Graham Campbell", + "GrahamCampbell", + "Laravel Markdown", + "Laravel-Markdown", + "common mark", + "commonmark", + "framework", + "laravel", + "markdown" + ], + "time": "2020-04-14T16:14:52+00:00" + }, { "name": "guzzlehttp/guzzle", "version": "6.5.4", diff --git a/config/app.php b/config/app.php index 7b466ca..06583d1 100644 --- a/config/app.php +++ b/config/app.php @@ -164,7 +164,9 @@ return [ /* * Package Service Providers... + */ + GrahamCampbell\Markdown\MarkdownServiceProvider::class, /* * Application Service Providers... @@ -230,7 +232,8 @@ return [ 'Validator' => Illuminate\Support\Facades\Validator::class, 'View' => Illuminate\Support\Facades\View::class, 'UUID' => App\Facades\UUID::class, - 'IP' => App\Facades\IP::class + 'IP' => App\Facades\IP::class, + 'Markdown' => GrahamCampbell\Markdown\Facades\Markdown::class, ], diff --git a/config/markdown.php b/config/markdown.php new file mode 100644 index 0000000..6408d6f --- /dev/null +++ b/config/markdown.php @@ -0,0 +1,158 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +return [ + + /* + |-------------------------------------------------------------------------- + | Enable View Integration + |-------------------------------------------------------------------------- + | + | This option specifies if the view integration is enabled so you can write + | markdown views and have them rendered as html. The following extensions + | are currently supported: ".md", ".md.php", and ".md.blade.php". You may + | disable this integration if it is conflicting with another package. + | + | Default: true + | + */ + + 'views' => true, + + /* + |-------------------------------------------------------------------------- + | CommonMark Extensions + |-------------------------------------------------------------------------- + | + | This option specifies what extensions will be automatically enabled. + | Simply provide your extension class names here. + | + | Default: [] + | + */ + + 'extensions' => [], + + /* + |-------------------------------------------------------------------------- + | Renderer Configuration + |-------------------------------------------------------------------------- + | + | This option specifies an array of options for rendering HTML. + | + | Default: [ + | 'block_separator' => "\n", + | 'inner_separator' => "\n", + | 'soft_break' => "\n", + | ] + | + */ + + 'renderer' => [ + 'block_separator' => "\n", + 'inner_separator' => "\n", + 'soft_break' => "\n", + ], + + /* + |-------------------------------------------------------------------------- + | Enable Em Tag Parsing + |-------------------------------------------------------------------------- + | + | This option specifies if `` parsing is enabled. + | + | Default: true + | + */ + + 'enable_em' => true, + + /* + |-------------------------------------------------------------------------- + | Enable Strong Tag Parsing + |-------------------------------------------------------------------------- + | + | This option specifies if `` parsing is enabled. + | + | Default: true + | + */ + + 'enable_strong' => true, + + /* + |-------------------------------------------------------------------------- + | Enable Asterisk Parsing + |-------------------------------------------------------------------------- + | + | This option specifies if `*` should be parsed for emphasis. + | + | Default: true + | + */ + + 'use_asterisk' => true, + + /* + |-------------------------------------------------------------------------- + | Enable Underscore Parsing + |-------------------------------------------------------------------------- + | + | This option specifies if `_` should be parsed for emphasis. + | + | Default: true + | + */ + + 'use_underscore' => true, + + /* + |-------------------------------------------------------------------------- + | HTML Input + |-------------------------------------------------------------------------- + | + | This option specifies how to handle untrusted HTML input. + | + | Default: 'strip' + | + */ + + 'html_input' => 'strip', + + /* + |-------------------------------------------------------------------------- + | Allow Unsafe Links + |-------------------------------------------------------------------------- + | + | This option specifies whether to allow risky image URLs and links. + | + | Default: true + | + */ + + 'allow_unsafe_links' => false, + + /* + |-------------------------------------------------------------------------- + | Maximum Nesting Level + |-------------------------------------------------------------------------- + | + | This option specifies the maximum permitted block nesting level. + | + | Default: INF + | + */ + + 'max_nesting_level' => INF, + +]; diff --git a/database/migrations/2020_07_11_020743_add_detailed_description_to_vacancy.php b/database/migrations/2020_07_11_020743_add_detailed_description_to_vacancy.php new file mode 100644 index 0000000..d049d3f --- /dev/null +++ b/database/migrations/2020_07_11_020743_add_detailed_description_to_vacancy.php @@ -0,0 +1,32 @@ +longText('vacancyFullDescription')->nullable()->after('vacancyDescription'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('vacancies', function (Blueprint $table) { + $table->dropColumn('vacancyFullDescription'); + }); + } +} diff --git a/resources/views/dashboard/administration/positions.blade.php b/resources/views/dashboard/administration/positions.blade.php index 15d4f54..3323750 100644 --- a/resources/views/dashboard/administration/positions.blade.php +++ b/resources/views/dashboard/administration/positions.blade.php @@ -55,6 +55,9 @@ + + + Markdown supported
diff --git a/resources/views/dashboard/dashboard.blade.php b/resources/views/dashboard/dashboard.blade.php index 61f7de1..ff0274c 100644 --- a/resources/views/dashboard/dashboard.blade.php +++ b/resources/views/dashboard/dashboard.blade.php @@ -14,6 +14,38 @@ @section('content') + @if (!$vacancies->isEmpty()) + + @foreach($vacancies as $vacancy) + + + + @if (is_null($vacancy->vacancyFullDescription)) + +
+ +

There don't seem to be any details

+

+ This vacancy does not have any details yet. +

+ +
+ @else + + {!! $vacancy->vacancyFullDescription !!} +

+ Last updated @ {{ $vacancy->updated_at }} +

+ @endif + + + +
+ + @endforeach + + @endif +
@@ -190,7 +222,7 @@
diff --git a/resources/views/home.blade.php b/resources/views/home.blade.php index c5b0e8b..b25bce9 100644 --- a/resources/views/home.blade.php +++ b/resources/views/home.blade.php @@ -2,6 +2,42 @@ @section('content') + @if(!$positions->isEmpty()) + + + + + @foreach($positions as $position) + + + + @if (is_null($position->vacancyFullDescription)) + +
+ +

There don't seem to be any details

+

+ This opening does not have any details yet. +

+ +
+ @else + + {!! $position->vacancyFullDescription !!} +

+ Last updated @ {{ $position->updated_at }} +

+ @endif + + + +
+ + @endforeach + + + @endif +
@@ -57,6 +93,7 @@ @guest + @endguest