2017 © Pedro Peláez
 

package lets-blog

Blogging package for Laravel 5

image

saywebsolutions/lets-blog

Blogging package for Laravel 5

  • Sunday, April 29, 2018
  • by saywebsolutions
  • Repository
  • 0 Watchers
  • 0 Stars
  • 4 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 100 % Grown

The README.md

Let's Blog

A simple command line, markdown based blog add-on package for Laravel including support for tags and series of related posts., (*1)

Install and Quick Start

Include the package via composer:, (*2)

composer require "saywebsolutions/letsblog"

Add the service provider to config/app.php:, (*3)

'providers' => [
    ...
    SayWebSolutions\LetsBlog\Providers\LetsBlogServiceProvider::class,
    ...
]

Publish the Config File

The best way to get a sense of the config options is to publish the config and take a look at the file:, (*4)

php artisan vendor:publish --provider="SayWebSolutions\LetsBlog\Providers\LetsBlogServiceProvider" --tag=config

Find the config file in config/letsblog.php., (*5)

Migrate the Let's Blog Tables:

php artisan migrate --path=/vendor/saywebsolutions/lets-blog/database/migrations

Your main blade layout must be named app.blade.php for the default theme to work out of the box; if not, there is a config key theme_extends that will allow you to define the blade layout to extend., (*6)

Navigate to /blog and see the default blog page., (*7)

Adding & Updating Posts

Write posts using the markdown format, and by default posts should go in the ./blog/posts directory., (*8)

After adding/editing a post run the letsblog:build command to add the new post(s) and/or apply your edits:, (*9)

php artisan letsblog:build

The main key used for checking existing posts will be the identifier field which by default uses the filename., (*10)

Post Format

The post format should look like the following:, (*11)

---
title: LetsBlog Package Released
slug: letsblog-package-released-laravel
meta: LetsBlog package released for Laravel.
keywords: letsblog, package, laravel, release
published_at: 2018-03-17
tags: LetsBlog, Laravel
---

## Post Title

Post contents...

You can set any fields in the top section (front matter) of the file. The available parsers recieve the data defined in the front matter for each field, and can manipulate that data prior to being saved to the posts table., (*12)

Current parsers are:, (*13)

  • Title
  • Meta (description)
  • Body
  • PublishedAt
  • Slug (if not defined will fallback to filename)
  • Tags
  • Series (optional name of the series to which to post belongs)

Migrations

The migration can be run directly from the packages migrations folder:, (*14)

php artisan migrate --path=/vendor/saywebsolutions/lets-blog/database/migrations
php artisan migrate:rollback

If the migrations need to be published to the parent app, use the vendor:publish command:, (*15)

php artisan vendor:publish --provider="SayWebSolutions\LetsBlog\Providers\LetsBlogServiceProvider" --tag=migrations

Themes

To set a theme set the 'letsblog.theme' property in the config. To simplify things ALL views should simply use letsblog::theme.master as the main view. Then a view is set as part of the data sent to the view., (*16)

return view('letsblog::themes.master', [
    'view' => lb_view('post.show'),
]);

The lb_view is a shortcut helper to use to avoid having to set the full path with the theme each time. This allows easy swapping of themes by only having to change the config parameter., (*17)

So far the currently supported themes are:, (*18)

  • default
  • extension

Default Theme

The default theme is currently untested, and may or may not be working., (*19)

Extension Theme

The extension theme is useful if you have an existing blade layout you'd like to embed the blog in. Right now the extension theme expects Bootstrap 3 to be available in the parent application., (*20)

Make sure to have a yield directive for javascript in your parent layout, ex.):, (*21)

@yield ('javascript')

Overriding Layouts

In many cases you will want to add some customization to the layout to include some analytics tracking or ads for instance. To allow this the themes include many section blocks that can replace or modify existing layout., (*22)

To start, create an overrides file in the views directory:, (*23)

/resources/views/vendor/lets-blog/themes/overrides.blade.php

From there the following section blocks can be used which hopefully are self explanatory., (*24)

  • meta.opensearch
  • meta.title
  • meta.keywords
  • meta.description
  • meta.og
  • head.files
  • head.styles
  • sidebar.series
  • sidebar.popular
  • component.search
  • component.related
  • footer-nav.left
  • footer-nav.right
  • post.list
  • post.head
  • post.series
  • post.body
  • post.related
  • page.head
  • page.body
  • layout.view
  • layout.end

Customize

For customization the LetsBlog facade may be used., (*25)

'aliases' => [
  'Blog'      => SayWebSolutions\LetsBlog\Facades\LetsBlogFacade::class,
  ...
]

The facade provides access to the following shortcut functions:, (*26)

  • published() - Paginated list of posts.
  • search($q) - Paginated list of posts by search.
  • all() - All posts.
  • last() - Last post (by published_at date).
  • post($slug) - Post or page by slug.
  • count() - Post count.
  • top($amount) - Top posts (default 10).
  • tags() - All tags.
  • publishedWhereTag($tag) - Paginated list of posts by tag.

Assets

Publish all files from the package:, (*27)

php artisan vendor:publish --provider="SayWebSolutions\LetsBlog\Providers\LetsBlogServiceProvider"

Or publish separately:, (*28)

php artisan vendor:publish --provider="SayWebSolutions\LetsBlog\Providers\LetsBlogServiceProvider" --tag=migrations
php artisan vendor:publish --provider="SayWebSolutions\LetsBlog\Providers\LetsBlogServiceProvider" --tag=views
php artisan vendor:publish --provider="SayWebSolutions\LetsBlog\Providers\LetsBlogServiceProvider" --tag=config
php artisan vendor:publish --provider="SayWebSolutions\LetsBlog\Providers\LetsBlogServiceProvider" --tag=assets

Headers & Footers

Each theme should also support a header and footer section (and perhaps more standard sections to follow). The idea is that a list of views can be provided and they will be included in that order., (*29)

This allows the inclusion of any ads or analytics tracking codes., (*30)

Adding Parser

To add a parser, create a class with the name of the key being parsed. So title would look for SayWebSolutions\LetsBlog\Parser\Field\Title. This way additional fields may be added or existing ones overridden., (*31)

To Do

Some things that still need to be done., (*32)

  • Admin section (with WYSIWYG MD editor)
  • Additional themes
  • Comments

The Versions

29/04 2018

dev-master

9999999-dev https://github.com/saywebsolutions/lets-blog

Blogging package for Laravel 5

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel cms laravel 5 blog publishing blogging say web solutions saywebsolutions lets-blog letsblog

29/04 2018

0.0.1

0.0.1.0 https://github.com/saywebsolutions/lets-blog

Blogging package for Laravel 5

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel cms laravel 5 blog publishing blogging say web solutions saywebsolutions lets-blog letsblog