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,19 @@
1
+ var TextParser = require('./text-parser')
2
+
3
+ module.exports = {
4
+ prefix : 'v',
5
+ debug : false,
6
+ silent : false,
7
+ enterClass : 'v-enter',
8
+ leaveClass : 'v-leave',
9
+ interpolate : true
10
+ }
11
+
12
+ Object.defineProperty(module.exports, 'delimiters', {
13
+ get: function () {
14
+ return TextParser.delimiters
15
+ },
16
+ set: function (delimiters) {
17
+ TextParser.setDelimiters(delimiters)
18
+ }
19
+ })
@@ -0,0 +1,65 @@
1
+ var Emitter = require('./emitter'),
2
+ utils = require('./utils'),
3
+ Observer = require('./observer'),
4
+ catcher = new Emitter()
5
+
6
+ /**
7
+ * Auto-extract the dependencies of a computed property
8
+ * by recording the getters triggered when evaluating it.
9
+ */
10
+ function catchDeps (binding) {
11
+ if (binding.isFn) return
12
+ utils.log('\n- ' + binding.key)
13
+ var got = utils.hash()
14
+ binding.deps = []
15
+ catcher.on('get', function (dep) {
16
+ var has = got[dep.key]
17
+ if (
18
+ // avoid duplicate bindings
19
+ (has && has.compiler === dep.compiler) ||
20
+ // avoid repeated items as dependency
21
+ // only when the binding is from self or the parent chain
22
+ (dep.compiler.repeat && !isParentOf(dep.compiler, binding.compiler))
23
+ ) {
24
+ return
25
+ }
26
+ got[dep.key] = dep
27
+ utils.log(' - ' + dep.key)
28
+ binding.deps.push(dep)
29
+ dep.subs.push(binding)
30
+ })
31
+ binding.value.$get()
32
+ catcher.off('get')
33
+ }
34
+
35
+ /**
36
+ * Test if A is a parent of or equals B
37
+ */
38
+ function isParentOf (a, b) {
39
+ while (b) {
40
+ if (a === b) {
41
+ return true
42
+ }
43
+ b = b.parent
44
+ }
45
+ }
46
+
47
+ module.exports = {
48
+
49
+ /**
50
+ * the observer that catches events triggered by getters
51
+ */
52
+ catcher: catcher,
53
+
54
+ /**
55
+ * parse a list of computed property bindings
56
+ */
57
+ parse: function (bindings) {
58
+ utils.log('\nparsing dependencies...')
59
+ Observer.shouldGet = true
60
+ bindings.forEach(catchDeps)
61
+ Observer.shouldGet = false
62
+ utils.log('\ndone.')
63
+ }
64
+
65
+ }
@@ -0,0 +1,258 @@
1
+ var dirId = 1,
2
+ ARG_RE = /^[\w\$-]+$/,
3
+ FILTER_TOKEN_RE = /[^\s'"]+|'[^']+'|"[^"]+"/g,
4
+ NESTING_RE = /^\$(parent|root)\./,
5
+ SINGLE_VAR_RE = /^[\w\.$]+$/,
6
+ QUOTE_RE = /"/g,
7
+ TextParser = require('./text-parser')
8
+
9
+ /**
10
+ * Directive class
11
+ * represents a single directive instance in the DOM
12
+ */
13
+ function Directive (name, ast, definition, compiler, el) {
14
+
15
+ this.id = dirId++
16
+ this.name = name
17
+ this.compiler = compiler
18
+ this.vm = compiler.vm
19
+ this.el = el
20
+ this.computeFilters = false
21
+ this.key = ast.key
22
+ this.arg = ast.arg
23
+ this.expression = ast.expression
24
+
25
+ var isEmpty = this.expression === ''
26
+
27
+ // mix in properties from the directive definition
28
+ if (typeof definition === 'function') {
29
+ this[isEmpty ? 'bind' : 'update'] = definition
30
+ } else {
31
+ for (var prop in definition) {
32
+ this[prop] = definition[prop]
33
+ }
34
+ }
35
+
36
+ // empty expression, we're done.
37
+ if (isEmpty || this.isEmpty) {
38
+ this.isEmpty = true
39
+ return
40
+ }
41
+
42
+ if (TextParser.Regex.test(this.key)) {
43
+ this.key = compiler.eval(this.key)
44
+ if (this.isLiteral) {
45
+ this.expression = this.key
46
+ }
47
+ }
48
+
49
+ var filters = ast.filters,
50
+ filter, fn, i, l, computed
51
+ if (filters) {
52
+ this.filters = []
53
+ for (i = 0, l = filters.length; i < l; i++) {
54
+ filter = filters[i]
55
+ fn = this.compiler.getOption('filters', filter.name)
56
+ if (fn) {
57
+ filter.apply = fn
58
+ this.filters.push(filter)
59
+ if (fn.computed) {
60
+ computed = true
61
+ }
62
+ }
63
+ }
64
+ }
65
+
66
+ if (!this.filters || !this.filters.length) {
67
+ this.filters = null
68
+ }
69
+
70
+ if (computed) {
71
+ this.computedKey = Directive.inlineFilters(this.key, this.filters)
72
+ this.filters = null
73
+ }
74
+
75
+ this.isExp =
76
+ computed ||
77
+ !SINGLE_VAR_RE.test(this.key) ||
78
+ NESTING_RE.test(this.key)
79
+
80
+ }
81
+
82
+ var DirProto = Directive.prototype
83
+
84
+ /**
85
+ * called when a new value is set
86
+ * for computed properties, this will only be called once
87
+ * during initialization.
88
+ */
89
+ DirProto.$update = function (value, init) {
90
+ if (this.$lock) return
91
+ if (init || value !== this.value || (value && typeof value === 'object')) {
92
+ this.value = value
93
+ if (this.update) {
94
+ this.update(
95
+ this.filters && !this.computeFilters
96
+ ? this.$applyFilters(value)
97
+ : value,
98
+ init
99
+ )
100
+ }
101
+ }
102
+ }
103
+
104
+ /**
105
+ * pipe the value through filters
106
+ */
107
+ DirProto.$applyFilters = function (value) {
108
+ var filtered = value, filter
109
+ for (var i = 0, l = this.filters.length; i < l; i++) {
110
+ filter = this.filters[i]
111
+ filtered = filter.apply.apply(this.vm, [filtered].concat(filter.args))
112
+ }
113
+ return filtered
114
+ }
115
+
116
+ /**
117
+ * Unbind diretive
118
+ */
119
+ DirProto.$unbind = function () {
120
+ // this can be called before the el is even assigned...
121
+ if (!this.el || !this.vm) return
122
+ if (this.unbind) this.unbind()
123
+ this.vm = this.el = this.binding = this.compiler = null
124
+ }
125
+
126
+ // Exposed static methods -----------------------------------------------------
127
+
128
+ /**
129
+ * Parse a directive string into an Array of
130
+ * AST-like objects representing directives
131
+ */
132
+ Directive.parse = function (str) {
133
+
134
+ var inSingle = false,
135
+ inDouble = false,
136
+ curly = 0,
137
+ square = 0,
138
+ paren = 0,
139
+ begin = 0,
140
+ argIndex = 0,
141
+ dirs = [],
142
+ dir = {},
143
+ lastFilterIndex = 0,
144
+ arg
145
+
146
+ for (var c, i = 0, l = str.length; i < l; i++) {
147
+ c = str.charAt(i)
148
+ if (inSingle) {
149
+ // check single quote
150
+ if (c === "'") inSingle = !inSingle
151
+ } else if (inDouble) {
152
+ // check double quote
153
+ if (c === '"') inDouble = !inDouble
154
+ } else if (c === ',' && !paren && !curly && !square) {
155
+ // reached the end of a directive
156
+ pushDir()
157
+ // reset & skip the comma
158
+ dir = {}
159
+ begin = argIndex = lastFilterIndex = i + 1
160
+ } else if (c === ':' && !dir.key && !dir.arg) {
161
+ // argument
162
+ arg = str.slice(begin, i).trim()
163
+ if (ARG_RE.test(arg)) {
164
+ argIndex = i + 1
165
+ dir.arg = arg
166
+ }
167
+ } else if (c === '|' && str.charAt(i + 1) !== '|' && str.charAt(i - 1) !== '|') {
168
+ if (dir.key === undefined) {
169
+ // first filter, end of key
170
+ lastFilterIndex = i + 1
171
+ dir.key = str.slice(argIndex, i).trim()
172
+ } else {
173
+ // already has filter
174
+ pushFilter()
175
+ }
176
+ } else if (c === '"') {
177
+ inDouble = true
178
+ } else if (c === "'") {
179
+ inSingle = true
180
+ } else if (c === '(') {
181
+ paren++
182
+ } else if (c === ')') {
183
+ paren--
184
+ } else if (c === '[') {
185
+ square++
186
+ } else if (c === ']') {
187
+ square--
188
+ } else if (c === '{') {
189
+ curly++
190
+ } else if (c === '}') {
191
+ curly--
192
+ }
193
+ }
194
+ if (i === 0 || begin !== i) {
195
+ pushDir()
196
+ }
197
+
198
+ function pushDir () {
199
+ dir.expression = str.slice(begin, i).trim()
200
+ if (dir.key === undefined) {
201
+ dir.key = str.slice(argIndex, i).trim()
202
+ } else if (lastFilterIndex !== begin) {
203
+ pushFilter()
204
+ }
205
+ if (i === 0 || dir.key) {
206
+ dirs.push(dir)
207
+ }
208
+ }
209
+
210
+ function pushFilter () {
211
+ var exp = str.slice(lastFilterIndex, i).trim(),
212
+ filter
213
+ if (exp) {
214
+ filter = {}
215
+ var tokens = exp.match(FILTER_TOKEN_RE)
216
+ filter.name = tokens[0]
217
+ filter.args = tokens.length > 1 ? tokens.slice(1) : null
218
+ }
219
+ if (filter) {
220
+ (dir.filters = dir.filters || []).push(filter)
221
+ }
222
+ lastFilterIndex = i + 1
223
+ }
224
+
225
+ return dirs
226
+ }
227
+
228
+ /**
229
+ * Inline computed filters so they become part
230
+ * of the expression
231
+ */
232
+ Directive.inlineFilters = function (key, filters) {
233
+ var args, filter
234
+ for (var i = 0, l = filters.length; i < l; i++) {
235
+ filter = filters[i]
236
+ args = filter.args
237
+ ? ',"' + filter.args.map(escapeQuote).join('","') + '"'
238
+ : ''
239
+ key = 'this.$compiler.getOption("filters", "' +
240
+ filter.name +
241
+ '").call(this,' +
242
+ key + args +
243
+ ')'
244
+ }
245
+ return key
246
+ }
247
+
248
+ /**
249
+ * Convert double quotes to single quotes
250
+ * so they don't mess up the generated function body
251
+ */
252
+ function escapeQuote (v) {
253
+ return v.indexOf('"') > -1
254
+ ? v.replace(QUOTE_RE, '\'')
255
+ : v
256
+ }
257
+
258
+ module.exports = Directive
@@ -0,0 +1,41 @@
1
+ var utils = require('../utils'),
2
+ slice = [].slice
3
+
4
+ /**
5
+ * Binding for innerHTML
6
+ */
7
+ module.exports = {
8
+
9
+ bind: function () {
10
+ // a comment node means this is a binding for
11
+ // {{{ inline unescaped html }}}
12
+ if (this.el.nodeType === 8) {
13
+ // hold nodes
14
+ this.nodes = []
15
+ }
16
+ },
17
+
18
+ update: function (value) {
19
+ value = utils.guard(value)
20
+ if (this.nodes) {
21
+ this.swap(value)
22
+ } else {
23
+ this.el.innerHTML = value
24
+ }
25
+ },
26
+
27
+ swap: function (value) {
28
+ var parent = this.el.parentNode,
29
+ nodes = this.nodes,
30
+ i = nodes.length
31
+ // remove old nodes
32
+ while (i--) {
33
+ parent.removeChild(nodes[i])
34
+ }
35
+ // convert new value to a fragment
36
+ var frag = utils.toFragment(value)
37
+ // save a reference to these nodes so we can remove later
38
+ this.nodes = slice.call(frag.childNodes)
39
+ parent.insertBefore(frag, this.el)
40
+ }
41
+ }
@@ -0,0 +1,56 @@
1
+ var utils = require('../utils')
2
+
3
+ /**
4
+ * Manages a conditional child VM
5
+ */
6
+ module.exports = {
7
+
8
+ bind: function () {
9
+
10
+ this.parent = this.el.parentNode
11
+ this.ref = document.createComment('vue-if')
12
+ this.Ctor = this.compiler.resolveComponent(this.el)
13
+
14
+ // insert ref
15
+ this.parent.insertBefore(this.ref, this.el)
16
+ this.parent.removeChild(this.el)
17
+
18
+ if (utils.attr(this.el, 'view')) {
19
+ utils.warn(
20
+ 'Conflict: v-if cannot be used together with v-view. ' +
21
+ 'Just set v-view\'s binding value to empty string to empty it.'
22
+ )
23
+ }
24
+ if (utils.attr(this.el, 'repeat')) {
25
+ utils.warn(
26
+ 'Conflict: v-if cannot be used together with v-repeat. ' +
27
+ 'Use `v-show` or the `filterBy` filter instead.'
28
+ )
29
+ }
30
+ },
31
+
32
+ update: function (value) {
33
+
34
+ if (!value) {
35
+ this.unbind()
36
+ } else if (!this.childVM) {
37
+ this.childVM = new this.Ctor({
38
+ el: this.el.cloneNode(true),
39
+ parent: this.vm
40
+ })
41
+ if (this.compiler.init) {
42
+ this.parent.insertBefore(this.childVM.$el, this.ref)
43
+ } else {
44
+ this.childVM.$before(this.ref)
45
+ }
46
+ }
47
+
48
+ },
49
+
50
+ unbind: function () {
51
+ if (this.childVM) {
52
+ this.childVM.$destroy()
53
+ this.childVM = null
54
+ }
55
+ }
56
+ }
@@ -0,0 +1,129 @@
1
+ var utils = require('../utils'),
2
+ config = require('../config'),
3
+ transition = require('../transition'),
4
+ directives = module.exports = utils.hash()
5
+
6
+ /**
7
+ * Nest and manage a Child VM
8
+ */
9
+ directives.component = {
10
+ isLiteral: true,
11
+ bind: function () {
12
+ if (!this.el.vue_vm) {
13
+ this.childVM = new this.Ctor({
14
+ el: this.el,
15
+ parent: this.vm
16
+ })
17
+ }
18
+ },
19
+ unbind: function () {
20
+ if (this.childVM) {
21
+ this.childVM.$destroy()
22
+ }
23
+ }
24
+ }
25
+
26
+ /**
27
+ * Binding HTML attributes
28
+ */
29
+ directives.attr = {
30
+ bind: function () {
31
+ var params = this.vm.$options.paramAttributes
32
+ this.isParam = params && params.indexOf(this.arg) > -1
33
+ },
34
+ update: function (value) {
35
+ if (value || value === 0) {
36
+ this.el.setAttribute(this.arg, value)
37
+ } else {
38
+ this.el.removeAttribute(this.arg)
39
+ }
40
+ if (this.isParam) {
41
+ this.vm[this.arg] = utils.checkNumber(value)
42
+ }
43
+ }
44
+ }
45
+
46
+ /**
47
+ * Binding textContent
48
+ */
49
+ directives.text = {
50
+ bind: function () {
51
+ this.attr = this.el.nodeType === 3
52
+ ? 'nodeValue'
53
+ : 'textContent'
54
+ },
55
+ update: function (value) {
56
+ this.el[this.attr] = utils.guard(value)
57
+ }
58
+ }
59
+
60
+ /**
61
+ * Binding CSS display property
62
+ */
63
+ directives.show = function (value) {
64
+ var el = this.el,
65
+ target = value ? '' : 'none',
66
+ change = function () {
67
+ el.style.display = target
68
+ }
69
+ transition(el, value ? 1 : -1, change, this.compiler)
70
+ }
71
+
72
+ /**
73
+ * Binding CSS classes
74
+ */
75
+ directives['class'] = function (value) {
76
+ if (this.arg) {
77
+ utils[value ? 'addClass' : 'removeClass'](this.el, this.arg)
78
+ } else {
79
+ if (this.lastVal) {
80
+ utils.removeClass(this.el, this.lastVal)
81
+ }
82
+ if (value) {
83
+ utils.addClass(this.el, value)
84
+ this.lastVal = value
85
+ }
86
+ }
87
+ }
88
+
89
+ /**
90
+ * Only removed after the owner VM is ready
91
+ */
92
+ directives.cloak = {
93
+ isEmpty: true,
94
+ bind: function () {
95
+ var el = this.el
96
+ this.compiler.observer.once('hook:ready', function () {
97
+ el.removeAttribute(config.prefix + '-cloak')
98
+ })
99
+ }
100
+ }
101
+
102
+ /**
103
+ * Store a reference to self in parent VM's $
104
+ */
105
+ directives.ref = {
106
+ isLiteral: true,
107
+ bind: function () {
108
+ var id = this.expression
109
+ if (id) {
110
+ this.vm.$parent.$[id] = this.vm
111
+ }
112
+ },
113
+ unbind: function () {
114
+ var id = this.expression
115
+ if (id) {
116
+ delete this.vm.$parent.$[id]
117
+ }
118
+ }
119
+ }
120
+
121
+ directives.on = require('./on')
122
+ directives.repeat = require('./repeat')
123
+ directives.model = require('./model')
124
+ directives['if'] = require('./if')
125
+ directives['with'] = require('./with')
126
+ directives.html = require('./html')
127
+ directives.style = require('./style')
128
+ directives.partial = require('./partial')
129
+ directives.view = require('./view')