Merge pull request #136 from GrahamForks/markdown

Use a better markdown solution
This commit is contained in:
James Brooks
2014-12-30 13:07:40 +00:00
5 changed files with 111 additions and 12 deletions
+2
View File
@@ -124,6 +124,7 @@ return [
'Dingo\Api\Provider\ApiServiceProvider',
'GrahamCampbell\Throttle\ThrottleServiceProvider',
'GrahamCampbell\Markdown\MarkdownServiceProvider',
'Thujohn\Rss\RssServiceProvider',
'CachetHQ\Cachet\Support\ServiceProviders\RepositoryServiceProvider',
@@ -199,6 +200,7 @@ return [
'API' => 'Dingo\Api\Facade\API',
'Throttle' => 'GrahamCampbell\Throttle\Facades\Throttle',
'Markdown' => 'GrahamCampbell\Markdown\Facades\Markdown',
'RSS' => 'Thujohn\Rss\RssFacade',
],
@@ -0,0 +1,35 @@
<?php
/*
* This file is part of Laravel Markdown by Graham Campbell.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://bit.ly/UWsjkb.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
return [
/*
|--------------------------------------------------------------------------
| Enable The Engines
|--------------------------------------------------------------------------
|
| This option specifies if the view engines are enabled so you can write
| markdown views and have them compiled into html. The following extensions
| are currently supported: ".md", ".md.php", and ".md.blade.php". You may
| disable the engines if they are conflicting with another package.
|
| Default: true
|
*/
'engines' => false,
];
+14 -9
View File
@@ -1,11 +1,12 @@
<?php
use Dingo\Api\Transformer\TransformableInterface;
use Illuminate\Database\Eloquent\SoftDeletingTrait;
use Watson\Validating\ValidatingTrait;
class Incident extends Eloquent implements \Dingo\Api\Transformer\TransformableInterface
class Incident extends Eloquent implements TransformableInterface
{
use ValidatingTrait;
use Illuminate\Database\Eloquent\SoftDeletingTrait;
use SoftDeletingTrait, ValidatingTrait;
protected $rules = [
'user_id' => 'required|integer',
@@ -21,7 +22,8 @@ class Incident extends Eloquent implements \Dingo\Api\Transformer\TransformableI
/**
* An incident belongs to a component.
* @return Illuminate\Database\Eloquent\Relations\BelongsTo
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function component()
{
@@ -30,6 +32,7 @@ class Incident extends Eloquent implements \Dingo\Api\Transformer\TransformableI
/**
* Returns a human readable version of the status.
*
* @return string
*/
public function getHumanStatusAttribute()
@@ -41,6 +44,7 @@ class Incident extends Eloquent implements \Dingo\Api\Transformer\TransformableI
/**
* Finds the icon to use for each status.
*
* @return string
*/
public function getIconAttribute()
@@ -55,18 +59,18 @@ class Incident extends Eloquent implements \Dingo\Api\Transformer\TransformableI
/**
* Returns a Markdown formatted version of the status.
*
* @return string
*/
public function getFormattedMessageAttribute()
{
$parseDown = new ParsedownExtra();
return $parseDown->text($this->message);
return Markdown::render($this->message);
}
/**
* Get the transformer instance.
* @return CachetHQ\Cachet\Transformers\IncidentTransformer
*
* @return \CachetHQ\Cachet\Transformers\IncidentTransformer
*/
public function getTransformer()
{
@@ -75,7 +79,8 @@ class Incident extends Eloquent implements \Dingo\Api\Transformer\TransformableI
/**
* Check if Incident has message.
* @return boolean
*
* @return bool
*/
public function hasMessage()
{