Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Helpers cleanup #18

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
laravel-potion
===============
# laravel-potion

Potion is a pure PHP asset manager for Laravel based off of [Assetic](https://github.com/kriswallsmith/assetic).

###Description
# Description
Laravel 5 comes with a great asset manager called Elixir. While there is nothing wrong with Elixir, it requires you to install Node.js, Gulp, and dependent NPM packages on all of your web serves. While there is nothing wrong with this if you have other needs for those technologies, it seemed unnecessary to us to install that stack solely for the sake of handling assets. So we wrote Potion. Potion is a pure PHP solution, based off of [Assetic](https://github.com/kriswallsmith/assetic) that allows you to handle your assets in the same technology stack that your application is written in.

When using Potion the you will often see is "resources" and "assets". Think of resources as the raw resources inside of Laravel resources direction. Think of assets as what Potion will generate and will ultimately be served to visitors.

###Laravel Support
# Laravel Support
At this time Potion only supports Laravel 5.1 or higher. While Laravel 4 support was easy to implement in code, the time needed to support requests was too much.

###Features
# Features
- Fully integrated into Laravels' artisan commands
- Asset versioning support
- Asset CDN Url support
Expand All @@ -29,7 +29,7 @@ At this time Potion only supports Laravel 5.1 or higher. While Laravel 4 support
- JsCompressorFilter from YUI
- ScssphpFilter

###Installation
# Installation
1) Add 'classygeeks/potion' package to your composer.json file:

2) Add the Potion Service provider to your config/app.php file under the predefined "providers" array:
Expand All @@ -49,8 +49,20 @@ At this time Potion only supports Laravel 5.1 or higher. While Laravel 4 support

You will now see to new Potion artisan commands. The configuration is very well documented and should be able to get even the most complex projects going quickly.

###Future Features
# Future Features
- Resource watching command functionality
- Support for more filters from Assetic

# Rules For Contributing
- Please make sure all changed files are run through gofmt
- Submit a PR for review
- Your name will be added below to Contributors

# Author
[Matthew R. Miller](https://github.com/mattrmiller)

# Contributors
[Matthew R. Miller](https://github.com/mattrmiller)

# License
[MIT License](LICENSE)
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"kriswallsmith/assetic": "1.*",
"natxet/CssMin": "3.0.*",
"leafo/lessphp": "0.5.*",
"leafo/scssphp": "0.1.*",
"leafo/scssphp": "0.6.*",
"ptachoire/cssembed": "1.0.*",
"linkorb/jsmin-php": "1.0.*"
},
Expand Down
22 changes: 13 additions & 9 deletions src/ClassyGeeks/Potion/BladeHelpers.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright 2015 Classy Geeks llc. All Rights Reserved
* Copyright 2016 Matthew R. Miller via Classy Geeks llc. All Rights Reserved
* http://classygeeks.com
* MIT License:
* http://opensource.org/licenses/MIT
Expand Down Expand Up @@ -50,7 +50,7 @@ public static function assetUrl($name, $version = false)

// Version?
if ($version) {
$ret .= "v={$cache[$name]}";
$ret .= "?v={$cache[$name]}";
}

return $ret;
Expand All @@ -59,11 +59,11 @@ public static function assetUrl($name, $version = false)
/**
* Asset Css
* @param $name
* @param $rel
* @param $version
* @param $rel
* @return bool|string
*/
public static function assetCss($name, $rel = 'stylesheet', $version = false)
public static function assetCss($name, $version = false, $rel = 'stylesheet')
{
// Get cache
$cache = Cache::get('potion_assets', []);
Expand All @@ -77,16 +77,17 @@ public static function assetCss($name, $rel = 'stylesheet', $version = false)
$url = self::assetUrl($name, $version);

// Return
return "<link href=\"{$url}\" rel=\"{$rel}\" type=\"text/css\" />";
return "<link href=\"{$url}\" rel=\"{$rel}\" type=\"text/css\" />\n";
}

/**
* Asset Js
* @param $name
* @param $version
* @param $defer
* @return bool|string
*/
public static function assetJs($name, $version = false)
public static function assetJs($name, $version = false, $defer = FALSE)
{
// Get cache
$cache = Cache::get('potion_assets', []);
Expand All @@ -99,8 +100,11 @@ public static function assetJs($name, $version = false)
// Url
$url = self::assetUrl($name, $version);

// Deferred ?
$defer = $defer ? 'defer' : '';

// Return
return "<script type=\"text/javascript\" src=\"{$url}\"></script>";
return "<script type=\"text/javascript\" src=\"{$url}\" $defer></script>\n";
}

/**
Expand All @@ -123,6 +127,6 @@ public static function assetImg($name, $version = false)
$url = self::assetUrl($name, $version);

// Return
return "<img src=\"{$url}\" />";
return "<img src=\"{$url}\" />\n";
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright 2015 Classy Geeks llc. All Rights Reserved
* Copyright 2016 Matthew R. Miller via Classy Geeks llc. All Rights Reserved
* http://classygeeks.com
* MIT License:
* http://opensource.org/licenses/MIT
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright 2015 Classy Geeks llc. All Rights Reserved
* Copyright 2016 Matthew R. Miller via Classy Geeks llc. All Rights Reserved
* http://classygeeks.com
* MIT License:
* http://opensource.org/licenses/MIT
Expand Down
2 changes: 1 addition & 1 deletion src/ClassyGeeks/Potion/PotionServiceProvider.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright 2015 Classy Geeks llc. All Rights Reserved
* Copyright 2016 Matthew R. Miller via Classy Geeks llc. All Rights Reserved
* http://classygeeks.com
* MIT License:
* http://opensource.org/licenses/MIT
Expand Down
2 changes: 1 addition & 1 deletion src/config/config.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright 2015 Classy Geeks llc. All Rights Reserved
* Copyright 2016 Matthew R. Miller via Classy Geeks llc. All Rights Reserved
* http://classygeeks.com
* MIT License:
* http://opensource.org/licenses/MIT
Expand Down