storytime 1.2.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (359) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +10 -0
  3. data/.rspec +1 -0
  4. data/.ruby-gemset +1 -0
  5. data/.ruby-version +1 -0
  6. data/Gemfile +17 -0
  7. data/Gemfile.lock +448 -0
  8. data/Guardfile +24 -0
  9. data/MIT-LICENSE +1 -1
  10. data/README.md +160 -0
  11. data/app/assets/{javascripts/storytime/subscriptions.js → images/storytime/.keep} +0 -0
  12. data/app/assets/images/storytime/storytime-logo-nav-light.png +0 -0
  13. data/app/assets/images/storytime/storytime-logo-nav.png +0 -0
  14. data/app/assets/images/storytime/storytime-logo.png +0 -0
  15. data/app/assets/javascripts/storytime/application.js +11 -3
  16. data/app/assets/javascripts/storytime/base.js.coffee +44 -6
  17. data/app/assets/javascripts/storytime/blog_posts.js.coffee +16 -0
  18. data/app/assets/javascripts/storytime/blogs.js.coffee +18 -0
  19. data/app/assets/javascripts/storytime/character_counter.js.coffee +26 -0
  20. data/app/assets/javascripts/storytime/contenteditable.js.coffee +15 -0
  21. data/app/assets/javascripts/storytime/custom_posts.js.coffee +16 -0
  22. data/app/assets/javascripts/storytime/editor.js.coffee +50 -134
  23. data/app/assets/javascripts/storytime/media.js.coffee +91 -22
  24. data/app/assets/javascripts/storytime/pages.js.coffee +16 -0
  25. data/app/assets/javascripts/storytime/posts.js.coffee +28 -1
  26. data/app/assets/javascripts/storytime/sites.js.coffee +1 -16
  27. data/app/assets/javascripts/storytime/snippets.js.coffee +6 -3
  28. data/app/assets/javascripts/storytime/tags.js.coffee +17 -0
  29. data/app/assets/javascripts/storytime/users.js.coffee +10 -0
  30. data/app/assets/javascripts/storytime/wysiwyg.js.coffee +183 -0
  31. data/app/assets/stylesheets/storytime/_buttons.scss +70 -0
  32. data/app/assets/stylesheets/storytime/_dropdowns.scss +5 -0
  33. data/app/assets/stylesheets/storytime/_forms.scss +3 -0
  34. data/app/assets/stylesheets/storytime/_list-group.scss +13 -0
  35. data/app/assets/stylesheets/storytime/_pagination.scss +14 -0
  36. data/app/assets/stylesheets/storytime/_panels.scss +8 -0
  37. data/app/assets/stylesheets/storytime/_tabs.scss +38 -0
  38. data/app/assets/stylesheets/storytime/_type.scss +13 -0
  39. data/app/assets/stylesheets/storytime/_wells.scss +14 -0
  40. data/app/assets/stylesheets/storytime/admin.scss +42 -0
  41. data/app/assets/stylesheets/storytime/application.scss +75 -0
  42. data/app/assets/stylesheets/storytime/{comments.css.scss → comments.scss} +0 -0
  43. data/app/assets/stylesheets/storytime/icons.scss +79 -0
  44. data/app/assets/stylesheets/storytime/layout.scss +21 -0
  45. data/app/assets/stylesheets/storytime/media.scss +65 -0
  46. data/app/assets/stylesheets/storytime/modals.scss +46 -0
  47. data/app/assets/stylesheets/storytime/navigation.scss +137 -0
  48. data/app/assets/stylesheets/storytime/posts.scss +76 -0
  49. data/app/assets/stylesheets/storytime/scroll-panels.scss +19 -0
  50. data/app/assets/stylesheets/storytime/snippets.scss +11 -0
  51. data/app/assets/stylesheets/storytime/{sites.css.scss → subscriptions.scss} +0 -0
  52. data/app/assets/stylesheets/storytime/versions.scss +21 -0
  53. data/app/controllers/storytime/application_controller.rb +36 -16
  54. data/app/controllers/storytime/blog_homepage_controller.rb +10 -0
  55. data/app/controllers/storytime/blogs_controller.rb +56 -0
  56. data/app/controllers/storytime/comments_controller.rb +5 -1
  57. data/app/controllers/storytime/dashboard/autosaves_controller.rb +7 -3
  58. data/app/controllers/storytime/dashboard/blog_posts_controller.rb +60 -0
  59. data/app/controllers/storytime/dashboard/blogs_controller.rb +66 -0
  60. data/app/controllers/storytime/dashboard/custom_posts_controller.rb +51 -0
  61. data/app/controllers/storytime/dashboard/media_controller.rb +9 -7
  62. data/app/controllers/storytime/dashboard/memberships_controller.rb +49 -0
  63. data/app/controllers/storytime/dashboard/pages_controller.rb +24 -0
  64. data/app/controllers/storytime/dashboard/posts_controller.rb +29 -38
  65. data/app/controllers/storytime/dashboard/roles_controller.rb +16 -2
  66. data/app/controllers/storytime/dashboard/sites_controller.rb +25 -11
  67. data/app/controllers/storytime/dashboard/snippets_controller.rb +19 -14
  68. data/app/controllers/storytime/dashboard/subscriptions_controller.rb +9 -5
  69. data/app/controllers/storytime/dashboard/users_controller.rb +24 -22
  70. data/app/controllers/storytime/dashboard_controller.rb +9 -3
  71. data/app/controllers/storytime/homepage_controller.rb +10 -0
  72. data/app/controllers/storytime/pages_controller.rb +30 -13
  73. data/app/controllers/storytime/posts_controller.rb +22 -53
  74. data/app/controllers/storytime/subscriptions_controller.rb +5 -4
  75. data/app/helpers/storytime/application_helper.rb +28 -7
  76. data/app/helpers/storytime/dashboard/sites_helper.rb +2 -5
  77. data/app/helpers/storytime/subscriptions_helper.rb +0 -7
  78. data/app/inputs/date_time_picker_input.rb +1 -1
  79. data/app/mailers/storytime/subscription_mailer.rb +1 -3
  80. data/app/models/concerns/storytime/post_comments.rb +17 -0
  81. data/app/models/concerns/storytime/post_excerpt.rb +14 -0
  82. data/app/models/concerns/storytime/post_featured_images.rb +8 -0
  83. data/app/models/concerns/storytime/post_partial_inheritance.rb +29 -0
  84. data/app/models/concerns/storytime/post_tags.rb +41 -0
  85. data/app/models/concerns/storytime/scoped_to_site.rb +11 -0
  86. data/app/models/storytime/action.rb +1 -0
  87. data/app/models/storytime/autosave.rb +7 -1
  88. data/app/models/storytime/blog.rb +16 -0
  89. data/app/models/storytime/blog_post.rb +12 -1
  90. data/app/models/storytime/comment.rb +4 -1
  91. data/app/models/storytime/media.rb +2 -0
  92. data/app/models/storytime/membership.rb +17 -0
  93. data/app/models/storytime/page.rb +0 -5
  94. data/app/models/storytime/permission.rb +26 -20
  95. data/app/models/storytime/post.rb +29 -82
  96. data/app/models/storytime/role.rb +12 -0
  97. data/app/models/storytime/site.rb +42 -12
  98. data/app/models/storytime/snippet.rb +3 -0
  99. data/app/models/storytime/subscription.rb +2 -1
  100. data/app/models/storytime/tag.rb +5 -1
  101. data/app/models/storytime/tagging.rb +1 -0
  102. data/app/models/storytime/version.rb +1 -0
  103. data/app/policies/admin_policy.rb +30 -0
  104. data/app/policies/storytime/comment_policy.rb +5 -1
  105. data/app/policies/storytime/membership_policy.rb +32 -0
  106. data/app/policies/storytime/post_policy.rb +6 -4
  107. data/app/policies/storytime/site_policy.rb +7 -2
  108. data/app/policies/storytime/snippet_policy.rb +3 -2
  109. data/app/policies/storytime/subscription_policy.rb +3 -2
  110. data/app/policies/user_policy.rb +2 -5
  111. data/app/views/kaminari/_first_page.html.erb +13 -0
  112. data/app/views/kaminari/_gap.html.erb +8 -0
  113. data/app/views/kaminari/_last_page.html.erb +13 -0
  114. data/app/views/kaminari/_next_page.html.erb +13 -0
  115. data/app/views/kaminari/_page.html.erb +12 -0
  116. data/app/views/kaminari/_paginator.html.erb +24 -0
  117. data/app/views/kaminari/_prev_page.html.erb +13 -0
  118. data/app/views/layouts/storytime/application.html.erb +1 -1
  119. data/app/views/layouts/storytime/dashboard.html.erb +22 -6
  120. data/app/views/storytime/application/storytime/_disqus_comment_counts.html.erb +14 -0
  121. data/app/views/storytime/application/storytime/_header.html.erb +3 -4
  122. data/app/views/storytime/application/storytime/_navigation.html.erb +14 -1
  123. data/app/views/storytime/blogs/_tags.html.erb +3 -0
  124. data/app/views/storytime/{posts/index.atom.builder → blogs/show.atom.builder} +1 -1
  125. data/app/views/storytime/{posts/index.html.erb → blogs/show.html.erb} +1 -1
  126. data/app/views/storytime/comments/_discourse.html.erb +18 -0
  127. data/app/views/storytime/comments/_disqus.html.erb +2 -2
  128. data/app/views/storytime/comments/_form.html.erb +2 -2
  129. data/app/views/storytime/dashboard/_navigation.html.erb +109 -41
  130. data/app/views/storytime/dashboard/_settings_tabs.html.erb +32 -0
  131. data/app/views/storytime/dashboard/autosaves/_autosave_info.html.erb +7 -4
  132. data/app/views/storytime/dashboard/blog_posts/_form.html.erb +157 -0
  133. data/app/views/storytime/dashboard/blog_posts/edit.html.erb +55 -0
  134. data/app/views/storytime/dashboard/blog_posts/new.html.erb +31 -0
  135. data/app/views/storytime/dashboard/blogs/_blog.html.erb +3 -0
  136. data/app/views/storytime/dashboard/blogs/_form.html.erb +25 -0
  137. data/app/views/storytime/dashboard/blogs/edit.json.jbuilder +1 -0
  138. data/app/views/storytime/dashboard/blogs/index.json.jbuilder +1 -0
  139. data/app/views/storytime/dashboard/blogs/new.json.jbuilder +1 -0
  140. data/app/views/storytime/dashboard/media/_form.html.erb +3 -3
  141. data/app/views/storytime/dashboard/media/{_gallery.html → _gallery.html.erb} +7 -4
  142. data/app/views/storytime/dashboard/media/_media.html.erb +6 -13
  143. data/app/views/storytime/dashboard/media/_modal.html.erb +3 -3
  144. data/app/views/storytime/dashboard/media/index.html.erb +15 -5
  145. data/app/views/storytime/dashboard/memberships/_form.html.erb +12 -0
  146. data/app/views/storytime/dashboard/memberships/_index.html.erb +39 -0
  147. data/app/views/storytime/dashboard/memberships/_membership.html.erb +12 -0
  148. data/app/views/storytime/dashboard/memberships/index.json.jbuilder +2 -0
  149. data/app/views/storytime/dashboard/memberships/save.json.jbuilder +1 -0
  150. data/app/views/storytime/dashboard/pages/_form.html.erb +88 -0
  151. data/app/views/storytime/dashboard/pages/_index_title.html.erb +1 -0
  152. data/app/views/storytime/dashboard/pages/_new_button.html.erb +1 -0
  153. data/app/views/storytime/dashboard/pages/edit.html.erb +49 -0
  154. data/app/views/storytime/dashboard/pages/new.html.erb +28 -0
  155. data/app/views/storytime/dashboard/posts/_form.html.erb +128 -122
  156. data/app/views/storytime/dashboard/posts/_image_toolbar.html.erb +32 -0
  157. data/app/views/storytime/dashboard/posts/_index_title.html.erb +1 -0
  158. data/app/views/storytime/dashboard/posts/_list.html.erb +23 -24
  159. data/app/views/storytime/dashboard/posts/_new_button.html.erb +10 -0
  160. data/app/views/storytime/dashboard/posts/edit.html.erb +56 -13
  161. data/app/views/storytime/dashboard/posts/index.html.erb +56 -7
  162. data/app/views/storytime/dashboard/posts/new.html.erb +29 -8
  163. data/app/views/storytime/dashboard/roles/_form.html.erb +41 -0
  164. data/app/views/storytime/dashboard/roles/edit.json.jbuilder +1 -0
  165. data/app/views/storytime/dashboard/sites/_form.html.erb +31 -15
  166. data/app/views/storytime/dashboard/sites/new.html.erb +21 -8
  167. data/app/views/storytime/dashboard/sites/site.json.jbuilder +2 -0
  168. data/app/views/storytime/dashboard/snippets/_form.html.erb +26 -12
  169. data/app/views/storytime/dashboard/snippets/_index.html.erb +17 -0
  170. data/app/views/storytime/dashboard/snippets/_snippet.html.erb +12 -0
  171. data/app/views/storytime/dashboard/snippets/edit.json.jbuilder +1 -0
  172. data/app/views/storytime/dashboard/snippets/index.json.jbuilder +4 -0
  173. data/app/views/storytime/dashboard/snippets/new.json.jbuilder +1 -0
  174. data/app/views/storytime/dashboard/subscriptions/_form.html.erb +19 -0
  175. data/app/views/storytime/dashboard/subscriptions/_index.html.erb +19 -0
  176. data/app/views/storytime/dashboard/subscriptions/_subscription.html.erb +9 -10
  177. data/app/views/storytime/dashboard/subscriptions/form.json.jbuilder +1 -0
  178. data/app/views/storytime/dashboard/subscriptions/index.json.jbuilder +1 -0
  179. data/app/views/storytime/dashboard/users/_edit.html.erb +26 -0
  180. data/app/views/storytime/dashboard/users/_new.html.erb +25 -0
  181. data/app/views/storytime/dashboard/users/edit.json.jbuilder +2 -0
  182. data/app/views/storytime/dashboard/users/new.json.jbuilder +2 -0
  183. data/app/views/storytime/dashboard/versions/_version.html.erb +14 -0
  184. data/app/views/storytime/dashboard/versions/_versions_info.html.erb +1 -16
  185. data/app/views/storytime/pages/show.html.erb +1 -1
  186. data/app/views/storytime/posts/_post.html.erb +8 -0
  187. data/app/views/storytime/posts/_tags.html.erb +1 -1
  188. data/app/views/storytime/posts/show.html.erb +1 -1
  189. data/app/views/storytime/sites/_google_analytics_code.html.erb +2 -2
  190. data/app/views/storytime/snippets/_snippet.html.erb +9 -0
  191. data/app/views/storytime/subscription_mailer/new_post_email.html.erb +2 -2
  192. data/app/views/storytime/subscription_mailer/new_post_email.text.erb +2 -2
  193. data/app/views/storytime/subscriptions/_form.html.erb +0 -1
  194. data/app/views/storytime/subscriptions/_modal.html.erb +18 -10
  195. data/bin/rails +12 -0
  196. data/bin/storytime +4 -0
  197. data/circle.yml +3 -0
  198. data/config/initializers/storytime_admin.rb +3 -0
  199. data/config/initializers/url_for_patch.rb +2 -37
  200. data/config/locales/en.yml +33 -13
  201. data/config/routes.rb +47 -19
  202. data/db/migrate/20150128185746_seed_new_actions_and_permissions.rb +9 -0
  203. data/db/migrate/20150206201847_add_site_id_to_storytime_post.rb +7 -0
  204. data/db/migrate/20150206201919_add_site_id_to_storytime_snippet.rb +7 -0
  205. data/db/migrate/20150206201931_add_site_id_to_storytime_tag.rb +7 -0
  206. data/db/migrate/20150206205256_add_notification_fields_to_storytime_post.rb +6 -0
  207. data/db/migrate/20150216211257_add_subdomain_to_storytime_sites.rb +5 -0
  208. data/db/migrate/20150216225045_add_site_to_storytime_media.rb +6 -0
  209. data/db/migrate/20150219210528_remove_root_page_content_from_storytime_sites.rb +12 -0
  210. data/db/migrate/20150220184902_add_blog_id_to_posts.rb +6 -0
  211. data/db/migrate/20150224192138_add_homepage_path_to_storytime_sites.rb +5 -0
  212. data/db/migrate/20150224193151_add_subscription_email_from_to_storytime_sites.rb +5 -0
  213. data/db/migrate/20150224193551_add_layout_to_storytime_sites.rb +5 -0
  214. data/db/migrate/20150224194559_add_disqus_forum_shortname_to_storytime_sites.rb +5 -0
  215. data/db/migrate/20150224212453_remove_homepage_path_from_storytime_sites.rb +5 -0
  216. data/db/migrate/20150225143516_add_site_id_to_storytime_autosaves.rb +6 -0
  217. data/db/migrate/20150225143826_add_site_id_to_storytime_comments.rb +6 -0
  218. data/db/migrate/20150225145119_add_site_id_to_storytime_versions.rb +6 -0
  219. data/db/migrate/20150225145316_add_site_id_to_storytime_taggings.rb +6 -0
  220. data/db/migrate/20150225145608_update_storytime_site_id_columns.rb +11 -0
  221. data/db/migrate/20150225164232_add_site_id_to_storytime_permissions.rb +6 -0
  222. data/db/migrate/20150225212917_create_storytime_memberships.rb +11 -0
  223. data/db/migrate/20150225213535_create_memberships_for_storytime_users.rb +8 -0
  224. data/db/migrate/20150226201739_add_custom_domain_to_storytime_sites.rb +5 -0
  225. data/db/migrate/20150302171500_add_site_id_to_storytime_media.rb +8 -0
  226. data/db/migrate/20150302171722_set_site_layout.rb +8 -0
  227. data/db/migrate/20150302185138_remove_storytime_role_id_from_users.rb +5 -0
  228. data/db/migrate/20150302192525_transfer_posts_to_blogs.rb +8 -0
  229. data/db/migrate/20150302192759_seed_permissions.rb +9 -0
  230. data/db/migrate/20150331162329_add_discourse_name_to_storytime_sites.rb +5 -0
  231. data/db/migrate/20150402161427_remove_subdomain_from_storytime_site.rb +5 -0
  232. data/lib/generators/storytime/install_generator.rb +17 -0
  233. data/lib/generators/storytime/views_generator.rb +21 -9
  234. data/lib/generators/templates/storytime.rb +70 -27
  235. data/lib/storytime/cli/install.rb +274 -0
  236. data/lib/storytime/cli.rb +28 -0
  237. data/lib/storytime/concerns/current_site.rb +10 -0
  238. data/lib/storytime/concerns/has_versions.rb +22 -3
  239. data/lib/storytime/concerns/storytime_user.rb +31 -7
  240. data/lib/storytime/constraints/blog_constraint.rb +11 -0
  241. data/lib/storytime/constraints/blog_homepage_constraint.rb +11 -0
  242. data/lib/storytime/constraints/page_constraint.rb +13 -0
  243. data/lib/storytime/constraints/page_homepage_constraint.rb +11 -0
  244. data/lib/storytime/engine.rb +43 -14
  245. data/lib/storytime/generators/initializer.rb +45 -0
  246. data/lib/storytime/migrators/v1.rb +122 -0
  247. data/lib/storytime/post_notifier.rb +19 -0
  248. data/lib/storytime/post_url_handler.rb +47 -0
  249. data/lib/storytime/storytime_helpers.rb +12 -0
  250. data/lib/storytime/version.rb +1 -1
  251. data/lib/storytime.rb +57 -56
  252. data/screenshots/admin.png +0 -0
  253. data/screenshots/media.png +0 -0
  254. data/screenshots/page-list.png +0 -0
  255. data/screenshots/post-editor.png +0 -0
  256. data/screenshots/site-settings.png +0 -0
  257. data/screenshots/text-snippets.png +0 -0
  258. data/screenshots/user-management.png +0 -0
  259. data/spec/controllers/dashboard_controller_spec.rb +3 -1
  260. data/{app/assets/stylesheets/storytime/subscriptions.css.scss → spec/dummy/app/assets/images/.keep} +0 -0
  261. data/spec/dummy/app/assets/javascripts/application.js +3 -0
  262. data/spec/dummy/app/controllers/application_controller.rb +5 -1
  263. data/spec/dummy/app/controllers/concerns/.keep +0 -0
  264. data/spec/dummy/app/controllers/storytime_admin/widgets_controller.rb +5 -0
  265. data/spec/dummy/app/mailers/.keep +0 -0
  266. data/spec/dummy/app/models/.keep +0 -0
  267. data/spec/dummy/app/models/concerns/.keep +0 -0
  268. data/spec/dummy/app/models/user.rb +5 -1
  269. data/spec/dummy/app/models/video_post.rb +2 -0
  270. data/spec/dummy/app/models/widget.rb +3 -0
  271. data/spec/dummy/app/views/layouts/application.html.erb +1 -1
  272. data/spec/dummy/app/views/storytime/dashboard/posts/_video_post_fields.html.erb +1 -0
  273. data/spec/dummy/app/views/widgets/storytime/dashboard/admin/_headers.html.erb +1 -0
  274. data/spec/dummy/app/views/widgets/storytime/dashboard/admin/_row.html.erb +1 -0
  275. data/spec/dummy/config/database.yml +9 -5
  276. data/spec/dummy/config/environments/test.rb +1 -0
  277. data/spec/dummy/config/initializers/devise.rb +1 -1
  278. data/spec/dummy/config/initializers/session_store.rb +1 -1
  279. data/spec/dummy/config/initializers/storytime.rb +7 -14
  280. data/spec/dummy/db/development.sqlite3 +0 -0
  281. data/spec/dummy/db/migrate/20150127172846_create_widgets.rb +9 -0
  282. data/spec/dummy/db/migrate/20150206203824_add_video_url_to_storytime_posts.rb +5 -0
  283. data/spec/dummy/db/schema.rb +76 -21
  284. data/spec/dummy/db/test.sqlite3 +0 -0
  285. data/spec/dummy/lib/assets/.keep +0 -0
  286. data/spec/dummy/log/.keep +0 -0
  287. data/spec/factories/comment_factories.rb +1 -0
  288. data/spec/factories/membership_factories.rb +7 -0
  289. data/spec/factories/site_factories.rb +3 -2
  290. data/spec/factories/user_factories.rb +3 -3
  291. data/spec/factories/widget_factories.rb +5 -0
  292. data/spec/features/blogs_spec.rb +28 -0
  293. data/spec/features/comments_spec.rb +8 -9
  294. data/spec/features/dashboard/media_spec.rb +14 -30
  295. data/spec/features/dashboard/memberships_spec.rb +58 -0
  296. data/spec/features/dashboard/pages_spec.rb +67 -44
  297. data/spec/features/dashboard/posts_spec.rb +84 -62
  298. data/spec/features/dashboard/sites_spec.rb +28 -23
  299. data/spec/features/dashboard/snippets_spec.rb +44 -44
  300. data/spec/features/dashboard/subscription_spec.rb +36 -28
  301. data/spec/features/dashboard/users_spec.rb +48 -29
  302. data/spec/features/pages_spec.rb +2 -2
  303. data/spec/features/posts_spec.rb +2 -20
  304. data/spec/features/subscription_spec.rb +4 -4
  305. data/spec/models/post_spec.rb +26 -17
  306. data/spec/policies/comment_policy_spec.rb +22 -6
  307. data/spec/policies/post_policy_spec.rb +21 -3
  308. data/spec/requests/routings_spec.rb +27 -17
  309. data/spec/spec_helper.rb +12 -1
  310. data/spec/support/database_cleaner.rb +5 -5
  311. data/spec/support/domains.rb +18 -0
  312. data/spec/support/feature_macros.rb +18 -9
  313. data/storytime.gemspec +59 -0
  314. data/vendor/assets/javascripts/.DS_Store +0 -0
  315. data/vendor/assets/javascripts/codemirror/modes/css.js +717 -0
  316. data/vendor/assets/javascripts/codemirror/modes/htmlmixed.js +120 -0
  317. data/vendor/assets/javascripts/codemirror/modes/javascript.js +686 -0
  318. data/vendor/assets/javascripts/codemirror/modes/liquid.js +40 -0
  319. data/vendor/assets/javascripts/codemirror/modes/overlay.js +85 -0
  320. data/vendor/assets/javascripts/codemirror/{xml.js → modes/xml.js} +2 -2
  321. data/vendor/assets/javascripts/medium-editor.min.js +2450 -0
  322. data/vendor/assets/javascripts/phantom_js_bind_polyfill.js +24 -0
  323. data/vendor/assets/javascripts/tidy.js +30 -0
  324. data/vendor/assets/stylesheets/.DS_Store +0 -0
  325. data/vendor/assets/stylesheets/chosen-bootstrap-3.css +148 -0
  326. data/vendor/assets/stylesheets/{chosen.css.scss → chosen.scss} +1 -1
  327. data/vendor/assets/stylesheets/disable-transitions-for-test-env.css +7 -0
  328. data/vendor/assets/stylesheets/medium-editor-default.min.css +1 -0
  329. data/vendor/assets/stylesheets/medium-editor.min.css +1 -0
  330. metadata +297 -47
  331. data/app/assets/stylesheets/storytime/admin.css.scss +0 -121
  332. data/app/assets/stylesheets/storytime/application.css.scss +0 -22
  333. data/app/assets/stylesheets/storytime/layout.css.scss +0 -17
  334. data/app/assets/stylesheets/storytime/media.css.scss +0 -68
  335. data/app/assets/stylesheets/storytime/pagination.css.scss +0 -4
  336. data/app/assets/stylesheets/storytime/posts.css.scss +0 -30
  337. data/app/assets/stylesheets/storytime/versions.css.scss +0 -21
  338. data/app/helpers/storytime/dashboard/posts_helper.rb +0 -21
  339. data/app/views/storytime/blog_posts/_blog_post.html.erb +0 -8
  340. data/app/views/storytime/dashboard/posts/_basic_new_post_button.html.erb +0 -3
  341. data/app/views/storytime/dashboard/posts/_new_post_dropdown_button.html.erb +0 -10
  342. data/app/views/storytime/dashboard/sites/edit.html.erb +0 -25
  343. data/app/views/storytime/dashboard/snippets/_list.html.erb +0 -21
  344. data/app/views/storytime/dashboard/snippets/edit.html.erb +0 -13
  345. data/app/views/storytime/dashboard/snippets/index.html.erb +0 -13
  346. data/app/views/storytime/dashboard/snippets/new.html.erb +0 -12
  347. data/app/views/storytime/dashboard/subscriptions/edit.html.erb +0 -10
  348. data/app/views/storytime/dashboard/subscriptions/index.html.erb +0 -19
  349. data/app/views/storytime/dashboard/subscriptions/new.html.erb +0 -9
  350. data/app/views/storytime/dashboard/users/_user.html.erb +0 -11
  351. data/app/views/storytime/dashboard/users/edit.html.erb +0 -10
  352. data/app/views/storytime/dashboard/users/index.html.erb +0 -22
  353. data/app/views/storytime/dashboard/users/new.html.erb +0 -11
  354. data/spec/lib/storytime_spec.rb +0 -23
  355. data/vendor/assets/javascripts/codemirror/codemirror.js +0 -7831
  356. data/vendor/assets/javascripts/summernote.js +0 -5338
  357. data/vendor/assets/stylesheets/codemirror/codemirror.css +0 -309
  358. data/vendor/assets/stylesheets/codemirror/monokai.css +0 -31
  359. data/vendor/assets/stylesheets/summernote.css +0 -1
@@ -0,0 +1,686 @@
1
+ // CodeMirror, copyright (c) by Marijn Haverbeke and others
2
+ // Distributed under an MIT license: http://codemirror.net/LICENSE
3
+
4
+ // TODO actually recognize syntax of TypeScript constructs
5
+
6
+ (function(mod) {
7
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
8
+ mod(require("../../lib/codemirror"));
9
+ else if (typeof define == "function" && define.amd) // AMD
10
+ define(["../../lib/codemirror"], mod);
11
+ else // Plain browser env
12
+ mod(CodeMirror);
13
+ })(function(CodeMirror) {
14
+ "use strict";
15
+
16
+ CodeMirror.defineMode("javascript", function(config, parserConfig) {
17
+ var indentUnit = config.indentUnit;
18
+ var statementIndent = parserConfig.statementIndent;
19
+ var jsonldMode = parserConfig.jsonld;
20
+ var jsonMode = parserConfig.json || jsonldMode;
21
+ var isTS = parserConfig.typescript;
22
+ var wordRE = parserConfig.wordCharacters || /[\w$]/;
23
+
24
+ // Tokenizer
25
+
26
+ var keywords = function(){
27
+ function kw(type) {return {type: type, style: "keyword"};}
28
+ var A = kw("keyword a"), B = kw("keyword b"), C = kw("keyword c");
29
+ var operator = kw("operator"), atom = {type: "atom", style: "atom"};
30
+
31
+ var jsKeywords = {
32
+ "if": kw("if"), "while": A, "with": A, "else": B, "do": B, "try": B, "finally": B,
33
+ "return": C, "break": C, "continue": C, "new": C, "delete": C, "throw": C, "debugger": C,
34
+ "var": kw("var"), "const": kw("var"), "let": kw("var"),
35
+ "function": kw("function"), "catch": kw("catch"),
36
+ "for": kw("for"), "switch": kw("switch"), "case": kw("case"), "default": kw("default"),
37
+ "in": operator, "typeof": operator, "instanceof": operator,
38
+ "true": atom, "false": atom, "null": atom, "undefined": atom, "NaN": atom, "Infinity": atom,
39
+ "this": kw("this"), "module": kw("module"), "class": kw("class"), "super": kw("atom"),
40
+ "yield": C, "export": kw("export"), "import": kw("import"), "extends": C
41
+ };
42
+
43
+ // Extend the 'normal' keywords with the TypeScript language extensions
44
+ if (isTS) {
45
+ var type = {type: "variable", style: "variable-3"};
46
+ var tsKeywords = {
47
+ // object-like things
48
+ "interface": kw("interface"),
49
+ "extends": kw("extends"),
50
+ "constructor": kw("constructor"),
51
+
52
+ // scope modifiers
53
+ "public": kw("public"),
54
+ "private": kw("private"),
55
+ "protected": kw("protected"),
56
+ "static": kw("static"),
57
+
58
+ // types
59
+ "string": type, "number": type, "bool": type, "any": type
60
+ };
61
+
62
+ for (var attr in tsKeywords) {
63
+ jsKeywords[attr] = tsKeywords[attr];
64
+ }
65
+ }
66
+
67
+ return jsKeywords;
68
+ }();
69
+
70
+ var isOperatorChar = /[+\-*&%=<>!?|~^]/;
71
+ var isJsonldKeyword = /^@(context|id|value|language|type|container|list|set|reverse|index|base|vocab|graph)"/;
72
+
73
+ function readRegexp(stream) {
74
+ var escaped = false, next, inSet = false;
75
+ while ((next = stream.next()) != null) {
76
+ if (!escaped) {
77
+ if (next == "/" && !inSet) return;
78
+ if (next == "[") inSet = true;
79
+ else if (inSet && next == "]") inSet = false;
80
+ }
81
+ escaped = !escaped && next == "\\";
82
+ }
83
+ }
84
+
85
+ // Used as scratch variables to communicate multiple values without
86
+ // consing up tons of objects.
87
+ var type, content;
88
+ function ret(tp, style, cont) {
89
+ type = tp; content = cont;
90
+ return style;
91
+ }
92
+ function tokenBase(stream, state) {
93
+ var ch = stream.next();
94
+ if (ch == '"' || ch == "'") {
95
+ state.tokenize = tokenString(ch);
96
+ return state.tokenize(stream, state);
97
+ } else if (ch == "." && stream.match(/^\d+(?:[eE][+\-]?\d+)?/)) {
98
+ return ret("number", "number");
99
+ } else if (ch == "." && stream.match("..")) {
100
+ return ret("spread", "meta");
101
+ } else if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
102
+ return ret(ch);
103
+ } else if (ch == "=" && stream.eat(">")) {
104
+ return ret("=>", "operator");
105
+ } else if (ch == "0" && stream.eat(/x/i)) {
106
+ stream.eatWhile(/[\da-f]/i);
107
+ return ret("number", "number");
108
+ } else if (/\d/.test(ch)) {
109
+ stream.match(/^\d*(?:\.\d*)?(?:[eE][+\-]?\d+)?/);
110
+ return ret("number", "number");
111
+ } else if (ch == "/") {
112
+ if (stream.eat("*")) {
113
+ state.tokenize = tokenComment;
114
+ return tokenComment(stream, state);
115
+ } else if (stream.eat("/")) {
116
+ stream.skipToEnd();
117
+ return ret("comment", "comment");
118
+ } else if (state.lastType == "operator" || state.lastType == "keyword c" ||
119
+ state.lastType == "sof" || /^[\[{}\(,;:]$/.test(state.lastType)) {
120
+ readRegexp(stream);
121
+ stream.eatWhile(/[gimy]/); // 'y' is "sticky" option in Mozilla
122
+ return ret("regexp", "string-2");
123
+ } else {
124
+ stream.eatWhile(isOperatorChar);
125
+ return ret("operator", "operator", stream.current());
126
+ }
127
+ } else if (ch == "`") {
128
+ state.tokenize = tokenQuasi;
129
+ return tokenQuasi(stream, state);
130
+ } else if (ch == "#") {
131
+ stream.skipToEnd();
132
+ return ret("error", "error");
133
+ } else if (isOperatorChar.test(ch)) {
134
+ stream.eatWhile(isOperatorChar);
135
+ return ret("operator", "operator", stream.current());
136
+ } else if (wordRE.test(ch)) {
137
+ stream.eatWhile(wordRE);
138
+ var word = stream.current(), known = keywords.propertyIsEnumerable(word) && keywords[word];
139
+ return (known && state.lastType != ".") ? ret(known.type, known.style, word) :
140
+ ret("variable", "variable", word);
141
+ }
142
+ }
143
+
144
+ function tokenString(quote) {
145
+ return function(stream, state) {
146
+ var escaped = false, next;
147
+ if (jsonldMode && stream.peek() == "@" && stream.match(isJsonldKeyword)){
148
+ state.tokenize = tokenBase;
149
+ return ret("jsonld-keyword", "meta");
150
+ }
151
+ while ((next = stream.next()) != null) {
152
+ if (next == quote && !escaped) break;
153
+ escaped = !escaped && next == "\\";
154
+ }
155
+ if (!escaped) state.tokenize = tokenBase;
156
+ return ret("string", "string");
157
+ };
158
+ }
159
+
160
+ function tokenComment(stream, state) {
161
+ var maybeEnd = false, ch;
162
+ while (ch = stream.next()) {
163
+ if (ch == "/" && maybeEnd) {
164
+ state.tokenize = tokenBase;
165
+ break;
166
+ }
167
+ maybeEnd = (ch == "*");
168
+ }
169
+ return ret("comment", "comment");
170
+ }
171
+
172
+ function tokenQuasi(stream, state) {
173
+ var escaped = false, next;
174
+ while ((next = stream.next()) != null) {
175
+ if (!escaped && (next == "`" || next == "$" && stream.eat("{"))) {
176
+ state.tokenize = tokenBase;
177
+ break;
178
+ }
179
+ escaped = !escaped && next == "\\";
180
+ }
181
+ return ret("quasi", "string-2", stream.current());
182
+ }
183
+
184
+ var brackets = "([{}])";
185
+ // This is a crude lookahead trick to try and notice that we're
186
+ // parsing the argument patterns for a fat-arrow function before we
187
+ // actually hit the arrow token. It only works if the arrow is on
188
+ // the same line as the arguments and there's no strange noise
189
+ // (comments) in between. Fallback is to only notice when we hit the
190
+ // arrow, and not declare the arguments as locals for the arrow
191
+ // body.
192
+ function findFatArrow(stream, state) {
193
+ if (state.fatArrowAt) state.fatArrowAt = null;
194
+ var arrow = stream.string.indexOf("=>", stream.start);
195
+ if (arrow < 0) return;
196
+
197
+ var depth = 0, sawSomething = false;
198
+ for (var pos = arrow - 1; pos >= 0; --pos) {
199
+ var ch = stream.string.charAt(pos);
200
+ var bracket = brackets.indexOf(ch);
201
+ if (bracket >= 0 && bracket < 3) {
202
+ if (!depth) { ++pos; break; }
203
+ if (--depth == 0) break;
204
+ } else if (bracket >= 3 && bracket < 6) {
205
+ ++depth;
206
+ } else if (wordRE.test(ch)) {
207
+ sawSomething = true;
208
+ } else if (sawSomething && !depth) {
209
+ ++pos;
210
+ break;
211
+ }
212
+ }
213
+ if (sawSomething && !depth) state.fatArrowAt = pos;
214
+ }
215
+
216
+ // Parser
217
+
218
+ var atomicTypes = {"atom": true, "number": true, "variable": true, "string": true, "regexp": true, "this": true, "jsonld-keyword": true};
219
+
220
+ function JSLexical(indented, column, type, align, prev, info) {
221
+ this.indented = indented;
222
+ this.column = column;
223
+ this.type = type;
224
+ this.prev = prev;
225
+ this.info = info;
226
+ if (align != null) this.align = align;
227
+ }
228
+
229
+ function inScope(state, varname) {
230
+ for (var v = state.localVars; v; v = v.next)
231
+ if (v.name == varname) return true;
232
+ for (var cx = state.context; cx; cx = cx.prev) {
233
+ for (var v = cx.vars; v; v = v.next)
234
+ if (v.name == varname) return true;
235
+ }
236
+ }
237
+
238
+ function parseJS(state, style, type, content, stream) {
239
+ var cc = state.cc;
240
+ // Communicate our context to the combinators.
241
+ // (Less wasteful than consing up a hundred closures on every call.)
242
+ cx.state = state; cx.stream = stream; cx.marked = null, cx.cc = cc; cx.style = style;
243
+
244
+ if (!state.lexical.hasOwnProperty("align"))
245
+ state.lexical.align = true;
246
+
247
+ while(true) {
248
+ var combinator = cc.length ? cc.pop() : jsonMode ? expression : statement;
249
+ if (combinator(type, content)) {
250
+ while(cc.length && cc[cc.length - 1].lex)
251
+ cc.pop()();
252
+ if (cx.marked) return cx.marked;
253
+ if (type == "variable" && inScope(state, content)) return "variable-2";
254
+ return style;
255
+ }
256
+ }
257
+ }
258
+
259
+ // Combinator utils
260
+
261
+ var cx = {state: null, column: null, marked: null, cc: null};
262
+ function pass() {
263
+ for (var i = arguments.length - 1; i >= 0; i--) cx.cc.push(arguments[i]);
264
+ }
265
+ function cont() {
266
+ pass.apply(null, arguments);
267
+ return true;
268
+ }
269
+ function register(varname) {
270
+ function inList(list) {
271
+ for (var v = list; v; v = v.next)
272
+ if (v.name == varname) return true;
273
+ return false;
274
+ }
275
+ var state = cx.state;
276
+ if (state.context) {
277
+ cx.marked = "def";
278
+ if (inList(state.localVars)) return;
279
+ state.localVars = {name: varname, next: state.localVars};
280
+ } else {
281
+ if (inList(state.globalVars)) return;
282
+ if (parserConfig.globalVars)
283
+ state.globalVars = {name: varname, next: state.globalVars};
284
+ }
285
+ }
286
+
287
+ // Combinators
288
+
289
+ var defaultVars = {name: "this", next: {name: "arguments"}};
290
+ function pushcontext() {
291
+ cx.state.context = {prev: cx.state.context, vars: cx.state.localVars};
292
+ cx.state.localVars = defaultVars;
293
+ }
294
+ function popcontext() {
295
+ cx.state.localVars = cx.state.context.vars;
296
+ cx.state.context = cx.state.context.prev;
297
+ }
298
+ function pushlex(type, info) {
299
+ var result = function() {
300
+ var state = cx.state, indent = state.indented;
301
+ if (state.lexical.type == "stat") indent = state.lexical.indented;
302
+ else for (var outer = state.lexical; outer && outer.type == ")" && outer.align; outer = outer.prev)
303
+ indent = outer.indented;
304
+ state.lexical = new JSLexical(indent, cx.stream.column(), type, null, state.lexical, info);
305
+ };
306
+ result.lex = true;
307
+ return result;
308
+ }
309
+ function poplex() {
310
+ var state = cx.state;
311
+ if (state.lexical.prev) {
312
+ if (state.lexical.type == ")")
313
+ state.indented = state.lexical.indented;
314
+ state.lexical = state.lexical.prev;
315
+ }
316
+ }
317
+ poplex.lex = true;
318
+
319
+ function expect(wanted) {
320
+ function exp(type) {
321
+ if (type == wanted) return cont();
322
+ else if (wanted == ";") return pass();
323
+ else return cont(exp);
324
+ };
325
+ return exp;
326
+ }
327
+
328
+ function statement(type, value) {
329
+ if (type == "var") return cont(pushlex("vardef", value.length), vardef, expect(";"), poplex);
330
+ if (type == "keyword a") return cont(pushlex("form"), expression, statement, poplex);
331
+ if (type == "keyword b") return cont(pushlex("form"), statement, poplex);
332
+ if (type == "{") return cont(pushlex("}"), block, poplex);
333
+ if (type == ";") return cont();
334
+ if (type == "if") {
335
+ if (cx.state.lexical.info == "else" && cx.state.cc[cx.state.cc.length - 1] == poplex)
336
+ cx.state.cc.pop()();
337
+ return cont(pushlex("form"), expression, statement, poplex, maybeelse);
338
+ }
339
+ if (type == "function") return cont(functiondef);
340
+ if (type == "for") return cont(pushlex("form"), forspec, statement, poplex);
341
+ if (type == "variable") return cont(pushlex("stat"), maybelabel);
342
+ if (type == "switch") return cont(pushlex("form"), expression, pushlex("}", "switch"), expect("{"),
343
+ block, poplex, poplex);
344
+ if (type == "case") return cont(expression, expect(":"));
345
+ if (type == "default") return cont(expect(":"));
346
+ if (type == "catch") return cont(pushlex("form"), pushcontext, expect("("), funarg, expect(")"),
347
+ statement, poplex, popcontext);
348
+ if (type == "module") return cont(pushlex("form"), pushcontext, afterModule, popcontext, poplex);
349
+ if (type == "class") return cont(pushlex("form"), className, poplex);
350
+ if (type == "export") return cont(pushlex("form"), afterExport, poplex);
351
+ if (type == "import") return cont(pushlex("form"), afterImport, poplex);
352
+ return pass(pushlex("stat"), expression, expect(";"), poplex);
353
+ }
354
+ function expression(type) {
355
+ return expressionInner(type, false);
356
+ }
357
+ function expressionNoComma(type) {
358
+ return expressionInner(type, true);
359
+ }
360
+ function expressionInner(type, noComma) {
361
+ if (cx.state.fatArrowAt == cx.stream.start) {
362
+ var body = noComma ? arrowBodyNoComma : arrowBody;
363
+ if (type == "(") return cont(pushcontext, pushlex(")"), commasep(pattern, ")"), poplex, expect("=>"), body, popcontext);
364
+ else if (type == "variable") return pass(pushcontext, pattern, expect("=>"), body, popcontext);
365
+ }
366
+
367
+ var maybeop = noComma ? maybeoperatorNoComma : maybeoperatorComma;
368
+ if (atomicTypes.hasOwnProperty(type)) return cont(maybeop);
369
+ if (type == "function") return cont(functiondef, maybeop);
370
+ if (type == "keyword c") return cont(noComma ? maybeexpressionNoComma : maybeexpression);
371
+ if (type == "(") return cont(pushlex(")"), maybeexpression, comprehension, expect(")"), poplex, maybeop);
372
+ if (type == "operator" || type == "spread") return cont(noComma ? expressionNoComma : expression);
373
+ if (type == "[") return cont(pushlex("]"), arrayLiteral, poplex, maybeop);
374
+ if (type == "{") return contCommasep(objprop, "}", null, maybeop);
375
+ if (type == "quasi") { return pass(quasi, maybeop); }
376
+ return cont();
377
+ }
378
+ function maybeexpression(type) {
379
+ if (type.match(/[;\}\)\],]/)) return pass();
380
+ return pass(expression);
381
+ }
382
+ function maybeexpressionNoComma(type) {
383
+ if (type.match(/[;\}\)\],]/)) return pass();
384
+ return pass(expressionNoComma);
385
+ }
386
+
387
+ function maybeoperatorComma(type, value) {
388
+ if (type == ",") return cont(expression);
389
+ return maybeoperatorNoComma(type, value, false);
390
+ }
391
+ function maybeoperatorNoComma(type, value, noComma) {
392
+ var me = noComma == false ? maybeoperatorComma : maybeoperatorNoComma;
393
+ var expr = noComma == false ? expression : expressionNoComma;
394
+ if (value == "=>") return cont(pushcontext, noComma ? arrowBodyNoComma : arrowBody, popcontext);
395
+ if (type == "operator") {
396
+ if (/\+\+|--/.test(value)) return cont(me);
397
+ if (value == "?") return cont(expression, expect(":"), expr);
398
+ return cont(expr);
399
+ }
400
+ if (type == "quasi") { return pass(quasi, me); }
401
+ if (type == ";") return;
402
+ if (type == "(") return contCommasep(expressionNoComma, ")", "call", me);
403
+ if (type == ".") return cont(property, me);
404
+ if (type == "[") return cont(pushlex("]"), maybeexpression, expect("]"), poplex, me);
405
+ }
406
+ function quasi(type, value) {
407
+ if (type != "quasi") return pass();
408
+ if (value.slice(value.length - 2) != "${") return cont(quasi);
409
+ return cont(expression, continueQuasi);
410
+ }
411
+ function continueQuasi(type) {
412
+ if (type == "}") {
413
+ cx.marked = "string-2";
414
+ cx.state.tokenize = tokenQuasi;
415
+ return cont(quasi);
416
+ }
417
+ }
418
+ function arrowBody(type) {
419
+ findFatArrow(cx.stream, cx.state);
420
+ if (type == "{") return pass(statement);
421
+ return pass(expression);
422
+ }
423
+ function arrowBodyNoComma(type) {
424
+ findFatArrow(cx.stream, cx.state);
425
+ if (type == "{") return pass(statement);
426
+ return pass(expressionNoComma);
427
+ }
428
+ function maybelabel(type) {
429
+ if (type == ":") return cont(poplex, statement);
430
+ return pass(maybeoperatorComma, expect(";"), poplex);
431
+ }
432
+ function property(type) {
433
+ if (type == "variable") {cx.marked = "property"; return cont();}
434
+ }
435
+ function objprop(type, value) {
436
+ if (type == "variable" || cx.style == "keyword") {
437
+ cx.marked = "property";
438
+ if (value == "get" || value == "set") return cont(getterSetter);
439
+ return cont(afterprop);
440
+ } else if (type == "number" || type == "string") {
441
+ cx.marked = jsonldMode ? "property" : (cx.style + " property");
442
+ return cont(afterprop);
443
+ } else if (type == "jsonld-keyword") {
444
+ return cont(afterprop);
445
+ } else if (type == "[") {
446
+ return cont(expression, expect("]"), afterprop);
447
+ }
448
+ }
449
+ function getterSetter(type) {
450
+ if (type != "variable") return pass(afterprop);
451
+ cx.marked = "property";
452
+ return cont(functiondef);
453
+ }
454
+ function afterprop(type) {
455
+ if (type == ":") return cont(expressionNoComma);
456
+ if (type == "(") return pass(functiondef);
457
+ }
458
+ function commasep(what, end) {
459
+ function proceed(type) {
460
+ if (type == ",") {
461
+ var lex = cx.state.lexical;
462
+ if (lex.info == "call") lex.pos = (lex.pos || 0) + 1;
463
+ return cont(what, proceed);
464
+ }
465
+ if (type == end) return cont();
466
+ return cont(expect(end));
467
+ }
468
+ return function(type) {
469
+ if (type == end) return cont();
470
+ return pass(what, proceed);
471
+ };
472
+ }
473
+ function contCommasep(what, end, info) {
474
+ for (var i = 3; i < arguments.length; i++)
475
+ cx.cc.push(arguments[i]);
476
+ return cont(pushlex(end, info), commasep(what, end), poplex);
477
+ }
478
+ function block(type) {
479
+ if (type == "}") return cont();
480
+ return pass(statement, block);
481
+ }
482
+ function maybetype(type) {
483
+ if (isTS && type == ":") return cont(typedef);
484
+ }
485
+ function typedef(type) {
486
+ if (type == "variable"){cx.marked = "variable-3"; return cont();}
487
+ }
488
+ function vardef() {
489
+ return pass(pattern, maybetype, maybeAssign, vardefCont);
490
+ }
491
+ function pattern(type, value) {
492
+ if (type == "variable") { register(value); return cont(); }
493
+ if (type == "[") return contCommasep(pattern, "]");
494
+ if (type == "{") return contCommasep(proppattern, "}");
495
+ }
496
+ function proppattern(type, value) {
497
+ if (type == "variable" && !cx.stream.match(/^\s*:/, false)) {
498
+ register(value);
499
+ return cont(maybeAssign);
500
+ }
501
+ if (type == "variable") cx.marked = "property";
502
+ return cont(expect(":"), pattern, maybeAssign);
503
+ }
504
+ function maybeAssign(_type, value) {
505
+ if (value == "=") return cont(expressionNoComma);
506
+ }
507
+ function vardefCont(type) {
508
+ if (type == ",") return cont(vardef);
509
+ }
510
+ function maybeelse(type, value) {
511
+ if (type == "keyword b" && value == "else") return cont(pushlex("form", "else"), statement, poplex);
512
+ }
513
+ function forspec(type) {
514
+ if (type == "(") return cont(pushlex(")"), forspec1, expect(")"), poplex);
515
+ }
516
+ function forspec1(type) {
517
+ if (type == "var") return cont(vardef, expect(";"), forspec2);
518
+ if (type == ";") return cont(forspec2);
519
+ if (type == "variable") return cont(formaybeinof);
520
+ return pass(expression, expect(";"), forspec2);
521
+ }
522
+ function formaybeinof(_type, value) {
523
+ if (value == "in" || value == "of") { cx.marked = "keyword"; return cont(expression); }
524
+ return cont(maybeoperatorComma, forspec2);
525
+ }
526
+ function forspec2(type, value) {
527
+ if (type == ";") return cont(forspec3);
528
+ if (value == "in" || value == "of") { cx.marked = "keyword"; return cont(expression); }
529
+ return pass(expression, expect(";"), forspec3);
530
+ }
531
+ function forspec3(type) {
532
+ if (type != ")") cont(expression);
533
+ }
534
+ function functiondef(type, value) {
535
+ if (value == "*") {cx.marked = "keyword"; return cont(functiondef);}
536
+ if (type == "variable") {register(value); return cont(functiondef);}
537
+ if (type == "(") return cont(pushcontext, pushlex(")"), commasep(funarg, ")"), poplex, statement, popcontext);
538
+ }
539
+ function funarg(type) {
540
+ if (type == "spread") return cont(funarg);
541
+ return pass(pattern, maybetype);
542
+ }
543
+ function className(type, value) {
544
+ if (type == "variable") {register(value); return cont(classNameAfter);}
545
+ }
546
+ function classNameAfter(type, value) {
547
+ if (value == "extends") return cont(expression, classNameAfter);
548
+ if (type == "{") return cont(pushlex("}"), classBody, poplex);
549
+ }
550
+ function classBody(type, value) {
551
+ if (type == "variable" || cx.style == "keyword") {
552
+ cx.marked = "property";
553
+ if (value == "get" || value == "set") return cont(classGetterSetter, functiondef, classBody);
554
+ return cont(functiondef, classBody);
555
+ }
556
+ if (value == "*") {
557
+ cx.marked = "keyword";
558
+ return cont(classBody);
559
+ }
560
+ if (type == ";") return cont(classBody);
561
+ if (type == "}") return cont();
562
+ }
563
+ function classGetterSetter(type) {
564
+ if (type != "variable") return pass();
565
+ cx.marked = "property";
566
+ return cont();
567
+ }
568
+ function afterModule(type, value) {
569
+ if (type == "string") return cont(statement);
570
+ if (type == "variable") { register(value); return cont(maybeFrom); }
571
+ }
572
+ function afterExport(_type, value) {
573
+ if (value == "*") { cx.marked = "keyword"; return cont(maybeFrom, expect(";")); }
574
+ if (value == "default") { cx.marked = "keyword"; return cont(expression, expect(";")); }
575
+ return pass(statement);
576
+ }
577
+ function afterImport(type) {
578
+ if (type == "string") return cont();
579
+ return pass(importSpec, maybeFrom);
580
+ }
581
+ function importSpec(type, value) {
582
+ if (type == "{") return contCommasep(importSpec, "}");
583
+ if (type == "variable") register(value);
584
+ return cont();
585
+ }
586
+ function maybeFrom(_type, value) {
587
+ if (value == "from") { cx.marked = "keyword"; return cont(expression); }
588
+ }
589
+ function arrayLiteral(type) {
590
+ if (type == "]") return cont();
591
+ return pass(expressionNoComma, maybeArrayComprehension);
592
+ }
593
+ function maybeArrayComprehension(type) {
594
+ if (type == "for") return pass(comprehension, expect("]"));
595
+ if (type == ",") return cont(commasep(expressionNoComma, "]"));
596
+ return pass(commasep(expressionNoComma, "]"));
597
+ }
598
+ function comprehension(type) {
599
+ if (type == "for") return cont(forspec, comprehension);
600
+ if (type == "if") return cont(expression, comprehension);
601
+ }
602
+
603
+ // Interface
604
+
605
+ return {
606
+ startState: function(basecolumn) {
607
+ var state = {
608
+ tokenize: tokenBase,
609
+ lastType: "sof",
610
+ cc: [],
611
+ lexical: new JSLexical((basecolumn || 0) - indentUnit, 0, "block", false),
612
+ localVars: parserConfig.localVars,
613
+ context: parserConfig.localVars && {vars: parserConfig.localVars},
614
+ indented: 0
615
+ };
616
+ if (parserConfig.globalVars && typeof parserConfig.globalVars == "object")
617
+ state.globalVars = parserConfig.globalVars;
618
+ return state;
619
+ },
620
+
621
+ token: function(stream, state) {
622
+ if (stream.sol()) {
623
+ if (!state.lexical.hasOwnProperty("align"))
624
+ state.lexical.align = false;
625
+ state.indented = stream.indentation();
626
+ findFatArrow(stream, state);
627
+ }
628
+ if (state.tokenize != tokenComment && stream.eatSpace()) return null;
629
+ var style = state.tokenize(stream, state);
630
+ if (type == "comment") return style;
631
+ state.lastType = type == "operator" && (content == "++" || content == "--") ? "incdec" : type;
632
+ return parseJS(state, style, type, content, stream);
633
+ },
634
+
635
+ indent: function(state, textAfter) {
636
+ if (state.tokenize == tokenComment) return CodeMirror.Pass;
637
+ if (state.tokenize != tokenBase) return 0;
638
+ var firstChar = textAfter && textAfter.charAt(0), lexical = state.lexical;
639
+ // Kludge to prevent 'maybelse' from blocking lexical scope pops
640
+ if (!/^\s*else\b/.test(textAfter)) for (var i = state.cc.length - 1; i >= 0; --i) {
641
+ var c = state.cc[i];
642
+ if (c == poplex) lexical = lexical.prev;
643
+ else if (c != maybeelse) break;
644
+ }
645
+ if (lexical.type == "stat" && firstChar == "}") lexical = lexical.prev;
646
+ if (statementIndent && lexical.type == ")" && lexical.prev.type == "stat")
647
+ lexical = lexical.prev;
648
+ var type = lexical.type, closing = firstChar == type;
649
+
650
+ if (type == "vardef") return lexical.indented + (state.lastType == "operator" || state.lastType == "," ? lexical.info + 1 : 0);
651
+ else if (type == "form" && firstChar == "{") return lexical.indented;
652
+ else if (type == "form") return lexical.indented + indentUnit;
653
+ else if (type == "stat")
654
+ return lexical.indented + (state.lastType == "operator" || state.lastType == "," ? statementIndent || indentUnit : 0);
655
+ else if (lexical.info == "switch" && !closing && parserConfig.doubleIndentSwitch != false)
656
+ return lexical.indented + (/^(?:case|default)\b/.test(textAfter) ? indentUnit : 2 * indentUnit);
657
+ else if (lexical.align) return lexical.column + (closing ? 0 : 1);
658
+ else return lexical.indented + (closing ? 0 : indentUnit);
659
+ },
660
+
661
+ electricChars: ":{}",
662
+ blockCommentStart: jsonMode ? null : "/*",
663
+ blockCommentEnd: jsonMode ? null : "*/",
664
+ lineComment: jsonMode ? null : "//",
665
+ fold: "brace",
666
+
667
+ helperType: jsonMode ? "json" : "javascript",
668
+ jsonldMode: jsonldMode,
669
+ jsonMode: jsonMode
670
+ };
671
+ });
672
+
673
+ CodeMirror.registerHelper("wordChars", "javascript", /[\w$]/);
674
+
675
+ CodeMirror.defineMIME("text/javascript", "javascript");
676
+ CodeMirror.defineMIME("text/ecmascript", "javascript");
677
+ CodeMirror.defineMIME("application/javascript", "javascript");
678
+ CodeMirror.defineMIME("application/x-javascript", "javascript");
679
+ CodeMirror.defineMIME("application/ecmascript", "javascript");
680
+ CodeMirror.defineMIME("application/json", {name: "javascript", json: true});
681
+ CodeMirror.defineMIME("application/x-json", {name: "javascript", json: true});
682
+ CodeMirror.defineMIME("application/ld+json", {name: "javascript", jsonld: true});
683
+ CodeMirror.defineMIME("text/typescript", { name: "javascript", typescript: true });
684
+ CodeMirror.defineMIME("application/typescript", { name: "javascript", typescript: true });
685
+
686
+ });