ymdp 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. data/VERSION +1 -1
  2. data/lib/ymdp/configuration/config.rb +10 -0
  3. data/lib/ymdp/javascripts/jquery/ab_testing.js +130 -0
  4. data/lib/ymdp/javascripts/jquery/ajax.js +185 -0
  5. data/lib/ymdp/javascripts/jquery/application.js +139 -0
  6. data/lib/ymdp/javascripts/jquery/authorization.js +119 -0
  7. data/lib/ymdp/javascripts/{browser.js → jquery/browser.js} +0 -0
  8. data/lib/ymdp/javascripts/jquery/data.js +67 -0
  9. data/lib/ymdp/javascripts/jquery/debug.js +98 -0
  10. data/lib/ymdp/javascripts/jquery/education.js +168 -0
  11. data/lib/ymdp/javascripts/jquery/flash.js +76 -0
  12. data/lib/ymdp/javascripts/jquery/help.js +79 -0
  13. data/lib/ymdp/javascripts/jquery/i18n.js +293 -0
  14. data/lib/ymdp/javascripts/jquery/init.js +140 -0
  15. data/lib/ymdp/javascripts/jquery/launcher.js +153 -0
  16. data/lib/ymdp/javascripts/{logger.js → jquery/logger.js} +0 -0
  17. data/lib/ymdp/javascripts/{params.js → jquery/params.js} +0 -0
  18. data/lib/ymdp/javascripts/{reporter.js → jquery/reporter.js} +0 -0
  19. data/lib/ymdp/javascripts/jquery/tag_helper.js +180 -0
  20. data/lib/ymdp/javascripts/jquery/user.js +210 -0
  21. data/lib/ymdp/javascripts/{ab_testing.js → prototype/ab_testing.js} +0 -0
  22. data/lib/ymdp/javascripts/{ajax.js → prototype/ajax.js} +0 -0
  23. data/lib/ymdp/javascripts/{application.js → prototype/application.js} +0 -0
  24. data/lib/ymdp/javascripts/{authorization.js → prototype/authorization.js} +0 -0
  25. data/lib/ymdp/javascripts/prototype/browser.js +36 -0
  26. data/lib/ymdp/javascripts/{data.js → prototype/data.js} +0 -0
  27. data/lib/ymdp/javascripts/{debug.js → prototype/debug.js} +0 -0
  28. data/lib/ymdp/javascripts/{education.js → prototype/education.js} +0 -0
  29. data/lib/ymdp/javascripts/{flash.js → prototype/flash.js} +0 -0
  30. data/lib/ymdp/javascripts/{help.js → prototype/help.js} +0 -0
  31. data/lib/ymdp/javascripts/{i18n.js → prototype/i18n.js} +0 -0
  32. data/lib/ymdp/javascripts/{init.js → prototype/init.js} +0 -0
  33. data/lib/ymdp/javascripts/{launcher.js → prototype/launcher.js} +0 -0
  34. data/lib/ymdp/javascripts/prototype/logger.js +27 -0
  35. data/lib/ymdp/javascripts/prototype/params.js +35 -0
  36. data/lib/ymdp/javascripts/prototype/reporter.js +47 -0
  37. data/lib/ymdp/javascripts/{tag_helper.js → prototype/tag_helper.js} +0 -0
  38. data/lib/ymdp/javascripts/{user.js → prototype/user.js} +0 -0
  39. data/lib/ymdp/view/application_view.rb +5 -1
  40. data/ymdp.gemspec +38 -20
  41. metadata +40 -22
@@ -0,0 +1,210 @@
1
+ // gets user's state info from /ymdp/state
2
+ // including the user's OIB login
3
+ //
4
+ YMDP.getUserState = function(success_function, error_function) {
5
+ Debug.log("YMDP.getUserState");
6
+ OIB.get("ymdp/state", {}, function(response) {
7
+ Debug.log("YMDP.getUserState callback", response);
8
+ YMDP.setUserVariables(response);
9
+
10
+ if (success_function) {
11
+ Debug.log("YMDP.getUserState: About to success function")
12
+ success_function(response);
13
+ }
14
+ },
15
+ function() {
16
+ Debug.log("Failed to get user's state");
17
+ if (error_function) {
18
+ error_function();
19
+ }
20
+ });
21
+ };
22
+
23
+ YMDP.setUserVariables = function(response) {
24
+ YMDP.response = response;
25
+ try {
26
+ YMDP.since_date = formatUnixDate(YMDP.response.since_date.s);
27
+ } catch(omg) {
28
+ YMDP.since_date = 1294869484;
29
+ }
30
+ YMDP.login = response.login;
31
+ YMDP.state = response.state;
32
+ };
33
+
34
+ /*
35
+ YMDP.verifyUser
36
+
37
+ global to all views. calls the 'verify' action on ymdp controller and executes
38
+ a function with the result.
39
+
40
+ Sends the server the user's guid and 'ymail_wssid', which signs the user in if the
41
+ values match what we have in the database.
42
+ */
43
+ YMDP.verifyUser = function(success_function, error_function) {
44
+ Debug.log("YMDP.verifyUser");
45
+
46
+ OIB.get("ymdp/verify", {
47
+ ymail_guid: YMDP.guid,
48
+ ymail_wssid: YMDP.ymail_wssid
49
+ }, function(response) {
50
+ YMDP.user = response;
51
+ Debug.log("YMDP.verifyUser YMDP.user", YMDP.user);
52
+ if (success_function) {
53
+ Debug.log("YMDP.verifyUser: About to success function");
54
+ success_function(YMDP.user);
55
+ }
56
+ }, error_function);
57
+ };
58
+
59
+
60
+ /*
61
+ AUTHENTICATION
62
+ */
63
+
64
+ // Gets the ymail_wssid which is stored in the database on the remote server
65
+ // for the current user.
66
+ //
67
+ YMDP.confirm = function() {
68
+ Debug.log("YMDP.confirm");
69
+ OIB.get("ymdp/signin", {
70
+ "ymail_guid": YMDP.guid
71
+ }, function(response) {
72
+ Debug.log("inside ymdp/signin callback", response);
73
+
74
+ if (response.ymail_wssid) {
75
+ Debug.log("YMDP.response wasn't false");
76
+ // store ymail_wssid in permanent store
77
+
78
+ var raw_wssid = response.ymail_wssid || "";
79
+ var sliced_wssid = raw_wssid.slice(0, 255);
80
+
81
+ var data = {
82
+ "ymail_wssid": sliced_wssid
83
+ };
84
+
85
+ Debug.log("About to call Data.store", data);
86
+
87
+ Data.store(data);
88
+ YMDP.ymail_wssid = response.ymail_wssid;
89
+
90
+ // now that we've got their ymail_wssid, we can sign them in:
91
+ YMDP.verifyUser(Launcher.launchMain);
92
+ // Launcher.launchMain();
93
+ } else {
94
+ // signin didn't work properly, display an error
95
+ Debug.log("YMDP.response was false");
96
+ YMDP.showError({
97
+ "method": "YMDP.confirm",
98
+ "description": "no ymail_wssid"
99
+ });
100
+ }
101
+ });
102
+ };
103
+
104
+ // gets both guid and ymail_wssid and stores them then runs the callback_function
105
+ //
106
+ // YMDP.ymail_wssid
107
+ // YMDP.guid
108
+ //
109
+ YMDP.getGuidAndYmailWssid = function(callback_function) {
110
+ Debug.log("YMDP.getGuidAndYmailWssid");
111
+ YMDP.getGuid(function(guid) {
112
+ YMDP.getYmailWssid(function(ymail_wssid) {
113
+ callback_function(guid, ymail_wssid);
114
+ });
115
+ });
116
+ };
117
+
118
+ // gets the ymail_wssid from the permanent store and executes the callback function
119
+ // if there is a ymail_wssid, and the error callback if it's undefined
120
+ //
121
+ // YMDP.ymail_wssid
122
+ //
123
+ YMDP.getYmailWssid = function(success_function, error_function) {
124
+ Debug.log("YMDP.getYmailWssid");
125
+
126
+ // this function will show the error page if the ymail_wssid has not been set
127
+ //
128
+ var show_error = function() {
129
+ if (!YMDP.ymail_wssid) {
130
+ Debug.log("No YMDP.ymail_wssid");
131
+
132
+ YMDP.showError({
133
+ "retry": "hide"
134
+ });
135
+ }
136
+ };
137
+
138
+ // run the show_error function after 5 seconds
139
+ //
140
+ // Debug.log("Set timeout for error function to 10 seconds");
141
+ // YMDP.setTimeoutInSeconds(show_error, 10);
142
+ // Debug.log("About to call Data.fetch");
143
+
144
+ // retrieve the user's ymail_wssid and store it in YMDP.ymail_wssid
145
+ //
146
+ Data.fetch(["ymail_wssid"], function(response) {
147
+ Debug.log("Inside Data.fetch callback");
148
+ YMDP.ymail_wssid = response.data.ymail_wssid;
149
+
150
+ Debug.log("YMDP.ymail_wssid is defined", YMDP.ymail_wssid);
151
+
152
+ try {
153
+ success_function(YMDP.ymail_wssid);
154
+ } catch(omg) {
155
+ Debug.error("Error in YMDP.getYmailWssid getData callback", omg);
156
+ }
157
+ });
158
+ };
159
+
160
+ // gets the guid from the Yahoo! environment and executes the success callback
161
+ // if there is a guid, and the error callback if it's undefined
162
+ //
163
+ // YMDP.guid
164
+ //
165
+ YMDP.getGuid = function(success_function, error_function) {
166
+ Debug.log("YMDP.getGuid");
167
+
168
+ openmail.Application.getParameters(function(response) {
169
+ Debug.log("getParameters callback");
170
+ YMDP.guid = response.user.guid;
171
+ try {
172
+ Debug.log("YMDP.getGuid getParameters response", response);
173
+
174
+ var params = {};
175
+ if (response.data) {
176
+ params = response.data.launchParams;
177
+ }
178
+ Params.init(params);
179
+ } catch(omg) {
180
+ Debug.error("error getting parameters: " + omg);
181
+ }
182
+ if (YMDP.guid !== undefined) {
183
+ success_function(YMDP.guid);
184
+ }
185
+ else {
186
+ error_function();
187
+ }
188
+ });
189
+ };
190
+
191
+ YMDP.deactivateUser = function() {
192
+ YMDP.getGuidAndYmailWssid(function() {
193
+ var guid, ymail_wssid;
194
+
195
+ guid = YMDP.guid;
196
+ ymail_wssid = YMDP.ymail_wssid;
197
+
198
+ Data.clear();
199
+
200
+ OIB.post("/ymdp/deactivate", {
201
+ "ymail_guid": guid,
202
+ "ymail_wssid": ymail_wssid
203
+ },
204
+ function(response) {
205
+ if (View.name !== "deactivate") {
206
+ Launcher.launchGoodbye();
207
+ }
208
+ });
209
+ });
210
+ };
File without changes
@@ -0,0 +1,36 @@
1
+ var Browser;
2
+
3
+ Browser = {
4
+ version: function(v) {
5
+ var version, app_version;
6
+ app_version = navigator.appVersion;
7
+ Debug.log("Browser app_version: ", app_version);
8
+
9
+ if (app_version.match("MSIE 6.0")) {
10
+ version = 6.0;
11
+ }
12
+
13
+ if (v) {
14
+ return (version === v);
15
+ } else {
16
+ return version;
17
+ }
18
+ },
19
+
20
+ ie: function() {
21
+ return navigator.appName.match("Internet Explorer");
22
+ },
23
+
24
+ ie6: function() {
25
+ return (Browser.ie() && Browser.version(6.0));
26
+ },
27
+
28
+ ie7: function() {
29
+ return (Browser.ie() && Browser.version(7.0));
30
+ },
31
+
32
+ ie8: function() {
33
+ return (Browser.ie() && Browser.version(8.0));
34
+ }
35
+ };
36
+
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,27 @@
1
+ var Logger;
2
+
3
+ Logger = {
4
+ on: false,
5
+
6
+ init: function() {
7
+ OIB.get("ymdp/state", {}, function(response) {
8
+ Logger.on = response.observe;
9
+ });
10
+ },
11
+
12
+ observe: function(message) {
13
+ if (this.on) {
14
+ this.log(message);
15
+ }
16
+ },
17
+
18
+ log: function(message) {
19
+ // console.log("LOGGING " + message);
20
+ OIB.post("ymdp/logs", {
21
+ "_hide_debug": true,
22
+ "log": message
23
+ }, function() {
24
+
25
+ });
26
+ }
27
+ };
@@ -0,0 +1,35 @@
1
+ var Params = {
2
+ names: ["invitation", "page"],
3
+ parameters: {},
4
+
5
+ init: function(launchParams) {
6
+ launchParams = launchParams || {};
7
+ Debug.log("Params.init", launchParams);
8
+
9
+ try {
10
+ if (launchParams) {
11
+ Params.parameters = launchParams;
12
+ } else {
13
+ Params.parameters = {};
14
+ }
15
+ } catch(wtf) {
16
+ Debug.error(wtf);
17
+ }
18
+ },
19
+
20
+ get: function(name) {
21
+ Debug.log("Params.get", name);
22
+ var index, result;
23
+
24
+ try {
25
+ index = Params.names.indexOf(name);
26
+
27
+ if (index >= 0) {
28
+ result = Params.parameters["param" + index];
29
+ }
30
+ } catch(wtf) {
31
+ Debug.error(wtf);
32
+ }
33
+ return result;
34
+ }
35
+ };
@@ -0,0 +1,47 @@
1
+ // DO NOT USE the @view instance variable in any files in /app/javascripts/base.
2
+ // The way they are cached makes it not safe to do so.
3
+
4
+ var Reporter;
5
+
6
+ // Reports pageviews to OIB for tracking counts of each pageview.
7
+ //
8
+ // The main interface to this class is located in "header.js" where it can
9
+ // make use of the current view name.
10
+ //
11
+ // == Usage
12
+ //
13
+ // Reporter.reportCurrentView(guid);
14
+ //
15
+ Reporter = {
16
+ error: function(guid, params) {
17
+ // Debug.log("Reporter.error", params);
18
+ Reporter.report(guid, "error", params);
19
+ },
20
+
21
+ reportCurrentView: function(guid) {
22
+ Reporter.report(guid, View.name);
23
+ },
24
+
25
+ // Report the Ymail guid and page view name to OIB.
26
+ //
27
+ report: function(guid, view, params) {
28
+ params = params || {};
29
+
30
+ params["ymail_guid"] = guid;
31
+ params["view"] = view;
32
+
33
+ // Debug.log("Reporting guid " + guid + ", view " + view);
34
+ Reporter.post(params);
35
+ },
36
+
37
+ // Post data back to OIB, to the URL /ymdp/report.
38
+ //
39
+ post: function(params) {
40
+ params = params || {};
41
+ OIB.post("ymdp/report", params, function(response) {
42
+ // Debug.log("Reported page view", params);
43
+ }, function(response) {
44
+ // Debug.error("Error reporting page view with params", response);
45
+ });
46
+ },
47
+ };
File without changes
@@ -251,10 +251,14 @@ module YMDP
251
251
  end
252
252
 
253
253
  def render_default_javascripts(options={})
254
+ library_path = options[:library] || configuration.javascript_library || "jquery"
255
+
256
+ # Javascripts need to be loaded in a certain order, this is why we don't just load everything at once
257
+ #
254
258
  default_javascripts = ['application', 'params', 'browser', 'data', 'ajax', 'user', 'init', 'reporter', 'debug', 'tag_helper', 'launcher', 'logger', 'i18n', 'flash', 'ab_testing', 'education', 'authorization']
255
259
 
256
260
  filenames = default_javascripts.map do |filename|
257
- File.join(File.dirname(__FILE__), "..", "javascripts", "#{filename}.js")
261
+ File.join(File.dirname(__FILE__), "..", "javascripts", library_path, "#{filename}.js")
258
262
  end
259
263
 
260
264
  filenames = filter_filenames(filenames, options)
data/ymdp.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{ymdp}
8
- s.version = "0.6.0"
8
+ s.version = "0.7.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Isaac Priestley"]
12
- s.date = %q{2011-05-06}
12
+ s.date = %q{2011-05-13}
13
13
  s.description = %q{Framework for developing applications in the Yahoo! Mail Development Platform.}
14
14
  s.email = %q{progressions@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -54,24 +54,42 @@ Gem::Specification.new do |s|
54
54
  "lib/ymdp/generator/templates/stylesheet.css",
55
55
  "lib/ymdp/generator/templates/translation.pres",
56
56
  "lib/ymdp/generator/templates/view.html.haml",
57
- "lib/ymdp/javascripts/ab_testing.js",
58
- "lib/ymdp/javascripts/ajax.js",
59
- "lib/ymdp/javascripts/application.js",
60
- "lib/ymdp/javascripts/authorization.js",
61
- "lib/ymdp/javascripts/browser.js",
62
- "lib/ymdp/javascripts/data.js",
63
- "lib/ymdp/javascripts/debug.js",
64
- "lib/ymdp/javascripts/education.js",
65
- "lib/ymdp/javascripts/flash.js",
66
- "lib/ymdp/javascripts/help.js",
67
- "lib/ymdp/javascripts/i18n.js",
68
- "lib/ymdp/javascripts/init.js",
69
- "lib/ymdp/javascripts/launcher.js",
70
- "lib/ymdp/javascripts/logger.js",
71
- "lib/ymdp/javascripts/params.js",
72
- "lib/ymdp/javascripts/reporter.js",
73
- "lib/ymdp/javascripts/tag_helper.js",
74
- "lib/ymdp/javascripts/user.js",
57
+ "lib/ymdp/javascripts/jquery/ab_testing.js",
58
+ "lib/ymdp/javascripts/jquery/ajax.js",
59
+ "lib/ymdp/javascripts/jquery/application.js",
60
+ "lib/ymdp/javascripts/jquery/authorization.js",
61
+ "lib/ymdp/javascripts/jquery/browser.js",
62
+ "lib/ymdp/javascripts/jquery/data.js",
63
+ "lib/ymdp/javascripts/jquery/debug.js",
64
+ "lib/ymdp/javascripts/jquery/education.js",
65
+ "lib/ymdp/javascripts/jquery/flash.js",
66
+ "lib/ymdp/javascripts/jquery/help.js",
67
+ "lib/ymdp/javascripts/jquery/i18n.js",
68
+ "lib/ymdp/javascripts/jquery/init.js",
69
+ "lib/ymdp/javascripts/jquery/launcher.js",
70
+ "lib/ymdp/javascripts/jquery/logger.js",
71
+ "lib/ymdp/javascripts/jquery/params.js",
72
+ "lib/ymdp/javascripts/jquery/reporter.js",
73
+ "lib/ymdp/javascripts/jquery/tag_helper.js",
74
+ "lib/ymdp/javascripts/jquery/user.js",
75
+ "lib/ymdp/javascripts/prototype/ab_testing.js",
76
+ "lib/ymdp/javascripts/prototype/ajax.js",
77
+ "lib/ymdp/javascripts/prototype/application.js",
78
+ "lib/ymdp/javascripts/prototype/authorization.js",
79
+ "lib/ymdp/javascripts/prototype/browser.js",
80
+ "lib/ymdp/javascripts/prototype/data.js",
81
+ "lib/ymdp/javascripts/prototype/debug.js",
82
+ "lib/ymdp/javascripts/prototype/education.js",
83
+ "lib/ymdp/javascripts/prototype/flash.js",
84
+ "lib/ymdp/javascripts/prototype/help.js",
85
+ "lib/ymdp/javascripts/prototype/i18n.js",
86
+ "lib/ymdp/javascripts/prototype/init.js",
87
+ "lib/ymdp/javascripts/prototype/launcher.js",
88
+ "lib/ymdp/javascripts/prototype/logger.js",
89
+ "lib/ymdp/javascripts/prototype/params.js",
90
+ "lib/ymdp/javascripts/prototype/reporter.js",
91
+ "lib/ymdp/javascripts/prototype/tag_helper.js",
92
+ "lib/ymdp/javascripts/prototype/user.js",
75
93
  "lib/ymdp/tasks/build.rake",
76
94
  "lib/ymdp/tasks/keys.rake",
77
95
  "lib/ymdp/tasks/ymdp.rake",