diff --git a/Gemfile b/Gemfile index 618a1a4ae..0ea1ff9c8 100644 --- a/Gemfile +++ b/Gemfile @@ -52,6 +52,7 @@ gem "i18n-js", "~> 3.9.0" # Helps with internationalization in Rails. gem "imgproxy", "~> 2.0" # A gem that easily generates imgproxy URLs for your images gem "inline_svg", "~> 1.7" # Embed SVG documents in your Rails views and style them with CSS gem "jbuilder", "~> 2.11" # Create JSON structures via a Builder-style DSL +gem "js-routes", "~> 2.1" # Brings Rails named routes to javascript gem "jsonapi-serializer", "~> 2.2" # Serializer for Ruby objects gem "kaminari", "~> 1.2" # A Scope & Engine based, clean, powerful, customizable and sophisticated paginator gem "katex", "~> 0.8.0" # This rubygem enables you to render TeX math to HTML using KaTeX. It uses ExecJS under the hood diff --git a/Gemfile.lock b/Gemfile.lock index 82979385e..f98b55ad3 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -415,6 +415,8 @@ GEM actionpack (>= 3.1) railties (>= 3.1) sass (>= 3.2) + js-routes (2.1.1) + railties (>= 4) json (2.5.1) jsonapi-serializer (2.2.0) activesupport (>= 4.2) @@ -943,6 +945,7 @@ DEPENDENCIES imgproxy (~> 2.0) inline_svg (~> 1.7) jbuilder (~> 2.11) + js-routes (~> 2.1) jsonapi-serializer (~> 2.2) kaminari (~> 1.2) katex (~> 0.8.0) diff --git a/app/javascript/routes.js.erb b/app/javascript/routes.js.erb new file mode 100644 index 000000000..5965eb2ae --- /dev/null +++ b/app/javascript/routes.js.erb @@ -0,0 +1 @@ +<%= JsRoutes.generate %> diff --git a/config/initializers/js_routes.rb b/config/initializers/js_routes.rb new file mode 100644 index 000000000..7e1ac7252 --- /dev/null +++ b/config/initializers/js_routes.rb @@ -0,0 +1,6 @@ +JsRoutes.setup do |c| + c.camel_case = true + # Setup your JS module system: + # ESM, CJS, AMD, UMD or nil + # c.module_type = "ESM" +end diff --git a/vendor/cache/js-routes-2.1.1.gem b/vendor/cache/js-routes-2.1.1.gem new file mode 100644 index 000000000..c00c5ea0d Binary files /dev/null and b/vendor/cache/js-routes-2.1.1.gem differ