koda 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (161) hide show
  1. data/lib/helpers/app_helper.rb +40 -0
  2. data/lib/helpers/koda_helper.rb +105 -0
  3. data/lib/helpers/view_helper.rb +146 -0
  4. data/lib/koda.rb +123 -0
  5. data/lib/models/hash.rb +29 -0
  6. data/lib/models/mongo_collection.rb +144 -0
  7. data/lib/models/mongo_config.rb +22 -0
  8. data/lib/models/mongo_database.rb +136 -0
  9. data/lib/models/mongo_document.rb +124 -0
  10. data/lib/models/mongo_grid.rb +85 -0
  11. data/lib/models/mongo_media.rb +55 -0
  12. data/lib/models/user_access_provider.rb +135 -0
  13. data/lib/models/user_context.rb +19 -0
  14. data/lib/routes/koda_api.rb +392 -0
  15. data/lib/routes/koda_site.rb +57 -0
  16. data/lib/views/console.erb +139 -0
  17. data/lib/views/explorer.erb +119 -0
  18. data/lib/views/login.erb +77 -0
  19. data/lib/views/not_allowed.erb +75 -0
  20. data/public/koda/Help/DataTypes.txt +82 -0
  21. data/public/koda/Help/KodaType_Template.js +48 -0
  22. data/public/koda/apple-touch-icon-114x114-precomposed.png +0 -0
  23. data/public/koda/apple-touch-icon-144x144-precomposed.png +0 -0
  24. data/public/koda/apple-touch-icon-57x57-precomposed.png +0 -0
  25. data/public/koda/apple-touch-icon-72x72-precomposed.png +0 -0
  26. data/public/koda/apple-touch-icon-precomposed.png +0 -0
  27. data/public/koda/apple-touch-icon.png +0 -0
  28. data/public/koda/css/bootstrap-responsive.css +1058 -0
  29. data/public/koda/css/bootstrap.css +5774 -0
  30. data/public/koda/css/main.css +288 -0
  31. data/public/koda/favicon.ico +0 -0
  32. data/public/koda/fonts/angelina-webfont.eot +0 -0
  33. data/public/koda/fonts/angelina-webfont.svg +228 -0
  34. data/public/koda/fonts/angelina-webfont.ttf +0 -0
  35. data/public/koda/fonts/angelina-webfont.woff +0 -0
  36. data/public/koda/fonts/coolvetica_rg-webfont.eot +0 -0
  37. data/public/koda/fonts/coolvetica_rg-webfont.svg +232 -0
  38. data/public/koda/fonts/coolvetica_rg-webfont.ttf +0 -0
  39. data/public/koda/fonts/coolvetica_rg-webfont.woff +0 -0
  40. data/public/koda/fonts/ladyic__-webfont.eot +0 -0
  41. data/public/koda/fonts/ladyic__-webfont.svg +257 -0
  42. data/public/koda/fonts/ladyic__-webfont.ttf +0 -0
  43. data/public/koda/fonts/ladyic__-webfont.woff +0 -0
  44. data/public/koda/images/ajax-loader.gif +0 -0
  45. data/public/koda/images/back.png +0 -0
  46. data/public/koda/images/bg-table-thead.png +0 -0
  47. data/public/koda/images/big_folder.png +0 -0
  48. data/public/koda/images/box_file.png +0 -0
  49. data/public/koda/images/car_add.png +0 -0
  50. data/public/koda/images/compress.png +0 -0
  51. data/public/koda/images/database_table.png +0 -0
  52. data/public/koda/images/feed_add.png +0 -0
  53. data/public/koda/images/feed_link.png +0 -0
  54. data/public/koda/images/file.png +0 -0
  55. data/public/koda/images/folder.png +0 -0
  56. data/public/koda/images/folder_image.png +0 -0
  57. data/public/koda/images/glyphicons-halflings-white.png +0 -0
  58. data/public/koda/images/glyphicons-halflings.png +0 -0
  59. data/public/koda/images/group_add.png +0 -0
  60. data/public/koda/images/group_key.png +0 -0
  61. data/public/koda/images/image_add.png +0 -0
  62. data/public/koda/images/layout_add.png +0 -0
  63. data/public/koda/images/package.png +0 -0
  64. data/public/koda/images/page_white_edit.png +0 -0
  65. data/public/koda/images/page_white_text.png +0 -0
  66. data/public/koda/images/photo_add.png +0 -0
  67. data/public/koda/images/toggle-collapse-dark.png +0 -0
  68. data/public/koda/images/toggle-collapse-light.png +0 -0
  69. data/public/koda/images/toggle-expand-dark.png +0 -0
  70. data/public/koda/images/toggle-expand-light.png +0 -0
  71. data/public/koda/images/twitter.png +0 -0
  72. data/public/koda/koda-editors/KodaEditor.js +843 -0
  73. data/public/koda/koda-editors/collection-editor.html +56 -0
  74. data/public/koda/koda-editors/generic-editor.css +112 -0
  75. data/public/koda/koda-editors/generic-editor.html +74 -0
  76. data/public/koda/koda-editors/koda-editor.css +72 -0
  77. data/public/koda/koda-editors/twitterfeed-editor.html +90 -0
  78. data/public/koda/koda-types/_builtin_registration.json +62 -0
  79. data/public/koda/koda-types/koda-access.json +49 -0
  80. data/public/koda/koda-types/koda-collection.json +12 -0
  81. data/public/koda/koda-types/koda-generictext.json +50 -0
  82. data/public/koda/koda-types/koda-media.json +58 -0
  83. data/public/koda/koda-types/koda-twitterfeed.json +79 -0
  84. data/public/koda/koda-types/koda-user.json +71 -0
  85. data/public/koda/nicEditorIcons.gif +0 -0
  86. data/public/koda/scripts/Koda.js +1200 -0
  87. data/public/koda/scripts/lib/DOMAssistant.js +4 -0
  88. data/public/koda/scripts/lib/modernizr.js +4 -0
  89. data/public/koda/scripts/lib/respond.js +2 -0
  90. data/public/koda/scripts/lib/selectivizr.js +5 -0
  91. data/public/koda/scripts/plugins/bootstrap.js +2027 -0
  92. data/public/koda/scripts/plugins/box.js +8 -0
  93. data/public/koda/scripts/plugins/fancybox/blank.gif +0 -0
  94. data/public/koda/scripts/plugins/fancybox/fancy_close.png +0 -0
  95. data/public/koda/scripts/plugins/fancybox/fancy_loading.png +0 -0
  96. data/public/koda/scripts/plugins/fancybox/fancy_nav_left.png +0 -0
  97. data/public/koda/scripts/plugins/fancybox/fancy_nav_right.png +0 -0
  98. data/public/koda/scripts/plugins/fancybox/fancy_shadow_e.png +0 -0
  99. data/public/koda/scripts/plugins/fancybox/fancy_shadow_n.png +0 -0
  100. data/public/koda/scripts/plugins/fancybox/fancy_shadow_ne.png +0 -0
  101. data/public/koda/scripts/plugins/fancybox/fancy_shadow_nw.png +0 -0
  102. data/public/koda/scripts/plugins/fancybox/fancy_shadow_s.png +0 -0
  103. data/public/koda/scripts/plugins/fancybox/fancy_shadow_se.png +0 -0
  104. data/public/koda/scripts/plugins/fancybox/fancy_shadow_sw.png +0 -0
  105. data/public/koda/scripts/plugins/fancybox/fancy_shadow_w.png +0 -0
  106. data/public/koda/scripts/plugins/fancybox/fancy_title_left.png +0 -0
  107. data/public/koda/scripts/plugins/fancybox/fancy_title_main.png +0 -0
  108. data/public/koda/scripts/plugins/fancybox/fancy_title_over.png +0 -0
  109. data/public/koda/scripts/plugins/fancybox/fancy_title_right.png +0 -0
  110. data/public/koda/scripts/plugins/fancybox/fancybox-x.png +0 -0
  111. data/public/koda/scripts/plugins/fancybox/fancybox-y.png +0 -0
  112. data/public/koda/scripts/plugins/fancybox/fancybox.png +0 -0
  113. data/public/koda/scripts/plugins/fancybox/jquery.easing-1.3.pack.js +72 -0
  114. data/public/koda/scripts/plugins/fancybox/jquery.fancybox-1.3.4.css +359 -0
  115. data/public/koda/scripts/plugins/fancybox/jquery.fancybox-1.3.4.js +1155 -0
  116. data/public/koda/scripts/plugins/fancybox/jquery.fancybox-1.3.4.pack.js +46 -0
  117. data/public/koda/scripts/plugins/fancybox/jquery.mousewheel-3.0.4.pack.js +14 -0
  118. data/public/koda/scripts/plugins/fileuploader.js +1527 -0
  119. data/public/koda/scripts/plugins/jquery-class.js +7 -0
  120. data/public/koda/scripts/plugins/jquery.contextmenu/images/cut.png +0 -0
  121. data/public/koda/scripts/plugins/jquery.contextmenu/images/door.png +0 -0
  122. data/public/koda/scripts/plugins/jquery.contextmenu/images/page_white_copy.png +0 -0
  123. data/public/koda/scripts/plugins/jquery.contextmenu/images/page_white_delete.png +0 -0
  124. data/public/koda/scripts/plugins/jquery.contextmenu/images/page_white_edit.png +0 -0
  125. data/public/koda/scripts/plugins/jquery.contextmenu/images/page_white_paste.png +0 -0
  126. data/public/koda/scripts/plugins/jquery.contextmenu/jquery.contextMenu.css +63 -0
  127. data/public/koda/scripts/plugins/jquery.contextmenu/jquery.contextMenu.js +211 -0
  128. data/public/koda/scripts/plugins/jquery.js +2 -0
  129. data/public/koda/scripts/plugins/json2.js +277 -0
  130. data/public/koda/scripts/plugins/modernizr.js +2 -0
  131. data/public/koda/scripts/plugins/nicEdit.js +183 -0
  132. data/public/koda/scripts/plugins/qunit.js +1448 -0
  133. data/public/koda/scripts/plugins/spin.js +2 -0
  134. data/public/koda/scripts/plugins/uploader/README.md +77 -0
  135. data/public/koda/scripts/plugins/uploader/README.txt +89 -0
  136. data/public/koda/scripts/plugins/uploader/example/application.js +20 -0
  137. data/public/koda/scripts/plugins/uploader/example/index.html +109 -0
  138. data/public/koda/scripts/plugins/uploader/example/style.css +22 -0
  139. data/public/koda/scripts/plugins/uploader/example/upload.php +313 -0
  140. data/public/koda/scripts/plugins/uploader/jquery.fileupload-ui.css +100 -0
  141. data/public/koda/scripts/plugins/uploader/jquery.fileupload-ui.js +642 -0
  142. data/public/koda/scripts/plugins/uploader/jquery.fileupload.js +711 -0
  143. data/public/koda/scripts/plugins/uploader/jquery.iframe-transport.js +133 -0
  144. data/public/koda/scripts/plugins/uploader/pbar-ani.gif +0 -0
  145. data/public/koda/scripts/plugins/uploader/tests/index.html +115 -0
  146. data/public/koda/scripts/plugins/uploader/tests/tests.js +1008 -0
  147. data/public/koda/scripts/require.js +32 -0
  148. data/public/koda/scripts/specs.js +12 -0
  149. data/public/koda/scripts/specs/cd-command-spec.js +51 -0
  150. data/public/koda/scripts/specs/controller-spec.js +95 -0
  151. data/public/koda/scripts/specs/doubles/mock-command.js +21 -0
  152. data/public/koda/scripts/specs/doubles/mock-jamservice.js +33 -0
  153. data/public/koda/scripts/specs/doubles/mock-prompt.js +30 -0
  154. data/public/koda/scripts/specs/doubles/uiobject-double.js +15 -0
  155. data/public/koda/scripts/specs/edit-command-spec.js +76 -0
  156. data/public/koda/scripts/specs/ls-command-spec.js +61 -0
  157. data/public/koda/scripts/specs/mkdir-command-spec.js +40 -0
  158. data/public/koda/scripts/specs/peek-command-spec.js +24 -0
  159. data/public/koda/scripts/specs/remove-command-spec.js +37 -0
  160. data/public/koda/scripts/specs/service-spec.js +85 -0
  161. metadata +402 -0
@@ -0,0 +1,2 @@
1
+ //fgnass.github.com/spin.js#v1.2.6
2
+ !function(e,t,n){function o(e,n){var r=t.createElement(e||"div"),i;for(i in n)r[i]=n[i];return r}function u(e){for(var t=1,n=arguments.length;t<n;t++)e.appendChild(arguments[t]);return e}function f(e,t,n,r){var o=["opacity",t,~~(e*100),n,r].join("-"),u=.01+n/r*100,f=Math.max(1-(1-e)/t*(100-u),e),l=s.substring(0,s.indexOf("Animation")).toLowerCase(),c=l&&"-"+l+"-"||"";return i[o]||(a.insertRule("@"+c+"keyframes "+o+"{"+"0%{opacity:"+f+"}"+u+"%{opacity:"+e+"}"+(u+.01)+"%{opacity:1}"+(u+t)%100+"%{opacity:"+e+"}"+"100%{opacity:"+f+"}"+"}",a.cssRules.length),i[o]=1),o}function l(e,t){var i=e.style,s,o;if(i[t]!==n)return t;t=t.charAt(0).toUpperCase()+t.slice(1);for(o=0;o<r.length;o++){s=r[o]+t;if(i[s]!==n)return s}}function c(e,t){for(var n in t)e.style[l(e,n)||n]=t[n];return e}function h(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)e[i]===n&&(e[i]=r[i])}return e}function p(e){var t={x:e.offsetLeft,y:e.offsetTop};while(e=e.offsetParent)t.x+=e.offsetLeft,t.y+=e.offsetTop;return t}var r=["webkit","Moz","ms","O"],i={},s,a=function(){var e=o("style",{type:"text/css"});return u(t.getElementsByTagName("head")[0],e),e.sheet||e.styleSheet}(),d={lines:12,length:7,width:5,radius:10,rotate:0,corners:1,color:"#000",speed:1,trail:100,opacity:.25,fps:20,zIndex:2e9,className:"spinner",top:"auto",left:"auto"},v=function m(e){if(!this.spin)return new m(e);this.opts=h(e||{},m.defaults,d)};v.defaults={},h(v.prototype,{spin:function(e){this.stop();var t=this,n=t.opts,r=t.el=c(o(0,{className:n.className}),{position:"relative",width:0,zIndex:n.zIndex}),i=n.radius+n.length+n.width,u,a;e&&(e.insertBefore(r,e.firstChild||null),a=p(e),u=p(r),c(r,{left:(n.left=="auto"?a.x-u.x+(e.offsetWidth>>1):parseInt(n.left,10)+i)+"px",top:(n.top=="auto"?a.y-u.y+(e.offsetHeight>>1):parseInt(n.top,10)+i)+"px"})),r.setAttribute("aria-role","progressbar"),t.lines(r,t.opts);if(!s){var f=0,l=n.fps,h=l/n.speed,d=(1-n.opacity)/(h*n.trail/100),v=h/n.lines;(function m(){f++;for(var e=n.lines;e;e--){var i=Math.max(1-(f+e*v)%h*d,n.opacity);t.opacity(r,n.lines-e,i,n)}t.timeout=t.el&&setTimeout(m,~~(1e3/l))})()}return t},stop:function(){var e=this.el;return e&&(clearTimeout(this.timeout),e.parentNode&&e.parentNode.removeChild(e),this.el=n),this},lines:function(e,t){function i(e,r){return c(o(),{position:"absolute",width:t.length+t.width+"px",height:t.width+"px",background:e,boxShadow:r,transformOrigin:"left",transform:"rotate("+~~(360/t.lines*n+t.rotate)+"deg) translate("+t.radius+"px"+",0)",borderRadius:(t.corners*t.width>>1)+"px"})}var n=0,r;for(;n<t.lines;n++)r=c(o(),{position:"absolute",top:1+~(t.width/2)+"px",transform:t.hwaccel?"translate3d(0,0,0)":"",opacity:t.opacity,animation:s&&f(t.opacity,t.trail,n,t.lines)+" "+1/t.speed+"s linear infinite"}),t.shadow&&u(r,c(i("#000","0 0 4px #000"),{top:"2px"})),u(e,u(r,i(t.color,"0 0 1px rgba(0,0,0,.1)")));return e},opacity:function(e,t,n){t<e.childNodes.length&&(e.childNodes[t].style.opacity=n)}}),function(){function e(e,t){return o("<"+e+' xmlns="urn:schemas-microsoft.com:vml" class="spin-vml">',t)}var t=c(o("group"),{behavior:"url(#default#VML)"});!l(t,"transform")&&t.adj?(a.addRule(".spin-vml","behavior:url(#default#VML)"),v.prototype.lines=function(t,n){function s(){return c(e("group",{coordsize:i+" "+i,coordorigin:-r+" "+ -r}),{width:i,height:i})}function l(t,i,o){u(a,u(c(s(),{rotation:360/n.lines*t+"deg",left:~~i}),u(c(e("roundrect",{arcsize:n.corners}),{width:r,height:n.width,left:n.radius,top:-n.width>>1,filter:o}),e("fill",{color:n.color,opacity:n.opacity}),e("stroke",{opacity:0}))))}var r=n.length+n.width,i=2*r,o=-(n.width+n.length)*2+"px",a=c(s(),{position:"absolute",top:o,left:o}),f;if(n.shadow)for(f=1;f<=n.lines;f++)l(f,-2,"progid:DXImageTransform.Microsoft.Blur(pixelradius=2,makeshadow=1,shadowopacity=.3)");for(f=1;f<=n.lines;f++)l(f);return u(t,a)},v.prototype.opacity=function(e,t,n,r){var i=e.firstChild;r=r.shadow&&r.lines||0,i&&t+r<i.childNodes.length&&(i=i.childNodes[t+r],i=i&&i.firstChild,i=i&&i.firstChild,i&&(i.opacity=n))}):s=l(t,"animation")}(),typeof define=="function"&&define.amd?define(function(){return v}):e.Spinner=v}(window,document);
@@ -0,0 +1,77 @@
1
+ # jQuery File Upload Plugin
2
+
3
+ ## Demo
4
+ [Demo File Upload](http://aquantum-demo.appspot.com/file-upload)
5
+
6
+ ## Setup instructions
7
+ [How to setup the plugin on your website](https://github.com/blueimp/jQuery-File-Upload/wiki/Setup)
8
+
9
+ ## Features
10
+ * **Multiple file upload:**
11
+ Allows to select multiple files at once and upload them simultaneously.
12
+ * **Drag & Drop support:**
13
+ Allows to upload files by dragging them from your desktop or filemanager and dropping them on your browser window.
14
+ * **Upload progress bar:**
15
+ Shows a progress bar indicating the upload progress for individual files and for all uploads combined.
16
+ * **Cancelable uploads:**
17
+ Individual file uploads can be canceled to stop the upload progress.
18
+ * **Resumable uploads:**
19
+ Aborted uploads can be resumed with browsers supporting the Blob API.
20
+ * **Chunked uploads:**
21
+ Large files can be uploaded in smaller chunks with browsers supporting the Blob API.
22
+ * **Preview images:**
23
+ A preview of image files can be displayed before uploading with browsers supporting the required HTML5 APIs.
24
+ * **No browser plugins (e.g. Adobe Flash) required:**
25
+ The implementation is based on open standards like HTML5 and JavaScript and requires no additional browser plugins.
26
+ * **Graceful fallback for legacy browsers:**
27
+ Uploads files via XMLHttpRequests if supported and uses iframes as fallback for legacy browsers.
28
+ * **HTML file upload form fallback:**
29
+ Shows a standard HTML file upload form if JavaScript is disabled.
30
+ * **Cross-site file uploads:**
31
+ Supports uploading files to a different domain with Cross-site XMLHttpRequests.
32
+ * **Multiple plugin instances:**
33
+ Allows to use multiple plugin instances on the same webpage.
34
+ * **Customizable and extensible:**
35
+ Provides an API to set individual options and define callBack methods for various upload events.
36
+ * **Multipart and file contents stream uploads:**
37
+ Files can be uploaded as standard "multipart/form-data" or file contents stream (HTTP PUT file upload).
38
+ * **Compatible with any server-side application platform:**
39
+ Works with Google App Engine (Python, Java), Ruby on Rails, PHP and any other platform that supports HTTP file uploads.
40
+
41
+ ## Requirements
42
+ * [jQuery](http://jquery.com/) v. 1.6+
43
+ * [jQuery UI](http://jqueryui.com/) v. 1.8+ (required: Widget, optional: Progressbar, Button)
44
+ * jQuery Iframe Transport plugin (included)
45
+ * [jQuery Templates plugin](http://api.jquery.com/category/plugins/templates/) v. 1.0+ (optional)
46
+
47
+ The jQuery UI widget factory is a requirement for the basic File Upload plugin, but very lightweight without any other dependencies.
48
+ The UI version of the File Upload plugin also requires the jQuery UI Progressbar and Button components as well as the jQuery Templates plugin. These dependencies are marked as optional, as the basic File Upload plugin can be used without them and the UI version of the plugin can be extended to override these dependencies with alternative solutions.
49
+
50
+ ## Browser Support (tested versions)
51
+ * Google Chrome - 7.0+
52
+ * Apple Safari - 4.0+
53
+ * Mozilla Firefox - 3.0+
54
+ * Opera - 10.0+
55
+ * Microsoft Internet Explorer 6.0+
56
+
57
+ Drag & Drop is only supported on Google Chrome, Firefox 4.0+ and Safari 5.0+.
58
+ Microsoft Internet Explorer has no support for multiple file selection or upload progress.
59
+ [Extended browser support information](https://github.com/blueimp/jQuery-File-Upload/wiki/Browser-support).
60
+
61
+ ## License
62
+ Released under the [MIT license](http://creativecommons.org/licenses/MIT/).
63
+
64
+ ## Source Code & Download
65
+ * Browse and checkout the [source code](https://github.com/blueimp/jQuery-File-Upload).
66
+ * [Download](https://github.com/blueimp/jQuery-File-Upload/archives/master) the project to add the plugin to your website.
67
+
68
+ ## Documentation & Support
69
+ * Documentation can be found on the [Project Wiki](https://github.com/blueimp/jQuery-File-Upload/wiki).
70
+ * Support requests and bug reports can be posted to the [Issue Tracker](https://github.com/blueimp/jQuery-File-Upload/issues).
71
+
72
+ ## Donations
73
+ jQuery File Upload is free software, but you can donate to support the developer, Sebastian Tschan:
74
+
75
+ flattr (€): [![flattr](https://api.flattr.com/button/flattr-badge-large.png)](https://flattr.com/thing/286433/jQuery-File-Upload-Plugin)
76
+
77
+ PayPal ($): [![Paypal](https://www.paypalobjects.com/WEBSCR-640-20110429-1/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=PYWYSYP77KL54)
@@ -0,0 +1,89 @@
1
+ jQuery File Upload Plugin
2
+ =========================
3
+
4
+ Demo
5
+ ----
6
+ http://aquantum-demo.appspot.com/file-upload
7
+
8
+ Setup instructions
9
+ ------------------
10
+ https://github.com/blueimp/jQuery-File-Upload/wiki/Setup
11
+
12
+ Features
13
+ --------
14
+ - Multiple file upload:
15
+ Allows to select multiple files at once and upload them simultaneously.
16
+ - Drag & Drop support:
17
+ Allows to upload files by dragging them from your desktop or filemanager and dropping them on your browser window.
18
+ - Upload progress bar:
19
+ Shows a progress bar indicating the upload progress for individual files and for all uploads combined.
20
+ - Cancelable uploads:
21
+ Individual file uploads can be canceled to stop the upload progress.
22
+ - Resumable uploads:
23
+ Aborted uploads can be resumed with browsers supporting the Blob API.
24
+ - Chunked uploads:
25
+ Large files can be uploaded in smaller chunks with browsers supporting the Blob API.
26
+ - Preview images:
27
+ A preview of image files can be displayed before uploading with browsers supporting the required HTML5 APIs.
28
+ - No browser plugins (e.g. Adobe Flash) required:
29
+ The implementation is based on open standards like HTML5 and JavaScript and requires no additional browser plugins.
30
+ - Graceful fallback for legacy browsers:
31
+ Uploads files via XMLHttpRequests if supported and uses iframes as fallback for legacy browsers.
32
+ - HTML file upload form fallback:
33
+ Shows a standard HTML file upload form if JavaScript is disabled.
34
+ - Cross-site file uploads:
35
+ Supports uploading files to a different domain with Cross-site XMLHttpRequests.
36
+ - Multiple plugin instances:
37
+ Allows to use multiple plugin instances on the same webpage.
38
+ - Customizable and extensible:
39
+ Provides an API to set individual options and define callBack methods for various upload events.
40
+ - Multipart and file contents stream uploads:
41
+ Files can be uploaded as standard "multipart/form-data" or file contents stream (HTTP PUT file upload).
42
+ - Compatible with any server-side application platform:
43
+ Works with Google App Engine (Python, Java), Ruby on Rails, PHP and any other platform that supports HTTP file uploads.
44
+
45
+ Requirements
46
+ ------------
47
+ - jQuery v. 1.6+
48
+ - jQuery UI v. 1.8+ (required: Widget, optional: Progressbar, Button)
49
+ - jQuery Iframe Transport plugin (included)
50
+ - jQuery Templates plugin v. 1.0+ (optional)
51
+
52
+ The jQuery UI widget factory is a requirement for the basic File Upload plugin, but very lightweight without any other dependencies.
53
+ The UI version of the File Upload plugin also requires the jQuery UI Progressbar and Button components as well as the jQuery Templates plugin. These dependencies are marked as optional, as the basic File Upload plugin can be used without them and the UI version of the plugin can be extended to override these dependencies with alternative solutions.
54
+
55
+ Browser Support (tested versions)
56
+ ---------------------------------
57
+ - Google Chrome - 7.0+
58
+ - Apple Safari - 4.0+
59
+ - Mozilla Firefox - 3.0+
60
+ - Opera - 10.0+
61
+ - Microsoft Internet Explorer 6.0+
62
+
63
+ Drag & Drop is only supported on Google Chrome, Firefox 4.0+ and Safari 5.0+.
64
+ Microsoft Internet Explorer has no support for multiple file selection or upload progress.
65
+ Extended browser support information:
66
+ https://github.com/blueimp/jQuery-File-Upload/wiki/Browser-support
67
+
68
+ License
69
+ -------
70
+ Released under the MIT license:
71
+ http://creativecommons.org/licenses/MIT/
72
+
73
+ Source Code & Download
74
+ ----------------------
75
+ https://github.com/blueimp/jQuery-File-Upload
76
+
77
+ Documentation
78
+ -------------
79
+ https://github.com/blueimp/jQuery-File-Upload/wiki
80
+
81
+ Donations
82
+ ---------
83
+ jQuery File Upload is free software, but you can donate to support the developer, Sebastian Tschan:
84
+
85
+ flattr (€):
86
+ https://flattr.com/thing/286433/jQuery-File-Upload-Plugin
87
+
88
+ PayPal ($):
89
+ https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=PYWYSYP77KL54
@@ -0,0 +1,20 @@
1
+ /*
2
+ * jQuery File Upload Plugin JS Example 5.0.1
3
+ * https://github.com/blueimp/jQuery-File-Upload
4
+ *
5
+ * Copyright 2010, Sebastian Tschan
6
+ * https://blueimp.net
7
+ *
8
+ * Licensed under the MIT license:
9
+ * http://creativecommons.org/licenses/MIT/
10
+ */
11
+
12
+ /*jslint nomen: false */
13
+ /*global $ */
14
+
15
+ $(function () {
16
+
17
+ // Initialize the jQuery File Upload widget:
18
+ $('#fileupload').fileupload();
19
+
20
+ });
@@ -0,0 +1,109 @@
1
+ <!DOCTYPE HTML>
2
+ <!--
3
+ /*
4
+ * jQuery File Upload Plugin HTML Example 5.0.5
5
+ * https://github.com/blueimp/jQuery-File-Upload
6
+ *
7
+ * Copyright 2010, Sebastian Tschan
8
+ * https://blueimp.net
9
+ *
10
+ * Licensed under the MIT license:
11
+ * http://creativecommons.org/licenses/MIT/
12
+ */
13
+ -->
14
+ <html lang="en" class="no-js">
15
+ <head>
16
+ <meta charset="utf-8">
17
+ <title>jQuery File Upload Example</title>
18
+ <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.13/themes/base/jquery-ui.css" id="theme">
19
+ <link rel="stylesheet" href="../jquery.fileupload-ui.css">
20
+ <link rel="stylesheet" href="style.css">
21
+ </head>
22
+ <body>
23
+ <div id="fileupload">
24
+ <form action="upload.php" method="POST" enctype="multipart/form-data">
25
+ <div class="fileupload-buttonbar">
26
+ <label class="fileinput-button">
27
+ <span>Add files...</span>
28
+ <input type="file" name="files[]" multiple>
29
+ </label>
30
+ <button type="submit" class="start">Start upload</button>
31
+ <button type="reset" class="cancel">Cancel upload</button>
32
+ <button type="button" class="delete">Delete files</button>
33
+ </div>
34
+ </form>
35
+ <div class="fileupload-content">
36
+ <table class="files"></table>
37
+ <div class="fileupload-progressbar"></div>
38
+ </div>
39
+ </div>
40
+ <script id="template-upload" type="text/x-jquery-tmpl">
41
+ <tr class="template-upload{{if error}} ui-state-error{{/if}}">
42
+ <td class="preview"></td>
43
+ <td class="name">${name}</td>
44
+ <td class="size">${sizef}</td>
45
+ {{if error}}
46
+ <td class="error" colspan="2">Error:
47
+ {{if error === 'maxFileSize'}}File is too big
48
+ {{else error === 'minFileSize'}}File is too small
49
+ {{else error === 'acceptFileTypes'}}Filetype not allowed
50
+ {{else error === 'maxNumberOfFiles'}}Max number of files exceeded
51
+ {{else}}${error}
52
+ {{/if}}
53
+ </td>
54
+ {{else}}
55
+ <td class="progress"><div></div></td>
56
+ <td class="start"><button>Start</button></td>
57
+ {{/if}}
58
+ <td class="cancel"><button>Cancel</button></td>
59
+ </tr>
60
+ </script>
61
+ <script id="template-download" type="text/x-jquery-tmpl">
62
+ <tr class="template-download{{if error}} ui-state-error{{/if}}">
63
+ {{if error}}
64
+ <td></td>
65
+ <td class="name">${name}</td>
66
+ <td class="size">${sizef}</td>
67
+ <td class="error" colspan="2">Error:
68
+ {{if error === 1}}File exceeds upload_max_filesize (php.ini directive)
69
+ {{else error === 2}}File exceeds MAX_FILE_SIZE (HTML form directive)
70
+ {{else error === 3}}File was only partially uploaded
71
+ {{else error === 4}}No File was uploaded
72
+ {{else error === 5}}Missing a temporary folder
73
+ {{else error === 6}}Failed to write file to disk
74
+ {{else error === 7}}File upload stopped by extension
75
+ {{else error === 'maxFileSize'}}File is too big
76
+ {{else error === 'minFileSize'}}File is too small
77
+ {{else error === 'acceptFileTypes'}}Filetype not allowed
78
+ {{else error === 'maxNumberOfFiles'}}Max number of files exceeded
79
+ {{else error === 'uploadedBytes'}}Uploaded bytes exceed file size
80
+ {{else error === 'emptyResult'}}Empty file upload result
81
+ {{else}}${error}
82
+ {{/if}}
83
+ </td>
84
+ {{else}}
85
+ <td class="preview">
86
+ {{if thumbnail_url}}
87
+ <a href="${url}" target="_blank"><img src="${thumbnail_url}"></a>
88
+ {{/if}}
89
+ </td>
90
+ <td class="name">
91
+ <a href="${url}"{{if thumbnail_url}} target="_blank"{{/if}}>${name}</a>
92
+ </td>
93
+ <td class="size">${sizef}</td>
94
+ <td colspan="2"></td>
95
+ {{/if}}
96
+ <td class="delete">
97
+ <button data-type="${delete_type}" data-url="${delete_url}">Delete</button>
98
+ </td>
99
+ </tr>
100
+ </script>
101
+ <script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
102
+ <script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.8.13/jquery-ui.min.js"></script>
103
+ <script src="//ajax.aspnetcdn.com/ajax/jquery.templates/beta1/jquery.tmpl.min.js"></script>
104
+ <script src="../jquery.iframe-transport.js"></script>
105
+ <script src="../jquery.fileupload.js"></script>
106
+ <script src="../jquery.fileupload-ui.js"></script>
107
+ <script src="application.js"></script>
108
+ </body>
109
+ </html>
@@ -0,0 +1,22 @@
1
+ @charset 'UTF-8';
2
+ /*
3
+ * jQuery File Upload Plugin CSS Example 5.0
4
+ * https://github.com/blueimp/jQuery-File-Upload
5
+ *
6
+ * Copyright 2010, Sebastian Tschan
7
+ * https://blueimp.net
8
+ *
9
+ * Licensed under the MIT license:
10
+ * http://creativecommons.org/licenses/MIT/
11
+ */
12
+
13
+ body {
14
+ font-family: Verdana, Arial, sans-serif;
15
+ font-size: 13px;
16
+ margin: 0;
17
+ padding: 20px;
18
+ }
19
+
20
+ a {
21
+ color: #222;
22
+ }
@@ -0,0 +1,313 @@
1
+ <?php
2
+ /*
3
+ * jQuery File Upload Plugin PHP Example 5.2.1
4
+ * https://github.com/blueimp/jQuery-File-Upload
5
+ *
6
+ * Copyright 2010, Sebastian Tschan
7
+ * https://blueimp.net
8
+ *
9
+ * Licensed under the MIT license:
10
+ * http://creativecommons.org/licenses/MIT/
11
+ */
12
+
13
+ error_reporting(E_ALL | E_STRICT);
14
+
15
+ class UploadHandler
16
+ {
17
+ private $options;
18
+
19
+ function __construct($options=null) {
20
+ $this->options = array(
21
+ 'script_url' => $_SERVER['PHP_SELF'],
22
+ 'upload_dir' => dirname(__FILE__).'/files/',
23
+ 'upload_url' => dirname($_SERVER['PHP_SELF']).'/files/',
24
+ 'param_name' => 'files',
25
+ // The php.ini settings upload_max_filesize and post_max_size
26
+ // take precedence over the following max_file_size setting:
27
+ 'max_file_size' => null,
28
+ 'min_file_size' => 1,
29
+ 'accept_file_types' => '/.+$/i',
30
+ 'max_number_of_files' => null,
31
+ 'discard_aborted_uploads' => true,
32
+ 'image_versions' => array(
33
+ // Uncomment the following version to restrict the size of
34
+ // uploaded images. You can also add additional versions with
35
+ // their own upload directories:
36
+ /*
37
+ 'large' => array(
38
+ 'upload_dir' => dirname(__FILE__).'/files/',
39
+ 'upload_url' => dirname($_SERVER['PHP_SELF']).'/files/',
40
+ 'max_width' => 1920,
41
+ 'max_height' => 1200
42
+ ),
43
+ */
44
+ 'thumbnail' => array(
45
+ 'upload_dir' => dirname(__FILE__).'/thumbnails/',
46
+ 'upload_url' => dirname($_SERVER['PHP_SELF']).'/thumbnails/',
47
+ 'max_width' => 80,
48
+ 'max_height' => 80
49
+ )
50
+ )
51
+ );
52
+ if ($options) {
53
+ $this->options = array_merge_recursive($this->options, $options);
54
+ }
55
+ }
56
+
57
+ private function get_file_object($file_name) {
58
+ $file_path = $this->options['upload_dir'].$file_name;
59
+ if (is_file($file_path) && $file_name[0] !== '.') {
60
+ $file = new stdClass();
61
+ $file->name = $file_name;
62
+ $file->size = filesize($file_path);
63
+ $file->url = $this->options['upload_url'].rawurlencode($file->name);
64
+ foreach($this->options['image_versions'] as $version => $options) {
65
+ if (is_file($options['upload_dir'].$file_name)) {
66
+ $file->{$version.'_url'} = $options['upload_url']
67
+ .rawurlencode($file->name);
68
+ }
69
+ }
70
+ $file->delete_url = $this->options['script_url']
71
+ .'?file='.rawurlencode($file->name);
72
+ $file->delete_type = 'DELETE';
73
+ return $file;
74
+ }
75
+ return null;
76
+ }
77
+
78
+ private function get_file_objects() {
79
+ return array_values(array_filter(array_map(
80
+ array($this, 'get_file_object'),
81
+ scandir($this->options['upload_dir'])
82
+ )));
83
+ }
84
+
85
+ private function create_scaled_image($file_name, $options) {
86
+ $file_path = $this->options['upload_dir'].$file_name;
87
+ $new_file_path = $options['upload_dir'].$file_name;
88
+ list($img_width, $img_height) = @getimagesize($file_path);
89
+ if (!$img_width || !$img_height) {
90
+ return false;
91
+ }
92
+ $scale = min(
93
+ $options['max_width'] / $img_width,
94
+ $options['max_height'] / $img_height
95
+ );
96
+ if ($scale > 1) {
97
+ $scale = 1;
98
+ }
99
+ $new_width = $img_width * $scale;
100
+ $new_height = $img_height * $scale;
101
+ $new_img = @imagecreatetruecolor($new_width, $new_height);
102
+ switch (strtolower(substr(strrchr($file_name, '.'), 1))) {
103
+ case 'jpg':
104
+ case 'jpeg':
105
+ $src_img = @imagecreatefromjpeg($file_path);
106
+ $write_image = 'imagejpeg';
107
+ break;
108
+ case 'gif':
109
+ $src_img = @imagecreatefromgif($file_path);
110
+ $write_image = 'imagegif';
111
+ break;
112
+ case 'png':
113
+ $src_img = @imagecreatefrompng($file_path);
114
+ $write_image = 'imagepng';
115
+ break;
116
+ default:
117
+ $src_img = $image_method = null;
118
+ }
119
+ $success = $src_img && @imagecopyresampled(
120
+ $new_img,
121
+ $src_img,
122
+ 0, 0, 0, 0,
123
+ $new_width,
124
+ $new_height,
125
+ $img_width,
126
+ $img_height
127
+ ) && $write_image($new_img, $new_file_path);
128
+ // Free up memory (imagedestroy does not delete files):
129
+ @imagedestroy($src_img);
130
+ @imagedestroy($new_img);
131
+ return $success;
132
+ }
133
+
134
+ private function has_error($uploaded_file, $file, $error) {
135
+ if ($error) {
136
+ return $error;
137
+ }
138
+ if (!preg_match($this->options['accept_file_types'], $file->name)) {
139
+ return 'acceptFileTypes';
140
+ }
141
+ if ($uploaded_file && is_uploaded_file($uploaded_file)) {
142
+ $file_size = filesize($uploaded_file);
143
+ } else {
144
+ $file_size = $_SERVER['CONTENT_LENGTH'];
145
+ }
146
+ if ($this->options['max_file_size'] && (
147
+ $file_size > $this->options['max_file_size'] ||
148
+ $file->size > $this->options['max_file_size'])
149
+ ) {
150
+ return 'maxFileSize';
151
+ }
152
+ if ($this->options['min_file_size'] &&
153
+ $file_size < $this->options['min_file_size']) {
154
+ return 'minFileSize';
155
+ }
156
+ if (is_int($this->options['max_number_of_files']) && (
157
+ count($this->get_file_objects()) >= $this->options['max_number_of_files'])
158
+ ) {
159
+ return 'maxNumberOfFiles';
160
+ }
161
+ return $error;
162
+ }
163
+
164
+ private function handle_file_upload($uploaded_file, $name, $size, $type, $error) {
165
+ $file = new stdClass();
166
+ $file->name = basename(stripslashes($name));
167
+ $file->size = intval($size);
168
+ $file->type = $type;
169
+ $error = $this->has_error($uploaded_file, $file, $error);
170
+ if (!$error && $file->name) {
171
+ if ($file->name[0] === '.') {
172
+ $file->name = substr($file->name, 1);
173
+ }
174
+ $file_path = $this->options['upload_dir'].$file->name;
175
+ $append_file = is_file($file_path) && $file->size > filesize($file_path);
176
+ clearstatcache();
177
+ if ($uploaded_file && is_uploaded_file($uploaded_file)) {
178
+ // multipart/formdata uploads (POST method uploads)
179
+ if ($append_file) {
180
+ file_put_contents(
181
+ $file_path,
182
+ fopen($uploaded_file, 'r'),
183
+ FILE_APPEND
184
+ );
185
+ } else {
186
+ move_uploaded_file($uploaded_file, $file_path);
187
+ }
188
+ } else {
189
+ // Non-multipart uploads (PUT method support)
190
+ file_put_contents(
191
+ $file_path,
192
+ fopen('php://input', 'r'),
193
+ $append_file ? FILE_APPEND : 0
194
+ );
195
+ }
196
+ $file_size = filesize($file_path);
197
+ if ($file_size === $file->size) {
198
+ $file->url = $this->options['upload_url'].rawurlencode($file->name);
199
+ foreach($this->options['image_versions'] as $version => $options) {
200
+ if ($this->create_scaled_image($file->name, $options)) {
201
+ $file->{$version.'_url'} = $options['upload_url']
202
+ .rawurlencode($file->name);
203
+ }
204
+ }
205
+ } else if ($this->options['discard_aborted_uploads']) {
206
+ unlink($file_path);
207
+ $file->error = 'abort';
208
+ }
209
+ $file->size = $file_size;
210
+ $file->delete_url = $this->options['script_url']
211
+ .'?file='.rawurlencode($file->name);
212
+ $file->delete_type = 'DELETE';
213
+ } else {
214
+ $file->error = $error;
215
+ }
216
+ return $file;
217
+ }
218
+
219
+ public function get() {
220
+ $file_name = isset($_REQUEST['file']) ?
221
+ basename(stripslashes($_REQUEST['file'])) : null;
222
+ if ($file_name) {
223
+ $info = $this->get_file_object($file_name);
224
+ } else {
225
+ $info = $this->get_file_objects();
226
+ }
227
+ header('Content-type: application/json');
228
+ echo json_encode($info);
229
+ }
230
+
231
+ public function post() {
232
+ $upload = isset($_FILES[$this->options['param_name']]) ?
233
+ $_FILES[$this->options['param_name']] : array(
234
+ 'tmp_name' => null,
235
+ 'name' => null,
236
+ 'size' => null,
237
+ 'type' => null,
238
+ 'error' => null
239
+ );
240
+ $info = array();
241
+ if (is_array($upload['tmp_name'])) {
242
+ foreach ($upload['tmp_name'] as $index => $value) {
243
+ $info[] = $this->handle_file_upload(
244
+ $upload['tmp_name'][$index],
245
+ isset($_SERVER['HTTP_X_FILE_NAME']) ?
246
+ $_SERVER['HTTP_X_FILE_NAME'] : $upload['name'][$index],
247
+ isset($_SERVER['HTTP_X_FILE_SIZE']) ?
248
+ $_SERVER['HTTP_X_FILE_SIZE'] : $upload['size'][$index],
249
+ isset($_SERVER['HTTP_X_FILE_TYPE']) ?
250
+ $_SERVER['HTTP_X_FILE_TYPE'] : $upload['type'][$index],
251
+ $upload['error'][$index]
252
+ );
253
+ }
254
+ } else {
255
+ $info[] = $this->handle_file_upload(
256
+ $upload['tmp_name'],
257
+ isset($_SERVER['HTTP_X_FILE_NAME']) ?
258
+ $_SERVER['HTTP_X_FILE_NAME'] : $upload['name'],
259
+ isset($_SERVER['HTTP_X_FILE_SIZE']) ?
260
+ $_SERVER['HTTP_X_FILE_SIZE'] : $upload['size'],
261
+ isset($_SERVER['HTTP_X_FILE_TYPE']) ?
262
+ $_SERVER['HTTP_X_FILE_TYPE'] : $upload['type'],
263
+ $upload['error']
264
+ );
265
+ }
266
+ header('Vary: Accept');
267
+ if (isset($_SERVER['HTTP_ACCEPT']) &&
268
+ (strpos($_SERVER['HTTP_ACCEPT'], 'application/json') !== false)) {
269
+ header('Content-type: application/json');
270
+ } else {
271
+ header('Content-type: text/plain');
272
+ }
273
+ echo json_encode($info);
274
+ }
275
+
276
+ public function delete() {
277
+ $file_name = isset($_REQUEST['file']) ?
278
+ basename(stripslashes($_REQUEST['file'])) : null;
279
+ $file_path = $this->options['upload_dir'].$file_name;
280
+ $success = is_file($file_path) && $file_name[0] !== '.' && unlink($file_path);
281
+ if ($success) {
282
+ foreach($this->options['image_versions'] as $version => $options) {
283
+ $file = $options['upload_dir'].$file_name;
284
+ if (is_file($file)) {
285
+ unlink($file);
286
+ }
287
+ }
288
+ }
289
+ header('Content-type: application/json');
290
+ echo json_encode($success);
291
+ }
292
+ }
293
+
294
+ $upload_handler = new UploadHandler();
295
+
296
+ header('Pragma: no-cache');
297
+ header('Cache-Control: private, no-cache');
298
+
299
+ switch ($_SERVER['REQUEST_METHOD']) {
300
+ case 'HEAD':
301
+ case 'GET':
302
+ $upload_handler->get();
303
+ break;
304
+ case 'POST':
305
+ $upload_handler->post();
306
+ break;
307
+ case 'DELETE':
308
+ $upload_handler->delete();
309
+ break;
310
+ default:
311
+ header('HTTP/1.0 405 Method Not Allowed');
312
+ }
313
+ ?>