spontaneous 0.1.0.alpha1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +49 -0
- data/Gemfile.lock +146 -0
- data/LICENSE +0 -0
- data/README +0 -0
- data/Rakefile +284 -0
- data/Readme.markdown +7 -0
- data/application/css/add_alias_dialogue.scss +27 -0
- data/application/css/definitions.scss +249 -0
- data/application/css/developer.scss +9 -0
- data/application/css/editing.scss +649 -0
- data/application/css/login.scss +91 -0
- data/application/css/min/54ee0ed3c7fac7632bd5c020d69e9a2503e0c88c.css +1 -0
- data/application/css/min/c256adc144e2bdd0b0539356b04eb62db01e1dc3.css +1 -0
- data/application/css/popover.scss +335 -0
- data/application/css/schema_error.scss +90 -0
- data/application/css/spontaneous.scss +111 -0
- data/application/css/unsupported.scss +16 -0
- data/application/css/v2.scss +1606 -0
- data/application/css/variables.scss +80 -0
- data/application/js/add_alias_dialogue.js +59 -0
- data/application/js/add_home_dialogue.js +59 -0
- data/application/js/ajax.js +99 -0
- data/application/js/authentication.js +22 -0
- data/application/js/box.js +104 -0
- data/application/js/box_container.js +82 -0
- data/application/js/compatibility.js +132 -0
- data/application/js/conflicted_field_dialogue.js +92 -0
- data/application/js/content.js +224 -0
- data/application/js/content_area.js +44 -0
- data/application/js/dialogue.js +196 -0
- data/application/js/dom.js +71 -0
- data/application/js/edit_dialogue.js +137 -0
- data/application/js/edit_panel.js +232 -0
- data/application/js/editing.js +42 -0
- data/application/js/entry.js +13 -0
- data/application/js/extensions.js +104 -0
- data/application/js/field.js +4 -0
- data/application/js/field_preview.js +55 -0
- data/application/js/field_types/date_field.js +16 -0
- data/application/js/field_types/file_field.js +71 -0
- data/application/js/field_types/image_field.js +358 -0
- data/application/js/field_types/markdown_field.js +656 -0
- data/application/js/field_types/string_field.js +185 -0
- data/application/js/image.js +72 -0
- data/application/js/init.js +34 -0
- data/application/js/load.js +4 -0
- data/application/js/location.js +157 -0
- data/application/js/login.js +53 -0
- data/application/js/min/492a209de8ee955fa9c729a765377495001e11b1.js +17 -0
- data/application/js/min/80f684d77c940887a1d4a63e3a96102e993baa98.js +88 -0
- data/application/js/min/b8abf302a824c35385ff517b34111e1710ff3b37.js +2 -0
- data/application/js/min/c7140ec9475e5bf868b901e0621338d7d162358b.js +3 -0
- data/application/js/min/f07f2bd6630ee31e1c2288ec223383d8f0658ba6.js +2 -0
- data/application/js/page.js +43 -0
- data/application/js/page_browser.js +147 -0
- data/application/js/page_entry.js +47 -0
- data/application/js/popover.js +99 -0
- data/application/js/popover_view.js +56 -0
- data/application/js/preview.js +64 -0
- data/application/js/progress.js +358 -0
- data/application/js/properties.js +90 -0
- data/application/js/publish.js +187 -0
- data/application/js/require.js +129 -0
- data/application/js/sharded_upload.js +206 -0
- data/application/js/side_bar.js +30 -0
- data/application/js/spontaneous.js +6 -0
- data/application/js/state.js +64 -0
- data/application/js/status_bar.js +47 -0
- data/application/js/top_bar.js +368 -0
- data/application/js/types.js +98 -0
- data/application/js/upload.js +88 -0
- data/application/js/upload_manager.js +319 -0
- data/application/js/user.js +37 -0
- data/application/js/vendor/.DS_Store +0 -0
- data/application/js/vendor/JS.Class-2.1.5/CHANGELOG +283 -0
- data/application/js/vendor/JS.Class-2.1.5/MIT-LICENSE +30 -0
- data/application/js/vendor/JS.Class-2.1.5/README +30 -0
- data/application/js/vendor/JS.Class-2.1.5/min/command.js +1 -0
- data/application/js/vendor/JS.Class-2.1.5/min/comparable.js +1 -0
- data/application/js/vendor/JS.Class-2.1.5/min/constant_scope.js +1 -0
- data/application/js/vendor/JS.Class-2.1.5/min/core.js +1 -0
- data/application/js/vendor/JS.Class-2.1.5/min/decorator.js +1 -0
- data/application/js/vendor/JS.Class-2.1.5/min/enumerable.js +1 -0
- data/application/js/vendor/JS.Class-2.1.5/min/forwardable.js +1 -0
- data/application/js/vendor/JS.Class-2.1.5/min/hash.js +1 -0
- data/application/js/vendor/JS.Class-2.1.5/min/linked_list.js +1 -0
- data/application/js/vendor/JS.Class-2.1.5/min/loader.js +1 -0
- data/application/js/vendor/JS.Class-2.1.5/min/method_chain.js +1 -0
- data/application/js/vendor/JS.Class-2.1.5/min/observable.js +1 -0
- data/application/js/vendor/JS.Class-2.1.5/min/package.js +1 -0
- data/application/js/vendor/JS.Class-2.1.5/min/proxy.js +1 -0
- data/application/js/vendor/JS.Class-2.1.5/min/ruby.js +1 -0
- data/application/js/vendor/JS.Class-2.1.5/min/set.js +1 -0
- data/application/js/vendor/JS.Class-2.1.5/min/stack_trace.js +1 -0
- data/application/js/vendor/JS.Class-2.1.5/min/state.js +1 -0
- data/application/js/vendor/JS.Class-2.1.5/min/stdlib.js +16 -0
- data/application/js/vendor/JS.Class-2.1.5/src/command.js +93 -0
- data/application/js/vendor/JS.Class-2.1.5/src/comparable.js +37 -0
- data/application/js/vendor/JS.Class-2.1.5/src/constant_scope.js +48 -0
- data/application/js/vendor/JS.Class-2.1.5/src/core.js +1060 -0
- data/application/js/vendor/JS.Class-2.1.5/src/decorator.js +50 -0
- data/application/js/vendor/JS.Class-2.1.5/src/enumerable.js +505 -0
- data/application/js/vendor/JS.Class-2.1.5/src/forwardable.js +22 -0
- data/application/js/vendor/JS.Class-2.1.5/src/hash.js +334 -0
- data/application/js/vendor/JS.Class-2.1.5/src/linked_list.js +114 -0
- data/application/js/vendor/JS.Class-2.1.5/src/loader.js +553 -0
- data/application/js/vendor/JS.Class-2.1.5/src/method_chain.js +172 -0
- data/application/js/vendor/JS.Class-2.1.5/src/observable.js +55 -0
- data/application/js/vendor/JS.Class-2.1.5/src/package.js +472 -0
- data/application/js/vendor/JS.Class-2.1.5/src/proxy.js +58 -0
- data/application/js/vendor/JS.Class-2.1.5/src/ruby.js +44 -0
- data/application/js/vendor/JS.Class-2.1.5/src/set.js +332 -0
- data/application/js/vendor/JS.Class-2.1.5/src/stack_trace.js +151 -0
- data/application/js/vendor/JS.Class-2.1.5/src/state.js +95 -0
- data/application/js/vendor/JS.Class-2.1.5/src/stdlib.js +2612 -0
- data/application/js/vendor/crypto-2.3.0-crypto.js +160 -0
- data/application/js/vendor/crypto-2.3.0-sha1.js +91 -0
- data/application/js/vendor/diff_match_patch.js +2153 -0
- data/application/js/vendor/jquery-1.4.2.min.js +154 -0
- data/application/js/vendor/jquery-1.4.3.min.js +166 -0
- data/application/js/vendor/jquery-1.5.1.min.js +16 -0
- data/application/js/vendor/jquery-1.5.1rc1.min.js +24 -0
- data/application/js/vendor/jquery-1.6.2.min.js +18 -0
- data/application/js/vendor/jquery-ui-1.8.6.custom.min.js +265 -0
- data/application/js/vendor/jquery-ui-1.8.9.custom.min.js +415 -0
- data/application/js/vendor/jquery-ui-1.8.custom.min.js +106 -0
- data/application/js/vendor/jquery.hotkeys-0.7.9.js +248 -0
- data/application/js/vendor/jquery.hotkeys-0.7.9.min.js +19 -0
- data/application/js/vendor/jsdiff.js +169 -0
- data/application/js/views/box_view.js +229 -0
- data/application/js/views/page_piece_view.js +45 -0
- data/application/js/views/page_view.js +238 -0
- data/application/js/views/piece_view.js +178 -0
- data/application/js/views.js +110 -0
- data/application/static/editing-0-noise.png +0 -0
- data/application/static/editing-1-noise.png +0 -0
- data/application/static/editing-texture-1.png +0 -0
- data/application/static/editing-texture.png +0 -0
- data/application/static/editing-toolbar-shadow-bottom.png +0 -0
- data/application/static/editing-toolbar-shadow-top.png +0 -0
- data/application/static/favicon.ico +0 -0
- data/application/static/inner-glow.png +0 -0
- data/application/static/item-buttons.png +0 -0
- data/application/static/location-arrow.png +0 -0
- data/application/static/logo-400px-transparent.png +0 -0
- data/application/static/missing.png +0 -0
- data/application/static/orange-down-arrow.png +0 -0
- data/application/static/page-browser-next.png +0 -0
- data/application/static/paper-texture-dark.png +0 -0
- data/application/static/px.gif +0 -0
- data/application/static/select-arrow-root.png +0 -0
- data/application/static/select-arrow.png +0 -0
- data/application/static/slot-down-arrow.png +0 -0
- data/application/static/splash.png +0 -0
- data/application/static/spontaneous.png +0 -0
- data/application/static/spot.png +0 -0
- data/application/static/spot.svg +40 -0
- data/application/static/texture.png +0 -0
- data/application/views/index.erubis +46 -0
- data/application/views/login.erubis +69 -0
- data/application/views/schema_modification_error.html.erb +61 -0
- data/application/views/unsupported.erubis +23 -0
- data/bin/limit-upload +5 -0
- data/bin/spot +10 -0
- data/bin/unlimit-upload +3 -0
- data/config/nginx.conf +60 -0
- data/db/migrations/20100610142136_init.rb +66 -0
- data/db/migrations/20101130104334_timestamps.rb +44 -0
- data/db/migrations/20101202113205_site_publishing_flags.rb +12 -0
- data/db/migrations/20101206124543_aliases.rb +16 -0
- data/db/migrations/20110201133550_visibility.rb +27 -0
- data/db/migrations/20110209152710_users_and_groups.rb +58 -0
- data/db/migrations/20110215133910_boxes.rb +25 -0
- data/db/migrations/20110521114145_remove_slots_and_entries.rb +21 -0
- data/db/migrations/20110604192145_rename_schema_id_columns.rb +22 -0
- data/db/migrations/20110805141925_rename_site_to_state.rb +11 -0
- data/lib/cutaneous/context_helper.rb +82 -0
- data/lib/cutaneous/first_pass_parser.rb +23 -0
- data/lib/cutaneous/first_pass_renderer.rb +18 -0
- data/lib/cutaneous/parser_core.rb +18 -0
- data/lib/cutaneous/preview_context.rb +31 -0
- data/lib/cutaneous/preview_renderer.rb +15 -0
- data/lib/cutaneous/publish_context.rb +9 -0
- data/lib/cutaneous/renderer.rb +122 -0
- data/lib/cutaneous/request_context.rb +8 -0
- data/lib/cutaneous/second_pass_parser.rb +23 -0
- data/lib/cutaneous/second_pass_renderer.rb +18 -0
- data/lib/cutaneous.rb +47 -0
- data/lib/sequel/plugins/content_table_inheritance.rb +196 -0
- data/lib/sequel/plugins/yajl_serialization.rb +154 -0
- data/lib/spontaneous/application/feature.rb +9 -0
- data/lib/spontaneous/application/plugin.rb +13 -0
- data/lib/spontaneous/application.rb +8 -0
- data/lib/spontaneous/box.rb +232 -0
- data/lib/spontaneous/box_style.rb +64 -0
- data/lib/spontaneous/change.rb +107 -0
- data/lib/spontaneous/cli/adapter.rb +13 -0
- data/lib/spontaneous/cli/base.rb +184 -0
- data/lib/spontaneous/cli/console.rb +0 -0
- data/lib/spontaneous/cli/media.rb +13 -0
- data/lib/spontaneous/cli/server.rb +50 -0
- data/lib/spontaneous/cli/site.rb +46 -0
- data/lib/spontaneous/cli/sync.rb +42 -0
- data/lib/spontaneous/cli/tasks.rb +9 -0
- data/lib/spontaneous/cli.rb +83 -0
- data/lib/spontaneous/collections/box_set.rb +56 -0
- data/lib/spontaneous/collections/change_set.rb +43 -0
- data/lib/spontaneous/collections/entry_set.rb +83 -0
- data/lib/spontaneous/collections/field_set.rb +53 -0
- data/lib/spontaneous/collections/prototype_set.rb +131 -0
- data/lib/spontaneous/collections/style_set.rb +13 -0
- data/lib/spontaneous/config.rb +156 -0
- data/lib/spontaneous/constants.rb +24 -0
- data/lib/spontaneous/content.rb +113 -0
- data/lib/spontaneous/content_query.rb +17 -0
- data/lib/spontaneous/errors.rb +48 -0
- data/lib/spontaneous/extensions/array.rb +18 -0
- data/lib/spontaneous/extensions/class.rb +17 -0
- data/lib/spontaneous/extensions/hash.rb +18 -0
- data/lib/spontaneous/extensions/json.rb +26 -0
- data/lib/spontaneous/extensions/kernel.rb +7 -0
- data/lib/spontaneous/extensions/object.rb +30 -0
- data/lib/spontaneous/extensions/object_space.rb +12 -0
- data/lib/spontaneous/extensions/string.rb +44 -0
- data/lib/spontaneous/facet.rb +47 -0
- data/lib/spontaneous/field_types/date_field.rb +12 -0
- data/lib/spontaneous/field_types/field.rb +252 -0
- data/lib/spontaneous/field_types/image_field.rb +329 -0
- data/lib/spontaneous/field_types/markdown_field.rb +37 -0
- data/lib/spontaneous/field_types/string_field.rb +14 -0
- data/lib/spontaneous/field_types.rb +40 -0
- data/lib/spontaneous/generators/page/inline.html.cut +1 -0
- data/lib/spontaneous/generators/page/page.html.cut.tt +4 -0
- data/lib/spontaneous/generators/page/page.rb.tt +9 -0
- data/lib/spontaneous/generators/page.rb +38 -0
- data/lib/spontaneous/generators/site/.gitignore +4 -0
- data/lib/spontaneous/generators/site/Gemfile.tt +31 -0
- data/lib/spontaneous/generators/site/Rakefile.tt +6 -0
- data/lib/spontaneous/generators/site/config/back.ru +7 -0
- data/lib/spontaneous/generators/site/config/boot.rb +19 -0
- data/lib/spontaneous/generators/site/config/database.yml.tt +21 -0
- data/lib/spontaneous/generators/site/config/deploy.rb.tt +0 -0
- data/lib/spontaneous/generators/site/config/environment.rb.tt +8 -0
- data/lib/spontaneous/generators/site/config/environments/development.rb.tt +15 -0
- data/lib/spontaneous/generators/site/config/environments/production.rb.tt +5 -0
- data/lib/spontaneous/generators/site/config/front.ru +8 -0
- data/lib/spontaneous/generators/site/config/user_levels.yml +22 -0
- data/lib/spontaneous/generators/site/lib/site.rb.tt +4 -0
- data/lib/spontaneous/generators/site/lib/tasks/site.rake.tt +8 -0
- data/lib/spontaneous/generators/site/public/css/site.css +0 -0
- data/lib/spontaneous/generators/site/public/favicon.ico +0 -0
- data/lib/spontaneous/generators/site/public/js/.empty_directory +0 -0
- data/lib/spontaneous/generators/site/public/js/site.js +0 -0
- data/lib/spontaneous/generators/site/public/robots.txt +0 -0
- data/lib/spontaneous/generators/site/schema/.map +1 -0
- data/lib/spontaneous/generators/site/schema/page.rb.tt +8 -0
- data/lib/spontaneous/generators/site/schema/piece.rb.tt +4 -0
- data/lib/spontaneous/generators/site/templates/layouts/standard.html.cut.tt +13 -0
- data/lib/spontaneous/generators/site.rb +77 -0
- data/lib/spontaneous/generators.rb +23 -0
- data/lib/spontaneous/image_size.rb +117 -0
- data/lib/spontaneous/json.rb +33 -0
- data/lib/spontaneous/layout.rb +15 -0
- data/lib/spontaneous/loader.rb +280 -0
- data/lib/spontaneous/logger.rb +369 -0
- data/lib/spontaneous/media.rb +84 -0
- data/lib/spontaneous/page.rb +92 -0
- data/lib/spontaneous/page_controller.rb +18 -0
- data/lib/spontaneous/page_piece.rb +77 -0
- data/lib/spontaneous/paths.rb +30 -0
- data/lib/spontaneous/permissions/access_group.rb +50 -0
- data/lib/spontaneous/permissions/access_key.rb +35 -0
- data/lib/spontaneous/permissions/user.rb +167 -0
- data/lib/spontaneous/permissions/user_level.rb +177 -0
- data/lib/spontaneous/permissions.rb +55 -0
- data/lib/spontaneous/piece.rb +30 -0
- data/lib/spontaneous/plugins/aliases.rb +128 -0
- data/lib/spontaneous/plugins/allowed_types.rb +173 -0
- data/lib/spontaneous/plugins/application/facets.rb +25 -0
- data/lib/spontaneous/plugins/application/paths.rb +137 -0
- data/lib/spontaneous/plugins/application/render.rb +29 -0
- data/lib/spontaneous/plugins/application/serialisation.rb +16 -0
- data/lib/spontaneous/plugins/application/state.rb +86 -0
- data/lib/spontaneous/plugins/boxes.rb +84 -0
- data/lib/spontaneous/plugins/controllers.rb +52 -0
- data/lib/spontaneous/plugins/entries.rb +193 -0
- data/lib/spontaneous/plugins/entry.rb +51 -0
- data/lib/spontaneous/plugins/fields.rb +103 -0
- data/lib/spontaneous/plugins/instance_code.rb +18 -0
- data/lib/spontaneous/plugins/layouts.rb +87 -0
- data/lib/spontaneous/plugins/media.rb +41 -0
- data/lib/spontaneous/plugins/page/formats.rb +67 -0
- data/lib/spontaneous/plugins/page/request.rb +89 -0
- data/lib/spontaneous/plugins/page_search.rb +64 -0
- data/lib/spontaneous/plugins/page_tree.rb +25 -0
- data/lib/spontaneous/plugins/paths.rb +125 -0
- data/lib/spontaneous/plugins/permissions.rb +63 -0
- data/lib/spontaneous/plugins/prototypes.rb +84 -0
- data/lib/spontaneous/plugins/publishing.rb +255 -0
- data/lib/spontaneous/plugins/render.rb +24 -0
- data/lib/spontaneous/plugins/schema_hierarchy.rb +76 -0
- data/lib/spontaneous/plugins/schema_id.rb +60 -0
- data/lib/spontaneous/plugins/schema_title.rb +33 -0
- data/lib/spontaneous/plugins/serialisation.rb +67 -0
- data/lib/spontaneous/plugins/site/instance.rb +22 -0
- data/lib/spontaneous/plugins/site/map.rb +19 -0
- data/lib/spontaneous/plugins/site/publishing.rb +74 -0
- data/lib/spontaneous/plugins/site/revisions.rb +28 -0
- data/lib/spontaneous/plugins/site/selectors.rb +41 -0
- data/lib/spontaneous/plugins/site_map.rb +34 -0
- data/lib/spontaneous/plugins/styles.rb +119 -0
- data/lib/spontaneous/plugins/supertype.rb +11 -0
- data/lib/spontaneous/plugins/visibility.rb +151 -0
- data/lib/spontaneous/plugins.rb +20 -0
- data/lib/spontaneous/prototypes/box_prototype.rb +168 -0
- data/lib/spontaneous/prototypes/field_prototype.rb +112 -0
- data/lib/spontaneous/prototypes/layout_prototype.rb +17 -0
- data/lib/spontaneous/prototypes/style_prototype.rb +42 -0
- data/lib/spontaneous/proxy_object.rb +12 -0
- data/lib/spontaneous/publishing/fire_and_forget.rb +57 -0
- data/lib/spontaneous/publishing/immediate.rb +197 -0
- data/lib/spontaneous/publishing/threaded.rb +25 -0
- data/lib/spontaneous/publishing.rb +10 -0
- data/lib/spontaneous/rack/around_back.rb +44 -0
- data/lib/spontaneous/rack/around_front.rb +29 -0
- data/lib/spontaneous/rack/around_preview.rb +26 -0
- data/lib/spontaneous/rack/assets.rb +98 -0
- data/lib/spontaneous/rack/back.rb +729 -0
- data/lib/spontaneous/rack/front.rb +41 -0
- data/lib/spontaneous/rack/http.rb +18 -0
- data/lib/spontaneous/rack/media.rb +29 -0
- data/lib/spontaneous/rack/public.rb +232 -0
- data/lib/spontaneous/rack/reloader.rb +42 -0
- data/lib/spontaneous/rack/static.rb +25 -0
- data/lib/spontaneous/rack.rb +55 -0
- data/lib/spontaneous/render/context.rb +100 -0
- data/lib/spontaneous/render/development_renderer.rb +14 -0
- data/lib/spontaneous/render/engine.rb +19 -0
- data/lib/spontaneous/render/format/html.rb +5 -0
- data/lib/spontaneous/render/format.rb +70 -0
- data/lib/spontaneous/render/preview_renderer.rb +18 -0
- data/lib/spontaneous/render/published_renderer.rb +54 -0
- data/lib/spontaneous/render/publishing_renderer.rb +13 -0
- data/lib/spontaneous/render/renderer.rb +46 -0
- data/lib/spontaneous/render.rb +173 -0
- data/lib/spontaneous/revision.rb +7 -0
- data/lib/spontaneous/schema/schema_modification.rb +260 -0
- data/lib/spontaneous/schema/uid.rb +221 -0
- data/lib/spontaneous/schema.rb +295 -0
- data/lib/spontaneous/server.rb +65 -0
- data/lib/spontaneous/site.rb +87 -0
- data/lib/spontaneous/state.rb +53 -0
- data/lib/spontaneous/style.rb +144 -0
- data/lib/spontaneous/tasks/database.rake +9 -0
- data/lib/spontaneous/tasks.rb +5 -0
- data/lib/spontaneous/version.rb +6 -0
- data/lib/spontaneous.rb +179 -0
- data/spontaneous.gemspec.tmpl +66 -0
- data/test/disabled/test_slots.rb +287 -0
- data/test/experimental/test_formats.rb +92 -0
- data/test/experimental/test_plugins.rb +64 -0
- data/test/fixtures/application/css/test.less +5 -0
- data/test/fixtures/application/js/test.js +1 -0
- data/test/fixtures/application/static/favicon.ico +1 -0
- data/test/fixtures/application/static/test.html +1 -0
- data/test/fixtures/application/views/index.erubis +1 -0
- data/test/fixtures/back/public/test.html +1 -0
- data/test/fixtures/back/templates/layouts/standard.html.cut +1 -0
- data/test/fixtures/config/config/environment.rb +4 -0
- data/test/fixtures/config/config/environments/development.rb +13 -0
- data/test/fixtures/config/config/environments/production.rb +22 -0
- data/test/fixtures/config/config/environments/staging.rb +2 -0
- data/test/fixtures/example_application/Gemfile +6 -0
- data/test/fixtures/example_application/Gemfile.lock +76 -0
- data/test/fixtures/example_application/Rakefile +6 -0
- data/test/fixtures/example_application/config/back.rb +15 -0
- data/test/fixtures/example_application/config/back.ru +8 -0
- data/test/fixtures/example_application/config/back.yml +8 -0
- data/test/fixtures/example_application/config/boot.rb +16 -0
- data/test/fixtures/example_application/config/database.yml +24 -0
- data/test/fixtures/example_application/config/environment.rb +4 -0
- data/test/fixtures/example_application/config/environments/development.rb +16 -0
- data/test/fixtures/example_application/config/environments/production.rb +21 -0
- data/test/fixtures/example_application/config/environments/staging.rb +1 -0
- data/test/fixtures/example_application/config/front.rb +8 -0
- data/test/fixtures/example_application/config/front.ru +8 -0
- data/test/fixtures/example_application/config/front.yml +8 -0
- data/test/fixtures/example_application/config/schema.yml +48 -0
- data/test/fixtures/example_application/config/unicorn.rb +1 -0
- data/test/fixtures/example_application/config/user_levels.yml +19 -0
- data/test/fixtures/example_application/public/css/test.css +0 -0
- data/test/fixtures/example_application/public/favicon.ico +1 -0
- data/test/fixtures/example_application/public/js/test.js +0 -0
- data/test/fixtures/example_application/public/test.html +1 -0
- data/test/fixtures/example_application/schema/client_project.rb +18 -0
- data/test/fixtures/example_application/schema/client_projects.rb +8 -0
- data/test/fixtures/example_application/schema/home_page.rb +22 -0
- data/test/fixtures/example_application/schema/info_page.rb +13 -0
- data/test/fixtures/example_application/schema/inline_image.rb +11 -0
- data/test/fixtures/example_application/schema/page.rb +4 -0
- data/test/fixtures/example_application/schema/piece.rb +3 -0
- data/test/fixtures/example_application/schema/project.rb +21 -0
- data/test/fixtures/example_application/schema/project_image.rb +18 -0
- data/test/fixtures/example_application/schema/projects_page.rb +12 -0
- data/test/fixtures/example_application/schema/text.rb +8 -0
- data/test/fixtures/example_application/templates/client_project/images.html.cut +1 -0
- data/test/fixtures/example_application/templates/client_project.html.cut +4 -0
- data/test/fixtures/example_application/templates/client_projects.html.cut +6 -0
- data/test/fixtures/example_application/templates/info_page/inline.html.cut +0 -0
- data/test/fixtures/example_application/templates/inline_image.html.cut +1 -0
- data/test/fixtures/example_application/templates/layouts/home.html.cut +15 -0
- data/test/fixtures/example_application/templates/layouts/info.html.cut +3 -0
- data/test/fixtures/example_application/templates/layouts/project.html.cut +13 -0
- data/test/fixtures/example_application/templates/layouts/projects.html.cut +11 -0
- data/test/fixtures/example_application/templates/layouts/standard.html.cut +0 -0
- data/test/fixtures/example_application/templates/project/inline.html.cut +5 -0
- data/test/fixtures/example_application/templates/project.html.cut +5 -0
- data/test/fixtures/example_application/templates/project_image.html.cut +1 -0
- data/test/fixtures/example_application/templates/text.html.cut +1 -0
- data/test/fixtures/images/rose.greyscale.jpg +0 -0
- data/test/fixtures/images/rose.jpg +0 -0
- data/test/fixtures/images/size.gif +0 -0
- data/test/fixtures/images/size.jpg +0 -0
- data/test/fixtures/images/size.png24 +0 -0
- data/test/fixtures/images/size.png8 +0 -0
- data/test/fixtures/layouts/layouts/custom1.html.cut +1 -0
- data/test/fixtures/layouts/layouts/custom1.pdf.cut +0 -0
- data/test/fixtures/layouts/layouts/custom1.xml.cut +0 -0
- data/test/fixtures/layouts/layouts/custom2.html.cut +1 -0
- data/test/fixtures/layouts/layouts/custom3.html.cut +0 -0
- data/test/fixtures/layouts/layouts/standard.html.cut +1 -0
- data/test/fixtures/media/101/003/rose.jpg +0 -0
- data/test/fixtures/permissions/config/user_levels.yml +9 -0
- data/test/fixtures/permissions/media/image.jpg +0 -0
- data/test/fixtures/plugins/schema_plugin/init.rb +1 -0
- data/test/fixtures/plugins/schema_plugin/schema/external.rb +5 -0
- data/test/fixtures/plugins/schema_plugin/templates/external.html.cut +1 -0
- data/test/fixtures/plugins/schema_plugin/templates/from_plugin.html.cut +0 -0
- data/test/fixtures/plugins/schema_plugin/templates/layouts/from_plugin.html.cut +0 -0
- data/test/fixtures/public/templates/layouts/default.html.cut +1 -0
- data/test/fixtures/public/templates/layouts/default.pdf.cut +1 -0
- data/test/fixtures/public/templates/layouts/default.rss.cut +1 -0
- data/test/fixtures/public/templates/layouts/dynamic.html.cut +1 -0
- data/test/fixtures/public/templates/layouts/standard.html.cut +0 -0
- data/test/fixtures/schema/before.yml +24 -0
- data/test/fixtures/schema/resolvable.yml +12 -0
- data/test/fixtures/schema/schema.yml +7 -0
- data/test/fixtures/serialisation/class_hash.yaml.erb +53 -0
- data/test/fixtures/serialisation/root_hash.yaml.erb +184 -0
- data/test/fixtures/sharding/rose.jpg +0 -0
- data/test/fixtures/sharding/xaa +0 -0
- data/test/fixtures/sharding/xab +0 -0
- data/test/fixtures/sharding/xac +0 -0
- data/test/fixtures/sharding/xad +0 -0
- data/test/fixtures/sharding/xae +0 -0
- data/test/fixtures/sharding/xaf +0 -0
- data/test/fixtures/sharding/xag +0 -0
- data/test/fixtures/styles/box_a/runny.html.cut +0 -0
- data/test/fixtures/styles/box_a.html.cut +1 -0
- data/test/fixtures/styles/named2.html.cut +1 -0
- data/test/fixtures/styles/orange/apple.html.cut +1 -0
- data/test/fixtures/styles/template_class/named1.html.cut +1 -0
- data/test/fixtures/styles/template_class/results.html.cut +1 -0
- data/test/fixtures/styles/template_class/walky.html.cut +0 -0
- data/test/fixtures/styles/template_class.epub.cut +0 -0
- data/test/fixtures/styles/template_class.html.cut +1 -0
- data/test/fixtures/styles/template_class.pdf.cut +0 -0
- data/test/fixtures/styles/template_sub_class1.html.cut +1 -0
- data/test/fixtures/templates/aliases/a/a_style.html.cut +0 -0
- data/test/fixtures/templates/aliases/a/page.html.cut +0 -0
- data/test/fixtures/templates/aliases/a_alias/a_alias_style.html.cut +0 -0
- data/test/fixtures/templates/aliases/layouts/b.html.cut +1 -0
- data/test/fixtures/templates/aliases/layouts/b_alias.html.cut +1 -0
- data/test/fixtures/templates/aliases/layouts/c_alias.html.cut +1 -0
- data/test/fixtures/templates/boxes/blank_content/things.html.cut +1 -0
- data/test/fixtures/templates/boxes/my_box_class/christy.html.cut +1 -0
- data/test/fixtures/templates/boxes/thangs.html.cut +1 -0
- data/test/fixtures/templates/boxes/with_template_box.html.cut +1 -0
- data/test/fixtures/templates/content/include.html.cut +1 -0
- data/test/fixtures/templates/content/include_dir.html.cut +1 -0
- data/test/fixtures/templates/content/included.epub.cut +1 -0
- data/test/fixtures/templates/content/included.html.cut +1 -0
- data/test/fixtures/templates/content/partial/included.html.cut +1 -0
- data/test/fixtures/templates/content/preprocess.html.cut +1 -0
- data/test/fixtures/templates/content/second.html.cut +1 -0
- data/test/fixtures/templates/content/template.epub.cut +1 -0
- data/test/fixtures/templates/content/template.html.cut +1 -0
- data/test/fixtures/templates/default_style_class.html.cut +1 -0
- data/test/fixtures/templates/direct.html.cut +1 -0
- data/test/fixtures/templates/extended/grandparent.html.cut +10 -0
- data/test/fixtures/templates/extended/main.html.cut +6 -0
- data/test/fixtures/templates/extended/parent.html.cut +10 -0
- data/test/fixtures/templates/layouts/entries.html.cut +7 -0
- data/test/fixtures/templates/layouts/page_style.html.cut +1 -0
- data/test/fixtures/templates/layouts/params.html.cut +1 -0
- data/test/fixtures/templates/layouts/preview_render.html.cut +2 -0
- data/test/fixtures/templates/layouts/standard_page.html.cut +1 -0
- data/test/fixtures/templates/layouts/subdir_style.html.cut +1 -0
- data/test/fixtures/templates/layouts/template_params.html.cut +1 -0
- data/test/fixtures/templates/page_class/inline_style.html.cut +1 -0
- data/test/fixtures/templates/preview_render/inline.html.cut +0 -0
- data/test/fixtures/templates/publishing/layouts/dynamic.html.cut +1 -0
- data/test/fixtures/templates/publishing/layouts/static.html.cut +1 -0
- data/test/fixtures/templates/template_class/anonymous_style.html.cut +4 -0
- data/test/fixtures/templates/template_class/another_template.html.cut +0 -0
- data/test/fixtures/templates/template_class/complex_template.html.cut +6 -0
- data/test/fixtures/templates/template_class/complex_template.pdf.cut +6 -0
- data/test/fixtures/templates/template_class/default_template_style.html.cut +4 -0
- data/test/fixtures/templates/template_class/images_with_template.html.cut +5 -0
- data/test/fixtures/templates/template_class/slots_template.html.cut +5 -0
- data/test/fixtures/templates/template_class/slots_template.pdf.cut +5 -0
- data/test/fixtures/templates/template_class/this_template.epub.cut +1 -0
- data/test/fixtures/templates/template_class/this_template.html.cut +1 -0
- data/test/fixtures/templates/template_class/this_template.pdf.cut +1 -0
- data/test/fixtures/templates/with_default_style_class.html.cut +1 -0
- data/test/functional/test_application.rb +176 -0
- data/test/functional/test_back.rb +902 -0
- data/test/functional/test_front.rb +571 -0
- data/test/javascript/test_dom.rb +94 -0
- data/test/javascript/test_markdown.rb +97 -0
- data/test/slow/test_publishing.rb +987 -0
- data/test/slow/test_visibility.rb +250 -0
- data/test/support/custom_matchers.rb +77 -0
- data/test/support/timing.rb +23 -0
- data/test/test_helper.rb +164 -0
- data/test/test_javascript.rb +34 -0
- data/test/ui/test_page_editing.rb +167 -0
- data/test/ui_helper.rb +114 -0
- data/test/unit/test_alias.rb +254 -0
- data/test/unit/test_authentication.rb +510 -0
- data/test/unit/test_boxes.rb +497 -0
- data/test/unit/test_config.rb +156 -0
- data/test/unit/test_content.rb +221 -0
- data/test/unit/test_content_inheritance.rb +103 -0
- data/test/unit/test_extensions.rb +14 -0
- data/test/unit/test_fields.rb +392 -0
- data/test/unit/test_generators.rb +97 -0
- data/test/unit/test_image_size.rb +25 -0
- data/test/unit/test_images.rb +265 -0
- data/test/unit/test_layouts.rb +111 -0
- data/test/unit/test_logger.rb +80 -0
- data/test/unit/test_media.rb +70 -0
- data/test/unit/test_page.rb +244 -0
- data/test/unit/test_permissions.rb +834 -0
- data/test/unit/test_piece.rb +80 -0
- data/test/unit/test_prototype_set.rb +192 -0
- data/test/unit/test_prototypes.rb +102 -0
- data/test/unit/test_render.rb +359 -0
- data/test/unit/test_schema.rb +1009 -0
- data/test/unit/test_serialisation.rb +215 -0
- data/test/unit/test_site.rb +145 -0
- data/test/unit/test_structure.rb +85 -0
- data/test/unit/test_styles.rb +417 -0
- data/test/unit/test_templates.rb +224 -0
- data/test/unit/test_type_hierarchy.rb +28 -0
- metadata +1017 -0
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
// console.log("Loading UploadManager...");
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
Spontaneous.UploadManager = (function($, S) {
|
|
5
|
+
var dom = S.Dom;
|
|
6
|
+
var Upload = S.Upload;
|
|
7
|
+
// var upload_id = (new Date()).valueOf();
|
|
8
|
+
// var Upload = new JS.Class({
|
|
9
|
+
// initialize: function(manager, target, file) {
|
|
10
|
+
// this.manager = manager;
|
|
11
|
+
// this.field_name = target.schema_id();
|
|
12
|
+
// this.uid = target.uid();
|
|
13
|
+
// this.target = target;
|
|
14
|
+
// this.target_id = target.id();
|
|
15
|
+
// this._position = 0;
|
|
16
|
+
// this.failure_count = 0;
|
|
17
|
+
// this.file = file;
|
|
18
|
+
// this.name = this.file.fileName;
|
|
19
|
+
// this._total = this.file.size;
|
|
20
|
+
// this.complete = false;
|
|
21
|
+
// this.upload_id = upload_id++;
|
|
22
|
+
// },
|
|
23
|
+
// position: function() {
|
|
24
|
+
// return this._position;
|
|
25
|
+
// },
|
|
26
|
+
// total: function() {
|
|
27
|
+
// return this._total;
|
|
28
|
+
// },
|
|
29
|
+
// start: function() {
|
|
30
|
+
// var form = new FormData();
|
|
31
|
+
// form.append('file', this.file);
|
|
32
|
+
// form.append('field', this.field_name);
|
|
33
|
+
// form.append('version', this.target.data.version);
|
|
34
|
+
// this.post("/file/replace/"+this.target_id, form);
|
|
35
|
+
// },
|
|
36
|
+
|
|
37
|
+
// post: function(url, form_data) {
|
|
38
|
+
// this.xhr = new XMLHttpRequest();
|
|
39
|
+
// this.upload = this.xhr.upload;
|
|
40
|
+
// this.xhr.open("POST", this.namespaced_path(url), true);
|
|
41
|
+
// this.upload.onprogress = this.onprogress.bind(this);
|
|
42
|
+
// this.upload.onload = this.onload.bind(this);
|
|
43
|
+
// this.upload.onloadend = this.onloadend.bind(this);
|
|
44
|
+
// this.upload.onerror = this.onerror.bind(this);
|
|
45
|
+
// this.xhr.onreadystatechange = this.onreadystatechange.bind(this);
|
|
46
|
+
// this.started = (new Date()).valueOf();
|
|
47
|
+
// this.xhr.send(form_data);
|
|
48
|
+
// },
|
|
49
|
+
// namespaced_path: function(path) {
|
|
50
|
+
// return S.Ajax.request_url(path, true);
|
|
51
|
+
// },
|
|
52
|
+
// // While loading and sending data.
|
|
53
|
+
// onprogress: function(event) {
|
|
54
|
+
// var position = event.position;
|
|
55
|
+
// this._position = position;
|
|
56
|
+
// this.time = (new Date()).valueOf() - this.started;
|
|
57
|
+
// this.manager.upload_progress(this);
|
|
58
|
+
// },
|
|
59
|
+
// // When the request has successfully completed.
|
|
60
|
+
// onload: function(event) {
|
|
61
|
+
// },
|
|
62
|
+
// // When the request has completed (either in success or failure).
|
|
63
|
+
// onloadend: function(event) {
|
|
64
|
+
// this.manager.upload_failed(this, event);
|
|
65
|
+
// },
|
|
66
|
+
// onreadystatechange: function(event) {
|
|
67
|
+
// var xhr = event.currentTarget;
|
|
68
|
+
// if (xhr.readyState == 4) {
|
|
69
|
+
// if (xhr.status === 200) {
|
|
70
|
+
// if (!this.complete) {
|
|
71
|
+
// var result = JSON.parse(xhr.responseText);
|
|
72
|
+
// this.manager.upload_complete(this, result);
|
|
73
|
+
// this.complete = true;
|
|
74
|
+
// }
|
|
75
|
+
// } else if (xhr.status === 409) {
|
|
76
|
+
// this.manager.upload_conflict(this, event);
|
|
77
|
+
// }
|
|
78
|
+
// }
|
|
79
|
+
// },
|
|
80
|
+
|
|
81
|
+
// onerror: function(event) {
|
|
82
|
+
// this.failure_count++;
|
|
83
|
+
// this.manager.upload_failed(this, event);
|
|
84
|
+
// }
|
|
85
|
+
// });
|
|
86
|
+
var WrapUpload = new JS.Class(Upload, {
|
|
87
|
+
start: function() {
|
|
88
|
+
var form = new FormData();
|
|
89
|
+
form.append('file', this.file);
|
|
90
|
+
this.post(["/file/wrap", this.target_id].join('/'), form);
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
var ShardedWrapUpload = new JS.Class(S.ShardedUpload, {
|
|
94
|
+
path: function() {
|
|
95
|
+
return ["/shard/wrap", this.target_id].join('/');
|
|
96
|
+
},
|
|
97
|
+
});
|
|
98
|
+
var FormUpload = new JS.Class(Upload, {
|
|
99
|
+
initialize: function(manager, target, form_data, size) {
|
|
100
|
+
this.callSuper(manager, target, form_data)
|
|
101
|
+
this.form_data = this.file;
|
|
102
|
+
this._total = size;
|
|
103
|
+
this.name = "Saving...";
|
|
104
|
+
},
|
|
105
|
+
start: function() {
|
|
106
|
+
this.post(this.target.save_path(), this.form_data);
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
var UploadManager = {
|
|
110
|
+
init: function(status_bar) {
|
|
111
|
+
this.status_bar = status_bar;
|
|
112
|
+
this.pending = [];
|
|
113
|
+
this.completed = [];
|
|
114
|
+
this.failed = [];
|
|
115
|
+
this.current = null;
|
|
116
|
+
this.updater = null;
|
|
117
|
+
this.total_time = 0;
|
|
118
|
+
this.total_data = 0;
|
|
119
|
+
this.targets = {};
|
|
120
|
+
},
|
|
121
|
+
// call to append call for image replacement to queue
|
|
122
|
+
add: function(target, upload) {
|
|
123
|
+
this.pending.push(upload);
|
|
124
|
+
this.register(target);
|
|
125
|
+
},
|
|
126
|
+
register: function(target) {
|
|
127
|
+
this.targets[target.uid()] = target;
|
|
128
|
+
},
|
|
129
|
+
unregister: function(target) {
|
|
130
|
+
delete this.targets[target.uid()];
|
|
131
|
+
},
|
|
132
|
+
replace: function(field, file) {
|
|
133
|
+
var uploader_class = Upload;
|
|
134
|
+
if (S.ShardedUpload.supported()) {
|
|
135
|
+
console.log('Using sharded uploader')
|
|
136
|
+
uploader_class = S.ShardedUpload;
|
|
137
|
+
}
|
|
138
|
+
this.add(field, new uploader_class(this, field, file))
|
|
139
|
+
if (!this.current) {
|
|
140
|
+
this.next();
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
// call to wrap files
|
|
144
|
+
wrap: function(slot, files) {
|
|
145
|
+
for (var i = 0, ii = files.length; i < ii; i++) {
|
|
146
|
+
var file = files[i], upload, upload_class = WrapUpload;
|
|
147
|
+
if (S.ShardedUpload.supported()) {
|
|
148
|
+
console.log('Using sharded uploader')
|
|
149
|
+
upload_class = ShardedWrapUpload;
|
|
150
|
+
}
|
|
151
|
+
upload = new upload_class(this, slot, file);
|
|
152
|
+
this.add(slot, upload)
|
|
153
|
+
}
|
|
154
|
+
if (!this.current) {
|
|
155
|
+
this.next();
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
form: function(content, form_data, file_size) {
|
|
159
|
+
var upload = new FormUpload(this, content, form_data, file_size);
|
|
160
|
+
this.add(content, upload)
|
|
161
|
+
if (!this.current) {
|
|
162
|
+
this.next();
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
next: function() {
|
|
166
|
+
if (this.current) { return; }
|
|
167
|
+
if (this.pending.length === 0) {
|
|
168
|
+
// the download queue is complete
|
|
169
|
+
if (this.failed.length === 0) {
|
|
170
|
+
this.finished();
|
|
171
|
+
} else {
|
|
172
|
+
var upload = this.failed.pop(), delay = Math.pow(2, upload.failure_count);
|
|
173
|
+
console.log("UploadManager.next", "scheduling re-try of failed upload after", delay, "seconds");
|
|
174
|
+
this.pending.push(upload);
|
|
175
|
+
window.setTimeout(function() {
|
|
176
|
+
console.log("UploadManager.next", "re-trying failed upload");
|
|
177
|
+
this.next();
|
|
178
|
+
}.bind(this), delay * 1000);
|
|
179
|
+
}
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
this.init_progress_bar();
|
|
183
|
+
this.current = this.pending.shift();
|
|
184
|
+
this.bars.name.text(this.current.name);
|
|
185
|
+
this.current.start();
|
|
186
|
+
},
|
|
187
|
+
finished: function() {
|
|
188
|
+
// console.log('UploadManager.finished', this.pending);
|
|
189
|
+
this.completed = [];
|
|
190
|
+
this.status_bar.hide();
|
|
191
|
+
},
|
|
192
|
+
init_progress_bar: function() {
|
|
193
|
+
this.status_bar.show();
|
|
194
|
+
if (this.progress_showing) { return; }
|
|
195
|
+
var c = this.status_bar.progress_container();
|
|
196
|
+
var outer = dom.div('#progress-bars');
|
|
197
|
+
var total = dom.div('#progress-total.bar');
|
|
198
|
+
var individual = dom.div('#progress-individual.bar');
|
|
199
|
+
var name = dom.div('#progress-name');
|
|
200
|
+
var stats = dom.div('#progress-stats');
|
|
201
|
+
outer.append(individual);
|
|
202
|
+
outer.append(total);
|
|
203
|
+
c.append(outer);
|
|
204
|
+
c.append(name).append(stats);
|
|
205
|
+
this.bars = {
|
|
206
|
+
total: total,
|
|
207
|
+
individual: individual,
|
|
208
|
+
name: name,
|
|
209
|
+
stats: stats
|
|
210
|
+
};
|
|
211
|
+
this.progress_showing = true;
|
|
212
|
+
},
|
|
213
|
+
data_total: function() {
|
|
214
|
+
var total = 0;
|
|
215
|
+
for (var i = 0, ii = this.completed.length; i < ii; i++) {
|
|
216
|
+
total += this.completed[i].total();
|
|
217
|
+
}
|
|
218
|
+
for (var i = 0, ii = this.pending.length; i < ii; i++) {
|
|
219
|
+
total += this.pending[i].total();
|
|
220
|
+
}
|
|
221
|
+
if (this.current) {
|
|
222
|
+
total += this.current.total();
|
|
223
|
+
}
|
|
224
|
+
return total;
|
|
225
|
+
},
|
|
226
|
+
data_completed: function() {
|
|
227
|
+
var completed = 0;
|
|
228
|
+
for (var i = 0, ii = this.completed.length; i < ii; i++) {
|
|
229
|
+
completed += this.completed[i].total();
|
|
230
|
+
}
|
|
231
|
+
if (this.current) {
|
|
232
|
+
completed += this.current.position();
|
|
233
|
+
}
|
|
234
|
+
return completed;
|
|
235
|
+
},
|
|
236
|
+
update_progress_bars: function() {
|
|
237
|
+
var total = this.data_total(), completed = this.data_completed();
|
|
238
|
+
completed = Math.min(total, completed);
|
|
239
|
+
|
|
240
|
+
this.set_bar_length('total', completed, total);
|
|
241
|
+
if (this.current) {
|
|
242
|
+
this.set_bar_length('individual', this.current.position, this.current.total);
|
|
243
|
+
this.bars.stats.text([this.rate(), 'Kb\/s', this.time_estimate()].join(' '));
|
|
244
|
+
} else {
|
|
245
|
+
this.set_bar_length('individual', 0, 0);
|
|
246
|
+
}
|
|
247
|
+
},
|
|
248
|
+
rate: function() {
|
|
249
|
+
var t = this.total_time, d = this.total_data;
|
|
250
|
+
if (this.current) {
|
|
251
|
+
t += this.current.time;
|
|
252
|
+
d += this.current.position();
|
|
253
|
+
}
|
|
254
|
+
return Math.round(((d/1024)/(t/1000)*10)/10);
|
|
255
|
+
},
|
|
256
|
+
time_estimate: function() {
|
|
257
|
+
var remaining = this.data_total() - this.data_completed();
|
|
258
|
+
var time = (remaining/1024) / this.rate();
|
|
259
|
+
return (Math.round(time)) + 's';
|
|
260
|
+
},
|
|
261
|
+
set_bar_length: function(bar_name, position, total) {
|
|
262
|
+
var bar = this.bars[bar_name], percent = (position/total) * 100;
|
|
263
|
+
bar.css('width', percent+"%");
|
|
264
|
+
},
|
|
265
|
+
upload_progress: function(upload) {
|
|
266
|
+
if (upload !== this.current) {
|
|
267
|
+
console.warn("UploadManager#upload_progress", "completed upload does not match current")
|
|
268
|
+
}
|
|
269
|
+
var target = this.targets[upload.uid];
|
|
270
|
+
if (target) {
|
|
271
|
+
target.upload_progress(upload.position(), upload.total());
|
|
272
|
+
}
|
|
273
|
+
this.update_progress_bars();
|
|
274
|
+
},
|
|
275
|
+
upload_complete: function(upload, result) {
|
|
276
|
+
if (upload !== this.current) {
|
|
277
|
+
console.warn("UploadManager#upload_complete", "completed upload does not match current")
|
|
278
|
+
}
|
|
279
|
+
this.completed.push(this.current);
|
|
280
|
+
this.total_time += this.current.time;
|
|
281
|
+
this.total_data += this.current.position();
|
|
282
|
+
var target = this.targets[upload.uid];
|
|
283
|
+
if (target) {
|
|
284
|
+
target.upload_complete(result);
|
|
285
|
+
}
|
|
286
|
+
this.current = null;
|
|
287
|
+
this.next();
|
|
288
|
+
},
|
|
289
|
+
upload_failed: function(upload, event) {
|
|
290
|
+
if (upload !== this.current) {
|
|
291
|
+
console.warn("UploadManager#upload_complete", "completed upload does not match current")
|
|
292
|
+
}
|
|
293
|
+
this.failed.push(this.current);
|
|
294
|
+
var target = this.targets[upload.uid];
|
|
295
|
+
if (target) {
|
|
296
|
+
target.upload_failed(event);
|
|
297
|
+
}
|
|
298
|
+
this.current = null;
|
|
299
|
+
console.error("UploadManager#upload_failed", upload, this.failed)
|
|
300
|
+
this.next();
|
|
301
|
+
},
|
|
302
|
+
upload_conflict: function(upload, event) {
|
|
303
|
+
if (upload !== this.current) {
|
|
304
|
+
console.warn("UploadManager#upload_complete", "completed upload does not match current")
|
|
305
|
+
}
|
|
306
|
+
var target = this.targets[upload.uid];
|
|
307
|
+
if (target) {
|
|
308
|
+
target.upload_conflict($.parseJSON(event.currentTarget.response));
|
|
309
|
+
}
|
|
310
|
+
this.current = null;
|
|
311
|
+
console.error("UploadManager#upload_conflict", upload, event)
|
|
312
|
+
this.next();
|
|
313
|
+
},
|
|
314
|
+
FormUpload: FormUpload,
|
|
315
|
+
WrapUpload: WrapUpload
|
|
316
|
+
};
|
|
317
|
+
return UploadManager;
|
|
318
|
+
}(jQuery, Spontaneous));
|
|
319
|
+
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// console.log('Loading User...')
|
|
2
|
+
|
|
3
|
+
Spontaneous.User = (function($, S) {
|
|
4
|
+
var User = new JS.Class({
|
|
5
|
+
initialize: function(user_data) {
|
|
6
|
+
this.attrs = user_data;
|
|
7
|
+
},
|
|
8
|
+
name: function() {
|
|
9
|
+
return this.attrs.name;
|
|
10
|
+
},
|
|
11
|
+
email: function() {
|
|
12
|
+
return this.attrs.email;
|
|
13
|
+
},
|
|
14
|
+
login: function() {
|
|
15
|
+
return this.attrs.login;
|
|
16
|
+
},
|
|
17
|
+
is_developer: function() {
|
|
18
|
+
return this.attrs.developer;
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
var instance = new JS.Singleton({
|
|
23
|
+
include: Spontaneous.Properties,
|
|
24
|
+
load: function() {
|
|
25
|
+
S.Ajax.get('/user', this.loaded.bind(this));
|
|
26
|
+
},
|
|
27
|
+
loaded: function(user_data) {
|
|
28
|
+
this.user = new User(user_data);
|
|
29
|
+
this.set('user', this.user);
|
|
30
|
+
},
|
|
31
|
+
name: function() { return this.user.name(); },
|
|
32
|
+
email: function() { return this.user.email(); },
|
|
33
|
+
login: function() { return this.user.login(); },
|
|
34
|
+
is_developer: function() { return this.user.is_developer(); }
|
|
35
|
+
});
|
|
36
|
+
return instance;
|
|
37
|
+
}(jQuery, Spontaneous));
|
|
Binary file
|
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
Version 2.1.5
|
|
2
|
+
June 5 2010
|
|
3
|
+
================================================================
|
|
4
|
+
|
|
5
|
+
* Adds support for Node, Narwhal and Windows Script Host to the
|
|
6
|
+
JS.Package loading system.
|
|
7
|
+
|
|
8
|
+
* Adds an `autoload` macro to the package system for quickly
|
|
9
|
+
configuring modules using filename conventions.
|
|
10
|
+
|
|
11
|
+
* Renames `require()` to `JS.require()` so as not to conflict
|
|
12
|
+
with CommonJS module API.
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
Version 2.1.4
|
|
16
|
+
March 9 2010
|
|
17
|
+
================================================================
|
|
18
|
+
|
|
19
|
+
* Rewritten the package loader to use event listeners to trigger
|
|
20
|
+
loading of dependencies rather than polling for readiness.
|
|
21
|
+
|
|
22
|
+
* package.js and loader.js no longer depend on or include the
|
|
23
|
+
JS.Class core; you must call `require()` to use JS.Class,
|
|
24
|
+
JS.Module, JS.Interface or JS.Singleton.
|
|
25
|
+
|
|
26
|
+
* Fix bug in browser package loader in environments that have
|
|
27
|
+
a global `console` object with no `info()` method.
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
Version 2.1.3
|
|
31
|
+
October 10 2009
|
|
32
|
+
================================================================
|
|
33
|
+
|
|
34
|
+
* Fixes the load() function in the Packages DSL, and adds some
|
|
35
|
+
caching to improve lookup times for finding a package by the
|
|
36
|
+
name of its provided objects.
|
|
37
|
+
|
|
38
|
+
* Non-existent package errors are now defered until you require()
|
|
39
|
+
an object rather than being thrown at package definition time.
|
|
40
|
+
This means require() won't complain about being passed native
|
|
41
|
+
objects or objects loaded by other means, as long as the
|
|
42
|
+
required object does actually exist.
|
|
43
|
+
|
|
44
|
+
* MethodChain now adds instance methods from Modules, and adds
|
|
45
|
+
methods that were defined *before* MethodChain was loaded.
|
|
46
|
+
|
|
47
|
+
* State now supports callSuper() to state methods imported from
|
|
48
|
+
mixins; previously you could only callSuper() to the superclass.
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
Version 2.1.2
|
|
52
|
+
August 11 2009
|
|
53
|
+
================================================================
|
|
54
|
+
|
|
55
|
+
* LinkedList was defined twice in the stdlib.js bundle; this
|
|
56
|
+
is now fixed [thanks @skim].
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
Version 2.1.1
|
|
60
|
+
July 6 2009
|
|
61
|
+
================================================================
|
|
62
|
+
|
|
63
|
+
* Fixes a couple of Set bugs: Set#isProperSuperset had a missing
|
|
64
|
+
argument, and incomparable objects were being allowed into
|
|
65
|
+
SortedSet collections.
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
Version 2.1.0
|
|
69
|
+
June 8 2009
|
|
70
|
+
================================================================
|
|
71
|
+
|
|
72
|
+
* New libraries: ConstantScope, Hash, HashSet.
|
|
73
|
+
|
|
74
|
+
* Improved package manager, supports parallel downloads in
|
|
75
|
+
web browsers and now also works on server-side platforms
|
|
76
|
+
(tested on SpiderMonkey, Rhino and V8). Also supports custom
|
|
77
|
+
loader functions for integration with Google, YUI etc.
|
|
78
|
+
|
|
79
|
+
* Enumerable updated with Ruby 1.9 methods, enumerators, and
|
|
80
|
+
Symbol#to_proc functionality when passing strings to iterators.
|
|
81
|
+
Any object with a toFunction() method can be used as an iterator.
|
|
82
|
+
Search methods now use equals() where possible.
|
|
83
|
+
|
|
84
|
+
* ObjectMethods module is now called Kernel.
|
|
85
|
+
|
|
86
|
+
* New Kernel methods: tap(), equals(), hash(), enumFor() and methods(),
|
|
87
|
+
and new Module methods: instanceMethods() and match().
|
|
88
|
+
|
|
89
|
+
* The double inclusion problem is now fixed, i.e. the following
|
|
90
|
+
works in JS.Class 2.1:
|
|
91
|
+
|
|
92
|
+
A = new JS.Module();
|
|
93
|
+
C = new JS.Class({ include: A });
|
|
94
|
+
B = new JS.Module({ foo: function() { return 'B#foo' } });
|
|
95
|
+
A.include(B);
|
|
96
|
+
D = new JS.Class({ include: A });
|
|
97
|
+
|
|
98
|
+
new C().foo() // -> 'B#foo'
|
|
99
|
+
new D().foo() // -> 'B#foo'
|
|
100
|
+
|
|
101
|
+
(See http://eigenclass.org/hiki/The+double+inclusion+problem)
|
|
102
|
+
|
|
103
|
+
* Ancestor and method lookups are cached for improved performance.
|
|
104
|
+
|
|
105
|
+
* Automatic generation of displayName on methods for integration
|
|
106
|
+
with the WebKit debugger.
|
|
107
|
+
|
|
108
|
+
* API change: Set#classify now returns a Hash, not an Object.
|
|
109
|
+
|
|
110
|
+
* PDoc documentation for the core classes.
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
Version 1.6.3
|
|
114
|
+
March 4 2009
|
|
115
|
+
================================================================
|
|
116
|
+
|
|
117
|
+
* Fixes a bug caused by Function#prototype becoming a non-
|
|
118
|
+
enumerable property in Safari 4, causing classes to inherit
|
|
119
|
+
from themselves and leading to stack overflows.
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
Version 2.0.2
|
|
123
|
+
October 1 2008
|
|
124
|
+
================================================================
|
|
125
|
+
|
|
126
|
+
* The function returned by object.method('callSuper') now behaves
|
|
127
|
+
correctly when called after the containing method has returned.
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
Version 1.6.2
|
|
131
|
+
October 1 2008
|
|
132
|
+
================================================================
|
|
133
|
+
|
|
134
|
+
* Fixes some bugs to make various forEach() methods more robust.
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
Version 2.0.1
|
|
138
|
+
September 14 2008
|
|
139
|
+
================================================================
|
|
140
|
+
|
|
141
|
+
* Fixes a super()-related bug in Command.
|
|
142
|
+
|
|
143
|
+
* Better handling of 'include' and 'extend' directives such
|
|
144
|
+
that these are processed before all the other methods are
|
|
145
|
+
added. This allows mixins to override parts of the including
|
|
146
|
+
class to affect future method definitions.
|
|
147
|
+
|
|
148
|
+
* Module#include() has been fixed so that overriding it produces
|
|
149
|
+
more sane behaviour with respect to classes that delegate to
|
|
150
|
+
a module behind the scenes to store methods.
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
Version 2.0.0
|
|
154
|
+
August 12 2008
|
|
155
|
+
================================================================
|
|
156
|
+
|
|
157
|
+
* Complete rewrite of the core, including a proper implementation
|
|
158
|
+
of Modules with all inheritance semantics based around this.
|
|
159
|
+
Ruby-style multiple inheritance now works correctly, and
|
|
160
|
+
callSuper() can call methods from mixins.
|
|
161
|
+
|
|
162
|
+
* Class and Module are now classes, and must be created using
|
|
163
|
+
the 'new' keyword.
|
|
164
|
+
|
|
165
|
+
* Some backward compatibility breaks; see http://jsclass.jcoglan.com/upgrade.html
|
|
166
|
+
|
|
167
|
+
* New method: Object#__eigen__() returns an object's metaclass.
|
|
168
|
+
|
|
169
|
+
* Performance of super() calls is much improved.
|
|
170
|
+
|
|
171
|
+
* New libraries: Package, Set, SortedSet and StackTrace.
|
|
172
|
+
|
|
173
|
+
* Package provides a dependency-aware system for loading new
|
|
174
|
+
JavaScript files on demand.
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
Version 1.6.1
|
|
178
|
+
April 17 2008
|
|
179
|
+
================================================================
|
|
180
|
+
|
|
181
|
+
* Fixes bug in Decorator and Proxy.Virtual caused by the 'klass'
|
|
182
|
+
property being treated as a method and delegated.
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
Version 1.6.0
|
|
186
|
+
April 10 2008
|
|
187
|
+
================================================================
|
|
188
|
+
|
|
189
|
+
* Adds a DSL for defining classes in a more Ruby-like way using
|
|
190
|
+
procedures rather than declarations (experimental).
|
|
191
|
+
|
|
192
|
+
* New libraries: Forwardable, State.
|
|
193
|
+
|
|
194
|
+
* The extended() hook is now supported.
|
|
195
|
+
|
|
196
|
+
* The 'implement' directive is no longer supported.
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
Version 1.5.0
|
|
200
|
+
February 25 2008
|
|
201
|
+
================================================================
|
|
202
|
+
|
|
203
|
+
* Adds a standard library, including Command, Comparable,
|
|
204
|
+
Decorator, Enumerable, LinkedList, MethodChain, Observable
|
|
205
|
+
and Proxy.Virtual.
|
|
206
|
+
|
|
207
|
+
* Renames _super() to callSuper() to avoid problems with PackR's
|
|
208
|
+
private variable shrinking.
|
|
209
|
+
|
|
210
|
+
* Adds an Object#wait() method that calls a MethodChain on the
|
|
211
|
+
object using setTimeout().
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
Version 1.0.1
|
|
215
|
+
January 14 2008
|
|
216
|
+
================================================================
|
|
217
|
+
|
|
218
|
+
* Memoizes calls to Object#method() so that the same function
|
|
219
|
+
object is returned each time.
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
Version 1.0.0
|
|
223
|
+
January 4 2008
|
|
224
|
+
================================================================
|
|
225
|
+
|
|
226
|
+
* Singleton methods that call super() are now supported.
|
|
227
|
+
|
|
228
|
+
* Object#is_a() has been renamed to Object#isA().
|
|
229
|
+
|
|
230
|
+
* Classes now support inherited() and included() hooks.
|
|
231
|
+
|
|
232
|
+
* Adds Interface class for easier duck-typing checks across
|
|
233
|
+
several methods.
|
|
234
|
+
|
|
235
|
+
* New directive 'implement' can be used to check that a class
|
|
236
|
+
implements some interfaces.
|
|
237
|
+
|
|
238
|
+
* Singletons are now supported as class-like definitions that
|
|
239
|
+
yield a single object.
|
|
240
|
+
|
|
241
|
+
* Module has been added as a way to protect sets of methods by
|
|
242
|
+
wrapping them in a closure.
|
|
243
|
+
|
|
244
|
+
* Removes the bindMethods class flag in favour of the more
|
|
245
|
+
efficient and Ruby-like Ojbect#method(). This can also be
|
|
246
|
+
used on classes to get bound class methods.
|
|
247
|
+
|
|
248
|
+
* Exceptions thrown while calling super are no longer swallowed
|
|
249
|
+
inside the framework.
|
|
250
|
+
|
|
251
|
+
* Class#method() is now Class#instanceMethod.
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
Version 0.9.2
|
|
255
|
+
November 13 2007
|
|
256
|
+
================================================================
|
|
257
|
+
|
|
258
|
+
* Fixes bug caused by multiple methods in the same call stack
|
|
259
|
+
clobbering _super().
|
|
260
|
+
|
|
261
|
+
* Fixes some inheritance bugs related to class methods and
|
|
262
|
+
built-in instance methods.
|
|
263
|
+
|
|
264
|
+
* Improves performance by bootstrapping JavaScript's prototypes
|
|
265
|
+
for instance method inheritance.
|
|
266
|
+
|
|
267
|
+
* Allows inheritance from non-JS.Class-based classes.
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
Version 0.9.1
|
|
271
|
+
November 12 2007
|
|
272
|
+
================================================================
|
|
273
|
+
|
|
274
|
+
* Improves performance by checking whether methods use _super()
|
|
275
|
+
and only wrapping where necessary.
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
Version 0.9.0
|
|
279
|
+
November 11 2007
|
|
280
|
+
================================================================
|
|
281
|
+
|
|
282
|
+
* Initial release. Features single inheritance and _super().
|
|
283
|
+
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
JS.Class: Ruby-style JavaScript
|
|
2
|
+
Copyright (c) 2007-2010 James Coglan
|
|
3
|
+
|
|
4
|
+
http://jsclass.jcoglan.com
|
|
5
|
+
http://github.com/jcoglan/js.class
|
|
6
|
+
|
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
in the Software without restriction, including without limitation the rights
|
|
10
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
furnished to do so, subject to the following conditions:
|
|
13
|
+
|
|
14
|
+
The above copyright notice and this permission notice shall be included in
|
|
15
|
+
all copies or substantial portions of the Software.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
23
|
+
THE SOFTWARE.
|
|
24
|
+
|
|
25
|
+
Parts of this software are derived from the following open-source projects:
|
|
26
|
+
|
|
27
|
+
- The Prototype framework, (c) 2005-2010 Sam Stephenson
|
|
28
|
+
- Alex Arnell's Inheritance library, (c) 2006, Alex Arnell
|
|
29
|
+
- Base, (c) 2006-9, Dean Edwards
|
|
30
|
+
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
JS.Class - Ruby-style JavaScript
|
|
2
|
+
===
|
|
3
|
+
|
|
4
|
+
http://jsclass.jcoglan.com
|
|
5
|
+
|
|
6
|
+
JS.Class is a JavaScript library for building object-oriented programs using Ruby
|
|
7
|
+
idioms. It implements Ruby's core object/module/class system in JavaScript, as well
|
|
8
|
+
as several standard Ruby libraries and various other extensions.
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
Distribution files
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
The distribution contains the following files:
|
|
15
|
+
|
|
16
|
+
* `core.js` - contains `Class`, `Module`, `Kernel`, `Singleton` and `Interface`
|
|
17
|
+
* `loader.js` - the `Package` system and dependency data for the core object
|
|
18
|
+
system and the standard library.
|
|
19
|
+
* `stdlib.js` - the whole standard library in one file
|
|
20
|
+
|
|
21
|
+
The remaining files should be self-explanatory; each contains a single piece of the
|
|
22
|
+
standard library; see [the website](http://jsclass.jcoglan.com) for documentation.
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
License
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
Distributed under the MIT license.
|
|
29
|
+
Copyright (c) 2007-2010 James Coglan
|
|
30
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
JS.Command=new JS.Class('Command',{initialize:function(a){if(JS.isFn(a))a={execute:a};this._2=a;this._0=this._2.stack||null},execute:function(a){if(this._0)this._0._3();var b=this._2.execute;if(b)b.apply(this);if(this._0&&a!==false)this._0.push(this)},undo:function(){var exec=this._2.undo;if(exec)exec.apply(this)},extend:{Stack:new JS.Class({include:[JS.Observable||{},JS.Enumerable||{}],initialize:function(a){a=a||{};this._1=a.redo||null;this.clear()},forEach:function(a,b){if(!a)return this.enumFor('forEach');a=JS.Enumerable.toFn(a);for(var c=0,d=this._0.length;c<d;c++){if(this._0[c]!==undefined)a.call(b||null,this._0[c],c)}return this},clear:function(){this._0=[];this.length=this.pointer=0},_3:function(){if(this.pointer===0&&this._1&&this._1.execute)this._1.execute()},push:function(a){this._0.splice(this.pointer,this.length);this._0.push(a);this.length=this.pointer=this._0.length;if(this.notifyObservers)this.notifyObservers(this)},stepTo:function(a){if(a<0||a>this.length)return;var b,c;switch(true){case a>this.pointer:for(b=this.pointer,c=a;b<c;b++)this._0[b].execute(false);break;case a<this.pointer:if(this._1&&this._1.execute){this._1.execute();for(b=0,c=a;b<c;b++)this._0[b].execute(false)}else{for(b=0,c=this.pointer-a;b<c;b++)this._0[this.pointer-b-1].undo()}break}this.pointer=a;if(this.notifyObservers)this.notifyObservers(this)},undo:function(){this.stepTo(this.pointer-1)},redo:function(){this.stepTo(this.pointer+1)}})}});
|