Permalink
Browse files

initial re-commit

  • Loading branch information...
1 parent 0152395 commit 9b4fa824a6b37110123d6193fbbe00990d2e9056 @rmxdave rmxdave committed Jul 14, 2011
Showing with 7,951 additions and 2,373 deletions.
  1. +9 −8 README.txt
  2. +35 −0 app/assistants/about-assistant.js
  3. +215 −5 app/assistants/app-assistant.js
  4. +108 −0 app/assistants/dashboard-assistant.js
  5. +85 −61 app/assistants/finishAuth-assistant.js
  6. +43 −67 app/assistants/launch-assistant.js
  7. +835 −1,251 app/assistants/main-assistant.js
  8. +190 −176 app/assistants/oauth-assistant.js
  9. +42 −0 app/assistants/pictureView-assistant.js
  10. +168 −0 app/assistants/preferences-assistant.js
  11. +517 −0 app/assistants/profile-assistant.js
  12. +1 −3 app/assistants/stage-assistant.js
  13. +303 −0 app/assistants/status-assistant.js
  14. +72 −0 app/assistants/stream-assistant.js
  15. +303 −0 app/assistants/toasters/compose.js
  16. +27 −0 app/assistants/toasters/confirm.js
  17. +48 −0 app/assistants/toasters/convo.js
  18. +43 −0 app/assistants/toasters/lookup.js
  19. +24 −0 app/assistants/toasters/profile.js
  20. +39 −0 app/assistants/toasters/retweet.js
  21. +43 −0 app/assistants/toasters/search.js
  22. +35 −0 app/assistants/toasters/status-list.js
  23. +358 −0 app/assistants/toasters/tweet.js
  24. +39 −0 app/assistants/toasters/user-list.js
  25. +8 −9 app/config/config.js
  26. +206 −2 app/global/app-globals.js
  27. +47 −0 app/helpers/bitly.js
  28. +136 −0 app/helpers/tweet.js
  29. +354 −0 app/helpers/twitter.js
  30. +41 −0 app/models/account.js
  31. +97 −0 app/models/asyncWrappers.js
  32. +55 −0 app/models/local.js
  33. +1 −0 app/models/metrix.js
  34. +615 −0 app/models/metrixCore.js
  35. +42 −42 app/models/panel.js
  36. +82 −0 app/models/toaster-chain.js
  37. +89 −0 app/models/toaster.js
  38. +18 −0 app/views/about/about-scene.html
  39. +1 −0 app/views/dashboard/dashboard-scene.html
  40. +16 −0 app/views/dashboard/item-info.html
  41. +40 −39 app/views/finishAuth/finishAuth-scene.html
  42. +3 −6 app/views/launch/launch-scene.html
  43. +29 −109 app/views/main/main-scene.html
  44. +1 −0 app/views/metrix/displayBulletin-dialog.html
  45. +9 −0 app/views/pictureView/pictureView-scene.html
  46. +6 −0 app/views/preferences/preferences-scene.html
  47. +8 −0 app/views/preferences/section.html
  48. +5 −0 app/views/preferences/select.html
  49. +8 −0 app/views/preferences/toggle.html
  50. +82 −0 app/views/profile/content.html
  51. +11 −0 app/views/profile/profile-scene.html
  52. +24 −0 app/views/status/status-scene.html
  53. +1 −0 app/views/stream/stream-scene.html
  54. +3 −0 app/views/templates/account-card.html
  55. +1 −0 app/views/templates/account-menu.html
  56. +4 −0 app/views/templates/list-follows.html
  57. +4 −0 app/views/templates/list-item.html
  58. +4 −1 app/views/templates/panel.html
  59. +32 −0 app/views/templates/panels/lists.html
  60. +22 −0 app/views/templates/panels/search.html
  61. +5 −3 app/views/templates/panels/timeline.html
  62. +3 −0 app/views/templates/search-list-item.html
  63. +18 −0 app/views/templates/toasters/compose.html
  64. +9 −0 app/views/templates/toasters/confirm.html
  65. +7 −0 app/views/templates/toasters/convo.html
  66. +13 −0 app/views/templates/toasters/lookup.html
  67. +71 −0 app/views/templates/toasters/profile.html
  68. +9 −0 app/views/templates/toasters/retweet.html
  69. +7 −0 app/views/templates/toasters/status-list.html
  70. +16 −0 app/views/templates/toasters/tweet.html
  71. +18 −0 app/views/templates/tweets/convo-item.html
  72. +1 −1 app/views/templates/tweets/convo.html
  73. +16 −17 app/views/templates/tweets/details.html
  74. +12 −16 app/views/templates/tweets/item.html
  75. +9 −15 app/views/templates/tweets/search.html
  76. +10 −0 app/views/templates/user-item.html
  77. +10 −4 appinfo.json
  78. BIN dash-icon.png
  79. +1 −1 framework_config.json
  80. BIN icon128.png
  81. BIN icon24.png
  82. BIN icon256.png
  83. BIN icon48.png
  84. BIN icon64.png
  85. BIN images/Metrix/Thumbs.db
  86. BIN images/Metrix/header-button-inverse.png
  87. BIN images/Metrix/header-button.png
  88. BIN images/Metrix/menu-icon-back-bnk.png
  89. BIN images/Metrix/menu-icon-back-dwn.png
  90. BIN images/Metrix/menu-icon-back-upp.png
  91. BIN images/Metrix/menu-icon-forward-bnk.png
  92. BIN images/Metrix/menu-icon-forward-dwn.png
  93. BIN images/Metrix/menu-icon-forward-upp.png
  94. BIN images/low/Untitled-2.png
  95. BIN images/low/avatar-shadow.png
  96. BIN images/low/backgrounds/bg.png
  97. BIN images/low/backgrounds/fabric.png
  98. BIN images/low/backgrounds/texture1.png
  99. BIN images/low/buttons/negative-tapped.png
  100. BIN images/low/buttons/negative.png
  101. BIN images/low/buttons/neutral-tapped.png
  102. BIN images/low/buttons/neutral.png
  103. BIN images/low/buttons/positive-tapped.png
  104. BIN images/low/buttons/positive.png
  105. BIN images/low/buttons/signin-tapped.png
  106. BIN images/low/buttons/signin.png
  107. BIN images/low/buttons/submit-tapped.png
  108. BIN images/low/buttons/submit.png
  109. BIN images/low/compose-bg.png
  110. BIN images/low/compose-opts-bg.png
  111. BIN images/low/dialogbg.png
  112. BIN images/low/divider-bg.png
  113. BIN images/low/failwhale.png
  114. BIN images/low/header-bar.png
  115. BIN images/low/header-bg.png
  116. BIN images/low/icons/camera.png
  117. BIN images/low/icons/cancel.png
  118. BIN images/low/icons/compose.png
  119. BIN images/low/icons/confirm.png
  120. BIN images/low/icons/convo.png
  121. BIN images/low/icons/delete.png
  122. BIN images/low/icons/dm.png
  123. BIN images/low/icons/edit.png
  124. BIN images/low/icons/favorite-active.png
  125. BIN images/low/icons/favorite.png
  126. BIN images/low/icons/geotag-active.png
  127. BIN images/low/icons/geotag.png
  128. BIN images/low/icons/link.png
  129. BIN images/low/icons/lists.png
  130. BIN images/low/icons/mentions.png
  131. BIN images/low/icons/messages.png
  132. BIN images/low/icons/new-card.png
  133. BIN images/low/icons/opts.png
  134. BIN images/low/icons/profile-favorite-tapped.png
  135. BIN images/low/icons/profile-favorite.png
  136. BIN images/low/icons/profile-history-tapped.png
  137. BIN images/low/icons/profile-history.png
  138. BIN images/low/icons/profile-info-tapped.png
  139. BIN images/low/icons/profile-info.png
  140. BIN images/low/icons/profile-mentions-tapped.png
  141. BIN images/low/icons/profile-mentions.png
  142. BIN images/low/icons/refresh.png
  143. BIN images/low/icons/reply.png
  144. BIN images/low/icons/retweet.png
  145. BIN images/low/icons/search-button.png
  146. BIN images/low/icons/search.png
  147. BIN images/low/icons/tweets.png
  148. BIN images/low/icons/user-search.png
  149. BIN images/low/icons/verified.png
  150. BIN images/low/img-load.gif
  151. BIN images/low/indicator.png
  152. BIN images/low/list-card.png
  153. BIN images/low/list-spacer.png
  154. BIN images/low/load-fade.png
  155. BIN images/low/loading-bg.png
  156. BIN images/low/loading.gif
  157. BIN images/low/nav-bar.png
  158. BIN images/low/nav-icon-border.png
  159. BIN images/low/new-content.png
  160. BIN images/low/photo-bg.png
  161. BIN images/low/photobg.png
  162. BIN images/low/profile-opts-tapped.png
  163. BIN images/low/profile-opts.png
  164. BIN images/low/retweets-card.png
  165. BIN images/low/rt-button.png
  166. BIN images/low/rt-icon.png
  167. BIN images/low/scene-top.png
  168. BIN images/low/search-box.png
  169. BIN images/low/search-card.png
  170. BIN images/low/search-icon.png
  171. BIN images/low/splash-logo.png
  172. BIN images/low/textarea-border.png
  173. BIN images/low/themes/ash/bg.png
  174. BIN images/low/themes/ash/compose-bg.png
  175. BIN images/low/themes/ash/header-bar.png
  176. BIN images/low/themes/ash/indicator.png
  177. BIN images/low/themes/ash/nav-bar.png
  178. BIN images/low/themes/ash/toaster-bg.png
  179. BIN images/low/themes/pure/bg.png
  180. BIN images/low/themes/sunnyvale/bg.png
  181. BIN images/low/themes/sunnyvale/header-bar.png
  182. BIN images/low/themes/sunnyvale/indicator.png
  183. BIN images/low/themes/sunnyvale/nav-bar.png
  184. BIN images/low/themes/sunnyvale/nav-icon-border.png
  185. BIN images/low/themes/sunnyvale/toaster-bg.png
  186. BIN images/low/title-bg.png
  187. BIN images/low/toaster-bg.png
  188. BIN images/low/toaster-controls.png
  189. BIN images/low/tweet-border-bottom.png
  190. BIN images/low/tweet-border-top.png
  191. BIN images/low/tweet-border.png
  192. BIN images/low/tweet-highlight-bottom.png
  193. BIN images/low/tweet-highlight.png
  194. BIN images/low/user-card.png
  195. BIN images/trans13.png
  196. BIN images/trans9.png
  197. +12 −3 index.html
  198. +9 −0 lib/Ajax.js
  199. +68 −0 lib/Date.js
  200. +124 −153 lib/OAuth/OAuth.js
  201. +561 −0 lib/OAuth/OAuth.js.bak
  202. +30 −0 lib/String.js
  203. +75 −32 sources.json
  204. BIN splash-bg.png
  205. BIN splash-icon.png
  206. +96 −0 stylesheets/ash.css
  207. +848 −349 stylesheets/phnx.css
  208. +93 −0 stylesheets/rebirth.css
  209. +113 −0 stylesheets/sunnyvale.css
View
@@ -1,17 +1,18 @@
-=============================================
- phnx - a twitter app
-=============================================
+============================================
+ phnx - a twitter app
+============================================
Author: David Strack
Twitter: @rmxdave
-Email: david@davidstrack.com
-Web: http://prettyappmachine.com
+Email: davidstrack@gmail.com
+Web: http://davidstrack.com
+License:
You may not reproduce any part of this application without written permission from the author.
-Viewing source code for educational purposes is permitted - as long as nothing is copied for use in
-another application.
+Viewing or modifying source code for personal or educational purposes is permitted
+ - but you may NOT copy, distribute, or reproduce any portion of this application.
Before you steal this app, remember that you are hurting a young developer and his family,
not a large software company.
-Copyright 2010 - 2011 David Strack (D.B.A. Pretty App Machine)
+Copyright 2010 - 2011 David Strack
@@ -0,0 +1,35 @@
+function AboutAssistant(){}
+
+AboutAssistant.prototype = {
+ setup: function() {
+ var appMenu = [
+ Mojo.Menu.editItem,
+ {
+ label: 'Contact Support',
+ command: 'cmdSupport'
+ }
+ ];
+
+ this.controller.setupWidget(Mojo.Menu.appMenu, {omitDefaultItems: true}, {visible: true, items: appMenu});
+ this.controller.get('version').update(Mojo.appInfo.version);
+
+ this.controller.listen('head-honcho', Mojo.Event.tap, this.awesomeSauce.bind(this));
+ this.controller.listen('series-of-tubes', Mojo.Event.tap, this.coolio.bind(this));
+ },
+ awesomeSauce: function(event) {
+ var Twitter = new TwitterAPI(this.controller.stageController.user);
+ Twitter.getUser('rmxdave', function(r){
+ this.controller.stageController.pushScene({
+ name: 'profile',
+ disableSceneScroller: true
+ }, r.responseJSON);
+ }.bind(this));
+ },
+ coolio: function(event) {
+ global.openBrowser('http://phnxapp.com');
+ },
+ cleanup: function() {
+ this.controller.stopListening('head-honcho', Mojo.Event.tap, this.awesomeSauce);
+ this.controller.stopListening('series-of-tubes', Mojo.Event.tap, this.coolio);
+ }
+};
@@ -1,7 +1,217 @@
-function AppAssistant(){
-
-}
+function AppAssistant(){}
AppAssistant.prototype = {
-
-}
+ setup: function() {
+ var prefs = new LocalStorage();
+
+ if (prefs.read('sendAnalytics')) {
+ global.Metrix = new Metrix();
+ global.Metrix.postDeviceData();
+ }
+ },
+ handleLaunch: function(params) {
+ if (params.action === 'checkNotifications') {
+ var prefs = new LocalStorage();
+ var stageFocused = false; // temporaray
+ if (prefs.read('notifications') && !stageFocused) {
+ // Only background check notifications when enabled
+ // and when there are no stages present
+ this.checkNotifications();
+ }
+ else if (prefs.read('notifications') && stageFocused) {
+ global.setTimer(); // reset the timer anyway
+ }
+ }
+ else if (params.dockMode) {
+ // This is exhibition mode
+ }
+ else {
+ Mojo.Log.info('params: ' + params);
+ // Launch the app normally, load the default user if it exists.
+ this.launchMain();
+ // this.checkNotifications(); // for debugging
+ }
+ },
+ handleCommand: function(event) {
+ var stage = this.controller.getActiveStageController();
+ if (event.command === 'cmdPreferences') {
+ stage.pushScene('preferences');
+ }
+ else if (event.command === 'cmdAbout') {
+ stage.pushScene('about');
+ }
+ else if (event.command === 'cmdSupport') {
+ var service = new Mojo.Service.Request('palm://com.palm.applicationManager', {
+ method: 'open',
+ parameters: {
+ id: 'com.palm.app.email',
+ params: {
+ summary: "phnx support",
+ recipients: [{
+ value : 'support@phnxapp.com',
+ contactDisplay : 'support@phnxapp.com'
+ }]
+ }
+ }
+ });
+ }
+ },
+ launchMain: function() {
+ var prefs = new LocalStorage();
+ this.userCookie = new Mojo.Model.Cookie('phoenixFirstRun');
+
+ var user = {};
+
+ var defaultUser = prefs.read('defaultAccount');
+
+ // The app poops out on very first load if the Lawnchair store doesn't exist.
+ // Using a cookie to get around this...
+ if (typeof(this.userCookie.get()) !== "undefined") {
+ var am = new Account();
+ var accounts;
+ am.all(function(r){
+ accounts = r;
+ if (accounts.length > 0) {
+ Mojo.Log.info('Starting app, accounts exist');
+ // Push the main scene with the first account set as default.
+ if (defaultUser !== '0') {
+ for (var i=0; i < accounts.length; i++) {
+ if (accounts[i].id === defaultUser) {
+ user = accounts[i];
+ }
+ }
+ }
+ else {
+ // Use the first user if an explicit default has not been chosen
+ user = accounts[0];
+ }
+
+ Mojo.Log.info('User set as ' + user.screen_name);
+
+ var launchArgs = {
+ user: user,
+ users: accounts
+ };
+ prefs.write('defaultAccount', user.id);
+ var stageName = global.mainStage + user.key;
+
+ this.pushStage(stageName, launchArgs);
+ }
+ else {
+ this.launchNew();
+ }
+ }.bind(this));
+ }
+ else {
+ // This is the very first time the app is being launched,
+ // so just init the Lawnchair store
+
+ // Set the cookie, too.
+ this.userCookie.put({
+ run: true
+ });
+
+ var store = new Lawnchair('phnxAccounts');
+ this.launchNew();
+ }
+
+ },
+ launchNew: function() {
+ var launchArgs = {};
+ var stageName = global.authStage;
+ this.pushStage(stageName, launchArgs);
+ },
+ pushStage: function(stageName, launchArgs) {
+ var args = {
+ name: stageName,
+ lightweight: true
+ };
+
+ var pushMainScene = function(stageController) {
+ if (stageName !== global.authStage) {
+ global.stageActions(stageController);
+ }
+ stageController.pushScene('launch', launchArgs);
+ };
+
+ var userStage = this.controller.getStageProxy(stageName);
+ if (!userStage) {
+ this.controller.createStageWithCallback(args, pushMainScene, "card");
+ }
+ else {
+ userStage.activate();
+ }
+ },
+ checkNotifications: function() {
+ // Check for notifications
+ Mojo.Log.info('Checking notifications');
+ var prefs = new LocalStorage();
+
+ am = new Account();
+ am.all(function(r){
+
+ var callback = function(response, meta) {
+ if (response.responseJSON.length > 0) {
+ prefs.write(meta.user.id + '_' + meta.resource.name, response.responseJSON[0].id_str);
+ this.createDashboard(meta.resource, response.responseJSON, meta.user, r);
+ }
+ };
+
+ for (var i=0; i < r.length; i++) {
+ var user = r[i];
+ Mojo.Log.info('Checking ' + user.username + ' notifications');
+
+ // Name matches panel IDs in main-assistant
+ // Noun is used in dashboard title
+ var resources = [
+ {name: 'home', noun: 'Tweet', lastId: prefs.read(user.id + '_home'), enabled: prefs.read('notificationHome')},
+ {name: 'mentions', noun: 'Mention', lastId: prefs.read(user.id + '_mentions'), enabled: prefs.read('notificationMentions')},
+ {name: 'messages', noun: 'Direct Message', lastId: prefs.read(user.id + '_messages'), enabled: prefs.read('notificationMessages')}
+ ];
+
+ for (var j=0; j < resources.length; j++) {
+ var resource = resources[j];
+ if (resource.enabled && resource.lastId !== null) {
+ Mojo.Log.info('Checking ' + resource.name + ' last ID:' + resource.lastId);
+ var Twitter = new TwitterAPI(user);
+ Twitter.notificationCheck(resource, callback.bind(this), {"since_id": resource.lastId}, user);
+ }
+ }
+ }
+ }.bind(this));
+
+ // Reset the alarm
+ global.setTimer();
+ },
+ createDashboard: function(resource, items, account, accounts) {
+ var appController = Mojo.Controller.getAppController();
+ var dashboardStage = appController.getStageProxy(global.dashboardStage);
+
+ var userId;
+
+ if (items[0].user) {
+ userId = items[0].user.id_str;
+ }
+ else if (items[0].sender) {
+ userId = items[0].sender.id_str;
+ }
+
+ // Check if the user's stage is active & has scenes
+ var userStage = appController.getStageProxy(global.mainStage + userId);
+
+ if (userStage && userStage.isActiveAndHasScenes()) {
+ userStage.delegateToSceneAssistant('refreshPanelId', resource.name);
+ }
+ else {
+ if (dashboardStage) {
+ dashboardStage.delegateToSceneAssistant('update', items, resource, account, accounts);
+ }
+ else {
+ var pushDashboard = function(stageController){
+ stageController.pushScene('dashboard', items, resource, account, accounts);
+ };
+ appController.createStageWithCallback({name: global.dashboardStage, lightweight: true}, pushDashboard, 'dashboard');
+ }
+ }
+ }
+};
Oops, something went wrong.

0 comments on commit 9b4fa82

Please sign in to comment.