fluentd-ui 0.1.0

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.

Potentially problematic release.


This version of fluentd-ui might be problematic. Click here for more details.

Files changed (320) hide show
  1. checksums.yaml +7 -0
  2. data/.bowerrc +3 -0
  3. data/.gitignore +31 -0
  4. data/.rspec +1 -0
  5. data/ChangeLog +3 -0
  6. data/Gemfile +21 -0
  7. data/Gemfile.lock +247 -0
  8. data/Gemfile.production +3 -0
  9. data/README.md +53 -0
  10. data/Rakefile +8 -0
  11. data/app/assets/images/.keep +0 -0
  12. data/app/assets/javascripts/alert.js +51 -0
  13. data/app/assets/javascripts/application.js +22 -0
  14. data/app/assets/javascripts/nested_setting.js +41 -0
  15. data/app/assets/javascripts/setting_format.js +15 -0
  16. data/app/assets/javascripts/tutorial.js +58 -0
  17. data/app/assets/javascripts/vue/fluent_log.js +64 -0
  18. data/app/assets/javascripts/vue/in_tail_format.js +153 -0
  19. data/app/assets/javascripts/vue/treeview.js +97 -0
  20. data/app/assets/javascripts/vue_common.js +4 -0
  21. data/app/assets/stylesheets/application.css +18 -0
  22. data/app/assets/stylesheets/common.css.scss +152 -0
  23. data/app/controllers/api_controller.rb +37 -0
  24. data/app/controllers/application_controller.rb +110 -0
  25. data/app/controllers/concerns/.keep +0 -0
  26. data/app/controllers/fluentd/agents_controller.rb +35 -0
  27. data/app/controllers/fluentd/settings/in_syslog_controller.rb +34 -0
  28. data/app/controllers/fluentd/settings/in_tail_controller.rb +57 -0
  29. data/app/controllers/fluentd/settings/out_forward_controller.rb +42 -0
  30. data/app/controllers/fluentd/settings/out_mongo_controller.rb +36 -0
  31. data/app/controllers/fluentd/settings/out_s3_controller.rb +36 -0
  32. data/app/controllers/fluentd/settings/out_td_controller.rb +36 -0
  33. data/app/controllers/fluentd/settings_controller.rb +18 -0
  34. data/app/controllers/fluentd_controller.rb +62 -0
  35. data/app/controllers/misc_controller.rb +69 -0
  36. data/app/controllers/plugins_controller.rb +44 -0
  37. data/app/controllers/polling_controller.rb +20 -0
  38. data/app/controllers/sessions_controller.rb +45 -0
  39. data/app/controllers/tutorials_controller.rb +40 -0
  40. data/app/controllers/users_controller.rb +28 -0
  41. data/app/controllers/welcome_controller.rb +5 -0
  42. data/app/helpers/application_helper.rb +55 -0
  43. data/app/helpers/fluentd/settings_helper.rb +2 -0
  44. data/app/helpers/miscs_helper.rb +2 -0
  45. data/app/helpers/settings_helper.rb +43 -0
  46. data/app/mailers/.keep +0 -0
  47. data/app/models/.keep +0 -0
  48. data/app/models/concerns/.keep +0 -0
  49. data/app/models/fluentd.rb +178 -0
  50. data/app/models/fluentd/agent.rb +28 -0
  51. data/app/models/fluentd/agent/common.rb +76 -0
  52. data/app/models/fluentd/agent/configuration.rb +35 -0
  53. data/app/models/fluentd/agent/fluentd_gem.rb +104 -0
  54. data/app/models/fluentd/agent/local_common.rb +101 -0
  55. data/app/models/fluentd/agent/remote.rb +7 -0
  56. data/app/models/fluentd/agent/td_agent.rb +44 -0
  57. data/app/models/fluentd/api.rb +6 -0
  58. data/app/models/fluentd/api/http.rb +26 -0
  59. data/app/models/fluentd/setting.rb +4 -0
  60. data/app/models/fluentd/setting/common.rb +185 -0
  61. data/app/models/fluentd/setting/in_syslog.rb +16 -0
  62. data/app/models/fluentd/setting/in_tail.rb +107 -0
  63. data/app/models/fluentd/setting/out_forward.rb +70 -0
  64. data/app/models/fluentd/setting/out_mongo.rb +35 -0
  65. data/app/models/fluentd/setting/out_s3.rb +29 -0
  66. data/app/models/fluentd/setting/out_td.rb +26 -0
  67. data/app/models/plugin.rb +193 -0
  68. data/app/models/settings.rb +4 -0
  69. data/app/models/user.rb +52 -0
  70. data/app/views/fluentd/_form.html.haml +31 -0
  71. data/app/views/fluentd/edit.html.haml +3 -0
  72. data/app/views/fluentd/errors.html.haml +19 -0
  73. data/app/views/fluentd/log.html.haml +9 -0
  74. data/app/views/fluentd/new.html.haml +3 -0
  75. data/app/views/fluentd/settings/_form.html.haml +43 -0
  76. data/app/views/fluentd/settings/edit.html.haml +7 -0
  77. data/app/views/fluentd/settings/in_syslog/_form.html.haml +9 -0
  78. data/app/views/fluentd/settings/in_syslog/show.html.haml +6 -0
  79. data/app/views/fluentd/settings/in_tail/_form.html.haml +42 -0
  80. data/app/views/fluentd/settings/in_tail/after_file_choose.html.haml +19 -0
  81. data/app/views/fluentd/settings/in_tail/after_format.html.haml +10 -0
  82. data/app/views/fluentd/settings/in_tail/confirm.html.haml +13 -0
  83. data/app/views/fluentd/settings/in_tail/show.html.haml +5 -0
  84. data/app/views/fluentd/settings/out_forward/_form.html.haml +22 -0
  85. data/app/views/fluentd/settings/out_forward/show.html.haml +6 -0
  86. data/app/views/fluentd/settings/out_mongo/_form.html.haml +30 -0
  87. data/app/views/fluentd/settings/out_mongo/finish.html.haml +4 -0
  88. data/app/views/fluentd/settings/out_mongo/show.html.haml +6 -0
  89. data/app/views/fluentd/settings/out_s3/_form.html.haml +39 -0
  90. data/app/views/fluentd/settings/out_s3/show.html.haml +6 -0
  91. data/app/views/fluentd/settings/out_td/_form.html.haml +18 -0
  92. data/app/views/fluentd/settings/out_td/show.html.haml +6 -0
  93. data/app/views/fluentd/settings/show.html.haml +10 -0
  94. data/app/views/fluentd/settings/source_and_output.html.haml +45 -0
  95. data/app/views/fluentd/show.html.haml +60 -0
  96. data/app/views/layouts/application.html.erb +102 -0
  97. data/app/views/layouts/sign_in.html.erb +28 -0
  98. data/app/views/misc/information.html.haml +75 -0
  99. data/app/views/misc/update_fluentd_ui.html.haml +45 -0
  100. data/app/views/plugins/installed.html.haml +67 -0
  101. data/app/views/plugins/recommended.html.haml +59 -0
  102. data/app/views/plugins/updated.html.haml +29 -0
  103. data/app/views/sessions/new.html.haml +13 -0
  104. data/app/views/shared/_error.html.haml +3 -0
  105. data/app/views/shared/_flash.html.haml +10 -0
  106. data/app/views/shared/_fluentd_nav.html.haml +12 -0
  107. data/app/views/shared/_global_nav.html.erb +80 -0
  108. data/app/views/shared/_initial_setup.html.haml +13 -0
  109. data/app/views/shared/_modal.html.erb +25 -0
  110. data/app/views/shared/_setting_errors.html.haml +5 -0
  111. data/app/views/shared/vue/_fluent_log.html.erb +25 -0
  112. data/app/views/shared/vue/_in_tail_format.html.erb +53 -0
  113. data/app/views/shared/vue/_treeview.html.erb +30 -0
  114. data/app/views/tutorials/chapter1.html.erb +31 -0
  115. data/app/views/tutorials/chapter2.html.haml +12 -0
  116. data/app/views/tutorials/chapter3.html.haml +12 -0
  117. data/app/views/tutorials/chapter4.html.haml +12 -0
  118. data/app/views/tutorials/chapter5.html.haml +10 -0
  119. data/app/views/tutorials/index.html.haml +26 -0
  120. data/app/views/users/show.html.haml +22 -0
  121. data/app/workers/all_plugin_check_update.rb +14 -0
  122. data/app/workers/fluentd_ui_restart.rb +41 -0
  123. data/app/workers/fluentd_ui_update_check.rb +15 -0
  124. data/app/workers/gem_installer.rb +17 -0
  125. data/app/workers/gem_uninstaller.rb +15 -0
  126. data/app/workers/gem_update_check.rb +10 -0
  127. data/bin/bundle +3 -0
  128. data/bin/fluentd-ui +13 -0
  129. data/bin/fluentd-ui-restart +12 -0
  130. data/bin/rails +8 -0
  131. data/bin/rake +8 -0
  132. data/bin/spring +18 -0
  133. data/bower.json +10 -0
  134. data/circle.yml +8 -0
  135. data/config.ru +4 -0
  136. data/config/application.rb +48 -0
  137. data/config/application.yml +211 -0
  138. data/config/boot.rb +4 -0
  139. data/config/environment.rb +5 -0
  140. data/config/environments/development.rb +36 -0
  141. data/config/environments/production.rb +69 -0
  142. data/config/environments/test.rb +40 -0
  143. data/config/initializers/backtrace_silencers.rb +7 -0
  144. data/config/initializers/cookies_serializer.rb +3 -0
  145. data/config/initializers/filter_parameter_logging.rb +4 -0
  146. data/config/initializers/inflections.rb +16 -0
  147. data/config/initializers/mime_types.rb +4 -0
  148. data/config/initializers/prefetch_gem_updates.rb +1 -0
  149. data/config/initializers/session_store.rb +3 -0
  150. data/config/initializers/wrap_parameters.rb +14 -0
  151. data/config/locales/en.yml +204 -0
  152. data/config/locales/ja.yml +194 -0
  153. data/config/locales/translation_en.yml +255 -0
  154. data/config/locales/translation_ja.yml +255 -0
  155. data/config/locales/tutorial_en.yml +117 -0
  156. data/config/locales/tutorial_ja.yml +120 -0
  157. data/config/routes.rb +93 -0
  158. data/config/secrets.yml +22 -0
  159. data/db/schema.rb +0 -0
  160. data/db/seeds.rb +11 -0
  161. data/fluentd-ui-ss01.png +0 -0
  162. data/fluentd-ui-ss02.png +0 -0
  163. data/fluentd-ui-ss03.png +0 -0
  164. data/fluentd-ui-ss04.png +0 -0
  165. data/fluentd-ui-ss05.png +0 -0
  166. data/fluentd-ui.gemspec +46 -0
  167. data/lib/assets/.keep +0 -0
  168. data/lib/file_reverse_reader.rb +56 -0
  169. data/lib/fluentd-ui.rb +22 -0
  170. data/lib/fluentd-ui/command.rb +52 -0
  171. data/lib/fluentd-ui/version.rb +3 -0
  172. data/lib/grok_converter.rb +39 -0
  173. data/lib/regexp_preview.rb +48 -0
  174. data/lib/tasks/.keep +0 -0
  175. data/lib/treeview.rb +45 -0
  176. data/log/.keep +0 -0
  177. data/public/404.html +67 -0
  178. data/public/422.html +67 -0
  179. data/public/500.html +66 -0
  180. data/public/favicon.ico +0 -0
  181. data/public/fluentd-logo-right-text.png +0 -0
  182. data/public/fluentd-logo.png +0 -0
  183. data/public/fluentd.png +0 -0
  184. data/public/robots.txt +5 -0
  185. data/spec/controllers/plugins_controller_spec.rb +5 -0
  186. data/spec/controllers/polling_controller_spec.rb +5 -0
  187. data/spec/controllers/sessions_controller_spec.rb +5 -0
  188. data/spec/controllers/tutorials_controller_spec.rb +5 -0
  189. data/spec/factories/fluentd.rb +11 -0
  190. data/spec/factories/plugins.rb +8 -0
  191. data/spec/factories/user.rb +6 -0
  192. data/spec/features/fluentd/setting/out_forward_spec.rb +45 -0
  193. data/spec/features/fluentd/setting/out_td_spec.rb +35 -0
  194. data/spec/features/sessions_spec.rb +55 -0
  195. data/spec/features/shared_examples/login_required.rb +4 -0
  196. data/spec/features/users_spec.rb +9 -0
  197. data/spec/grok_converter_spec.rb +50 -0
  198. data/spec/lib/file_reverse_reader_spec.rb +73 -0
  199. data/spec/lib/fluentd-ui_spec.rb +35 -0
  200. data/spec/models/fluentd/agent_spec.rb +91 -0
  201. data/spec/models/fluentd/setting/common_spec.rb +178 -0
  202. data/spec/models/fluentd/setting/in_syslog_spec.rb +35 -0
  203. data/spec/models/fluentd/setting/out_mongo_spec.rb +40 -0
  204. data/spec/models/fluentd/setting/out_td_spec.rb +38 -0
  205. data/spec/models/fluentd_spec.rb +166 -0
  206. data/spec/models/plugin_spec.rb +191 -0
  207. data/spec/models/user_spec.rb +15 -0
  208. data/spec/spec_helper.rb +58 -0
  209. data/spec/support/fixtures/error0.log +12 -0
  210. data/spec/support/fixtures/error2.log +130 -0
  211. data/spec/support/fluentd_agent_common_behavior.rb +114 -0
  212. data/spec/support/fluentd_agent_restart_strategy.rb +94 -0
  213. data/tmp/.gitkeep +0 -0
  214. data/vendor/assets/javascripts/.keep +0 -0
  215. data/vendor/assets/javascripts/bower/es6-promise/.bower.json +15 -0
  216. data/vendor/assets/javascripts/bower/es6-promise/bower.json +5 -0
  217. data/vendor/assets/javascripts/bower/es6-promise/promise.js +684 -0
  218. data/vendor/assets/javascripts/bower/es6-promise/promise.min.js +1 -0
  219. data/vendor/assets/javascripts/bower/lodash/.bower.json +33 -0
  220. data/vendor/assets/javascripts/bower/lodash/LICENSE.txt +22 -0
  221. data/vendor/assets/javascripts/bower/lodash/bower.json +23 -0
  222. data/vendor/assets/javascripts/bower/lodash/dist/lodash.compat.js +7157 -0
  223. data/vendor/assets/javascripts/bower/lodash/dist/lodash.compat.min.js +61 -0
  224. data/vendor/assets/javascripts/bower/lodash/dist/lodash.js +6785 -0
  225. data/vendor/assets/javascripts/bower/lodash/dist/lodash.min.js +56 -0
  226. data/vendor/assets/javascripts/bower/lodash/dist/lodash.underscore.js +4979 -0
  227. data/vendor/assets/javascripts/bower/lodash/dist/lodash.underscore.min.js +39 -0
  228. data/vendor/assets/javascripts/bower/vue/.bower.json +29 -0
  229. data/vendor/assets/javascripts/bower/vue/LICENSE +21 -0
  230. data/vendor/assets/javascripts/bower/vue/dist/vue.js +4713 -0
  231. data/vendor/assets/javascripts/bower/vue/dist/vue.min.js +7 -0
  232. data/vendor/assets/javascripts/bower/vue/src/batcher.js +45 -0
  233. data/vendor/assets/javascripts/bower/vue/src/binding.js +103 -0
  234. data/vendor/assets/javascripts/bower/vue/src/compiler.js +1037 -0
  235. data/vendor/assets/javascripts/bower/vue/src/config.js +19 -0
  236. data/vendor/assets/javascripts/bower/vue/src/deps-parser.js +65 -0
  237. data/vendor/assets/javascripts/bower/vue/src/directive.js +258 -0
  238. data/vendor/assets/javascripts/bower/vue/src/directives/html.js +41 -0
  239. data/vendor/assets/javascripts/bower/vue/src/directives/if.js +56 -0
  240. data/vendor/assets/javascripts/bower/vue/src/directives/index.js +129 -0
  241. data/vendor/assets/javascripts/bower/vue/src/directives/model.js +174 -0
  242. data/vendor/assets/javascripts/bower/vue/src/directives/on.js +56 -0
  243. data/vendor/assets/javascripts/bower/vue/src/directives/partial.js +50 -0
  244. data/vendor/assets/javascripts/bower/vue/src/directives/repeat.js +246 -0
  245. data/vendor/assets/javascripts/bower/vue/src/directives/style.js +40 -0
  246. data/vendor/assets/javascripts/bower/vue/src/directives/view.js +56 -0
  247. data/vendor/assets/javascripts/bower/vue/src/directives/with.js +50 -0
  248. data/vendor/assets/javascripts/bower/vue/src/emitter.js +97 -0
  249. data/vendor/assets/javascripts/bower/vue/src/exp-parser.js +190 -0
  250. data/vendor/assets/javascripts/bower/vue/src/filters.js +190 -0
  251. data/vendor/assets/javascripts/bower/vue/src/fragment.js +84 -0
  252. data/vendor/assets/javascripts/bower/vue/src/main.js +186 -0
  253. data/vendor/assets/javascripts/bower/vue/src/observer.js +446 -0
  254. data/vendor/assets/javascripts/bower/vue/src/text-parser.js +96 -0
  255. data/vendor/assets/javascripts/bower/vue/src/transition.js +228 -0
  256. data/vendor/assets/javascripts/bower/vue/src/utils.js +321 -0
  257. data/vendor/assets/javascripts/bower/vue/src/viewmodel.js +180 -0
  258. data/vendor/assets/javascripts/sb-admin-v2/bootstrap.js +1951 -0
  259. data/vendor/assets/javascripts/sb-admin-v2/bootstrap.min.js +6 -0
  260. data/vendor/assets/javascripts/sb-admin-v2/demo/dashboard-demo.js +117 -0
  261. data/vendor/assets/javascripts/sb-admin-v2/demo/flot-demo.js +1242 -0
  262. data/vendor/assets/javascripts/sb-admin-v2/demo/morris-demo.js +155 -0
  263. data/vendor/assets/javascripts/sb-admin-v2/jquery-1.10.2.js +6 -0
  264. data/vendor/assets/javascripts/sb-admin-v2/plugins/dataTables/dataTables.bootstrap.js +245 -0
  265. data/vendor/assets/javascripts/sb-admin-v2/plugins/dataTables/jquery.dataTables.js +14013 -0
  266. data/vendor/assets/javascripts/sb-admin-v2/plugins/flot/excanvas.min.js +1 -0
  267. data/vendor/assets/javascripts/sb-admin-v2/plugins/flot/jquery.flot.js +2599 -0
  268. data/vendor/assets/javascripts/sb-admin-v2/plugins/flot/jquery.flot.pie.js +750 -0
  269. data/vendor/assets/javascripts/sb-admin-v2/plugins/flot/jquery.flot.resize.js +60 -0
  270. data/vendor/assets/javascripts/sb-admin-v2/plugins/flot/jquery.flot.tooltip.min.js +12 -0
  271. data/vendor/assets/javascripts/sb-admin-v2/plugins/metisMenu/jquery.metisMenu.js +45 -0
  272. data/vendor/assets/javascripts/sb-admin-v2/plugins/morris/morris.js +1888 -0
  273. data/vendor/assets/javascripts/sb-admin-v2/plugins/morris/raphael-2.1.0.min.js +10 -0
  274. data/vendor/assets/javascripts/sb-admin-v2/sb-admin.js +18 -0
  275. data/vendor/assets/stylesheets/.keep +0 -0
  276. data/vendor/assets/stylesheets/sb-admin-v2/bootstrap.css +5830 -0
  277. data/vendor/assets/stylesheets/sb-admin-v2/bootstrap.min.css +7 -0
  278. data/vendor/assets/stylesheets/sb-admin-v2/font-awesome/css/font-awesome.css +1338 -0
  279. data/vendor/assets/stylesheets/sb-admin-v2/font-awesome/css/font-awesome.min.css +4 -0
  280. data/vendor/assets/stylesheets/sb-admin-v2/font-awesome/fonts/FontAwesome.otf +0 -0
  281. data/vendor/assets/stylesheets/sb-admin-v2/font-awesome/fonts/fontawesome-webfont.eot +0 -0
  282. data/vendor/assets/stylesheets/sb-admin-v2/font-awesome/fonts/fontawesome-webfont.svg +414 -0
  283. data/vendor/assets/stylesheets/sb-admin-v2/font-awesome/fonts/fontawesome-webfont.ttf +0 -0
  284. data/vendor/assets/stylesheets/sb-admin-v2/font-awesome/fonts/fontawesome-webfont.woff +0 -0
  285. data/vendor/assets/stylesheets/sb-admin-v2/font-awesome/scss/_bordered-pulled.scss +16 -0
  286. data/vendor/assets/stylesheets/sb-admin-v2/font-awesome/scss/_core.scss +12 -0
  287. data/vendor/assets/stylesheets/sb-admin-v2/font-awesome/scss/_fixed-width.scss +6 -0
  288. data/vendor/assets/stylesheets/sb-admin-v2/font-awesome/scss/_icons.scss +412 -0
  289. data/vendor/assets/stylesheets/sb-admin-v2/font-awesome/scss/_larger.scss +13 -0
  290. data/vendor/assets/stylesheets/sb-admin-v2/font-awesome/scss/_list.scss +19 -0
  291. data/vendor/assets/stylesheets/sb-admin-v2/font-awesome/scss/_mixins.scss +20 -0
  292. data/vendor/assets/stylesheets/sb-admin-v2/font-awesome/scss/_path.scss +14 -0
  293. data/vendor/assets/stylesheets/sb-admin-v2/font-awesome/scss/_rotated-flipped.scss +9 -0
  294. data/vendor/assets/stylesheets/sb-admin-v2/font-awesome/scss/_spinning.scss +30 -0
  295. data/vendor/assets/stylesheets/sb-admin-v2/font-awesome/scss/_stacked.scss +20 -0
  296. data/vendor/assets/stylesheets/sb-admin-v2/font-awesome/scss/_variables.scss +381 -0
  297. data/vendor/assets/stylesheets/sb-admin-v2/font-awesome/scss/font-awesome.scss +17 -0
  298. data/vendor/assets/stylesheets/sb-admin-v2/fonts/glyphicons-halflings-regular.eot +0 -0
  299. data/vendor/assets/stylesheets/sb-admin-v2/fonts/glyphicons-halflings-regular.svg +229 -0
  300. data/vendor/assets/stylesheets/sb-admin-v2/fonts/glyphicons-halflings-regular.ttf +0 -0
  301. data/vendor/assets/stylesheets/sb-admin-v2/fonts/glyphicons-halflings-regular.woff +0 -0
  302. data/vendor/assets/stylesheets/sb-admin-v2/plugins/dataTables/dataTables.bootstrap.css +233 -0
  303. data/vendor/assets/stylesheets/sb-admin-v2/plugins/morris/morris-0.4.3.min.css +2 -0
  304. data/vendor/assets/stylesheets/sb-admin-v2/plugins/social-buttons/social-buttons.css +68 -0
  305. data/vendor/assets/stylesheets/sb-admin-v2/plugins/timeline/timeline.css +144 -0
  306. data/vendor/assets/stylesheets/sb-admin-v2/sb-admin.css +329 -0
  307. data/vendor/patterns/firewalls +60 -0
  308. data/vendor/patterns/grok-patterns +94 -0
  309. data/vendor/patterns/haproxy +37 -0
  310. data/vendor/patterns/java +3 -0
  311. data/vendor/patterns/junos +9 -0
  312. data/vendor/patterns/linux-syslog +16 -0
  313. data/vendor/patterns/mcollective +1 -0
  314. data/vendor/patterns/mcollective-patterns +4 -0
  315. data/vendor/patterns/mongodb +4 -0
  316. data/vendor/patterns/nagios +108 -0
  317. data/vendor/patterns/postgresql +3 -0
  318. data/vendor/patterns/redis +3 -0
  319. data/vendor/patterns/ruby +2 -0
  320. metadata +659 -0
@@ -0,0 +1,96 @@
1
+ var openChar = '{',
2
+ endChar = '}',
3
+ ESCAPE_RE = /[-.*+?^${}()|[\]\/\\]/g,
4
+ // lazy require
5
+ Directive
6
+
7
+ exports.Regex = buildInterpolationRegex()
8
+
9
+ function buildInterpolationRegex () {
10
+ var open = escapeRegex(openChar),
11
+ end = escapeRegex(endChar)
12
+ return new RegExp(open + open + open + '?(.+?)' + end + '?' + end + end)
13
+ }
14
+
15
+ function escapeRegex (str) {
16
+ return str.replace(ESCAPE_RE, '\\$&')
17
+ }
18
+
19
+ function setDelimiters (delimiters) {
20
+ openChar = delimiters[0]
21
+ endChar = delimiters[1]
22
+ exports.delimiters = delimiters
23
+ exports.Regex = buildInterpolationRegex()
24
+ }
25
+
26
+ /**
27
+ * Parse a piece of text, return an array of tokens
28
+ * token types:
29
+ * 1. plain string
30
+ * 2. object with key = binding key
31
+ * 3. object with key & html = true
32
+ */
33
+ function parse (text) {
34
+ if (!exports.Regex.test(text)) return null
35
+ var m, i, token, match, tokens = []
36
+ /* jshint boss: true */
37
+ while (m = text.match(exports.Regex)) {
38
+ i = m.index
39
+ if (i > 0) tokens.push(text.slice(0, i))
40
+ token = { key: m[1].trim() }
41
+ match = m[0]
42
+ token.html =
43
+ match.charAt(2) === openChar &&
44
+ match.charAt(match.length - 3) === endChar
45
+ tokens.push(token)
46
+ text = text.slice(i + m[0].length)
47
+ }
48
+ if (text.length) tokens.push(text)
49
+ return tokens
50
+ }
51
+
52
+ /**
53
+ * Parse an attribute value with possible interpolation tags
54
+ * return a Directive-friendly expression
55
+ *
56
+ * e.g. a {{b}} c => "a " + b + " c"
57
+ */
58
+ function parseAttr (attr) {
59
+ Directive = Directive || require('./directive')
60
+ var tokens = parse(attr)
61
+ if (!tokens) return null
62
+ if (tokens.length === 1) return tokens[0].key
63
+ var res = [], token
64
+ for (var i = 0, l = tokens.length; i < l; i++) {
65
+ token = tokens[i]
66
+ res.push(
67
+ token.key
68
+ ? inlineFilters(token.key)
69
+ : ('"' + token + '"')
70
+ )
71
+ }
72
+ return res.join('+')
73
+ }
74
+
75
+ /**
76
+ * Inlines any possible filters in a binding
77
+ * so that we can combine everything into a huge expression
78
+ */
79
+ function inlineFilters (key) {
80
+ if (key.indexOf('|') > -1) {
81
+ var dirs = Directive.parse(key),
82
+ dir = dirs && dirs[0]
83
+ if (dir && dir.filters) {
84
+ key = Directive.inlineFilters(
85
+ dir.key,
86
+ dir.filters
87
+ )
88
+ }
89
+ }
90
+ return '(' + key + ')'
91
+ }
92
+
93
+ exports.parse = parse
94
+ exports.parseAttr = parseAttr
95
+ exports.setDelimiters = setDelimiters
96
+ exports.delimiters = [openChar, endChar]
@@ -0,0 +1,228 @@
1
+ var endEvents = sniffEndEvents(),
2
+ config = require('./config'),
3
+ // batch enter animations so we only force the layout once
4
+ Batcher = require('./batcher'),
5
+ batcher = new Batcher(),
6
+ // cache timer functions
7
+ setTO = window.setTimeout,
8
+ clearTO = window.clearTimeout,
9
+ // exit codes for testing
10
+ codes = {
11
+ CSS_E : 1,
12
+ CSS_L : 2,
13
+ JS_E : 3,
14
+ JS_L : 4,
15
+ CSS_SKIP : -1,
16
+ JS_SKIP : -2,
17
+ JS_SKIP_E : -3,
18
+ JS_SKIP_L : -4,
19
+ INIT : -5,
20
+ SKIP : -6
21
+ }
22
+
23
+ // force layout before triggering transitions/animations
24
+ batcher._preFlush = function () {
25
+ /* jshint unused: false */
26
+ var f = document.body.offsetHeight
27
+ }
28
+
29
+ /**
30
+ * stage:
31
+ * 1 = enter
32
+ * 2 = leave
33
+ */
34
+ var transition = module.exports = function (el, stage, cb, compiler) {
35
+
36
+ var changeState = function () {
37
+ cb()
38
+ compiler.execHook(stage > 0 ? 'attached' : 'detached')
39
+ }
40
+
41
+ if (compiler.init) {
42
+ changeState()
43
+ return codes.INIT
44
+ }
45
+
46
+ var hasTransition = el.vue_trans === '',
47
+ hasAnimation = el.vue_anim === '',
48
+ effectId = el.vue_effect
49
+
50
+ if (effectId) {
51
+ return applyTransitionFunctions(
52
+ el,
53
+ stage,
54
+ changeState,
55
+ effectId,
56
+ compiler
57
+ )
58
+ } else if (hasTransition || hasAnimation) {
59
+ return applyTransitionClass(
60
+ el,
61
+ stage,
62
+ changeState,
63
+ hasAnimation
64
+ )
65
+ } else {
66
+ changeState()
67
+ return codes.SKIP
68
+ }
69
+
70
+ }
71
+
72
+ /**
73
+ * Togggle a CSS class to trigger transition
74
+ */
75
+ function applyTransitionClass (el, stage, changeState, hasAnimation) {
76
+
77
+ if (!endEvents.trans) {
78
+ changeState()
79
+ return codes.CSS_SKIP
80
+ }
81
+
82
+ // if the browser supports transition,
83
+ // it must have classList...
84
+ var onEnd,
85
+ classList = el.classList,
86
+ existingCallback = el.vue_trans_cb,
87
+ enterClass = config.enterClass,
88
+ leaveClass = config.leaveClass,
89
+ endEvent = hasAnimation ? endEvents.anim : endEvents.trans
90
+
91
+ // cancel unfinished callbacks and jobs
92
+ if (existingCallback) {
93
+ el.removeEventListener(endEvent, existingCallback)
94
+ classList.remove(enterClass)
95
+ classList.remove(leaveClass)
96
+ el.vue_trans_cb = null
97
+ }
98
+
99
+ if (stage > 0) { // enter
100
+
101
+ // set to enter state before appending
102
+ classList.add(enterClass)
103
+ // append
104
+ changeState()
105
+ // trigger transition
106
+ if (!hasAnimation) {
107
+ batcher.push({
108
+ execute: function () {
109
+ classList.remove(enterClass)
110
+ }
111
+ })
112
+ } else {
113
+ onEnd = function (e) {
114
+ if (e.target === el) {
115
+ el.removeEventListener(endEvent, onEnd)
116
+ el.vue_trans_cb = null
117
+ classList.remove(enterClass)
118
+ }
119
+ }
120
+ el.addEventListener(endEvent, onEnd)
121
+ el.vue_trans_cb = onEnd
122
+ }
123
+ return codes.CSS_E
124
+
125
+ } else { // leave
126
+
127
+ if (el.offsetWidth || el.offsetHeight) {
128
+ // trigger hide transition
129
+ classList.add(leaveClass)
130
+ onEnd = function (e) {
131
+ if (e.target === el) {
132
+ el.removeEventListener(endEvent, onEnd)
133
+ el.vue_trans_cb = null
134
+ // actually remove node here
135
+ changeState()
136
+ classList.remove(leaveClass)
137
+ }
138
+ }
139
+ // attach transition end listener
140
+ el.addEventListener(endEvent, onEnd)
141
+ el.vue_trans_cb = onEnd
142
+ } else {
143
+ // directly remove invisible elements
144
+ changeState()
145
+ }
146
+ return codes.CSS_L
147
+
148
+ }
149
+
150
+ }
151
+
152
+ function applyTransitionFunctions (el, stage, changeState, effectId, compiler) {
153
+
154
+ var funcs = compiler.getOption('effects', effectId)
155
+ if (!funcs) {
156
+ changeState()
157
+ return codes.JS_SKIP
158
+ }
159
+
160
+ var enter = funcs.enter,
161
+ leave = funcs.leave,
162
+ timeouts = el.vue_timeouts
163
+
164
+ // clear previous timeouts
165
+ if (timeouts) {
166
+ var i = timeouts.length
167
+ while (i--) {
168
+ clearTO(timeouts[i])
169
+ }
170
+ }
171
+
172
+ timeouts = el.vue_timeouts = []
173
+ function timeout (cb, delay) {
174
+ var id = setTO(function () {
175
+ cb()
176
+ timeouts.splice(timeouts.indexOf(id), 1)
177
+ if (!timeouts.length) {
178
+ el.vue_timeouts = null
179
+ }
180
+ }, delay)
181
+ timeouts.push(id)
182
+ }
183
+
184
+ if (stage > 0) { // enter
185
+ if (typeof enter !== 'function') {
186
+ changeState()
187
+ return codes.JS_SKIP_E
188
+ }
189
+ enter(el, changeState, timeout)
190
+ return codes.JS_E
191
+ } else { // leave
192
+ if (typeof leave !== 'function') {
193
+ changeState()
194
+ return codes.JS_SKIP_L
195
+ }
196
+ leave(el, changeState, timeout)
197
+ return codes.JS_L
198
+ }
199
+
200
+ }
201
+
202
+ /**
203
+ * Sniff proper transition end event name
204
+ */
205
+ function sniffEndEvents () {
206
+ var el = document.createElement('vue'),
207
+ defaultEvent = 'transitionend',
208
+ events = {
209
+ 'webkitTransition' : 'webkitTransitionEnd',
210
+ 'transition' : defaultEvent,
211
+ 'mozTransition' : defaultEvent
212
+ },
213
+ ret = {}
214
+ for (var name in events) {
215
+ if (el.style[name] !== undefined) {
216
+ ret.trans = events[name]
217
+ break
218
+ }
219
+ }
220
+ ret.anim = el.style.animation === ''
221
+ ? 'animationend'
222
+ : 'webkitAnimationEnd'
223
+ return ret
224
+ }
225
+
226
+ // Expose some stuff for testing purposes
227
+ transition.codes = codes
228
+ transition.sniff = sniffEndEvents
@@ -0,0 +1,321 @@
1
+ var config = require('./config'),
2
+ toString = ({}).toString,
3
+ win = window,
4
+ console = win.console,
5
+ def = Object.defineProperty,
6
+ OBJECT = 'object',
7
+ THIS_RE = /[^\w]this[^\w]/,
8
+ BRACKET_RE_S = /\['([^']+)'\]/g,
9
+ BRACKET_RE_D = /\["([^"]+)"\]/g,
10
+ hasClassList = 'classList' in document.documentElement,
11
+ ViewModel // late def
12
+
13
+ var defer =
14
+ win.requestAnimationFrame ||
15
+ win.webkitRequestAnimationFrame ||
16
+ win.setTimeout
17
+
18
+ /**
19
+ * Normalize keypath with possible brackets into dot notations
20
+ */
21
+ function normalizeKeypath (key) {
22
+ return key.indexOf('[') < 0
23
+ ? key
24
+ : key.replace(BRACKET_RE_S, '.$1')
25
+ .replace(BRACKET_RE_D, '.$1')
26
+ }
27
+
28
+ var utils = module.exports = {
29
+
30
+ /**
31
+ * Convert a string template to a dom fragment
32
+ */
33
+ toFragment: require('./fragment'),
34
+
35
+ /**
36
+ * get a value from an object keypath
37
+ */
38
+ get: function (obj, key) {
39
+ /* jshint eqeqeq: false */
40
+ key = normalizeKeypath(key)
41
+ if (key.indexOf('.') < 0) {
42
+ return obj[key]
43
+ }
44
+ var path = key.split('.'),
45
+ d = -1, l = path.length
46
+ while (++d < l && obj != null) {
47
+ obj = obj[path[d]]
48
+ }
49
+ return obj
50
+ },
51
+
52
+ /**
53
+ * set a value to an object keypath
54
+ */
55
+ set: function (obj, key, val) {
56
+ /* jshint eqeqeq: false */
57
+ key = normalizeKeypath(key)
58
+ if (key.indexOf('.') < 0) {
59
+ obj[key] = val
60
+ return
61
+ }
62
+ var path = key.split('.'),
63
+ d = -1, l = path.length - 1
64
+ while (++d < l) {
65
+ if (obj[path[d]] == null) {
66
+ obj[path[d]] = {}
67
+ }
68
+ obj = obj[path[d]]
69
+ }
70
+ obj[path[d]] = val
71
+ },
72
+
73
+ /**
74
+ * return the base segment of a keypath
75
+ */
76
+ baseKey: function (key) {
77
+ return key.indexOf('.') > 0
78
+ ? key.split('.')[0]
79
+ : key
80
+ },
81
+
82
+ /**
83
+ * Create a prototype-less object
84
+ * which is a better hash/map
85
+ */
86
+ hash: function () {
87
+ return Object.create(null)
88
+ },
89
+
90
+ /**
91
+ * get an attribute and remove it.
92
+ */
93
+ attr: function (el, type) {
94
+ var attr = config.prefix + '-' + type,
95
+ val = el.getAttribute(attr)
96
+ if (val !== null) {
97
+ el.removeAttribute(attr)
98
+ }
99
+ return val
100
+ },
101
+
102
+ /**
103
+ * Define an ienumerable property
104
+ * This avoids it being included in JSON.stringify
105
+ * or for...in loops.
106
+ */
107
+ defProtected: function (obj, key, val, enumerable, writable) {
108
+ def(obj, key, {
109
+ value : val,
110
+ enumerable : enumerable,
111
+ writable : writable,
112
+ configurable : true
113
+ })
114
+ },
115
+
116
+ /**
117
+ * A less bullet-proof but more efficient type check
118
+ * than Object.prototype.toString
119
+ */
120
+ isObject: function (obj) {
121
+ return typeof obj === OBJECT && obj && !Array.isArray(obj)
122
+ },
123
+
124
+ /**
125
+ * A more accurate but less efficient type check
126
+ */
127
+ isTrueObject: function (obj) {
128
+ return toString.call(obj) === '[object Object]'
129
+ },
130
+
131
+ /**
132
+ * Most simple bind
133
+ * enough for the usecase and fast than native bind()
134
+ */
135
+ bind: function (fn, ctx) {
136
+ return function (arg) {
137
+ return fn.call(ctx, arg)
138
+ }
139
+ },
140
+
141
+ /**
142
+ * Make sure null and undefined output empty string
143
+ */
144
+ guard: function (value) {
145
+ /* jshint eqeqeq: false, eqnull: true */
146
+ return value == null
147
+ ? ''
148
+ : (typeof value == 'object')
149
+ ? JSON.stringify(value)
150
+ : value
151
+ },
152
+
153
+ /**
154
+ * When setting value on the VM, parse possible numbers
155
+ */
156
+ checkNumber: function (value) {
157
+ return (isNaN(value) || value === null || typeof value === 'boolean')
158
+ ? value
159
+ : Number(value)
160
+ },
161
+
162
+ /**
163
+ * simple extend
164
+ */
165
+ extend: function (obj, ext) {
166
+ for (var key in ext) {
167
+ if (obj[key] !== ext[key]) {
168
+ obj[key] = ext[key]
169
+ }
170
+ }
171
+ return obj
172
+ },
173
+
174
+ /**
175
+ * filter an array with duplicates into uniques
176
+ */
177
+ unique: function (arr) {
178
+ var hash = utils.hash(),
179
+ i = arr.length,
180
+ key, res = []
181
+ while (i--) {
182
+ key = arr[i]
183
+ if (hash[key]) continue
184
+ hash[key] = 1
185
+ res.push(key)
186
+ }
187
+ return res
188
+ },
189
+
190
+ /**
191
+ * Convert the object to a ViewModel constructor
192
+ * if it is not already one
193
+ */
194
+ toConstructor: function (obj) {
195
+ ViewModel = ViewModel || require('./viewmodel')
196
+ return utils.isObject(obj)
197
+ ? ViewModel.extend(obj)
198
+ : typeof obj === 'function'
199
+ ? obj
200
+ : null
201
+ },
202
+
203
+ /**
204
+ * Check if a filter function contains references to `this`
205
+ * If yes, mark it as a computed filter.
206
+ */
207
+ checkFilter: function (filter) {
208
+ if (THIS_RE.test(filter.toString())) {
209
+ filter.computed = true
210
+ }
211
+ },
212
+
213
+ /**
214
+ * convert certain option values to the desired format.
215
+ */
216
+ processOptions: function (options) {
217
+ var components = options.components,
218
+ partials = options.partials,
219
+ template = options.template,
220
+ filters = options.filters,
221
+ key
222
+ if (components) {
223
+ for (key in components) {
224
+ components[key] = utils.toConstructor(components[key])
225
+ }
226
+ }
227
+ if (partials) {
228
+ for (key in partials) {
229
+ partials[key] = utils.toFragment(partials[key])
230
+ }
231
+ }
232
+ if (filters) {
233
+ for (key in filters) {
234
+ utils.checkFilter(filters[key])
235
+ }
236
+ }
237
+ if (template) {
238
+ options.template = utils.toFragment(template)
239
+ }
240
+ },
241
+
242
+ /**
243
+ * used to defer batch updates
244
+ */
245
+ nextTick: function (cb) {
246
+ defer(cb, 0)
247
+ },
248
+
249
+ /**
250
+ * add class for IE9
251
+ * uses classList if available
252
+ */
253
+ addClass: function (el, cls) {
254
+ if (hasClassList) {
255
+ el.classList.add(cls)
256
+ } else {
257
+ var cur = ' ' + el.className + ' '
258
+ if (cur.indexOf(' ' + cls + ' ') < 0) {
259
+ el.className = (cur + cls).trim()
260
+ }
261
+ }
262
+ },
263
+
264
+ /**
265
+ * remove class for IE9
266
+ */
267
+ removeClass: function (el, cls) {
268
+ if (hasClassList) {
269
+ el.classList.remove(cls)
270
+ } else {
271
+ var cur = ' ' + el.className + ' ',
272
+ tar = ' ' + cls + ' '
273
+ while (cur.indexOf(tar) >= 0) {
274
+ cur = cur.replace(tar, ' ')
275
+ }
276
+ el.className = cur.trim()
277
+ }
278
+ },
279
+
280
+ /**
281
+ * Convert an object to Array
282
+ * used in v-repeat and array filters
283
+ */
284
+ objectToArray: function (obj) {
285
+ var res = [], val, data
286
+ for (var key in obj) {
287
+ val = obj[key]
288
+ data = utils.isObject(val)
289
+ ? val
290
+ : { $value: val }
291
+ data.$key = key
292
+ res.push(data)
293
+ }
294
+ return res
295
+ }
296
+ }
297
+
298
+ enableDebug()
299
+ function enableDebug () {
300
+ /**
301
+ * log for debugging
302
+ */
303
+ utils.log = function (msg) {
304
+ if (config.debug && console) {
305
+ console.log(msg)
306
+ }
307
+ }
308
+
309
+ /**
310
+ * warnings, traces by default
311
+ * can be suppressed by `silent` option.
312
+ */
313
+ utils.warn = function (msg) {
314
+ if (!config.silent && console) {
315
+ console.warn(msg)
316
+ if (config.debug && console.trace) {
317
+ console.trace()
318
+ }
319
+ }
320
+ }
321
+ }