Skip to content

Commit

Permalink
initial release
Browse files Browse the repository at this point in the history
  • Loading branch information
skydiver committed Aug 13, 2015
0 parents commit 58f22a3
Show file tree
Hide file tree
Showing 7 changed files with 295 additions and 0 deletions.
Empty file added .gitignore
Empty file.
22 changes: 22 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
The MIT License (MIT)

Copyright (c) 2015 skydiver

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

124 changes: 124 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
# laravel-materialize-css
Materialize CSS Framework for Laravel 5 [http://materializecss.com/]



## Installation

* Require this package in your composer.json and run composer update.
```
"mskydiver/laravel-materialize-css": "dev-master"
```

* After updating composer, add the ServiceProvider to the providers array in config/app.php
```php
'Skydiver\LaravelMaterializeCSS\MaterializeCSSServiceProvider',
```

* Then publish the package's assets to public folder:
```
$ php artisan vendor:publish --tag=materializecss --force
```



## Updates
You can re-publish the assets automatically when composer updated the package:

* In your composer.json, go to **scripts** > **post-update-cmd** section, add the next line:
```
"php artisan vendor:publish --tag=materializecss --force"
```

* The code will look similar to:
```
"post-update-cmd": [
"php artisan optimize",
"php artisan vendor:publish --tag=materializecss --force"
],
```



## Usage

There are differents methods to include Materialize CSS assets:

* **include_full()**
```php
{!! MaterializeCSS::include_full() !!}
```
```html
<link rel="stylesheet" href="http://yourdomain.com/materialize-css/css/materialize.min.css">
<script src="//code.jquery.com/jquery-2.1.1.min.js"></script>
<script src="http://yourdomain.com/materialize-css/js/materialize.min.js"></script>
```

* **include_all()**
```php
{!! MaterializeCSS::include_all() !!}
```
```html
<link rel="stylesheet" href="http://yourdomain.com/materialize-css/css/materialize.min.css">
<script src="http://yourdomain.com/materialize-css/js/materialize.min.js"></script>
```

* **include_css()**
```php
{!! MaterializeCSS::include_css() !!}
```
```html
<link rel="stylesheet" href="http://yourdomain.com/materialize-css/css/materialize.min.css">
```

* **include_js()**
```php
{!! MaterializeCSS::include_js() !!}
```
```html
<script src="http://yourdomain.com/materialize-css/js/materialize.min.js"></script>
```

* **include_secure_css()**
```php
{!! MaterializeCSS::include_secure_css() !!}
```
```html
<link rel="stylesheet" href="https://yourdomain.com/materialize-css/css/materialize.min.css">
```

* **include_secure_js()**
```php
{!! MaterializeCSS::include_secure_js() !!}
```
```html
<script src="https://yourdomain.com/materialize-css/js/materialize.min.js"></script>
```

* **get_url_css($full=false, $secure=false)**
```php
{!! MaterializeCSS::get_url_css() !!}
{!! MaterializeCSS::get_url_css(true, false) !!}
{!! MaterializeCSS::get_url_css(false, true) !!}
{!! MaterializeCSS::get_url_css(true, true) !!}
```
```html
/materialize-css/css/materialize.min.css
http://yourdomain.com/materialize-css/css/materialize.min.css
/materialize-css/css/materialize.min.css
https://yourdomain.com/materialize-css/css/materialize.min.css
```

* **get_url_js($full=false, $secure=false)**
```php
{!! MaterializeCSS::get_url_js() !!}
{!! MaterializeCSS::get_url_js(true, false) !!}
{!! MaterializeCSS::get_url_js(false, true) !!}
{!! MaterializeCSS::get_url_js(true, true) !!}
```
```html
/materialize-css/js/materialize.min.js
http://yourdomain.com/materialize-css/js/materialize.min.js
/materialize-css/js/materialize.min.js
https://yourdomain.com/materialize-css/js/materialize.min.js
```
22 changes: 22 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "skydiver/laravel-materialize-css",
"description": "Add Materialize CSS Framework to Laravel",
"keywords": ["Materialize", "CSS", "Material Design", "laravel", "CSS Framework"],
"license": "MIT",
"require": {
"php": ">=5.4.0",
"illuminate/support": "5.*"
},
"authors": [
{
"name": "Martin",
"email": "[email protected]"
}
],
"autoload": {
"psr-4": {
"Skydiver\\LaravelMaterializeCSS\\": "src/"
}
},
"minimum-stability": "dev"
}
83 changes: 83 additions & 0 deletions src/MaterializeCSSBuilder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?php

namespace Skydiver\LaravelMaterializeCSS;

class MaterializeCSSBuilder {

private static $file_css = '/materialize-css/css/materialize.css';
private static $file_css_min = '/materialize-css/css/materialize.min.css';
private static $file_js = '/materialize-css/js/materialize.js';
private static $file_js_min = '/materialize-css/js/materialize.min.js';
private static $file_jquery = 'jquery-2.1.1.min.js';


public static function include_full() {
$return = self::include_css();
$return .= self::tag_js('//code.jquery.com/'.self::$file_jquery);
$return .= self::include_js();
return $return;
}

public static function include_all() {
$return = self::include_css();
$return .= self::include_js();
return $return;
}

public static function include_css() {
return self::tag_css(asset(self::$file_css_min));
}

public static function include_js() {
return self::tag_js(asset(self::$file_js_min));
}

public static function include_secure_css() {
return self::tag_css(secure_asset(self::$file_css_min));
}

public static function include_secure_js() {
return self::tag_js(secure_asset(self::$file_js_min));
}

public static function get_url_css($full=false, $secure=false) {
if($full == true && $secure == true) {
return secure_asset(self::$file_css_min);
}
if($full == true && $secure == false) {
return asset(self::$file_css_min);
}
return self::$file_css_min;
}

public static function get_url_js($full=false, $secure=false) {
if($full == true && $secure == true) {
return secure_asset(self::$file_js_min);
}
if($full == true && $secure == false) {
return asset(self::$file_js_min);
}
return self::$file_js_min;
}

private static function tag_css($path) {
return '<link rel="stylesheet" href="'.$path.'">';
}

private static function tag_js($path) {
return '<script src="'.$path.'"></script>';
}











}

?>
13 changes: 13 additions & 0 deletions src/MaterializeCSSFacade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Skydiver\LaravelMaterializeCSS;

use Illuminate\Support\Facades\Facade;

class MaterializeCSSFacade extends Facade {

protected static function getFacadeAccessor() { return 'materialize-css'; }

}

?>
31 changes: 31 additions & 0 deletions src/MaterializeCSSServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

namespace Skydiver\LaravelMaterializeCSS;

use Illuminate\Support\ServiceProvider;

class MaterializeCSSServiceProvider extends ServiceProvider {

protected $defer = true;

public function register() {
$this->publishes([
__DIR__.'/../assets' => public_path('materialize-css'),
], 'materializecss');
$this->registerMaterializeCSSBuilder();
$this->app->alias('materialize-css', 'Skydiver\LaravelMaterializeCSS\MaterializeCSSBuilder');
}

protected function registerMaterializeCSSBuilder() {
$this->app->bindShared('materialize-css', function($app) {
return new MaterializeCSSBuilder($app['url']);
});
}

public function provides() {
return array('materialize-css');
}

}

?>

0 comments on commit 58f22a3

Please sign in to comment.