locomotivecms 4.1.1 → 4.2.0.alpha1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (301) hide show
  1. checksums.yaml +4 -4
  2. data/MIT-LICENSE +1 -1
  3. data/README.md +4 -3
  4. data/Rakefile +4 -0
  5. data/app/api/locomotive/api.rb +1 -1
  6. data/app/assets/config/locomotive_manifest.js +2 -0
  7. data/app/assets/javascripts/locomotive.js +2 -2
  8. data/app/assets/stylesheets/locomotive/account.scss +0 -1
  9. data/app/assets/stylesheets/locomotive/application.scss +0 -1
  10. data/app/assets/stylesheets/locomotive/live_editing_error.scss +0 -1
  11. data/app/assets/stylesheets/locomotive/live_editing_iframe.scss +0 -1
  12. data/app/controllers/locomotive/base_controller.rb +1 -1
  13. data/app/controllers/locomotive/concerns/authorization_controller.rb +1 -1
  14. data/app/controllers/locomotive/concerns/redirect_to_main_host_controller.rb +1 -1
  15. data/app/controllers/locomotive/concerns/site_dispatcher_controller.rb +1 -1
  16. data/app/controllers/locomotive/errors_controller.rb +1 -1
  17. data/app/controllers/locomotive/my_account_controller.rb +1 -1
  18. data/app/controllers/locomotive/passwords_controller.rb +3 -1
  19. data/app/controllers/locomotive/registrations_controller.rb +3 -1
  20. data/app/controllers/locomotive/sessions_controller.rb +3 -1
  21. data/app/controllers/locomotive/sites_controller.rb +1 -1
  22. data/app/helpers/locomotive/base_helper.rb +2 -2
  23. data/app/helpers/locomotive/custom_fields_helper.rb +2 -2
  24. data/app/helpers/locomotive/shared/activities_helper.rb +1 -1
  25. data/app/inputs/locomotive/api_key_input.rb +1 -1
  26. data/app/mailers/locomotive/notifications.rb +1 -1
  27. data/app/models/locomotive/account.rb +1 -1
  28. data/app/models/locomotive/concerns/account/api_key.rb +1 -1
  29. data/app/models/locomotive/concerns/content_entry/csv.rb +1 -1
  30. data/app/models/locomotive/concerns/content_entry/slug.rb +5 -5
  31. data/app/models/locomotive/concerns/content_type/entry_template.rb +3 -3
  32. data/app/models/locomotive/concerns/page/templatized.rb +1 -1
  33. data/app/models/locomotive/concerns/shared/json_attribute.rb +21 -2
  34. data/app/models/locomotive/concerns/site/routes.rb +1 -1
  35. data/app/models/locomotive/content_entry.rb +2 -2
  36. data/app/models/locomotive/page.rb +3 -3
  37. data/app/models/locomotive/section.rb +1 -1
  38. data/app/models/locomotive/snippet.rb +1 -1
  39. data/app/models/locomotive/translation.rb +1 -1
  40. data/app/services/locomotive/content_entry_import_service.rb +1 -1
  41. data/app/services/locomotive/content_entry_service.rb +2 -2
  42. data/app/services/locomotive/content_type_service.rb +13 -3
  43. data/app/services/locomotive/custom_field_service.rb +2 -2
  44. data/app/services/locomotive/editor_service.rb +1 -1
  45. data/app/uploaders/locomotive/base_uploader.rb +0 -10
  46. data/app/views/locomotive/dashboard/_activity.html.slim +1 -1
  47. data/app/views/locomotive/page_content/_edit.json.jbuilder +50 -0
  48. data/app/views/locomotive/page_content/edit.html.erb +1 -1
  49. data/app/views/locomotive/page_content/edit.json.jbuilder +52 -50
  50. data/config/initializers/devise.rb +5 -2
  51. data/lib/generators/locomotive/install/templates/locomotive.rb +0 -5
  52. data/lib/locomotive/action_controller/responder.rb +1 -1
  53. data/lib/locomotive/configuration.rb +2 -2
  54. data/lib/locomotive/dependencies.rb +0 -2
  55. data/lib/locomotive/engine.rb +14 -2
  56. data/lib/locomotive/mongoid/patches.rb +25 -65
  57. data/lib/locomotive/steam/services/api_entry_submission_service.rb +1 -0
  58. data/lib/locomotive/version.rb +1 -1
  59. data/vendor/assets/javascripts/locomotive/codemirror/addons/comment/comment.js +203 -0
  60. data/vendor/assets/javascripts/locomotive/codemirror/addons/comment/continuecomment.js +85 -0
  61. data/vendor/assets/javascripts/locomotive/codemirror/addons/dialog/dialog.js +157 -0
  62. data/vendor/assets/javascripts/locomotive/codemirror/addons/display/autorefresh.js +47 -0
  63. data/vendor/assets/javascripts/locomotive/codemirror/addons/display/fullscreen.js +41 -0
  64. data/vendor/assets/javascripts/locomotive/codemirror/addons/display/panel.js +112 -0
  65. data/vendor/assets/javascripts/locomotive/codemirror/addons/display/placeholder.js +62 -0
  66. data/vendor/assets/javascripts/locomotive/codemirror/addons/display/rulers.js +51 -0
  67. data/vendor/assets/javascripts/locomotive/codemirror/addons/edit/closebrackets.js +195 -0
  68. data/vendor/assets/javascripts/locomotive/codemirror/addons/edit/closetag.js +169 -0
  69. data/vendor/assets/javascripts/locomotive/codemirror/addons/edit/continuelist.js +51 -0
  70. data/vendor/assets/javascripts/locomotive/codemirror/addons/edit/matchbrackets.js +120 -0
  71. data/vendor/assets/javascripts/locomotive/codemirror/addons/edit/matchtags.js +66 -0
  72. data/vendor/assets/javascripts/locomotive/codemirror/addons/edit/trailingspace.js +27 -0
  73. data/vendor/assets/javascripts/locomotive/codemirror/addons/fold/brace-fold.js +105 -0
  74. data/vendor/assets/javascripts/locomotive/codemirror/addons/fold/comment-fold.js +59 -0
  75. data/vendor/assets/javascripts/locomotive/codemirror/addons/fold/foldcode.js +150 -0
  76. data/vendor/assets/javascripts/locomotive/codemirror/addons/fold/foldgutter.js +146 -0
  77. data/vendor/assets/javascripts/locomotive/codemirror/addons/fold/indent-fold.js +44 -0
  78. data/vendor/assets/javascripts/locomotive/codemirror/addons/fold/markdown-fold.js +49 -0
  79. data/vendor/assets/javascripts/locomotive/codemirror/addons/fold/xml-fold.js +182 -0
  80. data/vendor/assets/javascripts/locomotive/codemirror/addons/hint/anyword-hint.js +41 -0
  81. data/vendor/assets/javascripts/locomotive/codemirror/addons/hint/css-hint.js +60 -0
  82. data/vendor/assets/javascripts/locomotive/codemirror/addons/hint/html-hint.js +348 -0
  83. data/vendor/assets/javascripts/locomotive/codemirror/addons/hint/javascript-hint.js +146 -0
  84. data/vendor/assets/javascripts/locomotive/codemirror/addons/hint/show-hint.js +437 -0
  85. data/vendor/assets/javascripts/locomotive/codemirror/addons/hint/sql-hint.js +271 -0
  86. data/vendor/assets/javascripts/locomotive/codemirror/addons/hint/xml-hint.js +110 -0
  87. data/vendor/assets/javascripts/locomotive/codemirror/addons/lint/coffeescript-lint.js +41 -0
  88. data/vendor/assets/javascripts/locomotive/codemirror/addons/lint/css-lint.js +35 -0
  89. data/vendor/assets/javascripts/locomotive/codemirror/addons/lint/html-lint.js +46 -0
  90. data/vendor/assets/javascripts/locomotive/codemirror/addons/lint/javascript-lint.js +136 -0
  91. data/vendor/assets/javascripts/locomotive/codemirror/addons/lint/json-lint.js +31 -0
  92. data/vendor/assets/javascripts/locomotive/codemirror/addons/lint/lint.js +239 -0
  93. data/vendor/assets/javascripts/locomotive/codemirror/addons/lint/yaml-lint.js +28 -0
  94. data/vendor/assets/javascripts/locomotive/codemirror/addons/merge/merge.js +773 -0
  95. data/vendor/assets/javascripts/locomotive/codemirror/addons/mode/loadmode.js +64 -0
  96. data/vendor/assets/javascripts/locomotive/codemirror/addons/mode/multiplex.js +123 -0
  97. data/vendor/assets/javascripts/locomotive/codemirror/addons/mode/overlay.js +85 -0
  98. data/vendor/assets/javascripts/locomotive/codemirror/addons/mode/simple.js +213 -0
  99. data/vendor/assets/javascripts/locomotive/codemirror/addons/runmode/colorize.js +40 -0
  100. data/vendor/assets/javascripts/locomotive/codemirror/addons/runmode/runmode-standalone.js +157 -0
  101. data/vendor/assets/javascripts/locomotive/codemirror/addons/runmode/runmode.js +72 -0
  102. data/vendor/assets/javascripts/locomotive/codemirror/addons/runmode/runmode.node.js +179 -0
  103. data/vendor/assets/javascripts/locomotive/codemirror/addons/scroll/annotatescrollbar.js +118 -0
  104. data/vendor/assets/javascripts/locomotive/codemirror/addons/scroll/scrollpastend.js +48 -0
  105. data/vendor/assets/javascripts/locomotive/codemirror/addons/scroll/simplescrollbars.js +152 -0
  106. data/vendor/assets/javascripts/locomotive/codemirror/addons/search/jump-to-line.js +49 -0
  107. data/vendor/assets/javascripts/locomotive/codemirror/addons/search/match-highlighter.js +146 -0
  108. data/vendor/assets/javascripts/locomotive/codemirror/addons/search/matchesonscrollbar.js +97 -0
  109. data/vendor/assets/javascripts/locomotive/codemirror/addons/search/search.js +249 -0
  110. data/vendor/assets/javascripts/locomotive/codemirror/addons/search/searchcursor.js +189 -0
  111. data/vendor/assets/javascripts/locomotive/codemirror/addons/selection/active-line.js +74 -0
  112. data/vendor/assets/javascripts/locomotive/codemirror/addons/selection/mark-selection.js +118 -0
  113. data/vendor/assets/javascripts/locomotive/codemirror/addons/selection/selection-pointer.js +98 -0
  114. data/vendor/assets/javascripts/locomotive/codemirror/addons/tern/tern.js +701 -0
  115. data/vendor/assets/javascripts/locomotive/codemirror/addons/tern/worker.js +44 -0
  116. data/vendor/assets/javascripts/locomotive/codemirror/addons/wrap/hardwrap.js +144 -0
  117. data/vendor/assets/javascripts/locomotive/codemirror/keymaps/emacs.js +412 -0
  118. data/vendor/assets/javascripts/locomotive/codemirror/keymaps/sublime.js +580 -0
  119. data/vendor/assets/javascripts/locomotive/codemirror/keymaps/vim.js +5065 -0
  120. data/vendor/assets/javascripts/locomotive/codemirror/modes/apl.js +174 -0
  121. data/vendor/assets/javascripts/locomotive/codemirror/modes/asciiarmor.js +73 -0
  122. data/vendor/assets/javascripts/locomotive/codemirror/modes/asn.1.js +204 -0
  123. data/vendor/assets/javascripts/locomotive/codemirror/modes/asterisk.js +196 -0
  124. data/vendor/assets/javascripts/locomotive/codemirror/modes/brainfuck.js +85 -0
  125. data/vendor/assets/javascripts/locomotive/codemirror/modes/clike.js +786 -0
  126. data/vendor/assets/javascripts/locomotive/codemirror/modes/clojure.js +306 -0
  127. data/vendor/assets/javascripts/locomotive/codemirror/modes/cmake.js +97 -0
  128. data/vendor/assets/javascripts/locomotive/codemirror/modes/cobol.js +255 -0
  129. data/vendor/assets/javascripts/locomotive/codemirror/modes/coffeescript.js +355 -0
  130. data/vendor/assets/javascripts/locomotive/codemirror/modes/commonlisp.js +123 -0
  131. data/vendor/assets/javascripts/locomotive/codemirror/modes/crystal.js +391 -0
  132. data/vendor/assets/javascripts/locomotive/codemirror/modes/css.js +825 -0
  133. data/vendor/assets/javascripts/locomotive/codemirror/modes/cypher.js +146 -0
  134. data/vendor/assets/javascripts/locomotive/codemirror/modes/d.js +218 -0
  135. data/vendor/assets/javascripts/locomotive/codemirror/modes/dart.js +157 -0
  136. data/vendor/assets/javascripts/locomotive/codemirror/modes/diff.js +47 -0
  137. data/vendor/assets/javascripts/locomotive/codemirror/modes/django.js +356 -0
  138. data/vendor/assets/javascripts/locomotive/codemirror/modes/dockerfile.js +79 -0
  139. data/vendor/assets/javascripts/locomotive/codemirror/modes/dtd.js +142 -0
  140. data/vendor/assets/javascripts/locomotive/codemirror/modes/dylan.js +344 -0
  141. data/vendor/assets/javascripts/locomotive/codemirror/modes/ebnf.js +195 -0
  142. data/vendor/assets/javascripts/locomotive/codemirror/modes/ecl.js +206 -0
  143. data/vendor/assets/javascripts/locomotive/codemirror/modes/eiffel.js +160 -0
  144. data/vendor/assets/javascripts/locomotive/codemirror/modes/elm.js +205 -0
  145. data/vendor/assets/javascripts/locomotive/codemirror/modes/erlang.js +618 -0
  146. data/vendor/assets/javascripts/locomotive/codemirror/modes/factor.js +83 -0
  147. data/vendor/assets/javascripts/locomotive/codemirror/modes/fcl.js +173 -0
  148. data/vendor/assets/javascripts/locomotive/codemirror/modes/forth.js +180 -0
  149. data/vendor/assets/javascripts/locomotive/codemirror/modes/fortran.js +188 -0
  150. data/vendor/assets/javascripts/locomotive/codemirror/modes/gas.js +345 -0
  151. data/vendor/assets/javascripts/locomotive/codemirror/modes/gfm.js +130 -0
  152. data/vendor/assets/javascripts/locomotive/codemirror/modes/gherkin.js +178 -0
  153. data/vendor/assets/javascripts/locomotive/codemirror/modes/go.js +185 -0
  154. data/vendor/assets/javascripts/locomotive/codemirror/modes/groovy.js +230 -0
  155. data/vendor/assets/javascripts/locomotive/codemirror/modes/haml.js +161 -0
  156. data/vendor/assets/javascripts/locomotive/codemirror/modes/handlebars.js +62 -0
  157. data/vendor/assets/javascripts/locomotive/codemirror/modes/haskell-literate.js +43 -0
  158. data/vendor/assets/javascripts/locomotive/codemirror/modes/haskell.js +267 -0
  159. data/vendor/assets/javascripts/locomotive/codemirror/modes/haxe.js +515 -0
  160. data/vendor/assets/javascripts/locomotive/codemirror/modes/htmlembedded.js +28 -0
  161. data/vendor/assets/javascripts/locomotive/codemirror/modes/htmlmixed.js +152 -0
  162. data/vendor/assets/javascripts/locomotive/codemirror/modes/http.js +113 -0
  163. data/vendor/assets/javascripts/locomotive/codemirror/modes/idl.js +290 -0
  164. data/vendor/assets/javascripts/locomotive/codemirror/modes/jade.js +590 -0
  165. data/vendor/assets/javascripts/locomotive/codemirror/modes/javascript.js +748 -0
  166. data/vendor/assets/javascripts/locomotive/codemirror/modes/jinja2.js +142 -0
  167. data/vendor/assets/javascripts/locomotive/codemirror/modes/jsx.js +147 -0
  168. data/vendor/assets/javascripts/locomotive/codemirror/modes/julia.js +392 -0
  169. data/vendor/assets/javascripts/locomotive/codemirror/modes/livescript.js +280 -0
  170. data/vendor/assets/javascripts/locomotive/codemirror/modes/lua.js +159 -0
  171. data/vendor/assets/javascripts/locomotive/codemirror/modes/markdown.js +797 -0
  172. data/vendor/assets/javascripts/locomotive/codemirror/modes/mathematica.js +176 -0
  173. data/vendor/assets/javascripts/locomotive/codemirror/modes/mbox.js +129 -0
  174. data/vendor/assets/javascripts/locomotive/codemirror/modes/mirc.js +193 -0
  175. data/vendor/assets/javascripts/locomotive/codemirror/modes/mllike.js +205 -0
  176. data/vendor/assets/javascripts/locomotive/codemirror/modes/modelica.js +245 -0
  177. data/vendor/assets/javascripts/locomotive/codemirror/modes/mscgen.js +169 -0
  178. data/vendor/assets/javascripts/locomotive/codemirror/modes/mumps.js +148 -0
  179. data/vendor/assets/javascripts/locomotive/codemirror/modes/nginx.js +178 -0
  180. data/vendor/assets/javascripts/locomotive/codemirror/modes/nsis.js +95 -0
  181. data/vendor/assets/javascripts/locomotive/codemirror/modes/ntriples.js +186 -0
  182. data/vendor/assets/javascripts/locomotive/codemirror/modes/octave.js +135 -0
  183. data/vendor/assets/javascripts/locomotive/codemirror/modes/oz.js +252 -0
  184. data/vendor/assets/javascripts/locomotive/codemirror/modes/pascal.js +109 -0
  185. data/vendor/assets/javascripts/locomotive/codemirror/modes/pegjs.js +114 -0
  186. data/vendor/assets/javascripts/locomotive/codemirror/modes/perl.js +837 -0
  187. data/vendor/assets/javascripts/locomotive/codemirror/modes/php.js +234 -0
  188. data/vendor/assets/javascripts/locomotive/codemirror/modes/pig.js +178 -0
  189. data/vendor/assets/javascripts/locomotive/codemirror/modes/powershell.js +396 -0
  190. data/vendor/assets/javascripts/locomotive/codemirror/modes/properties.js +78 -0
  191. data/vendor/assets/javascripts/locomotive/codemirror/modes/protobuf.js +68 -0
  192. data/vendor/assets/javascripts/locomotive/codemirror/modes/puppet.js +220 -0
  193. data/vendor/assets/javascripts/locomotive/codemirror/modes/python.js +340 -0
  194. data/vendor/assets/javascripts/locomotive/codemirror/modes/q.js +139 -0
  195. data/vendor/assets/javascripts/locomotive/codemirror/modes/r.js +164 -0
  196. data/vendor/assets/javascripts/locomotive/codemirror/modes/rpm.js +109 -0
  197. data/vendor/assets/javascripts/locomotive/codemirror/modes/rst.js +557 -0
  198. data/vendor/assets/javascripts/locomotive/codemirror/modes/ruby.js +285 -0
  199. data/vendor/assets/javascripts/locomotive/codemirror/modes/rust.js +71 -0
  200. data/vendor/assets/javascripts/locomotive/codemirror/modes/sas.js +315 -0
  201. data/vendor/assets/javascripts/locomotive/codemirror/modes/sass.js +414 -0
  202. data/vendor/assets/javascripts/locomotive/codemirror/modes/scheme.js +249 -0
  203. data/vendor/assets/javascripts/locomotive/codemirror/modes/shell.js +139 -0
  204. data/vendor/assets/javascripts/locomotive/codemirror/modes/sieve.js +193 -0
  205. data/vendor/assets/javascripts/locomotive/codemirror/modes/slim.js +575 -0
  206. data/vendor/assets/javascripts/locomotive/codemirror/modes/smalltalk.js +168 -0
  207. data/vendor/assets/javascripts/locomotive/codemirror/modes/smarty.js +225 -0
  208. data/vendor/assets/javascripts/locomotive/codemirror/modes/solr.js +104 -0
  209. data/vendor/assets/javascripts/locomotive/codemirror/modes/soy.js +199 -0
  210. data/vendor/assets/javascripts/locomotive/codemirror/modes/sparql.js +180 -0
  211. data/vendor/assets/javascripts/locomotive/codemirror/modes/spreadsheet.js +112 -0
  212. data/vendor/assets/javascripts/locomotive/codemirror/modes/sql.js +413 -0
  213. data/vendor/assets/javascripts/locomotive/codemirror/modes/stex.js +251 -0
  214. data/vendor/assets/javascripts/locomotive/codemirror/modes/stylus.js +769 -0
  215. data/vendor/assets/javascripts/locomotive/codemirror/modes/swift.js +202 -0
  216. data/vendor/assets/javascripts/locomotive/codemirror/modes/tcl.js +139 -0
  217. data/vendor/assets/javascripts/locomotive/codemirror/modes/textile.js +469 -0
  218. data/vendor/assets/javascripts/locomotive/codemirror/modes/tiddlywiki.js +308 -0
  219. data/vendor/assets/javascripts/locomotive/codemirror/modes/tiki.js +312 -0
  220. data/vendor/assets/javascripts/locomotive/codemirror/modes/toml.js +88 -0
  221. data/vendor/assets/javascripts/locomotive/codemirror/modes/tornado.js +68 -0
  222. data/vendor/assets/javascripts/locomotive/codemirror/modes/troff.js +84 -0
  223. data/vendor/assets/javascripts/locomotive/codemirror/modes/ttcn-cfg.js +214 -0
  224. data/vendor/assets/javascripts/locomotive/codemirror/modes/ttcn.js +283 -0
  225. data/vendor/assets/javascripts/locomotive/codemirror/modes/turtle.js +162 -0
  226. data/vendor/assets/javascripts/locomotive/codemirror/modes/twig.js +141 -0
  227. data/vendor/assets/javascripts/locomotive/codemirror/modes/vb.js +276 -0
  228. data/vendor/assets/javascripts/locomotive/codemirror/modes/vbscript.js +350 -0
  229. data/vendor/assets/javascripts/locomotive/codemirror/modes/velocity.js +201 -0
  230. data/vendor/assets/javascripts/locomotive/codemirror/modes/verilog.js +537 -0
  231. data/vendor/assets/javascripts/locomotive/codemirror/modes/vhdl.js +189 -0
  232. data/vendor/assets/javascripts/locomotive/codemirror/modes/vue.js +69 -0
  233. data/vendor/assets/javascripts/locomotive/codemirror/modes/webidl.js +195 -0
  234. data/vendor/assets/javascripts/locomotive/codemirror/modes/xml.js +394 -0
  235. data/vendor/assets/javascripts/locomotive/codemirror/modes/xquery.js +437 -0
  236. data/vendor/assets/javascripts/locomotive/codemirror/modes/yacas.js +204 -0
  237. data/vendor/assets/javascripts/locomotive/codemirror/modes/yaml-frontmatter.js +68 -0
  238. data/vendor/assets/javascripts/locomotive/codemirror/modes/yaml.js +117 -0
  239. data/vendor/assets/javascripts/locomotive/codemirror/modes/z80.js +116 -0
  240. data/vendor/assets/javascripts/locomotive/codemirror.js +8922 -0
  241. data/vendor/assets/javascripts/locomotive/select2.js +436 -175
  242. data/vendor/assets/javascripts/locomotive/wysihtml5x-toolbar.js +1346 -564
  243. data/vendor/assets/stylesheets/locomotive/codemirror/addons/dialog/dialog.css +32 -0
  244. data/vendor/assets/stylesheets/locomotive/codemirror/addons/display/fullscreen.css +6 -0
  245. data/vendor/assets/stylesheets/locomotive/codemirror/addons/fold/foldgutter.css +20 -0
  246. data/vendor/assets/stylesheets/locomotive/codemirror/addons/hint/show-hint.css +37 -0
  247. data/vendor/assets/stylesheets/locomotive/codemirror/addons/lint/lint.css +73 -0
  248. data/vendor/assets/stylesheets/locomotive/codemirror/addons/merge/merge.css +113 -0
  249. data/vendor/assets/stylesheets/locomotive/codemirror/addons/scroll/simplescrollbars.css +66 -0
  250. data/vendor/assets/stylesheets/locomotive/codemirror/addons/search/matchesonscrollbar.css +8 -0
  251. data/vendor/assets/stylesheets/locomotive/codemirror/addons/tern/tern.css +87 -0
  252. data/vendor/assets/stylesheets/locomotive/codemirror/modes/tiddlywiki.css +14 -0
  253. data/vendor/assets/stylesheets/locomotive/codemirror/modes/tiki.css +26 -0
  254. data/vendor/assets/stylesheets/locomotive/codemirror/themes/3024-day.css +41 -0
  255. data/vendor/assets/stylesheets/locomotive/codemirror/themes/3024-night.css +39 -0
  256. data/vendor/assets/stylesheets/locomotive/codemirror/themes/abcdef.css +32 -0
  257. data/vendor/assets/stylesheets/locomotive/codemirror/themes/ambiance-mobile.css +5 -0
  258. data/vendor/assets/stylesheets/locomotive/codemirror/themes/ambiance.css +74 -0
  259. data/vendor/assets/stylesheets/locomotive/codemirror/themes/base16-dark.css +38 -0
  260. data/vendor/assets/stylesheets/locomotive/codemirror/themes/base16-light.css +38 -0
  261. data/vendor/assets/stylesheets/locomotive/codemirror/themes/bespin.css +34 -0
  262. data/vendor/assets/stylesheets/locomotive/codemirror/themes/blackboard.css +32 -0
  263. data/vendor/assets/stylesheets/locomotive/codemirror/themes/cobalt.css +25 -0
  264. data/vendor/assets/stylesheets/locomotive/codemirror/themes/colorforth.css +33 -0
  265. data/vendor/assets/stylesheets/locomotive/codemirror/themes/dracula.css +41 -0
  266. data/vendor/assets/stylesheets/locomotive/codemirror/themes/eclipse.css +23 -0
  267. data/vendor/assets/stylesheets/locomotive/codemirror/themes/elegant.css +13 -0
  268. data/vendor/assets/stylesheets/locomotive/codemirror/themes/erlang-dark.css +34 -0
  269. data/vendor/assets/stylesheets/locomotive/codemirror/themes/hopscotch.css +34 -0
  270. data/vendor/assets/stylesheets/locomotive/codemirror/themes/icecoder.css +43 -0
  271. data/vendor/assets/stylesheets/locomotive/codemirror/themes/isotope.css +34 -0
  272. data/vendor/assets/stylesheets/locomotive/codemirror/themes/lesser-dark.css +47 -0
  273. data/vendor/assets/stylesheets/locomotive/codemirror/themes/liquibyte.css +95 -0
  274. data/vendor/assets/stylesheets/locomotive/codemirror/themes/material.css +53 -0
  275. data/vendor/assets/stylesheets/locomotive/codemirror/themes/mbo.css +37 -0
  276. data/vendor/assets/stylesheets/locomotive/codemirror/themes/mdn-like.css +46 -0
  277. data/vendor/assets/stylesheets/locomotive/codemirror/themes/midnight.css +45 -0
  278. data/vendor/assets/stylesheets/locomotive/codemirror/themes/monokai.css +36 -0
  279. data/vendor/assets/stylesheets/locomotive/codemirror/themes/neat.css +12 -0
  280. data/vendor/assets/stylesheets/locomotive/codemirror/themes/neo.css +43 -0
  281. data/vendor/assets/stylesheets/locomotive/codemirror/themes/night.css +27 -0
  282. data/vendor/assets/stylesheets/locomotive/codemirror/themes/paraiso-dark.css +38 -0
  283. data/vendor/assets/stylesheets/locomotive/codemirror/themes/paraiso-light.css +38 -0
  284. data/vendor/assets/stylesheets/locomotive/codemirror/themes/pastel-on-dark.css +53 -0
  285. data/vendor/assets/stylesheets/locomotive/codemirror/themes/railscasts.css +34 -0
  286. data/vendor/assets/stylesheets/locomotive/codemirror/themes/rubyblue.css +25 -0
  287. data/vendor/assets/stylesheets/locomotive/codemirror/themes/seti.css +44 -0
  288. data/vendor/assets/stylesheets/locomotive/codemirror/themes/solarized.css +169 -0
  289. data/vendor/assets/stylesheets/locomotive/codemirror/themes/the-matrix.css +30 -0
  290. data/vendor/assets/stylesheets/locomotive/codemirror/themes/tomorrow-night-bright.css +35 -0
  291. data/vendor/assets/stylesheets/locomotive/codemirror/themes/tomorrow-night-eighties.css +38 -0
  292. data/vendor/assets/stylesheets/locomotive/codemirror/themes/ttcn.css +64 -0
  293. data/vendor/assets/stylesheets/locomotive/codemirror/themes/twilight.css +32 -0
  294. data/vendor/assets/stylesheets/locomotive/codemirror/themes/vibrant-ink.css +34 -0
  295. data/vendor/assets/stylesheets/locomotive/codemirror/themes/xq-dark.css +53 -0
  296. data/vendor/assets/stylesheets/locomotive/codemirror/themes/xq-light.css +43 -0
  297. data/vendor/assets/stylesheets/locomotive/codemirror/themes/yeti.css +44 -0
  298. data/vendor/assets/stylesheets/locomotive/codemirror/themes/zenburn.css +37 -0
  299. data/vendor/assets/stylesheets/locomotive/codemirror.css +347 -0
  300. data/vendor/assets/stylesheets/locomotive/select2.css +3 -6
  301. metadata +349 -128
@@ -0,0 +1,50 @@
1
+ json.data do
2
+ json.site do
3
+ json.sectionsContent sections_content(current_site, @sections, @section_definitions)
4
+ end
5
+
6
+ json.page do
7
+ json.(@page, :id, :title, :seo_title, :meta_description, :meta_keywords, :listed, :published)
8
+
9
+ json.slug @page.slug if display_slug?(@page)
10
+
11
+ json.fullpath nice_preview_page_path(@page)
12
+ json.contentEntryId @page.content_entry&.id
13
+ json.sectionsContent sections_content(@page, @sections, @section_definitions)
14
+ json.sectionsDropzoneContent sections_dropzone_content(@page)
15
+ end
16
+
17
+ json.sectionDefinitions @section_definitions
18
+
19
+ json.editableElements @editable_elements
20
+
21
+ json.sections do
22
+ json.all sections_by_id(@sections, @page)
23
+ json.top @sections[:top]
24
+ json.bottom @sections[:bottom]
25
+ json.dropzone @sections[:dropzone]
26
+ end
27
+
28
+ json.locale current_content_locale
29
+ json.locales current_site.locales
30
+ json.uiLocale I18n.locale
31
+
32
+ json.contentTypes content_types_with_templates(current_site)
33
+ end
34
+
35
+ json.urls do
36
+ json.base pages_path(current_site)
37
+ json.load edit_page_content_path(current_site, @page)
38
+ json.save page_content_path(current_site, @page, format: :json)
39
+ json.editableElements editable_elements_path(current_site, @page)
40
+ json.settings edit_page_path(current_site, @page)
41
+ json.preview preview_page_path(@page, mounted_on: true)
42
+ json.localized_previews localized_preview_page_paths(@page, mounted_on: true)
43
+ json.thumbnail root_path + '_image_thumbnail'
44
+ json.assets content_assets_path(current_site, format: :json)
45
+ json.bulkAssetUpload bulk_create_content_assets_path(current_site, :json)
46
+ json.resources search_for_resources_path(current_site, format: :json)
47
+ json.loaderImage image_url('locomotive/editor_loader.gif')
48
+ json.deadendImage image_url('locomotive/deadend.png')
49
+ json.contentEntries content_entries_paths_by_slug(current_site)
50
+ end
@@ -2,7 +2,7 @@
2
2
 
3
3
  <% content_for :head do %>
4
4
  <script>
5
- const _json = <%== render template: 'locomotive/page_content/edit.json.jbuilder' %>;
5
+ const _json = <%== render partial: 'locomotive/page_content/edit', formats: :json %>;
6
6
 
7
7
  window.Locomotive.previewBaseUrl = "<%= preview_path(current_site) %>";
8
8
 
@@ -1,50 +1,52 @@
1
- json.data do
2
- json.site do
3
- json.sectionsContent sections_content(current_site, @sections, @section_definitions)
4
- end
5
-
6
- json.page do
7
- json.(@page, :id, :title, :seo_title, :meta_description, :meta_keywords, :listed, :published)
8
-
9
- json.slug @page.slug if display_slug?(@page)
10
-
11
- json.fullpath nice_preview_page_path(@page)
12
- json.contentEntryId @page.content_entry&.id
13
- json.sectionsContent sections_content(@page, @sections, @section_definitions)
14
- json.sectionsDropzoneContent sections_dropzone_content(@page)
15
- end
16
-
17
- json.sectionDefinitions @section_definitions
18
-
19
- json.editableElements @editable_elements
20
-
21
- json.sections do
22
- json.all sections_by_id(@sections, @page)
23
- json.top @sections[:top]
24
- json.bottom @sections[:bottom]
25
- json.dropzone @sections[:dropzone]
26
- end
27
-
28
- json.locale current_content_locale
29
- json.locales current_site.locales
30
- json.uiLocale I18n.locale
31
-
32
- json.contentTypes content_types_with_templates(current_site)
33
- end
34
-
35
- json.urls do
36
- json.base pages_path(current_site)
37
- json.load edit_page_content_path(current_site, @page)
38
- json.save page_content_path(current_site, @page, format: :json)
39
- json.editableElements editable_elements_path(current_site, @page)
40
- json.settings edit_page_path(current_site, @page)
41
- json.preview preview_page_path(@page, mounted_on: true)
42
- json.localized_previews localized_preview_page_paths(@page, mounted_on: true)
43
- json.thumbnail root_path + '_image_thumbnail'
44
- json.assets content_assets_path(current_site, format: :json)
45
- json.bulkAssetUpload bulk_create_content_assets_path(current_site, :json)
46
- json.resources search_for_resources_path(current_site, format: :json)
47
- json.loaderImage image_url('locomotive/editor_loader.gif')
48
- json.deadendImage image_url('locomotive/deadend.png')
49
- json.contentEntries content_entries_paths_by_slug(current_site)
50
- end
1
+ json.partial! 'edit'
2
+
3
+ # json.data do
4
+ # json.site do
5
+ # json.sectionsContent sections_content(current_site, @sections, @section_definitions)
6
+ # end
7
+
8
+ # json.page do
9
+ # json.(@page, :id, :title, :seo_title, :meta_description, :meta_keywords, :listed, :published)
10
+
11
+ # json.slug @page.slug if display_slug?(@page)
12
+
13
+ # json.fullpath nice_preview_page_path(@page)
14
+ # json.contentEntryId @page.content_entry&.id
15
+ # json.sectionsContent sections_content(@page, @sections, @section_definitions)
16
+ # json.sectionsDropzoneContent sections_dropzone_content(@page)
17
+ # end
18
+
19
+ # json.sectionDefinitions @section_definitions
20
+
21
+ # json.editableElements @editable_elements
22
+
23
+ # json.sections do
24
+ # json.all sections_by_id(@sections, @page)
25
+ # json.top @sections[:top]
26
+ # json.bottom @sections[:bottom]
27
+ # json.dropzone @sections[:dropzone]
28
+ # end
29
+
30
+ # json.locale current_content_locale
31
+ # json.locales current_site.locales
32
+ # json.uiLocale I18n.locale
33
+
34
+ # json.contentTypes content_types_with_templates(current_site)
35
+ # end
36
+
37
+ # json.urls do
38
+ # json.base pages_path(current_site)
39
+ # json.load edit_page_content_path(current_site, @page)
40
+ # json.save page_content_path(current_site, @page, format: :json)
41
+ # json.editableElements editable_elements_path(current_site, @page)
42
+ # json.settings edit_page_path(current_site, @page)
43
+ # json.preview preview_page_path(@page, mounted_on: true)
44
+ # json.localized_previews localized_preview_page_paths(@page, mounted_on: true)
45
+ # json.thumbnail root_path + '_image_thumbnail'
46
+ # json.assets content_assets_path(current_site, format: :json)
47
+ # json.bulkAssetUpload bulk_create_content_assets_path(current_site, :json)
48
+ # json.resources search_for_resources_path(current_site, format: :json)
49
+ # json.loaderImage image_url('locomotive/editor_loader.gif')
50
+ # json.deadendImage image_url('locomotive/deadend.png')
51
+ # json.contentEntries content_entries_paths_by_slug(current_site)
52
+ # end
@@ -4,7 +4,6 @@ module Locomotive
4
4
  class FailureApp < ::Devise::FailureApp
5
5
 
6
6
  include ::Locomotive::Engine.routes.url_helpers
7
-
8
7
  def redirect_url
9
8
  new_locomotive_account_session_path
10
9
  end
@@ -12,4 +11,8 @@ module Locomotive
12
11
  end
13
12
 
14
13
  end
15
- end
14
+ end
15
+
16
+ Devise.setup do |config|
17
+ config.secret_key = Rails.application.secret_key_base
18
+ end
@@ -70,9 +70,4 @@ Locomotive.configure do |config|
70
70
  # Indicate whether you want to allow users to register with the site. If set
71
71
  # to false the registration page will not be shown. (Default: true)
72
72
  # config.enable_registration = true
73
-
74
- # By default, Locomotive doesn't try to optimize the assets uploaded by the editors.
75
- # If true, it will use imageoptim to decrease the size of an image without losing (too much of) quality.
76
- # config.optimize_uploaded_files = false
77
-
78
73
  end
@@ -78,7 +78,7 @@ module Locomotive
78
78
 
79
79
  if in_header
80
80
  set_flash_message!
81
- message = URI::escape(controller.flash[type].to_str) if controller.flash[type]
81
+ message = ERB::Util.url_encode(controller.flash[type].to_str) if controller.flash[type]
82
82
 
83
83
  unless message.blank?
84
84
  controller.headers['X-Message'] = ActiveSupport::JSON.encode(message)
@@ -30,8 +30,8 @@ module Locomotive
30
30
  },
31
31
  rack_cache: {
32
32
  verbose: true,
33
- metastore: URI.encode("file:#{Rails.root}/tmp/dragonfly/cache/meta"), # URI encoded in case of spaces
34
- entitystore: URI.encode("file:#{Rails.root}/tmp/dragonfly/cache/body")
33
+ metastore: ERB::Util.url_encode("file:#{Rails.root}/tmp/dragonfly/cache/meta"), # URI encoded in case of spaces
34
+ entitystore: ERB::Util.url_encode("file:#{Rails.root}/tmp/dragonfly/cache/body")
35
35
  },
36
36
  devise_modules: [:registerable, :rememberable, :database_authenticatable, :recoverable, :trackable, :validatable, :encryptable, { encryptor: :sha1 }],
37
37
  steam_image_resizer_secret: 'please change it'
@@ -19,7 +19,6 @@ require 'slim'
19
19
  require 'simple_form'
20
20
  require 'responders'
21
21
  require 'carrierwave'
22
- require 'carrierwave-imageoptim'
23
22
  require 'custom_fields'
24
23
  require 'mimetype_fu'
25
24
  require 'actionmailer_with_request'
@@ -32,7 +31,6 @@ require 'csv'
32
31
  require 'rails-i18n'
33
32
  require 'json-schema'
34
33
 
35
- require 'codemirror/rails'
36
34
  require 'jquery/rails'
37
35
  require 'jquery-ui-rails'
38
36
 
@@ -12,6 +12,11 @@ module Locomotive
12
12
  end
13
13
  end
14
14
 
15
+ initializer 'locomotive.mongoid' do
16
+ # https://jira.mongodb.org/browse/MONGOID-5260?jql=text%20~%20%22pluck%20localized%22
17
+ ::Mongoid.legacy_pluck_distinct = true
18
+ end
19
+
15
20
  initializer 'locomotive.params.filter' do |app|
16
21
  # Do not log remote_<field>_url params because they can contain huge base64 string
17
22
  app.config.filter_parameters += [/\Aremote_.+_url\Z/]
@@ -21,8 +26,14 @@ module Locomotive
21
26
  ::ActionController::Base.wrap_parameters format: [:json]
22
27
  end
23
28
 
24
- initializer 'locomotive.devise' do |app|
25
- ::DeviseController.respond_to :html, :json
29
+ # initializer 'locomotive.devise' do |app|
30
+ # ::DeviseController.respond_to :html, :json
31
+ # end
32
+
33
+ initializer 'locomotive.inflectors' do |app|
34
+ ActiveSupport::Inflector.inflections(:en) do |inflect|
35
+ inflect.acronym 'API'
36
+ end
26
37
  end
27
38
 
28
39
  initializer 'locomotive.assets' do |app|
@@ -31,6 +42,7 @@ module Locomotive
31
42
 
32
43
  initializer 'locomotive.precompile.hook', group: :all do |app|
33
44
  app.config.assets.precompile += %w(
45
+ locomotive_manifest.js
34
46
  locomotive/icons/flags/*.png
35
47
  locomotive/*.png
36
48
  locomotive/*.gif
@@ -1,4 +1,4 @@
1
- # encoding: utf-8
1
+ # # encoding: utf-8
2
2
 
3
3
  require 'mongoid'
4
4
 
@@ -41,73 +41,33 @@ module Mongoid #:nodoc:
41
41
  end
42
42
  end
43
43
 
44
- # FIXME: https://github.com/benedikt/mongoid-tree/issues/58
45
- # We replace all the @_#{name} occurences by @_#{name}_ivar.
46
- module Relations
47
- module Accessors
48
- def reset_relation_criteria(name)
49
- if instance_variable_defined?("@_#{name}_ivar")
50
- send(name).reset_unloaded
51
- end
52
- end
53
- def set_relation(name, relation)
54
- instance_variable_set("@_#{name}_ivar", relation)
55
- end
56
- end
57
- def reload_relations
58
- relations.each_pair do |name, meta|
59
- if instance_variable_defined?("@_#{name}_ivar")
60
- if _parent.nil? || instance_variable_get("@_#{name}_ivar") != _parent
61
- remove_instance_variable("@_#{name}_ivar")
62
- end
63
- end
64
- end
65
- end
66
-
44
+ # Hack to give a specific type to the EditableElement
45
+ module Association
67
46
  module Embedded
68
- class Many < Relations::Many
69
-
70
- def with_same_class!(document, klass)
71
- return document if document.is_a?(klass)
72
-
73
- Factory.build(klass, {}).tap do |_document|
74
- # make it part of the relationship
75
- _document.apply_post_processed_defaults
76
- integrate(_document)
77
-
78
- # make it look like the old document
79
- attributes = document.attributes
80
- attributes['_type'] = _document._type
81
-
82
- _document.instance_variable_set(:@attributes, attributes)
83
- _document.new_record = document.new_record?
84
- _document._index = document._index
85
-
86
- # finally, make the change in the lists
87
- target[_document._index] = _document
88
- _unscoped[_document._index] = _document
47
+ class EmbedsMany
48
+ class Proxy < Association::Many
49
+ def with_same_class!(document, klass)
50
+ return document if document.is_a?(klass)
51
+
52
+ Factory.build(klass, {}).tap do |_document|
53
+ # make it part of the relationship
54
+ _document.apply_post_processed_defaults
55
+ integrate(_document)
56
+
57
+ # make it look like the old document
58
+ attributes = document.attributes
59
+ attributes['_type'] = _document._type
60
+
61
+ _document.instance_variable_set(:@attributes, attributes)
62
+ _document.new_record = document.new_record?
63
+ _document._index = document._index
64
+
65
+ # finally, make the change in the lists
66
+ _target[_document._index] = _document
67
+ _unscoped[_document._index] = _document
68
+ end
89
69
  end
90
70
  end
91
-
92
- end
93
- end
94
-
95
- end
96
- module Extensions
97
- module Object
98
- def ivar(name)
99
- if instance_variable_defined?("@_#{name}_ivar")
100
- return instance_variable_get("@_#{name}_ivar")
101
- else
102
- false
103
- end
104
- end
105
- def remove_ivar(name)
106
- if instance_variable_defined?("@_#{name}_ivar")
107
- return remove_instance_variable("@_#{name}_ivar")
108
- else
109
- false
110
- end
111
71
  end
112
72
  end
113
73
  end
@@ -29,6 +29,7 @@ module Locomotive
29
29
  })
30
30
 
31
31
  entity = entry.to_steam(@content_type)
32
+
32
33
  Locomotive::Steam::Decorators::I18nDecorator.new(entity, locale)
33
34
  end
34
35
  end
@@ -1,3 +1,3 @@
1
1
  module Locomotive
2
- VERSION = '4.1.1'
2
+ VERSION = '4.2.0.alpha1'
3
3
  end
@@ -0,0 +1,203 @@
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
+ var noOptions = {};
15
+ var nonWS = /[^\s\u00a0]/;
16
+ var Pos = CodeMirror.Pos;
17
+
18
+ function firstNonWS(str) {
19
+ var found = str.search(nonWS);
20
+ return found == -1 ? 0 : found;
21
+ }
22
+
23
+ CodeMirror.commands.toggleComment = function(cm) {
24
+ cm.toggleComment();
25
+ };
26
+
27
+ CodeMirror.defineExtension("toggleComment", function(options) {
28
+ if (!options) options = noOptions;
29
+ var cm = this;
30
+ var minLine = Infinity, ranges = this.listSelections(), mode = null;
31
+ for (var i = ranges.length - 1; i >= 0; i--) {
32
+ var from = ranges[i].from(), to = ranges[i].to();
33
+ if (from.line >= minLine) continue;
34
+ if (to.line >= minLine) to = Pos(minLine, 0);
35
+ minLine = from.line;
36
+ if (mode == null) {
37
+ if (cm.uncomment(from, to, options)) mode = "un";
38
+ else { cm.lineComment(from, to, options); mode = "line"; }
39
+ } else if (mode == "un") {
40
+ cm.uncomment(from, to, options);
41
+ } else {
42
+ cm.lineComment(from, to, options);
43
+ }
44
+ }
45
+ });
46
+
47
+ // Rough heuristic to try and detect lines that are part of multi-line string
48
+ function probablyInsideString(cm, pos, line) {
49
+ return /\bstring\b/.test(cm.getTokenTypeAt(Pos(pos.line, 0))) && !/^[\'\"`]/.test(line)
50
+ }
51
+
52
+ CodeMirror.defineExtension("lineComment", function(from, to, options) {
53
+ if (!options) options = noOptions;
54
+ var self = this, mode = self.getModeAt(from);
55
+ var firstLine = self.getLine(from.line);
56
+ if (firstLine == null || probablyInsideString(self, from, firstLine)) return;
57
+
58
+ var commentString = options.lineComment || mode.lineComment;
59
+ if (!commentString) {
60
+ if (options.blockCommentStart || mode.blockCommentStart) {
61
+ options.fullLines = true;
62
+ self.blockComment(from, to, options);
63
+ }
64
+ return;
65
+ }
66
+
67
+ var end = Math.min(to.ch != 0 || to.line == from.line ? to.line + 1 : to.line, self.lastLine() + 1);
68
+ var pad = options.padding == null ? " " : options.padding;
69
+ var blankLines = options.commentBlankLines || from.line == to.line;
70
+
71
+ self.operation(function() {
72
+ if (options.indent) {
73
+ var baseString = null;
74
+ for (var i = from.line; i < end; ++i) {
75
+ var line = self.getLine(i);
76
+ var whitespace = line.slice(0, firstNonWS(line));
77
+ if (baseString == null || baseString.length > whitespace.length) {
78
+ baseString = whitespace;
79
+ }
80
+ }
81
+ for (var i = from.line; i < end; ++i) {
82
+ var line = self.getLine(i), cut = baseString.length;
83
+ if (!blankLines && !nonWS.test(line)) continue;
84
+ if (line.slice(0, cut) != baseString) cut = firstNonWS(line);
85
+ self.replaceRange(baseString + commentString + pad, Pos(i, 0), Pos(i, cut));
86
+ }
87
+ } else {
88
+ for (var i = from.line; i < end; ++i) {
89
+ if (blankLines || nonWS.test(self.getLine(i)))
90
+ self.replaceRange(commentString + pad, Pos(i, 0));
91
+ }
92
+ }
93
+ });
94
+ });
95
+
96
+ CodeMirror.defineExtension("blockComment", function(from, to, options) {
97
+ if (!options) options = noOptions;
98
+ var self = this, mode = self.getModeAt(from);
99
+ var startString = options.blockCommentStart || mode.blockCommentStart;
100
+ var endString = options.blockCommentEnd || mode.blockCommentEnd;
101
+ if (!startString || !endString) {
102
+ if ((options.lineComment || mode.lineComment) && options.fullLines != false)
103
+ self.lineComment(from, to, options);
104
+ return;
105
+ }
106
+
107
+ var end = Math.min(to.line, self.lastLine());
108
+ if (end != from.line && to.ch == 0 && nonWS.test(self.getLine(end))) --end;
109
+
110
+ var pad = options.padding == null ? " " : options.padding;
111
+ if (from.line > end) return;
112
+
113
+ self.operation(function() {
114
+ if (options.fullLines != false) {
115
+ var lastLineHasText = nonWS.test(self.getLine(end));
116
+ self.replaceRange(pad + endString, Pos(end));
117
+ self.replaceRange(startString + pad, Pos(from.line, 0));
118
+ var lead = options.blockCommentLead || mode.blockCommentLead;
119
+ if (lead != null) for (var i = from.line + 1; i <= end; ++i)
120
+ if (i != end || lastLineHasText)
121
+ self.replaceRange(lead + pad, Pos(i, 0));
122
+ } else {
123
+ self.replaceRange(endString, to);
124
+ self.replaceRange(startString, from);
125
+ }
126
+ });
127
+ });
128
+
129
+ CodeMirror.defineExtension("uncomment", function(from, to, options) {
130
+ if (!options) options = noOptions;
131
+ var self = this, mode = self.getModeAt(from);
132
+ var end = Math.min(to.ch != 0 || to.line == from.line ? to.line : to.line - 1, self.lastLine()), start = Math.min(from.line, end);
133
+
134
+ // Try finding line comments
135
+ var lineString = options.lineComment || mode.lineComment, lines = [];
136
+ var pad = options.padding == null ? " " : options.padding, didSomething;
137
+ lineComment: {
138
+ if (!lineString) break lineComment;
139
+ for (var i = start; i <= end; ++i) {
140
+ var line = self.getLine(i);
141
+ var found = line.indexOf(lineString);
142
+ if (found > -1 && !/comment/.test(self.getTokenTypeAt(Pos(i, found + 1)))) found = -1;
143
+ if (found == -1 && (i != end || i == start) && nonWS.test(line)) break lineComment;
144
+ if (found > -1 && nonWS.test(line.slice(0, found))) break lineComment;
145
+ lines.push(line);
146
+ }
147
+ self.operation(function() {
148
+ for (var i = start; i <= end; ++i) {
149
+ var line = lines[i - start];
150
+ var pos = line.indexOf(lineString), endPos = pos + lineString.length;
151
+ if (pos < 0) continue;
152
+ if (line.slice(endPos, endPos + pad.length) == pad) endPos += pad.length;
153
+ didSomething = true;
154
+ self.replaceRange("", Pos(i, pos), Pos(i, endPos));
155
+ }
156
+ });
157
+ if (didSomething) return true;
158
+ }
159
+
160
+ // Try block comments
161
+ var startString = options.blockCommentStart || mode.blockCommentStart;
162
+ var endString = options.blockCommentEnd || mode.blockCommentEnd;
163
+ if (!startString || !endString) return false;
164
+ var lead = options.blockCommentLead || mode.blockCommentLead;
165
+ var startLine = self.getLine(start), endLine = end == start ? startLine : self.getLine(end);
166
+ var open = startLine.indexOf(startString), close = endLine.lastIndexOf(endString);
167
+ if (close == -1 && start != end) {
168
+ endLine = self.getLine(--end);
169
+ close = endLine.lastIndexOf(endString);
170
+ }
171
+ if (open == -1 || close == -1 ||
172
+ !/comment/.test(self.getTokenTypeAt(Pos(start, open + 1))) ||
173
+ !/comment/.test(self.getTokenTypeAt(Pos(end, close + 1))))
174
+ return false;
175
+
176
+ // Avoid killing block comments completely outside the selection.
177
+ // Positions of the last startString before the start of the selection, and the first endString after it.
178
+ var lastStart = startLine.lastIndexOf(startString, from.ch);
179
+ var firstEnd = lastStart == -1 ? -1 : startLine.slice(0, from.ch).indexOf(endString, lastStart + startString.length);
180
+ if (lastStart != -1 && firstEnd != -1 && firstEnd + endString.length != from.ch) return false;
181
+ // Positions of the first endString after the end of the selection, and the last startString before it.
182
+ firstEnd = endLine.indexOf(endString, to.ch);
183
+ var almostLastStart = endLine.slice(to.ch).lastIndexOf(startString, firstEnd - to.ch);
184
+ lastStart = (firstEnd == -1 || almostLastStart == -1) ? -1 : to.ch + almostLastStart;
185
+ if (firstEnd != -1 && lastStart != -1 && lastStart != to.ch) return false;
186
+
187
+ self.operation(function() {
188
+ self.replaceRange("", Pos(end, close - (pad && endLine.slice(close - pad.length, close) == pad ? pad.length : 0)),
189
+ Pos(end, close + endString.length));
190
+ var openEnd = open + startString.length;
191
+ if (pad && startLine.slice(openEnd, openEnd + pad.length) == pad) openEnd += pad.length;
192
+ self.replaceRange("", Pos(start, open), Pos(start, openEnd));
193
+ if (lead) for (var i = start + 1; i <= end; ++i) {
194
+ var line = self.getLine(i), found = line.indexOf(lead);
195
+ if (found == -1 || nonWS.test(line.slice(0, found))) continue;
196
+ var foundEnd = found + lead.length;
197
+ if (pad && line.slice(foundEnd, foundEnd + pad.length) == pad) foundEnd += pad.length;
198
+ self.replaceRange("", Pos(i, found), Pos(i, foundEnd));
199
+ }
200
+ });
201
+ return true;
202
+ });
203
+ });