veddy 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/Rakefile +32 -0
  4. data/lib/generators/veddy/templates/config/initializers/assets.rb +1 -0
  5. data/lib/generators/veddy/templates/vendor/assets/javascripts/base64/base64-1.1.js +176 -0
  6. data/lib/generators/veddy/templates/vendor/assets/javascripts/base64/base64-1.1.min.js +26 -0
  7. data/lib/generators/veddy/templates/vendor/assets/javascripts/ved_analytics/ved_analytics-1.1.js +105 -0
  8. data/lib/generators/veddy/templates/vendor/assets/javascripts/ved_analytics/ved_analytics-1.1.min.js +59 -0
  9. data/lib/generators/veddy/veddy_generator.rb +35 -0
  10. data/lib/tasks/veddy_tasks.rake +4 -0
  11. data/lib/veddy.rb +2 -0
  12. data/lib/veddy/version.rb +3 -0
  13. data/test/dummy/README.rdoc +28 -0
  14. data/test/dummy/Rakefile +6 -0
  15. data/test/dummy/app/assets/javascripts/application.js +13 -0
  16. data/test/dummy/app/assets/stylesheets/application.css +15 -0
  17. data/test/dummy/app/controllers/application_controller.rb +5 -0
  18. data/test/dummy/app/helpers/application_helper.rb +2 -0
  19. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  20. data/test/dummy/bin/bundle +3 -0
  21. data/test/dummy/bin/rails +4 -0
  22. data/test/dummy/bin/rake +4 -0
  23. data/test/dummy/config.ru +4 -0
  24. data/test/dummy/config/application.rb +23 -0
  25. data/test/dummy/config/boot.rb +5 -0
  26. data/test/dummy/config/database.yml +25 -0
  27. data/test/dummy/config/environment.rb +5 -0
  28. data/test/dummy/config/environments/development.rb +37 -0
  29. data/test/dummy/config/environments/production.rb +83 -0
  30. data/test/dummy/config/environments/test.rb +39 -0
  31. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  32. data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
  33. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  34. data/test/dummy/config/initializers/inflections.rb +16 -0
  35. data/test/dummy/config/initializers/mime_types.rb +4 -0
  36. data/test/dummy/config/initializers/session_store.rb +3 -0
  37. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  38. data/test/dummy/config/locales/en.yml +23 -0
  39. data/test/dummy/config/routes.rb +56 -0
  40. data/test/dummy/config/secrets.yml +22 -0
  41. data/test/dummy/public/404.html +67 -0
  42. data/test/dummy/public/422.html +67 -0
  43. data/test/dummy/public/500.html +66 -0
  44. data/test/dummy/public/favicon.ico +0 -0
  45. data/test/test_helper.rb +15 -0
  46. data/test/veddy_test.rb +7 -0
  47. metadata +152 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3ebac4955da872300deb97ecffa02568cea282d6
4
+ data.tar.gz: 738af6153f2384eb905996e98de18ed633221a4c
5
+ SHA512:
6
+ metadata.gz: 2eca26a55b4a437532e9074f3287aaa3a34f34b98cd8c17914e9023a4172153f2aa16039586fe1bb576cb0dfdecbbd152f4fff523af9b5438d22a0f890efd8b5
7
+ data.tar.gz: ee125eecd4461047da85fa6bd65a89825e7582ced6377e902682f21bc31c876abbdde95a2d287f786887e9b73d97226ab9cbe20459292dd469240dc9931f4f03
@@ -0,0 +1,20 @@
1
+ Copyright 2014 YOURNAME
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,32 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'Veddy'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.rdoc')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+
18
+
19
+
20
+ Bundler::GemHelper.install_tasks
21
+
22
+ require 'rake/testtask'
23
+
24
+ Rake::TestTask.new(:test) do |t|
25
+ t.libs << 'lib'
26
+ t.libs << 'test'
27
+ t.pattern = 'test/**/*_test.rb'
28
+ t.verbose = false
29
+ end
30
+
31
+
32
+ task default: :test
@@ -0,0 +1 @@
1
+ Rails.application.config.assets.precompile += %w( base64/base64-1.1.min.js )
@@ -0,0 +1,176 @@
1
+ /*
2
+ * Copyright (c) 2010 Nick Galbreath
3
+ * http://code.google.com/p/stringencoders/source/browse/#svn/trunk/javascript
4
+ *
5
+ * Permission is hereby granted, free of charge, to any person
6
+ * obtaining a copy of this software and associated documentation
7
+ * files (the "Software"), to deal in the Software without
8
+ * restriction, including without limitation the rights to use,
9
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the
11
+ * Software is furnished to do so, subject to the following
12
+ * conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be
15
+ * included in all copies or substantial portions of the Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24
+ * OTHER DEALINGS IN THE SOFTWARE.
25
+ */
26
+
27
+ /* base64 encode/decode compatible with window.btoa/atob
28
+ *
29
+ * window.atob/btoa is a Firefox extension to convert binary data (the "b")
30
+ * to base64 (ascii, the "a").
31
+ *
32
+ * It is also found in Safari and Chrome. It is not available in IE.
33
+ *
34
+ * if (!window.btoa) window.btoa = base64.encode
35
+ * if (!window.atob) window.atob = base64.decode
36
+ *
37
+ * The original spec's for atob/btoa are a bit lacking
38
+ * https://developer.mozilla.org/en/DOM/window.atob
39
+ * https://developer.mozilla.org/en/DOM/window.btoa
40
+ *
41
+ * window.btoa and base64.encode takes a string where charCodeAt is [0,255]
42
+ * If any character is not [0,255], then an DOMException(5) is thrown.
43
+ *
44
+ * window.atob and base64.decode take a base64-encoded string
45
+ * If the input length is not a multiple of 4, or contains invalid characters
46
+ * then an DOMException(5) is thrown.
47
+ */
48
+ var base64 = {};
49
+ base64.PADCHAR = '=';
50
+ base64.ALPHA = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
51
+
52
+ base64.makeDOMException = function() {
53
+ // sadly in FF,Safari,Chrome you can't make a DOMException
54
+ var e, tmp;
55
+
56
+ try {
57
+ return new DOMException(DOMException.INVALID_CHARACTER_ERR);
58
+ } catch (tmp) {
59
+ // not available, just passback a duck-typed equiv
60
+ // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Error
61
+ // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Error/prototype
62
+ var ex = new Error("DOM Exception 5");
63
+
64
+ // ex.number and ex.description is IE-specific.
65
+ ex.code = ex.number = 5;
66
+ ex.name = ex.description = "INVALID_CHARACTER_ERR";
67
+
68
+ // Safari/Chrome output format
69
+ ex.toString = function() { return 'Error: ' + ex.name + ': ' + ex.message; };
70
+ return ex;
71
+ }
72
+ }
73
+
74
+ base64.getbyte64 = function(s,i) {
75
+ // This is oddly fast, except on Chrome/V8.
76
+ // Minimal or no improvement in performance by using a
77
+ // object with properties mapping chars to value (eg. 'A': 0)
78
+ var idx = base64.ALPHA.indexOf(s.charAt(i));
79
+ if (idx === -1) {
80
+ throw base64.makeDOMException();
81
+ }
82
+ return idx;
83
+ }
84
+
85
+ base64.decode = function(s) {
86
+ // convert to string
87
+ s = '' + s;
88
+ var getbyte64 = base64.getbyte64;
89
+ var pads, i, b10;
90
+ var imax = s.length
91
+ if (imax === 0) {
92
+ return s;
93
+ }
94
+
95
+ if (imax % 4 !== 0) {
96
+ throw base64.makeDOMException();
97
+ }
98
+
99
+ pads = 0
100
+ if (s.charAt(imax - 1) === base64.PADCHAR) {
101
+ pads = 1;
102
+ if (s.charAt(imax - 2) === base64.PADCHAR) {
103
+ pads = 2;
104
+ }
105
+ // either way, we want to ignore this last block
106
+ imax -= 4;
107
+ }
108
+
109
+ var x = [];
110
+ for (i = 0; i < imax; i += 4) {
111
+ b10 = (getbyte64(s,i) << 18) | (getbyte64(s,i+1) << 12) |
112
+ (getbyte64(s,i+2) << 6) | getbyte64(s,i+3);
113
+ x.push(String.fromCharCode(b10 >> 16, (b10 >> 8) & 0xff, b10 & 0xff));
114
+ }
115
+
116
+ switch (pads) {
117
+ case 1:
118
+ b10 = (getbyte64(s,i) << 18) | (getbyte64(s,i+1) << 12) | (getbyte64(s,i+2) << 6);
119
+ x.push(String.fromCharCode(b10 >> 16, (b10 >> 8) & 0xff));
120
+ break;
121
+ case 2:
122
+ b10 = (getbyte64(s,i) << 18) | (getbyte64(s,i+1) << 12);
123
+ x.push(String.fromCharCode(b10 >> 16));
124
+ break;
125
+ }
126
+ return x.join('');
127
+ }
128
+
129
+ base64.getbyte = function(s,i) {
130
+ var x = s.charCodeAt(i);
131
+ if (x > 255) {
132
+ throw base64.makeDOMException();
133
+ }
134
+ return x;
135
+ }
136
+
137
+ base64.encode = function(s) {
138
+ if (arguments.length !== 1) {
139
+ throw new SyntaxError("Not enough arguments");
140
+ }
141
+ var padchar = base64.PADCHAR;
142
+ var alpha = base64.ALPHA;
143
+ var getbyte = base64.getbyte;
144
+
145
+ var i, b10;
146
+ var x = [];
147
+
148
+ // convert to string
149
+ s = '' + s;
150
+
151
+ var imax = s.length - s.length % 3;
152
+
153
+ if (s.length === 0) {
154
+ return s;
155
+ }
156
+ for (i = 0; i < imax; i += 3) {
157
+ b10 = (getbyte(s,i) << 16) | (getbyte(s,i+1) << 8) | getbyte(s,i+2);
158
+ x.push(alpha.charAt(b10 >> 18));
159
+ x.push(alpha.charAt((b10 >> 12) & 0x3F));
160
+ x.push(alpha.charAt((b10 >> 6) & 0x3f));
161
+ x.push(alpha.charAt(b10 & 0x3f));
162
+ }
163
+ switch (s.length - imax) {
164
+ case 1:
165
+ b10 = getbyte(s,i) << 16;
166
+ x.push(alpha.charAt(b10 >> 18) + alpha.charAt((b10 >> 12) & 0x3F) +
167
+ padchar + padchar);
168
+ break;
169
+ case 2:
170
+ b10 = (getbyte(s,i) << 16) | (getbyte(s,i+1) << 8);
171
+ x.push(alpha.charAt(b10 >> 18) + alpha.charAt((b10 >> 12) & 0x3F) +
172
+ alpha.charAt((b10 >> 6) & 0x3f) + padchar);
173
+ break;
174
+ }
175
+ return x.join('');
176
+ }
@@ -0,0 +1,26 @@
1
+ /*
2
+ * Copyright (c) 2010 Nick Galbreath
3
+ * http://code.google.com/p/stringencoders/source/browse/#svn/trunk/javascript
4
+ *
5
+ * Permission is hereby granted, free of charge, to any person
6
+ * obtaining a copy of this software and associated documentation
7
+ * files (the "Software"), to deal in the Software without
8
+ * restriction, including without limitation the rights to use,
9
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the
11
+ * Software is furnished to do so, subject to the following
12
+ * conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be
15
+ * included in all copies or substantial portions of the Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24
+ * OTHER DEALINGS IN THE SOFTWARE.
25
+ */
26
+ var base64={};base64.PADCHAR='=';base64.ALPHA='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';base64.makeDOMException=function(){var e,tmp;try{return new DOMException(DOMException.INVALID_CHARACTER_ERR)}catch(tmp){var a=new Error("DOM Exception 5");a.code=a.number=5;a.name=a.description="INVALID_CHARACTER_ERR";a.toString=function(){return'Error: '+a.name+': '+a.message};return a}};base64.getbyte64=function(s,i){var a=base64.ALPHA.indexOf(s.charAt(i));if(a===-1){throw base64.makeDOMException();}return a};base64.decode=function(s){s=''+s;var a=base64.getbyte64;var b,i,b10;var c=s.length;if(c===0){return s}if(c%4!==0){throw base64.makeDOMException();}b=0;if(s.charAt(c-1)===base64.PADCHAR){b=1;if(s.charAt(c-2)===base64.PADCHAR){b=2}c-=4}var x=[];for(i=0;i<c;i+=4){b10=(a(s,i)<<18)|(a(s,i+1)<<12)|(a(s,i+2)<<6)|a(s,i+3);x.push(String.fromCharCode(b10>>16,(b10>>8)&0xff,b10&0xff))}switch(b){case 1:b10=(a(s,i)<<18)|(a(s,i+1)<<12)|(a(s,i+2)<<6);x.push(String.fromCharCode(b10>>16,(b10>>8)&0xff));break;case 2:b10=(a(s,i)<<18)|(a(s,i+1)<<12);x.push(String.fromCharCode(b10>>16));break}return x.join('')};base64.getbyte=function(s,i){var x=s.charCodeAt(i);if(x>255){throw base64.makeDOMException();}return x};base64.encode=function(s){if(arguments.length!==1){throw new SyntaxError("Not enough arguments");}var a=base64.PADCHAR;var b=base64.ALPHA;var c=base64.getbyte;var i,b10;var x=[];s=''+s;var d=s.length-s.length%3;if(s.length===0){return s}for(i=0;i<d;i+=3){b10=(c(s,i)<<16)|(c(s,i+1)<<8)|c(s,i+2);x.push(b.charAt(b10>>18));x.push(b.charAt((b10>>12)&0x3F));x.push(b.charAt((b10>>6)&0x3f));x.push(b.charAt(b10&0x3f))}switch(s.length-d){case 1:b10=c(s,i)<<16;x.push(b.charAt(b10>>18)+b.charAt((b10>>12)&0x3F)+a+a);break;case 2:b10=(c(s,i)<<16)|(c(s,i+1)<<8);x.push(b.charAt(b10>>18)+b.charAt((b10>>12)&0x3F)+b.charAt((b10>>6)&0x3f)+a);break}return x.join('')};
@@ -0,0 +1,105 @@
1
+ /**
2
+ This file is part of VED DECODE v1.1
3
+
4
+ Copyright 2013 Deed Poll Office Ltd, UK
5
+
6
+ Licensed under the Apache License, Version 2.0 (the "License");
7
+ you may not use this file except in compliance with the License.
8
+ You may obtain a copy of the License at
9
+
10
+ http://www.apache.org/licenses/LICENSE-2.0
11
+
12
+ Unless required by applicable law or agreed to in writing, software
13
+ distributed under the License is distributed on an "AS IS" BASIS,
14
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ See the License for the specific language governing permissions and
16
+ limitations under the License.
17
+ */
18
+
19
+ var VedDecode = VedDecode || {};
20
+ (function(_, w) {
21
+ if (!w.atob) w.atob = base64.decode;
22
+ var linkTypes = {
23
+ '22' : 'normal (universal) search result',
24
+ '1146': 'normal result thumbnail (e.g. for an application, recipe, etc.)',
25
+ '1150': 'normal result thumbnail (e.g. for an application, recipe, etc.)',
26
+ '2060': 'sitelink',
27
+ '338' : 'one-line sitelink',
28
+ '745' : 'breadcrumb',
29
+ '586' : '“Jump to” link',
30
+ '300' : 'more results link (listed mainly for Q&A websites)',
31
+ '288' : 'local search result',
32
+ '1455': 'local search result marker pin icon',
33
+ '5497': 'dictionary definition link',
34
+ '152' : 'blog search result',
35
+ '232' : 'book search result',
36
+ '235' : 'book search result thumbnail',
37
+ '1140': 'book search result author link',
38
+ '245' : 'image search result in basic image search / universal search',
39
+ '429' : 'image search result [probably not in use any more]',
40
+ '3588': 'image search result (thumbnail)',
41
+ '3598': 'image search result preview title link',
42
+ '3724': 'image search result preview grey website link underneath title',
43
+ '3597': 'image search result preview thumbnail',
44
+ '3596': 'image search result preview “View image” link',
45
+ '3599': 'image search result preview “Visit page” link',
46
+ '5077': 'in-depth article result',
47
+ '5078': 'in-depth article result thumbnail',
48
+ '1701': 'map search result',
49
+ '612' : 'map search result website link',
50
+ '646' : 'map search result thumbnail',
51
+ '297' : 'news result',
52
+ '295' : 'news result thumbnail',
53
+ '2237': 'news result video thumbnail',
54
+ '1532': 'news sub-result (i.e. the same story from a different site)',
55
+ '232' : 'patent result',
56
+ '235' : 'patent result thumbnail',
57
+ '1107': 'patent result “Overview” / “Related” / “Discuss” link',
58
+ '371' : 'shopping search result',
59
+ '311' : 'video result',
60
+ '312' : 'video result thumbnail',
61
+ '2937': 'authorship thumbnail link',
62
+ '2847': 'authorship “by [author]” link',
63
+ '2459': 'knowledge graph link',
64
+ '3836': 'knowledge graph main image',
65
+ '1732': 'knowledge graph repeated sub-link (e.g. album track listing)',
66
+ '1617': 'adword (i.e. sponsored search result)',
67
+ '706' : 'adword sitelink',
68
+ '5158': 'adword one-line sitelink',
69
+ '1987': 'sponsored shopping result (main column of universal search)',
70
+ '1986': 'sponsored shopping result thumbnail (main column of universal search)',
71
+ '1908': 'sponsored shopping result (right column of universal search)',
72
+ '1907': 'sponsored shopping result thumbnail (right column of universal search)'
73
+ },
74
+ matches = w.document.referrer.match(/[\/.]google\..*[?&]ved=([a-zA-Z0-9_:,-]+)\b/);
75
+
76
+ if (_.ved = matches && matches.length && ved_decode(matches[1]) || null) {
77
+ _.linkIndex = getOneIndexedVal(_.ved[1]);
78
+ _.linkType = linkTypes[_.ved[2]] || _.ved[2] || null;
79
+ _.resultPosition = getOneIndexedVal(_.ved[6]);
80
+ _.subResultPosition = getOneIndexedVal(_.ved[5]);
81
+ _.page = (_.ved[7] || 0) / 10 + 1;
82
+ }
83
+ function getOneIndexedVal(val) { return val != undefined ? val + 1 : null; }
84
+
85
+ function ved_decode(ved) {
86
+ var keys = { t: 2, r: 6, s: 7, i: 1 }, ret = {}, re, match;
87
+ if (ved.match(/^1/)) {
88
+ re = /([a-z]+):([0-9]+)/ig;
89
+ while ((match = re.exec(ved)) !== null)
90
+ ret[keys[match[1]] || match[1]] = parseInt(match[2], 10);
91
+ return ret;
92
+ }
93
+ ved = ved.replace(/_/, '+').replace('-', '/');
94
+ ved = w.atob((ved + "===").slice(1, ved.length + 3 - (ved.length + 2) % 4));
95
+ re = /([\x80-\xff]*[\x00-\x7f])([\x80-\xff]*[\x00-\x7f])/g;
96
+ while ((match = re.exec(ved)) !== null)
97
+ ret[varint_decode(match[1]) >> 3] = varint_decode(match[2]);
98
+ return ret;
99
+ function varint_decode(vint) {
100
+ var ret = 0, i = 0;
101
+ for (; i < vint.length; ++i) ret += (vint.charCodeAt(i) & 0x7f) << (i * 7);
102
+ return ret;
103
+ }
104
+ }
105
+ })(VedDecode, window);
@@ -0,0 +1,59 @@
1
+ /* Copyright 2013 Deed Poll Office Ltd, UK <http://deed-poll-office.org.uk>, and licensed under Apache Licence v2.0 <http://apache.org/licenses/LICENSE-2.0> */
2
+ var VedDecode=VedDecode||{};
3
+ (function(_,w){
4
+ if(!w.atob)w.atob=base64.decode;
5
+ var linkTypes={
6
+ '22' :'normal (universal) search result',
7
+ '1146':'normal result thumbnail (e.g. for an application, recipe, etc.)',
8
+ '1150':'normal result thumbnail (e.g. for an application, recipe, etc.)',
9
+ '2060':'sitelink',
10
+ '338' :'one-line sitelink',
11
+ '745' :'breadcrumb',
12
+ '586' :'“Jump to” link',
13
+ '300' :'more results link (listed mainly for Q&A websites)',
14
+ '288' :'local search result',
15
+ '1455':'local search result marker pin icon',
16
+ '5497':'dictionary definition link',
17
+ '152' :'blog search result',
18
+ '232' :'book search result',
19
+ '235' :'book search result thumbnail',
20
+ '1140':'book search result author link',
21
+ '245' :'image search result in basic image search / universal search',
22
+ '429' :'image search result [probably not in use any more]',
23
+ '3588':'image search result (thumbnail)',
24
+ '3598':'image search result preview title link',
25
+ '3724':'image search result preview grey website link underneath title',
26
+ '3597':'image search result preview thumbnail',
27
+ '3596':'image search result preview “View image” link',
28
+ '3599':'image search result preview “Visit page” link',
29
+ '5077':'in-depth article result',
30
+ '5078':'in-depth article result thumbnail',
31
+ '1701':'map search result',
32
+ '612' :'map search result website link',
33
+ '646' :'map search result thumbnail',
34
+ '297' :'news result',
35
+ '295' :'news result thumbnail',
36
+ '2237':'news result video thumbnail',
37
+ '1532':'news sub-result (i.e. the same story from a different site)',
38
+ '232' :'patent result',
39
+ '235' :'patent result thumbnail',
40
+ '1107':'patent result “Overview” / “Related” / “Discuss” link',
41
+ '371' :'shopping search result',
42
+ '311' :'video result',
43
+ '312' :'video result thumbnail',
44
+ '2937':'authorship thumbnail link',
45
+ '2847':'authorship “by [author]” link',
46
+ '2459':'knowledge graph link',
47
+ '3836':'knowledge graph main image',
48
+ '1732':'knowledge graph repeated sub-link (e.g. album track listing)',
49
+ '1617':'adword (i.e. sponsored search result)',
50
+ '706' :'adword sitelink',
51
+ '5158':'adword one-line sitelink',
52
+ '1987':'sponsored shopping result (main column of universal search)',
53
+ '1986':'sponsored shopping result thumbnail (main column of universal search)',
54
+ '1908':'sponsored shopping result (right column of universal search)',
55
+ '1907':'sponsored shopping result thumbnail (right column of universal search)'
56
+ },
57
+ m=w.document.referrer.match(/[\/.]google\..*[?&]ved=([a-zA-Z0-9_:,-]+)\b/);if(_.ved=m&&m.length&&ved_decode(m[1])||null){_.linkIndex=f(_.ved[1]);_.linkType=linkTypes[_.ved[2]]||_.ved[2]||null;_.resultPosition=f(_.ved[6]);_.subResultPosition=f(_.ved[5]);_.page=(_.ved[7]||0)/10+1}function f(a){return a!=void 0?a+1:null}
58
+ function ved_decode(c){var d={t:2,r:6,s:7,i:1},r={},g,m;if(c.match(/^1/)){g=/([a-z]+):([0-9]+)/ig;while((m=g.exec(c))!==null)r[d[m[1]]||m[1]]=parseInt(m[2],10);return r}c=c.replace(/_/,'+').replace('-','/');c=w.atob((c+"===").slice(1,c.length+3-(c.length+2)%4));g=/([\x80-\xff]*[\x00-\x7f])([\x80-\xff]*[\x00-\x7f])/g;while((m=g.exec(c))!==null)r[f(m[1])>>3]=f(m[2]);return r;function f(a){for(var b=0,i=0;i<a.length;++i)b+=(a.charCodeAt(i)&0x7f)<<(i*7);return b}}
59
+ })(VedDecode,window);
@@ -0,0 +1,35 @@
1
+ class VeddyGenerator < Rails::Generators::Base
2
+ source_root File.expand_path("../templates", __FILE__)
3
+ desc "This generator installs veddy."
4
+
5
+ def create_vendor_files
6
+ # Some browsers are not capable of Base64 decoding *cough IE10 and below*
7
+ # Nick Galbreat has gone and solved this issue for us.
8
+ template "vendor/assets/javascripts/base64/base64-1.1.js"
9
+ template "vendor/assets/javascripts/base64/base64-1.1.min.js"
10
+ # To decode the Ved parameters and set them up to be sent off to Universal
11
+ # Analytics, we use some JavaScript created by Deed Poll Office Ltd, UK
12
+ template "vendor/assets/javascripts/ved_analytics/ved_analytics-1.1.js"
13
+ template "vendor/assets/javascripts/ved_analytics/ved_analytics-1.1.min.js"
14
+ end
15
+
16
+ def mobile_installation
17
+ # Since mobile devices are not able to do hyperlink auditing,
18
+ # (well, they can, just don't expect the average user to turn it on)
19
+ # we insert a meta tag to be able to capture the ved parameter.
20
+ # Make sure that this comes before your JavaScript.
21
+ insert_into_file "app/views/layouts/application.html.erb", %Q{\n <meta name="referrer" content="origin">\n}, after: "<head>"
22
+ end
23
+
24
+ def set_up_assets
25
+ # This initializer will ensure that we don't add the Base64 encoding
26
+ # to our asset pipeline.
27
+ template "config/initializers/assets.rb"
28
+ # Now that the asset will not be included in the pipeline, we insert
29
+ # it into the layout just after the closing title tag.
30
+ insert_into_file "app/views/layouts/application.html.erb", %Q{\n\n <!--[if lt IE 10]>\n <%= javascript_include_tag 'base64/base64-1.1.min.js' %>\n <![endif]-->\n}, after: "</title>"
31
+ # To add the Ved Analytics to our asset pipeline, we make sure it is
32
+ # run first due to the dependency reasons.
33
+ insert_into_file "app/assets/javascripts/application.js", %Q{//= require ved_analytics/ved_analytics-1.1\n}, before: "//= require jquery\n"
34
+ end
35
+ end