Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 02ac560
Showing
320 changed files
with
30,377 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
APP_ENV=local | ||
APP_KEY= | ||
APP_DEBUG=true | ||
APP_LOG_LEVEL=debug | ||
APP_URL=http://localhost | ||
|
||
DB_CONNECTION=mysql | ||
DB_HOST=127.0.0.1 | ||
DB_PORT=3306 | ||
DB_DATABASE= | ||
DB_USERNAME= | ||
DB_PASSWORD= | ||
|
||
BROADCAST_DRIVER=log | ||
CACHE_DRIVER=file | ||
SESSION_DRIVER=file | ||
QUEUE_DRIVER=sync | ||
|
||
REDIS_HOST=127.0.0.1 | ||
REDIS_PASSWORD=null | ||
REDIS_PORT=6379 | ||
|
||
MAIL_DRIVER=smtp | ||
MAIL_HOST= | ||
MAIL_PORT= | ||
MAIL_USERNAME= | ||
MAIL_PASSWORD= | ||
MAIL_ENCRYPTION= | ||
MAIL_FROM=Example | ||
MAIL_NAME=Example | ||
|
||
PUSHER_KEY= | ||
PUSHER_SECRET= | ||
PUSHER_APP_ID= | ||
|
||
GITHUB_CLIENT_ID= | ||
GITHUB_CLIENT_SECRET= | ||
GITHUB_REDIRECT= | ||
|
||
YOUDAO_API_KEY= | ||
YOUDAO_KEY_FROM= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
* text=auto | ||
*.css linguist-vendored | ||
*.scss linguist-vendored |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/node_modules | ||
/public/storage | ||
/vendor | ||
/.idea | ||
Homestead.json | ||
Homestead.yaml | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2016 Jiajian Chan | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
<?php | ||
|
||
namespace App; | ||
|
||
use App\Scopes\DraftScope; | ||
use App\Services\Markdowner; | ||
use Illuminate\Database\Eloquent\Model; | ||
use Illuminate\Database\Eloquent\SoftDeletes; | ||
|
||
class Article extends Model | ||
{ | ||
use SoftDeletes; | ||
|
||
/** | ||
* The attributes that should be mutated to dates. | ||
* | ||
* @var array | ||
*/ | ||
protected $dates = ['published_at', 'created_at', 'deleted_at']; | ||
|
||
/** | ||
* The attributes that are mass assignable. | ||
* | ||
* @var array | ||
*/ | ||
protected $fillable = [ | ||
'user_id', | ||
'last_user_id', | ||
'category_id', | ||
'title', | ||
'subtitle', | ||
'slug', | ||
'page_image', | ||
'content', | ||
'meta_description', | ||
'is_draft', | ||
'is_original', | ||
'published_at', | ||
]; | ||
|
||
/** | ||
* The "booting" method of the model. | ||
* | ||
* @return void | ||
*/ | ||
public static function boot() | ||
{ | ||
parent::boot(); | ||
|
||
static::addGlobalScope(new DraftScope()); | ||
} | ||
|
||
/** | ||
* Get the user for the blog article. | ||
* | ||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo | ||
*/ | ||
public function user() | ||
{ | ||
return $this->belongsTo(User::class); | ||
} | ||
|
||
/** | ||
* Get the category for the blog article. | ||
* | ||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo | ||
*/ | ||
public function category() | ||
{ | ||
return $this->belongsTo(Category::class); | ||
} | ||
|
||
/** | ||
* Get the tags for the blog article. | ||
* | ||
* @return \Illuminate\Database\Eloquent\Relations\morphToMany | ||
*/ | ||
public function tags() | ||
{ | ||
return $this->morphToMany(Tag::class, 'taggable'); | ||
} | ||
|
||
/** | ||
* Get the comments for the discussion. | ||
* | ||
* @return \Illuminate\Database\Eloquent\Relations\morphMany | ||
*/ | ||
public function comments() | ||
{ | ||
return $this->morphMany(Comment::class, 'commentable'); | ||
} | ||
|
||
/** | ||
* Get the config for the configuration. | ||
* | ||
* @return \Illuminate\Database\Eloquent\Relations\morphMany | ||
*/ | ||
public function config() | ||
{ | ||
return $this->morphMany(Configuration::class, 'configuration'); | ||
} | ||
|
||
/** | ||
* Get the created at attribute. | ||
* | ||
* @param $value | ||
* @return string | ||
*/ | ||
public function getCreatedAtAttribute($value) | ||
{ | ||
return \Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $value)->diffForHumans(); | ||
} | ||
|
||
/** | ||
* Set the title and the readable slug. | ||
* | ||
* @param string $value | ||
*/ | ||
public function setTitleAttribute($value) | ||
{ | ||
$this->attributes['title'] = $value; | ||
|
||
if (!config('services.youdao.key') || !config('services.youdao.from')) { | ||
$this->setUniqueSlug($value, ''); | ||
} else { | ||
$this->attributes['slug'] = translug($value); | ||
} | ||
} | ||
|
||
/** | ||
* Set the unique slug. | ||
* | ||
* @param $value | ||
* @param $extra | ||
*/ | ||
public function setUniqueSlug($value, $extra) { | ||
$slug = str_slug($value.'-'.$extra); | ||
if (static::whereSlug($slug)->exists()) { | ||
$this->setUniqueSlug($slug, $extra+1); | ||
return; | ||
} | ||
$this->attributes['slug'] = $slug; | ||
} | ||
|
||
/** | ||
* Set the content attribute. | ||
* | ||
* @param $value | ||
*/ | ||
public function setContentAttribute($value) | ||
{ | ||
$data = [ | ||
'raw' => $value, | ||
'html' => (new Markdowner)->convertMarkdownToHtml($value) | ||
]; | ||
|
||
$this->attributes['content'] = json_encode($data); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
namespace App; | ||
|
||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class Category extends Model | ||
{ | ||
/** | ||
* The attributes that are mass assignable. | ||
* | ||
* @var array | ||
*/ | ||
protected $fillable = [ | ||
'parent_id', 'name', 'path', 'description' | ||
]; | ||
|
||
/** | ||
* Get the articles for the category. | ||
* | ||
* @return \Illuminate\Database\Eloquent\Relations\HasMany | ||
*/ | ||
public function articles() | ||
{ | ||
return $this->hasMany(Article::Class); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?php | ||
|
||
namespace App; | ||
|
||
use App\Services\Mention; | ||
use App\Services\Markdowner; | ||
use Illuminate\Database\Eloquent\Model; | ||
use Illuminate\Database\Eloquent\SoftDeletes; | ||
|
||
class Comment extends Model | ||
{ | ||
use SoftDeletes; | ||
|
||
/** | ||
* The attributes that are mass assignable. | ||
* | ||
* @var array | ||
*/ | ||
protected $fillable = [ | ||
'user_id', 'commentable_id', 'commentable_type', 'content' | ||
]; | ||
|
||
/** | ||
* The attributes that should be mutated to dates. | ||
* | ||
* @var array | ||
*/ | ||
protected $dates = ['deleted_at']; | ||
|
||
/** | ||
* Get the user for the discussion comment. | ||
* | ||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo | ||
*/ | ||
public function user() | ||
{ | ||
return $this->belongsTo(User::class); | ||
} | ||
|
||
/** | ||
* Get all of the owning commentable models. | ||
* | ||
* @return \Illuminate\Database\Eloquent\Relations\morphTo | ||
*/ | ||
public function commentable() | ||
{ | ||
return $this->morphTo(); | ||
} | ||
|
||
/** | ||
* Set the content Attribute. | ||
* | ||
* @param $value | ||
*/ | ||
public function setContentAttribute($value) | ||
{ | ||
$content = (new Mention)->parse($value); | ||
|
||
$data = [ | ||
'raw' => $content, | ||
'html' => (new Markdowner)->convertMarkdownToHtml($content) | ||
]; | ||
|
||
$this->attributes['content'] = json_encode($data); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
|
||
namespace App\Console\Commands; | ||
|
||
use Illuminate\Console\Command; | ||
|
||
class BlogInstall extends Command | ||
{ | ||
/** | ||
* The name and signature of the console command. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'blog:install'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Install the blog'; | ||
|
||
/** | ||
* Create a new command instance. | ||
* | ||
* @return void | ||
*/ | ||
public function __construct() | ||
{ | ||
parent::__construct(); | ||
} | ||
|
||
/** | ||
* Execute the console command. | ||
* | ||
* @return mixed | ||
*/ | ||
public function handle() | ||
{ | ||
$this->execShellWithPrettyPrint('php artisan key:generate'); | ||
$this->execShellWithPrettyPrint('php artisan migrate --seed'); | ||
$this->execShellWithPrettyPrint('php artisan passport:install'); | ||
} | ||
|
||
/** | ||
* Exec sheel with pretty print. | ||
* | ||
* @param string $command | ||
* @return mixed | ||
*/ | ||
public function execShellWithPrettyPrint($command) | ||
{ | ||
$this->info('---'); | ||
$this->info($command); | ||
$output = shell_exec($command); | ||
$this->info($output); | ||
$this->info('---'); | ||
} | ||
} |
Oops, something went wrong.
02ac560
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you