Skip to content
Browse files

Initial Commit

  • Loading branch information...
0 parents commit b691b3821e30c160f4b657f3d1863460cbc247c7 Brian Moore committed Jul 15, 2010
Showing with 8,699 additions and 0 deletions.
  1. +19 −0 contact-server/Rakefile
  2. +27 −0 contact-server/application.rb
  3. +33 −0 contact-server/config.ru
  4. BIN contact-server/dump.rdb
  5. +1 −0 contact-server/settings/license.key
  6. +17 −0 contact-server/settings/settings.yml
  7. +34 −0 contact-server/sources/customer.rb
  8. +25 −0 contact-server/spec/sources/customer_spec.rb
  9. +27 −0 contact-server/spec/spec_helper.rb
  10. +28 −0 contact/Rakefile
  11. +7 −0 contact/app/Customer/customer.rb
  12. +112 −0 contact/app/Customer/customer_controller.rb
  13. +69 −0 contact/app/Customer/edit.bb.erb
  14. +68 −0 contact/app/Customer/edit.erb
  15. +21 −0 contact/app/Customer/index.bb.erb
  16. +29 −0 contact/app/Customer/index.erb
  17. +69 −0 contact/app/Customer/new.bb.erb
  18. +67 −0 contact/app/Customer/new.erb
  19. +66 −0 contact/app/Customer/show.bb.erb
  20. +61 −0 contact/app/Customer/show.erb
  21. +10 −0 contact/app/Customer/wait.erb
  22. +75 −0 contact/app/Settings/controller.rb
  23. +17 −0 contact/app/Settings/home.bb.erb
  24. +23 −0 contact/app/Settings/home.erb
  25. +32 −0 contact/app/Settings/index.bb.erb
  26. +46 −0 contact/app/Settings/index.erb
  27. +35 −0 contact/app/Settings/login.bb.erb
  28. +31 −0 contact/app/Settings/login.erb
  29. +15 −0 contact/app/Settings/reset.bb.erb
  30. +18 −0 contact/app/Settings/reset.erb
  31. +3 −0 contact/app/Settings/wait.bb.erb
  32. +5 −0 contact/app/Settings/wait.erb
  33. +12 −0 contact/app/application.rb
  34. +108 −0 contact/app/helpers/application_helper.rb
  35. +18 −0 contact/app/helpers/browser_helper.rb
  36. +26 −0 contact/app/index.bb.erb
  37. +23 −0 contact/app/index.erb
  38. +25 −0 contact/app/layout.erb
  39. +11 −0 contact/app/loading.html
  40. +7 −0 contact/app/test/customer_spec.rb
  41. +25 −0 contact/build.yml
  42. BIN contact/icon/icon.ico
  43. BIN contact/icon/icon.png
  44. +287 −0 contact/public/css/android.css
  45. +115 −0 contact/public/css/blackberry.css
  46. +382 −0 contact/public/css/iphone.css
  47. +41 −0 contact/public/css/webkit.css
  48. +212 −0 contact/public/css/windows_mobile.css
  49. +21 −0 contact/public/images/IUI_LICENSE.txt
  50. BIN contact/public/images/android/btn_check_off.png
  51. BIN contact/public/images/android/btn_check_on.png
  52. BIN contact/public/images/android/btn_radio_off.png
  53. BIN contact/public/images/android/btn_radio_on.png
  54. BIN contact/public/images/android/ic_menu_more.png
  55. BIN contact/public/images/backButton.png
  56. BIN contact/public/images/blueButton.png
  57. BIN contact/public/images/cancel.png
  58. BIN contact/public/images/grayButton.png
  59. BIN contact/public/images/iphone/disclosure.png
  60. BIN contact/public/images/iphone/disclosure_detail.png
  61. BIN contact/public/images/iphone/radiobutton.png
  62. BIN contact/public/images/iphone/select.png
  63. BIN contact/public/images/iphone/switch.png
  64. BIN contact/public/images/iui-logo-touch-icon.png
  65. BIN contact/public/images/listArrow.png
  66. BIN contact/public/images/listArrowDown.png
  67. BIN contact/public/images/listArrowSel.png
  68. BIN contact/public/images/listGroup.png
  69. BIN contact/public/images/loading.gif
  70. BIN contact/public/images/pinstripes.png
  71. BIN contact/public/images/right_button.png
  72. BIN contact/public/images/selection.png
  73. BIN contact/public/images/thumb.png
  74. BIN contact/public/images/toggle.png
  75. BIN contact/public/images/toggleOn.png
  76. BIN contact/public/images/toolButton.png
  77. BIN contact/public/images/toolButton_new.png
  78. BIN contact/public/images/toolbar.png
  79. BIN contact/public/images/whiteButton.png
  80. +1 −0 contact/public/js/application.js
  81. +4 −0 contact/public/js/rho.js
  82. +59 −0 contact/public/js/rhogeolocation-wm.js
  83. +11 −0 contact/public/js/rhogeolocation.js
  84. +24 −0 contact/rhoconfig.txt
  85. +28 −0 css/Rakefile
  86. +29 −0 css/app/Person/edit.bb.erb
  87. +28 −0 css/app/Person/edit.erb
  88. +21 −0 css/app/Person/index.bb.erb
  89. +23 −0 css/app/Person/index.erb
  90. +50 −0 css/app/Person/new.bb.erb
  91. +46 −0 css/app/Person/new.erb
  92. +7 −0 css/app/Person/person.rb
  93. +59 −0 css/app/Person/person_controller.rb
  94. +26 −0 css/app/Person/show.bb.erb
  95. +24 −0 css/app/Person/show.erb
  96. +75 −0 css/app/Settings/controller.rb
  97. +17 −0 css/app/Settings/home.bb.erb
  98. +23 −0 css/app/Settings/home.erb
  99. +32 −0 css/app/Settings/index.bb.erb
  100. +46 −0 css/app/Settings/index.erb
  101. +35 −0 css/app/Settings/login.bb.erb
  102. +31 −0 css/app/Settings/login.erb
  103. +15 −0 css/app/Settings/reset.bb.erb
  104. +18 −0 css/app/Settings/reset.erb
  105. +3 −0 css/app/Settings/wait.bb.erb
  106. +5 −0 css/app/Settings/wait.erb
  107. +12 −0 css/app/application.rb
  108. +108 −0 css/app/helpers/application_helper.rb
  109. +18 −0 css/app/helpers/browser_helper.rb
  110. +26 −0 css/app/index.bb.erb
  111. +34 −0 css/app/index.erb
  112. +25 −0 css/app/layout.erb
  113. +11 −0 css/app/loading.html
  114. +7 −0 css/app/test/person_spec.rb
  115. +16 −0 css/build.yml
  116. BIN css/icon/icon.ico
  117. BIN css/icon/icon.png
  118. +292 −0 css/public/css/android.css
  119. +115 −0 css/public/css/blackberry.css
  120. +382 −0 css/public/css/iphone.css
  121. +41 −0 css/public/css/webkit.css
  122. +212 −0 css/public/css/windows_mobile.css
  123. +21 −0 css/public/images/IUI_LICENSE.txt
  124. BIN css/public/images/android/btn_check_off.png
  125. BIN css/public/images/android/btn_check_on.png
  126. BIN css/public/images/android/btn_radio_off.png
  127. BIN css/public/images/android/btn_radio_on.png
  128. BIN css/public/images/android/ic_menu_more.png
  129. BIN css/public/images/backButton.png
  130. BIN css/public/images/blueButton.png
  131. BIN css/public/images/cancel.png
  132. BIN css/public/images/grayButton.png
  133. BIN css/public/images/iphone/disclosure.png
  134. BIN css/public/images/iphone/disclosure_detail.png
  135. BIN css/public/images/iphone/radiobutton.png
  136. BIN css/public/images/iphone/select.png
  137. BIN css/public/images/iphone/switch.png
  138. BIN css/public/images/iui-logo-touch-icon.png
  139. BIN css/public/images/listArrow.png
  140. BIN css/public/images/listArrowDown.png
  141. BIN css/public/images/listArrowSel.png
  142. BIN css/public/images/listGroup.png
  143. BIN css/public/images/loading.gif
  144. BIN css/public/images/pinstripes.png
  145. BIN css/public/images/right_button.png
  146. BIN css/public/images/selection.png
  147. BIN css/public/images/thumb.png
  148. BIN css/public/images/toggle.png
  149. BIN css/public/images/toggleOn.png
  150. BIN css/public/images/toolButton.png
  151. BIN css/public/images/toolButton_new.png
  152. BIN css/public/images/toolbar.png
  153. BIN css/public/images/whiteButton.png
  154. +1 −0 css/public/js/application.js
  155. +4 −0 css/public/js/rho.js
  156. +59 −0 css/public/js/rhogeolocation-wm.js
  157. +11 −0 css/public/js/rhogeolocation.js
  158. +23 −0 css/rhoconfig.txt
  159. +28 −0 imageupload/Rakefile
  160. +11 −0 imageupload/app/Image/image.rb
  161. +55 −0 imageupload/app/Image/image_controller.rb
  162. +21 −0 imageupload/app/Image/index.bb.erb
  163. +46 −0 imageupload/app/Image/index.erb
  164. +75 −0 imageupload/app/Settings/controller.rb
  165. +17 −0 imageupload/app/Settings/home.bb.erb
  166. +23 −0 imageupload/app/Settings/home.erb
  167. +32 −0 imageupload/app/Settings/index.bb.erb
  168. +46 −0 imageupload/app/Settings/index.erb
  169. +35 −0 imageupload/app/Settings/login.bb.erb
  170. +31 −0 imageupload/app/Settings/login.erb
  171. +15 −0 imageupload/app/Settings/reset.bb.erb
  172. +18 −0 imageupload/app/Settings/reset.erb
  173. +3 −0 imageupload/app/Settings/wait.bb.erb
  174. +5 −0 imageupload/app/Settings/wait.erb
  175. +12 −0 imageupload/app/application.rb
  176. +108 −0 imageupload/app/helpers/application_helper.rb
  177. +18 −0 imageupload/app/helpers/browser_helper.rb
  178. +26 −0 imageupload/app/index.bb.erb
  179. +23 −0 imageupload/app/index.erb
  180. +25 −0 imageupload/app/layout.erb
  181. +11 −0 imageupload/app/loading.html
  182. +7 −0 imageupload/app/test/image_spec.rb
  183. +18 −0 imageupload/build.yml
  184. BIN imageupload/icon/icon.ico
  185. BIN imageupload/icon/icon.png
  186. +296 −0 imageupload/public/css/android.css
  187. +115 −0 imageupload/public/css/blackberry.css
  188. +382 −0 imageupload/public/css/iphone.css
  189. +41 −0 imageupload/public/css/webkit.css
  190. +212 −0 imageupload/public/css/windows_mobile.css
  191. +21 −0 imageupload/public/images/IUI_LICENSE.txt
  192. BIN imageupload/public/images/android/btn_check_off.png
  193. BIN imageupload/public/images/android/btn_check_on.png
  194. BIN imageupload/public/images/android/btn_radio_off.png
  195. BIN imageupload/public/images/android/btn_radio_on.png
  196. BIN imageupload/public/images/android/disclosure.png
  197. BIN imageupload/public/images/android/ic_menu_more.png
  198. BIN imageupload/public/images/backButton.png
  199. BIN imageupload/public/images/blueButton.png
  200. BIN imageupload/public/images/cancel.png
  201. BIN imageupload/public/images/grayButton.png
  202. BIN imageupload/public/images/iphone/disclosure.png
  203. BIN imageupload/public/images/iphone/disclosure_detail.png
  204. BIN imageupload/public/images/iphone/radiobutton.png
  205. BIN imageupload/public/images/iphone/select.png
  206. BIN imageupload/public/images/iphone/switch.png
  207. BIN imageupload/public/images/iui-logo-touch-icon.png
  208. BIN imageupload/public/images/listArrow.png
  209. BIN imageupload/public/images/listArrowDown.png
  210. BIN imageupload/public/images/listArrowSel.png
  211. BIN imageupload/public/images/listGroup.png
  212. BIN imageupload/public/images/loading.gif
  213. BIN imageupload/public/images/pinstripes.png
  214. BIN imageupload/public/images/right_button.png
  215. BIN imageupload/public/images/selection.png
  216. BIN imageupload/public/images/thumb.png
  217. BIN imageupload/public/images/toggle.png
  218. BIN imageupload/public/images/toggleOn.png
  219. BIN imageupload/public/images/toolButton.png
  220. BIN imageupload/public/images/toolButton_new.png
  221. BIN imageupload/public/images/toolbar.png
  222. BIN imageupload/public/images/whiteButton.png
  223. +1 −0 imageupload/public/js/application.js
  224. +4 −0 imageupload/public/js/rho.js
  225. +59 −0 imageupload/public/js/rhogeolocation-wm.js
  226. +11 −0 imageupload/public/js/rhogeolocation.js
  227. +26 −0 imageupload/rhoconfig.txt
  228. +19 −0 metastore-server/Rakefile
  229. +27 −0 metastore-server/application.rb
  230. +33 −0 metastore-server/config.ru
  231. BIN metastore-server/dump.rdb
  232. +1 −0 metastore-server/settings/license.key
  233. +17 −0 metastore-server/settings/settings.yml
  234. +174 −0 metastore-server/sources/person.rb
  235. +25 −0 metastore-server/spec/sources/person_spec.rb
  236. +27 −0 metastore-server/spec/spec_helper.rb
  237. +28 −0 metastore/Rakefile
  238. +34 −0 metastore/app/Person/edit.bb.erb
  239. +33 −0 metastore/app/Person/edit.erb
  240. +21 −0 metastore/app/Person/index.bb.erb
  241. +23 −0 metastore/app/Person/index.erb
  242. +34 −0 metastore/app/Person/new.bb.erb
  243. +32 −0 metastore/app/Person/new.erb
  244. +7 −0 metastore/app/Person/person.rb
  245. +62 −0 metastore/app/Person/person_controller.rb
  246. +31 −0 metastore/app/Person/show.bb.erb
  247. +29 −0 metastore/app/Person/show.erb
  248. +75 −0 metastore/app/Settings/controller.rb
  249. +17 −0 metastore/app/Settings/home.bb.erb
  250. +23 −0 metastore/app/Settings/home.erb
  251. +32 −0 metastore/app/Settings/index.bb.erb
  252. +46 −0 metastore/app/Settings/index.erb
  253. +35 −0 metastore/app/Settings/login.bb.erb
  254. +31 −0 metastore/app/Settings/login.erb
  255. +15 −0 metastore/app/Settings/reset.bb.erb
  256. +18 −0 metastore/app/Settings/reset.erb
  257. +3 −0 metastore/app/Settings/wait.bb.erb
  258. +5 −0 metastore/app/Settings/wait.erb
  259. +12 −0 metastore/app/application.rb
  260. +108 −0 metastore/app/helpers/application_helper.rb
  261. +18 −0 metastore/app/helpers/browser_helper.rb
  262. +26 −0 metastore/app/index.bb.erb
  263. +23 −0 metastore/app/index.erb
  264. +25 −0 metastore/app/layout.erb
  265. +11 −0 metastore/app/loading.html
  266. +7 −0 metastore/app/test/person_spec.rb
  267. +16 −0 metastore/build.yml
  268. BIN metastore/icon/icon.ico
  269. BIN metastore/icon/icon.png
  270. +287 −0 metastore/public/css/android.css
  271. +115 −0 metastore/public/css/blackberry.css
  272. +382 −0 metastore/public/css/iphone.css
  273. +41 −0 metastore/public/css/webkit.css
  274. +212 −0 metastore/public/css/windows_mobile.css
  275. +21 −0 metastore/public/images/IUI_LICENSE.txt
  276. BIN metastore/public/images/android/btn_check_off.png
  277. BIN metastore/public/images/android/btn_check_on.png
  278. BIN metastore/public/images/android/btn_radio_off.png
  279. BIN metastore/public/images/android/btn_radio_on.png
  280. BIN metastore/public/images/android/ic_menu_more.png
  281. BIN metastore/public/images/backButton.png
  282. BIN metastore/public/images/blueButton.png
  283. BIN metastore/public/images/cancel.png
  284. BIN metastore/public/images/grayButton.png
  285. BIN metastore/public/images/iphone/disclosure.png
  286. BIN metastore/public/images/iphone/disclosure_detail.png
  287. BIN metastore/public/images/iphone/radiobutton.png
  288. BIN metastore/public/images/iphone/select.png
  289. BIN metastore/public/images/iphone/switch.png
  290. BIN metastore/public/images/iui-logo-touch-icon.png
  291. BIN metastore/public/images/listArrow.png
  292. BIN metastore/public/images/listArrowDown.png
  293. BIN metastore/public/images/listArrowSel.png
  294. BIN metastore/public/images/listGroup.png
  295. BIN metastore/public/images/loading.gif
  296. BIN metastore/public/images/pinstripes.png
  297. BIN metastore/public/images/right_button.png
  298. BIN metastore/public/images/selection.png
  299. BIN metastore/public/images/thumb.png
  300. BIN metastore/public/images/toggle.png
Sorry, we could not display the entire diff because too many files (476) changed.
19 contact-server/Rakefile
@@ -0,0 +1,19 @@
+begin
+ require 'vendor/rhosync/lib/rhosync/tasks'
+ require 'vendor/rhosync/lib/rhosync'
+rescue LoadError
+ require 'rhosync/tasks'
+ require 'rhosync'
+end
+
+ROOT_PATH = File.expand_path(File.dirname(__FILE__))
+
+begin
+ require 'resque/tasks'
+ task "resque:setup" do
+ require 'application'
+ end
+rescue LoadError
+ puts "Resque not available. Install it with: "
+ puts "gem install resque\n\n"
+end
27 contact-server/application.rb
@@ -0,0 +1,27 @@
+class Application < Rhosync::Base
+ class << self
+ def authenticate(username,password,session)
+ true # do some interesting authentication here...
+ end
+
+ # Add hooks for application startup here
+ # Don't forget to call super at the end!
+ def initializer(path)
+ super
+ end
+
+ # Calling super here returns rack tempfile path:
+ # i.e. /var/folders/J4/J4wGJ-r6H7S313GEZ-Xx5E+++TI
+ # Note: This tempfile is removed when server stops or crashes...
+ # See http://rack.rubyforge.org/doc/Multipart.html for more info
+ #
+ # Override this by creating a copy of the file somewhere
+ # and returning the path to that file (then don't call super!):
+ # i.e. /mnt/myimages/soccer.png
+ def store_blob(blob)
+ super #=> returns blob[:tempfile]
+ end
+ end
+end
+
+Application.initializer(ROOT_PATH)
33 contact-server/config.ru
@@ -0,0 +1,33 @@
+#!/usr/bin/env ruby
+
+# Try to load vendor-ed rhosync, otherwise load the gem
+begin
+ require 'vendor/rhosync/lib/rhosync/server'
+ require 'vendor/rhosync/lib/rhosync/console/server'
+rescue LoadError
+ require 'rhosync/server'
+ require 'rhosync/console/server'
+end
+
+# By default, turn on the resque web console
+require 'resque/server'
+
+ROOT_PATH = File.expand_path(File.dirname(__FILE__))
+
+# Rhosync server flags
+Rhosync::Server.disable :run
+Rhosync::Server.disable :clean_trace
+Rhosync::Server.enable :raise_errors
+Rhosync::Server.set :environment, :development
+Rhosync::Server.set :secret, '<changeme>'
+Rhosync::Server.set :root, ROOT_PATH
+Rhosync::Server.use Rack::Static, :urls => ["/data"], :root => Rhosync::Server.root
+
+# Load our rhosync application
+require 'application'
+
+# Setup the url map
+run Rack::URLMap.new \
+ "/" => Rhosync::Server.new,
+ "/resque" => Resque::Server.new, # If you don't want resque frontend, disable it here
+ "/console" => RhosyncConsole::Server.new # If you don't want rhosync frontend, disable it here
BIN contact-server/dump.rdb
Binary file not shown.
1 contact-server/settings/license.key
@@ -0,0 +1 @@
+858fc60fadfde40273d0ac505906969318aa4931d1a2c4aeb24d98393c74379f60e226651601969874257f7f1fbda9b099ecd551a641519aa46819947fda0191
17 contact-server/settings/settings.yml
@@ -0,0 +1,17 @@
+#Sources
+:sources:
+ Customer:
+ :poll_interval: 300
+
+:test:
+ :redis: localhost:6379
+ :licensefile: settings/license.key
+ :syncserver: http://localhost:9292/application/
+:development:
+ :redis: localhost:6379
+ :licensefile: settings/license.key
+ :syncserver: http://localhost:9292/application/
+:production:
+ :redis: localhost:6379
+ :licensefile: settings/license.key
+ :syncserver: http://localhost:9292/application/
34 contact-server/sources/customer.rb
@@ -0,0 +1,34 @@
+class Customer < SourceAdapter
+ def initialize(source,credential)
+ @base = 'http://rhostore.heroku.com/customers'
+ super(source,credential)
+ end
+
+ def query(params=nil)
+ parsed=JSON.parse(RestClient.get("#{@base}.json").body)
+
+ @result={}
+ parsed.each { |item|@result[item["customer"]["id"].to_s]=item["customer"] } if parsed
+ @result
+ end
+
+ def create(name_value_list)
+ res = RestClient.post(@base,:customer => name_value_list)
+
+ # after create we are redirected to the new record.
+ # We need to get the id of that record and return it as part of create
+ # so rhosync can establish a link from its temporary object on the
+ # client to this newly created object on the server
+ JSON.parse(RestClient.get("#{res.headers[:location]}.json").body)["customer"]["id"]
+ end
+
+ def update(name_value_list)
+ obj_id = name_value_list['id']
+ name_value_list.delete('id')
+ RestClient.put("#{@base}/#{obj_id}",:customer => name_value_list)
+ end
+
+ def delete(name_value_list)
+ RestClient.delete("#{@base}/#{name_value_list['id']}")
+ end
+end
25 contact-server/spec/sources/customer_spec.rb
@@ -0,0 +1,25 @@
+require File.join(File.dirname(__FILE__),'..','spec_helper')
+
+describe "Customer" do
+ it_should_behave_like "SpecHelper"
+
+ before(:each) do
+ setup_test_for Customer,'testuser'
+ end
+
+ it "should process Customer query" do
+ pending
+ end
+
+ it "should process Customer create" do
+ pending
+ end
+
+ it "should process Customer update" do
+ pending
+ end
+
+ it "should process Customer delete" do
+ pending
+ end
+end
27 contact-server/spec/spec_helper.rb
@@ -0,0 +1,27 @@
+require 'rubygems'
+
+# Set environment to test
+ENV['RHO_ENV'] = 'test'
+ROOT_PATH = File.expand_path(File.join(File.dirname(__FILE__),'..'))
+
+# Try to load vendor-ed rhosync, otherwise load the gem
+begin
+ require 'vendor/rhosync/lib/rhosync'
+rescue LoadError
+ require 'rhosync'
+end
+
+# Load our rhosync application
+require 'application'
+include Rhosync
+
+require 'rhosync/test_methods'
+
+describe "SpecHelper", :shared => true do
+ include Rhosync::TestMethods
+
+ before(:each) do
+ Store.db.flushdb
+ Application.initializer(ROOT_PATH)
+ end
+end
28 contact/Rakefile
@@ -0,0 +1,28 @@
+require 'yaml'
+
+unless File.exists? "build.yml"
+ puts "Cannot find build.yml"
+ exit 1
+end
+
+
+$app_config = YAML::load_file("build.yml")
+$app_path = File.expand_path(File.dirname(__FILE__))
+
+if ENV["RHO_HOME"].nil?
+ rakefilepath = "#{$app_config["sdk"]}/Rakefile"
+else
+ rakefilepath = "#{ENV["RHO_HOME"]}/Rakefile"
+end
+
+unless File.exists? rakefilepath
+ puts "\nCannot find your Rhodes gem or source path."
+ puts "\nIf you have the sdk on your path or have installed the gem this"
+ puts "can be resolved by running 'set-rhodes-sdk'"
+ puts "\nYou can also set this manually by modifying your build.yml or"
+ puts "setting the environment variable RHO_HOME"
+ exit 1
+end
+
+load rakefilepath
+
7 contact/app/Customer/customer.rb
@@ -0,0 +1,7 @@
+# The model has already been created by the framework, and extends Rhom::RhomObject
+# You can add more methods here
+class Customer
+ include Rhom::PropertyBag
+ enable :sync
+ #add model specifc code here
+end
112 contact/app/Customer/customer_controller.rb
@@ -0,0 +1,112 @@
+require 'rho/rhocontroller'
+require 'helpers/browser_helper'
+
+class CustomerController < Rho::RhoController
+ include BrowserHelper
+
+ def map_it
+ @customer = Customer.find(@params["id"])
+ map_params = {
+ :settings => {:map_type => "hybrid",:region => [@customer.lat, @customer.long, 0.2, 0.2],
+ :zoom_enabled => true,:scroll_enabled => true,:shows_user_location => false,
+ :api_key => 'Google Maps API Key'},
+ :annotations => [{
+ :latitude => @customer.lat,
+ :longitude => @customer.long,
+ :title => "#{@customer.first} #{@customer.last}",
+ :subtitle => "Go to customer",
+ :url => "/app/Customer/{#{@customer.object}}"
+ }]
+ }
+
+ MapView.create map_params
+
+ redirect :action => :index
+ end
+
+ def map_all
+ if !GeoLocation.known_position?
+ GeoLocation.set_notification( url_for(:action => :geo_callback), "", 2)
+ redirect :action => :wait
+ else
+ @customers = Customer.find(:all)
+ annotations = []
+ @customers.each do |customer|
+ annotations << {
+ :latitude => customer.lat,
+ :longitude => customer.long,
+ :title => "#{customer.first} #{customer.last}",
+ :subtitle => "",
+ :url => "/app/Customer/{#{customer.object}}"
+ }
+ end
+ map_params = {
+ :settings => {:map_type => "hybrid",:region => [GeoLocation.latitude, GeoLocation.longitude, 0.21, 0.21],
+ :zoom_enabled => true,:scroll_enabled => true,:shows_user_location => false,
+ :api_key => 'Google Maps API Key'},
+ :annotations => annotations
+ }
+
+ MapView.create map_params
+
+ redirect :action => :index
+ end
+ end
+
+ def geo_callback
+ WebView.navigate url_for(:action => :map_all) if @params['known_position'].to_i != 0 && @params['status'] == 'ok'
+ end
+
+ #GET /Customer
+ def index
+ @customers = Customer.find(:all)
+ render
+ end
+
+ # GET /Customer/{1}
+ def show
+ @customer = Customer.find(@params['id'])
+ if @customer
+ render :action => :show
+ else
+ redirect :action => :index
+ end
+ end
+
+ # GET /Customer/new
+ def new
+ @customer = Customer.new
+ render :action => :new
+ end
+
+ # GET /Customer/{1}/edit
+ def edit
+ @customer = Customer.find(@params['id'])
+ if @customer
+ render :action => :edit
+ else
+ redirect :action => :index
+ end
+ end
+
+ # POST /Customer/create
+ def create
+ @customer = Customer.new(@params['customer'])
+ @customer.save
+ redirect :action => :index
+ end
+
+ # POST /Customer/{1}/update
+ def update
+ @customer = Customer.find(@params['id'])
+ @customer.update_attributes(@params['customer']) if @customer
+ redirect :action => :index
+ end
+
+ # POST /Customer/{1}/delete
+ def delete
+ @customer = Customer.find(@params['id'])
+ @customer.destroy if @customer
+ redirect :action => :index
+ end
+end
69 contact/app/Customer/edit.bb.erb
@@ -0,0 +1,69 @@
+<div id="pageTitle">
+ <h1>Edit <%= @customer.first%></h1>
+</div>
+
+<div id="toolbar">
+ <%= link_to "Back", :action => :show, :id => @customer.object %>
+ <%= link_to "Delete", :action => :delete, :id => @customer.object %>
+</div>
+
+
+<div id="content">
+ <form method="POST" action="<%= url_for :action => :update %>">
+ <input type="hidden" name="id" value="<%= @customer.object %>"/>
+ <table>
+
+ <tr>
+ <td class="itemLabel">First: </td>
+ <td class="itemValue"><input type="text" name="customer[first]" value="<%= @customer.first %>"/></td>
+ </tr>
+
+ <tr>
+ <td class="itemLabel">Last: </td>
+ <td class="itemValue"><input type="text" name="customer[last]" value="<%= @customer.last %>"/></td>
+ </tr>
+
+ <tr>
+ <td class="itemLabel">Email: </td>
+ <td class="itemValue"><input type="text" name="customer[email]" value="<%= @customer.email %>"/></td>
+ </tr>
+
+ <tr>
+ <td class="itemLabel">Phone: </td>
+ <td class="itemValue"><input type="text" name="customer[phone]" value="<%= @customer.phone %>"/></td>
+ </tr>
+
+ <tr>
+ <td class="itemLabel">Address: </td>
+ <td class="itemValue"><input type="text" name="customer[address]" value="<%= @customer.address %>"/></td>
+ </tr>
+
+ <tr>
+ <td class="itemLabel">City: </td>
+ <td class="itemValue"><input type="text" name="customer[city]" value="<%= @customer.city %>"/></td>
+ </tr>
+
+ <tr>
+ <td class="itemLabel">State: </td>
+ <td class="itemValue"><input type="text" name="customer[state]" value="<%= @customer.state %>"/></td>
+ </tr>
+
+ <tr>
+ <td class="itemLabel">Zip: </td>
+ <td class="itemValue"><input type="text" name="customer[zip]" value="<%= @customer.zip %>"/></td>
+ </tr>
+
+ <tr>
+ <td class="itemLabel">Lat: </td>
+ <td class="itemValue"><input type="text" name="customer[lat]" value="<%= @customer.lat %>"/></td>
+ </tr>
+
+ <tr>
+ <td class="itemLabel">Long: </td>
+ <td class="itemValue"><input type="text" name="customer[long]" value="<%= @customer.long %>"/></td>
+ </tr>
+
+ </table>
+ <input type="submit" class="standardButton" value="Update" />
+ </form>
+</div>
68 contact/app/Customer/edit.erb
@@ -0,0 +1,68 @@
+<div id="pageTitle">
+ <h1>Edit <%= @customer.first%></h1>
+</div>
+
+<div id="toolbar">
+ <div id="leftItem" class="backButton"><%= link_to "Cancel", :action => :show, :id => @customer.object %></div>
+ <div id="rightItem" class="regularButton"><%= link_to "Delete", :action => :delete, :id => @customer.object %></div>
+</div>
+
+<div id="content">
+ <form method="POST" action="<%= url_for :action => :update %>">
+ <input type="hidden" name="id" value="<%= @customer.object %>"/>
+ <ul>
+
+ <li>
+ <label for="customer[first]" class="fieldLabel">First</label>
+ <input type="text" name="customer[first]" value="<%= @customer.first%>" <%= placeholder( "First" ) %> />
+ </li>
+
+ <li>
+ <label for="customer[last]" class="fieldLabel">Last</label>
+ <input type="text" name="customer[last]" value="<%= @customer.last%>" <%= placeholder( "Last" ) %> />
+ </li>
+
+ <li>
+ <label for="customer[email]" class="fieldLabel">Email</label>
+ <input type="text" name="customer[email]" value="<%= @customer.email%>" <%= placeholder( "Email" ) %> />
+ </li>
+
+ <li>
+ <label for="customer[phone]" class="fieldLabel">Phone</label>
+ <input type="text" name="customer[phone]" value="<%= @customer.phone%>" <%= placeholder( "Phone" ) %> />
+ </li>
+
+ <li>
+ <label for="customer[address]" class="fieldLabel">Address</label>
+ <input type="text" name="customer[address]" value="<%= @customer.address%>" <%= placeholder( "Address" ) %> />
+ </li>
+
+ <li>
+ <label for="customer[city]" class="fieldLabel">City</label>
+ <input type="text" name="customer[city]" value="<%= @customer.city%>" <%= placeholder( "City" ) %> />
+ </li>
+
+ <li>
+ <label for="customer[state]" class="fieldLabel">State</label>
+ <input type="text" name="customer[state]" value="<%= @customer.state%>" <%= placeholder( "State" ) %> />
+ </li>
+
+ <li>
+ <label for="customer[zip]" class="fieldLabel">Zip</label>
+ <input type="text" name="customer[zip]" value="<%= @customer.zip%>" <%= placeholder( "Zip" ) %> />
+ </li>
+
+ <li>
+ <label for="customer[lat]" class="fieldLabel">Lat</label>
+ <input type="text" name="customer[lat]" value="<%= @customer.lat%>" <%= placeholder( "Lat" ) %> />
+ </li>
+
+ <li>
+ <label for="customer[long]" class="fieldLabel">Long</label>
+ <input type="text" name="customer[long]" value="<%= @customer.long%>" <%= placeholder( "Long" ) %> />
+ </li>
+
+ </ul>
+ <input type="submit" class="standardButton" value="Update" />
+ </form>
+</div>
21 contact/app/Customer/index.bb.erb
@@ -0,0 +1,21 @@
+<div id="pageTitle">
+ <h1>Customers</h1>
+</div>
+
+
+<div id="toolbar">
+ <%= link_to "New", :action => :new %>
+ <%= link_to "Home", RhoConfig::start_path %>
+</div>
+
+<div id="content">
+ <table>
+ <tr>
+ <% @customers.each do |obj| %>
+
+ <td class="recordLabel"><%= link_to "#{obj.first}", :action => :show, :id => obj.object %></td>
+
+ <% end %>
+ </tr>
+ </table>
+</div>
29 contact/app/Customer/index.erb
@@ -0,0 +1,29 @@
+<div id="pageTitle">
+ <h1>Customers</h1>
+</div>
+
+<div id="toolbar">
+ <div id="leftItem" class="regularButton"><%= link_to "Home", Rho::RhoConfig.start_path %></div>
+ <div id="rightItem" class="regularButton"><%= link_to "New", :controller => :Customer, :action => :new %></div>
+</div>
+
+<div id="content">
+ <ul>
+ <li>
+ <a href="<%= url_for :action => :map_all %>">
+ <span class="title">Map all</span>
+ <span class="disclosure_indicator"></span>
+ </a>
+ </li>
+ <% @customers.each do |obj| %>
+
+ <li>
+ <a href="<%= url_for :action => :show, :id => obj.object %>">
+ <span class="title"><%= obj.first %></span>
+ <span class="disclosure_indicator"></span>
+ </a>
+ </li>
+
+ <% end %>
+ </ul>
+</div>
69 contact/app/Customer/new.bb.erb
@@ -0,0 +1,69 @@
+<div id="pageTitle">
+ <h1>New Customer</h1>
+</div>
+
+<div id="toolbar">
+ <%= link_to "Back", :action => :index %>
+</div>
+
+
+<div id="content">
+
+ <form method="POST" action="<%= url_for :action => :create %>">
+ <input type="hidden" name="id" value="<%= @customer.object %>"/>
+ <table>
+
+ <tr>
+ <td class="itemLabel">First: </td>
+ <td class="itemValue"><input type="text" name="customer[first]"/></td>
+ </tr>
+
+ <tr>
+ <td class="itemLabel">Last: </td>
+ <td class="itemValue"><input type="text" name="customer[last]"/></td>
+ </tr>
+
+ <tr>
+ <td class="itemLabel">Email: </td>
+ <td class="itemValue"><input type="text" name="customer[email]"/></td>
+ </tr>
+
+ <tr>
+ <td class="itemLabel">Phone: </td>
+ <td class="itemValue"><input type="text" name="customer[phone]"/></td>
+ </tr>
+
+ <tr>
+ <td class="itemLabel">Address: </td>
+ <td class="itemValue"><input type="text" name="customer[address]"/></td>
+ </tr>
+
+ <tr>
+ <td class="itemLabel">City: </td>
+ <td class="itemValue"><input type="text" name="customer[city]"/></td>
+ </tr>
+
+ <tr>
+ <td class="itemLabel">State: </td>
+ <td class="itemValue"><input type="text" name="customer[state]"/></td>
+ </tr>
+
+ <tr>
+ <td class="itemLabel">Zip: </td>
+ <td class="itemValue"><input type="text" name="customer[zip]"/></td>
+ </tr>
+
+ <tr>
+ <td class="itemLabel">Lat: </td>
+ <td class="itemValue"><input type="text" name="customer[lat]"/></td>
+ </tr>
+
+ <tr>
+ <td class="itemLabel">Long: </td>
+ <td class="itemValue"><input type="text" name="customer[long]"/></td>
+ </tr>
+
+ </table>
+ <input type="submit" class="standardButton" value="Create" />
+ </form>
+</div>
67 contact/app/Customer/new.erb
@@ -0,0 +1,67 @@
+<div id="pageTitle">
+ <h1>New <%= @customer.title %></h1>
+</div>
+
+<div id="toolbar">
+ <div id="leftItem" class="backButton"><%= link_to "Cancel", :action => :index %></div>
+</div>
+
+<div id="content">
+ <form method="POST" action="<%= url_for :action => :create %>">
+ <input type="hidden" name="id" value="<%= @customer.object %>"/>
+ <ul>
+
+ <li>
+ <label for="customer[first]" class="fieldLabel">First</label>
+ <input type="text" name="customer[first]" <%= placeholder( "First" ) %> />
+ </li>
+
+ <li>
+ <label for="customer[last]" class="fieldLabel">Last</label>
+ <input type="text" name="customer[last]" <%= placeholder( "Last" ) %> />
+ </li>
+
+ <li>
+ <label for="customer[email]" class="fieldLabel">Email</label>
+ <input type="text" name="customer[email]" <%= placeholder( "Email" ) %> />
+ </li>
+
+ <li>
+ <label for="customer[phone]" class="fieldLabel">Phone</label>
+ <input type="text" name="customer[phone]" <%= placeholder( "Phone" ) %> />
+ </li>
+
+ <li>
+ <label for="customer[address]" class="fieldLabel">Address</label>
+ <input type="text" name="customer[address]" <%= placeholder( "Address" ) %> />
+ </li>
+
+ <li>
+ <label for="customer[city]" class="fieldLabel">City</label>
+ <input type="text" name="customer[city]" <%= placeholder( "City" ) %> />
+ </li>
+
+ <li>
+ <label for="customer[state]" class="fieldLabel">State</label>
+ <input type="text" name="customer[state]" <%= placeholder( "State" ) %> />
+ </li>
+
+ <li>
+ <label for="customer[zip]" class="fieldLabel">Zip</label>
+ <input type="text" name="customer[zip]" <%= placeholder( "Zip" ) %> />
+ </li>
+
+ <li>
+ <label for="customer[lat]" class="fieldLabel">Lat</label>
+ <input type="text" name="customer[lat]" <%= placeholder( "Lat" ) %> />
+ </li>
+
+ <li>
+ <label for="customer[long]" class="fieldLabel">Long</label>
+ <input type="text" name="customer[long]" <%= placeholder( "Long" ) %> />
+ </li>
+
+ </ul>
+ <input type="submit" class="standardButton" value="Create" />
+ </form>
+</div>
66 contact/app/Customer/show.bb.erb
@@ -0,0 +1,66 @@
+<div id="pageTitle">
+ <h1><%= @customer.first%></h1>
+</div>
+
+<div id="toolbar">
+ <%= link_to "Back", :action => :index %>
+ <%= link_to "Edit", :action => :edit, :id => @customer.object %>
+</div>
+
+
+<div id="content">
+
+ <table>
+
+ <tr>
+ <td class="itemLabel">First</td>
+ <td class="itemValue"><%= @customer.first%></td>
+ </tr>
+
+ <tr>
+ <td class="itemLabel">Last</td>
+ <td class="itemValue"><%= @customer.last%></td>
+ </tr>
+
+ <tr>
+ <td class="itemLabel">Email</td>
+ <td class="itemValue"><%= @customer.email%></td>
+ </tr>
+
+ <tr>
+ <td class="itemLabel">Phone</td>
+ <td class="itemValue"><%= @customer.phone%></td>
+ </tr>
+
+ <tr>
+ <td class="itemLabel">Address</td>
+ <td class="itemValue"><%= @customer.address%></td>
+ </tr>
+
+ <tr>
+ <td class="itemLabel">City</td>
+ <td class="itemValue"><%= @customer.city%></td>
+ </tr>
+
+ <tr>
+ <td class="itemLabel">State</td>
+ <td class="itemValue"><%= @customer.state%></td>
+ </tr>
+
+ <tr>
+ <td class="itemLabel">Zip</td>
+ <td class="itemValue"><%= @customer.zip%></td>
+ </tr>
+
+ <tr>
+ <td class="itemLabel">Lat</td>
+ <td class="itemValue"><%= @customer.lat%></td>
+ </tr>
+
+ <tr>
+ <td class="itemLabel">Long</td>
+ <td class="itemValue"><%= @customer.long%></td>
+ </tr>
+
+ </table>
+</div>
61 contact/app/Customer/show.erb
@@ -0,0 +1,61 @@
+<div id="pageTitle">
+ <h1><%= @customer.first%></h1>
+</div>
+
+<div id="toolbar">
+ <div id="leftItem" class="backButton"><%= link_to "Back", :action => :index %></div>
+ <div id="rightItem" class="regularButton"><%= link_to "Edit", :action => :edit, :id => @customer.object %></div>
+</div>
+
+<div id="content">
+ <ul>
+
+ <li>
+ <div class="itemLabel">First</div>
+ <div class="itemValue"><%= @customer.first%></div>
+ </li>
+
+ <li>
+ <div class="itemLabel">Last</div>
+ <div class="itemValue"><%= @customer.last%></div>
+ </li>
+
+ <li>
+ <div class="itemLabel">Email</div>
+ <div class="itemValue"><%= @customer.email%></div>
+ </li>
+
+ <li>
+ <div class="itemLabel">Phone</div>
+ <div class="itemValue"><%= @customer.phone%></div>
+ </li>
+
+ <li>
+ <div class="itemLabel">Address</div>
+ <div class="itemValue"><%= @customer.address%></div>
+ </li>
+
+ <li>
+ <div class="itemLabel">City</div>
+ <div class="itemValue"><%= @customer.city%></div>
+ </li>
+
+ <li>
+ <div class="itemLabel">State</div>
+ <div class="itemValue"><%= @customer.state%></div>
+ </li>
+
+ <li>
+ <div class="itemLabel">Zip</div>
+ <div class="itemValue"><%= @customer.zip%></div>
+ </li>
+
+ <li>
+ <a href="<%= url_for( :action => :map_it, :id => @customer.object) %>">
+ <span class="title">Show on map</span>
+ <span class="disclosure_indicator"></span>
+ </a>
+ </li>
+
+ </ul>
+</div>
10 contact/app/Customer/wait.erb
@@ -0,0 +1,10 @@
+<div id="pageTitle">
+ <h1>Wait</h1>
+</div>
+
+<div id="toolbar">
+</div>
+
+<div id="content">
+Please wait while we determine your location.
+</div>
75 contact/app/Settings/controller.rb
@@ -0,0 +1,75 @@
+require 'rho'
+require 'rho/rhocontroller'
+require 'rho/rhoerror'
+require 'helpers/browser_helper'
+
+class SettingsController < Rho::RhoController
+ include BrowserHelper
+
+ def index
+ @msg = @params['msg']
+ render
+ end
+
+ def login
+ @msg = @params['msg']
+ render :action => :login, :back => '/app'
+ end
+
+ def login_callback
+ errCode = @params['error_code'].to_i
+ if errCode == 0
+ # run sync if we were successful
+ WebView.navigate Rho::RhoConfig.options_path
+ SyncEngine.dosync
+ else
+ if errCode == Rho::RhoError::ERR_CUSTOMSYNCSERVER
+ @msg = @params['error_message']
+ end
+
+ if !@msg || @msg.length == 0
+ @msg = Rho::RhoError.new(errCode).message
+ end
+
+ WebView.navigate ( url_for :action => :login, :query => {:msg => @msg} )
+ end
+ end
+
+ def do_login
+ if @params['login'] and @params['password']
+ begin
+ SyncEngine.login(@params['login'], @params['password'], (url_for :action => :login_callback) )
+ render :action => :wait
+ rescue Rho::RhoError => e
+ @msg = e.message
+ render :action => :login
+ end
+ else
+ @msg = Rho::RhoError.err_message(Rho::RhoError::ERR_UNATHORIZED) unless @msg && @msg.length > 0
+ render :action => :login
+ end
+ end
+
+ def logout
+ SyncEngine.logout
+ @msg = "You have been logged out."
+ render :action => :login
+ end
+
+ def reset
+ render :action => :reset
+ end
+
+ def do_reset
+ Rhom::Rhom.database_full_reset
+ SyncEngine.dosync
+ @msg = "Database has been reset."
+ redirect :action => :index, :query => {:msg => @msg}
+ end
+
+ def do_sync
+ SyncEngine.dosync
+ @msg = "Sync has been triggered."
+ redirect :action => :index, :query => {:msg => @msg}
+ end
+end
17 contact/app/Settings/home.bb.erb
@@ -0,0 +1,17 @@
+<div id="pageTitle">
+ <h1>Home</h1>
+</div>
+
+<div id="toolbar">
+ <% if SyncEngine::logged_in > 0 %>
+ <%= link_to "Logout", :action => :logout %>
+ <% else %>
+ <%= link_to "Login", :action => :login %>
+ <% end %>
+</div>
+
+<div id="content">
+ <ul>
+ <li>Add links here...</li>
+ </ul>
+</div>
23 contact/app/Settings/home.erb
@@ -0,0 +1,23 @@
+<div id="pageTitle">>
+ <h1>Home</h1>
+</div>
+
+<div id="toolbar">
+ <div id="leftItem" class="blueButton"><%%= link_to "Sync", :action => :do_sync %></div>
+ <%% if SyncEngine::logged_in > 0 %>
+ <div id="rightItem" class="regularButton"><%%= link_to "Logout", :action => :logout %></div>
+ <%% else %>
+ <div id="rightItem" class="regularButton"><%%= link_to "Login", :action => :login %></div>
+ <%% end %>
+</div>
+
+<div id="content">
+ <ul>
+ <li>
+ <a href="#">
+ <span class="title">Add Links Here...</span>
+ <span class="disclosure_indicator"></span>
+ </a>
+ </li>
+ </ul>
+</div>
32 contact/app/Settings/index.bb.erb
@@ -0,0 +1,32 @@
+<div id="pageTitle">
+ <h1>Settings</h1>
+</div>
+
+<div id="content">
+ <% if @msg %>
+ <div class="alert" align="center"><%= @msg %></div>
+ <% end %>
+
+ <ul>
+ <li>
+ <p>Client ID: <span class="cid"><%= Rhom::Rhom::client_id %></span></p>
+ </li>
+ <li>
+ <%= link_to "Reset Database", :action => :reset %>
+ </li>
+ <li>
+ <%= link_to "Sync", :action => :do_sync %>
+ </li>
+
+ <% if SyncEngine::logged_in > 0 %>
+ <li>
+ <%= link_to "Logout", :action => :logout %>
+ </li>
+ <% else %>
+ <li>
+ <%= link_to "Login", :action => :login %>
+ </li>
+ <% end %>
+ </ul>
+
+</div>
46 contact/app/Settings/index.erb
@@ -0,0 +1,46 @@
+<div id="pageTitle">
+ <h1>Settings</h1>
+</div>
+
+<div id="toolbar"></div>
+
+<div id="content">
+ <ul id="settings">
+ <% if @msg %>
+ <li class="alertMessage">
+ <span class="message"><%= @msg %></span>
+ </li>
+ <% end %>
+ <li>
+ <div class="itemLabel">
+ <span class="title">Client ID:</span>
+ </div>
+ <div class="itemValue">
+ <span class="clientID"><%= Rhom::Rhom::client_id %></span>
+ </div>
+ </li>
+ <li>
+ <a href="<%= url_for :action => :reset %>">
+ <span class="title">Reset Database</span>
+ </a>
+ </li>
+ <li>
+ <a href="<%= url_for :action => :do_sync %>">
+ <span class="title">Perform Sync</span>
+ </a>
+ </li>
+ <% if SyncEngine::logged_in > 0 %>
+ <li>
+ <a href="<%= url_for :action => :logout %>">
+ <span class="title">Logout</span>
+ </a>
+ </li>
+ <% else %>
+ <li>
+ <a href="<%= url_for :action => :login %>">
+ <span class="title">Login</span>
+ </a>
+ </li>
+ <% end %>
+ </ul>
+</div>
35 contact/app/Settings/login.bb.erb
@@ -0,0 +1,35 @@
+<div id="pageTitle">
+ <h1>Login</h1>
+</div>
+
+<div id="toolbar">
+ <%= link_to "Back", :action => :index %>
+</div>
+
+<div id="content">
+ <form method="POST" action="<%= url_for :action => :do_login %>">
+
+ <% if @msg %>
+ <div class="alert" align="center"><%= @msg %></div>
+ <% end %>
+
+ <table>
+
+ <tr>
+ <td width="125" class="fieldLabel">Login</td>
+ <td><input type="text" maxlength="100" name="login"/></td>
+ </tr>
+
+ <tr>
+ <td width="125" class="fieldLabel">Password</td>
+ <td><input type="password" maxlength="100" name="password"/></td>
+ </tr>
+ </table>
+
+ <input type="submit" class="standardButton" value="Login" />
+ </form>
+</div>
+
+
+
+
31 contact/app/Settings/login.erb
@@ -0,0 +1,31 @@
+<div id="pageTitle">
+ <h1>Login</h1>
+</div>
+
+
+<div id="toolbar">
+ <div id="leftItem" class="regularButton"><%= link_to "Cancel", :action => :index %></div>
+</div>
+
+
+
+<div id="content">
+ <form method="POST" action="<%= url_for :action => :do_login %>">
+
+ <% if @msg %>
+ <p style="color:#ff0000"><%= @msg %></p>
+ <% end %>
+ <ul>
+ <li>
+ <label for="login" class="fieldLabel">Login</label>
+ <input type="text" name="login" <%= placeholder( "Login" ) %> />
+ </li>
+
+ <li>
+ <label for="password" class="fieldLabel">Password</label>
+ <input type="password" name="password" <%= placeholder( "Password" ) %> />
+ </li>
+ </ul>
+ <input type="submit" class="standardButton" value="Login" />
+ </form>
+</div>
15 contact/app/Settings/reset.bb.erb
@@ -0,0 +1,15 @@
+<div id="pageTitle">
+ <h1>Reset Database</h1>
+</div>
+
+<div id="toolbar">
+ <%= link_to "Confirm", :action => :do_reset %>
+ <%= link_to "Cancel", Rho::RhoConfig.options_path %>
+</div>
+
+<div id="content">
+ <div class="warning">
+ <h2>Are you sure?</h2>
+ <p> Resetting removes all objects from your device.</p>
+ </div>
+</div>
18 contact/app/Settings/reset.erb
@@ -0,0 +1,18 @@
+<div id="pageTitle">
+ <h1>Reset Database</h1>
+</div>
+
+
+
+<div id="toolbar">
+ <div id="leftItem" class="regularButton"><%= link_to "Cancel", :action => :index %></div>
+ <div id="rightItem" class="blueButton"><%= link_to "Confirm", :action => :do_reset %></div>
+</div>
+
+
+<div id="content">
+ <div id="reset">
+ <h4>Are you sure?<br/>
+ Resetting removes all objects from your device.</h4>
+ </div>
+</div>
3 contact/app/Settings/wait.bb.erb
@@ -0,0 +1,3 @@
+<div id="pageTitle">
+ <h1>Wait</h1>
+</div>
5 contact/app/Settings/wait.erb
@@ -0,0 +1,5 @@
+<div id="pageTitle">
+ <h1>Wait</h1>
+</div>
+
+<div id="toolbar"></div>
12 contact/app/application.rb
@@ -0,0 +1,12 @@
+require 'rho/rhoapplication'
+
+class AppApplication < Rho::RhoApplication
+ def initialize
+ # Tab items are loaded left->right, @tabs[0] is leftmost tab in the tab-bar
+ @tabs = nil
+
+ @@tabbar = nil
+ # Important to call super _after_ you define @tabs!
+ super
+ end
+end
108 contact/app/helpers/application_helper.rb
@@ -0,0 +1,108 @@
+module ApplicationHelper
+ def strip_braces(str=nil)
+ str ? str.gsub(/\{/,"").gsub(/\}/,"") : nil
+ end
+
+ def strike_if(str, condition=true)
+ condition ? "<s>#{str}</s>" : str
+ end
+
+ def display_blanks(value)
+ if blank?(value)
+ "---"
+ else
+ value
+ end
+ end
+
+ def blank?(value)
+ value.nil? || value == "" || value.length==0
+ end
+
+ def display_blankstr(value)
+ if blank?(value)
+ " "
+ else
+ value
+ end
+ end
+
+ def display_newline()
+ "<br>"
+ end
+
+ def display_space()
+ " "
+ end
+
+ def display_dollars(value)
+ if blank?(value)
+ " "
+ else
+ number = "$" + sprintf("%.2f", value)
+
+ # use a commify algorithm -- http://snippets.dzone.com/tag/commify
+ number.reverse!
+ number.gsub!(/(\d\d\d)(?=\d)(?!\d*\.)/, '\1,')
+ number.reverse!
+ end
+ end
+
+ def display_number(value)
+ if blank?(value)
+ " "
+ else
+ sprintf("%.2f", value)
+ end
+ end
+
+ def both_items_present?(value1, value2)
+ !blank?(value1) && !blank?(value2)
+ end
+
+ def replace_newlines(value)
+ if blank?(value)
+ " "
+ else
+ value.gsub('\n', ' ')
+ end
+ end
+
+ def format_address_for_mapping(street, city, state, zip, tagforurl)
+ # handle case where fields could be nil
+ mystreet = !street.nil? ? street : ""
+ mycity = !city.nil? ? city : ""
+ mystate = !state.nil? ? state : ""
+ myzip = !zip.nil? ? zip : ""
+
+ result = ""
+ if !tagforurl
+ # build up address string
+ result += (mystreet + ", ") if mystreet.length > 0
+ result += (mycity + ", ") if mycity.length > 0
+ result += (mystate + " ") if mystate.length > 0
+ result += myzip if myzip.length > 0
+ else
+ # need to URL encode data too
+ result += ("&street=" + Rho::RhoSupport.url_encode(mystreet)) if mystreet.length > 0
+ result += ("&city=" + Rho::RhoSupport.url_encode(mycity)) if mycity.length > 0
+ result += ("&state=" + Rho::RhoSupport.url_encode(mystate)) if mystate.length > 0
+ result += ("&zip=" + Rho::RhoSupport.url_encode(myzip)) if myzip.length > 0
+ end
+ # remove any extraneous characters that could interfere with proper address matching
+ result = replace_newlines(result)
+ end
+
+ def has_valid_mapping_address(street, city, state, zip)
+ # at a minimum, an address must have a state or a zip
+ (!state.nil? && state.length > 0) || (!zip.nil? && zip.length > 0)
+ end
+
+ def format_latlon_for_mapping(latitude, longitude)
+ result = ""
+ result += ("&latitude=" + Rho::RhoSupport.url_encode(latitude)) if latitude.length > 0
+ result += ("&longitude=" + Rho::RhoSupport.url_encode(longitude)) if longitude.length > 0
+ result
+ end
+
+end
18 contact/app/helpers/browser_helper.rb
@@ -0,0 +1,18 @@
+module BrowserHelper
+
+ def placeholder(label=nil)
+ "placeholder='#{label}'" if platform == 'apple'
+ end
+
+ def platform
+ System::get_property('platform').downcase
+ end
+
+ def selected(option_value,object_value)
+ "selected=\"yes\"" if option_value == object_value
+ end
+
+ def checked(option_value,object_value)
+ "checked=\"yes\"" if option_value == object_value
+ end
+end
26 contact/app/index.bb.erb
@@ -0,0 +1,26 @@
+<div id="pageTitle">
+ <h1>Contact</h1>
+</div>
+
+<div id="toolbar">
+ <%= link_to "Sync", :controller => :Settings, :action => :do_sync %>
+ <% if SyncEngine::logged_in > 0 %>
+ <%= link_to "Logout", :controller => :Settings, :action => :logout %>
+ <% else %>
+ <%= link_to "Login", :controller => :Settings, :action => :login %>
+ <% end %>
+</div>
+
+
+<div id="content">
+ <table>
+ <tr>
+ <td class="recordLabel">Add links here...</td>
+ </tr>
+ </table>
+</div>
+
+
+
+
+
23 contact/app/index.erb
@@ -0,0 +1,23 @@
+<div id="pageTitle">
+ <h1>Contact</h1>
+</div>
+
+<div id="toolbar">
+ <div id="leftItem" class="blueButton"><%= link_to "Sync", :controller => :Settings, :action => :do_sync %></div>
+ <% if SyncEngine::logged_in > 0 %>
+ <div id="rightItem" class="regularButton"><%= link_to "Logout", :controller => :Settings, :action => :logout %></div>
+ <% else %>
+ <div id="rightItem" class="regularButton"><%= link_to "Login", :controller => :Settings, :action => :login %></div>
+ <% end %>
+</div>
+
+<div id="content">
+ <ul>
+ <li>
+ <a href="Customer">
+ <span class="title">Customers</span>
+ <span class="disclosure_indicator"></span>
+ </a>
+ </li>
+ </ul>
+</div>
25 contact/app/layout.erb
@@ -0,0 +1,25 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <title>Contact</title>
+
+ <% if System::get_property('platform') == 'APPLE' %>
+ <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;"/>
+ <link href="/public/css/webkit.css" type="text/css" rel="stylesheet"/>
+ <link href="/public/css/iphone.css" type="text/css" rel="stylesheet"/>
+ <% elsif System::get_property('platform') == 'Blackberry' %>
+ <link href="/public/css/blackberry.css" type="text/css" rel="stylesheet"/>
+ <% elsif System::get_property('platform') == 'ANDROID' %>
+ <link href="/public/css/webkit.css" type="text/css" rel="stylesheet"/>
+ <link href="/public/css/android.css" type="text/css" rel="stylesheet"/>
+ <% else %>
+ <link href="/public/css/windows_mobile.css" type="text/css" rel="stylesheet"/>
+ <% end %>
+
+
+ </head>
+ <body>
+ <%= @content %>
+ </body>
+</html>
11 contact/app/loading.html
@@ -0,0 +1,11 @@
+<html>
+ <head>
+ <title>Home</title>
+ <meta name="viewport" content="initial-scale=1.0, width=device-width"/>
+ </head>
+ <body>
+ <div align="center">
+ <h3>Loading...</h3>
+ </div>
+ </body>
+</html>
7 contact/app/test/customer_spec.rb
@@ -0,0 +1,7 @@
+describe "Customer" do
+ #this test always fails, you really should have tests!
+
+ it "should have tests" do
+ true.should == false
+ end
+end
25 contact/build.yml
@@ -0,0 +1,25 @@
+---
+extensions:
+- extension-name-here
+- second-extension-name
+name: contact
+capabilities:
+- gps
+bbver: 4.6
+android:
+ version: 2.1
+ apikey: 0iQD6Wk5WtjLaoD4-g5eXbsfsyNSroB8KmRJkkA
+ mapping: true
+sdk: /Users/brian/work/rhodes
+applog: rholog.txt
+build: debug
+wmsdk: Windows Mobile 6 Professional SDK (ARMV4I)
+version: 1.0
+vendor: rhomobile
+sdkversion: 2.0.0
+iphone:
+ provisionprofile:
+ sdk: iphonesimulator3.0
+ entitlements:
+ codesignidentity:
+ configuration: Debug
BIN contact/icon/icon.ico
Binary file not shown.
BIN contact/icon/icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
287 contact/public/css/android.css
@@ -0,0 +1,287 @@
+/* Common css */
+
+body {
+ margin: 0;
+ height: 100%;
+ width: inherit;
+ font-family: "Droid",sans-serif;
+ background: white;
+ color: black;
+}
+h1 {
+ font-size: 1em;
+}
+
+div#content {
+ background-color:#ffffff;
+ width: 100%;
+ padding:0;
+ margin:0;
+}
+
+/* Toolbar */
+
+div#toolbar {
+ height: 60px;
+ width: 100%;
+ background: -webkit-gradient(linear, left top, left bottom, color-stop(0.0, #2B2B2B),color-stop(0.2, #585858),color-stop(1.0, #2B2B2B));
+ display: table;
+ text-align: center;
+ border-spacing: 10px;
+}
+
+div#toolbar div#leftItem,
+div#toolbar div#centerItem,
+div#toolbar div#rightItem {
+ display: table-cell;
+}
+
+div#toolbar a {
+ line-height: 40px;
+ color: black;
+ display: block;
+}
+
+div#toolbar .deleteButton,
+div#toolbar .regularButton,
+div#toolbar .blueButton,
+div#toolbar .backButton {
+ background: -webkit-gradient(linear, left top, left bottom, color-stop(0.0, white),color-stop(0.5, #ccc), color-stop(1.0, #bdbebd));
+ -webkit-border-radius: 1px;
+ font-size: .9em;
+ border: 1px solid white;
+}
+
+
+/* Header */
+
+div#pageTitle {
+ height: 25px;
+ margin:0;
+ width: 100%;
+ display:none;
+}
+
+div#pageTitle h1 {
+ position: absolute;
+ top: 0;
+ text-align: left;
+ width: 100%;
+ margin: 0;
+ padding-left: 5px;
+ color: white;
+ text-shadow: 1px 1px 1px #000;
+ line-height: 25px;
+ background: -webkit-gradient(linear, left top, left bottom, color-stop(0.0, #999),color-stop(0.5, #848684));
+}
+
+
+/* lists */
+
+div#content ul {
+ background: white;
+}
+
+div#content ul li {
+ border-bottom: 1px solid #000;
+ font-size: 20px;
+}
+
+div#content ul li a {
+ display: block;
+ text-decoration: none;