2017 © Pedro Peláez
 

library laravel-assets

image

kodicms/laravel-assets

  • Thursday, July 6, 2017
  • by butschster
  • Repository
  • 2 Watchers
  • 8 Stars
  • 55,652 Installations
  • PHP
  • 6 Dependents
  • 0 Suggesters
  • 3 Forks
  • 1 Open issues
  • 17 Versions
  • 8 % Grown

The README.md

!!! This project is not maintained anymore. Please use this package https://github.com/butschster/LaravelMetaTags !!!

Laravel Assets

Build Status StyleCI, (*1)

Установка

Для установки пакета вы можете выполнить консольную команду, (*2)

composer require kodicms/laravel-assets, (*3)

Или добавить пакет в composer.json, (*4)

{
  "require": {
    ...
    "kodicms/laravel-assets": "~0.6"
    ...
  }
}

Добавить в загрузку сервис провайдер

'providers' => [
  ...
  KodiCMS\Assets\AssetsServiceProvider::class,
  ...
],
'aliases' => [
  ...
  'Assets' => KodiCMS\Assets\Facades\Assets::class,
  'PackageManager' => KodiCMS\Assets\Facades\PackageManager::class,
  'Meta' => KodiCMS\Assets\Facades\Meta::class,
  ...
]

Использование

Формирование пакетов

PackageManager::add('jquery')
    ->js(null, 'https://code.jquery.com/jquery-2.1.4.min.js');

PackageManager::add('jquery-ui')
    ->js(null, 'https://code.jquery.com/ui/1.11.4/jquery-ui.min.js', 'jquery')
    ->css(null, 'https://code.jquery.com/ui/1.11.4/themes/ui-lightness/jquery-ui.css');

PackageManager::add('custom')
    ->js(null, '...')
    ->js('custom.second.js', '...', 'custom')
    ->css(null, '...')
    ->css('custom.second.css', '...');

Добавление данных в вывод

Формировать мета данные для вывода можно не только в шаблоне, но и непосредственно коде приложения, (*5)

use KodiCMS\Assets\Contracts\SocialMediaTagsInterface;

class Article extends Model implements SocialMediaTagsInterface
{
    ...
}

use Meta;

class ArticleController extends Controller
{
    public function show($articleId)
    {
        $article = Article::find($articleId);

        Meta::loadPackage('jquery')
            ->addSocialTags($article);

        Meta::addCss('style', url('css/style.css'));
        Meta::addJs('scripts', url('js/scripts.js'), 'jquery');

        Meta::addJsElixir();
        ...
    }
}

Вывод

Для вывода css и js в шаблон сайта используется класс Meta., (*6)

<!DOCTYPE html>
<html lang="en">
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no"/>
    {!!
        Meta::setFavicon('favicon.ico')
            // Подключение файлов из пакетов
            ->loadPackage('jquery', 'jquery-ui', 'custom')

            // Meta title
            ->setTitle('Hello world')
            ->setMetaDescription('Meta description')
            ->setMetaKeywords('Meta keywords')
            ->setMetaRobots('Meta robots')

            // Alternative meta title
            ->setMetaData(MetaDataInterface $data)

            // Social tags
            ->addSocialTags(SocialMediaTagsInterface $socialTags)

            // Custom tag
            ->addMeta([
                'property' => 'og:title',
                'content'  => 'Title',
                'name' => 'og:title'
            ])

            ->render()
    !!}
</head>

Вывод списка пакетов

php artisan assets:packages, (*7)

The Versions

06/07 2017

dev-master

9999999-dev

  Sources   Download

GNU GENERAL PUBLIC LICENSE

The Requires

 

The Development Requires

06/07 2017

v0.4.5

0.4.5.0

  Sources   Download

GNU GENERAL PUBLIC LICENSE

The Requires

 

The Development Requires

14/02 2017

dev-feature/dependencies

dev-feature/dependencies

  Sources   Download

GNU GENERAL PUBLIC LICENSE

The Requires

 

The Development Requires

08/11 2016

v0.3.5

0.3.5.0

  Sources   Download

GNU GENERAL PUBLIC LICENSE

The Requires

 

The Development Requires

19/08 2016

v0.3.3

0.3.3.0

  Sources   Download

GNU GENERAL PUBLIC LICENSE

The Requires

 

The Development Requires

11/08 2016

v0.3.1

0.3.1.0

  Sources   Download

GNU GENERAL PUBLIC LICENSE

The Requires

 

The Development Requires

09/08 2016

v0.3.0

0.3.0.0

  Sources   Download

GNU GENERAL PUBLIC LICENSE

The Requires

 

The Development Requires

08/08 2016

v0.2.0

0.2.0.0

  Sources   Download

GNU GENERAL PUBLIC LICENSE

The Requires

 

The Development Requires

14/04 2016

v0.1.18

0.1.18.0

  Sources   Download

GNU GENERAL PUBLIC LICENSE

The Requires

 

20/02 2016

v0.1.17

0.1.17.0

  Sources   Download

GNU GENERAL PUBLIC LICENSE

The Requires

 

15/02 2016

v0.0.17

0.0.17.0

  Sources   Download

GNU GENERAL PUBLIC LICENSE

The Requires

 

15/02 2016

v0.0.16

0.0.16.0

  Sources   Download

GNU GENERAL PUBLIC LICENSE

The Requires

 

15/02 2016

v0.0.15

0.0.15.0

  Sources   Download

GNU GENERAL PUBLIC LICENSE

The Requires

 

04/11 2015

v0.0.14

0.0.14.0

  Sources   Download

GNU GENERAL PUBLIC LICENSE

The Requires

 

03/11 2015

v0.0.13

0.0.13.0

  Sources   Download

GNU GENERAL PUBLIC LICENSE

The Requires

 

03/11 2015

v0.0.12

0.0.12.0

  Sources   Download

GNU GENERAL PUBLIC LICENSE

The Requires

 

03/11 2015

v0.0.11

0.0.11.0

  Sources   Download

GNU GENERAL PUBLIC LICENSE

The Requires