Skip to content

Assets loading with themes and skins supported - #191

Open
Yahasana wants to merge 15 commits into
ice:devfrom
Yahasana:patch-23
Open

Assets loading with themes and skins supported#191
Yahasana wants to merge 15 commits into
ice:devfrom
Yahasana:patch-23

Conversation

@Yahasana

@YahasanaYahasana commented Sep 15, 2018

Copy link
Copy Markdown
Contributor

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 modulepublicfunctionregisterServices(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
@YahasanaYahasana reopened this Sep 16, 2018
@YahasanaYahasana changed the title load assets from document root dirAssets loading with themes and skins supportedOct 4, 2018
@Yahasana

Copy link
Copy Markdown
ContributorAuthor

@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

Comment threadice/assets.zep Outdated
@Yahasana

Copy link
Copy Markdown
ContributorAuthor

@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'])
@mruzmruz added this to the 2.0.0 milestone Oct 29, 2018
Sign up for freeto 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

@Yahasana@mruz