spontaneous 0.2.0.alpha2 → 0.2.0.alpha3
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +3 -40
- data/Rakefile +29 -41
- data/Readme.markdown +21 -8
- data/application/css/add_alias_dialogue.css.scss +79 -0
- data/application/css/{v2.scss → core.css.scss} +537 -550
- data/application/css/{definitions.scss → definitions.css.scss} +121 -33
- data/application/css/dialogue.css.scss +409 -0
- data/application/css/{editing.scss → editing.css.scss} +25 -262
- data/application/css/font.css.scss +8 -0
- data/application/css/jquery-ui-1.8.21.custom/images/ui-bg_diagonals-thick_18_b81900_40x40.png +0 -0
- data/application/css/jquery-ui-1.8.21.custom/images/ui-bg_diagonals-thick_20_666666_40x40.png +0 -0
- data/application/css/jquery-ui-1.8.21.custom/images/ui-bg_flat_10_000000_40x100.png +0 -0
- data/application/css/jquery-ui-1.8.21.custom/images/ui-bg_glass_100_f6f6f6_1x400.png +0 -0
- data/application/css/jquery-ui-1.8.21.custom/images/ui-bg_glass_100_fdf5ce_1x400.png +0 -0
- data/application/css/jquery-ui-1.8.21.custom/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/application/css/jquery-ui-1.8.21.custom/images/ui-bg_gloss-wave_35_f6a828_500x100.png +0 -0
- data/application/css/jquery-ui-1.8.21.custom/images/ui-bg_highlight-soft_100_eeeeee_1x100.png +0 -0
- data/application/css/jquery-ui-1.8.21.custom/images/ui-bg_highlight-soft_75_ffe45c_1x100.png +0 -0
- data/application/css/jquery-ui-1.8.21.custom/images/ui-icons_222222_256x240.png +0 -0
- data/application/css/jquery-ui-1.8.21.custom/images/ui-icons_228ef1_256x240.png +0 -0
- data/application/css/jquery-ui-1.8.21.custom/images/ui-icons_ef8c08_256x240.png +0 -0
- data/application/css/jquery-ui-1.8.21.custom/images/ui-icons_ffd27a_256x240.png +0 -0
- data/application/css/jquery-ui-1.8.21.custom/images/ui-icons_ffffff_256x240.png +0 -0
- data/application/css/jquery-ui-1.8.21.custom/ui-lightness.css.scss +565 -0
- data/application/css/{login.scss → login.css.scss} +4 -4
- data/application/css/meta.css.scss +331 -0
- data/application/css/{popover.scss → popover.css.scss} +9 -8
- data/application/css/{schema_error.scss → schema_error.css.scss} +4 -4
- data/application/css/spontaneous.css +5 -0
- data/application/css/unsupported.css.scss +42 -0
- data/application/js/add_alias_dialogue.js +72 -10
- data/application/js/ajax.js +50 -16
- data/application/js/compatibility.js +19 -15
- data/application/js/content.js +39 -36
- data/application/js/content_area.js +53 -5
- data/application/js/dialogue.js +17 -0
- data/application/js/dom.js +1 -1
- data/application/js/edit_panel.js +23 -8
- data/application/js/extensions.js +7 -2
- data/application/js/field_preview.js +2 -1
- data/application/js/field_types/date_field.js +11 -8
- data/application/js/field_types/file_field.js +188 -9
- data/application/js/field_types/image_field.js +46 -29
- data/application/js/field_types/markdown_field.js +57 -14
- data/application/js/field_types/select_field.js +72 -0
- data/application/js/field_types/string_field.js +8 -0
- data/application/js/field_types/webvideo_field.js +8 -0
- data/application/js/init.js +1 -7
- data/application/js/location.js +41 -13
- data/application/js/login.js +3 -0
- data/application/js/meta_view/user_admin.js +543 -0
- data/application/js/meta_view.js +1 -0
- data/application/js/metadata.js +20 -0
- data/application/js/page.js +17 -3
- data/application/js/page_browser.js +40 -30
- data/application/js/page_entry.js +4 -0
- data/application/js/panel/root_menu.js +66 -0
- data/application/js/popover.js +2 -2
- data/application/js/preview.js +1 -1
- data/application/js/publish.js +138 -30
- data/application/js/services.js +43 -0
- data/application/js/sharded_upload.js +2 -2
- data/application/js/spontaneous.js +64 -5
- data/application/js/state.js +20 -9
- data/application/js/top_bar.js +273 -150
- data/application/js/types.js +20 -15
- data/application/js/upload.js +1 -2
- data/application/js/user.js +18 -4
- data/application/js/vendor/date.js +104 -0
- data/application/js/vendor/jquery-ui-1.8.18.custom.min.js +356 -0
- data/application/js/views/box_view.js +15 -8
- data/application/js/views/page_piece_view.js +11 -8
- data/application/js/views/page_view.js +21 -3
- data/application/js/views/piece_view.js +19 -10
- data/application/js/views.js +3 -0
- data/application/static/chromelogo-200x52-45c7cbc93be080bea342df5fcda2ef8b.png +0 -0
- data/application/static/dot-texture-9eea29e4ac7ad9a772285252078ec127.png +0 -0
- data/application/static/editing-textarea-resize-s-b5af62365eb7e19ea4beccf7242d508e.png +0 -0
- data/application/static/editing-texture-1-42b06a3439752490988f30f2a06d5e7c.png +0 -0
- data/application/static/font/fontawesome-webfont-5c5c21100a346972a82c34c5e96ffcfe.ttf +0 -0
- data/application/static/loop_alt1-white-7894b458528e92216196cae26b4c2c96.svg +12 -0
- data/application/static/spontaneous-states-e91ec89db525c62da0105b97cdd781ce.png +0 -0
- data/application/views/index.erb +2 -2
- data/application/views/login.erb +4 -8
- data/application/views/schema_modification_error.html.erb +1 -4
- data/application/views/unsupported.erb +9 -7
- data/bin/spot +1 -1
- data/db/migrations/20110209152710_users_and_groups.rb +10 -10
- data/db/migrations/20120305112647_site_modification_time.rb +11 -0
- data/db/migrations/20120418153903_add_ownership_of_content.rb +14 -0
- data/db/migrations/20120423175416_add_pending_modifications.rb +21 -0
- data/db/migrations/20120525164947_add_field_versions.rb +27 -0
- data/lib/sequel/plugins/scoped_table_name.rb +10 -1
- data/lib/spontaneous/asset/file.rb +25 -0
- data/lib/spontaneous/asset/source.rb +28 -0
- data/lib/spontaneous/asset.rb +75 -0
- data/lib/spontaneous/box.rb +6 -4
- data/lib/spontaneous/capistrano/deploy.rb +47 -0
- data/lib/spontaneous/capistrano/sync.rb +81 -0
- data/lib/spontaneous/capistrano.rb +13 -0
- data/lib/spontaneous/change.rb +60 -68
- data/lib/spontaneous/cli/assets.rb +29 -0
- data/lib/spontaneous/cli/base.rb +0 -48
- data/lib/spontaneous/cli/console.rb +1 -1
- data/lib/spontaneous/cli/server.rb +6 -4
- data/lib/spontaneous/cli/site.rb +28 -17
- data/lib/spontaneous/cli/user.rb +107 -0
- data/lib/spontaneous/cli.rb +100 -4
- data/lib/spontaneous/collections/entry_set.rb +2 -2
- data/lib/spontaneous/collections/field_set.rb +48 -22
- data/lib/spontaneous/collections/prototype_set.rb +20 -13
- data/lib/spontaneous/constants.rb +3 -0
- data/lib/spontaneous/content.rb +22 -5
- data/lib/spontaneous/errors.rb +3 -3
- data/lib/spontaneous/extensions/array.rb +12 -0
- data/lib/spontaneous/extensions/enumerable.rb +30 -0
- data/lib/spontaneous/extensions/nil.rb +3 -1
- data/lib/spontaneous/extensions/string.rb +16 -0
- data/lib/spontaneous/field_types/date_field.rb +45 -2
- data/lib/spontaneous/field_types/field.rb +42 -9
- data/lib/spontaneous/field_types/file_field.rb +68 -0
- data/lib/spontaneous/field_types/image_field.rb +63 -0
- data/lib/spontaneous/field_types/select_field.rb +109 -0
- data/lib/spontaneous/field_types/string_field.rb +6 -1
- data/lib/spontaneous/field_types/webvideo_field.rb +85 -27
- data/lib/spontaneous/field_types.rb +1 -1
- data/lib/spontaneous/field_version.rb +8 -0
- data/lib/spontaneous/generators/page.rb +1 -1
- data/lib/spontaneous/generators/site/Capfile.tt +1 -4
- data/lib/spontaneous/generators/site/Gemfile.tt +13 -6
- data/lib/spontaneous/generators/site/config/deploy.rb.tt +28 -0
- data/lib/spontaneous/generators/site/config/environments/production.rb.tt +7 -2
- data/lib/spontaneous/generators/site.rb +1 -0
- data/lib/spontaneous/json.rb +34 -11
- data/lib/spontaneous/layout.rb +22 -0
- data/lib/spontaneous/media/file.rb +4 -0
- data/lib/spontaneous/output/assets/compression.rb +58 -0
- data/lib/spontaneous/output/assets.rb +32 -0
- data/lib/spontaneous/output/context.rb +179 -0
- data/lib/spontaneous/output/format/html.rb +5 -0
- data/lib/spontaneous/output/format/plain.rb +5 -0
- data/lib/spontaneous/output/format.rb +180 -0
- data/lib/spontaneous/output/helpers/classes_helper.rb +18 -0
- data/lib/spontaneous/{render/helpers/html_helper.rb → output/helpers/conditional_comment_helper.rb} +3 -12
- data/lib/spontaneous/output/helpers/script_helper.rb +73 -0
- data/lib/spontaneous/output/helpers/stylesheet_helper.rb +61 -0
- data/lib/spontaneous/output/helpers.rb +28 -0
- data/lib/spontaneous/output/template/engine.rb +59 -0
- data/lib/spontaneous/output/template/renderer.rb +153 -0
- data/lib/spontaneous/output/template.rb +21 -0
- data/lib/spontaneous/output.rb +163 -0
- data/lib/spontaneous/page.rb +2 -1
- data/lib/spontaneous/paths.rb +6 -1
- data/lib/spontaneous/permissions/access_key.rb +5 -5
- data/lib/spontaneous/permissions/user.rb +81 -35
- data/lib/spontaneous/permissions/user_level.rb +26 -22
- data/lib/spontaneous/plugins/aliases.rb +76 -12
- data/lib/spontaneous/plugins/allowed_types.rb +60 -18
- data/lib/spontaneous/plugins/application/paths.rb +0 -28
- data/lib/spontaneous/plugins/application/system.rb +35 -0
- data/lib/spontaneous/plugins/boxes.rb +4 -0
- data/lib/spontaneous/plugins/content_groups.rb +16 -0
- data/lib/spontaneous/plugins/entries.rb +50 -30
- data/lib/spontaneous/plugins/fields.rb +15 -0
- data/lib/spontaneous/plugins/layouts.rb +8 -2
- data/lib/spontaneous/plugins/modifications.rb +228 -0
- data/lib/spontaneous/plugins/page/formats.rb +67 -42
- data/lib/spontaneous/plugins/page/request.rb +10 -0
- data/lib/spontaneous/plugins/page/site_timestamps.rb +28 -0
- data/lib/spontaneous/plugins/paths.rb +15 -3
- data/lib/spontaneous/plugins/publishing.rb +124 -45
- data/lib/spontaneous/plugins/render.rb +13 -8
- data/lib/spontaneous/plugins/schema_hierarchy.rb +18 -6
- data/lib/spontaneous/plugins/site/helpers.rb +53 -0
- data/lib/spontaneous/plugins/site/hooks.rb +50 -0
- data/lib/spontaneous/plugins/site/map.rb +1 -1
- data/lib/spontaneous/plugins/site/paths.rb +13 -0
- data/lib/spontaneous/plugins/site/publishing.rb +6 -2
- data/lib/spontaneous/plugins/site/{revisions.rb → state.rb} +5 -1
- data/lib/spontaneous/plugins/site/storage.rb +4 -0
- data/lib/spontaneous/plugins/site/url.rb +15 -0
- data/lib/spontaneous/plugins/site_map.rb +13 -3
- data/lib/spontaneous/plugins/styles.rb +5 -1
- data/lib/spontaneous/plugins/visibility.rb +39 -12
- data/lib/spontaneous/prototypes/box_prototype.rb +4 -0
- data/lib/spontaneous/prototypes/field_prototype.rb +15 -10
- data/lib/spontaneous/publishing/event_client.rb +46 -0
- data/lib/spontaneous/publishing/immediate.rb +81 -44
- data/lib/spontaneous/publishing/simultaneous.rb +23 -6
- data/lib/spontaneous/publishing.rb +4 -3
- data/lib/spontaneous/rack/around_back.rb +1 -5
- data/lib/spontaneous/rack/around_front.rb +4 -4
- data/lib/spontaneous/rack/around_preview.rb +4 -3
- data/lib/spontaneous/rack/assets.rb +81 -54
- data/lib/spontaneous/rack/authentication.rb +0 -1
- data/lib/spontaneous/rack/back.rb +160 -72
- data/lib/spontaneous/rack/cookie_authentication.rb +2 -2
- data/lib/spontaneous/rack/css.rb +18 -15
- data/lib/spontaneous/rack/event_source.rb +9 -21
- data/lib/spontaneous/rack/fiber_pool.rb +26 -0
- data/lib/spontaneous/rack/front.rb +12 -4
- data/lib/spontaneous/rack/helpers.rb +35 -13
- data/lib/spontaneous/rack/js.rb +41 -0
- data/lib/spontaneous/rack/public.rb +34 -44
- data/lib/spontaneous/rack/sse.rb +18 -0
- data/lib/spontaneous/rack/static.rb +3 -0
- data/lib/spontaneous/rack/user_admin.rb +100 -0
- data/lib/spontaneous/rack/user_helpers.rb +1 -1
- data/lib/spontaneous/rack.rb +6 -2
- data/lib/spontaneous/schema.rb +31 -4
- data/lib/spontaneous/search/index.rb +19 -3
- data/lib/spontaneous/search/results.rb +1 -1
- data/lib/spontaneous/sequel.rb +17 -0
- data/lib/spontaneous/site.rb +11 -4
- data/lib/spontaneous/state.rb +11 -0
- data/lib/spontaneous/storage/cloud.rb +4 -0
- data/lib/spontaneous/storage/local.rb +11 -0
- data/lib/spontaneous/style.rb +2 -2
- data/lib/spontaneous/tasks/database.rake +21 -22
- data/lib/spontaneous/utils/database/mysql_dumper.rb +4 -0
- data/lib/spontaneous/utils/database/postgres_dumper.rb +78 -0
- data/lib/spontaneous/utils/database.rb +6 -3
- data/lib/spontaneous/utils/smart_quotes.rb +499 -0
- data/lib/spontaneous/utils/smush_it.rb +66 -0
- data/lib/spontaneous/utils.rb +3 -1
- data/lib/spontaneous/version.rb +2 -2
- data/lib/spontaneous.rb +25 -29
- data/spontaneous.gemspec +186 -106
- data/test/experimental/test_features.rb +1 -1
- data/test/fixtures/asset_pipeline/application/css/basic.css.scss +4 -0
- data/test/fixtures/asset_pipeline/application/css/complex.css.scss.erb +6 -0
- data/test/fixtures/asset_pipeline/application/css/simple.css +3 -0
- data/test/fixtures/asset_pipeline/application/css/spontaneous.css +7 -0
- data/test/fixtures/asset_pipeline/application/css/subdir/complex.css.scss.erb +6 -0
- data/test/fixtures/asset_pipeline/application/css/subdir/library.css.scss +1 -0
- data/test/fixtures/asset_pipeline/application/css/subdir/simple.css +3 -0
- data/test/fixtures/asset_pipeline/application/js/basic.js.coffee +1 -0
- data/test/fixtures/asset_pipeline/application/js/complex.js.coffee.erb +1 -0
- data/test/fixtures/asset_pipeline/application/js/login.js +1 -0
- data/test/fixtures/asset_pipeline/application/js/require.js +1 -0
- data/test/fixtures/asset_pipeline/application/js/simple.js +1 -0
- data/test/fixtures/asset_pipeline/application/js/spontaneous.js +5 -0
- data/test/fixtures/asset_pipeline/application/js/subdir/complex.js.coffee.erb +1 -0
- data/test/fixtures/asset_pipeline/application/js/subdir/library.js.coffee +1 -0
- data/test/fixtures/asset_pipeline/application/js/subdir/simple.js +1 -0
- data/test/fixtures/asset_pipeline/application/js/vendor/jquery.js +1 -0
- data/test/fixtures/asset_pipeline/application/static/dot-texture.png +0 -0
- data/test/fixtures/asset_pipeline/application/static/subdir/px.gif +0 -0
- data/test/fixtures/assets/public1/css/a.scss +1 -0
- data/test/fixtures/assets/public1/js/a.js +1 -0
- data/test/fixtures/assets/public1/js/m.coffee +1 -0
- data/test/fixtures/assets/public2/css/b.scss +1 -0
- data/test/fixtures/assets/public2/css/c.css +1 -0
- data/test/fixtures/assets/public2/js/b.js +1 -0
- data/test/fixtures/assets/public2/js/c.js +1 -0
- data/test/fixtures/assets/public2/js/n.coffee +1 -0
- data/test/fixtures/back/config/user_levels.yml +3 -0
- data/test/fixtures/back/public/js/coffeescript.coffee +1 -0
- data/test/fixtures/back/templates/layouts/standard.css.cut +1 -0
- data/test/fixtures/back/templates/layouts/standard.js.cut +1 -0
- data/test/fixtures/example_application/config/database.yml +4 -4
- data/test/fixtures/helpers/templates/layouts/standard.html.cut +1 -0
- data/test/fixtures/helpers/templates/layouts/standard.mobile.cut +1 -0
- data/test/fixtures/images/vimlogo.pdf +0 -0
- data/test/fixtures/outputs/templates/layouts/standard.atom.cut +1 -0
- data/test/fixtures/permissions/config/user_levels.yml +6 -3
- data/test/fixtures/serialisation/class_hash.yaml.erb +1 -0
- data/test/fixtures/serialisation/root_hash.yaml.erb +2 -2
- data/test/fixtures/templates/extended/grandparent.html.cut +7 -7
- data/test/fixtures/templates/extended/main.html.cut +5 -5
- data/test/fixtures/templates/extended/parent.html.cut +8 -8
- data/test/fixtures/templates/extended/partial_with_locals.html.cut +1 -1
- data/test/fixtures/templates/extended/with_includes.html.cut +6 -6
- data/test/fixtures/templates/extended/with_includes_and_locals.html.cut +6 -7
- data/test/fixtures/templates/layouts/entries.html.cut +4 -4
- data/test/fixtures/templates/layouts/standard.html.cut +1 -0
- data/test/fixtures/templates/layouts/variables.html.cut +1 -1
- data/test/fixtures/templates/publishing/templates/layouts/static.html.cut +1 -1
- data/test/fixtures/templates/publishing/templates/layouts/static.rtf.cut +1 -0
- data/test/fixtures/templates/template_class/complex_template.html.cut +2 -2
- data/test/fixtures/templates/template_class/complex_template.pdf.cut +2 -2
- data/test/fixtures/templates/template_class/default_template_style.html.cut +1 -1
- data/test/fixtures/templates/template_class/images_with_template.html.cut +2 -2
- data/test/fixtures/templates/template_class/slots_template.html.cut +2 -2
- data/test/fixtures/templates/template_class/slots_template.pdf.cut +2 -2
- data/test/fixtures/user_manager/config/user_levels.yml +9 -0
- data/test/functional/test_application.rb +7 -7
- data/test/functional/test_back.rb +352 -97
- data/test/functional/test_front.rb +71 -20
- data/test/functional/test_user_manager.rb +284 -0
- data/test/javascript/env.js +13505 -0
- data/test/javascript/test_markdown.rb +43 -3
- data/test/support/custom_matchers.rb +3 -2
- data/test/test_helper.rb +50 -9
- data/test/test_javascript.rb +13 -13
- data/test/ui_helper.rb +1 -1
- data/test/unit/test_alias.rb +79 -8
- data/test/unit/test_asset_bundler.rb +220 -0
- data/test/unit/test_assets.rb +213 -0
- data/test/unit/test_async.rb +55 -0
- data/test/unit/test_authentication.rb +52 -39
- data/test/unit/test_boxes.rb +20 -15
- data/test/unit/test_changesets.rb +261 -0
- data/test/unit/test_content.rb +73 -33
- data/test/unit/test_content_inheritance.rb +18 -18
- data/test/unit/test_extensions.rb +26 -0
- data/test/unit/test_fields.rb +303 -16
- data/test/unit/test_formats.rb +267 -34
- data/test/unit/test_helpers.rb +79 -2
- data/test/unit/test_images.rb +10 -0
- data/test/unit/test_layouts.rb +21 -13
- data/test/unit/test_modifications.rb +648 -0
- data/test/unit/test_page.rb +6 -2
- data/test/unit/test_permissions.rb +101 -27
- data/test/unit/test_piece.rb +4 -4
- data/test/unit/test_plugins.rb +3 -2
- data/test/unit/test_publishing.rb +332 -0
- data/test/unit/test_render.rb +118 -67
- data/test/unit/test_revisions.rb +546 -0
- data/test/unit/test_schema.rb +83 -1
- data/test/unit/test_search.rb +59 -0
- data/test/unit/test_serialisation.rb +2 -47
- data/test/unit/test_site.rb +217 -108
- data/test/unit/test_storage.rb +26 -0
- data/test/unit/test_structure.rb +2 -2
- data/test/unit/test_styles.rb +90 -75
- data/test/unit/test_table_scoping.rb +21 -17
- data/test/unit/test_templates.rb +75 -69
- data/test/{slow → unit}/test_visibility.rb +78 -22
- metadata +528 -221
- data/application/css/add_alias_dialogue.scss +0 -27
- data/application/css/min/14c2a35812c443001b15d8b12a4780f88c678035.css +0 -1
- data/application/css/min/565d4c25e82148acb01c45c8d675b37a08676d77.css +0 -1
- data/application/css/min/84dbe894ea96eafd321c30823d630817bfc4b03b.css +0 -1
- data/application/css/spontaneous.scss +0 -111
- data/application/css/unsupported.scss +0 -16
- data/application/css/variables.scss +0 -80
- data/application/js/min/2a0c2962537a3181fedfff5c92596ba6d3122dc9.js +0 -3
- data/application/js/min/4cf1c493d3379ecba5287758c61238034c0893f9.js +0 -2
- data/application/js/min/78ac6b99d96750bb6b9f9aad4cb9cd91cd03f391.js +0 -3
- data/application/js/min/b8abf302a824c35385ff517b34111e1710ff3b37.js +0 -2
- data/application/js/min/c8efb9b9f7c3f6613fcebc6be60f605b6570a382.js +0 -90
- data/application/static/diagonal-texture.png +0 -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/inner-glow.png +0 -0
- data/application/static/item-buttons-highlight.png +0 -0
- data/application/static/item-buttons.png +0 -0
- data/application/static/paper-texture-dark.png +0 -0
- data/application/static/plus_alt.svg +0 -8
- data/application/static/select-arrow-root.png +0 -0
- data/application/static/slot-up-arrow.png +0 -0
- data/application/static/spontaneous.png +0 -0
- data/lib/cutaneous/context_helper.rb +0 -187
- data/lib/cutaneous/preview_context.rb +0 -32
- data/lib/cutaneous/preview_renderer.rb +0 -10
- data/lib/cutaneous/publish_context.rb +0 -10
- data/lib/cutaneous/publish_renderer.rb +0 -14
- data/lib/cutaneous/publish_template.rb +0 -62
- data/lib/cutaneous/publish_token_parser.rb +0 -8
- data/lib/cutaneous/renderer.rb +0 -124
- data/lib/cutaneous/request_context.rb +0 -9
- data/lib/cutaneous/request_renderer.rb +0 -15
- data/lib/cutaneous/request_template.rb +0 -11
- data/lib/cutaneous/request_token_parser.rb +0 -9
- data/lib/cutaneous/token_parser.rb +0 -125
- data/lib/cutaneous.rb +0 -48
- data/lib/spontaneous/render/context_base.rb +0 -143
- data/lib/spontaneous/render/development_renderer.rb +0 -14
- data/lib/spontaneous/render/engine.rb +0 -19
- data/lib/spontaneous/render/format/html.rb +0 -5
- data/lib/spontaneous/render/format.rb +0 -75
- data/lib/spontaneous/render/helpers/script_helper.rb +0 -17
- data/lib/spontaneous/render/helpers/stylesheet_helper.rb +0 -16
- data/lib/spontaneous/render/helpers.rb +0 -14
- data/lib/spontaneous/render/preview_context.rb +0 -8
- data/lib/spontaneous/render/preview_renderer.rb +0 -24
- data/lib/spontaneous/render/publish_context.rb +0 -22
- data/lib/spontaneous/render/published_renderer.rb +0 -53
- data/lib/spontaneous/render/publishing_renderer.rb +0 -16
- data/lib/spontaneous/render/render_cache.rb +0 -26
- data/lib/spontaneous/render/renderer.rb +0 -50
- data/lib/spontaneous/render/request_context.rb +0 -8
- data/lib/spontaneous/render.rb +0 -214
- data/test/experimental/test_cutaneous.rb +0 -309
- data/test/fixtures/application/css/test.less +0 -5
- data/test/slow/test_publishing.rb +0 -1006
- /data/application/css/{developer.scss → developer.css.scss} +0 -0
- /data/application/js/vendor/{jquery-1.7.1.min.js → jquery.js} +0 -0
- /data/application/static/{location-arrow.png → location-arrow-c1c1d3ca472481c61a0a5f8cb289d743.png} +0 -0
- /data/application/static/{missing.png → missing-911ce6dbd9f4602e0f3fbcd7e78846a2.png} +0 -0
- /data/application/static/{orange-down-arrow.png → orange-down-arrow-395ae1929e8662b2ff0977daf12c35bb.png} +0 -0
- /data/application/static/{page-browser-next.png → page-browser-next-ce781a242c23b980b99b9db7abc20b05.png} +0 -0
- /data/application/static/{plus-box.png → plus-box-dcde74a1e496f68298c9b443caa1c5d5.png} +0 -0
- /data/application/static/{select-arrow.png → select-arrow-6e7dd3745b00e934b0d7a3250c46558b.png} +0 -0
- /data/application/static/{slot-down-arrow.png → slot-down-arrow-59ad5f5ee5b52a7ebd00bca4b3104194.png} +0 -0
- /data/application/static/{splash.png → splash-65b493a714df9b8b3ab170103401b53d.png} +0 -0
- /data/application/static/{spot.png → spot-71fab1d2f065034f5fc15e7bea2ad36c.png} +0 -0
- /data/application/static/{spot.svg → spot-8505041082d8d3bbe8d34c29dddb3b7d.svg} +0 -0
- /data/application/static/{texture.png → texture-03f7627e8264b1d607113ab32c593a58.png} +0 -0
@@ -78,6 +78,7 @@ module Spontaneous::Prototypes
|
|
78
78
|
@extend.each { |block|
|
79
79
|
instance_class.class_eval(&block) if block
|
80
80
|
}
|
81
|
+
instance_class.prototype = self
|
81
82
|
end
|
82
83
|
end
|
83
84
|
|
@@ -85,8 +86,13 @@ module Spontaneous::Prototypes
|
|
85
86
|
instance_class
|
86
87
|
end
|
87
88
|
|
88
|
-
def default
|
89
|
-
@options[:default]
|
89
|
+
def default(_instance = nil)
|
90
|
+
case default = @options[:default]
|
91
|
+
when Proc
|
92
|
+
default[_instance]
|
93
|
+
else
|
94
|
+
default
|
95
|
+
end
|
90
96
|
end
|
91
97
|
|
92
98
|
def comment
|
@@ -134,13 +140,12 @@ module Spontaneous::Prototypes
|
|
134
140
|
end
|
135
141
|
end
|
136
142
|
|
137
|
-
def to_field(
|
138
|
-
|
139
|
-
values = {
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
self.instance_class.new(values, !default_values).tap do |field|
|
143
|
+
def to_field(instance, database_values=nil)
|
144
|
+
using_default_values = database_values.nil?
|
145
|
+
values = { :name => self.name }
|
146
|
+
values[:unprocessed_value] = default(instance) if using_default_values
|
147
|
+
values.update(database_values || {})
|
148
|
+
self.instance_class.new(values, !using_default_values).tap do |field|
|
144
149
|
field.prototype = self
|
145
150
|
end
|
146
151
|
end
|
@@ -153,7 +158,7 @@ module Spontaneous::Prototypes
|
|
153
158
|
:title => title,
|
154
159
|
:comment => comment || "",
|
155
160
|
:writable => Spontaneous::Permissions.has_level?(user, write_level)
|
156
|
-
}
|
161
|
+
}.merge(instance_class.export(user))
|
157
162
|
end
|
158
163
|
end
|
159
164
|
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'socket'
|
2
|
+
require 'net/http'
|
3
|
+
|
4
|
+
module Spontaneous
|
5
|
+
module Publishing
|
6
|
+
# a simple UNIX socket capable HTTP client used to send progress events
|
7
|
+
# from the publish task to the back server (for forwarding onto clients)
|
8
|
+
class EventClient
|
9
|
+
def initialize(server_address)
|
10
|
+
@server_address = server_address
|
11
|
+
end
|
12
|
+
|
13
|
+
def send_event(event_name, event_message)
|
14
|
+
socket = open_socket
|
15
|
+
return if socket.nil?
|
16
|
+
sock = Net::BufferedIO.new(socket)
|
17
|
+
request = request(event_name, event_message)
|
18
|
+
# Host is a required header, but it doesn't matter to us what it is
|
19
|
+
request["Host"] = "localhost"
|
20
|
+
request.exec(sock, "1.1", request.path)
|
21
|
+
ensure
|
22
|
+
sock.close if sock
|
23
|
+
end
|
24
|
+
|
25
|
+
def request(event_name, event_message)
|
26
|
+
query = ::Rack::Utils.build_nested_query({
|
27
|
+
"event" => event_name,
|
28
|
+
"data" => event_message.to_json
|
29
|
+
})
|
30
|
+
Net::HTTP::Put.new("/@spontaneous/event?#{query}")
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
def open_socket
|
35
|
+
return nil if @server_address.nil?
|
36
|
+
case @server_address
|
37
|
+
when /\//
|
38
|
+
UNIXSocket.new(@server_address)
|
39
|
+
else
|
40
|
+
host, port = @server_address.split(":")
|
41
|
+
TCPSocket.new(host, port)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -6,39 +6,37 @@ require 'sass'
|
|
6
6
|
module Spontaneous
|
7
7
|
module Publishing
|
8
8
|
class Immediate
|
9
|
-
|
10
|
-
# def self.status
|
11
|
-
# @status ||= ""
|
12
|
-
# end
|
13
|
-
|
14
|
-
# def self.status=(status)
|
15
|
-
# @status = status
|
16
|
-
# end
|
17
|
-
|
18
9
|
include ::Simultaneous::Task
|
19
10
|
|
20
11
|
attr_reader :revision
|
21
12
|
|
22
13
|
def initialize(revision)
|
23
14
|
@revision = revision
|
24
|
-
|
15
|
+
@previous_revision = Site.published_revision
|
25
16
|
end
|
26
17
|
|
27
|
-
def
|
28
|
-
|
29
|
-
|
18
|
+
def renderer
|
19
|
+
@renderer ||= Spontaneous::Output::Template::PublishRenderer.new(true)
|
20
|
+
end
|
21
|
+
|
22
|
+
def publish_pages(page_list)
|
23
|
+
pages = page_list.flatten.map { |c|
|
24
|
+
c.is_a?(S::Page) ? c.reload : S::Page[c]
|
30
25
|
}
|
31
|
-
|
32
|
-
|
26
|
+
all_pages = S::Page.all
|
27
|
+
|
28
|
+
if (all_pages - pages).empty?
|
33
29
|
# publish_all is quicker
|
34
30
|
publish_all
|
35
31
|
else
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
32
|
+
pages = Spontaneous::Change.include_dependencies(pages)
|
33
|
+
# changes = pages.map { |page| Spontaneous::Change.new(page) }
|
34
|
+
publish(pages)
|
35
|
+
|
36
|
+
# TODO: scheduled publishes will
|
37
|
+
# changes.each do |change|
|
38
|
+
# change.destroy
|
39
|
+
# end
|
42
40
|
end
|
43
41
|
|
44
42
|
end
|
@@ -48,19 +46,26 @@ module Spontaneous
|
|
48
46
|
# (but after we've duplicated the tables)
|
49
47
|
# so save the current list of changes
|
50
48
|
# TODO: make sure this is robust
|
51
|
-
changes = S::Change.all
|
49
|
+
# changes = S::Change.all
|
52
50
|
publish(nil)
|
53
|
-
changes.each do |change|
|
54
|
-
|
51
|
+
# changes.each do |change|
|
52
|
+
# change.destroy
|
53
|
+
# end
|
54
|
+
end
|
55
|
+
|
56
|
+
def rerender_revision
|
57
|
+
logger.info { "Re-rendering revision #{@revision}"}
|
58
|
+
S::Content.with_revision(@revision) do
|
59
|
+
render_revision
|
55
60
|
end
|
56
61
|
end
|
57
62
|
|
58
63
|
protected
|
59
64
|
|
60
|
-
def page_rendered(page, event = "rendering")
|
65
|
+
def page_rendered(page, event = "rendering", format = "html")
|
61
66
|
@pages_rendered += 1
|
62
67
|
update_progress(event, percent_complete)
|
63
|
-
logger.info { "Done: #{event} page #{page.path} #{percent_complete.round(1)}%" }
|
68
|
+
logger.info { "Done: #{event} page #{page.path} (#{format}) #{percent_complete.round(1)}%" }
|
64
69
|
end
|
65
70
|
|
66
71
|
|
@@ -76,6 +81,7 @@ module Spontaneous
|
|
76
81
|
end
|
77
82
|
|
78
83
|
def publish(modified_page_list)
|
84
|
+
logger.info { "Publishing revision #{@revision}"}
|
79
85
|
at_exit {
|
80
86
|
abort_publish_at_exit
|
81
87
|
}
|
@@ -85,21 +91,20 @@ module Spontaneous
|
|
85
91
|
render_revision
|
86
92
|
end
|
87
93
|
after_publish
|
88
|
-
rescue Exception => e
|
94
|
+
rescue ::Exception => e
|
89
95
|
abort_publish(e)
|
90
96
|
raise(e)
|
91
97
|
end
|
92
98
|
end
|
93
99
|
|
94
100
|
def render_revision
|
101
|
+
S::Output.renderer = renderer
|
95
102
|
update_progress("rendering", 0)
|
96
103
|
@pages_rendered = 0
|
97
104
|
S::Content.with_identity_map do
|
98
105
|
S::Content.with_visible do
|
99
|
-
|
100
|
-
|
101
|
-
index_pages unless index_stages == 0
|
102
|
-
end
|
106
|
+
render_pages
|
107
|
+
index_pages unless index_stages == 0
|
103
108
|
end
|
104
109
|
end
|
105
110
|
copy_static_files
|
@@ -110,19 +115,17 @@ module Spontaneous
|
|
110
115
|
# the delay is purely used in interface testing
|
111
116
|
delay = Spontaneous::Site.config.publishing_delay
|
112
117
|
pages.each do |page|
|
113
|
-
page.
|
114
|
-
render_page(page,
|
118
|
+
page.outputs.each do |output|
|
119
|
+
render_page(page, output)
|
115
120
|
end
|
116
121
|
sleep(delay) if delay
|
117
122
|
end
|
118
123
|
end
|
119
124
|
|
120
|
-
def render_page(page,
|
125
|
+
def render_page(page, output)
|
121
126
|
logger.info { "#{page.path}" }
|
122
|
-
|
123
|
-
|
124
|
-
renderer.render
|
125
|
-
page_rendered(page)
|
127
|
+
output.publish_page(renderer, revision)
|
128
|
+
page_rendered(page, "rendering", output.format)
|
126
129
|
end
|
127
130
|
|
128
131
|
def index_pages
|
@@ -140,7 +143,7 @@ module Spontaneous
|
|
140
143
|
# although not all pages are included by a format
|
141
144
|
def total_pages_to_render
|
142
145
|
@total_pages ||= (index_stages * pages.count) + pages.inject(0) do |total, page|
|
143
|
-
total += page.
|
146
|
+
total += page.outputs.length
|
144
147
|
end
|
145
148
|
end
|
146
149
|
|
@@ -148,6 +151,12 @@ module Spontaneous
|
|
148
151
|
((@pages_rendered || 0).to_f / (total_pages_to_render).to_f) * 100.0
|
149
152
|
end
|
150
153
|
|
154
|
+
# Deprecated. It's easier to use the messaging path provided by Simultaneous
|
155
|
+
# as it's auto configuring.
|
156
|
+
def event_client
|
157
|
+
@event_client ||= Spontaneous::Publishing::EventClient.new(ENV["SPOT_SERVER"])
|
158
|
+
end
|
159
|
+
|
151
160
|
def update_progress(state, progress='*')
|
152
161
|
simultaneous_event('publish_progress', {:state => state, :progress => progress}.to_json)
|
153
162
|
end
|
@@ -208,7 +217,7 @@ module Spontaneous
|
|
208
217
|
when ".scss"
|
209
218
|
render_sass_template(src, dest)
|
210
219
|
else
|
211
|
-
|
220
|
+
link_file(src, dest)
|
212
221
|
end
|
213
222
|
end
|
214
223
|
end
|
@@ -216,6 +225,16 @@ module Spontaneous
|
|
216
225
|
end
|
217
226
|
end
|
218
227
|
|
228
|
+
def link_file(src, dest)
|
229
|
+
src_dev = File::stat(src).dev
|
230
|
+
dst_dev = File::stat(File.dirname(dest)).dev
|
231
|
+
if (src_dev == dst_dev)
|
232
|
+
FileUtils.ln(src, dest, :force => true)
|
233
|
+
else
|
234
|
+
FileUtils.cp(src, dest)
|
235
|
+
end
|
236
|
+
end
|
237
|
+
|
219
238
|
def render_sass_template(template, dest)
|
220
239
|
dest_css = [dest.basename('.scss'), "css"].join(".")
|
221
240
|
dest = (dest.dirname + dest_css)
|
@@ -243,6 +262,9 @@ module Spontaneous
|
|
243
262
|
|
244
263
|
def before_publish
|
245
264
|
update_progress("initialising")
|
265
|
+
# when working with multiple instances it's possible to rollback the revision number
|
266
|
+
# leaving behind old revisions > the current published_revision.
|
267
|
+
S::Content.delete_revision(revision)
|
246
268
|
S::Site.send(:pending_revision=, revision)
|
247
269
|
end
|
248
270
|
|
@@ -250,11 +272,26 @@ module Spontaneous
|
|
250
272
|
update_progress("finalising")
|
251
273
|
S::Revision.create(:revision => revision, :published_at => Time.now)
|
252
274
|
S::Site.send(:set_published_revision, revision)
|
253
|
-
S::Site.send(:pending_revision=, nil)
|
254
275
|
tmp = Spontaneous.revision_dir(revision) / "tmp"
|
255
276
|
FileUtils.mkdir_p(tmp) unless ::File.exists?(tmp)
|
256
|
-
|
257
|
-
|
277
|
+
symlink_revision(revision)
|
278
|
+
|
279
|
+
begin
|
280
|
+
S::Site.trigger(:after_publish, revision)
|
281
|
+
S::Site.send(:pending_revision=, nil)
|
282
|
+
update_progress("complete")
|
283
|
+
rescue Exception => e
|
284
|
+
# if a post publish hook raises an exception then we want to roll everything back
|
285
|
+
S::Revision.filter(:revision => revision).delete
|
286
|
+
S::Site.send(:set_published_revision, @previous_revision)
|
287
|
+
symlink_revision(@previous_revision)
|
288
|
+
abort_publish(e)
|
289
|
+
raise e
|
290
|
+
end
|
291
|
+
end
|
292
|
+
|
293
|
+
def symlink_revision(rev)
|
294
|
+
system("ln -nsf #{Spontaneous.revision_dir(rev)} #{Spontaneous.revision_dir}")
|
258
295
|
end
|
259
296
|
|
260
297
|
def abort_publish_at_exit
|
@@ -267,7 +304,7 @@ module Spontaneous
|
|
267
304
|
FileUtils.rm_r(Spontaneous.revision_dir(revision)) if File.exists?(Spontaneous.revision_dir(revision))
|
268
305
|
S::Site.send(:pending_revision=, nil)
|
269
306
|
S::Content.delete_revision(revision)
|
270
|
-
puts exception.backtrace.join("\n")
|
307
|
+
puts exception.backtrace.join("\n") if exception
|
271
308
|
update_progress("error", exception)
|
272
309
|
end
|
273
310
|
end
|
@@ -11,8 +11,16 @@ module Spontaneous
|
|
11
11
|
:publish
|
12
12
|
end
|
13
13
|
|
14
|
+
def self.spot_binary
|
15
|
+
::Spontaneous.config.spontaneous_binary || default_spot_binary
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.default_spot_binary
|
19
|
+
(Pathname.new(Spontaneous.gem_dir) + "bin/spot").expand_path.to_s
|
20
|
+
end
|
21
|
+
|
14
22
|
def self.register_task
|
15
|
-
publish_binary =
|
23
|
+
publish_binary = spot_binary + " site:publish"
|
16
24
|
site_root = Pathname.new(Spontaneous.root).expand_path.to_s
|
17
25
|
niceness = S.config.publish_niceness || 15
|
18
26
|
logfile = "#{site_root}/log/publish.log"
|
@@ -22,17 +30,26 @@ module Spontaneous
|
|
22
30
|
:logfile => logfile,
|
23
31
|
:pwd => site_root
|
24
32
|
}
|
33
|
+
|
25
34
|
task_params = {
|
26
35
|
"site" => site_root,
|
27
36
|
"logfile" => logfile,
|
28
37
|
"environment" => Spontaneous.env
|
29
38
|
}
|
30
|
-
|
39
|
+
env = {
|
40
|
+
"SPOT_SERVER" => server_address
|
41
|
+
}
|
42
|
+
::Simultaneous.add_task(task_name, publish_binary, task_options, task_params, env)
|
31
43
|
end
|
32
44
|
|
33
45
|
def self.simultaneous_setup
|
34
|
-
::Simultaneous.
|
35
|
-
::Simultaneous.
|
46
|
+
::Simultaneous.client_mode = :async
|
47
|
+
::Simultaneous.connection = ::Spontaneous.config.simultaneous_connection
|
48
|
+
::Simultaneous.domain = ::Spontaneous.config.site_domain
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.server_address
|
52
|
+
Spontaneous.config.server_connection || "#{ ::Spontaneous.config.host || "127.0.0.1" }:#{::Spontaneous.config.port}"
|
36
53
|
end
|
37
54
|
|
38
55
|
simultaneous_setup
|
@@ -56,8 +73,8 @@ module Spontaneous
|
|
56
73
|
self.class.task_name
|
57
74
|
end
|
58
75
|
|
59
|
-
def
|
60
|
-
::Simultaneous.fire(task_name, {"
|
76
|
+
def publish_pages(page_list)
|
77
|
+
::Simultaneous.fire(task_name, {"pages" => page_list})
|
61
78
|
end
|
62
79
|
|
63
80
|
def publish_all
|
@@ -2,9 +2,10 @@
|
|
2
2
|
|
3
3
|
module Spontaneous
|
4
4
|
module Publishing
|
5
|
-
autoload :Immediate,
|
6
|
-
autoload :Threaded,
|
7
|
-
autoload :Simultaneous,
|
5
|
+
autoload :Immediate, "spontaneous/publishing/immediate"
|
6
|
+
autoload :Threaded, "spontaneous/publishing/threaded"
|
7
|
+
autoload :Simultaneous, "spontaneous/publishing/simultaneous"
|
8
|
+
autoload :EventClient, "spontaneous/publishing/event_client"
|
8
9
|
end # Publishing
|
9
10
|
end # Spontaneous
|
10
11
|
|
@@ -9,15 +9,15 @@ module Spontaneous
|
|
9
9
|
class AroundFront
|
10
10
|
def initialize(app)
|
11
11
|
@app = app
|
12
|
+
@renderer = Spontaneous::Output.published_renderer
|
12
13
|
end
|
13
14
|
|
14
15
|
def call(env)
|
15
16
|
status = headers = body = nil
|
17
|
+
env[Rack::RENDERER] = @renderer
|
16
18
|
Content.with_identity_map do
|
17
|
-
|
18
|
-
|
19
|
-
status, headers, body = @app.call(env)
|
20
|
-
end
|
19
|
+
Site.with_published do
|
20
|
+
status, headers, body = @app.call(env)
|
21
21
|
end
|
22
22
|
end
|
23
23
|
[status, headers.merge(POWERED_BY), body]
|
@@ -5,14 +5,15 @@ module Spontaneous
|
|
5
5
|
class AroundPreview
|
6
6
|
def initialize(app)
|
7
7
|
@app = app
|
8
|
+
@renderer = Spontaneous::Output.preview_renderer
|
9
|
+
Spontaneous::Output.renderer = @renderer
|
8
10
|
end
|
9
11
|
|
10
12
|
def call(env)
|
13
|
+
env[Rack::RENDERER] = @renderer
|
11
14
|
response = nil
|
12
15
|
Content.with_identity_map do
|
13
|
-
|
14
|
-
response = @app.call(env)
|
15
|
-
end
|
16
|
+
response = @app.call(env)
|
16
17
|
end
|
17
18
|
response
|
18
19
|
end
|
@@ -7,38 +7,69 @@ module Spontaneous
|
|
7
7
|
module Rack
|
8
8
|
module Assets
|
9
9
|
|
10
|
-
module Bundling
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
# module Bundling
|
11
|
+
# extend self
|
12
|
+
|
13
|
+
# def compress_js(filelist, options={})
|
14
|
+
# shine_compress_files(filelist, :js, options)
|
15
|
+
# end
|
16
|
+
|
17
|
+
# def compress_css(filelist, options={})
|
18
|
+
# # compress_files(filelist, :css, options)
|
19
|
+
# options = {
|
20
|
+
# :load_paths => [Spontaneous.css_dir],
|
21
|
+
# # :filename => sass_template,
|
22
|
+
# :cache => false,
|
23
|
+
# :style => :compressed
|
24
|
+
# }
|
25
|
+
# paths = paths(filelist)
|
26
|
+
# css = paths.map do |path|
|
27
|
+
# Sass::Engine.for_file(path, options).render
|
28
|
+
# end.join("\\n")
|
29
|
+
# hash = digest(css)
|
30
|
+
# [css, hash]
|
31
|
+
# end
|
32
|
+
|
33
|
+
# def shine_compress_files(filelist, format, options = {})
|
34
|
+
# paths = paths(filelist)
|
35
|
+
# original_size = filesize(paths)
|
36
|
+
# compressed = Shine::compress_files(paths, format, options)
|
37
|
+
# logger.info("Compressed #{filelist.length} files. Original size #{original_size}, compressed size #{compressed.length}, ratio #{(100*compressed.length.to_f/original_size.to_f).round}%")
|
38
|
+
# hash = digest(compressed)
|
39
|
+
# [compressed, hash]
|
40
|
+
# end
|
41
|
+
|
42
|
+
# def digest(str)
|
43
|
+
# hash = Digest::SHA1.new.update(str).hexdigest
|
44
|
+
# end
|
45
|
+
|
46
|
+
# def paths(filelist)
|
47
|
+
# filelist.map { |file| filepath(file) }.tap do |paths|
|
48
|
+
# logger.info("Bundling #{paths.length} files")
|
49
|
+
# end
|
50
|
+
# end
|
51
|
+
|
52
|
+
# def filepath(file)
|
53
|
+
# File.join(Spontaneous.application_dir, filetype, "#{file}.#{extension}")
|
54
|
+
# end
|
55
|
+
|
56
|
+
# def filesize(paths)
|
57
|
+
# paths.inject(0) { |sum, path| sum += File.size(path) }
|
58
|
+
# end
|
59
|
+
# end
|
60
|
+
module JavaScript
|
61
|
+
extend Spontaneous::Output::Assets::Compression
|
14
62
|
|
15
|
-
def
|
16
|
-
|
17
|
-
options = {
|
18
|
-
:load_paths => [Spontaneous.css_dir],
|
19
|
-
# :filename => sass_template,
|
20
|
-
:cache => false,
|
21
|
-
:style => :compressed
|
22
|
-
}
|
23
|
-
paths = paths(filelist)
|
24
|
-
css = paths.map do |path|
|
25
|
-
Sass::Engine.for_file(path, options).render
|
26
|
-
end.join("\n")
|
27
|
-
hash = digest(css)
|
28
|
-
[css, hash]
|
63
|
+
def self.filetype
|
64
|
+
"js"
|
29
65
|
end
|
30
66
|
|
31
|
-
def
|
32
|
-
|
33
|
-
original_size = filesize(paths)
|
34
|
-
compressed = Shine::compress_files(paths, format, options)
|
35
|
-
logger.info("Compressed #{filelist.length} files. Original size #{original_size}, compressed size #{compressed.length}, ratio #{(100*compressed.length.to_f/original_size.to_f).round}%")
|
36
|
-
hash = digest(compressed)
|
37
|
-
[compressed, hash]
|
67
|
+
def self.extension
|
68
|
+
"js"
|
38
69
|
end
|
39
70
|
|
40
|
-
def
|
41
|
-
|
71
|
+
def self.compress(filelist)
|
72
|
+
compress_js(paths(filelist))
|
42
73
|
end
|
43
74
|
|
44
75
|
def paths(filelist)
|
@@ -51,32 +82,16 @@ module Spontaneous
|
|
51
82
|
File.join(Spontaneous.application_dir, filetype, "#{file}.#{extension}")
|
52
83
|
end
|
53
84
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
def self.filetype
|
62
|
-
"js"
|
63
|
-
end
|
64
|
-
def self.extension
|
65
|
-
"js"
|
66
|
-
end
|
67
|
-
def self.compress(filelist)
|
68
|
-
compress_js(filelist)
|
69
|
-
end
|
70
|
-
|
71
|
-
JQUERY = %w(min/2a0c2962537a3181fedfff5c92596ba6d3122dc9)
|
72
|
-
COMPATIBILITY = %w(min/4cf1c493d3379ecba5287758c61238034c0893f9)
|
73
|
-
REQUIRE = %w(min/b8abf302a824c35385ff517b34111e1710ff3b37)
|
74
|
-
LOGIN_JS = %w(min/78ac6b99d96750bb6b9f9aad4cb9cd91cd03f391)
|
75
|
-
EDITING_JS = %w(min/c8efb9b9f7c3f6613fcebc6be60f605b6570a382)
|
85
|
+
# TODO: remove these
|
86
|
+
JQUERY = %w(vendor/jquery)
|
87
|
+
COMPATIBILITY = []#%w(compatibility)
|
88
|
+
REQUIRE = %w(require)
|
89
|
+
LOGIN_JS = %w(login)
|
90
|
+
EDITING_JS = %w(spontaneous)
|
76
91
|
end
|
77
92
|
|
78
93
|
module CSS
|
79
|
-
extend Spontaneous::
|
94
|
+
extend Spontaneous::Output::Assets::Compression
|
80
95
|
|
81
96
|
def self.filetype
|
82
97
|
"css"
|
@@ -86,12 +101,24 @@ module Spontaneous
|
|
86
101
|
end
|
87
102
|
|
88
103
|
def self.compress(filelist)
|
89
|
-
compress_css(filelist)
|
104
|
+
compress_css(paths(filelist))
|
105
|
+
end
|
106
|
+
|
107
|
+
|
108
|
+
def paths(filelist)
|
109
|
+
filelist.map { |file| filepath(file) }.tap do |paths|
|
110
|
+
logger.info("Bundling #{paths.length} files")
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
def filepath(file)
|
115
|
+
File.join(Spontaneous.application_dir, filetype, "#{file}.#{extension}")
|
90
116
|
end
|
91
117
|
|
92
|
-
|
93
|
-
|
94
|
-
|
118
|
+
# TODO: remove these
|
119
|
+
LOGIN_CSS = %w(spontaneous) # login
|
120
|
+
EDITING_CSS = %w(spontaneous)
|
121
|
+
SCHEMA_MODIFICATION_CSS = %w(spontaneous) #schema_error
|
95
122
|
end
|
96
123
|
|
97
124
|
end # Assets
|
@@ -12,7 +12,6 @@ module Spontaneous::Rack
|
|
12
12
|
unless first_level_exceptions.any? { |e| e === request.path }
|
13
13
|
ignore_key = second_level_exceptions.any? { |e| e === request.path }
|
14
14
|
valid_key = ignore_key || Spontaneous::Permissions::AccessKey.valid?(params[KEY_PARAM], user)
|
15
|
-
halt(401, erb(:login, :views => Spontaneous.application_dir('/views'), :locals => { :login => '' })) unless (user and valid_key)
|
16
15
|
show_login_page( :login => '' ) unless (user and valid_key)
|
17
16
|
end
|
18
17
|
}
|