From d987010bfbe995f22081809f5cb5de8dab6d4f2e Mon Sep 17 00:00:00 2001 From: Devon Noonan Date: Mon, 1 Oct 2012 08:29:36 -0400 Subject: [PATCH] First commit of gem and assets. --- .gitignore | 17 +++++++++++++++ Gemfile | 4 ++++ LICENSE.txt | 22 +++++++++++++++++++ README.md | 40 +++++++++++++++++++++++++++++++++++ Rakefile | 1 + lib/sisyphus-rails.rb | 7 ++++++ lib/sisyphus-rails/version.rb | 5 +++++ sisyphus-rails.gemspec | 21 ++++++++++++++++++ vendor/assets/jstorage.js | 18 ++++++++++++++++ vendor/assets/sisyphus.js | 1 + 10 files changed, 136 insertions(+) create mode 100644 .gitignore create mode 100644 Gemfile create mode 100644 LICENSE.txt create mode 100644 README.md create mode 100644 Rakefile create mode 100644 lib/sisyphus-rails.rb create mode 100644 lib/sisyphus-rails/version.rb create mode 100644 sisyphus-rails.gemspec create mode 100644 vendor/assets/jstorage.js create mode 100644 vendor/assets/sisyphus.js diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d87d4be --- /dev/null +++ b/.gitignore @@ -0,0 +1,17 @@ +*.gem +*.rbc +.bundle +.config +.yardoc +Gemfile.lock +InstalledFiles +_yardoc +coverage +doc/ +lib/bundler/man +pkg +rdoc +spec/reports +test/tmp +test/version_tmp +tmp diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..9bc27d8 --- /dev/null +++ b/Gemfile @@ -0,0 +1,4 @@ +source 'https://rubygems.org' + +# Specify your gem's dependencies in sisyphus-rails.gemspec +gemspec diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..576e81e --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,22 @@ +Copyright (c) 2012 Devon Noonan + +MIT License + +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. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..26fede4 --- /dev/null +++ b/README.md @@ -0,0 +1,40 @@ +# Sisyphus::Rails + +A gem to add gmail like form saving through sisyphus.js + +## Installation + +Add this line to your application's Gemfile: + + gem 'sisyphus-rails' + +And then execute: + + $ bundle + +Or install it yourself as: + + $ gem install sisyphus-rails + +## Usage + +Requires jquery. + +## TODO + +- Tests +- Multiple library support for jStorage (Prototype, Mootools etc.) +- Support for formtastic and extending other form builders + +## Contributing + +1. Fork it +2. Create your feature branch (`git checkout -b my-new-feature`) +3. Commit your changes (`git commit -am 'Add some feature'`) +4. Push to the branch (`git push origin my-new-feature`) +5. Create new Pull Request + +## Dependencies + +https://github.com/simsalabim/sisyphus +https://github.com/andris9/jStorage \ No newline at end of file diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..2995527 --- /dev/null +++ b/Rakefile @@ -0,0 +1 @@ +require "bundler/gem_tasks" diff --git a/lib/sisyphus-rails.rb b/lib/sisyphus-rails.rb new file mode 100644 index 0000000..36eab15 --- /dev/null +++ b/lib/sisyphus-rails.rb @@ -0,0 +1,7 @@ +require "sisyphus-rails/version" + +module Sisyphus + module Rails + class Engine < ::Rails::Engine + end +end diff --git a/lib/sisyphus-rails/version.rb b/lib/sisyphus-rails/version.rb new file mode 100644 index 0000000..23c7537 --- /dev/null +++ b/lib/sisyphus-rails/version.rb @@ -0,0 +1,5 @@ +module Sisyphus + module Rails + VERSION = "0.0.1" + end +end diff --git a/sisyphus-rails.gemspec b/sisyphus-rails.gemspec new file mode 100644 index 0000000..a40d7da --- /dev/null +++ b/sisyphus-rails.gemspec @@ -0,0 +1,21 @@ +# -*- encoding: utf-8 -*- +lib = File.expand_path('../lib', __FILE__) +$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) +require 'sisyphus-rails/version' + +Gem::Specification.new do |gem| + gem.name = "sisyphus-rails" + gem.version = Sisyphus::Rails::VERSION + gem.authors = ["Devon Noonan"] + gem.email = ["devon.noonan@gmail.com"] + gem.description = %q{Include gmail like auto-save on your forms} + gem.summary = %q{Using Sisyphus.js and jStorage.js the gem overrides the default rails form builder to add an auto-save feature to your forms.} + gem.homepage = "https://www.github.com/dnoonan/sisyphus-rails" + + gem.files = `git ls-files`.split($/) + gem.test_files = gem.files.grep(%r{^(test|spec|features)/}) + gem.require_paths = ["lib"] + + gem.add_dependency "railties", "~> 3.1" + gem.add_dependency "jquery-rails" +end diff --git a/vendor/assets/jstorage.js b/vendor/assets/jstorage.js new file mode 100644 index 0000000..2887fac --- /dev/null +++ b/vendor/assets/jstorage.js @@ -0,0 +1,18 @@ +(function(){function x(a,b){function f(){if("session"==a)try{j=m.parse(window.name||"{}")}catch(b){j={}}}var h=!1,e=0,g,d,j={};Math.random();if(b||"undefined"==typeof window[a+"Storage"])if("local"==a&&window.globalStorage)localStorage=window.globalStorage[window.location.hostname];else if("userDataBehavior"==l){b&&(window[a+"Storage"]&&window[a+"Storage"].parentNode)&&window[a+"Storage"].parentNode.removeChild(window[a+"Storage"]);d=document.createElement("button");document.getElementsByTagName("head")[0].appendChild(d); +"local"==a?j=c:"session"==a&&f();for(g in j)j.hasOwnProperty(g)&&("__jstorage_meta"!=g&&"length"!=g&&"undefined"!=typeof j[g])&&(g in d||e++,d[g]=j[g]);d.length=e;d.key=function(a){var b=0,c;f();for(c in j)if(j.hasOwnProperty(c)&&"__jstorage_meta"!=c&&"length"!=c&&"undefined"!=typeof j[c]){if(b==a)return c;b++}};d.getItem=function(b){f();return"session"==a?j[b]:o.jStorage.get(b)};d.setItem=function(a,b){"undefined"!=typeof b&&(d[a]=(b||"").toString())};d.removeItem=function(b){if("local"==a)return o.jStorage.deleteKey(b); +d[b]=void 0;h=!0;b in d&&d.removeAttribute(b);h=!1};d.clear=function(){"session"==a?(window.name="",x("session",!0)):o.jStorage.flush()};"local"==a&&(z=function(a,b){"length"!=a&&(h=!0,"undefined"==typeof b?a in d&&(e--,d.removeAttribute(a)):(a in d||e++,d[a]=(b||"").toString()),d.length=e,h=!1)});d.attachEvent("onpropertychange",function(b){if("length"!=b.propertyName&&!(h||"length"==b.propertyName)){if("local"==a)!(b.propertyName in j)&&"undefined"!=typeof d[b.propertyName]&&e++;else if("session"== +a){f();"undefined"!=typeof d[b.propertyName]&&!(b.propertyName in j)?(j[b.propertyName]=d[b.propertyName],e++):"undefined"==typeof d[b.propertyName]&&b.propertyName in j?(delete j[b.propertyName],e--):j[b.propertyName]=d[b.propertyName];"session"==a&&(window.name=m.stringify(j));d.length=e;return}o.jStorage.set(b.propertyName,d[b.propertyName]);d.length=e}});window[a+"Storage"]=d}}function D(){var a="{}";if("userDataBehavior"==l){i.load("jStorage");try{a=i.getAttribute("jStorage")}catch(b){}try{q= +i.getAttribute("jStorage_update")}catch(c){}k.jStorage=a}E();y();F()}function t(){var a;clearTimeout(G);G=setTimeout(function(){if("localStorage"==l||"globalStorage"==l)a=k.jStorage_update;else if("userDataBehavior"==l){i.load("jStorage");try{a=i.getAttribute("jStorage_update")}catch(b){}}if(a&&a!=q){q=a;var f=m.parse(m.stringify(c.__jstorage_meta.CRC32)),h;D();h=m.parse(m.stringify(c.__jstorage_meta.CRC32));var e,g=[],d=[];for(e in f)f.hasOwnProperty(e)&&(h[e]?f[e]!=h[e]&&g.push(e):d.push(e));for(e in h)h.hasOwnProperty(e)&& +(f[e]||g.push(e));r(g,"updated");r(d,"deleted")}},25)}function r(a,b){a=[].concat(a||[]);if("flushed"==b){var a=[],c;for(c in n)n.hasOwnProperty(c)&&a.push(c);b="deleted"}c=0;for(var h=a.length;cB){var b=a[0],h=a[1];a=a[2];if(s[h])for(var e=0,g=s[h].length;e>>8^d;h[a]=g^-1;this.setTTL(a,f.TTL||0);z(a,b);r(a,"updated");return b},get:function(a,b){p(a);return a in c?c[a]&&"object"==typeof c[a]&&c[a]._is_xml&&c[a]._is_xml?C.decode(c[a].xml):c[a]:"undefined"==typeof b?null:b},deleteKey:function(a){p(a);return a in c?(delete c[a],"object"==typeof c.__jstorage_meta.TTL&&a in c.__jstorage_meta.TTL&&delete c.__jstorage_meta.TTL[a],delete c.__jstorage_meta.CRC32[a],z(a,void 0),v(),u(),r(a,"deleted"),!0):!1},setTTL:function(a,b){var f=+new Date;p(a); +b=Number(b)||0;return a in c?(c.__jstorage_meta.TTL||(c.__jstorage_meta.TTL={}),0