Skip to content

Commit a78c8e4

Browse files
committed
Merge branch 'release/0.1.0'
2 parents 1223022 + 545be85 commit a78c8e4

File tree

343 files changed

+42837
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

343 files changed

+42837
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.DS_Store

app.dockerfile

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM php:7.1.12-fpm
2+
3+
RUN apt-get update && apt-get install -y libmcrypt-dev \
4+
mysql-client libmagickwand-dev --no-install-recommends curl nano \
5+
&& pecl install imagick \
6+
&& docker-php-ext-enable imagick \
7+
&& docker-php-ext-install \
8+
zip xml gd \
9+
mcrypt pdo_mysql

application/.babelrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"presets": ["es2015", "stage-2"]
3+
}

application/.editorconfig

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 4
6+
end_of_line = lf
7+
charset = utf-8
8+
trim_trailing_whitespace = true
9+
insert_final_newline = false
10+
11+
[*.{vue,js,scss}]
12+
charset = utf-8
13+
indent_style = space
14+
indent_size = 2
15+
end_of_line = lf
16+
insert_final_newline = true
17+
trim_trailing_whitespace = true
18+
19+
[*.md]
20+
trim_trailing_whitespace = false

application/.env.example

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
APP_ENV=local
2+
APP_KEY=
3+
APP_DEBUG=true
4+
APP_LOG_LEVEL=debug
5+
APP_URL=http://localhost
6+
7+
DB_CONNECTION=mysql
8+
DB_HOST=127.0.0.1
9+
DB_PORT=3306
10+
DB_DATABASE=homestead
11+
DB_USERNAME=homestead
12+
DB_PASSWORD=secret
13+
14+
BROADCAST_DRIVER=log
15+
CACHE_DRIVER=file
16+
SESSION_DRIVER=file
17+
QUEUE_DRIVER=sync
18+
19+
REDIS_HOST=127.0.0.1
20+
REDIS_PASSWORD=null
21+
REDIS_PORT=6379
22+
23+
MAIL_DRIVER=smtp
24+
MAIL_HOST=
25+
MAIL_PORT=
26+
MAIL_USERNAME=
27+
MAIL_PASSWORD=
28+
MAIL_ENCRYPTION=
29+
MAIL_FROM=Example
30+
MAIL_NAME=Example
31+
32+
PUSHER_APP_ID=
33+
PUSHER_APP_KEY=
34+
PUSHER_APP_SECRET=
35+
36+
GITHUB_CLIENT_ID=
37+
GITHUB_CLIENT_SECRET=
38+
GITHUB_REDIRECT=
39+
40+
YOUDAO_APP_KEY=
41+
YOUDAO_APP_SECRET=

application/.gitattributes

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
* text=auto
2+
*.css linguist-vendored
3+
*.scss linguist-vendored

application/.gitignore

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/node_modules
2+
/public/storage
3+
/vendor
4+
/.idea
5+
Homestead.json
6+
Homestead.yaml
7+
.env
8+
/public/css
9+
/public/js
10+
/public/fonts
11+
/public/mix-manifest.json
12+
npm-debug.log

application/LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2016 Jiajian Chan
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

application/app/Article.php

+165
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
<?php
2+
3+
namespace App;
4+
5+
use App\Scopes\DraftScope;
6+
use App\Tools\Markdowner;
7+
use Illuminate\Database\Eloquent\Model;
8+
use Illuminate\Database\Eloquent\SoftDeletes;
9+
10+
class Article extends Model
11+
{
12+
use SoftDeletes;
13+
14+
/**
15+
* The attributes that should be mutated to dates.
16+
*
17+
* @var array
18+
*/
19+
protected $dates = ['published_at', 'created_at', 'deleted_at'];
20+
21+
/**
22+
* The attributes that are mass assignable.
23+
*
24+
* @var array
25+
*/
26+
protected $fillable = [
27+
'user_id',
28+
'last_user_id',
29+
'category_id',
30+
'title',
31+
'subtitle',
32+
'slug',
33+
'page_image',
34+
'content',
35+
'meta_description',
36+
'is_draft',
37+
'is_original',
38+
'published_at',
39+
];
40+
41+
protected $casts = [
42+
'content' => 'array'
43+
];
44+
45+
/**
46+
* The "booting" method of the model.
47+
*
48+
* @return void
49+
*/
50+
public static function boot()
51+
{
52+
parent::boot();
53+
54+
static::addGlobalScope(new DraftScope());
55+
}
56+
57+
/**
58+
* Get the user for the blog article.
59+
*
60+
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
61+
*/
62+
public function user()
63+
{
64+
return $this->belongsTo(User::class);
65+
}
66+
67+
/**
68+
* Get the category for the blog article.
69+
*
70+
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
71+
*/
72+
public function category()
73+
{
74+
return $this->belongsTo(Category::class);
75+
}
76+
77+
/**
78+
* Get the tags for the blog article.
79+
*
80+
* @return \Illuminate\Database\Eloquent\Relations\morphToMany
81+
*/
82+
public function tags()
83+
{
84+
return $this->morphToMany(Tag::class, 'taggable');
85+
}
86+
87+
/**
88+
* Get the comments for the discussion.
89+
*
90+
* @return \Illuminate\Database\Eloquent\Relations\morphMany
91+
*/
92+
public function comments()
93+
{
94+
return $this->morphMany(Comment::class, 'commentable');
95+
}
96+
97+
/**
98+
* Get the config for the configuration.
99+
*
100+
* @return \Illuminate\Database\Eloquent\Relations\morphMany
101+
*/
102+
public function config()
103+
{
104+
return $this->morphMany(Configuration::class, 'configuration');
105+
}
106+
107+
/**
108+
* Get the created at attribute.
109+
*
110+
* @param $value
111+
* @return string
112+
*/
113+
public function getCreatedAtAttribute($value)
114+
{
115+
return \Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $value)->diffForHumans();
116+
}
117+
118+
/**
119+
* Set the title and the readable slug.
120+
*
121+
* @param string $value
122+
*/
123+
public function setTitleAttribute($value)
124+
{
125+
$this->attributes['title'] = $value;
126+
127+
if (!config('services.youdao.appKey') || !config('services.youdao.appSecret')) {
128+
$this->setUniqueSlug($value, str_random(5));
129+
} else {
130+
$this->setUniqueSlug(translug($value), '');
131+
}
132+
}
133+
134+
/**
135+
* Set the unique slug.
136+
*
137+
* @param $value
138+
* @param $extra
139+
*/
140+
public function setUniqueSlug($value, $extra) {
141+
$slug = str_slug($value.'-'.$extra);
142+
143+
if (static::whereSlug($slug)->exists()) {
144+
$this->setUniqueSlug($slug, (int) $extra + 1);
145+
return;
146+
}
147+
148+
$this->attributes['slug'] = $slug;
149+
}
150+
151+
/**
152+
* Set the content attribute.
153+
*
154+
* @param $value
155+
*/
156+
public function setContentAttribute($value)
157+
{
158+
$data = [
159+
'raw' => $value,
160+
'html' => (new Markdowner)->convertMarkdownToHtml($value)
161+
];
162+
163+
$this->attributes['content'] = json_encode($data);
164+
}
165+
}

application/app/Category.php

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
namespace App;
4+
5+
use Illuminate\Database\Eloquent\Model;
6+
7+
class Category extends Model
8+
{
9+
/**
10+
* The attributes that are mass assignable.
11+
*
12+
* @var array
13+
*/
14+
protected $fillable = [
15+
'parent_id', 'name', 'path', 'description'
16+
];
17+
18+
/**
19+
* Get the articles for the category.
20+
*
21+
* @return \Illuminate\Database\Eloquent\Relations\HasMany
22+
*/
23+
public function articles()
24+
{
25+
return $this->hasMany(Article::Class);
26+
}
27+
}

application/app/Comment.php

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?php
2+
3+
namespace App;
4+
5+
use App\Tools\Markdowner;
6+
use Jcc\LaravelVote\CanBeVoted;
7+
use Illuminate\Database\Eloquent\Model;
8+
use Illuminate\Database\Eloquent\SoftDeletes;
9+
10+
class Comment extends Model
11+
{
12+
use SoftDeletes, CanBeVoted;
13+
14+
protected $vote = User::class;
15+
16+
/**
17+
* The attributes that are mass assignable.
18+
*
19+
* @var array
20+
*/
21+
protected $fillable = [
22+
'user_id', 'commentable_id', 'commentable_type', 'content'
23+
];
24+
25+
/**
26+
* The attributes that should be mutated to dates.
27+
*
28+
* @var array
29+
*/
30+
protected $dates = ['deleted_at'];
31+
32+
/**
33+
* Get the user for the discussion comment.
34+
*
35+
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
36+
*/
37+
public function user()
38+
{
39+
return $this->belongsTo(User::class);
40+
}
41+
42+
/**
43+
* Get all of the owning commentable models.
44+
*
45+
* @return \Illuminate\Database\Eloquent\Relations\morphTo
46+
*/
47+
public function commentable()
48+
{
49+
return $this->morphTo();
50+
}
51+
52+
/**
53+
* Set the content Attribute.
54+
*
55+
* @param $value
56+
*/
57+
public function setContentAttribute($value)
58+
{
59+
$data = [
60+
'raw' => $value,
61+
'html' => (new Markdowner)->convertMarkdownToHtml($value)
62+
];
63+
64+
$this->attributes['content'] = json_encode($data);
65+
}
66+
67+
}

0 commit comments

Comments
 (0)