2017 © Pedro Peláez
 

library blog

Blog Plugin

image

machaen/blog

Blog Plugin

  • Thursday, March 2, 2017
  • by machaen
  • Repository
  • 1 Watchers
  • 0 Stars
  • 6 Installations
  • CSS
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

BLOG MACHAEN

Simple plugin to generate an enviroment blog, (*1)

Installation and configuration

1 - Add to file composer.json the next line and eject a composer update:, (*2)

{
    "require": {
        "machaen/blog": "dev-master"
    }
}

2 - Add the providers and aliases necessary to file config/app.php:, (*3)

'providers' => [
        'Illuminate\Html\HtmlServiceProvider',
        'Dimsav\Translatable\TranslatableServiceProvider',
        'Mcamara\LaravelLocalization\LaravelLocalizationServiceProvider',
        'Machaen\Blog\BlogServiceProvider',
    ]
    .....
'aliases' => [
        'Form'                  => 'Illuminate\Html\FormFacade',
        'LaravelLocalization'   => 'Mcamara\LaravelLocalization\Facades\LaravelLocalization',
    ]

3 - Public files whith the next command:, (*4)

php artisan vendor:publish

4 - Import files blog.css and blog.js inside our project:, (*5)

<head>
    <link href="{{ asset('css/blog.css') }}" rel="stylesheet">  
    <script src="{{ asset('js/blog.js') }}"></script>  
</head>

5 - Add middlewares to app/Http/kernel.php:, (*6)

...
protected $routeMiddleware = [
    'localize'              => '\Mcamara\LaravelLocalization\Middleware\LaravelLocalizationRoutes',
    'localizationRedirect'  => '\Mcamara\LaravelLocalization\Middleware\LaravelLocalizationRedirectFilter',
    'localeSessionRedirect' => '\Mcamara\LaravelLocalization\Middleware\LocaleSessionRedirect'
];

6 - Add routes to app/Http/routes.php:, (*7)

/*** 
Other routes
.............
 ***/

Route::group(
[
    'prefix'        => LaravelLocalization::setLocale(),
    'middleware'    => [ 'localeSessionRedirect', 'localizationRedirect' ]
],
function(){
    Route::get(LaravelLocalization::transRoute('blog.blog-index'),['as' => 'blog.index', 'uses' => '\Machaen\Blog\BlogController@index']);
    Route::get(LaravelLocalization::transRoute('blog.blog-show'),['as' => 'blog.show', 'uses' => '\Machaen\Blog\BlogController@show']);
});

7 - Finally you have to migrate and insert your seeds:, (*8)

    php artisan migrate:refresh --seed

Translations button

It's necessary configure a button that's allow change our locale and set the lenguage (only in the preview post). So, we have to insert the next condition inside our action link, for example:, (*9)


/*---------- PREVIEW BLOG POST ----------*/ /* This line call the function "getRouteBlog" that's create a link with the parameters necessary for translate the current route. Here we past the route at layout our project */ @extends('app', ['route_blog' => \Machaen\Blog\Helpers::getRouteBlog($post->id)]) /*---------- LAYOUT ----------*/ @if(LaravelLocalization::getCurrentLocale() == 'en') <a href="{{ isset($route_blog) ? $route_blog : LaravelLocalization::getLocalizedURL('es') }}">ESPAÑOL</a> @else <a href="{{isset($route_blog) ? $route_blog : LaravelLocalization::getLocalizedURL('en') }}">ENGLISH</a> @endif

The Versions

02/03 2017

dev-master

9999999-dev

Blog Plugin

  Sources   Download

MIT

The Requires

 

by programacion3