Git Product home page Git Product logo

montage's People

Contributors

jaymon avatar

Watchers

 avatar  avatar  avatar

montage's Issues

Asset pipeline

All of this was from a file called montage assets.txt (dated Sep 19, 2011 8:37pm) that was in my dropbox folder. No sense in keeping that random file when it can live here, I don't know how much (if any) I actually implemented of these notes or if the were anything other than ramblings


Asset handling

Asset
  /Assets.php
  /Asset.php
  /CssAsset.php extends Asset
  /JsAsset.php extends Asset
abstract class Asset {
  public function getPath();
  public function __toString();
}

Let's say we have a plugin that has an assets folder, then you could describe how those assets work by including a child class that extends Asset.

The Assets class will compile all assets and create Asset instances for them. How you can tell is when you grab all the pre-created Asset instances you can iterate through them and take out their paths from the compiled asset paths, then if any asset paths still remain, those need to have Asset instances automatically created for them (this might not work because if you create a CssAsset then it will try and get the absolute class using the ReflectionContainer).

Then the Asset classes will move their assets into the web/assets folder so they can be used, and the __toString() method will allow them to easily be echoed. This allows stuff like Blueprint (which is 4 or more css files) to be grouped together and to make the echoing easier.

My goal with asset management is to be able to do something like add a Blueprint plugin and then refresh the page and have blueprint be used without me having to do anything else, basically I want to write the plugin once and be able to re-use it easily.

a default method for determining order could be:

  1. all http:// remote assets
  2. any plugin assets
  3. all app assets

http://guides.rubyonrails.org/asset_pipeline.html

for example, let's say our plugin has these assets:

/Blueprint
  /assets
    Blueprint/
      /screen.css
      /ie.css
      /liquid.css

The Assets class would convert (and move the assets to the web folder) that to:

Blueprint/screen => /web/assets/Blueprint/screen-HASH.css
Blueprint/ie => web/assets/Blueprint/ie-HASH.css
Blueprint/liquid => web/assets/Blueprint/liquid-HASH.css

Then the Asset class would look something like this:

class BlueprintAsset extends \Montage\CssAsset {

  public function __construct(\Montage\Assets $assets){
  
    $this->assets = $assets;
  
  }
  
  public function getNames(){
  
    return array('Blueprint/screen','Blueprint/ie','Blueprint/liquid');
  
  }

  public function __toString(){
  
    $ret_str = '';
  
    $url_list = $this->getUrls(); // will call getNames() and generate urls
    foreach($url_list as $url){
    
      $ret_str .= $this->renderCss($url);
    
    }//foreach
  
    return $ret_str;
  
  }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.