Permalink
Browse files

initial check-in of project

  • Loading branch information...
0 parents commit 2fbe4f3819142e4ede57d17870dea2e7dad6b9f8 @mschoch mschoch committed Nov 20, 2011
Showing with 9,008 additions and 0 deletions.
  1. +8 −0 .classpath
  2. +17 −0 .gitignore
  3. BIN .phonegap/android/phonegap-1.2.0.jar
  4. +4,635 −0 .phonegap/android/phonegap-1.2.0.js
  5. +1 −0 .phonegap/android/readme.md
  6. +5 −0 .phonegap/config
  7. +3 −0 .phonegap/readme.md
  8. +33 −0 .project
  9. +34 −0 AndroidManifest.xml
  10. BIN Couchbase.zip
  11. +37 −0 README.md
  12. +17 −0 ant.properties
  13. +3 −0 assets/install/couchdb/bin/couchjs_wrapper
  14. +35 −0 assets/install/couchdb/etc/couchdb/android.default.ini
  15. +293 −0 assets/install/couchdb/etc/couchdb/default.ini
  16. +74 −0 assets/install/couchdb/etc/couchdb/local.ini
  17. 0 assets/install/couchdb/etc/couchdb/overrides.ini
  18. +7 −0 assets/install/couchdb/etc/default/couchdb
  19. BIN assets/install/couchdb/lib/couchdb/bin/couchjs
  20. +1,549 −0 assets/install/couchdb/share/couchdb/server/main-coffee.js
  21. +1,542 −0 assets/install/couchdb/share/couchdb/server/main.js
  22. +20 −0 assets/install/couchspawnkillable
  23. BIN assets/install/erlang/bin/child_setup
  24. +4 −0 assets/install/erlang/bin/erl_inetrc
  25. BIN assets/install/erlang/bin/inet_gethost
  26. BIN assets/install/erlang/bin/start.boot
  27. +30 −0 assets/lib/couch/ebin/couch.app
  28. BIN assets/lib/couch/ebin/couch.beam
  29. BIN assets/lib/couch/ebin/couch_access_log.beam
  30. BIN assets/lib/couch/ebin/couch_api_wrap.beam
  31. BIN assets/lib/couch/ebin/couch_api_wrap_httpc.beam
  32. BIN assets/lib/couch/ebin/couch_app.beam
  33. BIN assets/lib/couch/ebin/couch_auth_cache.beam
  34. BIN assets/lib/couch/ebin/couch_btree.beam
  35. BIN assets/lib/couch/ebin/couch_btree_copy.beam
  36. BIN assets/lib/couch/ebin/couch_changes.beam
  37. BIN assets/lib/couch/ebin/couch_compaction_daemon.beam
  38. BIN assets/lib/couch/ebin/couch_compress.beam
  39. BIN assets/lib/couch/ebin/couch_compress_types.beam
  40. BIN assets/lib/couch/ebin/couch_config.beam
  41. BIN assets/lib/couch/ebin/couch_config_writer.beam
  42. BIN assets/lib/couch/ebin/couch_db.beam
  43. BIN assets/lib/couch/ebin/couch_db_frontend.beam
  44. BIN assets/lib/couch/ebin/couch_db_update_notifier.beam
  45. BIN assets/lib/couch/ebin/couch_db_update_notifier_sup.beam
  46. BIN assets/lib/couch/ebin/couch_db_updater.beam
  47. BIN assets/lib/couch/ebin/couch_doc.beam
  48. BIN assets/lib/couch/ebin/couch_drv.beam
  49. BIN assets/lib/couch/ebin/couch_ejson_compare.beam
  50. BIN assets/lib/couch/ebin/couch_event_sup.beam
  51. BIN assets/lib/couch/ebin/couch_external_manager.beam
  52. BIN assets/lib/couch/ebin/couch_external_server.beam
  53. BIN assets/lib/couch/ebin/couch_file.beam
  54. BIN assets/lib/couch/ebin/couch_httpc_pool.beam
  55. BIN assets/lib/couch/ebin/couch_httpd.beam
  56. BIN assets/lib/couch/ebin/couch_httpd_auth.beam
  57. BIN assets/lib/couch/ebin/couch_httpd_db.beam
  58. BIN assets/lib/couch/ebin/couch_httpd_external.beam
  59. BIN assets/lib/couch/ebin/couch_httpd_misc_handlers.beam
  60. BIN assets/lib/couch/ebin/couch_httpd_oauth.beam
  61. BIN assets/lib/couch/ebin/couch_httpd_proxy.beam
  62. BIN assets/lib/couch/ebin/couch_httpd_replicator.beam
  63. BIN assets/lib/couch/ebin/couch_httpd_rewrite.beam
  64. BIN assets/lib/couch/ebin/couch_httpd_show.beam
  65. BIN assets/lib/couch/ebin/couch_httpd_stats_handlers.beam
  66. BIN assets/lib/couch/ebin/couch_httpd_vhost.beam
  67. BIN assets/lib/couch/ebin/couch_httpd_view.beam
  68. BIN assets/lib/couch/ebin/couch_httpd_view_merger.beam
  69. BIN assets/lib/couch/ebin/couch_indexer_manager.beam
  70. BIN assets/lib/couch/ebin/couch_internal_load_gen.beam
  71. BIN assets/lib/couch/ebin/couch_key_tree.beam
  72. BIN assets/lib/couch/ebin/couch_log.beam
  73. BIN assets/lib/couch/ebin/couch_native_process.beam
  74. BIN assets/lib/couch/ebin/couch_os_daemons.beam
  75. BIN assets/lib/couch/ebin/couch_os_process.beam
  76. BIN assets/lib/couch/ebin/couch_primary_sup.beam
  77. BIN assets/lib/couch/ebin/couch_query_servers.beam
  78. BIN assets/lib/couch/ebin/couch_ref_counter.beam
  79. BIN assets/lib/couch/ebin/couch_rep_sup.beam
  80. BIN assets/lib/couch/ebin/couch_replication_manager.beam
  81. BIN assets/lib/couch/ebin/couch_replication_notifier.beam
  82. BIN assets/lib/couch/ebin/couch_replicator.beam
  83. BIN assets/lib/couch/ebin/couch_replicator_utils.beam
  84. BIN assets/lib/couch/ebin/couch_replicator_worker.beam
  85. BIN assets/lib/couch/ebin/couch_secondary_sup.beam
  86. BIN assets/lib/couch/ebin/couch_server.beam
  87. BIN assets/lib/couch/ebin/couch_server_sup.beam
  88. BIN assets/lib/couch/ebin/couch_skew.beam
  89. BIN assets/lib/couch/ebin/couch_stats_aggregator.beam
  90. BIN assets/lib/couch/ebin/couch_stats_collector.beam
  91. BIN assets/lib/couch/ebin/couch_stream.beam
  92. BIN assets/lib/couch/ebin/couch_task_status.beam
  93. BIN assets/lib/couch/ebin/couch_util.beam
  94. BIN assets/lib/couch/ebin/couch_uuids.beam
  95. BIN assets/lib/couch/ebin/couch_view.beam
  96. BIN assets/lib/couch/ebin/couch_view_compactor.beam
  97. BIN assets/lib/couch/ebin/couch_view_group.beam
  98. BIN assets/lib/couch/ebin/couch_view_merger.beam
  99. BIN assets/lib/couch/ebin/couch_view_merger_queue.beam
  100. BIN assets/lib/couch/ebin/couch_view_updater.beam
  101. BIN assets/lib/couch/ebin/couch_work_queue.beam
  102. BIN assets/lib/couch/ebin/jninif.beam
  103. BIN assets/lib/couch/ebin/json_stream_parse.beam
  104. +31 −0 assets/lib/crypto-2.0.3/ebin/crypto.app
  105. +22 −0 assets/lib/crypto-2.0.3/ebin/crypto.appup
  106. BIN assets/lib/crypto-2.0.3/ebin/crypto.beam
  107. BIN assets/lib/crypto-2.0.3/ebin/crypto_app.beam
  108. BIN assets/lib/crypto-2.0.3/ebin/crypto_server.beam
  109. BIN assets/lib/crypto-2.0.3/ebin/crypto_sup.beam
  110. +9 −0 assets/lib/ejson-0.1.0/ebin/ejson.app
  111. BIN assets/lib/ejson-0.1.0/ebin/ejson.beam
  112. BIN assets/lib/ejson-0.1.0/ebin/mochijson2.beam
  113. BIN assets/lib/ejson-0.1.0/ebin/mochinum.beam
  114. +20 −0 assets/lib/erlang-oauth/ebin/oauth.app
  115. BIN assets/lib/erlang-oauth/ebin/oauth.beam
  116. BIN assets/lib/erlang-oauth/ebin/oauth_hmac_sha1.beam
  117. BIN assets/lib/erlang-oauth/ebin/oauth_http.beam
  118. BIN assets/lib/erlang-oauth/ebin/oauth_plaintext.beam
  119. BIN assets/lib/erlang-oauth/ebin/oauth_unix.beam
  120. BIN assets/lib/erlang-oauth/ebin/oauth_uri.beam
  121. BIN assets/lib/geocouch/couch_httpd_spatial.beam
  122. BIN assets/lib/geocouch/couch_httpd_spatial_list.beam
  123. BIN assets/lib/geocouch/couch_spatial.beam
  124. BIN assets/lib/geocouch/couch_spatial_compactor.beam
  125. BIN assets/lib/geocouch/couch_spatial_group.beam
  126. BIN assets/lib/geocouch/couch_spatial_updater.beam
  127. BIN assets/lib/geocouch/geocouch_duplicates.beam
  128. BIN assets/lib/geocouch/run_vtreestats.beam
  129. BIN assets/lib/geocouch/run_vtreeviz.beam
  130. BIN assets/lib/geocouch/vtree.beam
  131. BIN assets/lib/geocouch/vtree_bulk.beam
  132. BIN assets/lib/geocouch/vtree_insbench.beam
  133. BIN assets/lib/geocouch/vtreestats.beam
  134. BIN assets/lib/geocouch/vtreeviz.beam
  135. +13 −0 assets/lib/ibrowse-2.2.0/ebin/ibrowse.app
  136. BIN assets/lib/ibrowse-2.2.0/ebin/ibrowse.beam
  137. BIN assets/lib/ibrowse-2.2.0/ebin/ibrowse_app.beam
  138. BIN assets/lib/ibrowse-2.2.0/ebin/ibrowse_http_client.beam
  139. BIN assets/lib/ibrowse-2.2.0/ebin/ibrowse_lb.beam
  140. BIN assets/lib/ibrowse-2.2.0/ebin/ibrowse_lib.beam
  141. BIN assets/lib/ibrowse-2.2.0/ebin/ibrowse_sup.beam
  142. BIN assets/lib/ibrowse-2.2.0/ebin/ibrowse_test.beam
  143. BIN assets/lib/inets-5.7/ebin/httpd_util.beam
  144. +112 −0 assets/lib/inets-5.7/ebin/inets.app
  145. BIN assets/lib/kernel-2.14.5/ebin/application.beam
  146. BIN assets/lib/kernel-2.14.5/ebin/application_controller.beam
  147. BIN assets/lib/kernel-2.14.5/ebin/application_master.beam
  148. BIN assets/lib/kernel-2.14.5/ebin/application_starter.beam
  149. BIN assets/lib/kernel-2.14.5/ebin/auth.beam
  150. BIN assets/lib/kernel-2.14.5/ebin/code.beam
  151. BIN assets/lib/kernel-2.14.5/ebin/code_server.beam
  152. BIN assets/lib/kernel-2.14.5/ebin/disk_log.beam
  153. BIN assets/lib/kernel-2.14.5/ebin/disk_log_1.beam
  154. BIN assets/lib/kernel-2.14.5/ebin/disk_log_server.beam
  155. BIN assets/lib/kernel-2.14.5/ebin/disk_log_sup.beam
  156. BIN assets/lib/kernel-2.14.5/ebin/dist_ac.beam
  157. BIN assets/lib/kernel-2.14.5/ebin/dist_util.beam
  158. BIN assets/lib/kernel-2.14.5/ebin/erl_boot_server.beam
  159. BIN assets/lib/kernel-2.14.5/ebin/erl_ddll.beam
  160. BIN assets/lib/kernel-2.14.5/ebin/erl_distribution.beam
  161. BIN assets/lib/kernel-2.14.5/ebin/erl_epmd.beam
  162. BIN assets/lib/kernel-2.14.5/ebin/erl_reply.beam
  163. BIN assets/lib/kernel-2.14.5/ebin/error_handler.beam
  164. BIN assets/lib/kernel-2.14.5/ebin/error_logger.beam
  165. BIN assets/lib/kernel-2.14.5/ebin/erts_debug.beam
  166. BIN assets/lib/kernel-2.14.5/ebin/file.beam
  167. BIN assets/lib/kernel-2.14.5/ebin/file_io_server.beam
  168. BIN assets/lib/kernel-2.14.5/ebin/file_server.beam
  169. BIN assets/lib/kernel-2.14.5/ebin/gen_sctp.beam
  170. BIN assets/lib/kernel-2.14.5/ebin/gen_tcp.beam
  171. BIN assets/lib/kernel-2.14.5/ebin/gen_udp.beam
  172. BIN assets/lib/kernel-2.14.5/ebin/global.beam
  173. BIN assets/lib/kernel-2.14.5/ebin/global_group.beam
  174. BIN assets/lib/kernel-2.14.5/ebin/global_search.beam
  175. BIN assets/lib/kernel-2.14.5/ebin/group.beam
  176. BIN assets/lib/kernel-2.14.5/ebin/heart.beam
  177. BIN assets/lib/kernel-2.14.5/ebin/hipe_unified_loader.beam
  178. BIN assets/lib/kernel-2.14.5/ebin/inet.beam
  179. BIN assets/lib/kernel-2.14.5/ebin/inet6_sctp.beam
  180. BIN assets/lib/kernel-2.14.5/ebin/inet6_tcp.beam
  181. BIN assets/lib/kernel-2.14.5/ebin/inet6_tcp_dist.beam
  182. BIN assets/lib/kernel-2.14.5/ebin/inet6_udp.beam
  183. BIN assets/lib/kernel-2.14.5/ebin/inet_config.beam
  184. BIN assets/lib/kernel-2.14.5/ebin/inet_db.beam
  185. BIN assets/lib/kernel-2.14.5/ebin/inet_dns.beam
  186. BIN assets/lib/kernel-2.14.5/ebin/inet_gethost_native.beam
  187. BIN assets/lib/kernel-2.14.5/ebin/inet_hosts.beam
  188. BIN assets/lib/kernel-2.14.5/ebin/inet_parse.beam
  189. BIN assets/lib/kernel-2.14.5/ebin/inet_res.beam
  190. BIN assets/lib/kernel-2.14.5/ebin/inet_sctp.beam
  191. BIN assets/lib/kernel-2.14.5/ebin/inet_tcp.beam
  192. BIN assets/lib/kernel-2.14.5/ebin/inet_tcp_dist.beam
  193. BIN assets/lib/kernel-2.14.5/ebin/inet_udp.beam
  194. +120 −0 assets/lib/kernel-2.14.5/ebin/kernel.app
  195. +1 −0 assets/lib/kernel-2.14.5/ebin/kernel.appup
  196. BIN assets/lib/kernel-2.14.5/ebin/kernel.beam
  197. BIN assets/lib/kernel-2.14.5/ebin/kernel_config.beam
  198. BIN assets/lib/kernel-2.14.5/ebin/net.beam
  199. BIN assets/lib/kernel-2.14.5/ebin/net_adm.beam
  200. BIN assets/lib/kernel-2.14.5/ebin/net_kernel.beam
  201. BIN assets/lib/kernel-2.14.5/ebin/os.beam
  202. BIN assets/lib/kernel-2.14.5/ebin/packages.beam
  203. BIN assets/lib/kernel-2.14.5/ebin/pg2.beam
  204. BIN assets/lib/kernel-2.14.5/ebin/ram_file.beam
  205. BIN assets/lib/kernel-2.14.5/ebin/rpc.beam
  206. BIN assets/lib/kernel-2.14.5/ebin/seq_trace.beam
  207. BIN assets/lib/kernel-2.14.5/ebin/standard_error.beam
  208. BIN assets/lib/kernel-2.14.5/ebin/user.beam
  209. BIN assets/lib/kernel-2.14.5/ebin/user_drv.beam
  210. BIN assets/lib/kernel-2.14.5/ebin/user_sup.beam
  211. BIN assets/lib/kernel-2.14.5/ebin/wrap_log_reader.beam
  212. BIN assets/lib/mochiweb-1.4.1/ebin/mochifmt.beam
  213. BIN assets/lib/mochiweb-1.4.1/ebin/mochifmt_records.beam
  214. BIN assets/lib/mochiweb-1.4.1/ebin/mochifmt_std.beam
  215. BIN assets/lib/mochiweb-1.4.1/ebin/mochiglobal.beam
  216. BIN assets/lib/mochiweb-1.4.1/ebin/mochihex.beam
  217. BIN assets/lib/mochiweb-1.4.1/ebin/mochijson.beam
  218. BIN assets/lib/mochiweb-1.4.1/ebin/mochijson2.beam
  219. BIN assets/lib/mochiweb-1.4.1/ebin/mochilists.beam
  220. BIN assets/lib/mochiweb-1.4.1/ebin/mochilogfile2.beam
  221. BIN assets/lib/mochiweb-1.4.1/ebin/mochinum.beam
  222. BIN assets/lib/mochiweb-1.4.1/ebin/mochitemp.beam
  223. BIN assets/lib/mochiweb-1.4.1/ebin/mochiutf8.beam
  224. +32 −0 assets/lib/mochiweb-1.4.1/ebin/mochiweb.app
  225. BIN assets/lib/mochiweb-1.4.1/ebin/mochiweb.beam
  226. BIN assets/lib/mochiweb-1.4.1/ebin/mochiweb_acceptor.beam
  227. BIN assets/lib/mochiweb-1.4.1/ebin/mochiweb_app.beam
  228. BIN assets/lib/mochiweb-1.4.1/ebin/mochiweb_charref.beam
  229. BIN assets/lib/mochiweb-1.4.1/ebin/mochiweb_cookies.beam
  230. BIN assets/lib/mochiweb-1.4.1/ebin/mochiweb_cover.beam
  231. BIN assets/lib/mochiweb-1.4.1/ebin/mochiweb_echo.beam
  232. BIN assets/lib/mochiweb-1.4.1/ebin/mochiweb_headers.beam
  233. BIN assets/lib/mochiweb-1.4.1/ebin/mochiweb_html.beam
  234. BIN assets/lib/mochiweb-1.4.1/ebin/mochiweb_http.beam
  235. BIN assets/lib/mochiweb-1.4.1/ebin/mochiweb_io.beam
  236. BIN assets/lib/mochiweb-1.4.1/ebin/mochiweb_mime.beam
  237. BIN assets/lib/mochiweb-1.4.1/ebin/mochiweb_multipart.beam
  238. BIN assets/lib/mochiweb-1.4.1/ebin/mochiweb_request.beam
  239. BIN assets/lib/mochiweb-1.4.1/ebin/mochiweb_response.beam
  240. BIN assets/lib/mochiweb-1.4.1/ebin/mochiweb_skel.beam
  241. BIN assets/lib/mochiweb-1.4.1/ebin/mochiweb_socket.beam
  242. BIN assets/lib/mochiweb-1.4.1/ebin/mochiweb_socket_server.beam
  243. BIN assets/lib/mochiweb-1.4.1/ebin/mochiweb_sup.beam
  244. BIN assets/lib/mochiweb-1.4.1/ebin/mochiweb_util.beam
  245. BIN assets/lib/mochiweb-1.4.1/ebin/reloader.beam
  246. BIN assets/lib/os_mon-2.2.6/ebin/cpu_sup.beam
  247. BIN assets/lib/os_mon-2.2.6/ebin/disksup.beam
  248. BIN assets/lib/os_mon-2.2.6/ebin/memsup.beam
  249. BIN assets/lib/os_mon-2.2.6/ebin/nteventlog.beam
  250. +32 −0 assets/lib/os_mon-2.2.6/ebin/os_mon.app
  251. +41 −0 assets/lib/os_mon-2.2.6/ebin/os_mon.appup
  252. BIN assets/lib/os_mon-2.2.6/ebin/os_mon.beam
  253. BIN assets/lib/os_mon-2.2.6/ebin/os_mon_mib.beam
  254. BIN assets/lib/os_mon-2.2.6/ebin/os_mon_sysinfo.beam
  255. BIN assets/lib/os_mon-2.2.6/ebin/os_sup.beam
  256. BIN assets/lib/public_key-0.12/ebin/OTP-PUB-KEY.beam
  257. BIN assets/lib/public_key-0.12/ebin/pubkey_cert.beam
  258. BIN assets/lib/public_key-0.12/ebin/pubkey_cert_records.beam
  259. BIN assets/lib/public_key-0.12/ebin/pubkey_pem.beam
  260. BIN assets/lib/public_key-0.12/ebin/pubkey_ssh.beam
  261. +16 −0 assets/lib/public_key-0.12/ebin/public_key.app
  262. +70 −0 assets/lib/public_key-0.12/ebin/public_key.appup
  263. BIN assets/lib/public_key-0.12/ebin/public_key.beam
  264. BIN assets/lib/sasl-2.1.9.4/ebin/alarm_handler.beam
  265. BIN assets/lib/sasl-2.1.9.4/ebin/erlsrv.beam
  266. BIN assets/lib/sasl-2.1.9.4/ebin/format_lib_supp.beam
  267. BIN assets/lib/sasl-2.1.9.4/ebin/misc_supp.beam
  268. BIN assets/lib/sasl-2.1.9.4/ebin/overload.beam
  269. BIN assets/lib/sasl-2.1.9.4/ebin/rb.beam
  270. BIN assets/lib/sasl-2.1.9.4/ebin/rb_format_supp.beam
  271. BIN assets/lib/sasl-2.1.9.4/ebin/release_handler.beam
  272. BIN assets/lib/sasl-2.1.9.4/ebin/release_handler_1.beam
  273. +48 −0 assets/lib/sasl-2.1.9.4/ebin/sasl.app
  274. +25 −0 assets/lib/sasl-2.1.9.4/ebin/sasl.appup
  275. BIN assets/lib/sasl-2.1.9.4/ebin/sasl.beam
  276. BIN assets/lib/sasl-2.1.9.4/ebin/sasl_report.beam
  277. BIN assets/lib/sasl-2.1.9.4/ebin/sasl_report_file_h.beam
  278. BIN assets/lib/sasl-2.1.9.4/ebin/sasl_report_tty_h.beam
  279. BIN assets/lib/sasl-2.1.9.4/ebin/si.beam
  280. BIN assets/lib/sasl-2.1.9.4/ebin/si_sasl_supp.beam
  281. BIN assets/lib/sasl-2.1.9.4/ebin/systools.beam
  282. BIN assets/lib/sasl-2.1.9.4/ebin/systools_lib.beam
  283. BIN assets/lib/sasl-2.1.9.4/ebin/systools_make.beam
  284. BIN assets/lib/sasl-2.1.9.4/ebin/systools_rc.beam
  285. BIN assets/lib/sasl-2.1.9.4/ebin/systools_relup.beam
  286. +12 −0 assets/lib/snappy-1.0.3/ebin/snappy.app
  287. BIN assets/lib/snappy-1.0.3/ebin/snappy.beam
  288. BIN assets/lib/ssl-4.1.6/ebin/inet_ssl_dist.beam
  289. +36 −0 assets/lib/ssl-4.1.6/ebin/ssl.app
  290. +21 −0 assets/lib/ssl-4.1.6/ebin/ssl.appup
  291. BIN assets/lib/ssl-4.1.6/ebin/ssl.beam
  292. BIN assets/lib/ssl-4.1.6/ebin/ssl_alert.beam
  293. BIN assets/lib/ssl-4.1.6/ebin/ssl_app.beam
  294. BIN assets/lib/ssl-4.1.6/ebin/ssl_broker.beam
  295. BIN assets/lib/ssl-4.1.6/ebin/ssl_broker_sup.beam
  296. BIN assets/lib/ssl-4.1.6/ebin/ssl_certificate.beam
  297. BIN assets/lib/ssl-4.1.6/ebin/ssl_certificate_db.beam
  298. BIN assets/lib/ssl-4.1.6/ebin/ssl_cipher.beam
  299. BIN assets/lib/ssl-4.1.6/ebin/ssl_connection.beam
  300. BIN assets/lib/ssl-4.1.6/ebin/ssl_connection_sup.beam
Sorry, we could not display the entire diff because too many files (433) changed.
8 .classpath
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?><classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="gen"/>
+ <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
+ <classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
+ <classpathentry kind="lib" path="libs/phonegap-1.2.0.jar"/>
+ <classpathentry kind="output" path="bin/classes"/>
+<classpathentry kind="lib" path="libs/couchbase.jar"/><classpathentry kind="lib" path="libs/OtpErlang.jar"/></classpath>
17 .gitignore
@@ -0,0 +1,17 @@
+# built application files
+*.apk
+*.ap_
+
+# files for the dex VM
+*.dex
+
+# Java class files
+*.class
+
+# generated files
+/bin/
+/gen/
+
+# Local configuration file (sdk path, etc)
+local.properties
+build.properties
BIN .phonegap/android/phonegap-1.2.0.jar
Binary file not shown.
4,635 .phonegap/android/phonegap-1.2.0.js
4,635 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
1 .phonegap/android/readme.md
@@ -0,0 +1 @@
+ok...
5 .phonegap/config
@@ -0,0 +1,5 @@
+VERSION=1.2.0
+PROJECT_PATH=/Users/mschoch/Documents/workspace/Android-Couchbase-Callback/
+PACKAGE=com.couchbase.callback
+ACTIVITY=PhoneGapExample
+TARGET=8
3 .phonegap/readme.md
@@ -0,0 +1,3 @@
+this is local config for phonegap stuff to be eventually moved to
+config.xml ...we think. feedback to @davejohnson/@brianleroux
+appreciated here!
33 .project
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>Android-Couchbase-Callback</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.ApkBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>com.android.ide.eclipse.adt.AndroidNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
34 AndroidManifest.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android" android:windowSoftInputMode="adjustPan" package="com.couchbase.callback" android:versionName="1.1" android:versionCode="8">
+ <supports-screens android:largeScreens="true" android:normalScreens="true" android:smallScreens="true" android:resizeable="true" android:anyDensity="true"/>
+
+ <uses-permission android:name="android.permission.CAMERA"/>
+ <uses-permission android:name="android.permission.VIBRATE"/>
+ <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
+ <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
+ <uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS"/>
+ <uses-permission android:name="android.permission.INTERNET"/>
+ <uses-permission android:name="android.permission.RECEIVE_SMS"/>
+ <uses-permission android:name="android.permission.RECORD_AUDIO"/>
+ <uses-permission android:name="android.permission.RECORD_VIDEO"/>
+ <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
+ <uses-permission android:name="android.permission.READ_CONTACTS"/>
+ <uses-permission android:name="android.permission.WRITE_CONTACTS"/>
+ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
+ <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
+ <uses-permission android:name="android.permission.GET_ACCOUNTS"/>
+ <uses-permission android:name="android.permission.BROADCAST_STICKY"/>
+
+ <uses-feature android:name="android.hardware.camera"/>
+ <uses-feature android:name="android.hardware.camera.autofocus"/>
+
+ <application android:icon="@drawable/icon" android:label="@string/app_name" android:debuggable="true">
+ <activity android:name=".AndroidCouchbaseCallback" android:label="@string/app_name" android:configChanges="orientation|keyboardHidden">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN"/>
+ <category android:name="android.intent.category.LAUNCHER"/>
+ </intent-filter>
+ </activity>
+ <service android:name="com.couchbase.android.CouchbaseService" android:enabled="true" android:exported="false"/></application>
+
+ <uses-sdk android:minSdkVersion="8"/>
+</manifest>
BIN Couchbase.zip
Binary file not shown.
37 README.md
@@ -0,0 +1,37 @@
+## Android Couchbase Callback
+
+This application provides the fastest way to deploy a <a href="http://couchbase.org/">CouchApp</a> to an Android device using <a href="http://couchbase.org/">Couchbase Mobile</a> and <a href="http://incubator.apache.org/projects/callback.html">Apache Callback (formerly PhoneGap)</a>.
+
+## Getting Started
+
+1. Clone this repository
+2. Build this application, either using eclipse or command line tools
+
+ ant debug
+
+3. Install/Launch this application on your device/emulator
+
+ adb install bin/AndroidCouchbaseCallback-debug.apk
+ adb shell am start -n com.couchbase.callback/.AndroidCouchbaseCallback
+
+4. Couchbase Mobile is now running, you should see now see instructions on screen install your CouchApp.
+
+5. Forward the Couchbase Mobile from the device to your development machine (the Couchbase port is dynamic and is shown on the screen)
+
+ adb forward tcp:8984 tcp:<value displayed on your screen>
+
+6. From within your CouchApp project directory, run the following command to install your couchapp on the device.
+
+ couchapp push . http://localhost:8984/couchapp
+
+7. Compact your database
+
+ curl -X POST -H "Content-Type: application/json" http://localhost:8984/couchapp/_compact
+
+8. Copy the database off the device and into this Android application's assets directory:
+
+ adb pull /mnt/sdcard/Android/data/com.couchbase.callback/db/couchapp.couch assets
+
+9. Repackage your application with the database file included
+
+ ant debug
17 ant.properties
@@ -0,0 +1,17 @@
+# This file is used to override default values used by the Ant build system.
+#
+# This file must be checked in Version Control Systems, as it is
+# integral to the build system of your project.
+
+# This file is only used by the Ant script.
+
+# You can use this to override default values such as
+# 'source.dir' for the location of your java source folder and
+# 'out.dir' for the location of your output folder.
+
+# You can also use it define how the release builds are signed by declaring
+# the following properties:
+# 'key.store' for the location of your keystore and
+# 'key.alias' for the name of the key to use.
+# The password will be asked during the build when you use the 'release' target.
+
3 assets/install/couchdb/bin/couchjs_wrapper
@@ -0,0 +1,3 @@
+#!/system/bin/sh
+export LD_LIBRARY_PATH=%couch_installation_dir%/lib
+exec %couch_installation_dir%/couchdb/lib/couchdb/bin/couchjs $@
35 assets/install/couchdb/etc/couchdb/android.default.ini
@@ -0,0 +1,35 @@
+[couchdb]
+database_dir = %couch_data_dir%/db
+view_index_dir = %couch_data_dir%/db
+util_driver_dir = %couch_installation_dir%/
+uri_file = %couch_data_dir%/db/couch.uri
+file_compression = none
+
+[httpd]
+port = 0
+bind_address = 0.0.0.0
+
+[log]
+file = %couch_data_dir%/db/couch.log
+level = debug
+
+[access_log]
+file = %couch_data_dir%/db/couch_access.log
+
+[query_servers]
+javascript = %couch_installation_dir%/couchdb/bin/couchjs_wrapper %couch_installation_dir%/couchdb/share/couchdb/server/main.js
+coffeescript = %couch_installation_dir%/couchdb/bin/couchjs %couch_installation_dir%/couchdb/share/couchdb/server/main-coffee.js
+
+[daemons]
+spatial_manager={couch_spatial, start_link, []}
+
+[httpd_db_handlers]
+_spatial_cleanup = {couch_httpd_spatial, handle_spatial_cleanup_req}
+
+[httpd_design_handlers]
+_spatial = {couch_httpd_spatial, handle_spatial_req}
+_spatial/_list = {couch_httpd_spatial_list, handle_spatial_list_req}
+_spatial/_info = {couch_httpd_spatial, handle_design_info_req}
+_spatial/_compact = {couch_httpd_spatial, handle_compact_req}
+;deprecated API
+_spatiallist = {couch_httpd_spatial_list, handle_spatial_list_req_deprecated}
293 assets/install/couchdb/etc/couchdb/default.ini
@@ -0,0 +1,293 @@
+; etc/couchdb/default.ini.tpl. Generated from default.ini.tpl.in by configure.
+
+; Upgrading CouchDB will overwrite this file.
+
+[couchdb]
+database_dir = /data/data/%app_name%/couchdb/var/lib/couchdb
+view_index_dir = /data/data/%app_name%/couchdb/var/lib/couchdb
+util_driver_dir = /data/data/%app_name%/couchdb/lib/couchdb/erlang/lib/couch-1.2.0a-7b47329-git/priv/lib
+max_document_size = 4294967296 ; 4 GB
+os_process_timeout = 30000 ; 5 seconds. for view and external servers.
+max_dbs_open = 100
+delayed_commits = true ; set this to false to ensure an fsync before 201 Created is returned
+uri_file = /data/data/%app_name%/couchdb/var/run/couchdb/couch.uri
+; Method used to compress everything that is appended to database and view index files, except
+; for attachments (see the attachments section). Available methods are:
+;
+; none - no compression
+; snappy - use google snappy, a very fast compressor/decompressor
+; deflate_[N] - use zlib's deflate, N is the compression level which ranges from 1 (fastest,
+; lowest compression ratio) to 9 (slowest, highest compression ratio)
+file_compression = snappy
+; Maximum number of distinct view update/building processes at any point in time.
+max_parallel_indexers = 4
+
+[database_compaction]
+; larger buffer sizes can originate smaller files
+doc_buffer_size = 524288 ; value in bytes
+checkpoint_after = 5242880 ; checkpoint after every N bytes were written
+
+[view_compaction]
+; larger buffer sizes can originate smaller files
+keyvalue_buffer_size = 2097152 ; value in bytes
+
+[httpd]
+port = 5984
+bind_address = 127.0.0.1
+authentication_handlers = {couch_httpd_oauth, oauth_authentication_handler}, {couch_httpd_auth, cookie_authentication_handler}, {couch_httpd_auth, default_authentication_handler}
+default_handler = {couch_httpd_db, handle_request}
+secure_rewrites = true
+vhost_global_handlers = _utils, _uuids, _session, _oauth, _users
+allow_jsonp = false
+db_frontend = couch_db_frontend
+; Options for the MochiWeb HTTP server.
+;server_options = [{backlog, 128}, {acceptor_pool_size, 16}]
+; For more socket options, consult Erlang's module 'inet' man page.
+;socket_options = [{recbuf, 262144}, {sndbuf, 262144}, {nodelay, true}]
+
+[ssl]
+port = 6984
+
+[log]
+file = /data/data/%app_name%/couchdb/var/log/couchdb/couch.log
+level = info
+include_sasl = true
+
+; Enable apache httpd-style access logging.
+; The default format is the "extended" or "combined" format that
+; includes:
+; host ident authuser date request status bytes referer(sic) user-agent
+;
+; The alternative format is "common" that includes:
+; host ident authuser date request status bytes
+;
+; If a value is not defined, the log entry will be " - " for that value.
+
+[access_log]
+enable = false
+format = extended
+file = /data/data/%app_name%/couchdb/var/log/couchdb/couch_access.log
+
+[couch_httpd_auth]
+authentication_db = _users
+authentication_redirect = /_utils/session.html
+require_valid_user = false
+timeout = 600 ; number of seconds before automatic logout
+auth_cache_size = 50 ; size is number of cache entries
+
+[query_servers]
+javascript = /data/data/%app_name%/couchdb/bin/couchjs /data/data/%app_name%/couchdb/share/couchdb/server/main.js
+coffeescript = /data/data/%app_name%/couchdb/bin/couchjs /data/data/%app_name%/couchdb/share/couchdb/server/main-coffee.js
+
+
+; Changing reduce_limit to false will disable reduce_limit.
+; If you think you're hitting reduce_limit with a "good" reduce function,
+; please let us know on the mailing list so we can fine tune the heuristic.
+[query_server_config]
+reduce_limit = true
+os_process_limit = 50
+
+[daemons]
+view_manager={couch_view, start_link, []}
+external_manager={couch_external_manager, start_link, []}
+query_servers={couch_query_servers, start_link, []}
+vhosts={couch_httpd_vhost, start_link, []}
+httpd={couch_httpd, start_link, []}
+;stats_aggregator={couch_stats_aggregator, start, []}
+;stats_collector={couch_stats_collector, start, []}
+uuids={couch_uuids, start, []}
+auth_cache={couch_auth_cache, start_link, []}
+replication_manager={couch_replication_manager, start_link, []}
+os_daemons={couch_os_daemons, start_link, []}
+compaction_daemon={couch_compaction_daemon, start_link, []}
+
+[httpd_global_handlers]
+/ = {couch_httpd_misc_handlers, handle_welcome_req, <<"Welcome">>}
+favicon.ico = {couch_httpd_misc_handlers, handle_favicon_req, "/data/data/%app_name%/couchdb/share/couchdb/www"}
+
+_utils = {couch_httpd_misc_handlers, handle_utils_dir_req, "/data/data/%app_name%/couchdb/share/couchdb/www"}
+_all_dbs = {couch_httpd_misc_handlers, handle_all_dbs_req}
+_active_tasks = {couch_httpd_misc_handlers, handle_task_status_req}
+_config = {couch_httpd_misc_handlers, handle_config_req}
+_replicate = {couch_httpd_replicator, handle_req}
+_uuids = {couch_httpd_misc_handlers, handle_uuids_req}
+_restart = {couch_httpd_misc_handlers, handle_restart_req}
+;_stats = {couch_httpd_stats_handlers, handle_stats_req}
+_log = {couch_httpd_misc_handlers, handle_log_req}
+_session = {couch_httpd_auth, handle_session_req}
+_oauth = {couch_httpd_oauth, handle_oauth_req}
+_generate_load = {couch_internal_load_gen, handle_req}
+_view_merge = {couch_httpd_view_merger, handle_req}
+
+[httpd_db_handlers]
+_view_cleanup = {couch_httpd_db, handle_view_cleanup_req}
+_compact = {couch_httpd_db, handle_compact_req}
+_design = {couch_httpd_db, handle_design_req}
+_temp_view = {couch_httpd_view, handle_temp_view_req}
+_changes = {couch_httpd_db, handle_changes_req}
+
+; The external module takes an optional argument allowing you to narrow it to a
+; single script. Otherwise the script name is inferred from the first path section
+; after _external's own path.
+; _mypath = {couch_httpd_external, handle_external_req, <<"mykey">>}
+; _external = {couch_httpd_external, handle_external_req}
+
+[httpd_design_handlers]
+_view = {couch_httpd_view, handle_view_req}
+_show = {couch_httpd_show, handle_doc_show_req}
+_list = {couch_httpd_show, handle_view_list_req}
+_info = {couch_httpd_db, handle_design_info_req}
+_rewrite = {couch_httpd_rewrite, handle_rewrite_req}
+_update = {couch_httpd_show, handle_doc_update_req}
+
+; enable external as an httpd handler, then link it with commands here.
+; note, this api is still under consideration.
+; [external]
+; mykey = /path/to/mycommand
+
+; Here you can setup commands for CouchDB to manage
+; while it is alive. It will attempt to keep each command
+; alive if it exits.
+; [os_daemons]
+; some_daemon_name = /path/to/script -with args
+
+
+[uuids]
+; Known algorithms:
+; random - 128 bits of random awesome
+; All awesome, all the time.
+; sequential - monotonically increasing ids with random increments
+; First 26 hex characters are random. Last 6 increment in
+; random amounts until an overflow occurs. On overflow, the
+; random prefix is regenerated and the process starts over.
+; utc_random - Time since Jan 1, 1970 UTC with microseconds
+; First 14 characters are the time in hex. Last 18 are random.
+algorithm = sequential
+
+[stats]
+; rate is in milliseconds
+rate = 1000
+; sample intervals are in seconds
+samples = [0, 60, 300, 900]
+
+[attachments]
+compression_level = 8 ; from 1 (lowest, fastest) to 9 (highest, slowest), 0 to disable compression
+compressible_types = text/*, application/javascript, application/json, application/xml
+
+[replicator]
+db = _replicator
+; Maximum replicaton retry count can be a non-negative integer or "infinity".
+max_replication_retry_count = 10
+; More worker processes can give higher network throughput but can also
+; imply more disk and network IO.
+worker_processes = 4
+; With lower batch sizes checkpoints are done more frequently. Lower batch sizes
+; also reduce the total amount of used RAM memory.
+worker_batch_size = 500
+; Maximum number of HTTP connections per replication.
+http_connections = 20
+; HTTP connection timeout per replication.
+; Even for very fast/reliable networks it might need to be increased if a remote
+; database is too busy.
+connection_timeout = 30000
+; Some socket options that might boost performance in some scenarios:
+; {nodelay, boolean()}
+; {sndbuf, integer()}
+; {recbuf, integer()}
+; {priority, integer()}
+; See the `inet` Erlang module's man page for the full list of options.
+socket_options = [{keepalive, true}, {nodelay, false}]
+; set to true to validate peer certificates
+verify_ssl_certificates = false
+; file containing a list of peer trusted certificates (PEM format)
+; ssl_trusted_certificates_file = /etc/ssl/certs/ca-certificates.crt
+; maximum peer certificate depth (must be set even if certificate validation is off)
+ssl_certificate_max_depth = 3
+
+[compaction_daemon]
+; The delay, in seconds, between each check for which database and view indexes
+; need to be compacted.
+check_interval = 60
+; If a database or view index file is smaller then this value (in bytes),
+; compaction will not happen. Very small files always have a very high
+; fragmentation therefore it's not worth to compact them.
+min_file_size = 131072
+
+[compactions]
+; List of compaction rules for the compaction daemon.
+; The daemon compacts databases and their respective view groups when all the
+; condition parameters are satisfied. Configuration can be per database or
+; global, and it has the following format:
+;
+; database_name = [ {ParamName, ParamValue}, {ParamName, ParamValue}, ... ]
+; _default = [ {ParamName, ParamValue}, {ParamName, ParamValue}, ... ]
+;
+; Possible parameters:
+;
+; * db_fragmentation - If the ratio (as an integer percentage), of the amount
+; of old data (and its supporting metadata) over the database
+; file size is equal to or greater then this value, this
+; database compaction condition is satisfied.
+; This value is computed as:
+;
+; (file_size - data_size) / file_size * 100
+;
+; The data_size and file_size values can be obtained when
+; querying a database's information URI (GET /dbname/).
+;
+; * view_fragmentation - If the ratio (as an integer percentage), of the amount
+; of old data (and its supporting metadata) over the view
+; index (view group) file size is equal to or greater then
+; this value, then this view index compaction condition is
+; satisfied. This value is computed as:
+;
+; (file_size - data_size) / file_size * 100
+;
+; The data_size and file_size values can be obtained when
+; querying a view group's information URI
+; (GET /dbname/_design/groupname/_info).
+;
+; * from _and_ to - The period for which a database (and its view groups) compaction
+; is allowed. The value for these parameters must obey the format:
+;
+; HH:MM - HH:MM (HH in [0..23], MM in [0..59])
+;
+; * strict_window - If a compaction is still running after the end of the allowed
+; period, it will be canceled if this parameter is set to 'true'.
+; It defaults to 'false' and it's meaningful only if the *period*
+; parameter is also specified.
+;
+; * parallel_view_compaction - If set to 'true', the database and its views are
+; compacted in parallel. This is only useful on
+; certain setups, like for example when the database
+; and view index directories point to different
+; disks. It defaults to 'false'.
+;
+; Before a compaction is triggered, an estimation of how much free disk space is
+; needed is computed. This estimation corresponds to 2 times the data size of
+; the database or view index. When there's not enough free disk space to compact
+; a particular database or view index, a warning message is logged.
+;
+; Examples:
+;
+; 1) [{db_fragmentation, "70%"}, {view_fragmentation, "60%"}]
+; The `foo` database is compacted if its fragmentation is 70% or more.
+; Any view index of this database is compacted only if its fragmentation
+; is 60% or more.
+;
+; 2) [{db_fragmentation, "70%"}, {view_fragmentation, "60%"}, {from, "00:00"}, {to, "04:00"}]
+; Similar to the preceding example but a compaction (database or view index)
+; is only triggered if the current time is between midnight and 4 AM.
+;
+; 3) [{db_fragmentation, "70%"}, {view_fragmentation, "60%"}, {from, "00:00"}, {to, "04:00"}, {strict_window, true}]
+; Similar to the preceding example - a compaction (database or view index)
+; is only triggered if the current time is between midnight and 4 AM. If at
+; 4 AM the database or one of its views is still compacting, the compaction
+; process will be canceled.
+;
+; 4) [{db_fragmentation, "70%"}, {view_fragmentation, "60%"}, {from, "00:00"}, {to, "04:00"}, {strict_window, true}, {parallel_view_compaction, true}]
+; Similar to the preceding example, but a database and its views can be
+; compacted in parallel.
+;
+;_default = [{db_fragmentation, "70%"}, {view_fragmentation, "60%"}, {from, "23:00"}, {to, "04:00"}]
+
74 assets/install/couchdb/etc/couchdb/local.ini
@@ -0,0 +1,74 @@
+; CouchDB Configuration Settings
+
+; Custom settings should be made in this file. They will override settings
+; in default.ini, but unlike changes made to default.ini, this file won't be
+; overwritten on server upgrade.
+
+[couchdb]
+;max_document_size = 4294967296 ; bytes
+
+[httpd]
+;port = 5984
+;bind_address = 127.0.0.1
+; Options for the MochiWeb HTTP server.
+;server_options = [{backlog, 128}, {acceptor_pool_size, 16}]
+; For more socket options, consult Erlang's module 'inet' man page.
+;socket_options = [{recbuf, 262144}, {sndbuf, 262144}, {nodelay, true}]
+
+; Uncomment next line to trigger basic-auth popup on unauthorized requests.
+;WWW-Authenticate = Basic realm="administrator"
+
+; Uncomment next line to set the configuration modification whitelist. Only
+; whitelisted values may be changed via the /_config URLs. To allow the admin
+; to change this value over HTTP, remember to include {httpd,config_whitelist}
+; itself. Excluding it from the list would require editing this file to update
+; the whitelist.
+;config_whitelist = [{httpd,config_whitelist}, {log,level}, {etc,etc}]
+
+[httpd_global_handlers]
+;_google = {couch_httpd_proxy, handle_proxy_req, <<"http://www.google.com">>}
+
+[couch_httpd_auth]
+; If you set this to true, you should also uncomment the WWW-Authenticate line
+; above. If you don't configure a WWW-Authenticate header, CouchDB will send
+; Basic realm="server" in order to prevent you getting logged out.
+; require_valid_user = false
+
+[log]
+;level = debug
+
+[os_daemons]
+; For any commands listed here, CouchDB will attempt to ensure that
+; the process remains alive while CouchDB runs as well as shut them
+; down when CouchDB exits.
+;foo = /path/to/command -with args
+
+[daemons]
+; enable SSL support by uncommenting the following line and supply the PEM's below.
+; the default ssl port CouchDB listens on is 6984
+; httpsd = {couch_httpd, start_link, [https]}
+
+[ssl]
+;cert_file = /full/path/to/server_cert.pem
+;key_file = /full/path/to/server_key.pem
+
+; To enable Virtual Hosts in CouchDB, add a vhost = path directive. All requests to
+; the Virual Host will be redirected to the path. In the example below all requests
+; to http://example.com/ are redirected to /database.
+; If you run CouchDB on a specific port, include the port number in the vhost:
+; example.com:5984 = /database
+
+[vhosts]
+;example.com = /database/
+
+[update_notification]
+;unique notifier name=/full/path/to/exe -with "cmd line arg"
+
+; To create an admin account uncomment the '[admins]' section below and add a
+; line in the format 'username = password'. When you next start CouchDB, it
+; will change the password to a hash (so that your passwords don't linger
+; around in plain-text files). You can add more admin accounts with more
+; 'username = password' lines. Don't forget to restart CouchDB after
+; changing this.
+[admins]
+;admin = mysecretpassword
0 assets/install/couchdb/etc/couchdb/overrides.ini
No changes.
7 assets/install/couchdb/etc/default/couchdb
@@ -0,0 +1,7 @@
+# Sourced by init script for configuration.
+
+COUCHDB_USER=couchdb
+COUCHDB_STDOUT_FILE=/dev/null
+COUCHDB_STDERR_FILE=/dev/null
+COUCHDB_RESPAWN_TIMEOUT=5
+COUCHDB_OPTIONS=
BIN assets/install/couchdb/lib/couchdb/bin/couchjs
Binary file not shown.
1,549 assets/install/couchdb/share/couchdb/server/main-coffee.js
1,549 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
1,542 assets/install/couchdb/share/couchdb/server/main.js
@@ -0,0 +1,1542 @@
+// DO NOT EDIT THIS FILE BY HAND
+
+/*
+ http://www.JSON.org/json2.js
+ 2010-03-20
+
+ Public Domain.
+
+ NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
+
+ See http://www.JSON.org/js.html
+
+
+ This code should be minified before deployment.
+ See http://javascript.crockford.com/jsmin.html
+
+ USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO
+ NOT CONTROL.
+
+
+ This file creates a global JSON object containing two methods: stringify
+ and parse.
+
+ JSON.stringify(value, replacer, space)
+ value any JavaScript value, usually an object or array.
+
+ replacer an optional parameter that determines how object
+ values are stringified for objects. It can be a
+ function or an array of strings.
+
+ space an optional parameter that specifies the indentation
+ of nested structures. If it is omitted, the text will
+ be packed without extra whitespace. If it is a number,
+ it will specify the number of spaces to indent at each
+ level. If it is a string (such as '\t' or '&nbsp;'),
+ it contains the characters used to indent at each level.
+
+ This method produces a JSON text from a JavaScript value.
+
+ When an object value is found, if the object contains a toJSON
+ method, its toJSON method will be called and the result will be
+ stringified. A toJSON method does not serialize: it returns the
+ value represented by the name/value pair that should be serialized,
+ or undefined if nothing should be serialized. The toJSON method
+ will be passed the key associated with the value, and this will be
+ bound to the value
+
+ For example, this would serialize Dates as ISO strings.
+
+ Date.prototype.toJSON = function (key) {
+ function f(n) {
+ // Format integers to have at least two digits.
+ return n < 10 ? '0' + n : n;
+ }
+
+ return this.getUTCFullYear() + '-' +
+ f(this.getUTCMonth() + 1) + '-' +
+ f(this.getUTCDate()) + 'T' +
+ f(this.getUTCHours()) + ':' +
+ f(this.getUTCMinutes()) + ':' +
+ f(this.getUTCSeconds()) + 'Z';
+ };
+
+ You can provide an optional replacer method. It will be passed the
+ key and value of each member, with this bound to the containing
+ object. The value that is returned from your method will be
+ serialized. If your method returns undefined, then the member will
+ be excluded from the serialization.
+
+ If the replacer parameter is an array of strings, then it will be
+ used to select the members to be serialized. It filters the results
+ such that only members with keys listed in the replacer array are
+ stringified.
+
+ Values that do not have JSON representations, such as undefined or
+ functions, will not be serialized. Such values in objects will be
+ dropped; in arrays they will be replaced with null. You can use
+ a replacer function to replace those with JSON values.
+ JSON.stringify(undefined) returns undefined.
+
+ The optional space parameter produces a stringification of the
+ value that is filled with line breaks and indentation to make it
+ easier to read.
+
+ If the space parameter is a non-empty string, then that string will
+ be used for indentation. If the space parameter is a number, then
+ the indentation will be that many spaces.
+
+ Example:
+
+ text = JSON.stringify(['e', {pluribus: 'unum'}]);
+ // text is '["e",{"pluribus":"unum"}]'
+
+
+ text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\t');
+ // text is '[\n\t"e",\n\t{\n\t\t"pluribus": "unum"\n\t}\n]'
+
+ text = JSON.stringify([new Date()], function (key, value) {
+ return this[key] instanceof Date ?
+ 'Date(' + this[key] + ')' : value;
+ });
+ // text is '["Date(---current time---)"]'
+
+
+ JSON.parse(text, reviver)
+ This method parses a JSON text to produce an object or array.
+ It can throw a SyntaxError exception.
+
+ The optional reviver parameter is a function that can filter and
+ transform the results. It receives each of the keys and values,
+ and its return value is used instead of the original value.
+ If it returns what it received, then the structure is not modified.
+ If it returns undefined then the member is deleted.
+
+ Example:
+
+ // Parse the text. Values that look like ISO date strings will
+ // be converted to Date objects.
+
+ myData = JSON.parse(text, function (key, value) {
+ var a;
+ if (typeof value === 'string') {
+ a =
+/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value);
+ if (a) {
+ return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4],
+ +a[5], +a[6]));
+ }
+ }
+ return value;
+ });
+
+ myData = JSON.parse('["Date(09/09/2001)"]', function (key, value) {
+ var d;
+ if (typeof value === 'string' &&
+ value.slice(0, 5) === 'Date(' &&
+ value.slice(-1) === ')') {
+ d = new Date(value.slice(5, -1));
+ if (d) {
+ return d;
+ }
+ }
+ return value;
+ });
+
+
+ This is a reference implementation. You are free to copy, modify, or
+ redistribute.
+*/
+
+/*jslint evil: true, strict: false */
+
+/*members "", "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply,
+ call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,
+ getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join,
+ lastIndex, length, parse, prototype, push, replace, slice, stringify,
+ test, toJSON, toString, valueOf
+*/
+
+
+// Create a JSON object only if one does not already exist. We create the
+// methods in a closure to avoid creating global variables.
+
+if (!this.JSON) {
+ this.JSON = {};
+}
+
+(function () {
+
+ function f(n) {
+ // Format integers to have at least two digits.
+ return n < 10 ? '0' + n : n;
+ }
+
+ if (typeof Date.prototype.toJSON !== 'function') {
+
+ Date.prototype.toJSON = function (key) {
+
+ return isFinite(this.valueOf()) ?
+ this.getUTCFullYear() + '-' +
+ f(this.getUTCMonth() + 1) + '-' +
+ f(this.getUTCDate()) + 'T' +
+ f(this.getUTCHours()) + ':' +
+ f(this.getUTCMinutes()) + ':' +
+ f(this.getUTCSeconds()) + 'Z' : null;
+ };
+
+ String.prototype.toJSON =
+ Number.prototype.toJSON =
+ Boolean.prototype.toJSON = function (key) {
+ return this.valueOf();
+ };
+ }
+
+ var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
+ escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
+ gap,
+ indent,
+ meta = { // table of character substitutions
+ '\b': '\\b',
+ '\t': '\\t',
+ '\n': '\\n',
+ '\f': '\\f',
+ '\r': '\\r',
+ '"' : '\\"',
+ '\\': '\\\\'
+ },
+ rep;
+
+
+ function quote(string) {
+
+// If the string contains no control characters, no quote characters, and no
+// backslash characters, then we can safely slap some quotes around it.
+// Otherwise we must also replace the offending characters with safe escape
+// sequences.
+
+ escapable.lastIndex = 0;
+ return escapable.test(string) ?
+ '"' + string.replace(escapable, function (a) {
+ var c = meta[a];
+ return typeof c === 'string' ? c :
+ '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
+ }) + '"' :
+ '"' + string + '"';
+ }
+
+
+ function str(key, holder) {
+
+// Produce a string from holder[key].
+
+ var i, // The loop counter.
+ k, // The member key.
+ v, // The member value.
+ length,
+ mind = gap,
+ partial,
+ value = holder[key];
+
+// If the value has a toJSON method, call it to obtain a replacement value.
+
+ if (value && typeof value === 'object' &&
+ typeof value.toJSON === 'function') {
+ value = value.toJSON(key);
+ }
+
+// If we were called with a replacer function, then call the replacer to
+// obtain a replacement value.
+
+ if (typeof rep === 'function') {
+ value = rep.call(holder, key, value);
+ }
+
+// What happens next depends on the value's type.
+
+ switch (typeof value) {
+ case 'string':
+ return quote(value);
+
+ case 'number':
+
+// JSON numbers must be finite. Encode non-finite numbers as null.
+
+ return isFinite(value) ? String(value) : 'null';
+
+ case 'boolean':
+ case 'null':
+
+// If the value is a boolean or null, convert it to a string. Note:
+// typeof null does not produce 'null'. The case is included here in
+// the remote chance that this gets fixed someday.
+
+ return String(value);
+
+// If the type is 'object', we might be dealing with an object or an array or
+// null.
+
+ case 'object':
+
+// Due to a specification blunder in ECMAScript, typeof null is 'object',
+// so watch out for that case.
+
+ if (!value) {
+ return 'null';
+ }
+
+// Make an array to hold the partial results of stringifying this object value.
+
+ gap += indent;
+ partial = [];
+
+// Is the value an array?
+
+ if (Object.prototype.toString.apply(value) === '[object Array]') {
+
+// The value is an array. Stringify every element. Use null as a placeholder
+// for non-JSON values.
+
+ length = value.length;
+ for (i = 0; i < length; i += 1) {
+ partial[i] = str(i, value) || 'null';
+ }
+
+// Join all of the elements together, separated with commas, and wrap them in
+// brackets.
+
+ v = partial.length === 0 ? '[]' :
+ gap ? '[\n' + gap +
+ partial.join(',\n' + gap) + '\n' +
+ mind + ']' :
+ '[' + partial.join(',') + ']';
+ gap = mind;
+ return v;
+ }
+
+// If the replacer is an array, use it to select the members to be stringified.
+
+ if (rep && typeof rep === 'object') {
+ length = rep.length;
+ for (i = 0; i < length; i += 1) {
+ k = rep[i];
+ if (typeof k === 'string') {
+ v = str(k, value);
+ if (v) {
+ partial.push(quote(k) + (gap ? ': ' : ':') + v);
+ }
+ }
+ }
+ } else {
+
+// Otherwise, iterate through all of the keys in the object.
+
+ for (k in value) {
+ if (Object.hasOwnProperty.call(value, k)) {
+ v = str(k, value);
+ if (v) {
+ partial.push(quote(k) + (gap ? ': ' : ':') + v);
+ }
+ }
+ }
+ }
+
+// Join all of the member texts together, separated with commas,
+// and wrap them in braces.
+
+ v = partial.length === 0 ? '{}' :
+ gap ? '{\n' + gap + partial.join(',\n' + gap) + '\n' +
+ mind + '}' : '{' + partial.join(',') + '}';
+ gap = mind;
+ return v;
+ }
+ }
+
+// If the JSON object does not yet have a stringify method, give it one.
+
+ if (typeof JSON.stringify !== 'function') {
+ JSON.stringify = function (value, replacer, space) {
+
+// The stringify method takes a value and an optional replacer, and an optional
+// space parameter, and returns a JSON text. The replacer can be a function
+// that can replace values, or an array of strings that will select the keys.
+// A default replacer method can be provided. Use of the space parameter can
+// produce text that is more easily readable.
+
+ var i;
+ gap = '';
+ indent = '';
+
+// If the space parameter is a number, make an indent string containing that
+// many spaces.
+
+ if (typeof space === 'number') {
+ for (i = 0; i < space; i += 1) {
+ indent += ' ';
+ }
+
+// If the space parameter is a string, it will be used as the indent string.
+
+ } else if (typeof space === 'string') {
+ indent = space;
+ }
+
+// If there is a replacer, it must be a function or an array.
+// Otherwise, throw an error.
+
+ rep = replacer;
+ if (replacer && typeof replacer !== 'function' &&
+ (typeof replacer !== 'object' ||
+ typeof replacer.length !== 'number')) {
+ throw new Error('JSON.stringify');
+ }
+
+// Make a fake root object containing our value under the key of ''.
+// Return the result of stringifying the value.
+
+ return str('', {'': value});
+ };
+ }
+
+
+// If the JSON object does not yet have a parse method, give it one.
+
+ if (typeof JSON.parse !== 'function') {
+ JSON.parse = function (text, reviver) {
+
+// The parse method takes a text and an optional reviver function, and returns
+// a JavaScript value if the text is a valid JSON text.
+
+ var j;
+
+ function walk(holder, key) {
+
+// The walk method is used to recursively walk the resulting structure so
+// that modifications can be made.
+
+ var k, v, value = holder[key];
+ if (value && typeof value === 'object') {
+ for (k in value) {
+ if (Object.hasOwnProperty.call(value, k)) {
+ v = walk(value, k);
+ if (v !== undefined) {
+ value[k] = v;
+ } else {
+ delete value[k];
+ }
+ }
+ }
+ }
+ return reviver.call(holder, key, value);
+ }
+
+
+// Parsing happens in four stages. In the first stage, we replace certain
+// Unicode characters with escape sequences. JavaScript handles many characters
+// incorrectly, either silently deleting them, or treating them as line endings.
+
+ text = String(text);
+ cx.lastIndex = 0;
+ if (cx.test(text)) {
+ text = text.replace(cx, function (a) {
+ return '\\u' +
+ ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
+ });
+ }
+
+// In the second stage, we run the text against regular expressions that look
+// for non-JSON patterns. We are especially concerned with '()' and 'new'
+// because they can cause invocation, and '=' because it can cause mutation.
+// But just to be safe, we want to reject all unexpected forms.
+
+// We split the second stage into 4 regexp operations in order to work around
+// crippling inefficiencies in IE's and Safari's regexp engines. First we
+// replace the JSON backslash pairs with '@' (a non-JSON character). Second, we
+// replace all simple value tokens with ']' characters. Third, we delete all
+// open brackets that follow a colon or comma or that begin the text. Finally,
+// we look to see that the remaining characters are only whitespace or ']' or
+// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.
+
+ if (/^[\],:{}\s]*$/.
+test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@').
+replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']').
+replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
+
+// In the third stage we use the eval function to compile the text into a
+// JavaScript structure. The '{' operator is subject to a syntactic ambiguity
+// in JavaScript: it can begin a block or an object literal. We wrap the text
+// in parens to eliminate the ambiguity.
+
+ j = eval('(' + text + ')');
+
+// In the optional fourth stage, we recursively walk the new structure, passing
+// each name/value pair to a reviver function for possible transformation.
+
+ return typeof reviver === 'function' ?
+ walk({'': j}, '') : j;
+ }
+
+// If the text is not JSON parseable, then a SyntaxError is thrown.
+
+ throw new SyntaxError('JSON.parse');
+ };
+ }
+}());
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy of
+// the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+
+var Filter = (function() {
+
+ var view_emit = false;
+
+ return {
+ emit : function(key, value) {
+ view_emit = true;
+ },
+ filter : function(fun, ddoc, args) {
+ var results = [];
+ var docs = args[0];
+ var req = args[1];
+ for (var i=0; i < docs.length; i++) {
+ results.push((fun.apply(ddoc, [docs[i], req]) && true) || false);
+ };
+ respond([true, results]);
+ },
+ filter_view : function(fun, ddoc, args) {
+ // recompile
+ var source = fun.toSource();
+ fun = evalcx(source, filter_sandbox);
+
+ var results = [];
+ var docs = args[0];
+ for (var i=0; i < docs.length; i++) {
+ view_emit = false;
+ fun(docs[i]);
+ results.push((view_emit && true) || false);
+ };
+ respond([true, results]);
+ }
+ }
+})();
+// mimeparse.js
+//
+// This module provides basic functions for handling mime-types. It can
+// handle matching mime-types against a list of media-ranges. See section
+// 14.1 of the HTTP specification [RFC 2616] for a complete explanation.
+//
+// http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.1
+//
+// A port to JavaScript of Joe Gregorio's MIME-Type Parser:
+//
+// http://code.google.com/p/mimeparse/
+//
+// Ported by J. Chris Anderson <jchris@apache.org>, targeting the Spidermonkey runtime.
+//
+// To run the tests, open mimeparse-js-test.html in a browser.
+// Ported from version 0.1.2
+// Comments are mostly excerpted from the original.
+
+var Mimeparse = (function() {
+ // private helpers
+ function strip(string) {
+ return string.replace(/^\s+/, '').replace(/\s+$/, '');
+ };
+
+ function parseRanges(ranges) {
+ var parsedRanges = [], rangeParts = ranges.split(",");
+ for (var i=0; i < rangeParts.length; i++) {
+ parsedRanges.push(publicMethods.parseMediaRange(rangeParts[i]));
+ };
+ return parsedRanges;
+ };
+
+ var publicMethods = {
+ // Carves up a mime-type and returns an Array of the
+ // [type, subtype, params] where "params" is a Hash of all
+ // the parameters for the media range.
+ //
+ // For example, the media range "application/xhtml;q=0.5" would
+ // get parsed into:
+ //
+ // ["application", "xhtml", { "q" : "0.5" }]
+ parseMimeType : function(mimeType) {
+ var fullType, typeParts, params = {}, parts = mimeType.split(';');
+ for (var i=0; i < parts.length; i++) {
+ var p = parts[i].split('=');
+ if (p.length == 2) {
+ params[strip(p[0])] = strip(p[1]);
+ }
+ };
+ fullType = parts[0].replace(/^\s+/, '').replace(/\s+$/, '');
+ if (fullType == '*') fullType = '*/*';
+ typeParts = fullType.split('/');
+ return [typeParts[0], typeParts[1], params];
+ },
+
+ // Carves up a media range and returns an Array of the
+ // [type, subtype, params] where "params" is a Object with
+ // all the parameters for the media range.
+ //
+ // For example, the media range "application/*;q=0.5" would
+ // get parsed into:
+ //
+ // ["application", "*", { "q" : "0.5" }]
+ //
+ // In addition this function also guarantees that there
+ // is a value for "q" in the params dictionary, filling it
+ // in with a proper default if necessary.
+ parseMediaRange : function(range) {
+ var q, parsedType = this.parseMimeType(range);
+ if (!parsedType[2]['q']) {
+ parsedType[2]['q'] = '1';
+ } else {
+ q = parseFloat(parsedType[2]['q']);
+ if (isNaN(q)) {
+ parsedType[2]['q'] = '1';
+ } else if (q > 1 || q < 0) {
+ parsedType[2]['q'] = '1';
+ }
+ }
+ return parsedType;
+ },
+
+ // Find the best match for a given mime-type against
+ // a list of media_ranges that have already been
+ // parsed by parseMediaRange(). Returns an array of
+ // the fitness value and the value of the 'q' quality
+ // parameter of the best match, or (-1, 0) if no match
+ // was found. Just as for qualityParsed(), 'parsed_ranges'
+ // must be a list of parsed media ranges.
+ fitnessAndQualityParsed : function(mimeType, parsedRanges) {
+ var bestFitness = -1, bestFitQ = 0, target = this.parseMediaRange(mimeType);
+ var targetType = target[0], targetSubtype = target[1], targetParams = target[2];
+
+ for (var i=0; i < parsedRanges.length; i++) {
+ var parsed = parsedRanges[i];
+ var type = parsed[0], subtype = parsed[1], params = parsed[2];
+ if ((type == targetType || type == "*" || targetType == "*") &&
+ (subtype == targetSubtype || subtype == "*" || targetSubtype == "*")) {
+ var matchCount = 0;
+ for (param in targetParams) {
+ if (param != 'q' && params[param] && params[param] == targetParams[param]) {
+ matchCount += 1;
+ }
+ }
+
+ var fitness = (type == targetType) ? 100 : 0;
+ fitness += (subtype == targetSubtype) ? 10 : 0;
+ fitness += matchCount;
+
+ if (fitness > bestFitness) {
+ bestFitness = fitness;
+ bestFitQ = params["q"];
+ }
+ }
+ };
+ return [bestFitness, parseFloat(bestFitQ)];
+ },
+
+ // Find the best match for a given mime-type against
+ // a list of media_ranges that have already been
+ // parsed by parseMediaRange(). Returns the
+ // 'q' quality parameter of the best match, 0 if no
+ // match was found. This function bahaves the same as quality()
+ // except that 'parsedRanges' must be a list of
+ // parsed media ranges.
+ qualityParsed : function(mimeType, parsedRanges) {
+ return this.fitnessAndQualityParsed(mimeType, parsedRanges)[1];
+ },
+
+ // Returns the quality 'q' of a mime-type when compared
+ // against the media-ranges in ranges. For example:
+ //
+ // >>> Mimeparse.quality('text/html','text/*;q=0.3, text/html;q=0.7, text/html;level=1, text/html;level=2;q=0.4, */*;q=0.5')
+ // 0.7
+ quality : function(mimeType, ranges) {
+ return this.qualityParsed(mimeType, parseRanges(ranges));
+ },
+
+ // Takes a list of supported mime-types and finds the best
+ // match for all the media-ranges listed in header. The value of
+ // header must be a string that conforms to the format of the
+ // HTTP Accept: header. The value of 'supported' is a list of
+ // mime-types.
+ //
+ // >>> bestMatch(['application/xbel+xml', 'text/xml'], 'text/*;q=0.5,*/*; q=0.1')
+ // 'text/xml'
+ bestMatch : function(supported, header) {
+ var parsedHeader = parseRanges(header);
+ var weighted = [];
+ for (var i=0; i < supported.length; i++) {
+ weighted.push([publicMethods.fitnessAndQualityParsed(supported[i], parsedHeader), i, supported[i]]);
+ };
+ weighted.sort();
+ return weighted[weighted.length-1][0][1] ? weighted[weighted.length-1][2] : '';
+ }
+ };
+ return publicMethods;
+})();
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy of
+// the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+
+
+var Mime = (function() {
+ // registerType(name, mime-type, mime-type, ...)
+ //
+ // Available in query server sandbox. TODO: The list is cleared on reset.
+ // This registers a particular name with the set of mimetypes it can handle.
+ // Whoever registers last wins.
+ //
+ // Example:
+ // registerType("html", "text/html; charset=utf-8");
+
+ var mimesByKey = {};
+ var keysByMime = {};
+ function registerType() {
+ var mimes = [], key = arguments[0];
+ for (var i=1; i < arguments.length; i++) {
+ mimes.push(arguments[i]);
+ };
+ mimesByKey[key] = mimes;
+ for (var i=0; i < mimes.length; i++) {
+ keysByMime[mimes[i]] = key;
+ };
+ }
+
+ // Some default types
+ // Ported from Ruby on Rails
+ // Build list of Mime types for HTTP responses
+ // http://www.iana.org/assignments/media-types/
+ // http://dev.rubyonrails.org/svn/rails/trunk/actionpack/lib/action_controller/mime_types.rb
+
+ registerType("all", "*/*");
+ registerType("text", "text/plain; charset=utf-8", "txt");
+ registerType("html", "text/html; charset=utf-8");
+ registerType("xhtml", "application/xhtml+xml", "xhtml");
+ registerType("xml", "application/xml", "text/xml", "application/x-xml");
+ registerType("js", "text/javascript", "application/javascript", "application/x-javascript");
+ registerType("css", "text/css");
+ registerType("ics", "text/calendar");
+ registerType("csv", "text/csv");
+ registerType("rss", "application/rss+xml");
+ registerType("atom", "application/atom+xml");
+ registerType("yaml", "application/x-yaml", "text/yaml");
+ // just like Rails
+ registerType("multipart_form", "multipart/form-data");
+ registerType("url_encoded_form", "application/x-www-form-urlencoded");
+ // http://www.ietf.org/rfc/rfc4627.txt
+ registerType("json", "application/json", "text/x-json");
+
+
+ var mimeFuns = [];
+ function provides(type, fun) {
+ Mime.providesUsed = true;
+ mimeFuns.push([type, fun]);
+ };
+
+ function resetProvides() {
+ // set globals
+ Mime.providesUsed = false;
+ mimeFuns = [];
+ Mime.responseContentType = null;
+ };
+
+ function runProvides(req, ddoc) {
+ var supportedMimes = [], bestFun, bestKey = null, accept = req.headers["Accept"];
+ if (req.query && req.query.format) {
+ bestKey = req.query.format;
+ Mime.responseContentType = mimesByKey[bestKey][0];
+ } else if (accept) {
+ // log("using accept header: "+accept);
+ mimeFuns.reverse().forEach(function(mimeFun) {
+ var mimeKey = mimeFun[0];
+ if (mimesByKey[mimeKey]) {
+ supportedMimes = supportedMimes.concat(mimesByKey[mimeKey]);
+ }
+ });
+ Mime.responseContentType = Mimeparse.bestMatch(supportedMimes, accept);
+ bestKey = keysByMime[Mime.responseContentType];
+ } else {
+ // just do the first one
+ bestKey = mimeFuns[0][0];
+ Mime.responseContentType = mimesByKey[bestKey][0];
+ }
+
+ if (bestKey) {
+ for (var i=0; i < mimeFuns.length; i++) {
+ if (mimeFuns[i][0] == bestKey) {
+ bestFun = mimeFuns[i][1];
+ break;
+ }
+ };
+ };
+
+ if (bestFun) {
+ return bestFun.call(ddoc);
+ } else {
+ var supportedTypes = mimeFuns.map(function(mf) {
+ return mimesByKey[mf[0]].join(', ') || mf[0];
+ });
+ throw(["error","not_acceptable",
+ "Content-Type "+(accept||bestKey)+" not supported, try one of: "+supportedTypes.join(', ')]);
+ }
+ };
+
+
+ return {
+ registerType : registerType,
+ provides : provides,
+ resetProvides : resetProvides,
+ runProvides : runProvides
+ };
+})();
+
+
+
+
+////
+//// Render dispatcher
+////
+////
+////
+////
+
+var Render = (function() {
+ var chunks = [];
+
+
+ // Start chunks
+ var startResp = {};
+ function start(resp) {
+ startResp = resp || {};
+ };
+
+ function sendStart() {
+ startResp = applyContentType((startResp || {}), Mime.responseContentType);
+ respond(["start", chunks, startResp]);
+ chunks = [];
+ startResp = {};
+ }
+
+ function applyContentType(resp, responseContentType) {
+ resp["headers"] = resp["headers"] || {};
+ if (responseContentType) {
+ resp["headers"]["Content-Type"] = resp["headers"]["Content-Type"] || responseContentType;
+ }
+ return resp;
+ }
+
+ function send(chunk) {
+ chunks.push(chunk.toString());
+ };
+
+ function blowChunks(label) {
+ respond([label||"chunks", chunks]);
+ chunks = [];
+ };
+
+ var gotRow = false, lastRow = false;
+ function getRow() {
+ if (lastRow) return null;
+ if (!gotRow) {
+ gotRow = true;
+ sendStart();
+ } else {
+ blowChunks();
+ }
+ var json = JSON.parse(readline());
+ if (json[0] == "list_end") {
+ lastRow = true;
+ return null;
+ }
+ if (json[0] != "list_row") {
+ throw(["fatal", "list_error", "not a row '" + json[0] + "'"]);
+ }
+ return json[1];
+ };
+
+
+ function maybeWrapResponse(resp) {
+ var type = typeof resp;
+ if ((type == "string") || (type == "xml")) {
+ return {body:resp};
+ } else {
+ return resp;
+ }
+ };
+
+ // from http://javascript.crockford.com/remedial.html
+ function typeOf(value) {
+ var s = typeof value;
+ if (s === 'object') {
+ if (value) {
+ if (value instanceof Array) {
+ s = 'array';
+ }
+ } else {
+ s = 'null';
+ }
+ }
+ return s;
+ };
+
+ function isDocRequestPath(info) {
+ var path = info.path;
+ return path.length > 5;
+ };
+
+ function runShow(fun, ddoc, args) {
+ try {
+ resetList();
+ Mime.resetProvides();
+ var resp = fun.apply(ddoc, args) || {};
+
+ // handle list() style API
+ if (chunks.length && chunks.length > 0) {
+ resp = maybeWrapResponse(resp);
+ resp.headers = resp.headers || {};
+ for(var header in startResp) {
+ resp.headers[header] = startResp[header];
+ }
+ resp.body = chunks.join("") + (resp.body || "");
+ resetList();
+ }
+
+ if (Mime.providesUsed) {
+ resp = Mime.runProvides(args[1], ddoc);
+ resp = applyContentType(maybeWrapResponse(resp), Mime.responseContentType);
+ }
+
+ var type = typeOf(resp);
+ if (type == 'object' || type == 'string') {
+ respond(["resp", maybeWrapResponse(resp)]);
+ } else {
+ throw(["error", "render_error", "undefined response from show function"]);
+ }
+ } catch(e) {
+ if (args[0] === null && isDocRequestPath(args[1])) {
+ throw(["error", "not_found", "document not found"]);
+ } else {
+ renderError(e, fun.toSource());
+ }
+ }
+ };
+
+ function runUpdate(fun, ddoc, args) {
+ try {
+ var method = args[1].method;
+ // for analytics logging applications you might want to remove the next line
+ if (method == "GET") throw(["error","method_not_allowed","Update functions do not allow GET"]);
+ var result = fun.apply(ddoc, args);
+ var doc = result[0];
+ var resp = result[1];
+ var type = typeOf(resp);
+ if (type == 'object' || type == 'string') {
+ respond(["up", doc, maybeWrapResponse(resp)]);
+ } else {
+ throw(["error", "render_error", "undefined response from update function"]);
+ }
+ } catch(e) {
+ renderError(e, fun.toSource());
+ }
+ };
+
+ function resetList() {
+ gotRow = false;
+ lastRow = false;
+ chunks = [];
+ startResp = {};
+ };
+
+ function runList(listFun, ddoc, args) {
+ try {
+ Mime.resetProvides();
+ resetList();
+ var head = args[0];
+ var req = args[1];
+ var tail = listFun.apply(ddoc, args);
+
+ if (Mime.providesUsed) {
+ tail = Mime.runProvides(req, ddoc);
+ }
+ if (!gotRow) getRow();
+ if (typeof tail != "undefined") {
+ chunks.push(tail);
+ }
+ blowChunks("end");
+ } catch(e) {
+ renderError(e, listFun.toSource());
+ }
+ };
+
+ function renderError(e, funSrc) {
+ if (e.error && e.reason || e[0] == "error" || e[0] == "fatal") {
+ throw(e);
+ } else {
+ var logMessage = "function raised error: "+e.toSource()+" \nstacktrace: "+e.stack;
+ log(logMessage);
+ throw(["error", "render_error", logMessage]);
+ }
+ };
+
+ function escapeHTML(string) {
+ return string && string.replace(/&/g, "&amp;")
+ .replace(/</g, "&lt;")
+ .replace(/>/g, "&gt;");
+ };
+
+
+ return {
+ start : start,
+ send : send,
+ getRow : getRow,
+ show : function(fun, ddoc, args) {
+ // var showFun = Couch.compileFunction(funSrc);
+ runShow(fun, ddoc, args);
+ },
+ update : function(fun, ddoc, args) {
+ // var upFun = Couch.compileFunction(funSrc);
+ runUpdate(fun, ddoc, args);
+ },
+ list : function(fun, ddoc, args) {
+ runList(fun, ddoc, args);
+ }
+ };
+})();
+
+// send = Render.send;
+// getRow = Render.getRow;
+// start = Render.start;
+
+// unused. this will be handled in the Erlang side of things.
+// function htmlRenderError(e, funSrc) {
+// var msg = ["<html><body><h1>Render Error</h1>",
+// "<p>JavaScript function raised error: ",
+// e.toString(),
+// "</p><h2>Stacktrace:</h2><code><pre>",
+// escapeHTML(e.stack),
+// "</pre></code><h2>Function source:</h2><code><pre>",
+// escapeHTML(funSrc),
+// "</pre></code></body></html>"].join('');
+// return {body:msg};
+// };
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy of
+// the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+
+var State = {
+ reset : function(config) {
+ // clear the globals and run gc
+ State.funs = [];
+ State.lib = null;
+ State.query_config = config || {};
+ init_sandbox();
+ gc();
+ print("true"); // indicates success
+ },
+ addFun : function(newFun) {
+ // Compile to a function and add it to funs array
+ State.funs.push(Couch.compileFunction(newFun, {views : {lib : State.lib}}));
+ print("true");
+ },
+ addLib : function(lib) {
+ State.lib = lib;
+ print("true");
+ }
+};
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy of
+// the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+
+var resolveModule = function(names, mod, root) {
+ if (names.length == 0) {
+ if (typeof mod.current != "string") {
+ throw ["error","invalid_require_path",
+ 'Must require a JavaScript string, not: '+(typeof mod.current)];
+ }
+ return {
+ current : mod.current,
+ parent : mod.parent,
+ id : mod.id,
+ exports : {}
+ };
+ }
+ // we need to traverse the path
+ var n = names.shift();
+ if (n == '..') {
+ if (!(mod.parent && mod.parent.parent)) {
+ throw ["error", "invalid_require_path", 'Object has no parent '+JSON.stringify(mod.current)];
+ }
+ return resolveModule(names, {
+ id : mod.id.slice(0, mod.id.lastIndexOf('/')),
+ parent : mod.parent.parent,
+ current : mod.parent.current
+ });
+ } else if (n == '.') {
+ if (!mod.parent) {
+ throw ["error", "invalid_require_path", 'Object has no parent '+JSON.stringify(mod.current)];
+ }
+ return resolveModule(names, {
+ parent : mod.parent,
+ current : mod.current,
+ id : mod.id
+ });
+ } else if (root) {
+ mod = {current : root};
+ }
+ if (!mod.current[n]) {
+ throw ["error", "invalid_require_path", 'Object has no property "'+n+'". '+JSON.stringify(mod.current)];
+ }
+ return resolveModule(names, {
+ current : mod.current[n],
+ parent : mod,
+ id : mod.id ? mod.id + '/' + n : n
+ });
+};
+
+var Couch = {
+ // moving this away from global so we can move to json2.js later
+ toJSON : function (val) {
+ return JSON.stringify(val);
+ },
+ compileFunction : function(source, ddoc) {
+ if (!source) throw(["error","not_found","missing function"]);
+
+ var evaluate_function_source = function(source, evalFunction, sandbox) {