blogit
所属分类:博客
开发工具:PHP
文件大小:17KB
下载次数:0
上传日期:2016-11-27 15:18:20
上 传 者:
sh-1993
说明: 使用Git(中心)为Laravel 5和Lumen撰写博客。获取和分析Github上托管的文档。
(Blog with Git(hub) For Laravel 5 and Lumen. Fetch and Parse Documents hosted on Github.)
文件列表:
LICENSE (1097, 2016-11-27)
composer.json (1010, 2016-11-27)
src (0, 2016-11-27)
src\Blogit.php (6553, 2016-11-27)
src\BlogitCollection.php (972, 2016-11-27)
src\BlogitServiceProvider.php (4889, 2016-11-27)
src\Document (0, 2016-11-27)
src\Document\AbstractDocument.php (7489, 2016-11-27)
src\Document\Article.php (5885, 2016-11-27)
src\Document\ArticleFactory.php (824, 2016-11-27)
src\Facades (0, 2016-11-27)
src\Facades\Blogit.php (408, 2016-11-27)
src\Parser (0, 2016-11-27)
src\Parser\DocumentParser.php (1462, 2016-11-27)
src\Parser\ParserInterface.php (222, 2016-11-27)
src\Repositories (0, 2016-11-27)
src\Repositories\Contracts (0, 2016-11-27)
src\Repositories\Contracts\DocumentRepositoryInterface.php (242, 2016-11-27)
src\Repositories\Github (0, 2016-11-27)
src\Repositories\Github\AbstractRepository.php (860, 2016-11-27)
src\Repositories\Github\DocumentRepository.php (2045, 2016-11-27)
src\Repository (0, 2016-11-27)
src\Repository\AbstractGithubDocumentRepository.php (2250, 2016-11-27)
src\Repository\DocumentRepositoryInterface.php (316, 2016-11-27)
src\config (0, 2016-11-27)
src\config\blogit.php (336, 2016-11-27)
# jrean/blogit
**jrean/blogit** is a PHP wrapper for the Github API (not yet Framework
Agnostic) built for Laravel/Lumen to publish easily your content and "Blog with
Git".
## Goals
- Leverage the power of the Github API
- No database, no backoffice, no forms, ...
- Open source your content and allow easy contributions
- Write, Commit, Push, Live...
## Installation
This project can be installed via [Composer](http://getcomposer.org)
To get the latest version of Blogit, simply add the following line to
the require block of your composer.json file:
"jrean/blogit": "~0.1.0"
// or
"jrean/blogit": "dev-master"
You'll then need to run `composer install` or `composer update` to download it and
have the autoloader updated.
### Add the Service Provider
Once Blogit is installed, you need to register the service provider.
#### Laravel
Open up `config/app.php` and add the following to the `providers` key:
* `'Jrean\Blogit\BlogitServiceProvider'`
#### Lumen
Open up `bootstrap/app.php` and add the following:
* `$app->register('Jrean\Blogit\BlogitServiceProvider');`
### Enable Dotenv File (Lumen only)
Uncomment the following line in `bootstrap/app.php`:
// Dotenv::load(__DIR__.'/../');
## Configuration
Update your `.env` file with the following keys and assign your
values:
GITHUB_USER =your_github_user_name
GITHUB_TOKEN =your_github_token
GITHUB_REPOSITORY =your_repository_name
GITHUB_ARTICLES_DIRECTORY_PATH =content_root_directory_name
* `GITHUB_TOKEN`
Your Github username.
* `GITHUB_TOKEN`
Visit [Github](https://github.com/settings/tokens) and create a `Personal
Access Tokens`
* `GITHUB_REPOSITORY`
Create a new `Public` repository or use an existing one.
* `GITHUB_ARTICLES_DIRECTORY_PATH`
Inside your repository create a directory (for instance `articles`) where you
will push your files.
## Basic usage
### Without Controller
Update `app/Http/routes.php`:
$app->get('/blogit', function() use($app) {
// Jrean\Blogit\Blogit instance
$blogit = $app->make('blogit');
// Jrean\Blogit\BlogitCollection
$articles = $blogit->getArticles();
// Last 3 created Articles
$news = $articles->sortByCreatedAtDesc()->take(3);
// Last 3 updated Articles
$updates = $articles->sortByUpdatedAtDesc()->take(3);
return view('blogit.index', compact('news', 'updates')); });
$app->get('/blogit/{slug}', function($slug) use($app) {
// Jrean\Blogit\Blogit instance
$blogit = $app->make('blogit');
// Jrean\Blogit\Document\Article
$article = $blogit->getArticleBySlug($slug);
if ($article === null) abort(404);
return view('blogit.show', compact('article'));
});
### With Controller
Update `app/Http/routes.php`:
$app->get('/', [
'uses' => 'App\Http\Controllers\YourController@index',
'as' => 'index'
]);
$app->get('/{slug}', [
'uses' => 'App\Http\Controllers\YourController@show',
'as' => 'show'
]);
Update `app/Http/Controllers/YourController.php`:
blogit = $blogit;
}
public function index()
{
$articles = $this->blogit->getArticles();
$news = $articles->sortByCreatedAtDesc()->take(3);
$updates = $articles->sortByUpdatedAtDesc()->take(3);
return view('blogit.index', compact('news', 'updates'));
}
public function show($slug)
{
$article = $this->blogit->getArticleBySlug($slug);
if ($article === null) abort(404);
return view('blogit.show', compact('article'));
}
}
### Views (Blade for instance)
@foreach($articles as $article)
{{ $article->getTitle() }}
{{ $article->getSlug() }}
{{ $article->getLastCommitUrl() }}
{{ $article->getUpdatedAtDiff() }}
{{ $article->getTags() }}
{{ $article->getHtml() }}
{{ $article->getContributors() }}
...
@endforeach
## Basic File Format
I recommand to stick with `.md` files:
title: My Article Title
slug: my-custom-slug
tags: [tag, tag, tag]
---
## My Markdown Content
The `.md` file contains two sections separated by a `delimiter` string. One
section for the `metadata` and one for the `content`.
### Delimiter String
To separate `metadata` and `content` you MUST use a minimum of three `---`.
You can use more if you want.
### Metadata
Metada will be parsed as `Yaml` so feel free and creative because
you'll access them through an `array`. The only required key is the
`title`. `slug` and `tags` are optionnals. If you don't provide a custom
`slug`, one will be auto generated based on the `title` value...
### Content
Everything under `---` will be parsed as `Markdown`. Again, fell free and
creative.
## Extending and Customize Blogit
I try and will try my best to give you the ability to extend and override
`Blogit`. For now you can easily hack and extend `Jrean\Blogit\Blogit.php` and
`Jrean\Blogit\BlogitCollection.php` to bring your own logic, methods and
attributes.
### Be Creative
With the Blogit API you have access to methods and properties about your
content, metadata, commits, contributors, tags, dates, Github links,...
Have a look at `Jrean\Blogit\Document\*`, `Jrean\Blogit\Repository\*`
and `Jrean\Blogit\Blogit.php`.
## Contribute
This package is (yet) under active development and refactoring.
Please, feel free to comment, contribute and help. I would like/love to bring
`Unit tests`.
## Example
I will write soon a dedicated article for `Blogit` which is now used
on `Production` for [Askjong.com](http://www.askjong.com "AskJong, Quick Updates and Practical Approaches about anything Tech., Laravel, Vim, Php, DigitalOcean and Web Programming.")
## License
Blogit is licensed under [The MIT License (MIT)](LICENSE).
近期下载者:
相关文件:
收藏者: