Skip to content
Browse files

Update rails3 example

  • Loading branch information...
1 parent ce8b7f4 commit 2b6c8331ffa1593b43842b19808d36d7ec6a5d9c @ArthurN committed
View
7 examples/rails3-example/Gemfile
@@ -2,7 +2,12 @@ source 'http://rubygems.org'
gem 'rails', '>=3.0.0'
+# Pick your JS runtime (see https://github.com/sstephenson/execjs)
+gem 'therubyracer'
+#gem 'johnson'
+
# gem 'isotope'
gem 'json'
-gem 'johnson'
+gem 'execjs'
+
gem 'sqlite3-ruby', :require => 'sqlite3'
View
104 examples/rails3-example/Gemfile.lock
@@ -2,76 +2,82 @@ GEM
remote: http://rubygems.org/
specs:
abstract (1.0.0)
- actionmailer (3.0.0)
- actionpack (= 3.0.0)
- mail (~> 2.2.5)
- actionpack (3.0.0)
- activemodel (= 3.0.0)
- activesupport (= 3.0.0)
+ actionmailer (3.0.7)
+ actionpack (= 3.0.7)
+ mail (~> 2.2.15)
+ actionpack (3.0.7)
+ activemodel (= 3.0.7)
+ activesupport (= 3.0.7)
builder (~> 2.1.2)
erubis (~> 2.6.6)
- i18n (~> 0.4.1)
+ i18n (~> 0.5.0)
rack (~> 1.2.1)
- rack-mount (~> 0.6.12)
- rack-test (~> 0.5.4)
+ rack-mount (~> 0.6.14)
+ rack-test (~> 0.5.7)
tzinfo (~> 0.3.23)
- activemodel (3.0.0)
- activesupport (= 3.0.0)
+ activemodel (3.0.7)
+ activesupport (= 3.0.7)
builder (~> 2.1.2)
- i18n (~> 0.4.1)
- activerecord (3.0.0)
- activemodel (= 3.0.0)
- activesupport (= 3.0.0)
- arel (~> 1.0.0)
+ i18n (~> 0.5.0)
+ activerecord (3.0.7)
+ activemodel (= 3.0.7)
+ activesupport (= 3.0.7)
+ arel (~> 2.0.2)
tzinfo (~> 0.3.23)
- activeresource (3.0.0)
- activemodel (= 3.0.0)
- activesupport (= 3.0.0)
- activesupport (3.0.0)
- arel (1.0.1)
- activesupport (~> 3.0.0)
+ activeresource (3.0.7)
+ activemodel (= 3.0.7)
+ activesupport (= 3.0.7)
+ activesupport (3.0.7)
+ arel (2.0.10)
builder (2.1.2)
erubis (2.6.6)
abstract (>= 1.0.0)
- i18n (0.4.1)
- johnson (1.2.0)
- json (1.4.6)
- mail (2.2.7)
+ execjs (1.2.0)
+ multi_json (~> 1.0)
+ i18n (0.5.0)
+ json (1.5.3)
+ libv8 (3.3.10.2)
+ mail (2.2.19)
activesupport (>= 2.3.6)
- mime-types
- treetop (>= 1.4.5)
+ i18n (>= 0.4.0)
+ mime-types (~> 1.16)
+ treetop (~> 1.4.8)
mime-types (1.16)
+ multi_json (1.0.3)
polyglot (0.3.1)
- rack (1.2.1)
- rack-mount (0.6.13)
+ rack (1.2.3)
+ rack-mount (0.6.14)
rack (>= 1.0.0)
- rack-test (0.5.6)
+ rack-test (0.5.7)
rack (>= 1.0)
- rails (3.0.0)
- actionmailer (= 3.0.0)
- actionpack (= 3.0.0)
- activerecord (= 3.0.0)
- activeresource (= 3.0.0)
- activesupport (= 3.0.0)
- bundler (~> 1.0.0)
- railties (= 3.0.0)
- railties (3.0.0)
- actionpack (= 3.0.0)
- activesupport (= 3.0.0)
- rake (>= 0.8.4)
- thor (~> 0.14.0)
- rake (0.8.7)
+ rails (3.0.7)
+ actionmailer (= 3.0.7)
+ actionpack (= 3.0.7)
+ activerecord (= 3.0.7)
+ activeresource (= 3.0.7)
+ activesupport (= 3.0.7)
+ bundler (~> 1.0)
+ railties (= 3.0.7)
+ railties (3.0.7)
+ actionpack (= 3.0.7)
+ activesupport (= 3.0.7)
+ rake (>= 0.8.7)
+ thor (~> 0.14.4)
+ rake (0.9.0)
sqlite3-ruby (1.3.1)
- thor (0.14.3)
- treetop (1.4.8)
+ therubyracer (0.9.2)
+ libv8 (~> 3.3.10)
+ thor (0.14.6)
+ treetop (1.4.9)
polyglot (>= 0.3.1)
- tzinfo (0.3.23)
+ tzinfo (0.3.29)
PLATFORMS
ruby
DEPENDENCIES
- johnson
+ execjs
json
rails (>= 3.0.0)
sqlite3-ruby
+ therubyracer
View
61 examples/rails3-example/public/javascripts/isotope_functions.js
@@ -10,7 +10,7 @@ function getOrdinalSuffix(n) {
function formatDate(dateISO8601) {
var date = new Date(Date.parse(dateISO8601));
- return getMonthName(date.getMonth())+" "+date.getDate()+getOrdinalSuffix(date.getDate())+", "+date.getFullYear();
+ return getMonthName(date.getUTCMonth())+" "+date.getUTCDate()+getOrdinalSuffix(date.getUTCDate())+", "+date.getUTCFullYear();
}
String.prototype.parenthesize = function () {
@@ -18,29 +18,44 @@ String.prototype.parenthesize = function () {
};
/**
- * Date.parse with progressive enhancement for ISO-8601, version 2
+ * Date.parse with progressive enhancement for ISO-8601, version 5
* © 2010 Colin Snover <http://zetafleet.com>
* Released under MIT license.
*/
// http://zetafleet.com/blog/javascript-dateparse-for-iso-8601
-(function () {
- var origParse = Date.parse;
- Date.parse = function (date) {
- var timestamp = origParse(date), minutesOffset = 0, struct;
- if (isNaN(timestamp) && (struct = /^(\d{4}|[+\-]\d{6})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{3,}))?)?(?:(Z)|([+\-])(\d{2})(?::?(\d{2}))?))?/.exec(date))) {
- if (struct[8] !== 'Z') {
- minutesOffset = +struct[10] * 60 + (+struct[11]);
-
- if (struct[9] === '+') {
- minutesOffset = 0 - minutesOffset;
- }
- }
-
- if (!struct[7]) struct[7] = "0000";
-
- timestamp = new Date(+struct[1], +struct[2] - 1, +struct[3], +struct[4], +struct[5] + minutesOffset, +struct[6], +struct[7].substr(0, 3)).getTime();
- }
-
- return timestamp;
- };
-}());
+(function (Date, undefined) {
+ var origParse = Date.parse, numericKeys = [ 1, 4, 5, 6, 7, 10, 11 ];
+ Date.parse = function (date) {
+ var timestamp, struct, minutesOffset = 0;
+
+ // ES5 §15.9.4.2 states that the string should attempt to be parsed as a Date Time String Format string
+ // before falling back to any implementation-specific date parsing, so that’s what we do, even if native
+ // implementations could be faster
+ // 1 YYYY 2 MM 3 DD 4 HH 5 mm 6 ss 7 msec 8 Z 9 ± 10 tzHH 11 tzmm
+ if ((struct = /^(\d{4}|[+\-]\d{6})(?:-(\d{2})(?:-(\d{2}))?)?(?:T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{3}))?)?(?:(Z)|([+\-])(\d{2})(?::(\d{2}))?)?)?$/.exec(date))) {
+ // avoid NaN timestamps caused by “undefined” values being passed to Date.UTC
+ for (var i = 0, k; (k = numericKeys[i]); ++i) {
+ struct[k] = +struct[k] || 0;
+ }
+
+ // allow undefined days and months
+ struct[2] = (+struct[2] || 1) - 1;
+ struct[3] = +struct[3] || 1;
+
+ if (struct[8] !== 'Z' && struct[9] !== undefined) {
+ minutesOffset = struct[10] * 60 + struct[11];
+
+ if (struct[9] === '+') {
+ minutesOffset = 0 - minutesOffset;
+ }
+ }
+
+ timestamp = Date.UTC(struct[1], struct[2], struct[3], struct[4], struct[5] + minutesOffset, struct[6], struct[7]);
+ }
+ else {
+ timestamp = origParse ? origParse(date) : NaN;
+ }
+
+ return timestamp;
+ };
+}(Date));

0 comments on commit 2b6c833

Please sign in to comment.
Something went wrong with that request. Please try again.