vapid 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.gitmodules +6 -0
- data/.rspec +2 -0
- data/.rubocop.yml +133 -0
- data/.travis.yml +5 -0
- data/Gemfile +10 -0
- data/README.md +37 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/exe/vapid +7 -0
- data/lib/vapid.rb +24 -0
- data/lib/vapid/assets/javascripts/vapid/admin.coffee +2 -0
- data/lib/vapid/assets/stylesheets/vapid/admin.scss +72 -0
- data/lib/vapid/builder.rb +70 -0
- data/lib/vapid/cli.rb +96 -0
- data/lib/vapid/controllers/admin_controller.rb +282 -0
- data/lib/vapid/controllers/project_controller.rb +41 -0
- data/lib/vapid/db/migrate/20170202182310_create_groups.rb +12 -0
- data/lib/vapid/db/migrate/20170202183017_create_records.rb +11 -0
- data/lib/vapid/db/migrate/20170202185150_create_users.rb +11 -0
- data/lib/vapid/directive.rb +168 -0
- data/lib/vapid/directives.rb +30 -0
- data/lib/vapid/directives/audio.rb +27 -0
- data/lib/vapid/directives/group.rb +71 -0
- data/lib/vapid/directives/hide.rb +11 -0
- data/lib/vapid/directives/href.rb +11 -0
- data/lib/vapid/directives/image.rb +14 -0
- data/lib/vapid/directives/richtext.rb +15 -0
- data/lib/vapid/directives/show.rb +11 -0
- data/lib/vapid/directives/text.rb +24 -0
- data/lib/vapid/directives/video.rb +28 -0
- data/lib/vapid/generator_template/.gitignore +21 -0
- data/lib/vapid/generator_template/Gemfile.tt +13 -0
- data/lib/vapid/generator_template/README.md +0 -0
- data/lib/vapid/generator_template/assets/favicon.ico +0 -0
- data/lib/vapid/generator_template/assets/images/.keep +0 -0
- data/lib/vapid/generator_template/assets/javascripts/.keep +0 -0
- data/lib/vapid/generator_template/assets/stylesheets/.keep +0 -0
- data/lib/vapid/generator_template/assets/stylesheets/application.css +120 -0
- data/lib/vapid/generator_template/config.ru +3 -0
- data/lib/vapid/generator_template/config/database.yml +12 -0
- data/lib/vapid/generator_template/config/settings.yml.tt +11 -0
- data/lib/vapid/generator_template/templates/index.html.erb +25 -0
- data/lib/vapid/generator_template/templates/layouts/default.html.erb +22 -0
- data/lib/vapid/models.rb +18 -0
- data/lib/vapid/models/group.rb +36 -0
- data/lib/vapid/models/record.rb +30 -0
- data/lib/vapid/models/user.rb +16 -0
- data/lib/vapid/server.rb +93 -0
- data/lib/vapid/settings.rb +13 -0
- data/lib/vapid/template.rb +79 -0
- data/lib/vapid/template/node.rb +91 -0
- data/lib/vapid/template/parser.rb +50 -0
- data/lib/vapid/vendor/semantic-ui/.versions +4 -0
- data/lib/vapid/vendor/semantic-ui/LICENSE +22 -0
- data/lib/vapid/vendor/semantic-ui/README.md +7 -0
- data/lib/vapid/vendor/semantic-ui/components/accordion.css +252 -0
- data/lib/vapid/vendor/semantic-ui/components/accordion.js +610 -0
- data/lib/vapid/vendor/semantic-ui/components/accordion.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/accordion.min.js +10 -0
- data/lib/vapid/vendor/semantic-ui/components/ad.css +275 -0
- data/lib/vapid/vendor/semantic-ui/components/ad.min.css +10 -0
- data/lib/vapid/vendor/semantic-ui/components/api.js +1167 -0
- data/lib/vapid/vendor/semantic-ui/components/api.min.js +10 -0
- data/lib/vapid/vendor/semantic-ui/components/breadcrumb.css +124 -0
- data/lib/vapid/vendor/semantic-ui/components/breadcrumb.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/button.css +3450 -0
- data/lib/vapid/vendor/semantic-ui/components/button.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/card.css +964 -0
- data/lib/vapid/vendor/semantic-ui/components/card.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/checkbox.css +625 -0
- data/lib/vapid/vendor/semantic-ui/components/checkbox.js +831 -0
- data/lib/vapid/vendor/semantic-ui/components/checkbox.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/checkbox.min.js +10 -0
- data/lib/vapid/vendor/semantic-ui/components/colorize.js +274 -0
- data/lib/vapid/vendor/semantic-ui/components/colorize.min.js +11 -0
- data/lib/vapid/vendor/semantic-ui/components/comment.css +270 -0
- data/lib/vapid/vendor/semantic-ui/components/comment.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/container.css +147 -0
- data/lib/vapid/vendor/semantic-ui/components/container.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/dimmer.css +200 -0
- data/lib/vapid/vendor/semantic-ui/components/dimmer.js +708 -0
- data/lib/vapid/vendor/semantic-ui/components/dimmer.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/dimmer.min.js +10 -0
- data/lib/vapid/vendor/semantic-ui/components/divider.css +260 -0
- data/lib/vapid/vendor/semantic-ui/components/divider.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/dropdown.css +1442 -0
- data/lib/vapid/vendor/semantic-ui/components/dropdown.js +3767 -0
- data/lib/vapid/vendor/semantic-ui/components/dropdown.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/dropdown.min.js +11 -0
- data/lib/vapid/vendor/semantic-ui/components/embed.css +166 -0
- data/lib/vapid/vendor/semantic-ui/components/embed.js +696 -0
- data/lib/vapid/vendor/semantic-ui/components/embed.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/embed.min.js +10 -0
- data/lib/vapid/vendor/semantic-ui/components/feed.css +296 -0
- data/lib/vapid/vendor/semantic-ui/components/feed.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/flag.css +1031 -0
- data/lib/vapid/vendor/semantic-ui/components/flag.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/form.css +1067 -0
- data/lib/vapid/vendor/semantic-ui/components/form.js +1603 -0
- data/lib/vapid/vendor/semantic-ui/components/form.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/form.min.js +10 -0
- data/lib/vapid/vendor/semantic-ui/components/grid.css +2002 -0
- data/lib/vapid/vendor/semantic-ui/components/grid.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/header.css +721 -0
- data/lib/vapid/vendor/semantic-ui/components/header.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/icon.css +3292 -0
- data/lib/vapid/vendor/semantic-ui/components/icon.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/image.css +306 -0
- data/lib/vapid/vendor/semantic-ui/components/image.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/input.css +510 -0
- data/lib/vapid/vendor/semantic-ui/components/input.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/item.css +486 -0
- data/lib/vapid/vendor/semantic-ui/components/item.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/label.css +1307 -0
- data/lib/vapid/vendor/semantic-ui/components/label.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/list.css +951 -0
- data/lib/vapid/vendor/semantic-ui/components/list.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/loader.css +347 -0
- data/lib/vapid/vendor/semantic-ui/components/loader.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/menu.css +2002 -0
- data/lib/vapid/vendor/semantic-ui/components/menu.min.css +1 -0
- data/lib/vapid/vendor/semantic-ui/components/message.css +477 -0
- data/lib/vapid/vendor/semantic-ui/components/message.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/modal.css +502 -0
- data/lib/vapid/vendor/semantic-ui/components/modal.js +913 -0
- data/lib/vapid/vendor/semantic-ui/components/modal.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/modal.min.js +10 -0
- data/lib/vapid/vendor/semantic-ui/components/nag.css +147 -0
- data/lib/vapid/vendor/semantic-ui/components/nag.js +507 -0
- data/lib/vapid/vendor/semantic-ui/components/nag.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/nag.min.js +10 -0
- data/lib/vapid/vendor/semantic-ui/components/popup.css +733 -0
- data/lib/vapid/vendor/semantic-ui/components/popup.js +1475 -0
- data/lib/vapid/vendor/semantic-ui/components/popup.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/popup.min.js +10 -0
- data/lib/vapid/vendor/semantic-ui/components/progress.css +516 -0
- data/lib/vapid/vendor/semantic-ui/components/progress.js +931 -0
- data/lib/vapid/vendor/semantic-ui/components/progress.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/progress.min.js +10 -0
- data/lib/vapid/vendor/semantic-ui/components/rail.css +152 -0
- data/lib/vapid/vendor/semantic-ui/components/rail.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/rating.css +263 -0
- data/lib/vapid/vendor/semantic-ui/components/rating.js +508 -0
- data/lib/vapid/vendor/semantic-ui/components/rating.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/rating.min.js +10 -0
- data/lib/vapid/vendor/semantic-ui/components/reset.css +424 -0
- data/lib/vapid/vendor/semantic-ui/components/reset.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/reveal.css +284 -0
- data/lib/vapid/vendor/semantic-ui/components/reveal.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/search.css +408 -0
- data/lib/vapid/vendor/semantic-ui/components/search.js +1442 -0
- data/lib/vapid/vendor/semantic-ui/components/search.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/search.min.js +10 -0
- data/lib/vapid/vendor/semantic-ui/components/segment.css +798 -0
- data/lib/vapid/vendor/semantic-ui/components/segment.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/shape.css +157 -0
- data/lib/vapid/vendor/semantic-ui/components/shape.js +921 -0
- data/lib/vapid/vendor/semantic-ui/components/shape.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/shape.min.js +10 -0
- data/lib/vapid/vendor/semantic-ui/components/sidebar.css +634 -0
- data/lib/vapid/vendor/semantic-ui/components/sidebar.js +1036 -0
- data/lib/vapid/vendor/semantic-ui/components/sidebar.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/sidebar.min.js +10 -0
- data/lib/vapid/vendor/semantic-ui/components/site.css +160 -0
- data/lib/vapid/vendor/semantic-ui/components/site.js +487 -0
- data/lib/vapid/vendor/semantic-ui/components/site.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/site.min.js +10 -0
- data/lib/vapid/vendor/semantic-ui/components/state.js +708 -0
- data/lib/vapid/vendor/semantic-ui/components/state.min.js +10 -0
- data/lib/vapid/vendor/semantic-ui/components/statistic.css +569 -0
- data/lib/vapid/vendor/semantic-ui/components/statistic.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/step.css +623 -0
- data/lib/vapid/vendor/semantic-ui/components/step.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/sticky.css +78 -0
- data/lib/vapid/vendor/semantic-ui/components/sticky.js +942 -0
- data/lib/vapid/vendor/semantic-ui/components/sticky.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/sticky.min.js +10 -0
- data/lib/vapid/vendor/semantic-ui/components/tab.css +91 -0
- data/lib/vapid/vendor/semantic-ui/components/tab.js +952 -0
- data/lib/vapid/vendor/semantic-ui/components/tab.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/tab.min.js +10 -0
- data/lib/vapid/vendor/semantic-ui/components/table.css +1108 -0
- data/lib/vapid/vendor/semantic-ui/components/table.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/transition.css +1964 -0
- data/lib/vapid/vendor/semantic-ui/components/transition.js +1095 -0
- data/lib/vapid/vendor/semantic-ui/components/transition.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/transition.min.js +10 -0
- data/lib/vapid/vendor/semantic-ui/components/video.css +125 -0
- data/lib/vapid/vendor/semantic-ui/components/video.js +532 -0
- data/lib/vapid/vendor/semantic-ui/components/video.min.css +10 -0
- data/lib/vapid/vendor/semantic-ui/components/video.min.js +11 -0
- data/lib/vapid/vendor/semantic-ui/components/visibility.js +1288 -0
- data/lib/vapid/vendor/semantic-ui/components/visibility.min.js +10 -0
- data/lib/vapid/vendor/semantic-ui/components/visit.js +517 -0
- data/lib/vapid/vendor/semantic-ui/components/visit.min.js +11 -0
- data/lib/vapid/vendor/semantic-ui/package.js +34 -0
- data/lib/vapid/vendor/semantic-ui/package.json +20 -0
- data/lib/vapid/vendor/semantic-ui/semantic.css +36844 -0
- data/lib/vapid/vendor/semantic-ui/semantic.js +22617 -0
- data/lib/vapid/vendor/semantic-ui/semantic.min.css +364 -0
- data/lib/vapid/vendor/semantic-ui/semantic.min.js +19 -0
- data/lib/vapid/vendor/semantic-ui/themes/default/assets/fonts/icons.eot +0 -0
- data/lib/vapid/vendor/semantic-ui/themes/default/assets/fonts/icons.otf +0 -0
- data/lib/vapid/vendor/semantic-ui/themes/default/assets/fonts/icons.svg +2671 -0
- data/lib/vapid/vendor/semantic-ui/themes/default/assets/fonts/icons.ttf +0 -0
- data/lib/vapid/vendor/semantic-ui/themes/default/assets/fonts/icons.woff +0 -0
- data/lib/vapid/vendor/semantic-ui/themes/default/assets/fonts/icons.woff2 +0 -0
- data/lib/vapid/vendor/semantic-ui/themes/default/assets/images/flags.png +0 -0
- data/lib/vapid/vendor/trix/.blade.yml +45 -0
- data/lib/vapid/vendor/trix/.github/ISSUE_TEMPLATE.md +13 -0
- data/lib/vapid/vendor/trix/.gitignore +3 -0
- data/lib/vapid/vendor/trix/.ruby-version +1 -0
- data/lib/vapid/vendor/trix/.travis.yml +6 -0
- data/lib/vapid/vendor/trix/CONDUCT.md +79 -0
- data/lib/vapid/vendor/trix/Gemfile +17 -0
- data/lib/vapid/vendor/trix/Gemfile.lock +152 -0
- data/lib/vapid/vendor/trix/LICENSE +20 -0
- data/lib/vapid/vendor/trix/README.md +382 -0
- data/lib/vapid/vendor/trix/assets/index.html +55 -0
- data/lib/vapid/vendor/trix/assets/trix-core.coffee +2 -0
- data/lib/vapid/vendor/trix/assets/trix.coffee +3 -0
- data/lib/vapid/vendor/trix/assets/trix.scss +5 -0
- data/lib/vapid/vendor/trix/assets/trix/banner/index.coffee.erb +3 -0
- data/lib/vapid/vendor/trix/assets/trix/banner/index.scss.erb +3 -0
- data/lib/vapid/vendor/trix/assets/trix/banner/index.txt.erb +3 -0
- data/lib/vapid/vendor/trix/assets/trix/images/README.md +6 -0
- data/lib/vapid/vendor/trix/assets/trix/images/attach.svg +5 -0
- data/lib/vapid/vendor/trix/assets/trix/images/bold.svg +5 -0
- data/lib/vapid/vendor/trix/assets/trix/images/bullets.svg +5 -0
- data/lib/vapid/vendor/trix/assets/trix/images/code.svg +5 -0
- data/lib/vapid/vendor/trix/assets/trix/images/heading_1.svg +5 -0
- data/lib/vapid/vendor/trix/assets/trix/images/italic.svg +5 -0
- data/lib/vapid/vendor/trix/assets/trix/images/link.svg +6 -0
- data/lib/vapid/vendor/trix/assets/trix/images/nesting_level_decrease.svg +5 -0
- data/lib/vapid/vendor/trix/assets/trix/images/nesting_level_increase.svg +5 -0
- data/lib/vapid/vendor/trix/assets/trix/images/numbers.svg +5 -0
- data/lib/vapid/vendor/trix/assets/trix/images/quote.svg +5 -0
- data/lib/vapid/vendor/trix/assets/trix/images/redo.svg +5 -0
- data/lib/vapid/vendor/trix/assets/trix/images/remove.svg +4 -0
- data/lib/vapid/vendor/trix/assets/trix/images/strike.svg +6 -0
- data/lib/vapid/vendor/trix/assets/trix/images/trash.svg +5 -0
- data/lib/vapid/vendor/trix/assets/trix/images/undo.svg +5 -0
- data/lib/vapid/vendor/trix/assets/trix/stylesheets/attachments.scss +112 -0
- data/lib/vapid/vendor/trix/assets/trix/stylesheets/content.scss +88 -0
- data/lib/vapid/vendor/trix/assets/trix/stylesheets/editor.scss +8 -0
- data/lib/vapid/vendor/trix/assets/trix/stylesheets/icons.scss +14 -0
- data/lib/vapid/vendor/trix/assets/trix/stylesheets/media-queries.scss +7 -0
- data/lib/vapid/vendor/trix/assets/trix/stylesheets/toolbar.scss +194 -0
- data/lib/vapid/vendor/trix/bin/blade +16 -0
- data/lib/vapid/vendor/trix/bin/ci +21 -0
- data/lib/vapid/vendor/trix/bin/rackup +16 -0
- data/lib/vapid/vendor/trix/bin/rake +16 -0
- data/lib/vapid/vendor/trix/bin/release +139 -0
- data/lib/vapid/vendor/trix/bin/setup +69 -0
- data/lib/vapid/vendor/trix/bin/update-status-image +100 -0
- data/lib/vapid/vendor/trix/bower.json +34 -0
- data/lib/vapid/vendor/trix/config.ru +32 -0
- data/lib/vapid/vendor/trix/dist/trix-core.js +11 -0
- data/lib/vapid/vendor/trix/dist/trix.css +286 -0
- data/lib/vapid/vendor/trix/dist/trix.js +20 -0
- data/lib/vapid/vendor/trix/package.json +29 -0
- data/lib/vapid/vendor/trix/polyfills/polyfills.coffee +3 -0
- data/lib/vapid/vendor/trix/polyfills/set.coffee +24 -0
- data/lib/vapid/vendor/trix/polyfills/vendor/CustomElements.js +1029 -0
- data/lib/vapid/vendor/trix/polyfills/vendor/README.md +2 -0
- data/lib/vapid/vendor/trix/polyfills/vendor/promise.js +228 -0
- data/lib/vapid/vendor/trix/src/trix/VERSION +1 -0
- data/lib/vapid/vendor/trix/src/trix/config/block_attributes.coffee +37 -0
- data/lib/vapid/vendor/trix/src/trix/config/css.coffee +12 -0
- data/lib/vapid/vendor/trix/src/trix/config/file_size_formatting.coffee +22 -0
- data/lib/vapid/vendor/trix/src/trix/config/index.coffee +9 -0
- data/lib/vapid/vendor/trix/src/trix/config/lang.coffee +26 -0
- data/lib/vapid/vendor/trix/src/trix/config/selection_elements.coffee +26 -0
- data/lib/vapid/vendor/trix/src/trix/config/serialization.coffee +63 -0
- data/lib/vapid/vendor/trix/src/trix/config/text_attributes.coffee +25 -0
- data/lib/vapid/vendor/trix/src/trix/config/toolbar.coffee +41 -0
- data/lib/vapid/vendor/trix/src/trix/config/undo_interval.coffee +7 -0
- data/lib/vapid/vendor/trix/src/trix/controllers/attachment_editor_controller.coffee +104 -0
- data/lib/vapid/vendor/trix/src/trix/controllers/composition_controller.coffee +117 -0
- data/lib/vapid/vendor/trix/src/trix/controllers/controller.coffee +3 -0
- data/lib/vapid/vendor/trix/src/trix/controllers/editor_controller.coffee +369 -0
- data/lib/vapid/vendor/trix/src/trix/controllers/input/composition_input.coffee +57 -0
- data/lib/vapid/vendor/trix/src/trix/controllers/input_controller.coffee +473 -0
- data/lib/vapid/vendor/trix/src/trix/controllers/toolbar_controller.coffee +173 -0
- data/lib/vapid/vendor/trix/src/trix/core/basic_object.coffee +44 -0
- data/lib/vapid/vendor/trix/src/trix/core/collections/element_store.coffee +21 -0
- data/lib/vapid/vendor/trix/src/trix/core/collections/hash.coffee +98 -0
- data/lib/vapid/vendor/trix/src/trix/core/collections/index.coffee +4 -0
- data/lib/vapid/vendor/trix/src/trix/core/collections/object_group.coffee +37 -0
- data/lib/vapid/vendor/trix/src/trix/core/collections/object_map.coffee +10 -0
- data/lib/vapid/vendor/trix/src/trix/core/helpers/arrays.coffee +34 -0
- data/lib/vapid/vendor/trix/src/trix/core/helpers/config.coffee +23 -0
- data/lib/vapid/vendor/trix/src/trix/core/helpers/custom_elements.coffee +45 -0
- data/lib/vapid/vendor/trix/src/trix/core/helpers/dom.coffee +185 -0
- data/lib/vapid/vendor/trix/src/trix/core/helpers/extend.coffee +4 -0
- data/lib/vapid/vendor/trix/src/trix/core/helpers/functions.coffee +3 -0
- data/lib/vapid/vendor/trix/src/trix/core/helpers/global.coffee +23 -0
- data/lib/vapid/vendor/trix/src/trix/core/helpers/index.coffee +10 -0
- data/lib/vapid/vendor/trix/src/trix/core/helpers/objects.coffee +11 -0
- data/lib/vapid/vendor/trix/src/trix/core/helpers/ranges.coffee +33 -0
- data/lib/vapid/vendor/trix/src/trix/core/helpers/selection.coffee +25 -0
- data/lib/vapid/vendor/trix/src/trix/core/helpers/strings.coffee +46 -0
- data/lib/vapid/vendor/trix/src/trix/core/index.coffee +4 -0
- data/lib/vapid/vendor/trix/src/trix/core/object.coffee +33 -0
- data/lib/vapid/vendor/trix/src/trix/core/utilities/index.coffee +2 -0
- data/lib/vapid/vendor/trix/src/trix/core/utilities/operation.coffee +37 -0
- data/lib/vapid/vendor/trix/src/trix/core/utilities/utf16_string.coffee +93 -0
- data/lib/vapid/vendor/trix/src/trix/elements/trix_editor_element.coffee +166 -0
- data/lib/vapid/vendor/trix/src/trix/elements/trix_toolbar_element.coffee +28 -0
- data/lib/vapid/vendor/trix/src/trix/index.coffee.erb +14 -0
- data/lib/vapid/vendor/trix/src/trix/inspector/control_element.coffee +60 -0
- data/lib/vapid/vendor/trix/src/trix/inspector/debugger.coffee +104 -0
- data/lib/vapid/vendor/trix/src/trix/inspector/element.coffee +86 -0
- data/lib/vapid/vendor/trix/src/trix/inspector/index.coffee +17 -0
- data/lib/vapid/vendor/trix/src/trix/inspector/polyfills/vendor/details-element-polyfill.js +5 -0
- data/lib/vapid/vendor/trix/src/trix/inspector/templates/debug.jst.eco +17 -0
- data/lib/vapid/vendor/trix/src/trix/inspector/templates/document.jst.eco +33 -0
- data/lib/vapid/vendor/trix/src/trix/inspector/templates/performance.jst.eco +10 -0
- data/lib/vapid/vendor/trix/src/trix/inspector/templates/render.jst.eco +1 -0
- data/lib/vapid/vendor/trix/src/trix/inspector/templates/selection.jst.eco +5 -0
- data/lib/vapid/vendor/trix/src/trix/inspector/templates/undo.jst.eco +13 -0
- data/lib/vapid/vendor/trix/src/trix/inspector/view.coffee +58 -0
- data/lib/vapid/vendor/trix/src/trix/inspector/views/debug_view.coffee +33 -0
- data/lib/vapid/vendor/trix/src/trix/inspector/views/document_view.coffee +12 -0
- data/lib/vapid/vendor/trix/src/trix/inspector/views/performance_view.coffee +51 -0
- data/lib/vapid/vendor/trix/src/trix/inspector/views/render_view.coffee +21 -0
- data/lib/vapid/vendor/trix/src/trix/inspector/views/selection_view.coffee +33 -0
- data/lib/vapid/vendor/trix/src/trix/inspector/views/undo_view.coffee +12 -0
- data/lib/vapid/vendor/trix/src/trix/inspector/watchdog/deserializer.coffee +55 -0
- data/lib/vapid/vendor/trix/src/trix/inspector/watchdog/index.coffee +5 -0
- data/lib/vapid/vendor/trix/src/trix/inspector/watchdog/player.coffee +60 -0
- data/lib/vapid/vendor/trix/src/trix/inspector/watchdog/player_controller.coffee +43 -0
- data/lib/vapid/vendor/trix/src/trix/inspector/watchdog/player_element.coffee +32 -0
- data/lib/vapid/vendor/trix/src/trix/inspector/watchdog/player_view.coffee +133 -0
- data/lib/vapid/vendor/trix/src/trix/inspector/watchdog/recorder.coffee +82 -0
- data/lib/vapid/vendor/trix/src/trix/inspector/watchdog/recording.coffee +54 -0
- data/lib/vapid/vendor/trix/src/trix/inspector/watchdog/serializer.coffee +61 -0
- data/lib/vapid/vendor/trix/src/trix/models/attachment.coffee +157 -0
- data/lib/vapid/vendor/trix/src/trix/models/attachment_manager.coffee +24 -0
- data/lib/vapid/vendor/trix/src/trix/models/attachment_piece.coffee +47 -0
- data/lib/vapid/vendor/trix/src/trix/models/block.coffee +230 -0
- data/lib/vapid/vendor/trix/src/trix/models/composition.coffee +521 -0
- data/lib/vapid/vendor/trix/src/trix/models/document.coffee +538 -0
- data/lib/vapid/vendor/trix/src/trix/models/editor.coffee +141 -0
- data/lib/vapid/vendor/trix/src/trix/models/html_parser.coffee +335 -0
- data/lib/vapid/vendor/trix/src/trix/models/line_break_insertion.coffee +31 -0
- data/lib/vapid/vendor/trix/src/trix/models/location_mapper.coffee +156 -0
- data/lib/vapid/vendor/trix/src/trix/models/managed_attachment.coffee +28 -0
- data/lib/vapid/vendor/trix/src/trix/models/piece.coffee +95 -0
- data/lib/vapid/vendor/trix/src/trix/models/point_mapper.coffee +28 -0
- data/lib/vapid/vendor/trix/src/trix/models/selection_manager.coffee +129 -0
- data/lib/vapid/vendor/trix/src/trix/models/splittable_list.coffee +168 -0
- data/lib/vapid/vendor/trix/src/trix/models/string_piece.coffee +49 -0
- data/lib/vapid/vendor/trix/src/trix/models/text.coffee +168 -0
- data/lib/vapid/vendor/trix/src/trix/models/undo_manager.coffee +40 -0
- data/lib/vapid/vendor/trix/src/trix/observers/mutation_observer.coffee +131 -0
- data/lib/vapid/vendor/trix/src/trix/observers/selection_change_observer.coffee +56 -0
- data/lib/vapid/vendor/trix/src/trix/operations/file_verification_operation.coffee +15 -0
- data/lib/vapid/vendor/trix/src/trix/operations/image_preload_operation.coffee +15 -0
- data/lib/vapid/vendor/trix/src/trix/views/attachment_view.coffee +99 -0
- data/lib/vapid/vendor/trix/src/trix/views/block_view.coffee +37 -0
- data/lib/vapid/vendor/trix/src/trix/views/document_view.coffee +68 -0
- data/lib/vapid/vendor/trix/src/trix/views/object_group_view.coffee +23 -0
- data/lib/vapid/vendor/trix/src/trix/views/object_view.coffee +86 -0
- data/lib/vapid/vendor/trix/src/trix/views/piece_view.coffee +97 -0
- data/lib/vapid/vendor/trix/src/trix/views/previewable_attachment_view.coffee +49 -0
- data/lib/vapid/vendor/trix/src/trix/views/text_view.coffee +30 -0
- data/lib/vapid/vendor/trix/test/.gitignore +1 -0
- data/lib/vapid/vendor/trix/test/src/system/attachment_test.coffee +70 -0
- data/lib/vapid/vendor/trix/test/src/system/basic_input_test.coffee +68 -0
- data/lib/vapid/vendor/trix/test/src/system/block_formatting_test.coffee +602 -0
- data/lib/vapid/vendor/trix/test/src/system/caching_test.coffee +21 -0
- data/lib/vapid/vendor/trix/test/src/system/composition_input_test.coffee +138 -0
- data/lib/vapid/vendor/trix/test/src/system/cursor_movement_test.coffee +54 -0
- data/lib/vapid/vendor/trix/test/src/system/custom_element_test.coffee +314 -0
- data/lib/vapid/vendor/trix/test/src/system/html_loading_test.coffee +62 -0
- data/lib/vapid/vendor/trix/test/src/system/html_replacement_test.coffee +101 -0
- data/lib/vapid/vendor/trix/test/src/system/installation_process_test.coffee +59 -0
- data/lib/vapid/vendor/trix/test/src/system/list_formatting_test.coffee +70 -0
- data/lib/vapid/vendor/trix/test/src/system/mutation_input_test.coffee +73 -0
- data/lib/vapid/vendor/trix/test/src/system/pasting_test.coffee +215 -0
- data/lib/vapid/vendor/trix/test/src/system/text_formatting_test.coffee +151 -0
- data/lib/vapid/vendor/trix/test/src/system/undo_test.coffee +48 -0
- data/lib/vapid/vendor/trix/test/src/test.coffee +16 -0
- data/lib/vapid/vendor/trix/test/src/test_helpers/assertions.coffee +38 -0
- data/lib/vapid/vendor/trix/test/src/test_helpers/editor_helpers.coffee +37 -0
- data/lib/vapid/vendor/trix/test/src/test_helpers/fixtures/editor_empty.jst.eco +1 -0
- data/lib/vapid/vendor/trix/test/src/test_helpers/fixtures/editor_html.jst.eco +2 -0
- data/lib/vapid/vendor/trix/test/src/test_helpers/fixtures/editor_in_table.jst.eco +7 -0
- data/lib/vapid/vendor/trix/test/src/test_helpers/fixtures/editor_with_block_styles.jst.eco +6 -0
- data/lib/vapid/vendor/trix/test/src/test_helpers/fixtures/editor_with_bold_styles.jst.eco +7 -0
- data/lib/vapid/vendor/trix/test/src/test_helpers/fixtures/editor_with_image.jst.eco +2 -0
- data/lib/vapid/vendor/trix/test/src/test_helpers/fixtures/editor_with_styled_content.jst.eco +7 -0
- data/lib/vapid/vendor/trix/test/src/test_helpers/fixtures/editor_with_toolbar_and_input.jst.eco +5 -0
- data/lib/vapid/vendor/trix/test/src/test_helpers/fixtures/fixtures.coffee +536 -0
- data/lib/vapid/vendor/trix/test/src/test_helpers/fixtures/logo.png +0 -0
- data/lib/vapid/vendor/trix/test/src/test_helpers/index.coffee +18 -0
- data/lib/vapid/vendor/trix/test/src/test_helpers/input_helpers.coffee +183 -0
- data/lib/vapid/vendor/trix/test/src/test_helpers/selection_helpers.coffee +91 -0
- data/lib/vapid/vendor/trix/test/src/test_helpers/test_helpers.coffee +72 -0
- data/lib/vapid/vendor/trix/test/src/test_helpers/test_stubs.coffee +31 -0
- data/lib/vapid/vendor/trix/test/src/test_helpers/toolbar_helpers.coffee +45 -0
- data/lib/vapid/vendor/trix/test/src/unit/attachment_test.coffee +23 -0
- data/lib/vapid/vendor/trix/test/src/unit/block_test.coffee +22 -0
- data/lib/vapid/vendor/trix/test/src/unit/composition_test.coffee +13 -0
- data/lib/vapid/vendor/trix/test/src/unit/document_test.coffee +11 -0
- data/lib/vapid/vendor/trix/test/src/unit/document_view_test.coffee +6 -0
- data/lib/vapid/vendor/trix/test/src/unit/html_parser_test.coffee +162 -0
- data/lib/vapid/vendor/trix/test/src/unit/location_mapper_test.coffee +185 -0
- data/lib/vapid/vendor/trix/test/src/unit/mutation_observer_test.coffee +84 -0
- data/lib/vapid/vendor/trix/test/src/unit/serialization_test.coffee +7 -0
- data/lib/vapid/vendor/trix/test/src/unit/string_change_summary_test.coffee +57 -0
- data/lib/vapid/vendor/trix/test/src/unit/text_test.coffee +19 -0
- data/lib/vapid/vendor/trix/test/vendor/rangy-core.js +3845 -0
- data/lib/vapid/vendor/trix/test/vendor/rangy-textrange.js +1930 -0
- data/lib/vapid/version.rb +4 -0
- data/lib/vapid/views/admin/install.html.erb +19 -0
- data/lib/vapid/views/admin/login.html.erb +11 -0
- data/lib/vapid/views/admin/overview/index.html.erb +1 -0
- data/lib/vapid/views/admin/records/_form.erb +9 -0
- data/lib/vapid/views/admin/records/edit.html.erb +5 -0
- data/lib/vapid/views/admin/records/index.html.erb +38 -0
- data/lib/vapid/views/admin/records/new.html.erb +3 -0
- data/lib/vapid/views/errors/404.html.erb +1 -0
- data/lib/vapid/views/errors/500.html.erb +1 -0
- data/lib/vapid/views/layouts/admin.html.erb +41 -0
- data/lib/vapid/views/layouts/admin_form.html.erb +22 -0
- data/lib/vapid/views/layouts/error.html.erb +11 -0
- data/vapid.gemspec +48 -0
- metadata +811 -0
@@ -0,0 +1,60 @@
|
|
1
|
+
#= require trix/watchdog/recording
|
2
|
+
|
3
|
+
class Trix.Watchdog.Player
|
4
|
+
constructor: (@recording) ->
|
5
|
+
@playing = false
|
6
|
+
@index = -1
|
7
|
+
@length = @recording.getFrameCount()
|
8
|
+
|
9
|
+
play: ->
|
10
|
+
return if @playing
|
11
|
+
@index = -1 if @hasEnded()
|
12
|
+
@playing = true
|
13
|
+
@delegate?.playerDidStartPlaying?()
|
14
|
+
@tick()
|
15
|
+
|
16
|
+
tick: =>
|
17
|
+
if @hasEnded()
|
18
|
+
@stop()
|
19
|
+
else
|
20
|
+
@seek(@index + 1)
|
21
|
+
duration = @getTimeToNextFrame()
|
22
|
+
@timeout = setTimeout(@tick, duration)
|
23
|
+
|
24
|
+
seek: (index) ->
|
25
|
+
previousIndex = @index
|
26
|
+
|
27
|
+
if index < 0
|
28
|
+
@index = 0
|
29
|
+
else if index >= @length
|
30
|
+
@index = @length - 1
|
31
|
+
else
|
32
|
+
@index = index
|
33
|
+
|
34
|
+
if @index isnt previousIndex
|
35
|
+
@delegate?.playerDidSeekToIndex?(index)
|
36
|
+
|
37
|
+
stop: ->
|
38
|
+
return unless @playing
|
39
|
+
clearTimeout(@timeout)
|
40
|
+
@timeout = null
|
41
|
+
@playing = false
|
42
|
+
@delegate?.playerDidStopPlaying?()
|
43
|
+
|
44
|
+
isPlaying: ->
|
45
|
+
@playing
|
46
|
+
|
47
|
+
hasEnded: ->
|
48
|
+
@index >= @length - 1
|
49
|
+
|
50
|
+
getSnapshot: ->
|
51
|
+
@recording.getSnapshotAtFrameIndex(@index)
|
52
|
+
|
53
|
+
getEvents: ->
|
54
|
+
@recording.getEventsUpToFrameIndex(@index)
|
55
|
+
|
56
|
+
getTimeToNextFrame: ->
|
57
|
+
current = @recording.getTimestampAtFrameIndex(@index)
|
58
|
+
next = @recording.getTimestampAtFrameIndex(@index + 1)
|
59
|
+
duration = if current? and next? then next - current else 0
|
60
|
+
Math.min(duration, 500)
|
@@ -0,0 +1,43 @@
|
|
1
|
+
#= require trix/watchdog/player
|
2
|
+
#= require trix/watchdog/player_view
|
3
|
+
|
4
|
+
class Trix.Watchdog.PlayerController
|
5
|
+
constructor: (@element, @recording) ->
|
6
|
+
@player = new Trix.Watchdog.Player @recording
|
7
|
+
@player.delegate = this
|
8
|
+
|
9
|
+
@view = new Trix.Watchdog.PlayerView @element
|
10
|
+
@view.delegate = this
|
11
|
+
|
12
|
+
@view.setLength(@player.length)
|
13
|
+
@player.seek(0)
|
14
|
+
|
15
|
+
play: ->
|
16
|
+
@player.play()
|
17
|
+
|
18
|
+
stop: ->
|
19
|
+
@player.stop()
|
20
|
+
|
21
|
+
playerViewDidClickPlayButton: ->
|
22
|
+
if @player.isPlaying()
|
23
|
+
@player.stop()
|
24
|
+
else
|
25
|
+
@player.play()
|
26
|
+
|
27
|
+
playerViewDidChangeSliderValue: (value) ->
|
28
|
+
@player.seek(value)
|
29
|
+
|
30
|
+
playerDidSeekToIndex: (index) ->
|
31
|
+
@view.setIndex(index)
|
32
|
+
|
33
|
+
if snapshot = @player.getSnapshot(index)
|
34
|
+
@view.renderSnapshot(snapshot)
|
35
|
+
|
36
|
+
if events = @player.getEvents(index)
|
37
|
+
@view.renderEvents(events)
|
38
|
+
|
39
|
+
playerDidStartPlaying: ->
|
40
|
+
@view.playerDidStartPlaying()
|
41
|
+
|
42
|
+
playerDidStopPlaying: ->
|
43
|
+
@view.playerDidStopPlaying()
|
@@ -0,0 +1,32 @@
|
|
1
|
+
#= require trix/watchdog/recording
|
2
|
+
#= require trix/watchdog/player_controller
|
3
|
+
|
4
|
+
Trix.registerElement "trix-watchdog-player",
|
5
|
+
defaultCSS: """
|
6
|
+
%t > div { display: -webkit-flex; display: flex; font-size: 14px; margin: 10px 0 }
|
7
|
+
%t > div > button { width: 65px }
|
8
|
+
%t > div > input { width: 100%; -webkit-align-self: stretch; align-self: stretch; margin: 0 20px }
|
9
|
+
%t > div > span { display: inline-block; text-align: center; width: 110px }
|
10
|
+
"""
|
11
|
+
|
12
|
+
attachedCallback: ->
|
13
|
+
if url = @getAttribute("src")
|
14
|
+
@fetchRecordingAtURL(url)
|
15
|
+
|
16
|
+
attributeChangedCallback: (attributeName, oldValue, newValue) ->
|
17
|
+
if attributeName is "src"
|
18
|
+
@fetchRecordingAtURL(newValue)
|
19
|
+
|
20
|
+
fetchRecordingAtURL: (url) ->
|
21
|
+
@activeRequest?.abort()
|
22
|
+
@activeRequest = new XMLHttpRequest
|
23
|
+
@activeRequest.open("GET", url)
|
24
|
+
@activeRequest.send()
|
25
|
+
@activeRequest.onload = =>
|
26
|
+
json = @activeRequest.responseText
|
27
|
+
@activeRequest = null
|
28
|
+
recording = Trix.Watchdog.Recording.fromJSON(JSON.parse(json))
|
29
|
+
@loadRecording(recording)
|
30
|
+
|
31
|
+
loadRecording: (recording) ->
|
32
|
+
@controller = new Trix.Watchdog.PlayerController this, recording
|
@@ -0,0 +1,133 @@
|
|
1
|
+
#= require trix/watchdog/deserializer
|
2
|
+
|
3
|
+
class Trix.Watchdog.PlayerView
|
4
|
+
@documentClassName: "trix-watchdog-player"
|
5
|
+
@playingClassName: "trix-watchdog-player-playing"
|
6
|
+
|
7
|
+
constructor: (@element) ->
|
8
|
+
@frame = document.createElement("iframe")
|
9
|
+
@frame.style.border = "none"
|
10
|
+
@frame.style.width = "100%"
|
11
|
+
@frame.onload = @frameDidLoadDefaultDocument
|
12
|
+
@frame.onblur = @frameDidLoseFocus
|
13
|
+
|
14
|
+
controlsContainer = document.createElement("div")
|
15
|
+
|
16
|
+
@playButton = document.createElement("button")
|
17
|
+
@playButton.textContent = "Play"
|
18
|
+
@playButton.onclick = @didClickPlayButton
|
19
|
+
|
20
|
+
@slider = document.createElement("input")
|
21
|
+
@slider.type = "range"
|
22
|
+
@slider.oninput = @didChangeSliderValue
|
23
|
+
|
24
|
+
@indexLabel = document.createElement("span")
|
25
|
+
|
26
|
+
logContainer = document.createElement("div")
|
27
|
+
|
28
|
+
@log = document.createElement("textarea")
|
29
|
+
@log.setAttribute("readonly", "")
|
30
|
+
@log.rows = 4
|
31
|
+
|
32
|
+
render(controlsContainer, @playButton, @slider, @indexLabel)
|
33
|
+
render(logContainer, @log)
|
34
|
+
render(@element, @frame, controlsContainer, logContainer)
|
35
|
+
@setIndex(0)
|
36
|
+
|
37
|
+
renderSnapshot: (snapshot) ->
|
38
|
+
if @body
|
39
|
+
{element, range} = @deserializeSnapshot(snapshot)
|
40
|
+
render(@body, element)
|
41
|
+
select(@document, range)
|
42
|
+
@updateFrame()
|
43
|
+
else
|
44
|
+
@snapshot = snapshot
|
45
|
+
|
46
|
+
renderEvents: (events) ->
|
47
|
+
renderedEvents = for event, index in events by -1
|
48
|
+
@renderEvent(event, index)
|
49
|
+
@log.innerText = renderedEvents.join("\n")
|
50
|
+
|
51
|
+
setIndex: (index) ->
|
52
|
+
@slider.value = index
|
53
|
+
@indexLabel.textContent = "Frame #{index}"
|
54
|
+
|
55
|
+
setLength: (length) ->
|
56
|
+
@slider.max = length - 1
|
57
|
+
|
58
|
+
playerDidStartPlaying: ->
|
59
|
+
@element.classList.add(@constructor.playingClassName)
|
60
|
+
@playButton.textContent = "Pause"
|
61
|
+
|
62
|
+
playerDidStopPlaying: ->
|
63
|
+
@element.classList.remove(@constructor.playingClassName)
|
64
|
+
@playButton.textContent = "Play"
|
65
|
+
|
66
|
+
frameDidLoadDefaultDocument: =>
|
67
|
+
@document = @frame.contentDocument
|
68
|
+
@document.documentElement.classList.add(@constructor.documentClassName)
|
69
|
+
|
70
|
+
@document.head.innerHTML = document.head.innerHTML
|
71
|
+
for stylesheet in @document.head.querySelectorAll("link[rel=stylesheet]")
|
72
|
+
stylesheet.onload = @frameDidLoadStylesheet
|
73
|
+
|
74
|
+
@body = @document.body
|
75
|
+
@body.style.cssText = "margin: 0; padding: 0"
|
76
|
+
@body.onkeydown = (event) -> event.preventDefault()
|
77
|
+
|
78
|
+
if @snapshot
|
79
|
+
@renderSnapshot(snapshot)
|
80
|
+
@snapshot = null
|
81
|
+
|
82
|
+
frameDidLoadStylesheet: =>
|
83
|
+
@updateFrame()
|
84
|
+
|
85
|
+
frameDidLoseFocus: =>
|
86
|
+
if @element.classList.contains(@constructor.playingClassName)
|
87
|
+
requestAnimationFrame(@updateFrame)
|
88
|
+
|
89
|
+
didClickPlayButton: =>
|
90
|
+
@delegate?.playerViewDidClickPlayButton?()
|
91
|
+
|
92
|
+
didChangeSliderValue: =>
|
93
|
+
value = parseInt(@slider.value, 10)
|
94
|
+
@delegate?.playerViewDidChangeSliderValue?(value)
|
95
|
+
|
96
|
+
renderEvent: (event, index) ->
|
97
|
+
description = switch event.type
|
98
|
+
when "input"
|
99
|
+
"Browser input event received"
|
100
|
+
when "keypress"
|
101
|
+
key = event.character ? event.charCode ? event.keyCode
|
102
|
+
"Key pressed: #{JSON.stringify(key)}"
|
103
|
+
when "log"
|
104
|
+
event.message
|
105
|
+
when "snapshot"
|
106
|
+
"DOM update"
|
107
|
+
|
108
|
+
"[#{index}] #{description}"
|
109
|
+
|
110
|
+
deserializeSnapshot: (snapshot) ->
|
111
|
+
deserializer = new Trix.Watchdog.Deserializer @document, snapshot
|
112
|
+
element: deserializer.getElement()
|
113
|
+
range: deserializer.getRange()
|
114
|
+
|
115
|
+
updateFrame: =>
|
116
|
+
@frame.style.height = 0
|
117
|
+
@frame.style.height = @body.scrollHeight + "px"
|
118
|
+
@frame.focus()
|
119
|
+
@frame.contentWindow.focus()
|
120
|
+
|
121
|
+
clear = (element) ->
|
122
|
+
element.removeChild(element.lastChild) while element.lastChild
|
123
|
+
|
124
|
+
render = (element, contents...) ->
|
125
|
+
clear(element)
|
126
|
+
element.appendChild(content) for content in contents
|
127
|
+
|
128
|
+
select = (document, range) ->
|
129
|
+
return unless range
|
130
|
+
window = document.defaultView
|
131
|
+
selection = window.getSelection()
|
132
|
+
selection.removeAllRanges()
|
133
|
+
selection.addRange(range)
|
@@ -0,0 +1,82 @@
|
|
1
|
+
#= require trix/watchdog/recording
|
2
|
+
#= require trix/watchdog/serializer
|
3
|
+
|
4
|
+
class Trix.Watchdog.Recorder
|
5
|
+
constructor: (@element, {@snapshotLimit} = {}) ->
|
6
|
+
@recording = new Trix.Watchdog.Recording
|
7
|
+
|
8
|
+
start: ->
|
9
|
+
return if @started
|
10
|
+
@installMutationObserver()
|
11
|
+
@installEventListeners()
|
12
|
+
@recordSnapshot()
|
13
|
+
@started = true
|
14
|
+
|
15
|
+
stop: ->
|
16
|
+
return unless @started
|
17
|
+
@uninstallMutationObserver()
|
18
|
+
@uninstallEventListeners()
|
19
|
+
@started = false
|
20
|
+
|
21
|
+
log: (message) ->
|
22
|
+
@recording.recordEvent(type: "log", message: message)
|
23
|
+
|
24
|
+
installMutationObserver: ->
|
25
|
+
@mutationObserver = new MutationObserver @recordSnapshotDuringNextAnimationFrame
|
26
|
+
@mutationObserver.observe(@element, attributes: true, characterData: true, childList: true, subtree: true)
|
27
|
+
|
28
|
+
uninstallMutationObserver: ->
|
29
|
+
@mutationObserver.disconnect()
|
30
|
+
@mutationObserver = null
|
31
|
+
|
32
|
+
recordSnapshotDuringNextAnimationFrame: =>
|
33
|
+
@animationFrameRequest ?= requestAnimationFrame =>
|
34
|
+
@animationFrameRequest = null
|
35
|
+
@recordSnapshot()
|
36
|
+
|
37
|
+
installEventListeners: ->
|
38
|
+
@element.addEventListener("input", @handleEvent, true)
|
39
|
+
@element.addEventListener("keypress", @handleEvent, true)
|
40
|
+
document.addEventListener("selectionchange", @handleEvent, true)
|
41
|
+
|
42
|
+
uninstallEventListeners: ->
|
43
|
+
@element.removeEventListener("input", @handleEvent, true)
|
44
|
+
@element.removeEventListener("keypress", @handleEvent, true)
|
45
|
+
document.removeEventListener("selectionchange", @handleEvent, true)
|
46
|
+
|
47
|
+
handleEvent: (event) =>
|
48
|
+
switch event.type
|
49
|
+
when "input"
|
50
|
+
@recordInputEvent(event)
|
51
|
+
when "keypress"
|
52
|
+
@recordKeypressEvent(event)
|
53
|
+
when "selectionchange"
|
54
|
+
@recordSnapshotDuringNextAnimationFrame()
|
55
|
+
|
56
|
+
recordInputEvent: (event) ->
|
57
|
+
@recording.recordEvent(type: "input")
|
58
|
+
|
59
|
+
recordKeypressEvent: (event) ->
|
60
|
+
@recording.recordEvent
|
61
|
+
type: "keypress"
|
62
|
+
altKey: event.altKey
|
63
|
+
ctrlKey: event.ctrlKey
|
64
|
+
metaKey: event.metaKey
|
65
|
+
shiftKey: event.shiftKey
|
66
|
+
keyCode: event.keyCode
|
67
|
+
charCode: event.charCode
|
68
|
+
character: characterFromKeyboardEvent(event)
|
69
|
+
|
70
|
+
recordSnapshot: ->
|
71
|
+
@recording.recordSnapshot(@getSnapshot())
|
72
|
+
@recording.truncateToSnapshotCount(@snapshotLimit) if @snapshotLimit?
|
73
|
+
|
74
|
+
getSnapshot: ->
|
75
|
+
serializer = new Trix.Watchdog.Serializer @element
|
76
|
+
serializer.getSnapshot()
|
77
|
+
|
78
|
+
characterFromKeyboardEvent = (event) ->
|
79
|
+
if event.which is null
|
80
|
+
String.fromCharCode(event.keyCode)
|
81
|
+
else if event.which isnt 0 and event.charCode isnt 0
|
82
|
+
String.fromCharCode(event.charCode)
|
@@ -0,0 +1,54 @@
|
|
1
|
+
class Trix.Watchdog.Recording
|
2
|
+
@fromJSON: ({snapshots, frames}) ->
|
3
|
+
new this snapshots, frames
|
4
|
+
|
5
|
+
constructor: (@snapshots = [], @frames = []) ->
|
6
|
+
|
7
|
+
recordSnapshot: (snapshot) ->
|
8
|
+
snapshotJSON = JSON.stringify(snapshot)
|
9
|
+
if snapshotJSON isnt @lastSnapshotJSON
|
10
|
+
@lastSnapshotJSON = snapshotJSON
|
11
|
+
@snapshots.push(snapshot)
|
12
|
+
@recordEvent(type: "snapshot")
|
13
|
+
|
14
|
+
recordEvent: (event) ->
|
15
|
+
frame = [@getTimestamp(), @snapshots.length - 1, event]
|
16
|
+
@frames.push(frame)
|
17
|
+
|
18
|
+
getSnapshotAtIndex: (index) ->
|
19
|
+
@snapshots[index] if index >= 0
|
20
|
+
|
21
|
+
getSnapshotAtFrameIndex: (frameIndex) ->
|
22
|
+
snapshotIndex = @getSnapshotIndexAtFrameIndex(frameIndex)
|
23
|
+
@getSnapshotAtIndex(snapshotIndex)
|
24
|
+
|
25
|
+
getTimestampAtFrameIndex: (index) ->
|
26
|
+
@frames[index]?[0]
|
27
|
+
|
28
|
+
getSnapshotIndexAtFrameIndex: (index) ->
|
29
|
+
@frames[index]?[1]
|
30
|
+
|
31
|
+
getEventAtFrameIndex: (index) ->
|
32
|
+
@frames[index]?[2]
|
33
|
+
|
34
|
+
getEventsUpToFrameIndex: (index) ->
|
35
|
+
frame[2] for frame in @frames.slice(0, index + 1)
|
36
|
+
|
37
|
+
getFrameCount: ->
|
38
|
+
@frames.length
|
39
|
+
|
40
|
+
getTimestamp: ->
|
41
|
+
new Date().getTime()
|
42
|
+
|
43
|
+
truncateToSnapshotCount: (snapshotCount) ->
|
44
|
+
offset = @snapshots.length - snapshotCount
|
45
|
+
return if offset < 0
|
46
|
+
|
47
|
+
frames = @frames
|
48
|
+
@frames = for [timestamp, index, event] in frames when index >= offset
|
49
|
+
[timestamp, index - offset, event]
|
50
|
+
|
51
|
+
@snapshots = @snapshots.slice(offset)
|
52
|
+
|
53
|
+
toJSON: ->
|
54
|
+
{@snapshots, @frames}
|
@@ -0,0 +1,61 @@
|
|
1
|
+
class Trix.Watchdog.Serializer
|
2
|
+
constructor: (@element) ->
|
3
|
+
@id = 0
|
4
|
+
@serializeTree()
|
5
|
+
@serializeSelection()
|
6
|
+
|
7
|
+
serializeTree: ->
|
8
|
+
@ids = new Map
|
9
|
+
@tree = @serializeNode(@element)
|
10
|
+
|
11
|
+
serializeNode: (node) ->
|
12
|
+
object = id: ++@id, name: node.nodeName
|
13
|
+
@ids.set(node, object.id)
|
14
|
+
|
15
|
+
switch node.nodeType
|
16
|
+
when Node.ELEMENT_NODE
|
17
|
+
@serializeElementToObject(node, object)
|
18
|
+
@serializeElementChildrenToObject(node, object)
|
19
|
+
|
20
|
+
when Node.TEXT_NODE, Node.COMMENT_NODE
|
21
|
+
@serializeNodeValueToObject(node, object)
|
22
|
+
|
23
|
+
object
|
24
|
+
|
25
|
+
serializeElementToObject: (node, object) ->
|
26
|
+
attributes = {}
|
27
|
+
hasAttributes = false
|
28
|
+
|
29
|
+
for {name} in node.attributes
|
30
|
+
if node.hasAttribute(name)
|
31
|
+
value = node.getAttribute(name)
|
32
|
+
value = "data:" if name is "src" and value[0...5] is "data:"
|
33
|
+
attributes[name] = value
|
34
|
+
hasAttributes = true
|
35
|
+
|
36
|
+
if hasAttributes
|
37
|
+
object.attributes = attributes
|
38
|
+
|
39
|
+
serializeElementChildrenToObject: (node, object) ->
|
40
|
+
if node.childNodes.length
|
41
|
+
object.children = for childNode in node.childNodes
|
42
|
+
@serializeNode(childNode)
|
43
|
+
|
44
|
+
serializeNodeValueToObject: (node, object) ->
|
45
|
+
object.value = node.nodeValue
|
46
|
+
|
47
|
+
serializeSelection: ->
|
48
|
+
selection = window.getSelection()
|
49
|
+
return unless selection.rangeCount > 0
|
50
|
+
|
51
|
+
range = selection.getRangeAt(0)
|
52
|
+
startId = @ids.get(range?.startContainer)
|
53
|
+
endId = @ids.get(range?.endContainer)
|
54
|
+
|
55
|
+
if startId and endId
|
56
|
+
@selection =
|
57
|
+
start: id: startId, offset: range.startOffset
|
58
|
+
end: id: endId, offset: range.endOffset
|
59
|
+
|
60
|
+
getSnapshot: ->
|
61
|
+
{@tree, @selection}
|