From 83be3465ccd4bdc43cdfc14f253c236e2f44379e Mon Sep 17 00:00:00 2001 From: Yukai Huang Date: Thu, 13 Oct 2016 13:59:34 +0800 Subject: [PATCH 01/12] Fix scrollspy --- bower.json | 3 ++- package.json | 1 - public/views/foot.ejs | 1 + public/views/pretty.ejs | 3 ++- webpackBaseConfig.js | 3 +-- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/bower.json b/bower.json index d9923e2..7b5e05a 100644 --- a/bower.json +++ b/bower.json @@ -30,7 +30,8 @@ "velocity": "^1.3.1", "randomcolor": "randomColor#^0.4.4", "Idle.Js": "idle.js#^1.0.0", - "gist-embed": "*" + "gist-embed": "*", + "jquery-scrollspy": "softwarespot/jquery-scrollspy" }, "resolutions": { "jquery": "~3.1.1" diff --git a/package.json b/package.json index 03333fb..6b313be 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,6 @@ "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", diff --git a/public/views/foot.ejs b/public/views/foot.ejs index 696fe3b..4ba18e3 100644 --- a/public/views/foot.ejs +++ b/public/views/foot.ejs @@ -20,6 +20,7 @@ + <%- include build/index-scripts %> diff --git a/public/views/pretty.ejs b/public/views/pretty.ejs index 0cd9e01..b0eb568 100644 --- a/public/views/pretty.ejs +++ b/public/views/pretty.ejs @@ -99,8 +99,9 @@ <% } %> - + + <%- include build/pretty-scripts %> diff --git a/webpackBaseConfig.js b/webpackBaseConfig.js index e38213b..7bf3657 100644 --- a/webpackBaseConfig.js +++ b/webpackBaseConfig.js @@ -78,8 +78,7 @@ module.exports = { slide: path.join(__dirname, 'public/js/slide.js'), locale: path.join(__dirname, 'public/js/locale.js'), vendor: [ - "jquery-mousewheel", - "jquery-scrollspy/jquery-scrollspy", + "imports?$=jquery!jquery-mousewheel", "jquery-ui/ui/widgets/resizable", "jquery-ui/ui/widgets/tooltip", "jquery-ui/ui/widgets/controlgroup", From 4713b4f2aacab5bbc6ed557bd3f382df3af962df Mon Sep 17 00:00:00 2001 From: Yukai Huang Date: Thu, 13 Oct 2016 14:03:02 +0800 Subject: [PATCH 02/12] Fix syncscroll --- public/js/syncscroll.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/public/js/syncscroll.js b/public/js/syncscroll.js index 511c500..a9cfb5a 100644 --- a/public/js/syncscroll.js +++ b/public/js/syncscroll.js @@ -109,7 +109,8 @@ md.use(markdownitContainer, 'info', { render: renderContainer }); md.use(markdownitContainer, 'warning', { render: renderContainer }); md.use(markdownitContainer, 'danger', { render: renderContainer }); -var syncscroll = true; +// FIXME: expose syncscroll to window +window.syncscroll = true; var preventSyncScrollToEdit = false; var preventSyncScrollToView = false; From 440ad3506c22791fb58c1cc7888518ab93de3662 Mon Sep 17 00:00:00 2001 From: Yukai Huang Date: Thu, 13 Oct 2016 15:13:03 +0800 Subject: [PATCH 03/12] Fix lastchangeui and moment timestamps --- public/js/extra.js | 14 +++++--------- public/js/index.js | 3 --- public/js/pretty.js | 1 - public/js/slide.js | 15 +-------------- public/views/foot.ejs | 1 + public/views/pretty.ejs | 1 + public/views/slide.ejs | 1 + webpackBaseConfig.js | 7 ++----- 8 files changed, 11 insertions(+), 32 deletions(-) diff --git a/public/js/extra.js b/public/js/extra.js index 24d53fe..1a1caf8 100644 --- a/public/js/extra.js +++ b/public/js/extra.js @@ -5,9 +5,9 @@ var saveAs = require('file-saver').saveAs; require('../vendor/md-toc'); //auto update last change -var createtime = null; -var lastchangetime = null; -var lastchangeui = { +window.createtime = null; +window.lastchangetime = null; +window.lastchangeui = { status: $(".ui-status-lastchange"), time: $(".ui-lastchange"), user: $(".ui-lastchangeuser"), @@ -30,8 +30,8 @@ function updateLastChange() { } setInterval(updateLastChange, 60000); -var lastchangeuser = null; -var lastchangeuserprofile = null; +window.lastchangeuser = null; +window.lastchangeuserprofile = null; function updateLastChangeUser() { if (lastchangeui) { if (lastchangeuser && lastchangeuserprofile) { @@ -1070,11 +1070,7 @@ md.use(pdfPlugin); module.exports = { md: md, - createtime: createtime, - lastchangetime: lastchangetime, updateLastChange: updateLastChange, - lastchangeui: lastchangeui, - lastchangeuser: lastchangeuser, postProcess: postProcess, finishView: finishView, autoLinkify: autoLinkify, diff --git a/public/js/index.js b/public/js/index.js index 20a76ff..82d3ced 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -38,15 +38,12 @@ 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; diff --git a/public/js/pretty.js b/public/js/pretty.js index 6b551c1..1288225 100644 --- a/public/js/pretty.js +++ b/public/js/pretty.js @@ -7,7 +7,6 @@ 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; diff --git a/public/js/slide.js b/public/js/slide.js index 257c60b..d90fd43 100644 --- a/public/js/slide.js +++ b/public/js/slide.js @@ -22,23 +22,10 @@ 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'); +require('./render'); var body = $(".slides").html(); $(".slides").html(S(body).unescapeHTML().s); diff --git a/public/views/foot.ejs b/public/views/foot.ejs index 4ba18e3..b51920d 100644 --- a/public/views/foot.ejs +++ b/public/views/foot.ejs @@ -18,6 +18,7 @@ <% } %> + diff --git a/public/views/pretty.ejs b/public/views/pretty.ejs index b0eb568..09b548a 100644 --- a/public/views/pretty.ejs +++ b/public/views/pretty.ejs @@ -100,6 +100,7 @@ <% } %> + diff --git a/public/views/slide.ejs b/public/views/slide.ejs index 79d7708..679bed2 100644 --- a/public/views/slide.ejs +++ b/public/views/slide.ejs @@ -102,6 +102,7 @@ <% } %> + <%- include build/slide-scripts %> diff --git a/webpackBaseConfig.js b/webpackBaseConfig.js index 7bf3657..51eb2ad 100644 --- a/webpackBaseConfig.js +++ b/webpackBaseConfig.js @@ -79,10 +79,6 @@ module.exports = { locale: path.join(__dirname, 'public/js/locale.js'), vendor: [ "imports?$=jquery!jquery-mousewheel", - "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", @@ -129,7 +125,8 @@ module.exports = { "viz.js": "Viz", "socket.io-client": "io", "lodash": "_", - "jquery": "$" + "jquery": "$", + "moment": "moment" }, module: { From bcb12b9ae7d3562a05d007d6bab1042c1e6319fe Mon Sep 17 00:00:00 2001 From: Yukai Huang Date: Thu, 13 Oct 2016 15:30:26 +0800 Subject: [PATCH 04/12] Remove jquery-scrollspy dependency scrollspy is bootstrap built-in plugin --- bower.json | 3 +-- public/views/foot.ejs | 1 - public/views/pretty.ejs | 1 - 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/bower.json b/bower.json index 7b5e05a..d9923e2 100644 --- a/bower.json +++ b/bower.json @@ -30,8 +30,7 @@ "velocity": "^1.3.1", "randomcolor": "randomColor#^0.4.4", "Idle.Js": "idle.js#^1.0.0", - "gist-embed": "*", - "jquery-scrollspy": "softwarespot/jquery-scrollspy" + "gist-embed": "*" }, "resolutions": { "jquery": "~3.1.1" diff --git a/public/views/foot.ejs b/public/views/foot.ejs index b51920d..983ce3d 100644 --- a/public/views/foot.ejs +++ b/public/views/foot.ejs @@ -21,7 +21,6 @@ - <%- include build/index-scripts %> diff --git a/public/views/pretty.ejs b/public/views/pretty.ejs index 09b548a..d5814fc 100644 --- a/public/views/pretty.ejs +++ b/public/views/pretty.ejs @@ -102,7 +102,6 @@ - <%- include build/pretty-scripts %> From f678d9b81451fba0b196332a2d2d97310f2133ab Mon Sep 17 00:00:00 2001 From: Yukai Huang Date: Thu, 13 Oct 2016 15:54:17 +0800 Subject: [PATCH 05/12] Fix cheatsheet rendering do not process help-modal markdown-body --- public/js/pretty.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/js/pretty.js b/public/js/pretty.js index 1288225..c1c2b4a 100644 --- a/public/js/pretty.js +++ b/public/js/pretty.js @@ -10,7 +10,7 @@ var postProcess = extra.postProcess; var updateLastChange = extra.updateLastChange; var preventXSS = require('./render').preventXSS; -var markdown = $(".markdown-body"); +var markdown = $("#doc.markdown-body"); var text = $('