elabs 2.0.0.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (404) hide show
  1. checksums.yaml +7 -0
  2. data/.eslintrc.yml +26 -0
  3. data/.gitignore +49 -0
  4. data/.gitlab-ci.yml +93 -0
  5. data/.haml-lint.yml +4 -0
  6. data/.node-version +1 -0
  7. data/.rspec +1 -0
  8. data/.rubocop.yml +59 -0
  9. data/.ruby-version +1 -0
  10. data/.simplecov +5 -0
  11. data/.stylelintrc.yml +218 -0
  12. data/CHANGELOG.md +273 -0
  13. data/CODE_OF_CONDUCT.md +78 -0
  14. data/Gemfile +75 -0
  15. data/Gemfile.lock +376 -0
  16. data/LICENSE +21 -0
  17. data/LICENSES.md +6 -0
  18. data/README.md +41 -0
  19. data/ROADMAP.md +61 -0
  20. data/Rakefile +32 -0
  21. data/app/assets/config/elabs_manifest.js +3 -0
  22. data/app/assets/images/elabs/preview_placeholder.png +0 -0
  23. data/app/assets/images/elabs/preview_placeholder_nsfw.png +0 -0
  24. data/app/assets/javascripts/elabs/application.js +27 -0
  25. data/app/assets/javascripts/elabs/helpers-codemirror.js +29 -0
  26. data/app/assets/javascripts/elabs/helpers-markdown.js +42 -0
  27. data/app/assets/javascripts/elabs/helpers.js +17 -0
  28. data/app/assets/javascripts/elabs/modals.js +19 -0
  29. data/app/assets/javascripts/elabs/tabs.js +32 -0
  30. data/app/assets/stylesheets/elabs/_colors.scss +345 -0
  31. data/app/assets/stylesheets/elabs/_icons.scss +9 -0
  32. data/app/assets/stylesheets/elabs/_variables.scss +13 -0
  33. data/app/assets/stylesheets/elabs/app/_acts.scss +58 -0
  34. data/app/assets/stylesheets/elabs/app/_alerts.scss +3 -0
  35. data/app/assets/stylesheets/elabs/app/_buttons.scss +21 -0
  36. data/app/assets/stylesheets/elabs/app/_comments.scss +1 -0
  37. data/app/assets/stylesheets/elabs/app/_content.scss +10 -0
  38. data/app/assets/stylesheets/elabs/app/_content_uploads.scss +39 -0
  39. data/app/assets/stylesheets/elabs/app/_empty.scss +19 -0
  40. data/app/assets/stylesheets/elabs/app/_errors.scss +9 -0
  41. data/app/assets/stylesheets/elabs/app/_filter_links.scss +27 -0
  42. data/app/assets/stylesheets/elabs/app/_forms.scss +69 -0
  43. data/app/assets/stylesheets/elabs/app/_helpers.scss +3 -0
  44. data/app/assets/stylesheets/elabs/app/_languages.scss +6 -0
  45. data/app/assets/stylesheets/elabs/app/_layout.scss +194 -0
  46. data/app/assets/stylesheets/elabs/app/_licenses.scss +6 -0
  47. data/app/assets/stylesheets/elabs/app/_link-to-top.scss +8 -0
  48. data/app/assets/stylesheets/elabs/app/_medias.scss +12 -0
  49. data/app/assets/stylesheets/elabs/app/_modals.scss +53 -0
  50. data/app/assets/stylesheets/elabs/app/_nsfw.scss +5 -0
  51. data/app/assets/stylesheets/elabs/app/_pagination.scss +16 -0
  52. data/app/assets/stylesheets/elabs/app/_tabs.scss +54 -0
  53. data/app/assets/stylesheets/elabs/app/_tags.scss +6 -0
  54. data/app/assets/stylesheets/elabs/app/_toolbars.scss +3 -0
  55. data/app/assets/stylesheets/elabs/app/_users.scss +6 -0
  56. data/app/assets/stylesheets/elabs/app/admin-members/_forms.scss +6 -0
  57. data/app/assets/stylesheets/elabs/app/admin-members/_indexes.scss +70 -0
  58. data/app/assets/stylesheets/elabs/app/admin-members/_layout.scss +17 -0
  59. data/app/assets/stylesheets/elabs/app/areas/_devise.scss +31 -0
  60. data/app/assets/stylesheets/elabs/app/components/_cards.scss +16 -0
  61. data/app/assets/stylesheets/elabs/app/components/_container.scss +4 -0
  62. data/app/assets/stylesheets/elabs/app/mixins/_classifier-card.scss +16 -0
  63. data/app/assets/stylesheets/elabs/app/mixins/_content-card.scss +58 -0
  64. data/app/assets/stylesheets/elabs/app/mixins/_content-full.scss +39 -0
  65. data/app/assets/stylesheets/elabs/app/mixins/_icon.scss +9 -0
  66. data/app/assets/stylesheets/elabs/application.css +14 -0
  67. data/app/assets/stylesheets/elabs/lib/_codemirror.scss +26 -0
  68. data/app/assets/stylesheets/elabs/lib/fontawesome/_fontawesome.scss +38 -0
  69. data/app/assets/stylesheets/elabs/lib/fontawesome/_fonts.scss +42 -0
  70. data/app/assets/stylesheets/elabs/lib/fontawesome/_icons.scss +1118 -0
  71. data/app/assets/stylesheets/elabs/lib/knacss/_knacss-variables.scss +230 -0
  72. data/app/assets/stylesheets/elabs/lib/knacss/_knacss.scss +59 -0
  73. data/app/assets/stylesheets/elabs/style.scss +72 -0
  74. data/app/controllers/elabs/acts_controller.rb +12 -0
  75. data/app/controllers/elabs/admin/admin_application_controller.rb +19 -0
  76. data/app/controllers/elabs/admin/admin_content_application_controller.rb +66 -0
  77. data/app/controllers/elabs/admin/albums_controller.rb +10 -0
  78. data/app/controllers/elabs/admin/articles_controller.rb +10 -0
  79. data/app/controllers/elabs/admin/languages_controller.rb +77 -0
  80. data/app/controllers/elabs/admin/licenses_controller.rb +77 -0
  81. data/app/controllers/elabs/admin/notes_controller.rb +10 -0
  82. data/app/controllers/elabs/admin/projects_controller.rb +10 -0
  83. data/app/controllers/elabs/admin/reports_controller.rb +34 -0
  84. data/app/controllers/elabs/admin/tags_controller.rb +56 -0
  85. data/app/controllers/elabs/admin/uploads_controller.rb +10 -0
  86. data/app/controllers/elabs/admin/users_controller.rb +43 -0
  87. data/app/controllers/elabs/albums_controller.rb +26 -0
  88. data/app/controllers/elabs/articles_controller.rb +25 -0
  89. data/app/controllers/elabs/auth/callbacks_controller.rb +38 -0
  90. data/app/controllers/elabs/auth/confirmations_controller.rb +43 -0
  91. data/app/controllers/elabs/auth/passwords_controller.rb +47 -0
  92. data/app/controllers/elabs/auth/registrations_controller.rb +70 -0
  93. data/app/controllers/elabs/auth/sessions_controller.rb +36 -0
  94. data/app/controllers/elabs/auth/unlocks_controller.rb +38 -0
  95. data/app/controllers/elabs/concerns/elabs_controller.rb +18 -0
  96. data/app/controllers/elabs/concerns/localizable.rb +11 -0
  97. data/app/controllers/elabs/concerns/reportable.rb +17 -0
  98. data/app/controllers/elabs/content_application_controller.rb +45 -0
  99. data/app/controllers/elabs/elabs_application_controller.rb +95 -0
  100. data/app/controllers/elabs/languages_controller.rb +36 -0
  101. data/app/controllers/elabs/licenses_controller.rb +31 -0
  102. data/app/controllers/elabs/member/albums_controller.rb +11 -0
  103. data/app/controllers/elabs/member/articles_controller.rb +11 -0
  104. data/app/controllers/elabs/member/member_application_controller.rb +12 -0
  105. data/app/controllers/elabs/member/member_content_application_controller.rb +128 -0
  106. data/app/controllers/elabs/member/notes_controller.rb +11 -0
  107. data/app/controllers/elabs/member/preferences_controller.rb +36 -0
  108. data/app/controllers/elabs/member/projects_controller.rb +11 -0
  109. data/app/controllers/elabs/member/uploads_controller.rb +11 -0
  110. data/app/controllers/elabs/member/users_controller.rb +28 -0
  111. data/app/controllers/elabs/notes_controller.rb +25 -0
  112. data/app/controllers/elabs/projects_controller.rb +30 -0
  113. data/app/controllers/elabs/reports_controller.rb +36 -0
  114. data/app/controllers/elabs/tags_controller.rb +36 -0
  115. data/app/controllers/elabs/uploads_controller.rb +24 -0
  116. data/app/controllers/elabs/users_controller.rb +36 -0
  117. data/app/helpers/elabs/acts_helper.rb +22 -0
  118. data/app/helpers/elabs/admin_content_helper.rb +54 -0
  119. data/app/helpers/elabs/application_helper.rb +54 -0
  120. data/app/helpers/elabs/content_filters_helper.rb +97 -0
  121. data/app/helpers/elabs/content_renderer_helper.rb +13 -0
  122. data/app/helpers/elabs/member_content_helper.rb +47 -0
  123. data/app/helpers/elabs/thumbnails_helper.rb +28 -0
  124. data/app/helpers/elabs/time_helper.rb +19 -0
  125. data/app/helpers/elabs/uploads_helper.rb +19 -0
  126. data/app/jobs/elabs/application_job.rb +4 -0
  127. data/app/mailers/elabs/application_mailer.rb +6 -0
  128. data/app/models/elabs/act.rb +7 -0
  129. data/app/models/elabs/album.rb +24 -0
  130. data/app/models/elabs/albums_tag.rb +21 -0
  131. data/app/models/elabs/albums_upload.rb +21 -0
  132. data/app/models/elabs/application_content_record.rb +10 -0
  133. data/app/models/elabs/application_record.rb +5 -0
  134. data/app/models/elabs/article.rb +23 -0
  135. data/app/models/elabs/articles_tag.rb +21 -0
  136. data/app/models/elabs/comment.rb +12 -0
  137. data/app/models/elabs/concerns/actable_entity.rb +52 -0
  138. data/app/models/elabs/concerns/content_entity.rb +70 -0
  139. data/app/models/elabs/concerns/countable_entity.rb +81 -0
  140. data/app/models/elabs/concerns/taggable.rb +33 -0
  141. data/app/models/elabs/language.rb +17 -0
  142. data/app/models/elabs/license.rb +15 -0
  143. data/app/models/elabs/note.rb +21 -0
  144. data/app/models/elabs/notes_tag.rb +21 -0
  145. data/app/models/elabs/preference.rb +9 -0
  146. data/app/models/elabs/project.rb +25 -0
  147. data/app/models/elabs/projects_album.rb +21 -0
  148. data/app/models/elabs/projects_article.rb +21 -0
  149. data/app/models/elabs/projects_note.rb +21 -0
  150. data/app/models/elabs/projects_tag.rb +21 -0
  151. data/app/models/elabs/projects_upload.rb +21 -0
  152. data/app/models/elabs/report.rb +11 -0
  153. data/app/models/elabs/tag.rb +18 -0
  154. data/app/models/elabs/upload.rb +28 -0
  155. data/app/models/elabs/uploads_tag.rb +21 -0
  156. data/app/models/elabs/user.rb +30 -0
  157. data/app/validators/elabs/associated_author_validator.rb +11 -0
  158. data/app/views/elabs/acts/_act.json.jbuilder +2 -0
  159. data/app/views/elabs/acts/_filters.html.haml +3 -0
  160. data/app/views/elabs/acts/index.html.haml +27 -0
  161. data/app/views/elabs/acts/index.json.jbuilder +1 -0
  162. data/app/views/elabs/admin/albums/_album.json.jbuilder +2 -0
  163. data/app/views/elabs/admin/albums/index.html.haml +43 -0
  164. data/app/views/elabs/admin/albums/index.json.jbuilder +1 -0
  165. data/app/views/elabs/admin/articles/_article.json.jbuilder +2 -0
  166. data/app/views/elabs/admin/articles/index.html.haml +41 -0
  167. data/app/views/elabs/admin/articles/index.json.jbuilder +1 -0
  168. data/app/views/elabs/admin/languages/_form.html.haml +18 -0
  169. data/app/views/elabs/admin/languages/_language.json.jbuilder +2 -0
  170. data/app/views/elabs/admin/languages/edit.html.haml +6 -0
  171. data/app/views/elabs/admin/languages/index.html.haml +34 -0
  172. data/app/views/elabs/admin/languages/index.json.jbuilder +1 -0
  173. data/app/views/elabs/admin/languages/new.html.haml +3 -0
  174. data/app/views/elabs/admin/licenses/_form.html.haml +25 -0
  175. data/app/views/elabs/admin/licenses/_license.json.jbuilder +2 -0
  176. data/app/views/elabs/admin/licenses/edit.html.haml +6 -0
  177. data/app/views/elabs/admin/licenses/index.html.haml +42 -0
  178. data/app/views/elabs/admin/licenses/index.json.jbuilder +1 -0
  179. data/app/views/elabs/admin/licenses/new.html.haml +3 -0
  180. data/app/views/elabs/admin/notes/_note.json.jbuilder +2 -0
  181. data/app/views/elabs/admin/notes/index.html.haml +40 -0
  182. data/app/views/elabs/admin/notes/index.json.jbuilder +1 -0
  183. data/app/views/elabs/admin/projects/_project.json.jbuilder +2 -0
  184. data/app/views/elabs/admin/projects/index.html.haml +45 -0
  185. data/app/views/elabs/admin/projects/index.json.jbuilder +1 -0
  186. data/app/views/elabs/admin/reports/index.html.haml +27 -0
  187. data/app/views/elabs/admin/reports/index.json.jbuilder +1 -0
  188. data/app/views/elabs/admin/tags/_form.html.haml +17 -0
  189. data/app/views/elabs/admin/tags/_tag.json.jbuilder +2 -0
  190. data/app/views/elabs/admin/tags/edit.html.haml +6 -0
  191. data/app/views/elabs/admin/tags/index.html.haml +27 -0
  192. data/app/views/elabs/admin/tags/index.json.jbuilder +1 -0
  193. data/app/views/elabs/admin/uploads/_upload.json.jbuilder +2 -0
  194. data/app/views/elabs/admin/uploads/index.html.haml +45 -0
  195. data/app/views/elabs/admin/uploads/index.json.jbuilder +1 -0
  196. data/app/views/elabs/admin/users/_admin_user.json.jbuilder +2 -0
  197. data/app/views/elabs/admin/users/index.html.haml +33 -0
  198. data/app/views/elabs/admin/users/index.json.jbuilder +1 -0
  199. data/app/views/elabs/admin/users/show.html.haml +26 -0
  200. data/app/views/elabs/admin/users/show.json.jbuilder +1 -0
  201. data/app/views/elabs/albums/_album.html.haml +38 -0
  202. data/app/views/elabs/albums/_album.json.jbuilder +2 -0
  203. data/app/views/elabs/albums/_filters.html.haml +8 -0
  204. data/app/views/elabs/albums/index.html.haml +9 -0
  205. data/app/views/elabs/albums/index.json.jbuilder +1 -0
  206. data/app/views/elabs/albums/show.html.haml +60 -0
  207. data/app/views/elabs/albums/show.json.jbuilder +1 -0
  208. data/app/views/elabs/articles/_article.html.haml +30 -0
  209. data/app/views/elabs/articles/_article.json.jbuilder +2 -0
  210. data/app/views/elabs/articles/_filters.html.haml +8 -0
  211. data/app/views/elabs/articles/index.html.haml +9 -0
  212. data/app/views/elabs/articles/index.json.jbuilder +1 -0
  213. data/app/views/elabs/articles/show.html.haml +45 -0
  214. data/app/views/elabs/articles/show.json.jbuilder +1 -0
  215. data/app/views/elabs/auth/confirmations/new.html.haml +26 -0
  216. data/app/views/elabs/auth/passwords/edit.html.haml +31 -0
  217. data/app/views/elabs/auth/passwords/new.html.haml +23 -0
  218. data/app/views/elabs/auth/registrations/edit.html.haml +48 -0
  219. data/app/views/elabs/auth/registrations/new.html.haml +34 -0
  220. data/app/views/elabs/auth/sessions/_new.html.haml +15 -0
  221. data/app/views/elabs/auth/sessions/new.html.haml +8 -0
  222. data/app/views/elabs/auth/shared/_links.html.haml +16 -0
  223. data/app/views/elabs/auth/unlocks/new.html.haml +23 -0
  224. data/app/views/elabs/comments/_comment.json.jbuilder +2 -0
  225. data/app/views/elabs/comments/_comments.html.haml +21 -0
  226. data/app/views/elabs/comments/_form.html.haml +31 -0
  227. data/app/views/elabs/languages/_associations.html.haml +51 -0
  228. data/app/views/elabs/languages/_filters.html.haml +6 -0
  229. data/app/views/elabs/languages/_language.json.jbuilder +2 -0
  230. data/app/views/elabs/languages/index.html.haml +33 -0
  231. data/app/views/elabs/languages/index.json.jbuilder +1 -0
  232. data/app/views/elabs/languages/show.html.haml +38 -0
  233. data/app/views/elabs/languages/show.json.jbuilder +1 -0
  234. data/app/views/elabs/layouts/_empty.html.haml +3 -0
  235. data/app/views/elabs/layouts/_footer.html.haml +6 -0
  236. data/app/views/elabs/layouts/_hidden_entry.html.haml +6 -0
  237. data/app/views/elabs/layouts/_hidden_entry_full.html.haml +6 -0
  238. data/app/views/elabs/layouts/_language_menu.html.haml +2 -0
  239. data/app/views/elabs/layouts/_menu.html.haml +72 -0
  240. data/app/views/elabs/layouts/admin_application.html.haml +21 -0
  241. data/app/views/elabs/layouts/application.html.haml +37 -0
  242. data/app/views/elabs/layouts/lists/_albums.html.haml +10 -0
  243. data/app/views/elabs/layouts/lists/_projects.html.haml +10 -0
  244. data/app/views/elabs/layouts/lists/_tags.html.haml +9 -0
  245. data/app/views/elabs/layouts/mailer.html.haml +8 -0
  246. data/app/views/elabs/layouts/mailer.text.haml +1 -0
  247. data/app/views/elabs/layouts/member_application.html.haml +21 -0
  248. data/app/views/elabs/licenses/_associations.html.haml +51 -0
  249. data/app/views/elabs/licenses/_filters.html.haml +3 -0
  250. data/app/views/elabs/licenses/_license.json.jbuilder +2 -0
  251. data/app/views/elabs/licenses/index.html.haml +27 -0
  252. data/app/views/elabs/licenses/index.json.jbuilder +1 -0
  253. data/app/views/elabs/licenses/show.html.haml +44 -0
  254. data/app/views/elabs/licenses/show.json.jbuilder +1 -0
  255. data/app/views/elabs/member/albums/_album.json.jbuilder +2 -0
  256. data/app/views/elabs/member/albums/_form.html.haml +64 -0
  257. data/app/views/elabs/member/albums/edit.html.haml +6 -0
  258. data/app/views/elabs/member/albums/index.html.haml +49 -0
  259. data/app/views/elabs/member/albums/index.json.jbuilder +1 -0
  260. data/app/views/elabs/member/albums/new.html.haml +3 -0
  261. data/app/views/elabs/member/articles/_article.json.jbuilder +2 -0
  262. data/app/views/elabs/member/articles/_form.html.haml +70 -0
  263. data/app/views/elabs/member/articles/edit.html.haml +6 -0
  264. data/app/views/elabs/member/articles/index.html.haml +47 -0
  265. data/app/views/elabs/member/articles/index.json.jbuilder +1 -0
  266. data/app/views/elabs/member/articles/new.html.haml +3 -0
  267. data/app/views/elabs/member/layouts/_empty.html.haml +4 -0
  268. data/app/views/elabs/member/layouts/_markdown-preview.html.haml +8 -0
  269. data/app/views/elabs/member/notes/_form.html.haml +54 -0
  270. data/app/views/elabs/member/notes/_note.json.jbuilder +2 -0
  271. data/app/views/elabs/member/notes/edit.html.haml +6 -0
  272. data/app/views/elabs/member/notes/index.html.haml +47 -0
  273. data/app/views/elabs/member/notes/index.json.jbuilder +1 -0
  274. data/app/views/elabs/member/notes/new.html.haml +3 -0
  275. data/app/views/elabs/member/preferences/_form.html.haml +20 -0
  276. data/app/views/elabs/member/preferences/edit.html.haml +3 -0
  277. data/app/views/elabs/member/projects/_form.html.haml +71 -0
  278. data/app/views/elabs/member/projects/_project.json.jbuilder +2 -0
  279. data/app/views/elabs/member/projects/edit.html.haml +6 -0
  280. data/app/views/elabs/member/projects/index.html.haml +53 -0
  281. data/app/views/elabs/member/projects/index.json.jbuilder +1 -0
  282. data/app/views/elabs/member/projects/new.html.haml +3 -0
  283. data/app/views/elabs/member/uploads/_form.html.haml +67 -0
  284. data/app/views/elabs/member/uploads/_upload.json.jbuilder +2 -0
  285. data/app/views/elabs/member/uploads/edit.html.haml +6 -0
  286. data/app/views/elabs/member/uploads/index.html.haml +61 -0
  287. data/app/views/elabs/member/uploads/index.json.jbuilder +1 -0
  288. data/app/views/elabs/member/uploads/new.html.haml +3 -0
  289. data/app/views/elabs/member/users/_form.html.haml +38 -0
  290. data/app/views/elabs/notes/_filters.html.haml +7 -0
  291. data/app/views/elabs/notes/_note.html.haml +31 -0
  292. data/app/views/elabs/notes/_note.json.jbuilder +2 -0
  293. data/app/views/elabs/notes/index.html.haml +9 -0
  294. data/app/views/elabs/notes/index.json.jbuilder +1 -0
  295. data/app/views/elabs/notes/show.html.haml +44 -0
  296. data/app/views/elabs/notes/show.json.jbuilder +1 -0
  297. data/app/views/elabs/projects/_associations.html.haml +46 -0
  298. data/app/views/elabs/projects/_filters.html.haml +8 -0
  299. data/app/views/elabs/projects/_project.html.haml +29 -0
  300. data/app/views/elabs/projects/index.html.haml +9 -0
  301. data/app/views/elabs/projects/index.json.jbuilder +1 -0
  302. data/app/views/elabs/projects/show.html.haml +71 -0
  303. data/app/views/elabs/projects/show.json.jbuilder +1 -0
  304. data/app/views/elabs/reports/_form.html.haml +29 -0
  305. data/app/views/elabs/tags/_associations.html.haml +51 -0
  306. data/app/views/elabs/tags/_filters.html.haml +3 -0
  307. data/app/views/elabs/tags/_tag.json.jbuilder +2 -0
  308. data/app/views/elabs/tags/index.html.haml +26 -0
  309. data/app/views/elabs/tags/index.json.jbuilder +1 -0
  310. data/app/views/elabs/tags/show.html.haml +34 -0
  311. data/app/views/elabs/tags/show.json.jbuilder +1 -0
  312. data/app/views/elabs/uploads/_filters.html.haml +7 -0
  313. data/app/views/elabs/uploads/_player.html.haml +10 -0
  314. data/app/views/elabs/uploads/_preview.html.haml +17 -0
  315. data/app/views/elabs/uploads/_upload.html.haml +41 -0
  316. data/app/views/elabs/uploads/_upload.json.jbuilder +2 -0
  317. data/app/views/elabs/uploads/index.html.haml +9 -0
  318. data/app/views/elabs/uploads/index.json.jbuilder +1 -0
  319. data/app/views/elabs/uploads/show.html.haml +58 -0
  320. data/app/views/elabs/uploads/show.json.jbuilder +1 -0
  321. data/app/views/elabs/users/_associations.html.haml +51 -0
  322. data/app/views/elabs/users/_filters.html.haml +4 -0
  323. data/app/views/elabs/users/_user.html.haml +31 -0
  324. data/app/views/elabs/users/_user.json.jbuilder +2 -0
  325. data/app/views/elabs/users/index.html.haml +7 -0
  326. data/app/views/elabs/users/index.json.jbuilder +1 -0
  327. data/app/views/elabs/users/show.html.haml +48 -0
  328. data/app/views/elabs/users/show.json.jbuilder +1 -0
  329. data/bin/rails +14 -0
  330. data/config.ru +5 -0
  331. data/config/brakeman.ignore +124 -0
  332. data/config/brakeman.yml +3 -0
  333. data/config/cucumber.yml +9 -0
  334. data/config/routes.rb +116 -0
  335. data/db/migrate/20180813000000_devise_update_users.rb +15 -0
  336. data/db/migrate/20180813000001_create_languages.rb +16 -0
  337. data/db/migrate/20180813000002_create_tags.rb +14 -0
  338. data/db/migrate/20180813000004_create_licenses.rb +17 -0
  339. data/db/migrate/20180813000005_create_reports.rb +15 -0
  340. data/db/migrate/20180813000006_create_comments.rb +15 -0
  341. data/db/migrate/20180813000007_create_acts.rb +10 -0
  342. data/db/migrate/20180813000008_create_preferences.rb +13 -0
  343. data/db/migrate/20180813000009_create_active_storage_tables.active_storage.rb +26 -0
  344. data/db/migrate/20180813000010_create_albums.rb +23 -0
  345. data/db/migrate/20180813000011_create_articles.rb +23 -0
  346. data/db/migrate/20180813000012_create_notes.rb +21 -0
  347. data/db/migrate/20180813000013_create_uploads.rb +26 -0
  348. data/db/migrate/20180813000014_create_projects.rb +44 -0
  349. data/db/seeds.rb +10 -0
  350. data/db/seeds_development.rb +21 -0
  351. data/db/seeds_production.rb +0 -0
  352. data/docs/contributing.md +52 -0
  353. data/docs/cucumber_terms.md +9 -0
  354. data/docs/migrating.md +4 -0
  355. data/docs/overriding.md +20 -0
  356. data/docs/setup.md +136 -0
  357. data/docs/tips.md +13 -0
  358. data/elabs.gemspec +25 -0
  359. data/lib/assets/javascripts/README-highlight.js.md +39 -0
  360. data/lib/assets/javascripts/codemirror-5.39.2/addon/mode/overlay.js +90 -0
  361. data/lib/assets/javascripts/codemirror-5.39.2/lib/codemirror.js +9684 -0
  362. data/lib/assets/javascripts/codemirror-5.39.2/mode/clike/clike.js +834 -0
  363. data/lib/assets/javascripts/codemirror-5.39.2/mode/css/css.js +832 -0
  364. data/lib/assets/javascripts/codemirror-5.39.2/mode/gfm/gfm.js +129 -0
  365. data/lib/assets/javascripts/codemirror-5.39.2/mode/htmlmixed/htmlmixed.js +152 -0
  366. data/lib/assets/javascripts/codemirror-5.39.2/mode/javascript/javascript.js +896 -0
  367. data/lib/assets/javascripts/codemirror-5.39.2/mode/markdown/markdown.js +882 -0
  368. data/lib/assets/javascripts/codemirror-5.39.2/mode/meta.js +217 -0
  369. data/lib/assets/javascripts/codemirror-5.39.2/mode/xml/xml.js +402 -0
  370. data/lib/assets/javascripts/highlight.js-9.12.0/highlight.pack.js +2 -0
  371. data/lib/assets/javascripts/markdown-it-8.4.2.min.js +1 -0
  372. data/lib/assets/stylesheets/codemirror-5.39.2/lib/codemirror.css +346 -0
  373. data/lib/assets/stylesheets/codemirror-5.39.2/theme/base16-dark.css +38 -0
  374. data/lib/assets/stylesheets/codemirror-5.39.2/theme/base16-light.css +38 -0
  375. data/lib/assets/stylesheets/highlight.js-9.12.0/styles/atelier-sulphurpool-light.css +69 -0
  376. data/lib/elabs.rb +41 -0
  377. data/lib/elabs/engine.rb +5 -0
  378. data/lib/elabs/version.rb +3 -0
  379. data/lib/generators/elabs/assets_generator.rb +36 -0
  380. data/lib/generators/elabs/devise_views_generator.rb +24 -0
  381. data/lib/generators/elabs/install_generator.rb +26 -0
  382. data/lib/generators/elabs/required_assets_generator.rb +26 -0
  383. data/lib/generators/elabs/views_generator.rb +25 -0
  384. data/lib/generators/templates/elabs.rb +25 -0
  385. data/lib/generators/templates/fast_gettext.rb +3 -0
  386. data/lib/tasks/.keep +0 -0
  387. data/lib/tasks/cucumber.rake +75 -0
  388. data/lib/tasks/elabs_tasks.rake +4 -0
  389. data/lib/tasks/factory_bot.rake +14 -0
  390. data/lib/tasks/wipe.rake +31 -0
  391. data/locale/app.pot +1124 -0
  392. data/locale/devise_strings.rb +88 -0
  393. data/locale/en/app.edit.po +1123 -0
  394. data/locale/en/app.po +1123 -0
  395. data/locale/en/app.po.time_stamp +0 -0
  396. data/locale/fr/app.edit.po +1126 -0
  397. data/locale/fr/app.po +1125 -0
  398. data/locale/fr/app.po.time_stamp +0 -0
  399. data/locale/model_attributes.rb +85 -0
  400. data/package.json +22 -0
  401. data/script/cucumber +10 -0
  402. data/tmp/pids/.keep +0 -0
  403. data/yarn.lock +2759 -0
  404. metadata +463 -0
@@ -0,0 +1,129 @@
1
+ // CodeMirror, copyright (c) by Marijn Haverbeke and others
2
+ // Distributed under an MIT license: http://codemirror.net/LICENSE
3
+
4
+ (function(mod) {
5
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
6
+ mod(require("../../lib/codemirror"), require("../markdown/markdown"), require("../../addon/mode/overlay"));
7
+ else if (typeof define == "function" && define.amd) // AMD
8
+ define(["../../lib/codemirror", "../markdown/markdown", "../../addon/mode/overlay"], mod);
9
+ else // Plain browser env
10
+ mod(CodeMirror);
11
+ })(function(CodeMirror) {
12
+ "use strict";
13
+
14
+ var urlRE = /^((?:(?:aaas?|about|acap|adiumxtra|af[ps]|aim|apt|attachment|aw|beshare|bitcoin|bolo|callto|cap|chrome(?:-extension)?|cid|coap|com-eventbrite-attendee|content|crid|cvs|data|dav|dict|dlna-(?:playcontainer|playsingle)|dns|doi|dtn|dvb|ed2k|facetime|feed|file|finger|fish|ftp|geo|gg|git|gizmoproject|go|gopher|gtalk|h323|hcp|https?|iax|icap|icon|im|imap|info|ipn|ipp|irc[6s]?|iris(?:\.beep|\.lwz|\.xpc|\.xpcs)?|itms|jar|javascript|jms|keyparc|lastfm|ldaps?|magnet|mailto|maps|market|message|mid|mms|ms-help|msnim|msrps?|mtqp|mumble|mupdate|mvn|news|nfs|nih?|nntp|notes|oid|opaquelocktoken|palm|paparazzi|platform|pop|pres|proxy|psyc|query|res(?:ource)?|rmi|rsync|rtmp|rtsp|secondlife|service|session|sftp|sgn|shttp|sieve|sips?|skype|sm[bs]|snmp|soap\.beeps?|soldat|spotify|ssh|steam|svn|tag|teamspeak|tel(?:net)?|tftp|things|thismessage|tip|tn3270|tv|udp|unreal|urn|ut2004|vemmi|ventrilo|view-source|webcal|wss?|wtai|wyciwyg|xcon(?:-userid)?|xfire|xmlrpc\.beeps?|xmpp|xri|ymsgr|z39\.50[rs]?):(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]|\([^\s()<>]*\))+(?:\([^\s()<>]*\)|[^\s`*!()\[\]{};:'".,<>?«»“”‘’]))/i
15
+
16
+ CodeMirror.defineMode("gfm", function(config, modeConfig) {
17
+ var codeDepth = 0;
18
+ function blankLine(state) {
19
+ state.code = false;
20
+ return null;
21
+ }
22
+ var gfmOverlay = {
23
+ startState: function() {
24
+ return {
25
+ code: false,
26
+ codeBlock: false,
27
+ ateSpace: false
28
+ };
29
+ },
30
+ copyState: function(s) {
31
+ return {
32
+ code: s.code,
33
+ codeBlock: s.codeBlock,
34
+ ateSpace: s.ateSpace
35
+ };
36
+ },
37
+ token: function(stream, state) {
38
+ state.combineTokens = null;
39
+
40
+ // Hack to prevent formatting override inside code blocks (block and inline)
41
+ if (state.codeBlock) {
42
+ if (stream.match(/^```+/)) {
43
+ state.codeBlock = false;
44
+ return null;
45
+ }
46
+ stream.skipToEnd();
47
+ return null;
48
+ }
49
+ if (stream.sol()) {
50
+ state.code = false;
51
+ }
52
+ if (stream.sol() && stream.match(/^```+/)) {
53
+ stream.skipToEnd();
54
+ state.codeBlock = true;
55
+ return null;
56
+ }
57
+ // If this block is changed, it may need to be updated in Markdown mode
58
+ if (stream.peek() === '`') {
59
+ stream.next();
60
+ var before = stream.pos;
61
+ stream.eatWhile('`');
62
+ var difference = 1 + stream.pos - before;
63
+ if (!state.code) {
64
+ codeDepth = difference;
65
+ state.code = true;
66
+ } else {
67
+ if (difference === codeDepth) { // Must be exact
68
+ state.code = false;
69
+ }
70
+ }
71
+ return null;
72
+ } else if (state.code) {
73
+ stream.next();
74
+ return null;
75
+ }
76
+ // Check if space. If so, links can be formatted later on
77
+ if (stream.eatSpace()) {
78
+ state.ateSpace = true;
79
+ return null;
80
+ }
81
+ if (stream.sol() || state.ateSpace) {
82
+ state.ateSpace = false;
83
+ if (modeConfig.gitHubSpice !== false) {
84
+ if(stream.match(/^(?:[a-zA-Z0-9\-_]+\/)?(?:[a-zA-Z0-9\-_]+@)?(?=.{0,6}\d)(?:[a-f0-9]{7,40}\b)/)) {
85
+ // User/Project@SHA
86
+ // User@SHA
87
+ // SHA
88
+ state.combineTokens = true;
89
+ return "link";
90
+ } else if (stream.match(/^(?:[a-zA-Z0-9\-_]+\/)?(?:[a-zA-Z0-9\-_]+)?#[0-9]+\b/)) {
91
+ // User/Project#Num
92
+ // User#Num
93
+ // #Num
94
+ state.combineTokens = true;
95
+ return "link";
96
+ }
97
+ }
98
+ }
99
+ if (stream.match(urlRE) &&
100
+ stream.string.slice(stream.start - 2, stream.start) != "](" &&
101
+ (stream.start == 0 || /\W/.test(stream.string.charAt(stream.start - 1)))) {
102
+ // URLs
103
+ // Taken from http://daringfireball.net/2010/07/improved_regex_for_matching_urls
104
+ // And then (issue #1160) simplified to make it not crash the Chrome Regexp engine
105
+ // And then limited url schemes to the CommonMark list, so foo:bar isn't matched as a URL
106
+ state.combineTokens = true;
107
+ return "link";
108
+ }
109
+ stream.next();
110
+ return null;
111
+ },
112
+ blankLine: blankLine
113
+ };
114
+
115
+ var markdownConfig = {
116
+ taskLists: true,
117
+ strikethrough: true,
118
+ emoji: true
119
+ };
120
+ for (var attr in modeConfig) {
121
+ markdownConfig[attr] = modeConfig[attr];
122
+ }
123
+ markdownConfig.name = "markdown";
124
+ return CodeMirror.overlayMode(CodeMirror.getMode(config, markdownConfig), gfmOverlay);
125
+
126
+ }, "markdown");
127
+
128
+ CodeMirror.defineMIME("text/x-gfm", "gfm");
129
+ });
@@ -0,0 +1,152 @@
1
+ // CodeMirror, copyright (c) by Marijn Haverbeke and others
2
+ // Distributed under an MIT license: http://codemirror.net/LICENSE
3
+
4
+ (function(mod) {
5
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
6
+ mod(require("../../lib/codemirror"), require("../xml/xml"), require("../javascript/javascript"), require("../css/css"));
7
+ else if (typeof define == "function" && define.amd) // AMD
8
+ define(["../../lib/codemirror", "../xml/xml", "../javascript/javascript", "../css/css"], mod);
9
+ else // Plain browser env
10
+ mod(CodeMirror);
11
+ })(function(CodeMirror) {
12
+ "use strict";
13
+
14
+ var defaultTags = {
15
+ script: [
16
+ ["lang", /(javascript|babel)/i, "javascript"],
17
+ ["type", /^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^module$|^$/i, "javascript"],
18
+ ["type", /./, "text/plain"],
19
+ [null, null, "javascript"]
20
+ ],
21
+ style: [
22
+ ["lang", /^css$/i, "css"],
23
+ ["type", /^(text\/)?(x-)?(stylesheet|css)$/i, "css"],
24
+ ["type", /./, "text/plain"],
25
+ [null, null, "css"]
26
+ ]
27
+ };
28
+
29
+ function maybeBackup(stream, pat, style) {
30
+ var cur = stream.current(), close = cur.search(pat);
31
+ if (close > -1) {
32
+ stream.backUp(cur.length - close);
33
+ } else if (cur.match(/<\/?$/)) {
34
+ stream.backUp(cur.length);
35
+ if (!stream.match(pat, false)) stream.match(cur);
36
+ }
37
+ return style;
38
+ }
39
+
40
+ var attrRegexpCache = {};
41
+ function getAttrRegexp(attr) {
42
+ var regexp = attrRegexpCache[attr];
43
+ if (regexp) return regexp;
44
+ return attrRegexpCache[attr] = new RegExp("\\s+" + attr + "\\s*=\\s*('|\")?([^'\"]+)('|\")?\\s*");
45
+ }
46
+
47
+ function getAttrValue(text, attr) {
48
+ var match = text.match(getAttrRegexp(attr))
49
+ return match ? /^\s*(.*?)\s*$/.exec(match[2])[1] : ""
50
+ }
51
+
52
+ function getTagRegexp(tagName, anchored) {
53
+ return new RegExp((anchored ? "^" : "") + "<\/\s*" + tagName + "\s*>", "i");
54
+ }
55
+
56
+ function addTags(from, to) {
57
+ for (var tag in from) {
58
+ var dest = to[tag] || (to[tag] = []);
59
+ var source = from[tag];
60
+ for (var i = source.length - 1; i >= 0; i--)
61
+ dest.unshift(source[i])
62
+ }
63
+ }
64
+
65
+ function findMatchingMode(tagInfo, tagText) {
66
+ for (var i = 0; i < tagInfo.length; i++) {
67
+ var spec = tagInfo[i];
68
+ if (!spec[0] || spec[1].test(getAttrValue(tagText, spec[0]))) return spec[2];
69
+ }
70
+ }
71
+
72
+ CodeMirror.defineMode("htmlmixed", function (config, parserConfig) {
73
+ var htmlMode = CodeMirror.getMode(config, {
74
+ name: "xml",
75
+ htmlMode: true,
76
+ multilineTagIndentFactor: parserConfig.multilineTagIndentFactor,
77
+ multilineTagIndentPastTag: parserConfig.multilineTagIndentPastTag
78
+ });
79
+
80
+ var tags = {};
81
+ var configTags = parserConfig && parserConfig.tags, configScript = parserConfig && parserConfig.scriptTypes;
82
+ addTags(defaultTags, tags);
83
+ if (configTags) addTags(configTags, tags);
84
+ if (configScript) for (var i = configScript.length - 1; i >= 0; i--)
85
+ tags.script.unshift(["type", configScript[i].matches, configScript[i].mode])
86
+
87
+ function html(stream, state) {
88
+ var style = htmlMode.token(stream, state.htmlState), tag = /\btag\b/.test(style), tagName
89
+ if (tag && !/[<>\s\/]/.test(stream.current()) &&
90
+ (tagName = state.htmlState.tagName && state.htmlState.tagName.toLowerCase()) &&
91
+ tags.hasOwnProperty(tagName)) {
92
+ state.inTag = tagName + " "
93
+ } else if (state.inTag && tag && />$/.test(stream.current())) {
94
+ var inTag = /^([\S]+) (.*)/.exec(state.inTag)
95
+ state.inTag = null
96
+ var modeSpec = stream.current() == ">" && findMatchingMode(tags[inTag[1]], inTag[2])
97
+ var mode = CodeMirror.getMode(config, modeSpec)
98
+ var endTagA = getTagRegexp(inTag[1], true), endTag = getTagRegexp(inTag[1], false);
99
+ state.token = function (stream, state) {
100
+ if (stream.match(endTagA, false)) {
101
+ state.token = html;
102
+ state.localState = state.localMode = null;
103
+ return null;
104
+ }
105
+ return maybeBackup(stream, endTag, state.localMode.token(stream, state.localState));
106
+ };
107
+ state.localMode = mode;
108
+ state.localState = CodeMirror.startState(mode, htmlMode.indent(state.htmlState, ""));
109
+ } else if (state.inTag) {
110
+ state.inTag += stream.current()
111
+ if (stream.eol()) state.inTag += " "
112
+ }
113
+ return style;
114
+ };
115
+
116
+ return {
117
+ startState: function () {
118
+ var state = CodeMirror.startState(htmlMode);
119
+ return {token: html, inTag: null, localMode: null, localState: null, htmlState: state};
120
+ },
121
+
122
+ copyState: function (state) {
123
+ var local;
124
+ if (state.localState) {
125
+ local = CodeMirror.copyState(state.localMode, state.localState);
126
+ }
127
+ return {token: state.token, inTag: state.inTag,
128
+ localMode: state.localMode, localState: local,
129
+ htmlState: CodeMirror.copyState(htmlMode, state.htmlState)};
130
+ },
131
+
132
+ token: function (stream, state) {
133
+ return state.token(stream, state);
134
+ },
135
+
136
+ indent: function (state, textAfter, line) {
137
+ if (!state.localMode || /^\s*<\//.test(textAfter))
138
+ return htmlMode.indent(state.htmlState, textAfter);
139
+ else if (state.localMode.indent)
140
+ return state.localMode.indent(state.localState, textAfter, line);
141
+ else
142
+ return CodeMirror.Pass;
143
+ },
144
+
145
+ innerMode: function (state) {
146
+ return {state: state.localState || state.htmlState, mode: state.localMode || htmlMode};
147
+ }
148
+ };
149
+ }, "xml", "javascript", "css");
150
+
151
+ CodeMirror.defineMIME("text/html", "htmlmixed");
152
+ });
@@ -0,0 +1,896 @@
1
+ // CodeMirror, copyright (c) by Marijn Haverbeke and others
2
+ // Distributed under an MIT license: http://codemirror.net/LICENSE
3
+
4
+ (function(mod) {
5
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
6
+ mod(require("../../lib/codemirror"));
7
+ else if (typeof define == "function" && define.amd) // AMD
8
+ define(["../../lib/codemirror"], mod);
9
+ else // Plain browser env
10
+ mod(CodeMirror);
11
+ })(function(CodeMirror) {
12
+ "use strict";
13
+
14
+ CodeMirror.defineMode("javascript", function(config, parserConfig) {
15
+ var indentUnit = config.indentUnit;
16
+ var statementIndent = parserConfig.statementIndent;
17
+ var jsonldMode = parserConfig.jsonld;
18
+ var jsonMode = parserConfig.json || jsonldMode;
19
+ var isTS = parserConfig.typescript;
20
+ var wordRE = parserConfig.wordCharacters || /[\w$\xa1-\uffff]/;
21
+
22
+ // Tokenizer
23
+
24
+ var keywords = function(){
25
+ function kw(type) {return {type: type, style: "keyword"};}
26
+ var A = kw("keyword a"), B = kw("keyword b"), C = kw("keyword c"), D = kw("keyword d");
27
+ var operator = kw("operator"), atom = {type: "atom", style: "atom"};
28
+
29
+ return {
30
+ "if": kw("if"), "while": A, "with": A, "else": B, "do": B, "try": B, "finally": B,
31
+ "return": D, "break": D, "continue": D, "new": kw("new"), "delete": C, "void": C, "throw": C,
32
+ "debugger": kw("debugger"), "var": kw("var"), "const": kw("var"), "let": kw("var"),
33
+ "function": kw("function"), "catch": kw("catch"),
34
+ "for": kw("for"), "switch": kw("switch"), "case": kw("case"), "default": kw("default"),
35
+ "in": operator, "typeof": operator, "instanceof": operator,
36
+ "true": atom, "false": atom, "null": atom, "undefined": atom, "NaN": atom, "Infinity": atom,
37
+ "this": kw("this"), "class": kw("class"), "super": kw("atom"),
38
+ "yield": C, "export": kw("export"), "import": kw("import"), "extends": C,
39
+ "await": C
40
+ };
41
+ }();
42
+
43
+ var isOperatorChar = /[+\-*&%=<>!?|~^@]/;
44
+ var isJsonldKeyword = /^@(context|id|value|language|type|container|list|set|reverse|index|base|vocab|graph)"/;
45
+
46
+ function readRegexp(stream) {
47
+ var escaped = false, next, inSet = false;
48
+ while ((next = stream.next()) != null) {
49
+ if (!escaped) {
50
+ if (next == "/" && !inSet) return;
51
+ if (next == "[") inSet = true;
52
+ else if (inSet && next == "]") inSet = false;
53
+ }
54
+ escaped = !escaped && next == "\\";
55
+ }
56
+ }
57
+
58
+ // Used as scratch variables to communicate multiple values without
59
+ // consing up tons of objects.
60
+ var type, content;
61
+ function ret(tp, style, cont) {
62
+ type = tp; content = cont;
63
+ return style;
64
+ }
65
+ function tokenBase(stream, state) {
66
+ var ch = stream.next();
67
+ if (ch == '"' || ch == "'") {
68
+ state.tokenize = tokenString(ch);
69
+ return state.tokenize(stream, state);
70
+ } else if (ch == "." && stream.match(/^\d+(?:[eE][+\-]?\d+)?/)) {
71
+ return ret("number", "number");
72
+ } else if (ch == "." && stream.match("..")) {
73
+ return ret("spread", "meta");
74
+ } else if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
75
+ return ret(ch);
76
+ } else if (ch == "=" && stream.eat(">")) {
77
+ return ret("=>", "operator");
78
+ } else if (ch == "0" && stream.match(/^(?:x[\da-f]+|o[0-7]+|b[01]+)n?/i)) {
79
+ return ret("number", "number");
80
+ } else if (/\d/.test(ch)) {
81
+ stream.match(/^\d*(?:n|(?:\.\d*)?(?:[eE][+\-]?\d+)?)?/);
82
+ return ret("number", "number");
83
+ } else if (ch == "/") {
84
+ if (stream.eat("*")) {
85
+ state.tokenize = tokenComment;
86
+ return tokenComment(stream, state);
87
+ } else if (stream.eat("/")) {
88
+ stream.skipToEnd();
89
+ return ret("comment", "comment");
90
+ } else if (expressionAllowed(stream, state, 1)) {
91
+ readRegexp(stream);
92
+ stream.match(/^\b(([gimyus])(?![gimyus]*\2))+\b/);
93
+ return ret("regexp", "string-2");
94
+ } else {
95
+ stream.eat("=");
96
+ return ret("operator", "operator", stream.current());
97
+ }
98
+ } else if (ch == "`") {
99
+ state.tokenize = tokenQuasi;
100
+ return tokenQuasi(stream, state);
101
+ } else if (ch == "#") {
102
+ stream.skipToEnd();
103
+ return ret("error", "error");
104
+ } else if (isOperatorChar.test(ch)) {
105
+ if (ch != ">" || !state.lexical || state.lexical.type != ">") {
106
+ if (stream.eat("=")) {
107
+ if (ch == "!" || ch == "=") stream.eat("=")
108
+ } else if (/[<>*+\-]/.test(ch)) {
109
+ stream.eat(ch)
110
+ if (ch == ">") stream.eat(ch)
111
+ }
112
+ }
113
+ return ret("operator", "operator", stream.current());
114
+ } else if (wordRE.test(ch)) {
115
+ stream.eatWhile(wordRE);
116
+ var word = stream.current()
117
+ if (state.lastType != ".") {
118
+ if (keywords.propertyIsEnumerable(word)) {
119
+ var kw = keywords[word]
120
+ return ret(kw.type, kw.style, word)
121
+ }
122
+ if (word == "async" && stream.match(/^(\s|\/\*.*?\*\/)*[\[\(\w]/, false))
123
+ return ret("async", "keyword", word)
124
+ }
125
+ return ret("variable", "variable", word)
126
+ }
127
+ }
128
+
129
+ function tokenString(quote) {
130
+ return function(stream, state) {
131
+ var escaped = false, next;
132
+ if (jsonldMode && stream.peek() == "@" && stream.match(isJsonldKeyword)){
133
+ state.tokenize = tokenBase;
134
+ return ret("jsonld-keyword", "meta");
135
+ }
136
+ while ((next = stream.next()) != null) {
137
+ if (next == quote && !escaped) break;
138
+ escaped = !escaped && next == "\\";
139
+ }
140
+ if (!escaped) state.tokenize = tokenBase;
141
+ return ret("string", "string");
142
+ };
143
+ }
144
+
145
+ function tokenComment(stream, state) {
146
+ var maybeEnd = false, ch;
147
+ while (ch = stream.next()) {
148
+ if (ch == "/" && maybeEnd) {
149
+ state.tokenize = tokenBase;
150
+ break;
151
+ }
152
+ maybeEnd = (ch == "*");
153
+ }
154
+ return ret("comment", "comment");
155
+ }
156
+
157
+ function tokenQuasi(stream, state) {
158
+ var escaped = false, next;
159
+ while ((next = stream.next()) != null) {
160
+ if (!escaped && (next == "`" || next == "$" && stream.eat("{"))) {
161
+ state.tokenize = tokenBase;
162
+ break;
163
+ }
164
+ escaped = !escaped && next == "\\";
165
+ }
166
+ return ret("quasi", "string-2", stream.current());
167
+ }
168
+
169
+ var brackets = "([{}])";
170
+ // This is a crude lookahead trick to try and notice that we're
171
+ // parsing the argument patterns for a fat-arrow function before we
172
+ // actually hit the arrow token. It only works if the arrow is on
173
+ // the same line as the arguments and there's no strange noise
174
+ // (comments) in between. Fallback is to only notice when we hit the
175
+ // arrow, and not declare the arguments as locals for the arrow
176
+ // body.
177
+ function findFatArrow(stream, state) {
178
+ if (state.fatArrowAt) state.fatArrowAt = null;
179
+ var arrow = stream.string.indexOf("=>", stream.start);
180
+ if (arrow < 0) return;
181
+
182
+ if (isTS) { // Try to skip TypeScript return type declarations after the arguments
183
+ var m = /:\s*(?:\w+(?:<[^>]*>|\[\])?|\{[^}]*\})\s*$/.exec(stream.string.slice(stream.start, arrow))
184
+ if (m) arrow = m.index
185
+ }
186
+
187
+ var depth = 0, sawSomething = false;
188
+ for (var pos = arrow - 1; pos >= 0; --pos) {
189
+ var ch = stream.string.charAt(pos);
190
+ var bracket = brackets.indexOf(ch);
191
+ if (bracket >= 0 && bracket < 3) {
192
+ if (!depth) { ++pos; break; }
193
+ if (--depth == 0) { if (ch == "(") sawSomething = true; break; }
194
+ } else if (bracket >= 3 && bracket < 6) {
195
+ ++depth;
196
+ } else if (wordRE.test(ch)) {
197
+ sawSomething = true;
198
+ } else if (/["'\/]/.test(ch)) {
199
+ return;
200
+ } else if (sawSomething && !depth) {
201
+ ++pos;
202
+ break;
203
+ }
204
+ }
205
+ if (sawSomething && !depth) state.fatArrowAt = pos;
206
+ }
207
+
208
+ // Parser
209
+
210
+ var atomicTypes = {"atom": true, "number": true, "variable": true, "string": true, "regexp": true, "this": true, "jsonld-keyword": true};
211
+
212
+ function JSLexical(indented, column, type, align, prev, info) {
213
+ this.indented = indented;
214
+ this.column = column;
215
+ this.type = type;
216
+ this.prev = prev;
217
+ this.info = info;
218
+ if (align != null) this.align = align;
219
+ }
220
+
221
+ function inScope(state, varname) {
222
+ for (var v = state.localVars; v; v = v.next)
223
+ if (v.name == varname) return true;
224
+ for (var cx = state.context; cx; cx = cx.prev) {
225
+ for (var v = cx.vars; v; v = v.next)
226
+ if (v.name == varname) return true;
227
+ }
228
+ }
229
+
230
+ function parseJS(state, style, type, content, stream) {
231
+ var cc = state.cc;
232
+ // Communicate our context to the combinators.
233
+ // (Less wasteful than consing up a hundred closures on every call.)
234
+ cx.state = state; cx.stream = stream; cx.marked = null, cx.cc = cc; cx.style = style;
235
+
236
+ if (!state.lexical.hasOwnProperty("align"))
237
+ state.lexical.align = true;
238
+
239
+ while(true) {
240
+ var combinator = cc.length ? cc.pop() : jsonMode ? expression : statement;
241
+ if (combinator(type, content)) {
242
+ while(cc.length && cc[cc.length - 1].lex)
243
+ cc.pop()();
244
+ if (cx.marked) return cx.marked;
245
+ if (type == "variable" && inScope(state, content)) return "variable-2";
246
+ return style;
247
+ }
248
+ }
249
+ }
250
+
251
+ // Combinator utils
252
+
253
+ var cx = {state: null, column: null, marked: null, cc: null};
254
+ function pass() {
255
+ for (var i = arguments.length - 1; i >= 0; i--) cx.cc.push(arguments[i]);
256
+ }
257
+ function cont() {
258
+ pass.apply(null, arguments);
259
+ return true;
260
+ }
261
+ function inList(name, list) {
262
+ for (var v = list; v; v = v.next) if (v.name == name) return true
263
+ return false;
264
+ }
265
+ function register(varname) {
266
+ var state = cx.state;
267
+ cx.marked = "def";
268
+ if (state.context) {
269
+ if (state.lexical.info == "var" && state.context && state.context.block) {
270
+ // FIXME function decls are also not block scoped
271
+ var newContext = registerVarScoped(varname, state.context)
272
+ if (newContext != null) {
273
+ state.context = newContext
274
+ return
275
+ }
276
+ } else if (!inList(varname, state.localVars)) {
277
+ state.localVars = new Var(varname, state.localVars)
278
+ return
279
+ }
280
+ }
281
+ // Fall through means this is global
282
+ if (parserConfig.globalVars && !inList(varname, state.globalVars))
283
+ state.globalVars = new Var(varname, state.globalVars)
284
+ }
285
+ function registerVarScoped(varname, context) {
286
+ if (!context) {
287
+ return null
288
+ } else if (context.block) {
289
+ var inner = registerVarScoped(varname, context.prev)
290
+ if (!inner) return null
291
+ if (inner == context.prev) return context
292
+ return new Context(inner, context.vars, true)
293
+ } else if (inList(varname, context.vars)) {
294
+ return context
295
+ } else {
296
+ return new Context(context.prev, new Var(varname, context.vars), false)
297
+ }
298
+ }
299
+
300
+ function isModifier(name) {
301
+ return name == "public" || name == "private" || name == "protected" || name == "abstract" || name == "readonly"
302
+ }
303
+
304
+ // Combinators
305
+
306
+ function Context(prev, vars, block) { this.prev = prev; this.vars = vars; this.block = block }
307
+ function Var(name, next) { this.name = name; this.next = next }
308
+
309
+ var defaultVars = new Var("this", new Var("arguments", null))
310
+ function pushcontext() {
311
+ cx.state.context = new Context(cx.state.context, cx.state.localVars, false)
312
+ cx.state.localVars = defaultVars
313
+ }
314
+ function pushblockcontext() {
315
+ cx.state.context = new Context(cx.state.context, cx.state.localVars, true)
316
+ cx.state.localVars = null
317
+ }
318
+ function popcontext() {
319
+ cx.state.localVars = cx.state.context.vars
320
+ cx.state.context = cx.state.context.prev
321
+ }
322
+ popcontext.lex = true
323
+ function pushlex(type, info) {
324
+ var result = function() {
325
+ var state = cx.state, indent = state.indented;
326
+ if (state.lexical.type == "stat") indent = state.lexical.indented;
327
+ else for (var outer = state.lexical; outer && outer.type == ")" && outer.align; outer = outer.prev)
328
+ indent = outer.indented;
329
+ state.lexical = new JSLexical(indent, cx.stream.column(), type, null, state.lexical, info);
330
+ };
331
+ result.lex = true;
332
+ return result;
333
+ }
334
+ function poplex() {
335
+ var state = cx.state;
336
+ if (state.lexical.prev) {
337
+ if (state.lexical.type == ")")
338
+ state.indented = state.lexical.indented;
339
+ state.lexical = state.lexical.prev;
340
+ }
341
+ }
342
+ poplex.lex = true;
343
+
344
+ function expect(wanted) {
345
+ function exp(type) {
346
+ if (type == wanted) return cont();
347
+ else if (wanted == ";" || type == "}" || type == ")" || type == "]") return pass();
348
+ else return cont(exp);
349
+ };
350
+ return exp;
351
+ }
352
+
353
+ function statement(type, value) {
354
+ if (type == "var") return cont(pushlex("vardef", value), vardef, expect(";"), poplex);
355
+ if (type == "keyword a") return cont(pushlex("form"), parenExpr, statement, poplex);
356
+ if (type == "keyword b") return cont(pushlex("form"), statement, poplex);
357
+ if (type == "keyword d") return cx.stream.match(/^\s*$/, false) ? cont() : cont(pushlex("stat"), maybeexpression, expect(";"), poplex);
358
+ if (type == "debugger") return cont(expect(";"));
359
+ if (type == "{") return cont(pushlex("}"), pushblockcontext, block, poplex, popcontext);
360
+ if (type == ";") return cont();
361
+ if (type == "if") {
362
+ if (cx.state.lexical.info == "else" && cx.state.cc[cx.state.cc.length - 1] == poplex)
363
+ cx.state.cc.pop()();
364
+ return cont(pushlex("form"), parenExpr, statement, poplex, maybeelse);
365
+ }
366
+ if (type == "function") return cont(functiondef);
367
+ if (type == "for") return cont(pushlex("form"), forspec, statement, poplex);
368
+ if (type == "class" || (isTS && value == "interface")) { cx.marked = "keyword"; return cont(pushlex("form"), className, poplex); }
369
+ if (type == "variable") {
370
+ if (isTS && value == "declare") {
371
+ cx.marked = "keyword"
372
+ return cont(statement)
373
+ } else if (isTS && (value == "module" || value == "enum" || value == "type") && cx.stream.match(/^\s*\w/, false)) {
374
+ cx.marked = "keyword"
375
+ if (value == "enum") return cont(enumdef);
376
+ else if (value == "type") return cont(typeexpr, expect("operator"), typeexpr, expect(";"));
377
+ else return cont(pushlex("form"), pattern, expect("{"), pushlex("}"), block, poplex, poplex)
378
+ } else if (isTS && value == "namespace") {
379
+ cx.marked = "keyword"
380
+ return cont(pushlex("form"), expression, block, poplex)
381
+ } else if (isTS && value == "abstract") {
382
+ cx.marked = "keyword"
383
+ return cont(statement)
384
+ } else {
385
+ return cont(pushlex("stat"), maybelabel);
386
+ }
387
+ }
388
+ if (type == "switch") return cont(pushlex("form"), parenExpr, expect("{"), pushlex("}", "switch"), pushblockcontext,
389
+ block, poplex, poplex, popcontext);
390
+ if (type == "case") return cont(expression, expect(":"));
391
+ if (type == "default") return cont(expect(":"));
392
+ if (type == "catch") return cont(pushlex("form"), pushcontext, maybeCatchBinding, statement, poplex, popcontext);
393
+ if (type == "export") return cont(pushlex("stat"), afterExport, poplex);
394
+ if (type == "import") return cont(pushlex("stat"), afterImport, poplex);
395
+ if (type == "async") return cont(statement)
396
+ if (value == "@") return cont(expression, statement)
397
+ return pass(pushlex("stat"), expression, expect(";"), poplex);
398
+ }
399
+ function maybeCatchBinding(type) {
400
+ if (type == "(") return cont(funarg, expect(")"))
401
+ }
402
+ function expression(type, value) {
403
+ return expressionInner(type, value, false);
404
+ }
405
+ function expressionNoComma(type, value) {
406
+ return expressionInner(type, value, true);
407
+ }
408
+ function parenExpr(type) {
409
+ if (type != "(") return pass()
410
+ return cont(pushlex(")"), expression, expect(")"), poplex)
411
+ }
412
+ function expressionInner(type, value, noComma) {
413
+ if (cx.state.fatArrowAt == cx.stream.start) {
414
+ var body = noComma ? arrowBodyNoComma : arrowBody;
415
+ if (type == "(") return cont(pushcontext, pushlex(")"), commasep(funarg, ")"), poplex, expect("=>"), body, popcontext);
416
+ else if (type == "variable") return pass(pushcontext, pattern, expect("=>"), body, popcontext);
417
+ }
418
+
419
+ var maybeop = noComma ? maybeoperatorNoComma : maybeoperatorComma;
420
+ if (atomicTypes.hasOwnProperty(type)) return cont(maybeop);
421
+ if (type == "function") return cont(functiondef, maybeop);
422
+ if (type == "class" || (isTS && value == "interface")) { cx.marked = "keyword"; return cont(pushlex("form"), classExpression, poplex); }
423
+ if (type == "keyword c" || type == "async") return cont(noComma ? expressionNoComma : expression);
424
+ if (type == "(") return cont(pushlex(")"), maybeexpression, expect(")"), poplex, maybeop);
425
+ if (type == "operator" || type == "spread") return cont(noComma ? expressionNoComma : expression);
426
+ if (type == "[") return cont(pushlex("]"), arrayLiteral, poplex, maybeop);
427
+ if (type == "{") return contCommasep(objprop, "}", null, maybeop);
428
+ if (type == "quasi") return pass(quasi, maybeop);
429
+ if (type == "new") return cont(maybeTarget(noComma));
430
+ if (type == "import") return cont(expression);
431
+ return cont();
432
+ }
433
+ function maybeexpression(type) {
434
+ if (type.match(/[;\}\)\],]/)) return pass();
435
+ return pass(expression);
436
+ }
437
+
438
+ function maybeoperatorComma(type, value) {
439
+ if (type == ",") return cont(expression);
440
+ return maybeoperatorNoComma(type, value, false);
441
+ }
442
+ function maybeoperatorNoComma(type, value, noComma) {
443
+ var me = noComma == false ? maybeoperatorComma : maybeoperatorNoComma;
444
+ var expr = noComma == false ? expression : expressionNoComma;
445
+ if (type == "=>") return cont(pushcontext, noComma ? arrowBodyNoComma : arrowBody, popcontext);
446
+ if (type == "operator") {
447
+ if (/\+\+|--/.test(value) || isTS && value == "!") return cont(me);
448
+ if (isTS && value == "<" && cx.stream.match(/^([^>]|<.*?>)*>\s*\(/, false))
449
+ return cont(pushlex(">"), commasep(typeexpr, ">"), poplex, me);
450
+ if (value == "?") return cont(expression, expect(":"), expr);
451
+ return cont(expr);
452
+ }
453
+ if (type == "quasi") { return pass(quasi, me); }
454
+ if (type == ";") return;
455
+ if (type == "(") return contCommasep(expressionNoComma, ")", "call", me);
456
+ if (type == ".") return cont(property, me);
457
+ if (type == "[") return cont(pushlex("]"), maybeexpression, expect("]"), poplex, me);
458
+ if (isTS && value == "as") { cx.marked = "keyword"; return cont(typeexpr, me) }
459
+ if (type == "regexp") {
460
+ cx.state.lastType = cx.marked = "operator"
461
+ cx.stream.backUp(cx.stream.pos - cx.stream.start - 1)
462
+ return cont(expr)
463
+ }
464
+ }
465
+ function quasi(type, value) {
466
+ if (type != "quasi") return pass();
467
+ if (value.slice(value.length - 2) != "${") return cont(quasi);
468
+ return cont(expression, continueQuasi);
469
+ }
470
+ function continueQuasi(type) {
471
+ if (type == "}") {
472
+ cx.marked = "string-2";
473
+ cx.state.tokenize = tokenQuasi;
474
+ return cont(quasi);
475
+ }
476
+ }
477
+ function arrowBody(type) {
478
+ findFatArrow(cx.stream, cx.state);
479
+ return pass(type == "{" ? statement : expression);
480
+ }
481
+ function arrowBodyNoComma(type) {
482
+ findFatArrow(cx.stream, cx.state);
483
+ return pass(type == "{" ? statement : expressionNoComma);
484
+ }
485
+ function maybeTarget(noComma) {
486
+ return function(type) {
487
+ if (type == ".") return cont(noComma ? targetNoComma : target);
488
+ else if (type == "variable" && isTS) return cont(maybeTypeArgs, noComma ? maybeoperatorNoComma : maybeoperatorComma)
489
+ else return pass(noComma ? expressionNoComma : expression);
490
+ };
491
+ }
492
+ function target(_, value) {
493
+ if (value == "target") { cx.marked = "keyword"; return cont(maybeoperatorComma); }
494
+ }
495
+ function targetNoComma(_, value) {
496
+ if (value == "target") { cx.marked = "keyword"; return cont(maybeoperatorNoComma); }
497
+ }
498
+ function maybelabel(type) {
499
+ if (type == ":") return cont(poplex, statement);
500
+ return pass(maybeoperatorComma, expect(";"), poplex);
501
+ }
502
+ function property(type) {
503
+ if (type == "variable") {cx.marked = "property"; return cont();}
504
+ }
505
+ function objprop(type, value) {
506
+ if (type == "async") {
507
+ cx.marked = "property";
508
+ return cont(objprop);
509
+ } else if (type == "variable" || cx.style == "keyword") {
510
+ cx.marked = "property";
511
+ if (value == "get" || value == "set") return cont(getterSetter);
512
+ var m // Work around fat-arrow-detection complication for detecting typescript typed arrow params
513
+ if (isTS && cx.state.fatArrowAt == cx.stream.start && (m = cx.stream.match(/^\s*:\s*/, false)))
514
+ cx.state.fatArrowAt = cx.stream.pos + m[0].length
515
+ return cont(afterprop);
516
+ } else if (type == "number" || type == "string") {
517
+ cx.marked = jsonldMode ? "property" : (cx.style + " property");
518
+ return cont(afterprop);
519
+ } else if (type == "jsonld-keyword") {
520
+ return cont(afterprop);
521
+ } else if (isTS && isModifier(value)) {
522
+ cx.marked = "keyword"
523
+ return cont(objprop)
524
+ } else if (type == "[") {
525
+ return cont(expression, maybetype, expect("]"), afterprop);
526
+ } else if (type == "spread") {
527
+ return cont(expressionNoComma, afterprop);
528
+ } else if (value == "*") {
529
+ cx.marked = "keyword";
530
+ return cont(objprop);
531
+ } else if (type == ":") {
532
+ return pass(afterprop)
533
+ }
534
+ }
535
+ function getterSetter(type) {
536
+ if (type != "variable") return pass(afterprop);
537
+ cx.marked = "property";
538
+ return cont(functiondef);
539
+ }
540
+ function afterprop(type) {
541
+ if (type == ":") return cont(expressionNoComma);
542
+ if (type == "(") return pass(functiondef);
543
+ }
544
+ function commasep(what, end, sep) {
545
+ function proceed(type, value) {
546
+ if (sep ? sep.indexOf(type) > -1 : type == ",") {
547
+ var lex = cx.state.lexical;
548
+ if (lex.info == "call") lex.pos = (lex.pos || 0) + 1;
549
+ return cont(function(type, value) {
550
+ if (type == end || value == end) return pass()
551
+ return pass(what)
552
+ }, proceed);
553
+ }
554
+ if (type == end || value == end) return cont();
555
+ return cont(expect(end));
556
+ }
557
+ return function(type, value) {
558
+ if (type == end || value == end) return cont();
559
+ return pass(what, proceed);
560
+ };
561
+ }
562
+ function contCommasep(what, end, info) {
563
+ for (var i = 3; i < arguments.length; i++)
564
+ cx.cc.push(arguments[i]);
565
+ return cont(pushlex(end, info), commasep(what, end), poplex);
566
+ }
567
+ function block(type) {
568
+ if (type == "}") return cont();
569
+ return pass(statement, block);
570
+ }
571
+ function maybetype(type, value) {
572
+ if (isTS) {
573
+ if (type == ":") return cont(typeexpr);
574
+ if (value == "?") return cont(maybetype);
575
+ }
576
+ }
577
+ function mayberettype(type) {
578
+ if (isTS && type == ":") {
579
+ if (cx.stream.match(/^\s*\w+\s+is\b/, false)) return cont(expression, isKW, typeexpr)
580
+ else return cont(typeexpr)
581
+ }
582
+ }
583
+ function isKW(_, value) {
584
+ if (value == "is") {
585
+ cx.marked = "keyword"
586
+ return cont()
587
+ }
588
+ }
589
+ function typeexpr(type, value) {
590
+ if (value == "keyof" || value == "typeof") {
591
+ cx.marked = "keyword"
592
+ return cont(value == "keyof" ? typeexpr : expressionNoComma)
593
+ }
594
+ if (type == "variable" || value == "void") {
595
+ cx.marked = "type"
596
+ return cont(afterType)
597
+ }
598
+ if (type == "string" || type == "number" || type == "atom") return cont(afterType);
599
+ if (type == "[") return cont(pushlex("]"), commasep(typeexpr, "]", ","), poplex, afterType)
600
+ if (type == "{") return cont(pushlex("}"), commasep(typeprop, "}", ",;"), poplex, afterType)
601
+ if (type == "(") return cont(commasep(typearg, ")"), maybeReturnType)
602
+ if (type == "<") return cont(commasep(typeexpr, ">"), typeexpr)
603
+ }
604
+ function maybeReturnType(type) {
605
+ if (type == "=>") return cont(typeexpr)
606
+ }
607
+ function typeprop(type, value) {
608
+ if (type == "variable" || cx.style == "keyword") {
609
+ cx.marked = "property"
610
+ return cont(typeprop)
611
+ } else if (value == "?") {
612
+ return cont(typeprop)
613
+ } else if (type == ":") {
614
+ return cont(typeexpr)
615
+ } else if (type == "[") {
616
+ return cont(expression, maybetype, expect("]"), typeprop)
617
+ }
618
+ }
619
+ function typearg(type, value) {
620
+ if (type == "variable" && cx.stream.match(/^\s*[?:]/, false) || value == "?") return cont(typearg)
621
+ if (type == ":") return cont(typeexpr)
622
+ return pass(typeexpr)
623
+ }
624
+ function afterType(type, value) {
625
+ if (value == "<") return cont(pushlex(">"), commasep(typeexpr, ">"), poplex, afterType)
626
+ if (value == "|" || type == "." || value == "&") return cont(typeexpr)
627
+ if (type == "[") return cont(expect("]"), afterType)
628
+ if (value == "extends" || value == "implements") { cx.marked = "keyword"; return cont(typeexpr) }
629
+ }
630
+ function maybeTypeArgs(_, value) {
631
+ if (value == "<") return cont(pushlex(">"), commasep(typeexpr, ">"), poplex, afterType)
632
+ }
633
+ function typeparam() {
634
+ return pass(typeexpr, maybeTypeDefault)
635
+ }
636
+ function maybeTypeDefault(_, value) {
637
+ if (value == "=") return cont(typeexpr)
638
+ }
639
+ function vardef(_, value) {
640
+ if (value == "enum") {cx.marked = "keyword"; return cont(enumdef)}
641
+ return pass(pattern, maybetype, maybeAssign, vardefCont);
642
+ }
643
+ function pattern(type, value) {
644
+ if (isTS && isModifier(value)) { cx.marked = "keyword"; return cont(pattern) }
645
+ if (type == "variable") { register(value); return cont(); }
646
+ if (type == "spread") return cont(pattern);
647
+ if (type == "[") return contCommasep(pattern, "]");
648
+ if (type == "{") return contCommasep(proppattern, "}");
649
+ }
650
+ function proppattern(type, value) {
651
+ if (type == "variable" && !cx.stream.match(/^\s*:/, false)) {
652
+ register(value);
653
+ return cont(maybeAssign);
654
+ }
655
+ if (type == "variable") cx.marked = "property";
656
+ if (type == "spread") return cont(pattern);
657
+ if (type == "}") return pass();
658
+ return cont(expect(":"), pattern, maybeAssign);
659
+ }
660
+ function maybeAssign(_type, value) {
661
+ if (value == "=") return cont(expressionNoComma);
662
+ }
663
+ function vardefCont(type) {
664
+ if (type == ",") return cont(vardef);
665
+ }
666
+ function maybeelse(type, value) {
667
+ if (type == "keyword b" && value == "else") return cont(pushlex("form", "else"), statement, poplex);
668
+ }
669
+ function forspec(type, value) {
670
+ if (value == "await") return cont(forspec);
671
+ if (type == "(") return cont(pushlex(")"), forspec1, expect(")"), poplex);
672
+ }
673
+ function forspec1(type) {
674
+ if (type == "var") return cont(vardef, expect(";"), forspec2);
675
+ if (type == ";") return cont(forspec2);
676
+ if (type == "variable") return cont(formaybeinof);
677
+ return pass(expression, expect(";"), forspec2);
678
+ }
679
+ function formaybeinof(_type, value) {
680
+ if (value == "in" || value == "of") { cx.marked = "keyword"; return cont(expression); }
681
+ return cont(maybeoperatorComma, forspec2);
682
+ }
683
+ function forspec2(type, value) {
684
+ if (type == ";") return cont(forspec3);
685
+ if (value == "in" || value == "of") { cx.marked = "keyword"; return cont(expression); }
686
+ return pass(expression, expect(";"), forspec3);
687
+ }
688
+ function forspec3(type) {
689
+ if (type != ")") cont(expression);
690
+ }
691
+ function functiondef(type, value) {
692
+ if (value == "*") {cx.marked = "keyword"; return cont(functiondef);}
693
+ if (type == "variable") {register(value); return cont(functiondef);}
694
+ if (type == "(") return cont(pushcontext, pushlex(")"), commasep(funarg, ")"), poplex, mayberettype, statement, popcontext);
695
+ if (isTS && value == "<") return cont(pushlex(">"), commasep(typeparam, ">"), poplex, functiondef)
696
+ }
697
+ function funarg(type, value) {
698
+ if (value == "@") cont(expression, funarg)
699
+ if (type == "spread") return cont(funarg);
700
+ if (isTS && isModifier(value)) { cx.marked = "keyword"; return cont(funarg); }
701
+ return pass(pattern, maybetype, maybeAssign);
702
+ }
703
+ function classExpression(type, value) {
704
+ // Class expressions may have an optional name.
705
+ if (type == "variable") return className(type, value);
706
+ return classNameAfter(type, value);
707
+ }
708
+ function className(type, value) {
709
+ if (type == "variable") {register(value); return cont(classNameAfter);}
710
+ }
711
+ function classNameAfter(type, value) {
712
+ if (value == "<") return cont(pushlex(">"), commasep(typeparam, ">"), poplex, classNameAfter)
713
+ if (value == "extends" || value == "implements" || (isTS && type == ",")) {
714
+ if (value == "implements") cx.marked = "keyword";
715
+ return cont(isTS ? typeexpr : expression, classNameAfter);
716
+ }
717
+ if (type == "{") return cont(pushlex("}"), classBody, poplex);
718
+ }
719
+ function classBody(type, value) {
720
+ if (type == "async" ||
721
+ (type == "variable" &&
722
+ (value == "static" || value == "get" || value == "set" || (isTS && isModifier(value))) &&
723
+ cx.stream.match(/^\s+[\w$\xa1-\uffff]/, false))) {
724
+ cx.marked = "keyword";
725
+ return cont(classBody);
726
+ }
727
+ if (type == "variable" || cx.style == "keyword") {
728
+ cx.marked = "property";
729
+ return cont(isTS ? classfield : functiondef, classBody);
730
+ }
731
+ if (type == "[")
732
+ return cont(expression, maybetype, expect("]"), isTS ? classfield : functiondef, classBody)
733
+ if (value == "*") {
734
+ cx.marked = "keyword";
735
+ return cont(classBody);
736
+ }
737
+ if (type == ";") return cont(classBody);
738
+ if (type == "}") return cont();
739
+ if (value == "@") return cont(expression, classBody)
740
+ }
741
+ function classfield(type, value) {
742
+ if (value == "?") return cont(classfield)
743
+ if (type == ":") return cont(typeexpr, maybeAssign)
744
+ if (value == "=") return cont(expressionNoComma)
745
+ return pass(functiondef)
746
+ }
747
+ function afterExport(type, value) {
748
+ if (value == "*") { cx.marked = "keyword"; return cont(maybeFrom, expect(";")); }
749
+ if (value == "default") { cx.marked = "keyword"; return cont(expression, expect(";")); }
750
+ if (type == "{") return cont(commasep(exportField, "}"), maybeFrom, expect(";"));
751
+ return pass(statement);
752
+ }
753
+ function exportField(type, value) {
754
+ if (value == "as") { cx.marked = "keyword"; return cont(expect("variable")); }
755
+ if (type == "variable") return pass(expressionNoComma, exportField);
756
+ }
757
+ function afterImport(type) {
758
+ if (type == "string") return cont();
759
+ if (type == "(") return pass(expression);
760
+ return pass(importSpec, maybeMoreImports, maybeFrom);
761
+ }
762
+ function importSpec(type, value) {
763
+ if (type == "{") return contCommasep(importSpec, "}");
764
+ if (type == "variable") register(value);
765
+ if (value == "*") cx.marked = "keyword";
766
+ return cont(maybeAs);
767
+ }
768
+ function maybeMoreImports(type) {
769
+ if (type == ",") return cont(importSpec, maybeMoreImports)
770
+ }
771
+ function maybeAs(_type, value) {
772
+ if (value == "as") { cx.marked = "keyword"; return cont(importSpec); }
773
+ }
774
+ function maybeFrom(_type, value) {
775
+ if (value == "from") { cx.marked = "keyword"; return cont(expression); }
776
+ }
777
+ function arrayLiteral(type) {
778
+ if (type == "]") return cont();
779
+ return pass(commasep(expressionNoComma, "]"));
780
+ }
781
+ function enumdef() {
782
+ return pass(pushlex("form"), pattern, expect("{"), pushlex("}"), commasep(enummember, "}"), poplex, poplex)
783
+ }
784
+ function enummember() {
785
+ return pass(pattern, maybeAssign);
786
+ }
787
+
788
+ function isContinuedStatement(state, textAfter) {
789
+ return state.lastType == "operator" || state.lastType == "," ||
790
+ isOperatorChar.test(textAfter.charAt(0)) ||
791
+ /[,.]/.test(textAfter.charAt(0));
792
+ }
793
+
794
+ function expressionAllowed(stream, state, backUp) {
795
+ return state.tokenize == tokenBase &&
796
+ /^(?:operator|sof|keyword [bcd]|case|new|export|default|spread|[\[{}\(,;:]|=>)$/.test(state.lastType) ||
797
+ (state.lastType == "quasi" && /\{\s*$/.test(stream.string.slice(0, stream.pos - (backUp || 0))))
798
+ }
799
+
800
+ // Interface
801
+
802
+ return {
803
+ startState: function(basecolumn) {
804
+ var state = {
805
+ tokenize: tokenBase,
806
+ lastType: "sof",
807
+ cc: [],
808
+ lexical: new JSLexical((basecolumn || 0) - indentUnit, 0, "block", false),
809
+ localVars: parserConfig.localVars,
810
+ context: parserConfig.localVars && new Context(null, null, false),
811
+ indented: basecolumn || 0
812
+ };
813
+ if (parserConfig.globalVars && typeof parserConfig.globalVars == "object")
814
+ state.globalVars = parserConfig.globalVars;
815
+ return state;
816
+ },
817
+
818
+ token: function(stream, state) {
819
+ if (stream.sol()) {
820
+ if (!state.lexical.hasOwnProperty("align"))
821
+ state.lexical.align = false;
822
+ state.indented = stream.indentation();
823
+ findFatArrow(stream, state);
824
+ }
825
+ if (state.tokenize != tokenComment && stream.eatSpace()) return null;
826
+ var style = state.tokenize(stream, state);
827
+ if (type == "comment") return style;
828
+ state.lastType = type == "operator" && (content == "++" || content == "--") ? "incdec" : type;
829
+ return parseJS(state, style, type, content, stream);
830
+ },
831
+
832
+ indent: function(state, textAfter) {
833
+ if (state.tokenize == tokenComment) return CodeMirror.Pass;
834
+ if (state.tokenize != tokenBase) return 0;
835
+ var firstChar = textAfter && textAfter.charAt(0), lexical = state.lexical, top
836
+ // Kludge to prevent 'maybelse' from blocking lexical scope pops
837
+ if (!/^\s*else\b/.test(textAfter)) for (var i = state.cc.length - 1; i >= 0; --i) {
838
+ var c = state.cc[i];
839
+ if (c == poplex) lexical = lexical.prev;
840
+ else if (c != maybeelse) break;
841
+ }
842
+ while ((lexical.type == "stat" || lexical.type == "form") &&
843
+ (firstChar == "}" || ((top = state.cc[state.cc.length - 1]) &&
844
+ (top == maybeoperatorComma || top == maybeoperatorNoComma) &&
845
+ !/^[,\.=+\-*:?[\(]/.test(textAfter))))
846
+ lexical = lexical.prev;
847
+ if (statementIndent && lexical.type == ")" && lexical.prev.type == "stat")
848
+ lexical = lexical.prev;
849
+ var type = lexical.type, closing = firstChar == type;
850
+
851
+ if (type == "vardef") return lexical.indented + (state.lastType == "operator" || state.lastType == "," ? lexical.info.length + 1 : 0);
852
+ else if (type == "form" && firstChar == "{") return lexical.indented;
853
+ else if (type == "form") return lexical.indented + indentUnit;
854
+ else if (type == "stat")
855
+ return lexical.indented + (isContinuedStatement(state, textAfter) ? statementIndent || indentUnit : 0);
856
+ else if (lexical.info == "switch" && !closing && parserConfig.doubleIndentSwitch != false)
857
+ return lexical.indented + (/^(?:case|default)\b/.test(textAfter) ? indentUnit : 2 * indentUnit);
858
+ else if (lexical.align) return lexical.column + (closing ? 0 : 1);
859
+ else return lexical.indented + (closing ? 0 : indentUnit);
860
+ },
861
+
862
+ electricInput: /^\s*(?:case .*?:|default:|\{|\})$/,
863
+ blockCommentStart: jsonMode ? null : "/*",
864
+ blockCommentEnd: jsonMode ? null : "*/",
865
+ blockCommentContinue: jsonMode ? null : " * ",
866
+ lineComment: jsonMode ? null : "//",
867
+ fold: "brace",
868
+ closeBrackets: "()[]{}''\"\"``",
869
+
870
+ helperType: jsonMode ? "json" : "javascript",
871
+ jsonldMode: jsonldMode,
872
+ jsonMode: jsonMode,
873
+
874
+ expressionAllowed: expressionAllowed,
875
+
876
+ skipExpression: function(state) {
877
+ var top = state.cc[state.cc.length - 1]
878
+ if (top == expression || top == expressionNoComma) state.cc.pop()
879
+ }
880
+ };
881
+ });
882
+
883
+ CodeMirror.registerHelper("wordChars", "javascript", /[\w$]/);
884
+
885
+ CodeMirror.defineMIME("text/javascript", "javascript");
886
+ CodeMirror.defineMIME("text/ecmascript", "javascript");
887
+ CodeMirror.defineMIME("application/javascript", "javascript");
888
+ CodeMirror.defineMIME("application/x-javascript", "javascript");
889
+ CodeMirror.defineMIME("application/ecmascript", "javascript");
890
+ CodeMirror.defineMIME("application/json", {name: "javascript", json: true});
891
+ CodeMirror.defineMIME("application/x-json", {name: "javascript", json: true});
892
+ CodeMirror.defineMIME("application/ld+json", {name: "javascript", jsonld: true});
893
+ CodeMirror.defineMIME("text/typescript", { name: "javascript", typescript: true });
894
+ CodeMirror.defineMIME("application/typescript", { name: "javascript", typescript: true });
895
+
896
+ });