Skip to content

Generate the structure of jquery plugins easily. Manage library dependencies such as other jquery libraries or packing code on either mac or windows. Get jsspec testing baked in. Use the familiar rake tasks to manage your jquery code base.

Notifications You must be signed in to change notification settings

toddb/jQuery-Plugin-Generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jQuery Plugin Generator

DESCRIPTION:

Generate the structure of jquery plugins easily. Manage library dependencies such as other jquery libraries or packing code on either mac or windows. Get jsspec testing baked in. Use the familiar rake tasks to manage your jquery code base.

FEATURES/PROBLEMS:

  • CAN’t have a ‘-’ or ‘.’ in the project name [need to split plugin name and filename :-)]

  • refactor jquery.rake task like compiletask as it is pretty ugly and has some spaghetti going on

  • include qunit

  • add hoe-type features for updating plugins to jquery plugin page (as rake tasks)

  • be able to bundle/package library dependencies

  • be able to switch between local and remote libraries in actual html pages (perhaps this is the release bundle)

  • be able to generate new modules and update html pages (as rake task or generator)

  • nice to remove option -p for project “jpq myplugin”

  • other packer libraries (especially for windows to avoid perl and sed dependencies)

SYNOPSIS:

jqp -p myplugin

cd myplugin
rake first_time  (this installs the latest jquery, jquery-ui & themes, builds and shows tests in browser)

jQuery plugin generator to help you kick start your plugin development with the following structure:

plugin
  /src
    /css
    /images
    query.plugin.js
  /test
    spec_plugin.js
    acceptance_plugin.js
    specs.html
    acceptance.html
  /lib
   /jsspec
   jquery.min.js
   jquery-ui.js
   /themes
     /base
  example.html
  Rakefile
  History.txt
  README.txt

It will generate a base plugin of the structure:

(function($) {

 $.jquery.test = {

VERSION: “0.0.1”, defaults: { key: ‘value’ } };

$.fn.extend({

jquery.test: function(settings) {

settings = $.extend({}, $.jquery.test.defaults, settings);    
return this.each( function(){
  self = this;

   // your plugin

})

}

})

})(jQuery);

And a base set of jsspec tests all hooked into an html page ready to go:

describe('Basic plugin initialization', {

‘before’: function() {

$(‘#jqplugin’).jqplugin() },

‘after’: function(){ },

‘should be able see that version of project’: function(){ value_of($.jqplugin.VERSION).should_be(‘0.0.1’) },

‘should be able see that element is visible’: function(){ value_of($(‘#jqplugin’).is(‘:visible’)).should_be_true() },

‘should be able to override default settings’: function(){ // over to you! },

})

Once you have written your code. You have three views of the plugin:

1. Acceptance: rake acceptance (compiles and loads tests in browser)
2. Specs: rake specs (loads tests in browser)
3. Example: rake show (compiles and loads the sample page in a browser)

Finally, package your plugin ready for uploading the plugins.jquery.com

rake package

REQUIREMENTS:

  • jquery (installed with rake:jquery)

  • WINDOWS: 7zip (7z) on your path

  • gems: rss-simple

  • svn, sed, perl

INSTALL:

  • sudo gem install jqueryplugingen

LICENSE:

(The MIT License)

Copyright © 2009 toddb

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ‘Software’), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

Generate the structure of jquery plugins easily. Manage library dependencies such as other jquery libraries or packing code on either mac or windows. Get jsspec testing baked in. Use the familiar rake tasks to manage your jquery code base.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published