2017 © Pedro Peláez
 

library bloghub

Use a Git repository to generate blog entities and contents. PlainText, HTML and Markdown formats supported.

image

sly/bloghub

Use a Git repository to generate blog entities and contents. PlainText, HTML and Markdown formats supported.

  • Sunday, January 6, 2013
  • by Ph3nol
  • Repository
  • 1 Watchers
  • 2 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

BlogHub

Use a Git repository to generate blog entities and contents., (*1)

=====, (*2)

WORK IN PROGRESS.

=====, (*3)

Requirements

  • PHP 5.3+

Installation

Add to your project Composer packages

Just add sly/blog-hub package to the requirements of your Composer JSON configuration file, and run php composer.phar install to install it., (*4)

Install from GitHub

Clone this library from Git with git clone https://github.com/Ph3nol/BlogHub.git., (*5)

Goto to the library directory, get Composer phar package and install vendors:, (*6)

curl -s https://getcomposer.org/installer | php
php composer.phar install

You're ready to go., (*7)

Repository structure

Your git repository has to respect a Categories/Posts structure to be understood by the library., (*8)

The logic:, (*9)

Category 1
   `-- Title of my post 1
   `-- Title of my post 2
   `-- Title of my post 3

Category 2
   `-- Title of my post 4

To match this logic, the repository tree will be:, (*10)

Category 1/
Category 1/Title of my post 1.md
Category 1/Title of my post 2.md
Category 1/Title of my post 3.md
Category 2/
Category 2/Title of my post 4.md

Post structure

Each post has to be a markdown file, into a category folder. Informations can be added to it as PHPDoc/Annotations one. Here is an example:, (*11)

/**
 * @createdAt 2013-01-01
 * @description This is my post description.
 * @tags tag1, tag2, tag3
 * @format markdown
 */

# My post title

My post content.

Example

``` php require_once 'vendor/autoload.php';, (*12)

use GitElephant\Repository; use Sly\BlogHub\Blog\Blog;, (*13)

/** * GitElephant repository instance. */ $repo = new Repository('/path/to/your/repository'); $repo->checkout('master');, (*14)

/** * BlogHub instance, with repository object as argument. */ $blog = new Blog($repo);, (*15)


### Categories list ``` php foreach ($blog->getCategories() as $category) { // Your logic }

Elements:, (*16)

  • Category name: (string) $category or $category->getName()
  • Posts collection: $category->getPosts()
  • Number of posts: $category->getPosts()->count()

Posts list

``` php foreach ($blog->getPosts() as $post) { // Your logic }, (*17)


``` php foreach ($category->getPosts() as $post) { // Your logic }

Elements:, (*18)

  • Post title: (string) $post or $post->getTitle()
  • Post category object: $post->getCategory()
  • Slug: $post->getSlug()
  • Excerpt: $post->getExcerpt([string $separator = ' [...]'])
  • Tags collection: $post->getTags()
  • Creation DateTime: $post->getCreatedAt()
  • Update DateTime: $post->getUpdatedAt()

Tags list

``` php foreach ($blog->getTags() as $tag) { // Your logic }, (*19)


``` php foreach ($post->getTags() as $tag) { // Your logic }

Elements:, (*20)

  • Tag name: (string) $tag or $tag->getName()

Query Builder

You can use the QueryBuilder to retreive a specific model entity. Here is an example:, (*21)

php $query = $blog->getQuery(); // Get QueryBuilder from Blog Manager service $post = $query->from('Post')->getOneBySlug('hello-world'); // Get the Post from its slug, (*22)

The Versions

06/01 2013

dev-master

9999999-dev https://github.com/Ph3nol/BlogHub

Use a Git repository to generate blog entities and contents. PlainText, HTML and Markdown formats supported.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Cédric Dugat

repository git html markdown content repositories blog generated