about summary refs log tree commit diff
path: root/config
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2019-08-15 15:13:26 +0200
committerGitHub <noreply@github.com>2019-08-15 15:13:26 +0200
commit28636f43e4b0c04befa243b847c38e81c90f1289 (patch)
treec0c2210eb09026e02dde629cdb6899893c360437 /config
parentf178a01c11a4af077926dd035a0c4c44f6b3985c (diff)
Add OCR tool to media editing modal (#11566)
Diffstat (limited to 'config')
-rw-r--r--config/initializers/content_security_policy.rb8
-rw-r--r--config/webpack/development.js1
-rw-r--r--config/webpack/shared.js5
3 files changed, 10 insertions, 4 deletions
diff --git a/config/initializers/content_security_policy.rb b/config/initializers/content_security_policy.rb
index 59cfbba17..56e997933 100644
--- a/config/initializers/content_security_policy.rb
+++ b/config/initializers/content_security_policy.rb
@@ -20,11 +20,11 @@ Rails.application.config.content_security_policy do |p|
   if Rails.env.development?
     webpacker_urls = %w(ws http).map { |protocol| "#{protocol}#{Webpacker.dev_server.https? ? 's' : ''}://#{Webpacker.dev_server.host_with_port}" }
 
-    p.connect_src :self, :blob, assets_host, Rails.configuration.x.streaming_api_base_url, *webpacker_urls
-    p.script_src  :self, :unsafe_inline, :unsafe_eval, assets_host
+    p.connect_src :self, :data, :blob, assets_host, Rails.configuration.x.streaming_api_base_url, *webpacker_urls
+    p.script_src  :self, :blob, :unsafe_inline, :unsafe_eval, assets_host
   else
-    p.connect_src :self, :blob, assets_host, Rails.configuration.x.streaming_api_base_url
-    p.script_src  :self, assets_host
+    p.connect_src :self, :data, :blob, assets_host, Rails.configuration.x.streaming_api_base_url
+    p.script_src  :self, :blob, assets_host
   end
 end
 
diff --git a/config/webpack/development.js b/config/webpack/development.js
index 1e50a4f46..56f6e43f0 100644
--- a/config/webpack/development.js
+++ b/config/webpack/development.js
@@ -56,5 +56,6 @@ module.exports = merge(sharedConfig, {
       settings.dev_server.watch_options,
       watchOptions
     ),
+    writeToDisk: filePath => /ocr/.test(filePath),
   },
 });
diff --git a/config/webpack/shared.js b/config/webpack/shared.js
index cb4e5a85f..d5e399ced 100644
--- a/config/webpack/shared.js
+++ b/config/webpack/shared.js
@@ -5,6 +5,7 @@ const { basename, dirname, join, relative, resolve } = require('path');
 const { sync } = require('glob');
 const MiniCssExtractPlugin = require('mini-css-extract-plugin');
 const AssetsManifestPlugin = require('webpack-assets-manifest');
+const CopyPlugin = require('copy-webpack-plugin');
 const extname = require('path-complete-extname');
 const { env, settings, themes, output } = require('./configuration');
 const rules = require('./rules');
@@ -84,6 +85,10 @@ module.exports = {
       writeToDisk: true,
       publicPath: true,
     }),
+    new CopyPlugin([
+      { from: 'node_modules/tesseract.js/dist/worker.min.js', to: 'ocr' },
+      { from: 'node_modules/tesseract.js-core/tesseract-core.wasm.js', to: 'ocr' },
+    ]),
   ],
 
   resolve: {