]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - app/Resources/static/themes/_global/index.js
Highlight code in articles using highlight.js
[github/wallabag/wallabag.git] / app / Resources / static / themes / _global / index.js
index 00410754a244209c8b07bfa3dabb4152825626a2..7f7e87c0e6bbf954ab683105bb30c5b6d1d03fec 100644 (file)
@@ -9,12 +9,14 @@ import 'material-design-icons-iconfont/dist/material-design-icons.css';
 import 'lato-font/css/lato-font.css';
 import './global.scss';
 
-/* Shortcuts*/
+/* Shortcuts */
 import './js/shortcuts/entry';
 import './js/shortcuts/main';
 
-import { savePercent, retrievePercent } from './js/tools';
+/* Hightlight */
+import './js/highlight';
 
+import { savePercent, retrievePercent } from './js/tools';
 
 /* ==========================================================================
  Annotations & Remember position
@@ -28,8 +30,27 @@ $(document).ready(() => {
       element: document.querySelector('article'),
     });
 
+    const authorization = {
+      permits() { return true; },
+    };
+    app.registry.registerUtility(authorization, 'authorizationPolicy');
+
     const x = JSON.parse($('#annotationroutes').html());
-    app.include(annotator.storage.http, x);
+    app.include(annotator.storage.http, $.extend({}, x, {
+      onError(msg, xhr) {
+        if (!Object.prototype.hasOwnProperty.call(xhr, 'responseJSON')) {
+          annotator.notification.banner('An error occurred', 'error');
+          return;
+        }
+        $.each(xhr.responseJSON.children, (k, v) => {
+          if (v.errors) {
+            $.each(v.errors, (n, errorText) => {
+              annotator.notification.banner(errorText, 'error');
+            });
+          }
+        });
+      },
+    }));
 
     app.start().then(() => {
       app.annotations.load({ entry: x.entryId });