forked from modbase/asset-manager
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Stijn Geselle
committed
Feb 9, 2014
0 parents
commit ae4109d
Showing
11 changed files
with
235 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Auto detect text files and perform LF normalization | ||
* text=auto | ||
|
||
# Custom for Visual Studio | ||
*.cs diff=csharp | ||
*.sln merge=union | ||
*.csproj merge=union | ||
*.vbproj merge=union | ||
*.fsproj merge=union | ||
*.dbproj merge=union | ||
|
||
# Standard to msysgit | ||
*.doc diff=astextplain | ||
*.DOC diff=astextplain | ||
*.docx diff=astextplain | ||
*.DOCX diff=astextplain | ||
*.dot diff=astextplain | ||
*.DOT diff=astextplain | ||
*.pdf diff=astextplain | ||
*.PDF diff=astextplain | ||
*.rtf diff=astextplain | ||
*.RTF diff=astextplain |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/vendor | ||
composer.phar | ||
composer.lock | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
language: php | ||
|
||
php: | ||
- 5.3 | ||
- 5.4 | ||
- 5.5 | ||
|
||
before_script: | ||
- curl -s http://getcomposer.org/installer | php | ||
- php composer.phar install --dev | ||
|
||
script: phpunit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"name": "modbase/asset-manager", | ||
"description": "A very basic asset manager to be used in combination with versioned assets.", | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Stijn Geselle", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"require": { | ||
"php": ">=5.3.0", | ||
"illuminate/support": "4.1.*" | ||
}, | ||
"autoload": { | ||
"psr-0": { | ||
"Modbase\\AssetManager\\": "src/" | ||
} | ||
}, | ||
"minimum-stability": "stable" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit backupGlobals="false" | ||
backupStaticAttributes="false" | ||
bootstrap="vendor/autoload.php" | ||
colors="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
processIsolation="false" | ||
stopOnFailure="false" | ||
syntaxCheck="false" | ||
> | ||
<testsuites> | ||
<testsuite name="Package Test Suite"> | ||
<directory suffix=".php">./tests/</directory> | ||
</testsuite> | ||
</testsuites> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php namespace Modbase\AssetManager; | ||
|
||
use Illuminate\Support\ServiceProvider; | ||
|
||
class AssetManagerServiceProvider extends ServiceProvider { | ||
|
||
/** | ||
* Bootstrap the application events. | ||
* | ||
* @return void | ||
*/ | ||
public function boot() | ||
{ | ||
$this->package('modbase/asset-manager'); | ||
} | ||
|
||
/** | ||
* Register the service provider. | ||
* | ||
* @return void | ||
*/ | ||
public function register() | ||
{ | ||
$this->app->singleton('modbase.asset', 'Modbase\AssetManager\Manager'); | ||
|
||
$this->app->booting(function() | ||
{ | ||
$loader = \Illuminate\Foundation\AliasLoader::getInstance(); | ||
$loader->alias('Asset', 'Modbase\AssetManager\Facade\Asset'); | ||
}); | ||
} | ||
|
||
/** | ||
* Get the services provided by the provider. | ||
* | ||
* @return array | ||
*/ | ||
public function provides() | ||
{ | ||
return array('modbase.asset'); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php namespace Modbase\AssetManager\Facade; | ||
|
||
use Illuminate\Support\Facades\Facade; | ||
|
||
class Asset extends Facade { | ||
|
||
/** | ||
* Get the registered name of the component. | ||
* | ||
* @return string | ||
*/ | ||
protected static function getFacadeAccessor() { return 'modbase.asset'; } | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
<?php namespace Modbase\AssetManager; | ||
|
||
use \Illuminate\Filesystem\Filesystem as Filesystem; | ||
use \Illuminate\Support\Facades\Config as Config; | ||
|
||
class Manager { | ||
|
||
/** | ||
* Decoded contents of the JSON file | ||
* | ||
* @var array | ||
*/ | ||
protected $data; | ||
|
||
/** | ||
* @var \Illuminate\Filesystem\Filesystem | ||
*/ | ||
protected $files; | ||
|
||
/** | ||
* Create a new manager | ||
* | ||
* @param \Illuminate\Filesystem\Filesystem $files | ||
* @return void | ||
*/ | ||
public function __construct(Filesystem $files) | ||
{ | ||
$this->files = $files; | ||
} | ||
|
||
/** | ||
* Get HTML for all stylesheets of the bundle | ||
* | ||
* @param string $bundle | ||
* @return string | ||
*/ | ||
public function styles($bundle) | ||
{ | ||
// If we didn't parse the file before, then do it now | ||
if (!$this->data) | ||
{ | ||
$this->parseVersionsFile(); | ||
} | ||
|
||
// Create link tags for all stylesheets | ||
foreach ($this->data[$bundle.'.styles'] as $style) | ||
{ | ||
$styles[] = '<link rel="stylesheet" href="/css/'.$style.'" />'.PHP_EOL; | ||
} | ||
|
||
return join(PHP_EOL, $styles); | ||
} | ||
|
||
/** | ||
* Get HTML for all JavaScripts of the bundle | ||
* | ||
* @param string $bundle | ||
* @return string | ||
*/ | ||
public function scripts($bundle) | ||
{ | ||
// If we didn't parse the file before, then do it now | ||
if (!$this->data) | ||
{ | ||
$this->parseVersionsFile(); | ||
} | ||
|
||
// Create script tags for all JavaScripts | ||
foreach ($this->data[$bundle.'.scripts'] as $script) | ||
{ | ||
$scripts[] = '<script src="/js/'.$script.'"></script>'.PHP_EOL; | ||
} | ||
|
||
return join(PHP_EOL, $scripts); | ||
} | ||
|
||
/** | ||
* Get the assets file and contents. | ||
* | ||
* @return array | ||
*/ | ||
protected function getVersionsFile() | ||
{ | ||
return $this->files->get(base_path().'/'.Config::get('asset-manager::config.file')); | ||
} | ||
|
||
/** | ||
* JSON decode the assets file | ||
* | ||
* @return array | ||
*/ | ||
protected function parseVersionsFile() | ||
{ | ||
$this->data = json_decode($this->getVersionsFile(), true); | ||
} | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?php | ||
|
||
return [ | ||
'file' => 'assets.json', | ||
]; |
Empty file.