Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
MilesPong committed Mar 19, 2018
2 parents 5e44eec + 018031d commit 9622fbf
Show file tree
Hide file tree
Showing 24 changed files with 327 additions and 261 deletions.
8 changes: 6 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,20 @@ YOUDAO_APP_SECRET=

GOOGLE_ANALYTICS_ID=

ENABLE_VISITOR_LOG=false

COMMENT_DRIVER=
DISQUS_SHORT_NAME=

FILESYSTEM_DRIVER=
FILESYSTEM_DRIVER=public

ADMIN_EMAIL=

MAIL_FROM_ADDRESS=
MAIL_FROM_NAME=

SCOUT_QUEUE=true
SCOUT_QUEUE=false
SCOUT_DRIVER=null

ALGOLIA_APP_ID=
ALGOLIA_SECRET=
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,21 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

### Fixed

## 1.0.4 - 2018-03-19
### Added
- [README.md](README.md)
- License

### Changed
- Update composer packages
- Latest Google Analytics js code
- Default configurations

### Fixed
- Fix error while versioning copied files ([82ba259](https://github.com/MilesPong/indigo/commit/82ba25917cd87e1754fdc7309b2c7ae3d90d6995))
- Fix shedule bug
- Fix search bar height in chrome

## 1.0.0 - 2018-03-12
### Added
- Package spatie/laravel-backup and related schedule
Expand Down
86 changes: 70 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,34 @@

# Indigo

A blog built with [Laravel](https://laravel.com) and [Materialize](http://materializecss.com).
A blog application built with [Laravel](https://laravel.com), [Materialize](http://materializecss.com) and [Vue.js](https://vuejs.org/).

Indigo is a project I mainly learn to how to develop a Laravel application **in the right way**, include using design patterns, modern coding tricks, and other useful skills.

There is an introduction(Chinese) about this project as well, you can access it [here](https://immiles.com/articles/indigo).

## Screenshot

![screenshot](https://user-images.githubusercontent.com/5867628/37555740-48334dc4-2a27-11e8-973f-f54f96d9e912.png)

## Features

- Base blog features like post, page, archives, search, etc.
- Basic blog features like post, page, archives, search, etc.
- Material UI (responsive layout)
- Disqus comment integrated
- Repositories pattern
- Markdown editor
- Trash support
- Counter with multiple drivers support
- Backup with Google Drive storage support
- Multiple mix for building backend and frontend
- Multiple Mix for compiling backend and frontend

More features can be discovery in [CHANGELOG.md](CHANGELOG.md)
More features can be found in [CHANGELOG.md](CHANGELOG.md)

## Server Requirements

Basic requirements are listed in official [document](https://laravel.com/docs/5.5#server-requirements).
Basic requirements are listed in the official [document](https://laravel.com/docs/5.5#server-requirements).

Also additional services below may be used and **recommended**
Also, additional services below may be used and **recommended**

- Redis
- Algolia
Expand All @@ -35,10 +42,51 @@ Also additional services below may be used and **recommended**
```bash
$ git clone https://github.com/MilesPong/indigo
$ cd indigo
$ composer install
$ php artisan key:generate
$ cp .env.example .env # Change your DB settings and other services' config
$ cp .env.example .env
```

Change your DB settings and other services' configurations

```
# For Chinese translation in slug
YOUDAO_APP_KEY=
YOUDAO_APP_SECRET=
# Google Analytics
GOOGLE_ANALYTICS_ID=
# Visitor log
ENABLE_VISITOR_LOG=false
# Comment
COMMENT_DRIVER=
DISQUS_SHORT_NAME=
FILESYSTEM_DRIVER=public
# For receiving feedback while failed in backup
ADMIN_EMAIL=
MAIL_FROM_ADDRESS=
MAIL_FROM_NAME=
# Search
SCOUT_QUEUE=false
SCOUT_DRIVER=null
```

**Schedule** are required by default, set it up as follow

```bash
$ crontab -e
# Append this to the end
# * * * * * php /path/to/project/artisan schedule:run >> /dev/null 2>&1
```

**Auto backup** is enabled by default, you may have a look about the configuration under [config/backup.php](config/backup.php)

### Migration

*Default user(admin) info is in [InitializationSeeder](database/seeds/InitializationSeeder.php ), you can modify it before running the seed task.*
Expand All @@ -47,28 +95,34 @@ $ cp .env.example .env # Change your DB settings and other services' config
$ php artisan migrate --seed # Migration and seeding
```

### Others
### Compiling Assets

You may also set up the [schedule](https://laravel.com/docs/5.5/scheduling) and [queue](https://laravel.com/docs/5.5/queues) according to official docs to enable **counter** and **auto backup**. (See [commands](app/Console/Kernel.php))
```bash
$ npm install
$ npm run dev # Frontend
$ npm run admin-dev # Backend
```

**Note: Code is open-sourced and you know what to do when "Something went wrong".**

## Changelog

Refer to the [Changelog](CHANGELOG.md) for a full history of the project.
Refer to the [CHANGELOG.md](CHANGELOG.md) for a full history of the project.

## TODO

Check this out in [Gist](https://gist.github.com/MilesPong/7529f9586fb7070a7f4c56360cdf9475).

## Links

- [Materialize](http://materializecss.com)
- [Vuejs](https://vuejs.org)
- [Laravel](https://laravel.com)

## About Indigo

Indigo is a project I mainly learn to how to develop a Laravel application **in the right way**, include using design patterns, modern coding tricks and other useful skills.
## Contributing

There is a full introduction about this project as well, you can access it [here](https://immiles.com/articles/indigo).
Any bug report or pull request is welcome.

## License

The project is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
The project is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
3 changes: 2 additions & 1 deletion app/Http/Requests/StoreUpdateCategoryRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function rules()
{
$rules = [
'name' => 'required|min:2|max:255|unique:categories',
'slug' => 'unique:categories'
'slug' => 'required|unique:categories'
];

switch ($this->method()) {
Expand All @@ -40,6 +40,7 @@ public function rules()
Rule::unique('categories')->ignore($this->route('category'))
],
'slug' => [
'required',
Rule::unique('categories')->ignore($this->route('category'))
]
]);
Expand Down
3 changes: 2 additions & 1 deletion app/Http/Requests/StoreUpdatePageRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function rules()
{
$rules = [
'title' => 'required',
'slug' => 'unique:pages',
'slug' => 'required|unique:pages',
'body' => 'required',
];

Expand All @@ -42,6 +42,7 @@ public function rules()
case 'PATCH':
$rules = array_merge($rules, [
'slug' => [
'required',
Rule::unique('pages')->ignore($this->route('page'))
]
]);
Expand Down
3 changes: 2 additions & 1 deletion app/Http/Requests/StoreUpdatePostRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function rules()
'title' => 'required',
'description' => 'required|max:100',
'category_id' => 'required|exists:categories,id',
'slug' => 'unique:posts',
'slug' => 'required|unique:posts',
'body' => 'required',
'feature_img' => 'required',
];
Expand All @@ -41,6 +41,7 @@ public function rules()
case "PATCH":
$rules = array_merge($rules, [
'slug' => [
'required',
Rule::unique('posts')->ignore($this->route('post'))
]
]);
Expand Down
3 changes: 2 additions & 1 deletion app/Http/Requests/StoreUpdateTagRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function rules()
$rules = [
'name' => 'required|min:2|max:255|unique:tags',
'description' => 'max:255',
'slug' => 'unique:tags'
'slug' => 'required|unique:tags'
];

switch ($this->method()) {
Expand All @@ -42,6 +42,7 @@ public function rules()
],
'description' => 'max:255',
'slug' => [
'required',
Rule::unique('tags')->ignore($this->route('tag'))
]
];
Expand Down
20 changes: 20 additions & 0 deletions app/Http/ViewComposers/GoogleAnalyticsComposer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace App\Http\ViewComposers;

use Illuminate\View\View;

/**
* Class GoogleAnalyticsComposer
* @package App\Http\ViewComposers
*/
class GoogleAnalyticsComposer
{
/**
* @param \Illuminate\View\View $view
*/
public function compose(View $view)
{
$view->with('traceId', config('indigo.analytics.google_trace_id'));
}
}
2 changes: 2 additions & 0 deletions app/Providers/ComposerServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use App\Http\ViewComposers\CategoriesComposer;
use App\Http\ViewComposers\CommentComposer;
use App\Http\ViewComposers\GoogleAnalyticsComposer;
use App\Http\ViewComposers\HotPostsComposer;
use App\Http\ViewComposers\TagsComposer;
use Illuminate\Support\Facades\View;
Expand All @@ -26,6 +27,7 @@ public function boot()
View::composer('widgets.tag', TagsComposer::class);
View::composer('widgets.hot', HotPostsComposer::class);
View::composer('partials.comment', CommentComposer::class);
View::composer('partials.google_analytics', GoogleAnalyticsComposer::class);
}

/**
Expand Down
2 changes: 0 additions & 2 deletions app/Repositories/Eloquent/CategoryRepositoryEloquent.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ public function create(array $attributes)
*/
protected function preHandleData(array $attributes)
{
$attributes['slug'] = $this->autoSlug($attributes['slug'], $attributes['name']);

return $attributes;
}

Expand Down
2 changes: 0 additions & 2 deletions app/Repositories/Eloquent/PageRepositoryEloquent.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,6 @@ public function create(array $attributes)
*/
protected function preHandleData(array $attributes)
{
$attributes['slug'] = $this->autoSlug($attributes['slug'], $attributes['title']);

return $this->handle($attributes);
}

Expand Down
2 changes: 0 additions & 2 deletions app/Repositories/Eloquent/PostRepositoryEloquent.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,6 @@ public function create(array $attributes)
*/
protected function preHandleData(array $attributes)
{
$attributes['slug'] = $this->autoSlug($attributes['slug'], $attributes['title']);

return $this->handle($attributes);
}

Expand Down
2 changes: 0 additions & 2 deletions app/Repositories/Eloquent/TagRepositoryEloquent.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ public function create(array $attributes)
*/
protected function preHandleData(array $attributes)
{
$attributes['slug'] = $this->autoSlug($attributes['slug'], $attributes['name']);

return $attributes;
}

Expand Down
49 changes: 0 additions & 49 deletions app/Repositories/Eloquent/Traits/Slugable.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,55 +36,6 @@ protected function ifShouldIgnorePublishedStatus()
}
}

/**
* Auto create slug if request slug is null
*
* @param $slug
* @param $toBeTranslated
* @return \JellyBool\Translug\Translation|mixed|string
*/
public function autoSlug($slug, $toBeTranslated)
{
if (!empty($slug)) {
return $slug;
}

$slug = str_slug_with_cn($toBeTranslated);

if ($this->slugExists($slug)) {
$slug = $this->addUniqueChar($slug);
}

return $slug;
}

/**
* @param $slug
* @param string $column
* @return mixed
*/
protected function slugExists($slug, $column = 'slug')
{
return $this->model->where($column, $slug)->exists();
}

/**
* @param $slug
* @return string
*/
protected function addUniqueChar($slug)
{
return $slug . '-' . $this->uniqueChar();
}

/**
* @return string
*/
protected function uniqueChar()
{
return Carbon::now()->timestamp;
}

/**
* @param $id
* @return string
Expand Down
Loading

0 comments on commit 9622fbf

Please sign in to comment.