excursion 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f24b992e399793c3aa86eda6b7600607d9a924e8
4
- data.tar.gz: 0353b3d1d9c6800aca845a832e628328c9faa4bb
3
+ metadata.gz: 96891f4a7ce51c41bee68334371e535d8f6fabaa
4
+ data.tar.gz: 2a5124e3dd90fb7ee5d9b18949c8c0fa7c56a21b
5
5
  SHA512:
6
- metadata.gz: a293070a827e2d8f47679dc52a6fbfa6fe4ae279337ba002ccbf2531e77289d1dbfe0f7b6348bbcf19cb05e8a00b504b7004ad0744198a2f0a6f6798ce4649a5
7
- data.tar.gz: 5cdd776c45f85af440e94db4d70d9fae4269019389f99427b9614cd7dbd3bc58f5b6211151e076510e679480de4141d2bd703b8b5d5770141acfcfa279d38db6
6
+ metadata.gz: 1287077e792a77abfef3c193e346546c091ae43acf868ab9b1b72ac5a9ac3bb1d6faed4c285d0d479901d9dbd8ad5a7455e4a4de0f7010a632d8f8a1aa61029a
7
+ data.tar.gz: dc007ef010aef579514a13512ce5a8ebef37b17a9676b0033f49736679a58a728ebf1c7b7599d69c6665dc41e7692a54ffccaf174f7471f1dbb8a9ee8f6d020c
@@ -0,0 +1 @@
1
+ (function() { Excursion.loadPool("<%= Base64.encode64(Excursion::Pool.all_applications.values.map(&:to_cache).to_json.to_s).gsub("\n","") %>"); }());
@@ -1,5 +1,144 @@
1
- (function() {
1
+ /*
2
+ * This Base64 object was extracted from the jquery-base64 plugin, as it was the cleanest and
3
+ * simplest implementation I could find. I have avoided jquery as a dependency for excursion
4
+ * thus far, and would like to continue doing so where possible, so the jquery wrapper was
5
+ * removed and it has been included here.
6
+ *
7
+ * Full credit for this base64 functionality goes to Carlo Zottman (https://github.com/carlo)
8
+ * and his jquery plugin jquery-base64 (https://github.com/carlo/jquery-base64)
9
+ */
10
+ Base64 = (function() {
11
+
12
+ var _PADCHAR = "=",
13
+ _ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",
14
+ _VERSION = "1.0";
15
+
16
+
17
+ function _getbyte64( s, i ) {
18
+ // This is oddly fast, except on Chrome/V8.
19
+ // Minimal or no improvement in performance by using a
20
+ // object with properties mapping chars to value (eg. 'A': 0)
21
+
22
+ var idx = _ALPHA.indexOf( s.charAt( i ) );
23
+
24
+ if ( idx === -1 ) {
25
+ throw "Cannot decode base64";
26
+ }
27
+
28
+ return idx;
29
+ }
30
+
31
+
32
+ function _decode( s ) {
33
+ var pads = 0,
34
+ i,
35
+ b10,
36
+ imax = s.length,
37
+ x = [];
38
+
39
+ s = String( s );
40
+
41
+ if ( imax === 0 ) {
42
+ return s;
43
+ }
44
+
45
+ if ( imax % 4 !== 0 ) {
46
+ throw "Cannot decode base64";
47
+ }
48
+
49
+ if ( s.charAt( imax - 1 ) === _PADCHAR ) {
50
+ pads = 1;
51
+
52
+ if ( s.charAt( imax - 2 ) === _PADCHAR ) {
53
+ pads = 2;
54
+ }
55
+
56
+ // either way, we want to ignore this last block
57
+ imax -= 4;
58
+ }
59
+
60
+ for ( i = 0; i < imax; i += 4 ) {
61
+ b10 = ( _getbyte64( s, i ) << 18 ) | ( _getbyte64( s, i + 1 ) << 12 ) | ( _getbyte64( s, i + 2 ) << 6 ) | _getbyte64( s, i + 3 );
62
+ x.push( String.fromCharCode( b10 >> 16, ( b10 >> 8 ) & 0xff, b10 & 0xff ) );
63
+ }
64
+
65
+ switch ( pads ) {
66
+ case 1:
67
+ b10 = ( _getbyte64( s, i ) << 18 ) | ( _getbyte64( s, i + 1 ) << 12 ) | ( _getbyte64( s, i + 2 ) << 6 );
68
+ x.push( String.fromCharCode( b10 >> 16, ( b10 >> 8 ) & 0xff ) );
69
+ break;
70
+
71
+ case 2:
72
+ b10 = ( _getbyte64( s, i ) << 18) | ( _getbyte64( s, i + 1 ) << 12 );
73
+ x.push( String.fromCharCode( b10 >> 16 ) );
74
+ break;
75
+ }
76
+
77
+ return x.join( "" );
78
+ }
79
+
80
+
81
+ function _getbyte( s, i ) {
82
+ var x = s.charCodeAt( i );
83
+
84
+ if ( x > 255 ) {
85
+ throw "INVALID_CHARACTER_ERR: DOM Exception 5";
86
+ }
87
+
88
+ return x;
89
+ }
90
+
91
+
92
+ function _encode( s ) {
93
+ if ( arguments.length !== 1 ) {
94
+ throw "SyntaxError: exactly one argument required";
95
+ }
96
+
97
+ s = String( s );
98
+
99
+ var i,
100
+ b10,
101
+ x = [],
102
+ imax = s.length - s.length % 3;
2
103
 
104
+ if ( s.length === 0 ) {
105
+ return s;
106
+ }
107
+
108
+ for ( i = 0; i < imax; i += 3 ) {
109
+ b10 = ( _getbyte( s, i ) << 16 ) | ( _getbyte( s, i + 1 ) << 8 ) | _getbyte( s, i + 2 );
110
+ x.push( _ALPHA.charAt( b10 >> 18 ) );
111
+ x.push( _ALPHA.charAt( ( b10 >> 12 ) & 0x3F ) );
112
+ x.push( _ALPHA.charAt( ( b10 >> 6 ) & 0x3f ) );
113
+ x.push( _ALPHA.charAt( b10 & 0x3f ) );
114
+ }
115
+
116
+ switch ( s.length - imax ) {
117
+ case 1:
118
+ b10 = _getbyte( s, i ) << 16;
119
+ x.push( _ALPHA.charAt( b10 >> 18 ) + _ALPHA.charAt( ( b10 >> 12 ) & 0x3F ) + _PADCHAR + _PADCHAR );
120
+ break;
121
+
122
+ case 2:
123
+ b10 = ( _getbyte( s, i ) << 16 ) | ( _getbyte( s, i + 1 ) << 8 );
124
+ x.push( _ALPHA.charAt( b10 >> 18 ) + _ALPHA.charAt( ( b10 >> 12 ) & 0x3F ) + _ALPHA.charAt( ( b10 >> 6 ) & 0x3f ) + _PADCHAR );
125
+ break;
126
+ }
127
+
128
+ return x.join( "" );
129
+ }
130
+
131
+
132
+ return {
133
+ decode: _decode,
134
+ encode: _encode,
135
+ VERSION: _VERSION
136
+ };
137
+
138
+ }());
139
+
140
+ (function() {
141
+
3
142
  var Application = function(app) {
4
143
  for (prop in app) {
5
144
  this[prop] = app[prop];
@@ -54,9 +193,18 @@
54
193
  },
55
194
 
56
195
  loadPool: function(pool) {
196
+ if (typeof pool == "string") {
197
+ try {
198
+ pool = eval(pool);
199
+ } catch(err) {
200
+ pool = eval(Base64.decode(pool));
201
+ }
202
+ }
203
+
57
204
  for (app in pool) {
58
205
  this.registerApplication(pool[app]);
59
206
  }
60
207
  }
61
208
  };
62
209
  }());
210
+
@@ -2,7 +2,7 @@ module Excursion
2
2
  module Helpers
3
3
  module JavascriptHelper
4
4
  def render_excursion_javascript_helpers
5
- content_tag :script, raw("Excursion.loadPool(#{raw Excursion::Pool.all_applications.values.map(&:to_cache).to_json});"), type: "text/javascript"
5
+ content_tag :script, raw("Excursion.loadPool('#{raw Base64.encode64(Excursion::Pool.all_applications.values.map(&:to_cache).to_json.to_s).gsub("\n","")}');"), type: "text/javascript"
6
6
  end
7
7
 
8
8
  end
@@ -1,3 +1,3 @@
1
1
  module Excursion
2
- VERSION = '0.1.4'
2
+ VERSION = '0.1.5'
3
3
  end