Skip to content

Assets loading with themes and skins supported #191

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

Open
wants to merge 15 commits into
base: dev
Choose a base branch
from

Conversation

Yahasana
Copy link
Contributor

@Yahasana Yahasana commented Sep 15, 2018

Assets loading with themes and skins supported. assume that different apps (or plugins) are independent with each others but share the same basic modules and public resources

A) asset cases: there are stylesheet files in public css share by all apps
and app specific stylesheet locate in its directory. e.g.

  • public/css/style.css
  • public/min/css/style.min.css
  • app/account/skin/default/css/account.css
  • public/min/css/account.min.css

B) loading source and target

  1. load the min file
    • a) load from public: /css/style.css ===> public/min/css/style.min.css
      minify public/css/style.css to public/min/css/style.min.css
    • b) load from app dir: css/account.css ===> public/min/css/account.min.css
      minify account/default/css/account.css to public/min/css/account.min.css
  2. load the raw file
    • a) load from public: /css/style.css ===> public/css/style.css
    • b) load from app dir: default/css/account.css ===> public/default/css/account.css
      • i) if public/default/css/account.css not exists,
        copy account/default/css/account.css to public/default/css/
      • ii) else update account/default/css/account.css to public/default/css/

C) implement

  1. if uri is start with /, it'll try to load asset from document root
$mySkin = 'Default';

// Register specific services for the module
public function registerServices(Di $di)
{
    $di->assets->setOptions([
            'source' => __DIR__ . '/Skin/' . $mySkin . '/',
            'target' => 'min/',
            'minify' => 3
        ]);
}

// css used by specific module
// load from module dir/Skin/Default/css/account.css
$this->assets->addCss(['css/account.css']); 

// css shared by all modules
// load from document_root/Skin/Default/css/style.css
$this->assets->addCss(['/Skin/' . $mySkin . '/css/style.css']); 
  1. always store the min files in the document_root/target dir

ONE MORE THING

type parameter change from text/css or text/javascript to css or js

$assets->addCss(['css/style.css', 'type' => 'css'])
->addCss(['js/script.js', 'type' => 'js'])

but not

$assets->addCss(['css/style.css', 'type' => 'text/css'])
->addCss(['js/script.js', 'type' => 'text/javascript'])

Mofasa added 2 commits September 15, 2018 23:43
1) if `uri` is start with `/`, it'll try to load asset from document root
```php
// Register specific services for the module
public function registerServices(Di $di)
{
    $di->assets->setOptions([
            'source' => __DIR__ . '/Skin/Default/',
            'target' => 'min/',
            'minify' => 3
        ]);
}

// load from module dir/Skin/Default/css/style.css
$this->assets->addCss(['css/style.css']); 

// load from document_root/Skin/Default/css/style.css
$this->assets->addCss(['/Skin/Default/css/style.css']); 
```
2) always store the min files in the document_root/target dir
@Yahasana Yahasana closed this Sep 16, 2018
@Yahasana Yahasana reopened this Sep 16, 2018
@Yahasana Yahasana changed the title load assets from document root dir Assets loading with themes and skins supported Oct 4, 2018
@Yahasana
Copy link
Contributor Author

Yahasana commented Oct 4, 2018

@mruz please review the new features i just add to comment. i'll trying to implement it soon if you agree with that. and after that i think Ice is ready for new release and good for deploying to production

@Yahasana
Copy link
Contributor Author

Yahasana commented Oct 5, 2018

@mruz review plz

`type` parameter change from `text/css` or `text/javascript` to `css` or `js`
```php
$assets->addCss(['css/style.css', 'type' => 'css'])
->addCss(['js/script.js', 'type' => 'js'])
```
but not
```php
$assets->addCss(['css/style.css', 'type' => 'text/css'])
->addCss(['js/script.js', 'type' => 'text/javascript'])
@mruz mruz added this to the 2.0.0 milestone Oct 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants