Conventions for Plugin directory structures?
For anyone writing and using jQuery plugins:
I've been trying to improve plugin directory structures for some time
now. The basic idea is to find a good convention and document it.
A sample of the current state is here:
http://dev.jquery.com/view/trunk/plugins/accordion/
So far it consists of a browsable folder on the root directory, demo and
test folders with index.html (giving you some running code
http://.../plugin/demo/) and a lib folder that includes plugin
dependencies. That'll always be jquery.js and zero or more plugins.
The root should always contain up-to-date .min.js, .pack.js and .zip
files - min for anyone who can leverage GZip, pack for those who can't,
zip for those who want to download the whole package.
If there is more then one demo or test page, the root demo/test page
should contain links to the other pages. Any resource related only to
demo/test are placed inside the demo/test folders (css,
background-images, testrunner).
I'm thinking about putting plugin-related resources into an "assets"
folder. Eg. here http://dev.jquery.com/view/trunk/plugins/treeview/ the
images folder and the css files would be moved to assets. I like assets
because its short. "resources" could be more obvious, but is longer and
also somewhat ambigous - resources could be anything.
So all in all the structure could look like this:
- plugin root
* jquery.plugin.js
* jquery.plugin.min.js
* jquery.plugin.pack.js
* jquery.plugin.zip
- lib
* jquery.js
* other dependencies
- assets
* jquery.plugin.css
- images
* images necessary for the plugin, eg. linked as background-images
in jquery.plugin.css
- demo
* index.html - main demo, links to other demos
* other demo related files, more demos
- test
* index.html - main test, links to other tests
* other test related files, eg. testrunner.js/css
I think this could work well for normal plugins. Once its documented and
adopted my plugins in SVN, it'll be easier much for people to browser
for plugins and find dependencies, demos, tests, resources...
I find this topic particulary interesting in regards to jQuery UI. Maybe
someone already noticed that I'm still maintaining the accordion plugin
(linked above) in its old place and just syncing the jquery.accordion.js
and ui.accordion.js files manually. I wonder if the above structure
could also be used to jQuery UI, or could be modified to be usable.
We may also get to the point where we want to split plugin files into
smaller files like we do with jQuery core. In that case it'll be easy
enough to just put them under "src" and provide an appropiate build
target. I'm happy to avoid that because I'm always forgetting to rebuild
jquery when necesseary without an automatic build...
As always, your input is very welcome!
Jörn