diff options
-rw-r--r-- | .gitignore | 4 | ||||
-rw-r--r-- | bower.json | 32 | ||||
-rw-r--r-- | package.json | 82 | ||||
-rw-r--r-- | public/js/common.js | 38 | ||||
-rw-r--r-- | public/js/config.js.example | 17 | ||||
-rw-r--r-- | public/js/cover.js | 33 | ||||
-rw-r--r-- | public/js/extra.js | 182 | ||||
-rw-r--r-- | public/js/history.js | 28 | ||||
-rw-r--r-- | public/js/index.js | 115 | ||||
-rw-r--r-- | public/js/locale.js | 4 | ||||
-rw-r--r-- | public/js/pretty.js | 23 | ||||
-rw-r--r-- | public/js/public.js | 27 | ||||
-rw-r--r-- | public/js/render.js | 7 | ||||
-rw-r--r-- | public/js/slide.js | 42 | ||||
-rw-r--r-- | public/js/syncscroll.js | 40 | ||||
-rw-r--r-- | public/vendor/codemirror-spell-checker/spell-checker.min.js | 2 | ||||
-rw-r--r-- | public/views/foot.ejs | 69 | ||||
-rw-r--r-- | public/views/head.ejs | 9 | ||||
-rw-r--r-- | public/views/includes/header.ejs | 3 | ||||
-rw-r--r-- | public/views/includes/scripts.ejs | 3 | ||||
-rw-r--r-- | public/views/index.ejs | 20 | ||||
-rw-r--r-- | public/views/pretty.ejs | 54 | ||||
-rw-r--r-- | public/views/slide.ejs | 44 | ||||
-rw-r--r-- | webpack.config.js | 3 | ||||
-rw-r--r-- | webpack.production.js | 91 | ||||
-rw-r--r-- | webpackBaseConfig.js | 174 |
26 files changed, 818 insertions, 328 deletions
@@ -21,3 +21,7 @@ backups/ config.json public/js/config.js .sequelizerc + +# ignore webpack build +public/build +public/views/build @@ -16,51 +16,21 @@ ], "dependencies": { "bootstrap": "~3.3.7", - "jquery": "~3.1.1", "font-awesome": "~4.6.3", "Ionicons": "ionicons#~2.0.1", "reveal.js": "~3.3.0", - "jquery-mousewheel": "~3.1.13", "spin.js": "~2.3.2", "moment": "~2.15.1", "handlebars": "~4.0.5", - "js-url": "~2.3.0", - "socket.io-client": "~1.5.0", - "viz.js": "~1.3.0", "js-yaml": "~3.6.1", - "to-markdown": "~3.0.1", - "lz-string": "~1.4.4", "raphael": "~2.2.6", - "flowchart": "~1.6.3", - "xss": "~0.2.13", - "markdown-it": "^8.0.0", - "markdown-it-abbr": "^1.0.4", - "markdown-it-footnote": "^3.0.1", - "markdown-it-deflist": "^2.0.1", - "markdown-it-mark": "^2.0.0", - "markdown-it-ins": "^2.0.0", - "markdown-it-sub": "^1.0.0", - "markdown-it-sup": "^1.0.0", - "markdown-it-container": "^2.0.0", "mermaid": "^6.0.0", "MathJax": "^2.6.1", "octicons": "~3.5.0", "velocity": "^1.3.1", - "highlightjs": "^9.7.0", - "lodash": "^4.16.4", "randomcolor": "randomColor#^0.4.4", - "file-saver": "FileSaver#^1.3.1", "Idle.Js": "idle.js#^1.0.0", - "js-cookie": "^2.1.3", - "list.js": "^1.2.0", - "store-js": "store.js#^1.3.20", - "string": "^3.3.3", - "visibilityjs": "^1.2.4", - "pdfobject": "pdfobject2#*", - "gist-embed": "*", - "keymaster": "^1.6.3", - "prism": "^1.5.1", - "list.pagination.js": "^0.1.1" + "gist-embed": "*" }, "resolutions": { "jquery": "~3.1.1" diff --git a/package.json b/package.json index 7051affb..03333fb8 100644 --- a/package.json +++ b/package.json @@ -4,10 +4,16 @@ "description": "Realtime collaborative markdown notes on all platforms.", "main": "app.js", "license": "MIT", + "scripts": { + "dev": "webpack --config webpack.config.js --progress --colors --watch", + "build": "webpack --config webpack.production.js --progress --colors" + }, "dependencies": { + "Idle.Js": "github:shawnmclean/Idle.js", "async": "^2.0.1", "blueimp-md5": "^2.4.0", "body-parser": "^1.15.2", + "bootstrap": "^3.3.7", "chance": "^1.0.4", "cheerio": "^0.22.0", "compression": "^1.6.2", @@ -17,15 +23,44 @@ "diff-match-patch": "git+https://github.com/hackmdio/diff-match-patch.git", "ejs": "^2.5.2", "emojify.js": "^1.1.0", + "engine.io-client": "^1.7.0", "express": ">=4.14", "express-session": "^1.14.1", + "file-saver": "^1.3.3", + "flowchart.js": "^1.6.3", "formidable": "^1.0.17", + "gist-embed": "github:yukaii/gist-embed", + "handlebars": "^4.0.5", "helmet": "^2.3.0", + "highlight.js": "^9.7.0", "i18n": "^0.8.3", "imgur": "git+https://github.com/hackmdio/node-imgur.git", + "jquery": "^3.1.1", + "jquery-mousewheel": "^3.1.13", + "jquery-scrollspy": "github:softwarespot/jquery-scrollspy", + "jquery-textcomplete": "^1.7.3", + "jquery-ui": "^1.12.1", + "js-cookie": "^2.1.3", + "js-sequence-diagrams": "^1000000.0.6", + "js-url": "^2.3.0", "jsdom-nogyp": "^0.8.3", + "keymaster": "^1.6.2", + "list.js": "^1.2.0", + "list.pagination.js": "^0.1.1", + "lodash": "^4.16.4", "lz-string": "1.4.4", "markdown-it": "^8.0.0", + "markdown-it-abbr": "^1.0.4", + "markdown-it-container": "^2.0.0", + "markdown-it-deflist": "^2.0.1", + "markdown-it-footnote": "^3.0.1", + "markdown-it-imsize": "^2.0.1", + "markdown-it-ins": "^2.0.0", + "markdown-it-mark": "^2.0.0", + "markdown-it-mathjax": "^1.0.3", + "markdown-it-regexp": "^0.4.0", + "markdown-it-sub": "^1.0.0", + "markdown-it-sup": "^1.0.0", "markdown-pdf": "^7.0.0", "meta-marked": "^0.4.2", "method-override": "^2.3.6", @@ -41,30 +76,69 @@ "passport-google-oauth20": "^1.0.0", "passport-twitter": "^1.0.4", "passport.socketio": "^3.6.2", + "pdfobject": "^2.0.201604172", "pg": "^6.1.0", "pg-hstore": "^2.3.2", + "prismjs": "^1.5.1", "randomcolor": "^0.4.4", + "raphael": "github:dmitrybaranovskiy/raphael", "request": "^2.75.0", - "reveal.js": "3.3.0", + "reveal.js": "^3.3.0", "sequelize": "^3.24.3", "sequelize-cli": "^2.4.0", "shortid": "2.2.6", "socket.io": "1.5.0", + "socket.io-client": "^1.5.0", + "spin.js": "^2.3.2", "sqlite3": "^3.1.6", + "store": "^1.3.20", "string": "^3.3.1", "tedious": "^1.14.0", + "to-markdown": "^3.0.1", "toobusy-js": "^0.5.1", - "winston": "^2.2.0" + "visibilityjs": "^1.2.4", + "viz.js": "^1.3.0", + "winston": "^2.2.0", + "xss": "^0.2.13" }, "engines": { "node": ">=4.x" }, "bugs": "https://github.com/hackmdio/hackmd/issues", - "keywords": ["Collaborative", "Markdown", "Notes"], + "keywords": [ + "Collaborative", + "Markdown", + "Notes" + ], "homepage": "https://hackmd.io", - "maintainers": [{"name": "Max Wu", "email": "jackymaxj@gmail.com"}], + "maintainers": [ + { + "name": "Max Wu", + "email": "jackymaxj@gmail.com" + } + ], "repository": { "type": "git", "url": "https://github.com/hackmdio/hackmd.git" + }, + "devDependencies": { + "babel-core": "^6.17.0", + "babel-loader": "^6.2.5", + "bower-webpack-plugin": "^0.1.9", + "css-loader": "^0.25.0", + "ejs-loader": "^0.3.0", + "exports-loader": "^0.6.3", + "expose-loader": "^0.7.1", + "extract-text-webpack-plugin": "^1.0.1", + "file-loader": "^0.9.0", + "html-webpack-plugin": "^2.22.0", + "imports-loader": "^0.6.5", + "json-loader": "^0.5.4", + "less": "^2.7.1", + "less-loader": "^2.2.3", + "script-loader": "^0.7.0", + "style-loader": "^0.13.1", + "url-loader": "^0.5.7", + "webpack": "^1.13.2" } } diff --git a/public/js/common.js b/public/js/common.js index 047df8af..19455f3d 100644 --- a/public/js/common.js +++ b/public/js/common.js @@ -1,3 +1,11 @@ +var config = require('./config'); +var domain = config.domain; // domain name +var urlpath = config.urlpath; // sub url path, like: www.example.com/<urlpath> +var debug = config.debug; +var GOOGLE_API_KEY = config.GOOGLE_API_KEY; +var GOOGLE_CLIENT_ID = config.GOOGLE_CLIENT_ID; +var DROPBOX_APP_KEY = config.DROPBOX_APP_KEY; + //common var port = window.location.port; var serverurl = window.location.protocol + '//' + (domain ? domain : window.location.hostname) + (port ? ':' + port : '') + (urlpath ? '/' + urlpath : ''); @@ -82,4 +90,32 @@ function checkIfAuth(yesCallback, noCallback) { } else { noCallback(); } -}
\ No newline at end of file +} + +module.exports = { + domain: domain, + urlpath: urlpath, + debug: debug, + GOOGLE_API_KEY: GOOGLE_API_KEY, + GOOGLE_CLIENT_ID: GOOGLE_CLIENT_ID, + DROPBOX_APP_KEY: DROPBOX_APP_KEY, + port: port, + serverurl: serverurl, + noteid: noteid, + noteurl: noteurl, + version: version, + checkAuth: checkAuth, + profile: profile, + lastLoginState: lastLoginState, + lastUserId: lastUserId, + loginStateChangeEvent: loginStateChangeEvent, + + /* export functions */ + resetCheckAuth: resetCheckAuth, + setLoginState: setLoginState, + checkLoginStateChanged: checkLoginStateChanged, + getLoginState: getLoginState, + getUserId: getUserId, + clearLoginState: clearLoginState, + checkIfAuth: checkIfAuth +}; diff --git a/public/js/config.js.example b/public/js/config.js.example index 197d18f2..c5de388f 100644 --- a/public/js/config.js.example +++ b/public/js/config.js.example @@ -1,10 +1,11 @@ -//config -var domain = ''; // domain name -var urlpath = ''; // sub url path, like: www.example.com/<urlpath> -//settings -var debug = false; +module.exports = { + domain: '', // domain name + urlpath: '', // sub url path, like: www.example.com/<urlpath> -var GOOGLE_API_KEY = ''; -var GOOGLE_CLIENT_ID = ''; + // settings + debug: false, -var DROPBOX_APP_KEY = '';
\ No newline at end of file + GOOGLE_API_KEY: '', + GOOGLE_CLIENT_ID: '', + DROPBOX_APP_KEY: '' +}; diff --git a/public/js/cover.js b/public/js/cover.js index 3f9d787e..30a8e5c8 100644 --- a/public/js/cover.js +++ b/public/js/cover.js @@ -1,3 +1,26 @@ +var common = require('./common'); +var checkIfAuth = common.checkIfAuth; +var urlpath = common.urlpath; +var serverurl = common.serverurl; +var resetCheckAuth = common.resetCheckAuth; +var getLoginState = common.getLoginState; +var clearLoginState = common.clearLoginState; + +var historyModule = require('./history'); +var parseStorageToHistory = historyModule.parseStorageToHistory; +var parseHistory = historyModule.parseHistory; +var getStorageHistory = historyModule.getStorageHistory; +var getHistory = historyModule.getHistory; +var saveHistory = historyModule.saveHistory; +var removeHistory = historyModule.removeHistory; +var postHistoryToServer = historyModule.postHistoryToServer; +var deleteServerHistory = historyModule.deleteServerHistory; +var parseServerToHistory = historyModule.parseServerToHistory; +var saveStorageHistoryToServer = historyModule.saveStorageHistoryToServer; + +var saveAs = require('file-saver').saveAs; +var List = require('list.js'); + var options = { valueNames: ['id', 'text', 'timestamp', 'fromNow', 'time', 'tags', 'pinned'], item: '<li class="col-xs-12 col-sm-6 col-md-6 col-lg-4">\ @@ -199,7 +222,7 @@ function historyPinClick(e) { $this.addClass('active'); else $this.removeClass('active'); - } + } }); }, function () { getHistory(function (notehistory) { @@ -317,7 +340,7 @@ $(".ui-clear-history").click(function () { }); $(".ui-refresh-history").click(function () { - var lastTags = $(".ui-use-tags").select2('val'); + var lastTags = $(".ui-use-tags").select2('val'); $(".ui-use-tags").select2('val', ''); historyList.filter(); var lastKeyword = $('.search').val(); @@ -325,10 +348,10 @@ $(".ui-refresh-history").click(function () { historyList.search(); $('#history-list').slideUp('fast'); $('.pagination').slideUp('fast'); - + resetCheckAuth(); historyList.clear(); - parseHistory(historyList, function (list, notehistory) { + parseHistory(historyList, function (list, notehistory) { parseHistoryCallback(list, notehistory); $(".ui-use-tags").select2('val', lastTags); $(".ui-use-tags").trigger('change'); @@ -392,4 +415,4 @@ $(".ui-use-tags").on('change', function () { $('.search').keyup(function () { checkHistoryList(); -});
\ No newline at end of file +}); diff --git a/public/js/extra.js b/public/js/extra.js index 4a6c4a67..24d53fe7 100644 --- a/public/js/extra.js +++ b/public/js/extra.js @@ -1,3 +1,9 @@ +var hljs = require('highlight.js'); +var PDFObject = require('pdfobject'); +var S = require('string'); +var saveAs = require('file-saver').saveAs; +require('../vendor/md-toc'); + //auto update last change var createtime = null; var lastchangetime = null; @@ -242,7 +248,7 @@ function finishView(view) { }); //emojify try { - emojify.run(view[0]); + emojify.run(view[0]); } catch (err) { console.warn(err); } @@ -257,77 +263,79 @@ function finishView(view) { MathJax.Hub.Queue(viewAjaxCallback); } } catch (err) {} - //sequence diagram - var sequences = view.find(".sequence-diagram.raw").removeClass("raw"); - sequences.each(function (key, value) { - try { - var $value = $(value); - var $ele = $(value).parent().parent(); - - var sequence = $value; - sequence.sequenceDiagram({ - theme: 'simple' - }); - - $ele.addClass('sequence-diagram'); - $value.children().unwrap().unwrap(); - var svg = $ele.find('> svg'); - svg[0].setAttribute('viewBox', '0 0 ' + svg.attr('width') + ' ' + svg.attr('height')); - svg[0].setAttribute('preserveAspectRatio', 'xMidYMid meet'); - } catch (err) { - console.warn(err); - } - }); - //flowchart - var flow = view.find(".flow-chart.raw").removeClass("raw"); - flow.each(function (key, value) { - try { - var $value = $(value); - var $ele = $(value).parent().parent(); - - var chart = flowchart.parse($value.text()); - $value.html(''); - chart.drawSVG(value, { - 'line-width': 2, - 'fill': 'none', - 'font-size': '16px', - 'font-family': "'Andale Mono', monospace" - }); - - $ele.addClass('flow-chart'); - $value.children().unwrap().unwrap(); - } catch (err) { - console.warn(err); - } - }); + //sequence diagram + var sequences = view.find(".sequence-diagram.raw").removeClass("raw"); + sequences.each(function (key, value) { + try { + var $value = $(value); + var $ele = $(value).parent().parent(); + + var sequence = $value; + sequence.sequenceDiagram({ + theme: 'simple' + }); + + $ele.addClass('sequence-diagram'); + $value.children().unwrap().unwrap(); + var svg = $ele.find('> svg'); + svg[0].setAttribute('viewBox', '0 0 ' + svg.attr('width') + ' ' + svg.attr('height')); + svg[0].setAttribute('preserveAspectRatio', 'xMidYMid meet'); + } catch (err) { + console.warn(err); + } + }); + //flowchart + var flow = view.find(".flow-chart.raw").removeClass("raw"); + flow.each(function (key, value) { + try { + var $value = $(value); + var $ele = $(value).parent().parent(); + + var chart = flowchart.parse($value.text()); + $value.html(''); + chart.drawSVG(value, { + 'line-width': 2, + 'fill': 'none', + 'font-size': '16px', + 'font-family': "'Andale Mono', monospace" + }); + + $ele.addClass('flow-chart'); + $value.children().unwrap().unwrap(); + } catch (err) { + console.warn(err); + } + }); //graphviz + var Viz = require("viz.js"); var graphvizs = view.find(".graphviz.raw").removeClass("raw"); graphvizs.each(function (key, value) { try { var $value = $(value); var $ele = $(value).parent().parent(); - + var graphviz = Viz($value.text()); $value.html(graphviz); - + $ele.addClass('graphviz'); $value.children().unwrap().unwrap(); } catch (err) { console.warn(err); } }); + //mermaid var mermaids = view.find(".mermaid.raw").removeClass("raw"); mermaids.each(function (key, value) { try { var $value = $(value); var $ele = $(value).parent().parent(); - + var mermaidError = null; mermaid.parseError = function (err, hash) { mermaidError = err; }; - + if (mermaidAPI.parse($value.text())) { $ele.addClass('mermaid'); $ele.html($value.text()); @@ -427,14 +435,14 @@ function finishView(view) { }); //pdf view.find(".pdf.raw").removeClass("raw") - .each(function (key, value) { - var url = $(value).attr('data-pdfurl'); - var inner = $('<div></div>'); - $(this).append(inner); - PDFObject.embed(url, inner, { - height: '400px' + .each(function (key, value) { + var url = $(value).attr('data-pdfurl'); + var inner = $('<div></div>'); + $(this).append(inner); + PDFObject.embed(url, inner, { + height: '400px' + }); }); - }); //syntax highlighting view.find("pre.raw").removeClass("raw") .each(function (key, value) { @@ -483,6 +491,7 @@ function postProcess(code) { } return result; } +window.postProcess = postProcess; function generateCleanHTML(view) { var src = view.clone(); @@ -534,6 +543,8 @@ function exportToRawHTML(view) { saveAs(blob, filename); } +var common = require('./common.js'); +var serverurl = common.serverurl; //extract markdown body to html and compile to template function exportToHTML(view) { var title = renderTitle(ui.area.markdown); @@ -829,7 +840,10 @@ emojify.setConfig({ ignore_emoticons: true }); -var md = window.markdownit('default', { +var markdownit = require('markdown-it'); +var markdownitContainer = require('markdown-it-container'); + +var md = markdownit('default', { html: true, breaks: true, langPrefix: "", @@ -837,25 +851,28 @@ var md = window.markdownit('default', { typographer: true, highlight: highlightRender }); -md.use(window.markdownitAbbr); -md.use(window.markdownitFootnote); -md.use(window.markdownitDeflist); -md.use(window.markdownitMark); -md.use(window.markdownitIns); -md.use(window.markdownitSub); -md.use(window.markdownitSup); -md.use(window.markdownitMathjax); -md.use(window.markdownitImsize); +window.md = md; + +md.use(require('markdown-it-abbr')); +md.use(require('markdown-it-footnote')); +md.use(require('markdown-it-deflist')); +md.use(require('markdown-it-mark')); +md.use(require('markdown-it-ins')); +md.use(require('markdown-it-sub')); +md.use(require('markdown-it-sup')); +md.use(require('../vendor/markdown-it-mathjax')); +md.use(require('markdown-it-imsize')); + function renderContainer(tokens, idx, options, env, self) { tokens[idx].attrJoin('role', 'alert'); tokens[idx].attrJoin('class', 'alert'); tokens[idx].attrJoin('class', 'alert-' + tokens[idx].info.trim()); return self.renderToken.apply(self, arguments); } -md.use(window.markdownitContainer, 'success', { render: renderContainer }); -md.use(window.markdownitContainer, 'info', { render: renderContainer }); -md.use(window.markdownitContainer, 'warning', { render: renderContainer }); -md.use(window.markdownitContainer, 'danger', { render: renderContainer }); +md.use(markdownitContainer, 'success', { render: renderContainer }); +md.use(markdownitContainer, 'info', { render: renderContainer }); +md.use(markdownitContainer, 'warning', { render: renderContainer }); +md.use(markdownitContainer, 'danger', { render: renderContainer }); md.renderer.rules.image = function (tokens, idx, options, env, self) { tokens[idx].attrJoin('class', 'raw'); @@ -900,6 +917,9 @@ md.renderer.rules.fence = function (tokens, idx, options, env, self) { + '</code></pre>\n'; }; +/* Defined regex markdown it plugins */ +require('script!../vendor/markdown-it-regexp'); + //youtube var youtubePlugin = new Plugin( // regexp to match @@ -1046,4 +1066,26 @@ md.use(gistPlugin); md.use(tocPlugin); md.use(slidesharePlugin); md.use(speakerdeckPlugin); -md.use(pdfPlugin);
\ No newline at end of file +md.use(pdfPlugin); + +module.exports = { + md: md, + createtime: createtime, + lastchangetime: lastchangetime, + updateLastChange: updateLastChange, + lastchangeui: lastchangeui, + lastchangeuser: lastchangeuser, + postProcess: postProcess, + finishView: finishView, + autoLinkify: autoLinkify, + deduplicatedHeaderId: deduplicatedHeaderId, + renderTOC: renderTOC, + renderTitle: renderTitle, + renderFilename: renderFilename, + generateToc: generateToc, + smoothHashScroll: smoothHashScroll, + scrollToHash: scrollToHash, + owner: owner, + updateLastChangeUser: updateLastChangeUser, + updateOwner: updateOwner +}; diff --git a/public/js/history.js b/public/js/history.js index 324a9da2..d5082dd9 100644 --- a/public/js/history.js +++ b/public/js/history.js @@ -1,3 +1,15 @@ +var store = require('store'); + +var common = require('./common'); +var checkIfAuth = common.checkIfAuth; +var urlpath = common.urlpath; +var serverurl = common.serverurl; +var getLoginState = common.getLoginState; + +var extra = require('./extra'); +var renderFilename = extra.renderFilename; +var md = extra.md; + var migrateHistoryFromTempCallback = null; migrateHistoryFromTemp(); @@ -392,4 +404,18 @@ function deleteServerHistory(noteId, callback) { console.error(xhr.responseText); return callback(error, null); }); -}
\ No newline at end of file +} + +module.exports = { + writeHistory: writeHistory, + parseHistory: parseHistory, + getStorageHistory: getStorageHistory, + getHistory: getHistory, + saveHistory: saveHistory, + removeHistory: removeHistory, + parseStorageToHistory: parseStorageToHistory, + postHistoryToServer: postHistoryToServer, + deleteServerHistory: deleteServerHistory, + parseServerToHistory: parseServerToHistory, + saveStorageHistoryToServer: saveStorageHistoryToServer +} diff --git a/public/js/index.js b/public/js/index.js index 06be2f77..20a76ff1 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -1,3 +1,68 @@ +/* jquery and jquery plugins */ +require('../vendor/showup/showup'); + +require('prismjs/themes/prism.css'); +require('highlight.js/styles/github-gist.css'); + +require('prismjs'); +require('prismjs/components/prism-wiki'); +var toMarkdown = require('to-markdown'); + +var saveAs = require('file-saver').saveAs; +require('js-url'); +require('randomcolor'); + +var _ = require("lodash"); + +var List = require('list.js'); + +var common = require('./common.js'); +var urlpath = common.urlpath; +var noteid = common.noteid; +var debug = common.debug; +var version = common.version; +var serverurl = common.serverurl; +var GOOGLE_API_KEY = common.GOOGLE_API_KEY; +var GOOGLE_CLIENT_ID = common.GOOGLE_CLIENT_ID; +var DROPBOX_APP_KEY = common.DROPBOX_APP_KEY; +var noteurl = common.noteurl; + +var checkLoginStateChanged = common.checkLoginStateChanged; + +var syncScroll = require('./syncscroll'); +var setupSyncAreas = syncScroll.setupSyncAreas; +var clearMap = syncScroll.clearMap; +var syncScrollToEdit = syncScroll.syncScrollToEdit; +var syncScrollToView = syncScroll.syncScrollToView; + +require('./pretty'); +var extra = require('./extra'); +var md = extra.md; +var createtime = extra.createtime; +var updateLastChange = extra.updateLastChange; +var postProcess = extra.postProcess; +var finishView = extra.finishView; +var lastchangetime = extra.lastchangetime; +var autoLinkify = extra.autoLinkify; +var generateToc = extra.generateToc; +var smoothHashScroll = extra.smoothHashScroll; +var lastchangeuser = extra.lastchangeuser; +var deduplicatedHeaderId = extra.deduplicatedHeaderId; +var renderTOC = extra.renderTOC; +var renderTitle = extra.renderTitle; +var renderFilename = extra.renderFilename; +var scrollToHash = extra.scrollToHash; +var owner = extra.owner; +var updateLastChangeUser = extra.updateLastChangeUser; +var updateOwner = extra.updateOwner; + +var historyModule = require('./history'); +var writeHistory = historyModule.writeHistory; +var deleteServerHistory = historyModule.deleteServerHistory; + +var renderer = require('./render'); +var preventXSS = renderer.preventXSS; + var defaultTextHeight = 20; var viewportMargin = 20; var mac = CodeMirror.keyMap["default"] == CodeMirror.keyMap.macDefault; @@ -127,7 +192,7 @@ function wrapTextWith(cm, symbol) { }; var postText = cm.getRange(postEndPos, from); var postIndex = wrapSymbols.indexOf(postText); - // check if surround symbol are list in array and matched + // check if surround symbol are list in array and matched if (preIndex > -1 && postIndex > -1 && preIndex === postIndex) { cm.replaceRange("", to, preEndPos, '+delete'); cm.replaceRange("", postEndPos, from, '+delete'); @@ -279,7 +344,7 @@ var supportExtraTags = [ } } ]; -var modeType = { +window.modeType = { edit: { name: "edit" }, @@ -310,18 +375,18 @@ var statusType = { var defaultMode = modeType.view; //global vars -var loaded = false; -var needRefresh = false; -var isDirty = false; -var editShown = false; -var visibleXS = false; -var visibleSM = false; -var visibleMD = false; -var visibleLG = false; -var isTouchDevice = 'ontouchstart' in document.documentElement; -var currentMode = defaultMode; -var currentStatus = statusType.offline; -var lastInfo = { +window.loaded = false; +window.needRefresh = false; +window.isDirty = false; +window.editShown = false; +window.visibleXS = false; +window.visibleSM = false; +window.visibleMD = false; +window.visibleLG = false; +window.isTouchDevice = 'ontouchstart' in document.documentElement; +window.currentMode = defaultMode; +window.currentStatus = statusType.offline; +window.lastInfo = { needRestore: false, cursor: null, scroll: null, @@ -343,9 +408,9 @@ var lastInfo = { }, history: null }; -var personalInfo = {}; -var onlineUsers = []; -var fileTypes = { +window.personalInfo = {}; +window.onlineUsers = []; +window.fileTypes = { "pl": "perl", "cgi": "perl", "js": "javascript", @@ -359,7 +424,7 @@ var fileTypes = { //editor settings var textit = document.getElementById("textit"); if (!textit) throw new Error("There was no textit area!"); -var editor = CodeMirror.fromTextArea(textit, { +window.editor = CodeMirror.fromTextArea(textit, { mode: defaultEditorMode, backdrop: defaultEditorMode, keyMap: "sublime", @@ -1047,7 +1112,7 @@ function checkEditorStyle() { }, stop: function (e) { lastEditorWidth = ui.area.edit.width(); - // workaround that scroll event bindings + // workaround that scroll event bindings preventSyncScrollToView = 2; preventSyncScrollToEdit = true; editor.setOption('viewportMargin', viewportMargin); @@ -1281,12 +1346,12 @@ function changeMode(type) { preventSyncScrollToView = 2; syncScrollToEdit(null, true); } - + if (lastMode == modeType.edit && currentMode == modeType.both) { preventSyncScrollToEdit = 2; syncScrollToView(null, true); } - + if (lastMode == modeType.both && currentMode != modeType.both) { preventSyncScrollToView = false; preventSyncScrollToEdit = false; @@ -1389,6 +1454,7 @@ function onGoogleAPILoaded() { .prop('defer', true) .appendTo('body'); } +window.onGoogleAPILoaded = onGoogleAPILoaded; //button actions //share @@ -1687,7 +1753,7 @@ function parseRevisions(_revisions) { } } function selectRevision(time) { - if (time == revisionTime) return; + if (time == revisionTime) return; $.get(noteurl + '/revision/' + time) .done(function(data) { revision = data; @@ -2188,8 +2254,11 @@ function havePermission() { } return bool; } +// global module workaround +window.havePermission = havePermission; //socket.io actions +var io = require("socket.io-client"); var socket = io.connect({ path: urlpath ? '/' + urlpath + '/socket.io/' : '', timeout: 5000 //5 secs to timeout @@ -2198,7 +2267,7 @@ var socket = io.connect({ var on = socket.on; socket.on = function () { if (!checkLoginStateChanged() && !needRefresh) - on.apply(socket, arguments); + return on.apply(socket, arguments); }; var emit = socket.emit; socket.emit = function () { diff --git a/public/js/locale.js b/public/js/locale.js index 6fe7fdb6..484ce22f 100644 --- a/public/js/locale.js +++ b/public/js/locale.js @@ -1,3 +1,5 @@ +require('./cover'); + var lang = "en"; var userLang = navigator.language || navigator.userLanguage; var userLangCode = userLang.split('-')[0]; @@ -21,4 +23,4 @@ locale.change(function() { expires: 365 }); window.location.reload(); -});
\ No newline at end of file +}); diff --git a/public/js/pretty.js b/public/js/pretty.js index 0ca7ee18..6b551c17 100644 --- a/public/js/pretty.js +++ b/public/js/pretty.js @@ -1,3 +1,16 @@ +var extra = require('./extra'); +var md = extra.md; +var finishView = extra.finishView; +var autoLinkify = extra.autoLinkify; +var deduplicatedHeaderId = extra.deduplicatedHeaderId; +var renderTOC = extra.renderTOC; +var generateToc = extra.generateToc; +var smoothHashScroll = extra.smoothHashScroll; +var postProcess = extra.postProcess; +var lastchangeui = extra.lastchangeui; +var updateLastChange = extra.updateLastChange; +var preventXSS = require('./render').preventXSS; + var markdown = $(".markdown-body"); var text = $('<textarea/>').html(markdown.html()).text(); var lastMeta = md.meta; @@ -109,4 +122,12 @@ function scrollToBottom() { $('body, html').stop(true, true).animate({ scrollTop: $(document.body)[0].scrollHeight }, 100, "linear"); -}
\ No newline at end of file +} + +window.scrollToTop = scrollToTop; +window.scrollToBottom = scrollToBottom; + +module.exports = { + scrollToBottom: scrollToBottom, + scrollToTop: scrollToTop +} diff --git a/public/js/public.js b/public/js/public.js new file mode 100644 index 00000000..ac951804 --- /dev/null +++ b/public/js/public.js @@ -0,0 +1,27 @@ +/* jquery and jquery plugins */ +require('../vendor/showup/showup'); + +require('prismjs/themes/prism.css'); +require('highlight.js/styles/github-gist.css'); + +/* other vendors plugin */ +require('gist-embed'); +require('string'); +require('highlight.js'); +require('prismjs'); +require('prismjs/components/prism-wiki'); +require('to-markdown'); + +require('file-saver'); +require('store'); +require('js-url'); +require('visibilityjs'); +require('list.js'); +require('../vendor/md-toc'); +require('randomcolor'); + +require('./syncscroll'); +require('./extra'); +require('./history'); +require('./pretty'); +require('./render'); diff --git a/public/js/render.js b/public/js/render.js index 6f1a1c19..77778795 100644 --- a/public/js/render.js +++ b/public/js/render.js @@ -50,4 +50,9 @@ var filterXSSOptions = { function preventXSS(html) { return filterXSS(html, filterXSSOptions); -}
\ No newline at end of file +} +window.preventXSS = preventXSS; + +module.exports = { + preventXSS: preventXSS +} diff --git a/public/js/slide.js b/public/js/slide.js index 5b0f9bd0..257c60bb 100644 --- a/public/js/slide.js +++ b/public/js/slide.js @@ -1,3 +1,45 @@ +require('prismjs/themes/prism.css'); + +/* other vendors plugin */ +var S = require('string'); +require('prismjs'); +require('prismjs/components/prism-wiki'); +require('to-markdown'); + +require('../vendor/md-toc'); +require('randomcolor'); + +var commonModule = require('./common'); +var urlpath = commonModule.urlpath; +var noteid = commonModule.noteid; +var debug = commonModule.debug; +var version = commonModule.version; +var serverurl = commonModule.serverurl; +var GOOGLE_API_KEY = commonModule.GOOGLE_API_KEY; +var GOOGLE_CLIENT_ID = commonModule.GOOGLE_CLIENT_ID; +var DROPBOX_APP_KEY = commonModule.DROPBOX_APP_KEY; +var noteurl = commonModule.noteurl; + +var extraModule = require('./extra'); +var md = extraModule.md; +var createtime = extraModule.createtime; +var updateLastChange = extraModule.updateLastChange; +var postProcess = extraModule.postProcess; +var finishView = extraModule.finishView; +var lastchangetime = extraModule.lastchangetime; +var lastchangeui = extraModule.lastchangeui; +var autoLinkify = extraModule.autoLinkify; +var generateToc = extraModule.generateToc; +var smoothHashScroll = extraModule.smoothHashScroll; +var lastchangeuser = extraModule.lastchangeuser; +var deduplicatedHeaderId = extraModule.deduplicatedHeaderId; +var renderTOC = extraModule.renderTOC; +var renderTitle = extraModule.renderTitle; +var renderFilename = extraModule.renderFilename; +var scrollToHash = extraModule.scrollToHash; + +var render = require('./render'); + var body = $(".slides").html(); $(".slides").html(S(body).unescapeHTML().s); diff --git a/public/js/syncscroll.js b/public/js/syncscroll.js index 32d3f7a3..511c5000 100644 --- a/public/js/syncscroll.js +++ b/public/js/syncscroll.js @@ -1,5 +1,8 @@ // Inject line numbers for sync scroll. +var extra = require('./extra'); +var md = extra.md; + function addPart(tokens, idx) { if (tokens[idx].map && tokens[idx].level === 0) { var startline = tokens[idx].map[0] + 1; @@ -71,7 +74,7 @@ md.renderer.rules.fence = function (tokens, idx, options, env, self) { if (highlighted.indexOf('<pre') === 0) { return highlighted + '\n'; } - + if (tokens[idx].map && tokens[idx].level === 0) { var startline = tokens[idx].map[0] + 1; var endline = tokens[idx].map[1]; @@ -99,10 +102,12 @@ function renderContainer(tokens, idx, options, env, self) { addPart(tokens, idx); return self.renderToken.apply(self, arguments); } -md.use(window.markdownitContainer, 'success', { render: renderContainer }); -md.use(window.markdownitContainer, 'info', { render: renderContainer }); -md.use(window.markdownitContainer, 'warning', { render: renderContainer }); -md.use(window.markdownitContainer, 'danger', { render: renderContainer }); + +var markdownitContainer = require('markdown-it-container'); +md.use(markdownitContainer, 'success', { render: renderContainer }); +md.use(markdownitContainer, 'info', { render: renderContainer }); +md.use(markdownitContainer, 'warning', { render: renderContainer }); +md.use(markdownitContainer, 'danger', { render: renderContainer }); var syncscroll = true; @@ -240,7 +245,7 @@ function syncScrollToEdit(event, preventAnimate) { return; } if (editScrolling) return; - + var scrollTop = viewArea[0].scrollTop; var lineIndex = 0; for (var i = 0, l = scrollMap.length; i < l; i++) { @@ -260,7 +265,7 @@ function syncScrollToEdit(event, preventAnimate) { lineDiff = lineHeightMap[i + 1] - lineNo; } } - + var posTo = 0; var topDiffPercent = 0; var posToNextDiff = 0; @@ -269,7 +274,7 @@ function syncScrollToEdit(event, preventAnimate) { var preLastLineHeight = scrollInfo.height - scrollInfo.clientHeight - textHeight; var preLastLineNo = Math.round(preLastLineHeight / textHeight); var preLastLinePos = scrollMap[preLastLineNo]; - + if (scrollInfo.height > scrollInfo.clientHeight && scrollTop >= preLastLinePos) { posTo = preLastLineHeight; topDiffPercent = (scrollTop - preLastLinePos) / (viewBottom - preLastLinePos); @@ -281,7 +286,7 @@ function syncScrollToEdit(event, preventAnimate) { posToNextDiff = textHeight * lineDiff * topDiffPercent; posTo += Math.ceil(posToNextDiff); } - + if (preventAnimate) { editArea.scrollTop(posTo); } else { @@ -292,7 +297,7 @@ function syncScrollToEdit(event, preventAnimate) { scrollTop: posTo }, duration, "linear"); } - + viewScrolling = true; clearTimeout(viewScrollingTimer); viewScrollingTimer = setTimeout(viewScrollingTimeoutInner, duration * 1.5); @@ -322,7 +327,7 @@ function syncScrollToView(event, preventAnimate) { return; } if (viewScrolling) return; - + var lineNo, posTo; var topDiffPercent, posToNextDiff; var scrollInfo = editor.getScrollInfo(); @@ -341,7 +346,7 @@ function syncScrollToView(event, preventAnimate) { posToNextDiff = (scrollMap[lineNo + 1] - posTo) * topDiffPercent; posTo += Math.floor(posToNextDiff); } - + if (preventAnimate) { viewArea.scrollTop(posTo); } else { @@ -352,7 +357,7 @@ function syncScrollToView(event, preventAnimate) { scrollTop: posTo }, duration, "linear"); } - + editScrolling = true; clearTimeout(editScrollingTimer); editScrollingTimer = setTimeout(editScrollingTimeoutInner, duration * 1.5); @@ -360,4 +365,11 @@ function syncScrollToView(event, preventAnimate) { function editScrollingTimeoutInner() { editScrolling = false; -}
\ No newline at end of file +} + +module.exports = { + setupSyncAreas: setupSyncAreas, + clearMap: clearMap, + syncScrollToEdit: syncScrollToEdit, + syncScrollToView: syncScrollToView +}; diff --git a/public/vendor/codemirror-spell-checker/spell-checker.min.js b/public/vendor/codemirror-spell-checker/spell-checker.min.js index 4e3921a6..d5dd34d7 100644 --- a/public/vendor/codemirror-spell-checker/spell-checker.min.js +++ b/public/vendor/codemirror-spell-checker/spell-checker.min.js @@ -4,4 +4,4 @@ * @link https://github.com/NextStepWebs/codemirror-spell-checker * @license MIT */ -"use strict";var Typo=function(e,t,r,n){if(n=n||{},this.platform=n.platform||"chrome",this.dictionary=null,this.rules={},this.dictionaryTable={},this.compoundRules=[],this.compoundRuleCodes={},this.replacementTable=[],this.flags=n.flags||{},e){if(this.dictionary=e,"chrome"==this.platform)t||(t=this._readFile(chrome.extension.getURL("lib/typo/dictionaries/"+e+"/"+e+".aff"))),r||(r=this._readFile(chrome.extension.getURL("lib/typo/dictionaries/"+e+"/"+e+".dic")));else{var i=n.dictionaryPath||"";t||(t=this._readFile(i+"/"+e+"/"+e+".aff")),r||(r=this._readFile(i+"/"+e+"/"+e+".dic"))}this.rules=this._parseAFF(t),this.compoundRuleCodes={};for(var a=0,s=this.compoundRules.length;s>a;a++)for(var o=this.compoundRules[a],l=0,u=o.length;u>l;l++)this.compoundRuleCodes[o[l]]=[];"ONLYINCOMPOUND"in this.flags&&(this.compoundRuleCodes[this.flags.ONLYINCOMPOUND]=[]),this.dictionaryTable=this._parseDIC(r);for(var a in this.compoundRuleCodes)0==this.compoundRuleCodes[a].length&&delete this.compoundRuleCodes[a];for(var a=0,s=this.compoundRules.length;s>a;a++){for(var h=this.compoundRules[a],c="",l=0,u=h.length;u>l;l++){var p=h[l];c+=p in this.compoundRuleCodes?"("+this.compoundRuleCodes[p].join("|")+")":p}this.compoundRules[a]=RegExp(c,"i")}}return this};Typo.prototype={load:function(e){for(var t in e)this[t]=e[t];return this},_readFile:function(e,t){t||(t="ISO8859-1");var r=new XMLHttpRequest;return r.open("GET",e,!1),r.overrideMimeType&&r.overrideMimeType("text/plain; charset="+t),r.send(null),r.responseText},_parseAFF:function(e){var t={};e=this._removeAffixComments(e);for(var r=e.split("\n"),n=0,i=r.length;i>n;n++){var a=r[n],s=a.split(/\s+/),o=s[0];if("PFX"==o||"SFX"==o){for(var l=s[1],u=s[2],h=parseInt(s[3],10),c=[],p=n+1,f=n+1+h;f>p;p++){var a=r[p],d=a.split(/\s+/),v=d[2],g=d[3].split("/"),m=g[0];"0"===m&&(m="");var y=this.parseRuleCodes(g[1]),_=d[4],C={};C.add=m,y.length>0&&(C.continuationClasses=y),"."!==_&&(C.match=RegExp("SFX"===o?_+"$":"^"+_)),"0"!=v&&(C.remove="SFX"===o?RegExp(v+"$"):v),c.push(C)}t[l]={type:o,combineable:"Y"==u,entries:c},n+=h}else if("COMPOUNDRULE"===o){for(var h=parseInt(s[1],10),p=n+1,f=n+1+h;f>p;p++){var a=r[p],d=a.split(/\s+/);this.compoundRules.push(d[1])}n+=h}else if("REP"===o){var d=a.split(/\s+/);3===d.length&&this.replacementTable.push([d[1],d[2]])}else this.flags[o]=s[1]}return t},_removeAffixComments:function(e){return e=e.replace(/#.*$/gm,""),e=e.replace(/^\s\s*/m,"").replace(/\s\s*$/m,""),e=e.replace(/\n{2,}/g,"\n"),e=e.replace(/^\s\s*/,"").replace(/\s\s*$/,"")},_parseDIC:function(e){function t(e,t){e in n&&"object"==typeof n[e]||(n[e]=[]),n[e].push(t)}e=this._removeDicComments(e);for(var r=e.split("\n"),n={},i=1,a=r.length;a>i;i++){var s=r[i],o=s.split("/",2),l=o[0];if(o.length>1){var u=this.parseRuleCodes(o[1]);"NEEDAFFIX"in this.flags&&-1!=u.indexOf(this.flags.NEEDAFFIX)||t(l,u);for(var h=0,c=u.length;c>h;h++){var p=u[h],f=this.rules[p];if(f)for(var d=this._applyRule(l,f),v=0,g=d.length;g>v;v++){var m=d[v];if(t(m,[]),f.combineable)for(var y=h+1;c>y;y++){var _=u[y],C=this.rules[_];if(C&&C.combineable&&f.type!=C.type)for(var R=this._applyRule(m,C),b=0,F=R.length;F>b;b++){var x=R[b];t(x,[])}}}p in this.compoundRuleCodes&&this.compoundRuleCodes[p].push(l)}}else t(l.trim(),[])}return n},_removeDicComments:function(e){return e=e.replace(/^\t.*$/gm,"")},parseRuleCodes:function(e){if(!e)return[];if(!("FLAG"in this.flags))return e.split("");if("long"===this.flags.FLAG){for(var t=[],r=0,n=e.length;n>r;r+=2)t.push(e.substr(r,2));return t}return"num"===this.flags.FLAG?textCode.split(","):void 0},_applyRule:function(e,t){for(var r=t.entries,n=[],i=0,a=r.length;a>i;i++){var s=r[i];if(!s.match||e.match(s.match)){var o=e;if(s.remove&&(o=o.replace(s.remove,"")),"SFX"===t.type?o+=s.add:o=s.add+o,n.push(o),"continuationClasses"in s)for(var l=0,u=s.continuationClasses.length;u>l;l++){var h=this.rules[s.continuationClasses[l]];h&&(n=n.concat(this._applyRule(o,h)))}}}return n},check:function(e){var t=e.replace(/^\s\s*/,"").replace(/\s\s*$/,"");if(this.checkExact(t))return!0;if(t.toUpperCase()===t){var r=t[0]+t.substring(1).toLowerCase();if(this.hasFlag(r,"KEEPCASE"))return!1;if(this.checkExact(r))return!0}var n=t.toLowerCase();if(n!==t){if(this.hasFlag(n,"KEEPCASE"))return!1;if(this.checkExact(n))return!0}return!1},checkExact:function(e){var t=this.dictionaryTable[e];if(void 0===t){if("COMPOUNDMIN"in this.flags&&e.length>=this.flags.COMPOUNDMIN)for(var r=0,n=this.compoundRules.length;n>r;r++)if(e.match(this.compoundRules[r]))return!0;return!1}for(var r=0,n=t.length;n>r;r++)if(!this.hasFlag(e,"ONLYINCOMPOUND",t[r]))return!0;return!1},hasFlag:function(e,t,r){if(t in this.flags){if(void 0===r)var r=Array.prototype.concat.apply([],this.dictionaryTable[e]);if(r&&-1!==r.indexOf(this.flags[t]))return!0}return!1},alphabet:"",suggest:function(e,t){function r(e){for(var t=[],r=0,n=e.length;n>r;r++){for(var i=e[r],a=[],s=0,o=i.length+1;o>s;s++)a.push([i.substring(0,s),i.substring(s,i.length)]);for(var l=[],s=0,o=a.length;o>s;s++){var h=a[s];h[1]&&l.push(h[0]+h[1].substring(1))}for(var c=[],s=0,o=a.length;o>s;s++){var h=a[s];h[1].length>1&&c.push(h[0]+h[1][1]+h[1][0]+h[1].substring(2))}for(var p=[],s=0,o=a.length;o>s;s++){var h=a[s];if(h[1])for(var f=0,d=u.alphabet.length;d>f;f++)p.push(h[0]+u.alphabet[f]+h[1].substring(1))}for(var v=[],s=0,o=a.length;o>s;s++){var h=a[s];if(h[1])for(var f=0,d=u.alphabet.length;d>f;f++)p.push(h[0]+u.alphabet[f]+h[1])}t=t.concat(l),t=t.concat(c),t=t.concat(p),t=t.concat(v)}return t}function n(e){for(var t=[],r=0;r<e.length;r++)u.check(e[r])&&t.push(e[r]);return t}function i(e){function i(e,t){return e[1]<t[1]?-1:1}for(var a=r([e]),s=r(a),o=n(a).concat(n(s)),l={},h=0,c=o.length;c>h;h++)o[h]in l?l[o[h]]+=1:l[o[h]]=1;var p=[];for(var h in l)p.push([h,l[h]]);p.sort(i).reverse();for(var f=[],h=0,c=Math.min(t,p.length);c>h;h++)u.hasFlag(p[h][0],"NOSUGGEST")||f.push(p[h][0]);return f}if(t||(t=5),this.check(e))return[];for(var a=0,s=this.replacementTable.length;s>a;a++){var o=this.replacementTable[a];if(-1!==e.indexOf(o[0])){var l=e.replace(o[0],o[1]);if(this.check(l))return[l]}}var u=this;return u.alphabet="abcdefghijklmnopqrstuvwxyz",i(e)}};var num_loaded=0,aff_loading=!1,dic_loading=!1,aff_data="",dic_data="",typo;CodeMirror.defineMode("spell-checker",function(e){if(!aff_loading){aff_loading=!0;var t=new XMLHttpRequest;t.open("GET",serverurl+"/vendor/codemirror-spell-checker/en_US.aff",!0),t.onload=function(){4===t.readyState&&200===t.status&&(aff_data=t.responseText,num_loaded++,2==num_loaded&&(typo=new Typo("en_US",aff_data,dic_data,{platform:"any"})))},t.send(null)}if(!dic_loading){dic_loading=!0;var r=new XMLHttpRequest;r.open("GET",serverurl+"/vendor/codemirror-spell-checker/en_US.dic",!0),r.onload=function(){4===r.readyState&&200===r.status&&(dic_data=r.responseText,num_loaded++,2==num_loaded&&(typo=new Typo("en_US",aff_data,dic_data,{platform:"any"})))},r.send(null)}var n="!\"'#$%&()*+,-./:;<=>?@[\\]^_`{|}~ ",i=/^[A-Za-z][A-Za-z0-9]+$/,a={token:function(e){var t=e.peek(),r="";if(n.includes(t))return e.next(),null;for(;null!=(t=e.peek())&&!n.includes(t);)r+=t,e.next();return i.test(r)&&typo&&!typo.check(r)?"spell-error":null}},s=CodeMirror.getMode(e,e.backdrop||"text/plain");return CodeMirror.overlayMode(s,a,!0)}),String.prototype.includes||(String.prototype.includes=function(){return-1!==String.prototype.indexOf.apply(this,arguments)});
\ No newline at end of file +"use strict";var Typo=function(e,t,r,n){if(n=n||{},this.platform=n.platform||"chrome",this.dictionary=null,this.rules={},this.dictionaryTable={},this.compoundRules=[],this.compoundRuleCodes={},this.replacementTable=[],this.flags=n.flags||{},e){if(this.dictionary=e,"chrome"==this.platform)t||(t=this._readFile(chrome.extension.getURL("lib/typo/dictionaries/"+e+"/"+e+".aff"))),r||(r=this._readFile(chrome.extension.getURL("lib/typo/dictionaries/"+e+"/"+e+".dic")));else{var i=n.dictionaryPath||"";t||(t=this._readFile(i+"/"+e+"/"+e+".aff")),r||(r=this._readFile(i+"/"+e+"/"+e+".dic"))}this.rules=this._parseAFF(t),this.compoundRuleCodes={};for(var a=0,s=this.compoundRules.length;s>a;a++)for(var o=this.compoundRules[a],l=0,u=o.length;u>l;l++)this.compoundRuleCodes[o[l]]=[];"ONLYINCOMPOUND"in this.flags&&(this.compoundRuleCodes[this.flags.ONLYINCOMPOUND]=[]),this.dictionaryTable=this._parseDIC(r);for(var a in this.compoundRuleCodes)0==this.compoundRuleCodes[a].length&&delete this.compoundRuleCodes[a];for(var a=0,s=this.compoundRules.length;s>a;a++){for(var h=this.compoundRules[a],c="",l=0,u=h.length;u>l;l++){var p=h[l];c+=p in this.compoundRuleCodes?"("+this.compoundRuleCodes[p].join("|")+")":p}this.compoundRules[a]=RegExp(c,"i")}}return this};Typo.prototype={load:function(e){for(var t in e)this[t]=e[t];return this},_readFile:function(e,t){t||(t="ISO8859-1");var r=new XMLHttpRequest;return r.open("GET",e,!1),r.overrideMimeType&&r.overrideMimeType("text/plain; charset="+t),r.send(null),r.responseText},_parseAFF:function(e){var t={};e=this._removeAffixComments(e);for(var r=e.split("\n"),n=0,i=r.length;i>n;n++){var a=r[n],s=a.split(/\s+/),o=s[0];if("PFX"==o||"SFX"==o){for(var l=s[1],u=s[2],h=parseInt(s[3],10),c=[],p=n+1,f=n+1+h;f>p;p++){var a=r[p],d=a.split(/\s+/),v=d[2],g=d[3].split("/"),m=g[0];"0"===m&&(m="");var y=this.parseRuleCodes(g[1]),_=d[4],C={};C.add=m,y.length>0&&(C.continuationClasses=y),"."!==_&&(C.match=RegExp("SFX"===o?_+"$":"^"+_)),"0"!=v&&(C.remove="SFX"===o?RegExp(v+"$"):v),c.push(C)}t[l]={type:o,combineable:"Y"==u,entries:c},n+=h}else if("COMPOUNDRULE"===o){for(var h=parseInt(s[1],10),p=n+1,f=n+1+h;f>p;p++){var a=r[p],d=a.split(/\s+/);this.compoundRules.push(d[1])}n+=h}else if("REP"===o){var d=a.split(/\s+/);3===d.length&&this.replacementTable.push([d[1],d[2]])}else this.flags[o]=s[1]}return t},_removeAffixComments:function(e){return e=e.replace(/#.*$/gm,""),e=e.replace(/^\s\s*/m,"").replace(/\s\s*$/m,""),e=e.replace(/\n{2,}/g,"\n"),e=e.replace(/^\s\s*/,"").replace(/\s\s*$/,"")},_parseDIC:function(e){function t(e,t){e in n&&"object"==typeof n[e]||(n[e]=[]),n[e].push(t)}e=this._removeDicComments(e);for(var r=e.split("\n"),n={},i=1,a=r.length;a>i;i++){var s=r[i],o=s.split("/",2),l=o[0];if(o.length>1){var u=this.parseRuleCodes(o[1]);"NEEDAFFIX"in this.flags&&-1!=u.indexOf(this.flags.NEEDAFFIX)||t(l,u);for(var h=0,c=u.length;c>h;h++){var p=u[h],f=this.rules[p];if(f)for(var d=this._applyRule(l,f),v=0,g=d.length;g>v;v++){var m=d[v];if(t(m,[]),f.combineable)for(var y=h+1;c>y;y++){var _=u[y],C=this.rules[_];if(C&&C.combineable&&f.type!=C.type)for(var R=this._applyRule(m,C),b=0,F=R.length;F>b;b++){var x=R[b];t(x,[])}}}p in this.compoundRuleCodes&&this.compoundRuleCodes[p].push(l)}}else t(l.trim(),[])}return n},_removeDicComments:function(e){return e=e.replace(/^\t.*$/gm,"")},parseRuleCodes:function(e){if(!e)return[];if(!("FLAG"in this.flags))return e.split("");if("long"===this.flags.FLAG){for(var t=[],r=0,n=e.length;n>r;r+=2)t.push(e.substr(r,2));return t}return"num"===this.flags.FLAG?textCode.split(","):void 0},_applyRule:function(e,t){for(var r=t.entries,n=[],i=0,a=r.length;a>i;i++){var s=r[i];if(!s.match||e.match(s.match)){var o=e;if(s.remove&&(o=o.replace(s.remove,"")),"SFX"===t.type?o+=s.add:o=s.add+o,n.push(o),"continuationClasses"in s)for(var l=0,u=s.continuationClasses.length;u>l;l++){var h=this.rules[s.continuationClasses[l]];h&&(n=n.concat(this._applyRule(o,h)))}}}return n},check:function(e){var t=e.replace(/^\s\s*/,"").replace(/\s\s*$/,"");if(this.checkExact(t))return!0;if(t.toUpperCase()===t){var r=t[0]+t.substring(1).toLowerCase();if(this.hasFlag(r,"KEEPCASE"))return!1;if(this.checkExact(r))return!0}var n=t.toLowerCase();if(n!==t){if(this.hasFlag(n,"KEEPCASE"))return!1;if(this.checkExact(n))return!0}return!1},checkExact:function(e){var t=this.dictionaryTable[e];if(void 0===t){if("COMPOUNDMIN"in this.flags&&e.length>=this.flags.COMPOUNDMIN)for(var r=0,n=this.compoundRules.length;n>r;r++)if(e.match(this.compoundRules[r]))return!0;return!1}for(var r=0,n=t.length;n>r;r++)if(!this.hasFlag(e,"ONLYINCOMPOUND",t[r]))return!0;return!1},hasFlag:function(e,t,r){if(t in this.flags){if(void 0===r)var r=Array.prototype.concat.apply([],this.dictionaryTable[e]);if(r&&-1!==r.indexOf(this.flags[t]))return!0}return!1},alphabet:"",suggest:function(e,t){function r(e){for(var t=[],r=0,n=e.length;n>r;r++){for(var i=e[r],a=[],s=0,o=i.length+1;o>s;s++)a.push([i.substring(0,s),i.substring(s,i.length)]);for(var l=[],s=0,o=a.length;o>s;s++){var h=a[s];h[1]&&l.push(h[0]+h[1].substring(1))}for(var c=[],s=0,o=a.length;o>s;s++){var h=a[s];h[1].length>1&&c.push(h[0]+h[1][1]+h[1][0]+h[1].substring(2))}for(var p=[],s=0,o=a.length;o>s;s++){var h=a[s];if(h[1])for(var f=0,d=u.alphabet.length;d>f;f++)p.push(h[0]+u.alphabet[f]+h[1].substring(1))}for(var v=[],s=0,o=a.length;o>s;s++){var h=a[s];if(h[1])for(var f=0,d=u.alphabet.length;d>f;f++)p.push(h[0]+u.alphabet[f]+h[1])}t=t.concat(l),t=t.concat(c),t=t.concat(p),t=t.concat(v)}return t}function n(e){for(var t=[],r=0;r<e.length;r++)u.check(e[r])&&t.push(e[r]);return t}function i(e){function i(e,t){return e[1]<t[1]?-1:1}for(var a=r([e]),s=r(a),o=n(a).concat(n(s)),l={},h=0,c=o.length;c>h;h++)o[h]in l?l[o[h]]+=1:l[o[h]]=1;var p=[];for(var h in l)p.push([h,l[h]]);p.sort(i).reverse();for(var f=[],h=0,c=Math.min(t,p.length);c>h;h++)u.hasFlag(p[h][0],"NOSUGGEST")||f.push(p[h][0]);return f}if(t||(t=5),this.check(e))return[];for(var a=0,s=this.replacementTable.length;s>a;a++){var o=this.replacementTable[a];if(-1!==e.indexOf(o[0])){var l=e.replace(o[0],o[1]);if(this.check(l))return[l]}}var u=this;return u.alphabet="abcdefghijklmnopqrstuvwxyz",i(e)}};window.num_loaded=0;var aff_loading=!1,dic_loading=!1,aff_data="",dic_data="",typo;CodeMirror.defineMode("spell-checker",function(e){if(!aff_loading){aff_loading=!0;var t=new XMLHttpRequest;t.open("GET",serverurl+"/vendor/codemirror-spell-checker/en_US.aff",!0),t.onload=function(){4===t.readyState&&200===t.status&&(aff_data=t.responseText,num_loaded++,2==num_loaded&&(typo=new Typo("en_US",aff_data,dic_data,{platform:"any"})))},t.send(null)}if(!dic_loading){dic_loading=!0;var r=new XMLHttpRequest;r.open("GET",serverurl+"/vendor/codemirror-spell-checker/en_US.dic",!0),r.onload=function(){4===r.readyState&&200===r.status&&(dic_data=r.responseText,num_loaded++,2==num_loaded&&(typo=new Typo("en_US",aff_data,dic_data,{platform:"any"})))},r.send(null)}var n="!\"'#$%&()*+,-./:;<=>?@[\\]^_`{|}~ ",i=/^[A-Za-z][A-Za-z0-9]+$/,a={token:function(e){var t=e.peek(),r="";if(n.includes(t))return e.next(),null;for(;null!=(t=e.peek())&&!n.includes(t);)r+=t,e.next();return i.test(r)&&typo&&!typo.check(r)?"spell-error":null}},s=CodeMirror.getMode(e,e.backdrop||"text/plain");return CodeMirror.overlayMode(s,a,!0)}),String.prototype.includes||(String.prototype.includes=function(){return-1!==String.prototype.indexOf.apply(this,arguments)}); diff --git a/public/views/foot.ejs b/public/views/foot.ejs index 80c08f63..696fe3b6 100644 --- a/public/views/foot.ejs +++ b/public/views/foot.ejs @@ -3,83 +3,26 @@ </script> <% if(useCDN) { %> <script src="//cdnjs.cloudflare.com/ajax/libs/spin.js/2.3.2/spin.min.js" defer></script> -<script src="//ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> <script src="//cdn.jsdelivr.net/velocity/1.3.1/velocity.min.js" defer></script> <script src="//cdnjs.cloudflare.com/ajax/libs/jquery-mousewheel/3.1.13/jquery.mousewheel.min.js" defer></script> -<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" defer></script> -<script src="//cdnjs.cloudflare.com/ajax/libs/socket.io/1.5.0/socket.io.min.js" defer></script> <script src="//cdnjs.cloudflare.com/ajax/libs/js-yaml/3.6.1/js-yaml.min.js" defer></script> <script type="text/javascript" src="//cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" defer></script> <script src="//cdnjs.cloudflare.com/ajax/libs/moment.js/2.15.1/moment-with-locales.min.js" defer></script> <script src="//cdnjs.cloudflare.com/ajax/libs/mermaid/6.0.0/mermaid.min.js" defer></script> <% } else { %> <script src="<%- url %>/vendor/spin.js/spin.min.js" defer></script> -<script src="<%- url %>/vendor/jquery/dist/jquery.min.js"></script> <script src="<%- url %>/vendor/velocity/velocity.min.js" defer></script> -<script src="<%- url %>/vendor/jquery-mousewheel/jquery.mousewheel.min.js" defer></script> -<script src="<%- url %>/vendor/bootstrap/dist/js/bootstrap.min.js" defer></script> -<script src="<%- url %>/vendor/socket.io-client/socket.io.js" defer></script> <script src="<%- url %>/vendor/js-yaml/dist/js-yaml.min.js" defer></script> <script type="text/javascript" src="<%- url %>/vendor/MathJax/MathJax.js?config=TeX-AMS-MML_HTMLorMML" defer></script> <script src="<%- url %>/vendor/moment/min/moment-with-locales.js" defer></script> <script src="<%- url %>/vendor/mermaid/dist/mermaid.min.js" defer></script> <% } %> -<script src="<%- url %>/vendor/jquery-ui/jquery-ui.min.js" defer></script> -<!--codemirror--> -<script src="<%- url %>/vendor/codemirror/codemirror.min.js" defer></script> -<script src="<%- url %>/vendor/inlineAttachment/inline-attachment.js" defer></script> -<script src="<%- url %>/vendor/inlineAttachment/codemirror.inline-attachment.js" defer></script> -<script src="<%- url %>/vendor/codemirror-spell-checker/spell-checker.min.js" defer></script> -<!--ot--> -<script src="<%- url %>/vendor/ot/ot.min.js" defer></script> -<!--others--> -<script src="<%- url %>/vendor/markdown-it/dist/markdown-it.min.js" defer></script> -<script src="<%- url %>/vendor/markdown-it-abbr/dist/markdown-it-abbr.min.js" defer></script> -<script src="<%- url %>/vendor/markdown-it-footnote/dist/markdown-it-footnote.min.js" defer></script> -<script src="<%- url %>/vendor/markdown-it-deflist/dist/markdown-it-deflist.min.js" defer></script> -<script src="<%- url %>/vendor/markdown-it-mark/dist/markdown-it-mark.min.js" defer></script> -<script src="<%- url %>/vendor/markdown-it-ins/dist/markdown-it-ins.min.js" defer></script> -<script src="<%- url %>/vendor/markdown-it-sub/dist/markdown-it-sub.min.js" defer></script> -<script src="<%- url %>/vendor/markdown-it-sup/dist/markdown-it-sup.min.js" defer></script> -<script src="<%- url %>/vendor/markdown-it-container/dist/markdown-it-container.min.js" defer></script> -<script src="<%- url %>/vendor/markdown-it-mathjax.js" defer></script> -<script src="<%- url %>/vendor/markdown-it-regexp.js" defer></script> -<script src="<%- url %>/vendor/markdown-it-imsize.js" defer></script> -<script src="<%- url %>/vendor/gist-embed/gist-embed.min.js" defer></script> -<script src="<%- url %>/vendor/lz-string/libs/lz-string.min.js" defer></script> -<script src="<%- url %>/vendor/xss/dist/xss.min.js" defer></script> -<script src="<%- url %>/vendor/string/dist/string.min.js" defer></script> -<script src="<%- url %>/vendor/highlightjs/highlight.pack.min.js" defer></script> -<script src="<%- url %>/vendor/prism/prism.js" defer></script> -<script src="<%- url %>/vendor/prism/components/prism-wiki.min.js" defer></script> -<script src="<%- url %>/vendor/js-cookie/src/js.cookie.js" defer></script> -<script src="<%- url %>/vendor/handlebars/handlebars.min.js" defer></script> -<script src="<%- url %>/vendor/emojify/js/emojify.min.js" defer></script> -<script src="<%- url %>/vendor/to-markdown/dist/to-markdown.js" defer></script> -<script src="<%- url %>/vendor/raphael/raphael.min.js" defer></script> -<script src="<%- url %>/vendor/lodash/dist/lodash.min.js" defer></script> -<script src="<%- url %>/vendor/sequence-diagrams/sequence-diagram-min.js" defer></script> -<script src="<%- url %>/vendor/flowchart/release/flowchart.min.js" defer></script> -<script src="<%- url %>/vendor/viz.js/viz.js" defer></script> -<script src="<%- url %>/vendor/pdfobject/pdfobject.min.js" defer></script> -<script src="<%- url %>/vendor/file-saver/FileSaver.min.js" defer></script> -<script src="<%- url %>/vendor/store-js/store.min.js" defer></script> -<script src="<%- url %>/vendor/js-url/url.min.js" defer></script> -<script src="<%- url %>/vendor/jquery-textcomplete/jquery.textcomplete.js" defer></script> -<script src="<%- url %>/vendor/Idle.Js/build/idle.min.js" defer></script> -<script src="<%- url %>/vendor/visibilityjs/lib/visibility.core.js" defer></script> -<script src="<%- url %>/vendor/list.js/dist/list.min.js" defer></script> -<script src="<%- url %>/vendor/md-toc.js" defer></script> -<script src="<%- url %>/vendor/showup/showup.js" defer></script> -<script src="<%- url %>/vendor/randomcolor/randomColor.js" defer></script> -<script src="<%- url %>/vendor/keymaster/keymaster.js" defer></script> +<script src="//ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> +<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" defer></script> +<script src="//cdnjs.cloudflare.com/ajax/libs/lodash.js/4.16.4/lodash.min.js" defer></script> +<script src="//cdnjs.cloudflare.com/ajax/libs/socket.io/1.5.0/socket.io.min.js" defer></script> +<script src="//cdnjs.cloudflare.com/ajax/libs/viz.js/1.3.0/viz.js" defer></script> +<%- include build/index-scripts %> <script src="<%- url %>/js/google-drive-upload.js" defer></script> <script src="<%- url %>/js/google-drive-picker.js" defer></script> -<script src="<%- url %>/js/config.js" defer></script> -<script src="<%- url %>/js/common.js" defer></script> -<script src="<%- url %>/js/extra.js" defer></script> -<script src="<%- url %>/js/render.js" defer></script> -<script src="<%- url %>/js/history.js" defer></script> <script src="<%- url %>/js/reveal-markdown.js" defer></script> -<script src="<%- url %>/js/syncscroll.js" defer></script> -<script src="<%- url %>/js/index.js" defer></script>
\ No newline at end of file diff --git a/public/views/head.ejs b/public/views/head.ejs index 5d8e44b6..67884495 100644 --- a/public/views/head.ejs +++ b/public/views/head.ejs @@ -8,18 +8,16 @@ <link rel="icon" type="image/png" href="<%- url %>/favicon.png"> <link rel="apple-touch-icon" href="<%- url %>/apple-touch-icon.png"> <% if(useCDN) { %> -<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> -<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css"> <link rel="stylesheet" href="//cdn.jsdelivr.net/ionicons/2.0.1/css/ionicons.min.css"> <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/octicons/3.5.0/octicons.min.css"> <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/bootstrap-social/4.9.0/bootstrap-social.min.css"> <% } else { %> -<link rel="stylesheet" href="<%- url %>/vendor/bootstrap/dist/css/bootstrap.min.css"> -<link rel="stylesheet" href="<%- url %>/vendor/font-awesome/css/font-awesome.min.css"> <link rel="stylesheet" href="<%- url %>/vendor/Ionicons/css/ionicons.min.css"> <link rel="stylesheet" href="<%- url %>/vendor/octicons/octicons/octicons.css"> <link rel="stylesheet" href="<%- url %>/css/bootstrap-social.css"> <% } %> +<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> +<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css"> <link rel="stylesheet" href="<%- url %>/vendor/jquery-ui/jquery-ui.min.css"> <link rel="stylesheet" href="<%- url %>/vendor/codemirror/lib/codemirror.css"> <link rel="stylesheet" href="<%- url %>/vendor/codemirror-spell-checker/spell-checker.min.css"> @@ -33,12 +31,11 @@ <link rel="stylesheet" href="<%- url %>/vendor/codemirror/mode/tiddlywiki/tiddlywiki.css"> <link rel="stylesheet" href="<%- url %>/vendor/codemirror/mode/mediawiki/mediawiki.css"> <link rel="stylesheet" href="<%- url %>/css/github-extract.css"> -<link rel="stylesheet" href="<%- url %>/vendor/highlightjs/styles/github-gist.css"> -<link rel="stylesheet" href="<%- url %>/vendor/prism/themes/prism.css"> <link rel="stylesheet" href="<%- url %>/vendor/emojify/css/emojify.min.css"> <link rel="stylesheet" href="<%- url %>/vendor/showup/showup.css"> <link rel="stylesheet" href="<%- url %>/css/mermaid.css"> <link rel="stylesheet" href="<%- url %>/css/markdown.css"> +<%- include build/index-header %> <link rel="stylesheet" href="<%- url %>/css/index.css"> <link rel="stylesheet" href="<%- url %>/css/extra.css"> <link rel="stylesheet" href="<%- url %>/css/slide-preview.css"> diff --git a/public/views/includes/header.ejs b/public/views/includes/header.ejs new file mode 100644 index 00000000..89f3a0d1 --- /dev/null +++ b/public/views/includes/header.ejs @@ -0,0 +1,3 @@ +<% for (var css in htmlWebpackPlugin.files.css) { %> +<link href="<%= htmlWebpackPlugin.files.css[css] %>" rel="stylesheet"> +<% } %> diff --git a/public/views/includes/scripts.ejs b/public/views/includes/scripts.ejs new file mode 100644 index 00000000..4eec75e8 --- /dev/null +++ b/public/views/includes/scripts.ejs @@ -0,0 +1,3 @@ +<% for (var chunk in htmlWebpackPlugin.files.chunks) { %> +<script src="<%= htmlWebpackPlugin.files.chunks[chunk].entry %>" defer></script> +<% } %> diff --git a/public/views/index.ejs b/public/views/index.ejs index 4fdee8cf..0bc3dd50 100644 --- a/public/views/index.ejs +++ b/public/views/index.ejs @@ -27,6 +27,7 @@ <link rel="stylesheet" href="<%- url %>/vendor/select2/select2.css"> <link rel="stylesheet" href="<%- url %>/vendor/select2/select2-bootstrap.css"> <!-- Custom styles for this template --> + <%- include build/cover-header %> <link rel="stylesheet" href="<%- url %>/css/cover.css"> <link rel="stylesheet" href="<%- url %>/css/site.css"> </head> @@ -194,31 +195,18 @@ ================================================== --> <!-- Placed at the end of the document so the pages load faster --> <% if(useCDN) { %> - <script src="//ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js" defer></script> <script src="//cdn.jsdelivr.net/velocity/1.3.1/velocity.min.js" defer></script> <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" defer></script> <script src="//cdnjs.cloudflare.com/ajax/libs/select2/3.5.2/select2.min.js" defer></script> <script src="//cdnjs.cloudflare.com/ajax/libs/moment.js/2.15.1/moment-with-locales.min.js" defer></script> <script src="//cdnjs.cloudflare.com/ajax/libs/js-url/2.3.0/url.min.js" defer></script> <% } else { %> - <script src="<%- url %>/vendor/jquery/dist/jquery.min.js" defer></script> <script src="<%- url %>/vendor/velocity/velocity.min.js" defer></script> - <script src="<%- url %>/vendor/bootstrap/dist/js/bootstrap.min.js" defer></script> - <script src="<%- url %>/vendor/select2/select2.min.js" defer></script> <script src="<%- url %>/vendor/moment/min/moment-with-locales.min.js" defer></script> - <script src="<%- url %>/vendor/js-url/url.min.js" defer></script> <% } %> - <script src="<%- url %>/vendor/js-cookie/src/js.cookie.js" defer></script> - <script src="<%- url %>/vendor/list.js/dist/list.min.js" defer></script> - <script src="<%- url %>/vendor/list.pagination.js/dist/list.pagination.min.js" defer></script> - <script src="<%- url %>/vendor/file-saver/FileSaver.min.js" defer></script> - <script src="<%- url %>/vendor/store-js/store.min.js" defer></script> - <script src="<%- url %>/vendor/lz-string/libs/lz-string.min.js" defer></script> - <script src="<%- url %>/js/config.js" defer></script> - <script src="<%- url %>/js/common.js" defer></script> - <script src="<%- url %>/js/history.js" defer></script> - <script src="<%- url %>/js/cover.js" defer></script> - <script src="<%- url %>/js/locale.js" defer></script> + <script src="//ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js" defer></script> + <script src="//cdnjs.cloudflare.com/ajax/libs/lodash.js/4.16.4/lodash.min.js" defer></script> + <%- include build/cover-scripts %> </body> </html> diff --git a/public/views/pretty.ejs b/public/views/pretty.ejs index 79652012..0cd9e012 100644 --- a/public/views/pretty.ejs +++ b/public/views/pretty.ejs @@ -18,23 +18,20 @@ <link rel="icon" type="image/png" href="<%- url %>/favicon.png"> <link rel="apple-touch-icon" href="<%- url %>/apple-touch-icon.png"> <% if(useCDN) { %> - <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> - <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css"> <link rel="stylesheet" href="https://cdn.jsdelivr.net/ionicons/2.0.1/css/ionicons.min.css"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/octicons/3.5.0/octicons.min.css"> <% } else { %> - <link rel="stylesheet" href='<%- url %>/vendor/bootstrap/dist/css/bootstrap.min.css'> - <link rel="stylesheet" href='<%- url %>/vendor/font-awesome/css/font-awesome.min.css'> <link rel="stylesheet" href="<%- url %>/vendor/Ionicons/css/ionicons.min.css"> <link rel="stylesheet" href="<%- url %>/vendor/octicons/octicons/octicons.css"> <% } %> + <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> + <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css"> <link rel="stylesheet" href='<%- url %>/css/github-extract.css'> <link rel="stylesheet" href='<%- url %>/css/gist.css'> - <link rel="stylesheet" href='<%- url %>/vendor/highlightjs/styles/github-gist.css'> - <link rel="stylesheet" href="<%- url %>/vendor/prism/themes/prism.css"> <link rel="stylesheet" href="<%- url %>/css/mermaid.css"> <link rel="stylesheet" href='<%- url %>/css/markdown.css'> <link rel="stylesheet" href='<%- url %>/vendor/emojify/css/emojify.min.css'> + <%- include build/pretty-header %> <link rel="stylesheet" href='<%- url %>/css/extra.css'> <link rel="stylesheet" href="<%- url %>/css/slide-preview.css"> <link rel="stylesheet" href='<%- url %>/css/site.css'> @@ -92,53 +89,20 @@ MathJax.Hub.Config({ messageStyle: "none", skipStartupTypeset: true ,tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']], processEscapes: true }}); </script> <% if(useCDN) { %> -<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> -<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" defer></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/js-yaml/3.6.1/js-yaml.min.js" defer></script> <script type="text/javascript" src="//cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" defer></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.15.1/moment-with-locales.min.js" defer></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/mermaid/6.0.0/mermaid.min.js" defer></script> <% } else { %> -<script src="<%- url %>/vendor/jquery/dist/jquery.min.js"></script> -<script src="<%- url %>/vendor/bootstrap/dist/js/bootstrap.min.js" defer></script> <script src="<%- url %>/vendor/js-yaml/dist/js-yaml.min.js" defer></script> <script type="text/javascript" src="<%- url %>/vendor/MathJax/MathJax.js?config=TeX-AMS-MML_HTMLorMML" defer></script> <script src="<%- url %>/vendor/moment/min/moment-with-locales.js" defer></script> <script src="<%- url %>/vendor/mermaid/dist/mermaid.min.js" defer></script> <% } %> -<script src="<%- url %>/vendor/lz-string/libs/lz-string.min.js" defer></script> -<script src="<%- url %>/vendor/xss/dist/xss.min.js" defer></script> -<script src="<%- url %>/vendor/markdown-it/dist/markdown-it.min.js" defer></script> -<script src="<%- url %>/vendor/markdown-it-abbr/dist/markdown-it-abbr.min.js" defer></script> -<script src="<%- url %>/vendor/markdown-it-footnote/dist/markdown-it-footnote.min.js" defer></script> -<script src="<%- url %>/vendor/markdown-it-deflist/dist/markdown-it-deflist.min.js" defer></script> -<script src="<%- url %>/vendor/markdown-it-mark/dist/markdown-it-mark.min.js" defer></script> -<script src="<%- url %>/vendor/markdown-it-ins/dist/markdown-it-ins.min.js" defer></script> -<script src="<%- url %>/vendor/markdown-it-sub/dist/markdown-it-sub.min.js" defer></script> -<script src="<%- url %>/vendor/markdown-it-sup/dist/markdown-it-sup.min.js" defer></script> -<script src="<%- url %>/vendor/markdown-it-container/dist/markdown-it-container.min.js" defer></script> -<script src="<%- url %>/vendor/markdown-it-mathjax.js" defer></script> -<script src="<%- url %>/vendor/markdown-it-regexp.js" defer></script> -<script src="<%- url %>/vendor/markdown-it-imsize.js" defer></script> -<script src="<%- url %>/vendor/gist-embed/gist-embed.min.js" defer></script> -<script src="<%- url %>/vendor/string/dist/string.min.js" defer></script> -<script src="<%- url %>/vendor/highlightjs/highlight.pack.min.js" defer></script> -<script src="<%- url %>/vendor/prism/prism.js" defer></script> -<script src="<%- url %>/vendor/prism/components/prism-wiki.min.js" defer></script> -<script src="<%- url %>/vendor/js-cookie/src/js.cookie.js" defer></script> -<script src="<%- url %>/vendor/emojify/js/emojify.min.js" defer></script> -<script src="<%- url %>/vendor/raphael/raphael.min.js" defer></script> -<script src="<%- url %>/vendor/lodash/dist/lodash.min.js" defer></script> -<script src="<%- url %>/vendor/sequence-diagrams/sequence-diagram-min.js" defer></script> -<script src="<%- url %>/vendor/flowchart/release/flowchart.min.js" defer></script> -<script src="<%- url %>/vendor/viz.js/viz.js" defer></script> -<script src="<%- url %>/vendor/pdfobject/pdfobject.min.js" defer></script> -<script src="<%- url %>/vendor/md-toc.js" defer></script> -<script src="<%- url %>/js/config.js" defer></script> -<script src="<%- url %>/js/common.js" defer></script> -<script src="<%- url %>/js/extra.js" defer></script> -<script src="<%- url %>/js/render.js" defer></script> +<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" defer></script> +<script src="//ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> +<script src="//cdnjs.cloudflare.com/ajax/libs/lodash.js/4.16.4/lodash.min.js" defer></script> +<script src="//cdnjs.cloudflare.com/ajax/libs/viz.js/1.3.0/viz.js" defer></script> +<%- include build/pretty-scripts %> <script src="<%- url %>/js/reveal-markdown.js" defer></script> -<script src="<%- url %>/js/pretty.js" defer></script> - -<%- include ga %>
\ No newline at end of file +<%- include ga %> diff --git a/public/views/slide.ejs b/public/views/slide.ejs index 443e1468..79d77086 100644 --- a/public/views/slide.ejs +++ b/public/views/slide.ejs @@ -87,55 +87,25 @@ MathJax.Hub.Config({ messageStyle: "none", skipStartupTypeset: true ,tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']], processEscapes: true }}); </script> <% if(useCDN) { %> - <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> <script src="//cdn.jsdelivr.net/velocity/1.3.1/velocity.min.js" defer></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/js-yaml/3.6.1/js-yaml.min.js" defer></script> <script type="text/javascript" src="//cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" defer></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.15.1/moment-with-locales.min.js" defer></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/mermaid/6.0.0/mermaid.min.js" defer></script> <% } else { %> - <script src="<%- url %>/vendor/jquery/dist/jquery.min.js"></script> + <script src="<%- url %>/vendor/reveal.js/lib/js/head.min.js"></script> + <script src="<%- url %>/vendor/reveal.js/js/reveal.js"></script> <script src="<%- url %>/vendor/velocity/velocity.min.js" defer></script> <script src="<%- url %>/vendor/js-yaml/dist/js-yaml.min.js" defer></script> <script type="text/javascript" src="<%- url %>/vendor/MathJax/MathJax.js?config=TeX-AMS-MML_HTMLorMML" defer></script> <script src="<%- url %>/vendor/moment/min/moment-with-locales.js" defer></script> <script src="<%- url %>/vendor/mermaid/dist/mermaid.min.js" defer></script> <% } %> - <script src="<%- url %>/vendor/bootstrap/tooltip.min.js"></script> - <script src="<%- url %>/vendor/reveal.js/lib/js/head.min.js"></script> - <script src="<%- url %>/vendor/reveal.js/js/reveal.js"></script> - <script src="<%- url %>/vendor/xss/dist/xss.min.js" defer></script> - <script src="<%- url %>/vendor/markdown-it/dist/markdown-it.min.js" defer></script> - <script src="<%- url %>/vendor/markdown-it-abbr/dist/markdown-it-abbr.min.js" defer></script> - <script src="<%- url %>/vendor/markdown-it-footnote/dist/markdown-it-footnote.min.js" defer></script> - <script src="<%- url %>/vendor/markdown-it-deflist/dist/markdown-it-deflist.min.js" defer></script> - <script src="<%- url %>/vendor/markdown-it-mark/dist/markdown-it-mark.min.js" defer></script> - <script src="<%- url %>/vendor/markdown-it-ins/dist/markdown-it-ins.min.js" defer></script> - <script src="<%- url %>/vendor/markdown-it-sub/dist/markdown-it-sub.min.js" defer></script> - <script src="<%- url %>/vendor/markdown-it-sup/dist/markdown-it-sup.min.js" defer></script> - <script src="<%- url %>/vendor/markdown-it-container/dist/markdown-it-container.min.js" defer></script> - <script src="<%- url %>/vendor/markdown-it-mathjax.js" defer></script> - <script src="<%- url %>/vendor/markdown-it-regexp.js" defer></script> - <script src="<%- url %>/vendor/markdown-it-imsize.js" defer></script> - <script src="<%- url %>/vendor/gist-embed/gist-embed.min.js" defer></script> - <script src="<%- url %>/vendor/string/dist/string.min.js" defer></script> - <script src="<%- url %>/vendor/highlightjs/highlight.pack.min.js" defer></script> - <script src="<%- url %>/vendor/js-cookie/src/js.cookie.js" defer></script> - <script src="<%- url %>/vendor/emojify/js/emojify.min.js" defer></script> - <script src="<%- url %>/vendor/raphael/raphael.min.js" defer></script> - <script src="<%- url %>/vendor/lodash/dist/lodash.min.js" defer></script> - <script src="<%- url %>/vendor/sequence-diagrams/sequence-diagram-min.js" defer></script> - <script src="<%- url %>/vendor/flowchart/release/flowchart.min.js" defer></script> - <script src="<%- url %>/vendor/viz.js/viz.js" defer></script> - <script src="<%- url %>/vendor/pdfobject/pdfobject.min.js" defer></script> - <script src="<%- url %>/vendor/md-toc.js" defer></script> - <script src="<%- url %>/js/config.js" defer></script> - <script src="<%- url %>/js/common.js" defer></script> - <script src="<%- url %>/js/extra.js" defer></script> - <script src="<%- url %>/js/render.js" defer></script> - <script src="<%- url %>/js/slide.js" defer></script> - + <script src="//ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> + <script src="//cdnjs.cloudflare.com/ajax/libs/lodash.js/4.16.4/lodash.min.js" defer></script> + <script src="//cdnjs.cloudflare.com/ajax/libs/viz.js/1.3.0/viz.js" defer></script> + <%- include build/slide-scripts %> </body> </html> -<%- include ga %>
\ No newline at end of file +<%- include ga %> diff --git a/webpack.config.js b/webpack.config.js new file mode 100644 index 00000000..d2cf3dc7 --- /dev/null +++ b/webpack.config.js @@ -0,0 +1,3 @@ +var baseConfig = require('./webpackBaseConfig'); + +module.exports = baseConfig; diff --git a/webpack.production.js b/webpack.production.js new file mode 100644 index 00000000..1c2190ab --- /dev/null +++ b/webpack.production.js @@ -0,0 +1,91 @@ +var baseConfig = require('./webpackBaseConfig'); +var webpack = require('webpack'); +var ExtractTextPlugin = require("extract-text-webpack-plugin"); +var path = require('path'); +var HtmlWebpackPlugin = require('html-webpack-plugin'); + +module.exports = Object.assign({}, baseConfig, { + plugins: [ + new webpack.ProvidePlugin({ + '_': 'lodash', + Visibility: "visibilityjs", + Cookies: "js-cookie", + emojify: "emojify.js", + key: "keymaster" + }), + new ExtractTextPlugin("[name].css"), + new webpack.optimize.CommonsChunkPlugin({ + names: ["vendor", "public", "slide", "locale"], + children: true, + async: true, + filename: '[name].js', + minChunks: Infinity + }), + new HtmlWebpackPlugin({ + template: 'public/views/includes/header.ejs', + chunks: ['vendor', 'index'], + filename: path.join(__dirname, 'public/views/build/index-header.ejs'), + inject: false + }), + new HtmlWebpackPlugin({ + template: 'public/views/includes/scripts.ejs', + chunks: ['vendor', 'index'], + filename: path.join(__dirname, 'public/views/build/index-scripts.ejs'), + inject: false + }), + new HtmlWebpackPlugin({ + template: 'public/views/includes/header.ejs', + chunks: ['vendor', 'locale'], + filename: path.join(__dirname, 'public/views/build/cover-header.ejs'), + inject: false + }), + new HtmlWebpackPlugin({ + template: 'public/views/includes/scripts.ejs', + chunks: ['vendor', 'locale'], + filename: path.join(__dirname, 'public/views/build/cover-scripts.ejs'), + inject: false + }), + new HtmlWebpackPlugin({ + template: 'public/views/includes/header.ejs', + chunks: ['vendor', 'public'], + filename: path.join(__dirname, 'public/views/build/pretty-header.ejs'), + inject: false + }), + new HtmlWebpackPlugin({ + template: 'public/views/includes/scripts.ejs', + chunks: ['vendor', 'public'], + filename: path.join(__dirname, 'public/views/build/pretty-scripts.ejs'), + inject: false + }), + new HtmlWebpackPlugin({ + template: 'public/views/includes/header.ejs', + chunks: ['vendor', 'slide'], + filename: path.join(__dirname, 'public/views/build/slide-header.ejs'), + inject: false + }), + new HtmlWebpackPlugin({ + template: 'public/views/includes/scripts.ejs', + chunks: ['vendor', 'slide'], + filename: path.join(__dirname, 'public/views/build/slide-scripts.ejs'), + inject: false + }), + new webpack.DefinePlugin({ + 'process.env': { + 'NODE_ENV': JSON.stringify('production') + } + }), + new webpack.optimize.UglifyJsPlugin({ + compress: { + warnings: false + }, + mangle: false, + sourceMap: false + }) + ], + + output: { + path: path.join(__dirname, 'public/build'), + publicPath: '/build/', + filename: '[id].[name].[hash].js' + }, +}); diff --git a/webpackBaseConfig.js b/webpackBaseConfig.js new file mode 100644 index 00000000..e38213b3 --- /dev/null +++ b/webpackBaseConfig.js @@ -0,0 +1,174 @@ +var webpack = require('webpack'); +var path = require('path'); +var ExtractTextPlugin = require("extract-text-webpack-plugin"); +var HtmlWebpackPlugin = require('html-webpack-plugin'); + +module.exports = { + plugins: [ + new webpack.ProvidePlugin({ + Visibility: "visibilityjs", + Cookies: "js-cookie", + emojify: "emojify.js", + key: "keymaster", + $: "jquery", + jQuery: "jquery", + "window.jQuery": "jquery" + }), + new ExtractTextPlugin("[name].css"), + new webpack.optimize.CommonsChunkPlugin({ + names: ["vendor", "public", "slide", "locale"], + children: true, + async: true, + filename: '[name].js', + minChunks: Infinity + }), + new HtmlWebpackPlugin({ + template: 'public/views/includes/header.ejs', + chunks: ['vendor', 'index'], + filename: path.join(__dirname, 'public/views/build/index-header.ejs'), + inject: false + }), + new HtmlWebpackPlugin({ + template: 'public/views/includes/scripts.ejs', + chunks: ['vendor', 'index'], + filename: path.join(__dirname, 'public/views/build/index-scripts.ejs'), + inject: false + }), + new HtmlWebpackPlugin({ + template: 'public/views/includes/header.ejs', + chunks: ['vendor', 'locale'], + filename: path.join(__dirname, 'public/views/build/cover-header.ejs'), + inject: false + }), + new HtmlWebpackPlugin({ + template: 'public/views/includes/scripts.ejs', + chunks: ['vendor', 'locale'], + filename: path.join(__dirname, 'public/views/build/cover-scripts.ejs'), + inject: false + }), + new HtmlWebpackPlugin({ + template: 'public/views/includes/header.ejs', + chunks: ['vendor', 'public'], + filename: path.join(__dirname, 'public/views/build/pretty-header.ejs'), + inject: false + }), + new HtmlWebpackPlugin({ + template: 'public/views/includes/scripts.ejs', + chunks: ['vendor', 'public'], + filename: path.join(__dirname, 'public/views/build/pretty-scripts.ejs'), + inject: false + }), + new HtmlWebpackPlugin({ + template: 'public/views/includes/header.ejs', + chunks: ['vendor', 'slide'], + filename: path.join(__dirname, 'public/views/build/slide-header.ejs'), + inject: false + }), + new HtmlWebpackPlugin({ + template: 'public/views/includes/scripts.ejs', + chunks: ['vendor', 'slide'], + filename: path.join(__dirname, 'public/views/build/slide-scripts.ejs'), + inject: false + }) + ], + + entry: { + index: path.join(__dirname, 'public/js/index.js'), + public: path.join(__dirname, 'public/js/public.js'), + slide: path.join(__dirname, 'public/js/slide.js'), + locale: path.join(__dirname, 'public/js/locale.js'), + vendor: [ + "jquery-mousewheel", + "jquery-scrollspy/jquery-scrollspy", + "jquery-ui/ui/widgets/resizable", + "jquery-ui/ui/widgets/tooltip", + "jquery-ui/ui/widgets/controlgroup", + "jquery-ui/ui/widgets/autocomplete", + "script!gist-embed", + "expose?filterXSS!xss", + "js-url", + "expose?Spinner!spin.js", + "script!Idle.Js", + "expose?LZString!lz-string", + "expose?ListPagination!list.pagination.js/dist/list.pagination.js", + "script!codemirror", + "script!select2", + "script!inlineAttachment", + "script!jqueryTextcomplete", + "script!codemirrorSpellChecker", + "script!codemirrorInlineAttachment", + "script!ot", + "flowchart.js", + "js-sequence-diagrams" + ] + }, + + output: { + path: path.join(__dirname, 'public/build'), + publicPath: '/build/', + filename: '[name].js' + }, + + resolve: { + modulesDirectories: [ + path.resolve(__dirname, 'src'), + path.resolve(__dirname, 'node_modules') + ], + extensions: ["", ".js"], + alias: { + codemirror: path.join(__dirname, 'public/vendor/codemirror/codemirror.min.js'), + select2: path.join(__dirname, 'public/vendor/select2/select2.min.js'), + inlineAttachment: path.join(__dirname, 'public/vendor/inlineAttachment/inline-attachment.js'), + jqueryTextcomplete: path.join(__dirname, 'public/vendor/jquery-textcomplete/jquery.textcomplete.js'), + codemirrorSpellChecker: path.join(__dirname, 'public/vendor/codemirror-spell-checker/spell-checker.min.js'), + codemirrorInlineAttachment: path.join(__dirname, 'public/vendor/inlineAttachment/codemirror.inline-attachment.js'), + ot: path.join(__dirname, 'public/vendor/ot/ot.min.js') + } + }, + + externals: { + "viz.js": "Viz", + "socket.io-client": "io", + "lodash": "_", + "jquery": "$" + }, + + module: { + loaders: [{ + test: /\.json$/, + loader: 'json-loader' + }, { + test: /\.css$/, + loader: ExtractTextPlugin.extract('style-loader', 'css-loader') + }, { + test: /\.scss$/, + loader: ExtractTextPlugin.extract('style-loader', 'sass-loader') + }, { + test: /\.less$/, + loader: ExtractTextPlugin.extract('style-loader', 'less-loader') + }, { + test: require.resolve("js-sequence-diagrams"), + loader: "imports?Raphael=raphael" + }, { + test: /\.eot(\?v=\d+\.\d+\.\d+)?$/, + loader: "file" + }, { + test: /\.(woff|woff2)$/, + loader: "url?prefix=font/&limit=5000" + }, { + test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/, + loader: "url?limit=10000&mimetype=application/octet-stream" + }, { + test: /\.svg(\?v=\d+\.\d+\.\d+)?$/, + loader: "url?limit=10000&mimetype=image/svg+xml" + }], + + noParse: [ + "gist-embed" + ] + }, + + node: { + fs: "empty" + } +}; |