Page 1 of 1

AnnoLoader beta release

Posted: Mon Jan 17, 2011 11:53 am
by VladSun
http://code.google.com/p/annoloader/sou ... nnoLoader/

The problem

I have a lot of JS and CSS files needed to be loaded in a specific order based on their dependencies. I.e. an Ext.ex.grid.Panel extends the Ext.grid.Panel, so I need to load Ext.grid.Panel.js prior Ext.ex.grid.Panel.js in my HTML page. I have similar problems with CSS files - "overriding" styles should be loaded after the "original" ones.

The solution

I use PhpDoc like annotations in files that have some requirements. E.g.:

Ext.ex.grid.Panel.js

Code: Select all

/**
 * @annoloader-requires-file /Ext/grid/Panel.js
 */
In general I may have:

Code: Select all

/**
 *
 * @annoloader-requires-file 1.js
 * @annoloader-requires-file 2.js
 * 
 * @annoloader-requires-class Ext.Namespace.Class1
 * @annoloader-requires-class Ext.Namespace.Class2
 *
 * @annoloader-requires-namespace Ext.Namespace
 *
 * @annoloader-requires-directory ex/grid
 *
 * @annoloader-requires-directory-tree ex/data
 *
 */
Aliases:

Code: Select all

/**
 * the same as annoloader-requires-file
 * @annoloader-after-file /Ext/grid/Panel.css
 */
Critique needed on

1. PhpUnit tests applied (AnnoLoader_Dependency_Builder_ListTest needs more testing, but I'm not sure I do it right)
2. Patterns used
3. Decoupling

TODO

More complex caching


Thank's !!!

Re: AnnoLoader beta release

Posted: Mon Jan 24, 2011 11:44 am
by VladSun
Anyone? :(

Re: AnnoLoader beta release

Posted: Wed Feb 02, 2011 6:29 am
by Zyxist
It would be very helpful to post some examples from the PHP side, because just annotations show almost nothing, at least for me, and I could not find any examples on the project website. In addition, I think you should use PHP 5.3 namespaces, instead of the old underscore notation. More and more projects adapt it, and so should you.

Re: AnnoLoader beta release

Posted: Wed Feb 02, 2011 7:00 am
by VladSun
There is one simple example - the index.php file in the root directory
http://code.google.com/p/annoloader/sou ... /index.php

It will load all JacaScripts located in '/www/site/annoloader/scripts/test/AnnoLoader/js/ux' in order that would satisfy dependencies between them.

Another a little more complicated example:

Suppose we have:

[syntax]scripts/
/ex
/grid
Panel.js
/ux
/grid
Panel.js[/syntax]

Code: Select all

$js = new AnnoLoader_Facade_JS
(
        '/www/site/annoloader/scripts/test/AnnoLoader/scripts',
        array
        (
                'Ext.ex'        => 'ex',
                'Ext.ux'        => 'ux',
        )
);

$js->output(true);
exit();