Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

removing php implementation; updating documentation

  • Loading branch information...
commit f6edafcad95ce2fafa64f58e2a0113efa178053a 1 parent ce6766b
authored September 30, 2010
141  README.md
Source Rendered
... ...
@@ -1,7 +1,7 @@
1 1
 Depender: A MooTools Dependency Loader
2 2
 ======================================
3 3
 
4  
-This application generates concatenated libraries from multiple JavaScript files based on their dependencies and the files you require. It assumes that you have formatted your libraries in the way that MooTools is organized, though it does not require MooTools itself to operate.
  4
+This application generates concatenated libraries from multiple JavaScript files based on their dependencies and the files you require.
5 5
 
6 6
 Quick Start (Django version)
7 7
 -----------
@@ -14,62 +14,58 @@ Quick Start (Django version)
14 14
 		
15 15
 		Then open http://localhost:8000/depender/build?requireLibs=Core to get MooTools Core.
16 16
 
  17
+requirements:
  18
+
  19
+* [virtualenv](http://pypi.python.org/pypi/virtualenv)
  20
+* [python](http://www.python.org/)
  21
+
  22
+To install virtualenv on OSX, follow these instructions ([more on virtualenv](http://www.fprimex.com/coding/pymac.html)):
  23
+
  24
+	# Install easy_install and virtualenv into the system wide python package dir
  25
+	curl -O http://peak.telecommunity.com/dist/ez_setup.py > ez_setup.py
  26
+	sudo python ez_setup.py
  27
+	sudo easy_install virtualenv
  28
+	rm ez_setup.py
  29
+
  30
+Highlights
  31
+----------
  32
+
  33
+Depender can:
  34
+
  35
+* check and enforce decencies on startup
  36
+* it can also expressly just check dependencies on the command line and exit
  37
+* return a library to you with only the things you require
  38
+* return a library with what you require LESS things you already have (i.e. require=foo&exclude=bar)
  39
+* is a standalone Django app, making it deployable; it does not rely on apache / php or any other server environment
  40
+* can include in its response a JS library for loading more JS dependencies on the fly
  41
+* includes in its response a list of what is in the response and a url to recreate it
  42
+* can convert scripts.json to yaml headers and write them to JS files for you
  43
+* can convert yaml headers to scripts.json and write that to a file
  44
+* can work with both yaml header projects and scripts.json projects at the same time
  45
+* reads the entire library state into RAM, making it very, very fast; it is production ready
  46
+* can be run in debug mode, always reading from disk to allow for live development
  47
+* can be integrated with memcache for faster results
  48
+* can be configured to return compressed files; this compression only runs on startup
  49
+* can return libraries based on individual requirements (require=Core/Request) OR entire libraries (requireLib=Core)
  50
+* as a django app, it can be deployed inside another django app, meaning that you only need to start one server for your application
  51
+
17 52
 Overview
18 53
 -------
19 54
 
20  
-This is the official library builder for MooTools libraries. While this application can be used without MooTools to build libraries from other sources, it makes use of certain conventions tied to the MooTools JavaScript library and the manner in which its files are organized. In particular, the use of a file called *scripts.json* that describes the locations of scripts and their dependencies.
21  
-
22  
-The purpose of this application is to allow users to build their own libraries using MooTools files and files of their own. It can, if you choose, be used in a live environment to deliver scripts on the fly, but this is not its recommended use. It's more appropriate, especially for high-traffic applications, to use this application to output libraries and save these for deployment as static files. Linking to the application directly may produce a demand on server resources that is not acceptable.
23  
-
24  
-Included in this distribution is a PHP version of the builder and a Django/Python version. Additionally, there is a client library - Depender.Client.js - that allows for interactive, lazy-loading of required libraries. Using this client requires that you pull scripts from the Depender server, which depending on the load of your application, may not be acceptable.
25  
-
26  
-Installation
27  
-------------
28  
-
29  
-This application comes in two forms: a PHP version and a Django/Python version. Each has advantages and disadvantages.
30  
-
31  
-The PHP version of the application is very easy to deploy (just drop it into a directory in your webserver's htdocs and hit it with your browser). It also ships with a download builder interface that allows you to view the files available, click the dependencies you require and download the library. However, the PHP version is less performant than the Django version, and if you plan on deploying this server for applications to pull JavaScript from it, you should consider using the Django app. See the information on Caching below for more details on the PHP version's performance. Note that the PHP version now has support for memcache, which greatly improves its performance when enabled.
32  
-
33  
-**NOTE: The depender/php/cache directory MUST be writable by your web app**
  55
+While this application can be used without MooTools to build libraries from other sources, it makes use of certain conventions tied to the MooTools JavaScript library and the manner in which its files are organized. In particular, the use of yaml headers to declare dependencies.
34 56
 
35  
-The Django app does not have an html builder like the PHP version, but it's caching system is far more robust as it stores all scripts in memory. It is also easy to deploy assuming your server has Python running. Simply extract the files from this application onto your server and run "python manage.py runserver".
  57
+The purpose of this application is to allow users to build their own libraries using MooTools files and files of their own. It can, if you choose, be used in a live environment to deliver scripts on the fly. It's often more appropriate, especially for high-traffic applications, to use this application to output libraries and save these for deployment as static files. Linking to the application directly may produce a demand on server resources that is not acceptable. That said, this application reads the libraries to RAM and is very fast. Further, it can be configured to use something like [memcached](http://memcached.org/) for improved performance.
36 58
 
37  
-PHP Configuration
38  
----------------
39  
-Included in this distribution is a file named "config_example.json" which, if copied to "config.json" will put this app into its default mode. The values in the config.json are as follows:
40  
-
41  
-* compression - The default compression to use. Values can be "yui", "jsmin", or "none" - defaults to "none"; see compression section below for more details on compression.
42  
-* available_compressions - Supported compression types - defaults to both "yui", and "jsmin"; not all systems are set up to allow java executables at the command line (as on certain low-end hosting providers) so you may wish to disable yui. The Django app only supports yui (and none); it ignores any other listed types - so it will ignore jsmin for example.
43  
-* libs - an object pointing to each library that the builder should support. Each entry has a setting for "scripts" which points to the directory that contains *scripts.json*. From the example file:
44  
-
45  
-		"libs": {
46  
-			"mootools-core": {
47  
-				"copyright": "//MooTools, <http://mootools.net>, My Object Oriented (JavaScript) Tools. Copyright (c) 2006-2009 Valerio Proietti, <http://mad4milk.net>, MIT Style License."
48  
-				"scripts": "libs/core/Source"
49  
-			},
50  
-			"mootools-more": {
51  
-				"copyright": "//MooTools More, <http://mootools.net/more>. Copyright (c) 2006-2009 Aaron Newton <http://clientcide.com/>, Valerio Proietti <http://mad4milk.net> & the MooTools team <http://mootools.net/developers>, MIT Style License.",
52  
-				"scripts": "libs/more/Source"
53  
-			}
54  
-		}
55  
-
56  
-* cache scripts.json - When *true* the app will cash the values in the scripts.json files in your libraries and improve performance. The down side is that if you change the scripts.json, you must refresh the cache by hitting */depender/build.php?reset=true*. Note that **this value only applies to the php version** of this application, not the django version.
57  
-* output filename - the default value in the "save as" dialog without the .js suffix. Defaults to "mootools".
58  
-
59  
-### Notes
60  
-
61  
-* No two scripts in any of the libs should have the same name. So if one library has *Foo.js*, no other library should have a script with the same name. This is a remnant of the MooTools scripts.json, which wasn't designed originally to work with other scripts.json files. This naming requirement will be removed with MooTools 2.0.
62  
-* The copyrights will be included in the header of each library.
63  
-* **Important:** To use PHP to build MooTools with the new YAML headers, use Packager ([http://github.com/kamicane/packager](http://github.com/kamicane/packager)). Future versions of Depender's PHP app will support these headers. For now, either use the Django app (see below) or Packager.
  59
+This application is a [Django](http://www.djangoproject.com/) application. Additionally, there is a client library - Depender.Client.js - that allows for interactive, lazy-loading of required libraries. Using this client requires that you pull scripts from the Depender server, which depending on the load of your application, may not be acceptable.
64 60
 
65 61
 Django Configuration
66 62
 -------------------
67 63
 
68  
-The Django implementation of Depender supports both the "old" scripts.json method for naming package contents and dependencies (which suffers from a requirement that ALL scripts be named uniquely) but also the newer method that MooTools supports using YAML based manifests and headers. The package.yml and YAML fragments define package names and component names and [can be found described on the MooTools Forge in detail](http://mootools.net/forge/how-to-add). Note that the tag is not used in dependency requirements and the asterisk value is not supported. You cannot do this:
  64
+Depender supports both the "old" scripts.json method for naming package contents and dependencies (which suffers from a requirement that ALL scripts be named uniquely) but also the newer method that MooTools supports using YAML based manifests and headers. The package.yml and YAML fragments define package names and component names and [can be found described on the MooTools Forge in detail](http://mootools.net/forge/how-to-add). Note that the tag is not used in dependency requirements and the asterisk value is not supported. You cannot do this:
69 65
 
70 66
 	requires: [Core/1.2.4:'*']
71 67
 
72  
-If you specify a tag it will be ignored. Here is a valid YAML header sample:
  68
+If you specify a tag (the `1.2.4:` above) it will be ignored. Here is a valid YAML header sample:
73 69
 
74 70
 	/*
75 71
 	---
@@ -84,7 +80,7 @@ If you specify a tag it will be ignored. Here is a valid YAML header sample:
84 80
 	- Valerio Proietti
85 81
 
86 82
 	requires:
87  
-	- Core:1.2.4/Element.Event
  83
+	- Core/Element.Event
88 84
 	- Fx.Elements
89 85
 	
90 86
 	## requires: [Core/Element.Event, Fx.Elements] << also valid
@@ -115,15 +111,6 @@ The application ships with two git submodule settings - one for the most recent,
115 111
 
116 112
 This will download the libraries. 
117 113
 
118  
-Initializing the PHP instance
119  
-=============================
120  
-Copy *config_example.json* over to *config.json* and the application is ready to run. If you do not have git installed on your computer, you can simply download the MooTools Core and MooTools More libraries and unzip them into *libs/core* and *libs/more*.
121  
-
122  
-Note that the *php/cache* directory must be writable by your web server if you are using the PHP version of the library.
123  
-
124  
-Initializing the Django instance
125  
-================================
126  
-
127 114
 To run the Django depender server you should simply run this from the command line in the root of the repository:
128 115
 
129 116
 	$ virtualenv env 
@@ -146,30 +133,17 @@ Adding Libraries
146 133
 ----------------
147 134
 Additional libraries can be easily added to the system by dropping their contents into the libs/ directory and editing the appropriate config file (they do not have to reside in the libs/ directory; so long as the config points to the appropriate location). You can use git submodules to track specific branches of external repositories or you can track a working branch using something like [crepo](http://github.com/cloudera/crepo/tree/master). 
148 135
 
149  
-For the PHP version, each library *must* have a *scripts.json* file that notes dependencies. I suggest the [Moo-ish Template](http://github.com/3n/mooish-template/tree/master) as a good place to start. Otherwise use Packager for PHP ([http://github.com/kamicane/packager](http://github.com/kamicane/packager)).
150  
-
151 136
 Compression
152 137
 -----------
153 138
 
154  
-### PHP Compression
155  
-
156  
-The application includes two compression libraries: [jsmin](http://www.crockford.com/javascript/jsmin.html) which is a native php library and [yui](http://developer.yahoo.com/yui/compressor/) which is a java command line utility. Whenever a library is built, the uncompressed version of the file is saved to disk. If compression is enabled or requested the file is run through the compressor and also written to disk.
157  
-
158  
-Some systems may not be able to run the YUI compressor. For this purpose, there is another setting in the config file for "available_compressions" which is an array of the compressions you wish to support. It defaults to *[yui, jsmin]*. Setting this value to an empty array will disable compression support entirely.
159  
-
160  
-### Django/Python Compression
161  
-
162  
-The Django application also makes use of the YUI compressor. Unlike the PHP version, it doesn't cache results to disk but rather to memory, which makes it much faster and more ideal for actual deployment. Also unlike the PHP version, the Django version compresses *every* file the first time you hit it. Thus, the first request when the application starts up can take quite a while. After this, the application is very fast. Note that if you change files on the disk, the application will not pick up these changes until you restart it (unless you are in debug mode; see the section on Django Settings above).
  139
+Depender makes use of the [YUI compressor](http://developer.yahoo.com/yui/compressor/). It doesn't cache results to disk but rather to memory, which makes it much faster and more ideal for actual deployment. Startup is slow, as it compresses everything, but after this the application is very fast. Note that if you change files on the disk, the application will not pick up these changes until you restart it (unless you are in debug mode; see the section on Django Settings above). Compression is disabled in debug mode.
163 140
 
164 141
 Headers and Output
165 142
 -------
166 143
 Each file, whether compressed or not, is given a header that looks something like this:
167 144
 
168  
-	//<copyright as defined in config.json> -- Note that the Django app doesn't have support for these yet
169  
-
170  
-	//Contents: Core, Hash, Number, Function, String, Array, etc.
171  
-
172  
-	//This lib: http://localhost/depender/build.php?requireLibs=mootools-core
  145
+	//This library: http://localhost/depender/build.php?requireLibs=mootools-core
  146
+	//Contents: Core, Hash, Number, Function, String, Array, (etc.)
173 147
 
174 148
 From the header of the file you have the url needed to regenerate it as well as an inventory of the individual scripts included.
175 149
 
@@ -177,26 +151,11 @@ Requests and Query String Values
177 151
 --------------------------------
178 152
 To request a library, you can specify four arguments for the contents of the file:
179 153
 
180  
-* require - a comma separated list of *files* to require; can also be specified in the php style as "require[]=foo&require[]=bar"
181  
-* requireLibs - a comma separated list of *libraries* to require - these are the names defined in our *congfig.json* in the *libs* section. So, for example, *requireLibs=mootools-core,mootools-more* using the default config would include both the complete inventories of MooTools Core and More. This can also be specified as a comma separated list or the php style (*requireLibs[]=mootools-core&requireLibs[]=mootools-more*).
182  
-* exclude - exactly like the *require* value, except it's a list of files to exclude. This is useful if you have already loaded some scripts and now you require another. You can specify the scripts you already have and the one you now need, and the library will return only those you do not have.
183  
-* excludeLibs - just like the *exclude* option but instead you can specify entire libraries.
184  
-
185  
-### Additional Query String Values
186  
-In addition to the four values you can specify for the contents of the file, you can also override the default settings on the server for compression and caching. 
187  
-
188  
-* compression - you'll be returned the compression type you specify regardless of the server default. Note that if you specify a compression type that the server does not allow, you'll be returned which ever one it does. If it does not support compression at all, you will not be returned a compressed file. You can also specify "none" which is useful for development and debugging.
189  
-* reset - if true, destroys the cache and rebuilds it. Note that this represents an expense when compression is enabled.
  154
+* require - a comma separated list of *files* to require (`require=foo,bar`); can also be specified as `require=foo&require=bar`
  155
+* requireLibs - a comma separated list of *libraries* to require - these are the names defined the package names in each libary's package.yml or in the settings for those projects that use scripts.json. So, for example, *requireLibs=Core,More* using the default config would include both the complete inventories of MooTools Core and More. This can also be specified as a comma separated list or as `requireLibs=Core&requireLibs=More`).
  156
+* exclude - exactly like the `require` value, except it's a list of files to exclude. This is useful if you have already loaded some scripts and now you require another. You can specify the scripts you already have and the one you now need, and the library will return only those you do not have.
  157
+* excludeLibs - just like the `exclude` option but instead you can specify entire libraries.
190 158
 
191 159
 The Depender Client
192 160
 -------------------
193  
-The Depender app includes a client side component that integrates with this server. It allows you to interact with the server in your application code, requiring components and executes a callback when the load. See [the docs for the client for details](client/Docs/Depender.Client.md).
194  
-
195  
-File System Caching vs Other Options
196  
-------------------------------------
197  
-As noted above, the PHP version of this application caches files to disk (update: but also now supports memchace). Reading these files from the disk is not the best way to cache them. Every request still has to compute which items you need and check the local disk to see if the file exists. If it does php reads that file and sends it to the browser. There are other caching systems that are far more performant (such as [memcached](http://www.danga.com/memcached/) for example) that you may wish to consider. Unless you are using the system to lazy load content, you might consider downloading the built file and linking to it directly (just as if you'd downloaded it from [mootools.net](http://mootools.net) for example). For sites that do not have to support excessively large volumes of traffic you'll probably be fine just including the scripts directly from the builder (i.e. a script tag that links to "/depender/build.php?requireLibs=mootools-core"). The Django version of the application caches to memory and is much faster and more suited for live deployment.
198  
-
199  
-The Builder Interface
200  
----------------------
201  
-The PHP application ships with an HTML interface that allows you to pick and choose which files you wish to include in your download. You can easily specify your dependencies and see which files will be included with them. This interface basically just serves to help you construct the url for the library but also has a "Download" button to actually get the file if you want to save it. It can also be used to distribute your own plugins and files if you wish to share them.
202  
-
  161
+The Depender app includes a client side component that integrates with this server. It allows you to interact with the server in your application code, requiring components and executes a callback when the load. See [the docs for the client for details](client/Docs/Depender.Client.md).
291  compressors/jsmin-1.1.1.php
... ...
@@ -1,291 +0,0 @@
1  
-<?php
2  
-/**
3  
- * jsmin.php - PHP implementation of Douglas Crockford's JSMin.
4  
- *
5  
- * This is pretty much a direct port of jsmin.c to PHP with just a few
6  
- * PHP-specific performance tweaks. Also, whereas jsmin.c reads from stdin and
7  
- * outputs to stdout, this library accepts a string as input and returns another
8  
- * string as output.
9  
- *
10  
- * PHP 5 or higher is required.
11  
- *
12  
- * Permission is hereby granted to use this version of the library under the
13  
- * same terms as jsmin.c, which has the following license:
14  
- *
15  
- * --
16  
- * Copyright (c) 2002 Douglas Crockford  (www.crockford.com)
17  
- *
18  
- * Permission is hereby granted, free of charge, to any person obtaining a copy of
19  
- * this software and associated documentation files (the "Software"), to deal in
20  
- * the Software without restriction, including without limitation the rights to
21  
- * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
22  
- * of the Software, and to permit persons to whom the Software is furnished to do
23  
- * so, subject to the following conditions:
24  
- *
25  
- * The above copyright notice and this permission notice shall be included in all
26  
- * copies or substantial portions of the Software.
27  
- *
28  
- * The Software shall be used for Good, not Evil.
29  
- *
30  
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
31  
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
32  
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
33  
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
34  
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
35  
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
36  
- * SOFTWARE.
37  
- * --
38  
- *
39  
- * @package JSMin
40  
- * @author Ryan Grove <ryan@wonko.com>
41  
- * @copyright 2002 Douglas Crockford <douglas@crockford.com> (jsmin.c)
42  
- * @copyright 2008 Ryan Grove <ryan@wonko.com> (PHP port)
43  
- * @license http://opensource.org/licenses/mit-license.php MIT License
44  
- * @version 1.1.1 (2008-03-02)
45  
- * @link http://code.google.com/p/jsmin-php/
46  
- */
47  
-
48  
-class JSMin {
49  
-  const ORD_LF    = 10;
50  
-  const ORD_SPACE = 32;
51  
-
52  
-  protected $a           = '';
53  
-  protected $b           = '';
54  
-  protected $input       = '';
55  
-  protected $inputIndex  = 0;
56  
-  protected $inputLength = 0;
57  
-  protected $lookAhead   = null;
58  
-  protected $output      = '';
59  
-
60  
-  // -- Public Static Methods --------------------------------------------------
61  
-
62  
-  public static function minify($js) {
63  
-    $jsmin = new JSMin($js);
64  
-    return $jsmin->min();
65  
-  }
66  
-
67  
-  // -- Public Instance Methods ------------------------------------------------
68  
-
69  
-  public function __construct($input) {
70  
-    $this->input       = str_replace("\r\n", "\n", $input);
71  
-    $this->inputLength = strlen($this->input);
72  
-  }
73  
-
74  
-  // -- Protected Instance Methods ---------------------------------------------
75  
-
76  
-  protected function action($d) {
77  
-    switch($d) {
78  
-      case 1:
79  
-        $this->output .= $this->a;
80  
-
81  
-      case 2:
82  
-        $this->a = $this->b;
83  
-
84  
-        if ($this->a === "'" || $this->a === '"') {
85  
-          for (;;) {
86  
-            $this->output .= $this->a;
87  
-            $this->a       = $this->get();
88  
-
89  
-            if ($this->a === $this->b) {
90  
-              break;
91  
-            }
92  
-
93  
-            if (ord($this->a) <= self::ORD_LF) {
94  
-              throw new JSMinException('Unterminated string literal.');
95  
-            }
96  
-
97  
-            if ($this->a === '\\') {
98  
-              $this->output .= $this->a;
99  
-              $this->a       = $this->get();
100  
-            }
101  
-          }
102  
-        }
103  
-
104  
-      case 3:
105  
-        $this->b = $this->next();
106  
-
107  
-        if ($this->b === '/' && (
108  
-            $this->a === '(' || $this->a === ',' || $this->a === '=' ||
109  
-            $this->a === ':' || $this->a === '[' || $this->a === '!' ||
110  
-            $this->a === '&' || $this->a === '|' || $this->a === '?')) {
111  
-
112  
-          $this->output .= $this->a . $this->b;
113  
-
114  
-          for (;;) {
115  
-            $this->a = $this->get();
116  
-
117  
-            if ($this->a === '/') {
118  
-              break;
119  
-            } elseif ($this->a === '\\') {
120  
-              $this->output .= $this->a;
121  
-              $this->a       = $this->get();
122  
-            } elseif (ord($this->a) <= self::ORD_LF) {
123  
-              throw new JSMinException('Unterminated regular expression '.
124  
-                  'literal.');
125  
-            }
126  
-
127  
-            $this->output .= $this->a;
128  
-          }
129  
-
130  
-          $this->b = $this->next();
131  
-        }
132  
-    }
133  
-  }
134  
-
135  
-  protected function get() {
136  
-    $c = $this->lookAhead;
137  
-    $this->lookAhead = null;
138  
-
139  
-    if ($c === null) {
140  
-      if ($this->inputIndex < $this->inputLength) {
141  
-        $c = $this->input[$this->inputIndex];
142  
-        $this->inputIndex += 1;
143  
-      } else {
144  
-        $c = null;
145  
-      }
146  
-    }
147  
-
148  
-    if ($c === "\r") {
149  
-      return "\n";
150  
-    }
151  
-
152  
-    if ($c === null || $c === "\n" || ord($c) >= self::ORD_SPACE) {
153  
-      return $c;
154  
-    }
155  
-
156  
-    return ' ';
157  
-  }
158  
-
159  
-  protected function isAlphaNum($c) {
160  
-    return ord($c) > 126 || $c === '\\' || preg_match('/^[\w\$]$/', $c) === 1;
161  
-  }
162  
-
163  
-  protected function min() {
164  
-    $this->a = "\n";
165  
-    $this->action(3);
166  
-
167  
-    while ($this->a !== null) {
168  
-      switch ($this->a) {
169  
-        case ' ':
170  
-          if ($this->isAlphaNum($this->b)) {
171  
-            $this->action(1);
172  
-          } else {
173  
-            $this->action(2);
174  
-          }
175  
-          break;
176  
-
177  
-        case "\n":
178  
-          switch ($this->b) {
179  
-            case '{':
180  
-            case '[':
181  
-            case '(':
182  
-            case '+':
183  
-            case '-':
184  
-              $this->action(1);
185  
-              break;
186  
-
187  
-            case ' ':
188  
-              $this->action(3);
189  
-              break;
190  
-
191  
-            default:
192  
-              if ($this->isAlphaNum($this->b)) {
193  
-                $this->action(1);
194  
-              }
195  
-              else {
196  
-                $this->action(2);
197  
-              }
198  
-          }
199  
-          break;
200  
-
201  
-        default:
202  
-          switch ($this->b) {
203  
-            case ' ':
204  
-              if ($this->isAlphaNum($this->a)) {
205  
-                $this->action(1);
206  
-                break;
207  
-              }
208  
-
209  
-              $this->action(3);
210  
-              break;
211  
-
212  
-            case "\n":
213  
-              switch ($this->a) {
214  
-                case '}':
215  
-                case ']':
216  
-                case ')':
217  
-                case '+':
218  
-                case '-':
219  
-                case '"':
220  
-                case "'":
221  
-                  $this->action(1);
222  
-                  break;
223  
-
224  
-                default:
225  
-                  if ($this->isAlphaNum($this->a)) {
226  
-                    $this->action(1);
227  
-                  }
228  
-                  else {
229  
-                    $this->action(3);
230  
-                  }
231  
-              }
232  
-              break;
233  
-
234  
-            default:
235  
-              $this->action(1);
236  
-              break;
237  
-          }
238  
-      }
239  
-    }
240  
-
241  
-    return $this->output;
242  
-  }
243  
-
244  
-  protected function next() {
245  
-    $c = $this->get();
246  
-
247  
-    if ($c === '/') {
248  
-      switch($this->peek()) {
249  
-        case '/':
250  
-          for (;;) {
251  
-            $c = $this->get();
252  
-
253  
-            if (ord($c) <= self::ORD_LF) {
254  
-              return $c;
255  
-            }
256  
-          }
257  
-
258  
-        case '*':
259  
-          $this->get();
260  
-
261  
-          for (;;) {
262  
-            switch($this->get()) {
263  
-              case '*':
264  
-                if ($this->peek() === '/') {
265  
-                  $this->get();
266  
-                  return ' ';
267  
-                }
268  
-                break;
269  
-
270  
-              case null:
271  
-                throw new JSMinException('Unterminated comment.');
272  
-            }
273  
-          }
274  
-
275  
-        default:
276  
-          return $c;
277  
-      }
278  
-    }
279  
-
280  
-    return $c;
281  
-  }
282  
-
283  
-  protected function peek() {
284  
-    $this->lookAhead = $this->get();
285  
-    return $this->lookAhead;
286  
-  }
287  
-}
288  
-
289  
-// -- Exceptions ---------------------------------------------------------------
290  
-class JSMinException extends Exception {}
291  
-?>
8  compressors/jsmin.php
... ...
@@ -1,8 +0,0 @@
1  
-<?php
2  
-
3  
-function jsmin($script, $path, $root){
4  
-	include_once $root.'compressors/jsmin-1.1.1.php';
5  
-	return JSMin::minify($script);
6  
-}
7  
-
8  
-?>
11  compressors/yui.php
... ...
@@ -1,11 +0,0 @@
1  
-<?php
2  
-
3  
-function yui($input, $path, $root){
4  
-	$file = $root."compressors/yuicompressor-2.4.2.jar";
5  
-	if (!file_exists($file)) die('Could not load file: '.$file);
6  
-	if (!file_exists($path)) die('Could not load file: '.$path);
7  
-	exec("java -jar ".$file." --preserve-semi -v --line-break 150 --charset UTF-8 ".$path."", $out, $err);
8  
-	return join($out, PHP_EOL);
9  
-}
10  
-
11  
-?>
21  config/config_example.json
... ...
@@ -1,21 +0,0 @@
1  
-{
2  
-	"libs": {
3  
-		"Depender.Client": {
4  
-			"scripts": "client/Source"
5  
-		},
6  
-		"mootools-core": {
7  
-			"copyright": "//MooTools, <http://mootools.net>, My Object Oriented (JavaScript) Tools. Copyright (c) 2006-2009 Valerio Proietti, <http://mad4milk.net>, MIT Style License.",
8  
-			"scripts": "libs/core/Source"
9  
-		},
10  
-		"mootools-more": {
11  
-			"copyright": "//MooTools More, <http://mootools.net/more>. Copyright (c) 2006-2009 Aaron Newton <http://clientcide.com/>, Valerio Proietti <http://mad4milk.net> & the MooTools team <http://mootools.net/developers>, MIT Style License.",
12  
-			"scripts": "libs/more/Source"
13  
-		}
14  
-	},
15  
-	"cache" : "disk",
16  
-	"compression": "none",
17  
-	"available_compressions": ["yui", "jsmin"],
18  
-	"output filename": "mootools",
19  
-
20  
-	"php: cache scripts.json": false
21  
-}
13  django/src/depender/views.py
@@ -14,11 +14,7 @@
14 14
 LOG = logging.getLogger(__name__)
15 15
 
16 16
 def make_depender():
17  
-  try:
18  
-    return DependerData(settings.DEPENDER_PACKAGE_YMLS, settings.DEPENDER_SCRIPTS_JSON)
19  
-  except:
20  
-    logging.exception("Could not build JavaScript dependency map.")
21  
-    return None
  17
+  return DependerData(settings.DEPENDER_PACKAGE_YMLS, settings.DEPENDER_SCRIPTS_JSON)
22 18
 
23 19
 depender = make_depender()
24 20
 
@@ -79,9 +75,10 @@ def get_arr(name):
79 75
   client = get("client")
80 76
   compression = get("compression")
81 77
 
82  
-  dpdr = get_depender(reset)
83  
-  if dpdr is None:
84  
-    return HttpResponse("alert('Javascript dependency loader unavailable. Contact your administrator to check server logs for details.')")
  78
+  try:
  79
+    dpdr = get_depender(reset)
  80
+  except Exception, inst:
  81
+    return HttpResponse("alert('Javascript dependency loader unavailable. Contact your administrator to check server logs for details.\n [" + str(inst).replace("'", "\\'") +  "]')")
85 82
     
86 83
   if compression is None:
87 84
     compression = "none"
11  php/build.php
... ...
@@ -1,11 +0,0 @@
1  
-<?php
2  
-include_once 'depender.php';
3  
-
4  
-if (!file_exists('cache')) mkdir('cache');
5  
-$depender = New Depender;
6  
-if ($depender->getVar('require') || $depender->getVar('requireLibs') || $depender->getVar('client')) {
7  
-	$depender->build();
8  
-} else if ($depender->getVar('reset')) {
9  
-	$depender->deleteCache('flat');
10  
-}
11  
-
121  php/builder.form.php
... ...
@@ -1,121 +0,0 @@
1  
-<?php 
2  
-	$conf = $depender->getConfig();
3  
-?>
4  
-<form action="build.php" method="GET">
5  
-	<div class="includes">
6  
-		<dl class="sources">
7  
-		<?php 
8  
-				foreach ($depender->getLibraries() as $source => $data) {
9  
-					if ($source != "depender-client") { ?>
10  
-			<dt class="sourceHeader">
11  
-				<div class="select">
12  
-					<span class="button sourceAll">include entire library
13  
-						<input type="checkbox" value="<?php echo $source ?>" name="requireLibs[]">
14  
-					</span>
15  
-					<span class="button sourceNone">exclude entire library
16  
-						<input type="checkbox" value="<?php echo $source ?>" name="excludeLibs[]">
17  
-					</span>
18  
-				</div>
19  
-				<?php echo $conf["libs"][$source]["name"].": ".$conf["libs"][$source]["version"]; ?>
20  
-			</dt>
21  
-			<dd class="sourceContents">
22  
-				<dl class="dirs">
23  
-				<?php foreach($data as $dir => $scripts) {?>
24  
-					<dt class="dirHeader"><?php echo $dir ?></dt>
25  
-					<dd class="dirContents">
26  
-						<ul class="scripts clearfix">
27  
-						<?php foreach($scripts as $script => $details) {?>
28  
-							<li class="script">
29  
-								<b class="scriptName">
30  
-									<?php echo $script ?>
31  
-								</b>
32  
-								<?php if (isset($details["desc"])) {?>
33  
-									<div class="description"><?php echo $details["desc"]; ?></div>
34  
-								<?php } ?>
35  
-								<input type="checkbox" name="require[]" value="<?php echo $script ?>"
36  
-								 	id="<?php echo $script ?>" 
37  
-									deps="<?php echo join($details["deps"], ','); ?>"/>
38  
-							</li>
39  
-							<li class="exclude">
40  
-								<input type="checkbox" name="exclude[]" value="<?php echo $script ?>"/>
41  
-								exclude
42  
-							</li>
43  
-						<?php } ?>
44  
-						</ul>
45  
-					</dd>
46  
-				<?php } ?>
47  
-				</dl>
48  
-			</dd>
49  
-		<?php	} 
50  
-			} ?>
51  
-		</dl>
52  
-	</div>
53  
-<div id="controls">	
54  
-	<table cellpadding="0" cellspacing="0" border="0">
55  
-		<thead>
56  
-			<tr>
57  
-				<th id="compression" colspan="3">compression: </th>
58  
-			</tr>
59  
-		</thead>
60  
-		<tbody>
61  
-			<tr>
62  
-				<td id="compression_container">
63  
-					<ul>
64  
-						<?php foreach($depender->getCompressions() as $comp) { ?>
65  
-						<li><label>
66  
-							<input type="radio" name="compression" value="<?php echo $comp.'" '; if ( $comp === $depender->getDefaultCompression()) echo 'checked="checked"';?>/>
67  
-							<?php echo $comp; ?></label>
68  
-						</li>
69  
-						<?php } ?>
70  
-						<li><label>
71  
-							<input type="radio" name="compression" value=""/>
72  
-							none</label>
73  
-						</li>
74  
-					</ul>
75  
-				</td>
76  
-				<td id="client">
77  
-					integrate depender client:
78  
-					<input type="checkbox" name="client" value="true"/>
79  
-				</td>
80  
-				<td id="action_list">
81  
-					<ul>
82  
-						<li><a id="reset" class="button">Reset</a></li>
83  
-						<li><a id="download" class="button">Download</a></li>
84  
-						<li><a id="copy" class="button">Copy URL</a></li>
85  
-						<li><a id="copy_scripts" class="button">Copy &lt;script&gt;</a></li>
86  
-					</ul>
87  
-				</td>
88  
-			</tr>
89  
-		</tbody>
90  
-	</table>
91  
-</div>
92  
-</form>
93  
-<div id="help">
94  
-	<h2>Interface Usage
95  
-		<a id="close_help" class="button">close</a>
96  
-	</h2>
97  
-	<div id="help_contents">
98  
-		<h3>Step 1</h3>
99  
-		<p>Select the files you need for your application. You can select as many as you like. <b class="green">Green</b> items in the list are files that will be included in your download - these are dependencies of the files you select. You may, if you like, include entire libraries by selecting that option in the header for each library you wish to include.</p>
100  
-		<h3>Step 2</h3>
101  
-		<p>Select any files or libraries you wish to exclude. This is useful if a portion of your application has already been loaded. For example, if you load MooTools Core through the <a href="http://code.google.com/apis/ajaxlibs/documentation/index.html#mootools">Google Ajax Libraries API</a>, and you want to include a plugin from <a href="http://mootools.net/more">MooTools More</a> you can select the files you want and exclude MooTools Core, which you already have.</p>
102  
-		<h3>Step 3</h3>
103  
-		<p>Choose what compression you want for your file. The default is noted and if you make no selection this default will be used. Note that if you do not specify a compression and later the server changes configuration, scripts included directly from the builder will switch to the compression configured at that time.</p>
104  
-		<h3>Step 4</h3>
105  
-		<p>To get your library, you can download the file directly by clicking "Download." You can, alternately, copy the url to the file or copy the script tag for the url. This will pull the build library from the builder every time it is requested. If caching is enabled compressed libraries will be cached (to disk) to improve performance. Sites with high performance needs will likely want to implement a more robust caching system such as <a href="http://www.danga.com/memcached/">memcached</a>.</p>
106  
-		<h3>Output</h3>
107  
-		<p>Scripts output by this library include in their header comments a list of all files they include as well as a url that can be used to recreate them.</p>
108  
-		<h3>Configuration</h3>
109  
-		<p>See <a href="http://github.com/anutron/mootools-depender/tree/master#readme" target="readme">the readme on github</a>.</p>
110  
-	</div>
111  
-</div>
112  
-<div id="warn_url">
113  
-	You must select at least one dependency.
114  
-</div>
115  
-<div id="copier">
116  
-	<h2>Copy
117  
-		<a id="close_copier" class="button">close</a>
118  
-		</h2>
119  
-	<p>Copy the selected text:</p>
120  
-	<p><input type="text"/></p>
121  
-</div>
30  php/builder.php
... ...
@@ -1,30 +0,0 @@
1  
-<?php
2  
-include_once "depender.php";
3  
-$depender = New Depender;
4  
-?>
5  
-
6  
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
7  
-<html>
8  
-	<head>
9  
-		<title>Depender - A MooTools Dependency Builder</title>
10  
-		<link rel="stylesheet" href="../styles/reset.css" type="text/css" media="screen" title="no title" charset="utf-8">
11  
-		<link rel="stylesheet" href="../styles/depender.css" type="text/css" media="screen" title="no title" charset="utf-8">
12  
-		<script src="build.php?requireLibs=mootools-core&require=Fx.Reveal,URI,Element.Position,String.QueryString,Element.Delegation"></script>
13  
-		<script src="interface.js" type="text/javascript" charset="utf-8"></script>
14  
-	</head>
15  
-	<body>
16  
-		<h1>
17  
-			MooTools Library Builder
18  
-			<a class="button" id="help_link">Help</a>
19  
-		</h1>
20  
-		<?php include_once "builder.form.php"; ?>
21  
-
22  
-		<script>
23  
-			window.addEvent('domready', function(){
24  
-				Interface.start();
25  
-				$('help').position();
26  
-			});
27  
-		</script>
28  
-
29  
-	</body>
30  
-</html>
372  php/depender.php
... ...
@@ -1,372 +0,0 @@
1  
-<?php
2  
-
3  
-Class Depender {
4  
-	const ConfigFilename  = 'config';
5  
-	const ConfigPath  = '../config/';
6  
-	const FileRoot        = '../';
7  
-	const ScriptsFilename = 'scripts.json';
8  
-
9  
-	const Disk            = 'disk';
10  
-	const Memcache        = 'memcache';
11  
-
12  
-	const Post            = 'POST';
13  
-	const Get             = 'GET';
14  
-
15  
-	const Yui             = 'yui';
16  
-	const JSMin           = 'jsmin';
17  
-	
18  
-	private static $config;
19  
-	private static $flat;
20  
-	
21  
-	public function getConfig($reset=false) {
22  
-		if (isset(self::$config) && !$reset) return self::$config;
23  
-		$file = $this->getVar('project') ? $this->getVar('project') : self::ConfigFilename;
24  
-		$file = self::ConfigPath . $file . '.json';
25  
-		$this->checkFile($file);
26  
-		self::$config = json_decode( file_get_contents( $file ), True );
27  
-		return self::$config;
28  
-
29  
-	public function __construct() {
30  
-		$config = $this->getConfig();
31  
-		$this->cache = $config['cache'];
32  
-
33  
-		if ($this->cache == self::Memcache) {
34  
-			$this->memcache = New Memcache;
35  
-			$this->memcache->connect( 'localhost', 11211 );
36  
-		}
37  
-	}
38  
-
39  
-	public function getConfig() {
40  
-		return json_decode( file_get_contents( self::ConfigFilename ), True );
41  
-	}
42  
-	
43  
-	private function checkFile($file) {
44  
-		if (!file_exists($file)) die('Could not load file: '. realpath($file));
45  
-	}
46  
-
47  
-	public function getLibraries() {
48  
-		$all      = Array();
49  
-		$config  = $this->getConfig();
50  
-		foreach($config['libs'] as $libraryName => $library) {
51  
-			$scripts           = $this->getScriptsFromLibraryName($libraryName);
52  
-			$all[$libraryName] = $scripts;
53  
-		}
54  
-		return $all;
55  
-	}
56  
-
57  
-	private function addRoot($path) {
58  
-		if (strpos($path, '/') != 0) return self::FileRoot.$path;
59  
-		return $path;
60  
-	}
61  
-
62  
-	//decode scripts.json for a given library
63  
-	private function getScriptsFromLibraryName($name) {
64  
-		$config  = $this->getConfig();
65  
-		$library = $config['libs'][$name];
66  
-		$file = $this->addRoot($library['scripts']).'/'.self::ScriptsFilename;
67  
-		$this->checkFile($file);
68  
-		return json_decode(file_get_contents($file), True);
69  
-	}
70  
-
71  
-	//returns a list of all scripts in a library
72  
-	private function getScriptsNamesFromLibrary($library) {
73  
-		$all = Array();
74  
-		if(!isset($library)) die($library. ' not a valid library. (Check your config file)');
75  
-		foreach($library as $categoryName => $scripts) {
76  
-			foreach($scripts as $scriptName => $script) {
77  
-				$all[] = $scriptName;
78  
-			}
79  
-		}
80  
-		return $all;
81  
-	}
82  
-
83  
-	public function getCompressions() {
84  
-		$config = $this->getConfig();
85  
-		return $config['available_compressions'];
86  
-	}
87  
-
88  
-	public function getDefaultCompression() {
89  
-		$config = $this->getConfig();
90  
-		return $config['compression'];
91  
-	}
92  
-
93  
-	public function getVar($name, $default = False) {
94  
-		$var = null;
95  
-		switch ($_SERVER['REQUEST_METHOD']) {
96  
-			case self::Post:
97  
-				if (isset($_POST[$name])) $var = $_POST[$name];
98  
-				break;
99  
-			case self::Get:
100  
-				if (isset($_GET[$name])) $var = $_GET[$name];
101  
-				break;
102  
-		}
103  
-
104  
-		if ( !$var ) {
105  
-			return $default;
106  
-		}
107  
-		return $var;
108  
-	}
109  
-
110  
-	//serialize and cache dependency map
111  
-	private function getFlatData() {
112  
-		if (isset(self::$flat)) return self::$flat;
113  
-		$config  = $this->getConfig();
114  
-		$flat    = Array();
115  
-		$all     = Array();
116  
-		$cacheId = 'flat';
117  
-		$cached  = $this->getCache($cacheId);
118  
-		if ($cached && isset($config['php: cache scripts.json']) && $config['php: cache scripts.json']) {
119  
-			self::$flat = $cached;
120  
-			return $cached;
121  
-		}
122  
-		foreach($config['libs'] as $libraryName => $library) {
123  
-			$scripts = $this->getScriptsFromLibraryName($libraryName);
124  
-			if(!is_array($scripts)) die($libraryName. ' scripts.json file did not parse correctly. (Located at ' . realpath($this->addRoot($library['scripts']).'/'.self::ScriptsFilename) . ')');
125  
-			foreach($scripts as $categoryName => $categotyScripts) {
126  
-
127  
-				foreach($categotyScripts as $scriptName => $script) {
128  
-					$script['library']  = $libraryName;
129  
-					$script['category'] = $categoryName;
130  
-					$script['name']     = $scriptName;
131  
-					$script['path']     = $this->addRoot($library['scripts']).'/'.$script['category'].'/'.$script['name'].'.js';
132  
-					$all[$scriptName]   = $script;
133  
-				}
134  
-			}
135  
-		}
136  
-		$this->setCache($cacheId, $all);
137  
-		self::$flat = $all;
138  
-		return $all;
139  
-	}
140  
-
141  
-	private function getDependencies($scripts) {
142  
-		if (!is_array($scripts)) $scripts = array($scripts);
143  
-		$deps = array();
144  
-		$data = $this->getFlatData();
145  
-		foreach($scripts as $script) {
146  
-			if (!isset($data[$script])) {
147  
-				die($script." could not be found in the dependency map.");
148  
-			} else {
149  
-				foreach($data[$script]["deps"] as $dep) {
150  
-					if (!in_array($dep, $scripts)) $deps = array_merge($deps, $this->getDependencies($dep));
151  
-				}
152  
-				if (!in_array($script, $deps)) { array_push($deps, $script); }
153  
-			}
154  
-		}
155  
-		return $deps;
156  
-	}
157  
-
158  
-	private function getScriptFile($scriptName, $compression=False) {
159  
-		$flat      = $this->getFlatData();
160  
-		$script    = $flat[$scriptName];
161  
-		if (!is_array($script)) {
162  
-			return '';
163  
-		}
164  
-
165  
-		$atime     = filemtime($script['path']);
166  
-		$cacheId   = $script['name'].'_'.$atime.'_'.$compression;
167  
-		$cached    = $this->getCache($cacheId);
168  
-		if ($cached) {
169  
-			return $cached;
170  
-		}
171  
-
172  
-		$contents  = file_get_contents($script['path']);
173  
-		if ($compression && $compression != "none") {
174  
-			$contents = $this->compress($contents, $script['path'], $compression);
175  
-		}
176  
-		$this->setCache($cacheId, $contents);
177  
-		return $contents;
178  
-	}
179  
-
180  
-	public function compress($string, $path, $compression) {
181  
-		$file = self::FileRoot.'compressors/'.$compression.'.php';
182  
-		$this->checkFile($file);
183  
-		include_once($file);
184  
-		$compressed = call_user_func_array($compression, array($string, $path, self::FileRoot));
185  
-		return $compressed;
186  
-	}
187  
-
188  
-	public function header($compressed) {
189  
-		header('Cache-Control: must-revalidate');
190  
-		$filename = "built";
191  
-		$conf = $this->getConfig();
192  
-		if (isset($conf['output filename'])) $filename = $conf['output filename'];
193  
-		if ($compressed) $filename = $filename.'.compressed';
194  
-		if ($this->getVar('download')) {
195  
-			header("Content-Type: text/plain");
196  
-			header('Content-Disposition: attachment; filename="'.$filename.'.js";');
197  
-		} else {
198  
-			header("Content-Type: application/x-javascript");
199  
-		}
200  
-	}
201  
-
202  
-	private function getPageUrl() {
203  
-		$pageURL = 'http';
204  
-		if (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"]) {$pageURL .= "s";}
205  
-		$pageURL .= "://";
206  
-		if ($_SERVER["SERVER_PORT"] != "80") {
207  
-			$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
208  
-		} else {
209  
-			$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
210  
-		}
211  
-		return str_replace('&download=true', '', $pageURL);
212  
-	}
213  
-
214  
-	private function setCache($id, $value) {
215  
-		if ($this->cache == self::Disk) {
216  
-			$file = fopen('cache/'.$id, 'w+') or die("can't open file: cache/".$id);
217  
-			$result = fwrite($file, serialize($value));
218  
-			fclose($file);
219  
-			return $result;
220  
-		} else {
221  
-			return $this->memcache->set($id, $value);
222  
-		}
223  
-	}
224  
-
225  
-	private function getCache($id) {
226  
-		if ($this->cache == Disk) {
227  
-			$file = 'cache/'.$id;
228  
-			if (file_exists($file)) {
229  
-				return unserialize(file_get_contents($file));
230  
-			} else {
231  
-				return False;
232  
-			}
233  
-		} else {
234  
-			return $this->memcache->get($id);
235  
-		}
236  
-	}
237  
-
238  
-	private function deleteCache($id) {
239  
-		if ($this->cache == self::Disk) {
240  
-			$file = 'cache/'.$id;
241  
-			if (file_exists($file)) {
242  
-				return unlink($file);
243  
-			}
244  
-		} else {
245  
-			return $this->memcache->delete($id);
246  
-		}
247  
-	}
248  
-
249  
-	private function getLastModifiedDate($scripts) {
250  
-		$max  = 0;
251  
-		$flat = $this->getFlatData();
252  
-		foreach($scripts as $scriptName) {
253  
-			$script   = $flat[$scriptName];
254  
-			$modified = filemtime($script['path']);
255  
-			if ($modified > $max) {
256  
-				$max = $modified;
257  
-			}
258  
-		}
259  
-		return $max;
260  
-	}
261  
-	
262  
-	private function parseArray($str) {
263  
-		$ret = array();
264  
-		if (!is_array($str)) {
265  
-			if (strpos($str, ",") >=0) {
266  
-				$vals = explode(",", $str);
267  
-				foreach($vals as $val) {
268  
-					$ret[] = trim($val);
269  
-				}
270  
-			} else {
271  
-				$ret[] = $str;
272  
-			}
273  
-		} else if (is_array($str)){
274  
-			$ret = $str;
275  
-		}
276  
-		return $ret;
277  
-	}
278  
-
279  
-	private function dependerJs($scripts) {
280  
-		$out = PHP_EOL.PHP_EOL;
281  
-		$out .= "Depender.loaded.combine(['".join($scripts, "','")."']);".PHP_EOL;
282  
-		$out .= "Depender.setOptions({".PHP_EOL;
283  
-		$url = split("\?", $this->getPageUrl());
284  
-		$out .= "	builder: '".$url[0]."'".PHP_EOL;
285  
-		$out .= "});";
286  
-		return $out;
287  
-	}
288  
-
289  
-	public function build() {
290  
-
291  
-		if ($this->getVar('reset')) {
292  
-			$this->deleteCache('flat');
293  
-			$config = $this->getConfig(true);
294  
-		} else {
295  
-			$config = $this->getConfig();
296  
-		}
297  
-
298  
-		$include     = $this->getVar('require') ? $this->parseArray($this->getVar('require')) : Array();
299  
-		$exclude     = $this->getVar('exclude') ? $this->parseArray($this->getVar('exclude')) : Array();
300  
-		
301  
-		if ($this->getVar('client')) $include[] = "Depender.Client";
302  
-
303  
-		$includeLibs = $this->getVar('requireLibs') ? $this->parseArray($this->getVar('requireLibs')) : Array();
304  
-		$excludeLibs = $this->getVar('excludeLibs') ? $this->parseArray($this->getVar('excludeLibs')) : Array();
305  
-		$compressed = $this->getVar('compression', $config['compression']) != "none";
306  
-		$this->header($compressed);
307  
-
308  
-		$libs        = $this->getLibraries();
309  
-		$includes    = Array();
310  
-		$excludes    = Array();
311  
-
312  
-		foreach($includeLibs as $includeLib) {
313  
-			$library  = $libs[$includeLib];
314  
-			$includes = array_merge($includes, $this->getDependencies($this->getScriptsNamesFromLibrary($library)));
315  
-		}
316  
-
317  
-		foreach($include as $script) {
318  
-			$includes   = array_merge($includes, $this->getDependencies($script));
319  
-			$includes[] = $script;
320  
-		}
321  
-		$includes = array_unique($includes); //No duplicate
322  
-
323  
-		foreach($excludeLibs as $excludeLib) {
324  
-			$library  = $libs[$excludeLib];
325  
-			$excludes = array_merge($excludes, $this->getScriptsNamesFromLibrary($library));
326  
-		}
327  
-
328  
-		foreach($exclude as $script) {
329  
-			$excludes[] = $script;
330  
-		}
331  
-		$excludes = array_unique($excludes); //No duplicate
332  
-
333  
-		$includes = array_diff($includes, $excludes);
334  
-
335  
-		//$out         = join($config['copyright'], PHP_EOL).PHP_EOL.PHP_EOL;
336  
-		
337  
-		$out = "";
338  
-		
339  
-		$copyWritten = array();
340  
-		
341  
-		foreach($includes as $script) {
342  
-			if (isset($config['libs'][self::$flat[$script]['library']]['copyright']) && !isset($copyWritten[self::$flat[$script]['library']])) {
343  
-				$copyWritten[self::$flat[$script]['library']] = true;
344  
-				$out .= $config['libs'][self::$flat[$script]['library']]['copyright'].PHP_EOL;
345  
-			}
346  
-		}
347  
-		
348  
-		$out        .= PHP_EOL.'//Contents: '.join($includes, ', ').PHP_EOL.PHP_EOL;
349  
-		$out        .= '//This lib: '.$this->getPageUrl().PHP_EOL.PHP_EOL;
350  
-
351  
-		if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && $_SERVER['HTTP_IF_MODIFIED_SINCE']) {
352  
-			$browserCache = strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']);
353  
-			if ($browserCache >= $this->getLastModifiedDate($includes)) {
354  
-				header('HTTP/1.1 304 Not Modified');
355  
-				exit;
356  
-			}
357  
-		}
358  
-
359  
-		header('Last-modified: '.date('r', $this->getLastModifiedDate($includes)));
360  
-
361  
-		$compression = $this->getVar('compression', $config['compression']);
362  
-		foreach($includes as $include) {
363  
-			$out .= $this->getScriptFile($include, $compression);
364  
-		}
365  
-
366  
-		if (in_array('Depender.Client', $includes) || $this->getVar('client')) $out .= $this->dependerJs($includes);
367  
-
368  
-		print $out;
369  
-	}
370  
-}
371  
-date_default_timezone_set('UTC');
372  
-
238  php/interface.js
... ...
@@ -1,238 +0,0 @@
1  
-var Interface = {
2  
-	start: function(){
3  
-		this.setupChex();
4  
-		this.setupActions();
5  
-		this.clippers();
6  
-		this.reset();
7  
-		this.setupHelp();
8  
-	},
9  
-	setupHelp: function(){
10  
-		var help_link = $('help_link').addEvent('click', this.showHelp.bind(this));
11  
-		$('close_help').addEvent('click', this.hideHelp.bind(this));
12  
-		var help = $('help');
13  
-		$(document.body).addEvent('click', function(e){
14  
-			if ($('help').getStyle('display') != "none") {
15  
-				var target = $(e.target);
16  
-				if (target != help && !help.hasChild(target) && target != help_link) this.hideHelp();
17  
-			}
18  
-		}.bind(this));
19  
-		$(document).addEvent('keydown', function(e){
20  
-			if (e.key == "esc") this.hideHelp();
21  
-		}.bind(this));
22  
-	},
23  
-	hideHelp: function(){
24  
-		if ($('help').getStyle('display') == "none") return;
25  
-		$('help').fade('out').get('tween').chain(function(){
26  
-			$('help').setStyle('display', 'none');
27  
-		});
28  
-	},
29  
-	showHelp: function(){
30  
-		if ($('help').getStyle('display') != "none") return;
31  
-		$('help').position({
32  
-			offset: {
33  
-				y: 50
34  
-			},
35  
-			position: "topcenter",
36  
-			edge: "topcenter"
37  
-		}).setStyles({
38  
-			opacity: 0,
39  
-			display: 'block'
40  
-		}).fade('in');
41  
-	},
42  
-	setupActions: function(){
43  
-		$('reset').addEvent('click', this.reset.bind(this));
44  
-		$('download').addEvent('click', function(){
45  
-			if (this.checkUrl()) window.location.href = this.getUrl() + '&download=true';
46  
-		}.bind(this));
47  
-	},
48  
-	clippers: function(){
49  
-		//TODO