Răsfoiți Sursa

Mathjax init handling

NGPixel 8 ani în urmă
părinte
comite
b004362aba
6 a modificat fișierele cu 51 adăugiri și 20 ștergeri
  1. 1 0
      .gitignore
  2. 7 1
      client/js/pages/view.js
  3. 4 0
      client/js/pre-init/mathjax.js
  4. 20 0
      fuse.js
  5. 17 17
      package.json
  6. 2 2
      views/layout.pug

+ 1 - 0
.gitignore

@@ -25,6 +25,7 @@ newrelic.js
 
 # Fusebox
 .fusebox
+.build
 
 # Config Files
 config.yml

+ 7 - 1
client/js/pages/view.js

@@ -19,8 +19,14 @@ module.exports = (alerts) => {
         scale: 120,
         font: 'STIX-Web'
       },
-      showMathMenu: false
+      tex2jax: {
+        preview: 'none'
+      },
+      showMathMenu: false,
+      showProcessingMessages: false,
+      messageStyle: 'none'
     })
+    MathJax.Hub.Configured()
 
     require('../modals/create.js')(currentBasePath)
     require('../modals/move.js')(currentBasePath, alerts)

+ 4 - 0
client/js/pre-init/mathjax.js

@@ -0,0 +1,4 @@
+window.MathJax = {
+  root: '/js/mathjax',
+  delayStartupUntil: 'configured'
+}

+ 20 - 0
fuse.js

@@ -56,6 +56,10 @@ const ALIASES = {
   'vue': 'vue/dist/vue.min.js'
 }
 const SHIMS = {
+  _preinit: {
+    source: '.build/_preinit.js',
+    exports: '_preinit'
+  },
   jquery: {
     source: 'node_modules/jquery/dist/jquery.js',
     exports: '$'
@@ -72,6 +76,7 @@ const SHIMS = {
 
 console.info(colors.white('└── ') + colors.green('Running global tasks...'))
 
+let preInitContent = ''
 let globalTasks = Promise.mapSeries([
   /**
    * ACE Modes
@@ -144,6 +149,20 @@ let globalTasks = Promise.mapSeries([
         throw err
       }
     })
+  },
+  /**
+   * Bundle pre-init scripts
+   */
+  () => {
+    console.info(colors.white('  └── ') + colors.green('Bundling pre-init scripts...'))
+    return fs.readdirAsync('./client/js/pre-init').map(f => {
+      let fPath = path.join('./client/js/pre-init/', f)
+      return fs.readFileAsync(fPath, 'utf8').then(fContent => {
+        preInitContent += fContent + ';\n'
+      })
+    }).then(() => {
+      return fs.outputFileAsync('./.build/_preinit.js', preInitContent, 'utf8')
+    })
   }
 ], f => { return f() })
 
@@ -251,6 +270,7 @@ globalTasks.then(() => {
         shim: SHIMS,
         plugins: [
           fsbx.EnvPlugin({ NODE_ENV: 'production' }),
+          fsbx.BannerPlugin(preInitContent),
           [ fsbx.SassPlugin({ outputStyle: 'compressed', includePaths: ['./node_modules/requarks-core'] }), fsbx.CSSPlugin() ],
           fsbx.BabelPlugin({
             config: {

+ 17 - 17
package.json

@@ -41,12 +41,12 @@
     "auto-load": "^2.1.0",
     "axios": "^0.16.1",
     "bcryptjs-then": "^1.0.1",
-    "bluebird": "^3.4.7",
+    "bluebird": "^3.5.0",
     "body-parser": "^1.17.1",
-    "bunyan": "^1.8.9",
+    "bunyan": "^1.8.10",
     "cheerio": "^0.22.0",
     "child-process-promise": "^2.2.1",
-    "chokidar": "^1.6.0",
+    "chokidar": "^1.6.1",
     "commander": "^2.9.0",
     "compression": "^1.6.2",
     "connect-flash": "^0.1.1",
@@ -55,17 +55,17 @@
     "cron": "^1.2.1",
     "execa": "^0.6.3",
     "express": "^4.15.2",
-    "express-brute": "^1.0.0",
+    "express-brute": "^1.0.1",
     "express-brute-mongoose": "0.0.8",
     "express-session": "^1.15.2",
-    "file-type": "^4.0.0",
+    "file-type": "^4.1.0",
     "filesize.js": "^1.0.2",
     "follow-redirects": "^1.2.3",
     "fs-extra": "^2.1.2",
     "git-wrapper2-promise": "^0.2.9",
-    "highlight.js": "^9.9.0",
-    "i18next": "^7.1.3",
-    "i18next-express-middleware": "^1.0.3",
+    "highlight.js": "^9.10.0",
+    "i18next": "^7.2.3",
+    "i18next-express-middleware": "^1.0.4",
     "i18next-node-fs-backend": "^0.1.3",
     "image-size": "^0.5.1",
     "jimp": "github:ngpixel/jimp",
@@ -73,8 +73,8 @@
     "jsonwebtoken": "^7.3.0",
     "klaw": "^1.3.1",
     "levelup": "^1.3.5",
-    "lodash": "^4.17.3",
-    "markdown-it": "^8.3.0",
+    "lodash": "^4.17.4",
+    "markdown-it": "^8.3.1",
     "markdown-it-abbr": "^1.0.4",
     "markdown-it-anchor": "^4.0.0",
     "markdown-it-attrs": "^0.8.0",
@@ -89,8 +89,8 @@
     "moment": "^2.18.1",
     "moment-timezone": "^0.5.13",
     "mongodb": "^2.2.25",
-    "mongoose": "^4.9.2",
-    "multer": "^1.2.1",
+    "mongoose": "^4.9.4",
+    "multer": "^1.3.0",
     "ora": "^1.2.0",
     "passport": "^0.3.2",
     "passport-azure-ad-oauth2": "0.0.4",
@@ -129,7 +129,7 @@
     "brace": "^0.10.0",
     "colors": "^1.1.2",
     "eslint": "latest",
-    "eslint-config-standard": "^10.2.0",
+    "eslint-config-standard": "^10.2.1",
     "eslint-plugin-import": "latest",
     "eslint-plugin-node": "latest",
     "eslint-plugin-promise": "latest",
@@ -139,15 +139,15 @@
     "jquery": "^3.2.1",
     "jquery-contextmenu": "^2.4.4",
     "jquery-simple-upload": "^1.0.0",
-    "jquery-smooth-scroll": "^2.0.0",
+    "jquery-smooth-scroll": "^2.1.2",
     "mathjax": "^2.7.0",
     "node-sass": "latest",
     "nodemon": "latest",
     "pug-lint": "latest",
-    "snyk": "^1.27.1",
-    "standard": "^10.0.1",
+    "snyk": "^1.28.1",
+    "standard": "^10.0.2",
     "sticky-js": "^1.1.9",
-    "twemoji-awesome": "^1.0.4",
+    "twemoji-awesome": "^1.0.6",
     "uglify-js": "latest",
     "vee-validate": "^2.0.0-beta.25",
     "vue": "^2.2.6"

+ 2 - 2
views/layout.pug

@@ -18,8 +18,8 @@ html
     link(rel='manifest', href='/manifest.json')
 
     // JS / CSS
-    script(type='text/javascript').
-      window.MathJax = { root:"/js/mathjax" }
+    //script(type='text/javascript').
+      
     script(type='text/javascript', src='/js/bundle.min.js')
 
     block head