summaryrefslogtreecommitdiff
path: root/public
diff options
context:
space:
mode:
Diffstat (limited to 'public')
-rw-r--r--public/css/cover.css3
-rw-r--r--public/js/cover.js2
-rw-r--r--public/js/extra.js43
-rw-r--r--public/js/history.js62
-rw-r--r--public/js/index.js16
-rw-r--r--public/js/locale.js2
-rw-r--r--public/js/pretty.js5
-rw-r--r--public/js/public.js25
-rw-r--r--public/js/slide.js19
-rw-r--r--public/views/foot.ejs1
-rw-r--r--public/views/help-modal.ejs2
-rw-r--r--public/views/index.ejs2
-rw-r--r--public/views/pretty.ejs1
-rw-r--r--public/views/slide.ejs1
14 files changed, 73 insertions, 111 deletions
diff --git a/public/css/cover.css b/public/css/cover.css
index 228990ae..c8b35e8a 100644
--- a/public/css/cover.css
+++ b/public/css/cover.css
@@ -325,7 +325,8 @@ input {
.social-foot {
line-height: 30px;
}
-.social-foot > *, .social-foot > * > * {
+.social-foot > * {
+ line-height: 20px;
vertical-align: middle !important;
}
diff --git a/public/js/cover.js b/public/js/cover.js
index 3dd4de09..c02f6c81 100644
--- a/public/js/cover.js
+++ b/public/js/cover.js
@@ -1,3 +1,5 @@
+require('./locale');
+
var common = require('./common');
var checkIfAuth = common.checkIfAuth;
var urlpath = common.urlpath;
diff --git a/public/js/extra.js b/public/js/extra.js
index 436721a3..499bdc4c 100644
--- a/public/js/extra.js
+++ b/public/js/extra.js
@@ -1,3 +1,8 @@
+require('prismjs/themes/prism.css');
+require('highlight.js/styles/github-gist.css');
+
+var Prism = require('prismjs');
+require('prismjs/components/prism-wiki');
var hljs = require('highlight.js');
var PDFObject = require('pdfobject');
var S = require('string');
@@ -101,6 +106,41 @@ function renderFilename(view) {
return filename;
}
+// render tags
+function renderTags(view) {
+ var tags = [];
+ var rawtags = [];
+ if (md && md.meta && md.meta.tags && (typeof md.meta.tags == "string" || typeof md.meta.tags == "number")) {
+ var metaTags = ('' + md.meta.tags).split(',');
+ for (var i = 0; i < metaTags.length; i++) {
+ var text = metaTags[i].trim();
+ if (text) rawtags.push(text);
+ }
+ } else {
+ view.find('h6').each(function (key, value) {
+ if (/^tags/gmi.test($(value).text())) {
+ var codes = $(value).find("code");
+ for (var i = 0; i < codes.length; i++) {
+ var text = codes[i].innerHTML.trim();
+ if (text) rawtags.push(text);
+ }
+ }
+ });
+ }
+ for (var i = 0; i < rawtags.length; i++) {
+ var found = false;
+ for (var j = 0; j < tags.length; j++) {
+ if (tags[j] == rawtags[i]) {
+ found = true;
+ break;
+ }
+ }
+ if (!found)
+ tags.push(rawtags[i]);
+ }
+ return tags;
+}
+
function slugifyWithUTF8(text) {
var newText = S(text.toLowerCase()).trim().stripTags().dasherize().s;
newText = newText.replace(/([\!\"\#\$\%\&\'\(\)\*\+\,\.\/\:\;\<\=\>\?\@\[\\\]\^\`\{\|\}\~])/g, '');
@@ -844,8 +884,6 @@ md.use(require('markdown-it-emoji'), {
shortcuts: false
});
-var emojify = require('emojify.js');
-
emojify.setConfig({
blacklist: {
elements: ['script', 'textarea', 'a', 'pre', 'code', 'svg'],
@@ -1076,6 +1114,7 @@ module.exports = {
renderTOC: renderTOC,
renderTitle: renderTitle,
renderFilename: renderFilename,
+ renderTags: renderTags,
generateToc: generateToc,
smoothHashScroll: smoothHashScroll,
scrollToHash: scrollToHash,
diff --git a/public/js/history.js b/public/js/history.js
index d924eec1..390e38eb 100644
--- a/public/js/history.js
+++ b/public/js/history.js
@@ -5,10 +5,6 @@ var checkIfAuth = common.checkIfAuth;
var urlpath = common.urlpath;
var getLoginState = common.getLoginState;
-var extra = require('./extra');
-var renderFilename = extra.renderFilename;
-var md = extra.md;
-
window.migrateHistoryFromTempCallback = null;
migrateHistoryFromTemp();
@@ -147,19 +143,19 @@ function removeHistory(id, notehistory) {
}
//used for inner
-function writeHistory(view) {
+function writeHistory(title, tags) {
checkIfAuth(
function () {
// no need to do this anymore, this will count from server-side
- // writeHistoryToServer(view);
+ // writeHistoryToServer(title, tags);
},
function () {
- writeHistoryToStorage(view);
+ writeHistoryToStorage(title, tags);
}
);
}
-function writeHistoryToServer(view) {
+function writeHistoryToServer(title, tags) {
$.get(serverurl + '/history')
.done(function (data) {
try {
@@ -174,7 +170,7 @@ function writeHistoryToServer(view) {
if (!notehistory)
notehistory = [];
- var newnotehistory = generateHistory(view, notehistory);
+ var newnotehistory = generateHistory(title, tags, notehistory);
saveHistoryToServer(newnotehistory);
})
.fail(function (xhr, status, error) {
@@ -182,7 +178,7 @@ function writeHistoryToServer(view) {
});
}
-function writeHistoryToCookie(view) {
+function writeHistoryToCookie(title, tags) {
try {
var notehistory = Cookies.getJSON('notehistory');
} catch (err) {
@@ -191,11 +187,11 @@ function writeHistoryToCookie(view) {
if (!notehistory)
notehistory = [];
- var newnotehistory = generateHistory(view, notehistory);
+ var newnotehistory = generateHistory(title, tags, notehistory);
saveHistoryToCookie(newnotehistory);
}
-function writeHistoryToStorage(view) {
+function writeHistoryToStorage(title, tags) {
if (store.enabled) {
var data = store.get('notehistory');
if (data) {
@@ -207,10 +203,10 @@ function writeHistoryToStorage(view) {
if (!notehistory)
notehistory = [];
- var newnotehistory = generateHistory(view, notehistory);
+ var newnotehistory = generateHistory(title, tags, notehistory);
saveHistoryToStorage(newnotehistory);
} else {
- writeHistoryToCookie(view);
+ writeHistoryToCookie(title, tags);
}
}
@@ -220,39 +216,7 @@ if (!Array.isArray) {
};
}
-function renderHistory(view) {
- var title = renderFilename(view);
-
- var tags = [];
- var rawtags = [];
- if (md && md.meta && md.meta.tags && (typeof md.meta.tags == "string" || typeof md.meta.tags == "number")) {
- var metaTags = ('' + md.meta.tags).split(',');
- for (var i = 0; i < metaTags.length; i++) {
- var text = metaTags[i].trim();
- if (text) rawtags.push(text);
- }
- } else {
- view.find('h6').each(function (key, value) {
- if (/^tags/gmi.test($(value).text())) {
- var codes = $(value).find("code");
- for (var i = 0; i < codes.length; i++) {
- var text = codes[i].innerHTML.trim();
- if (text) rawtags.push(text);
- }
- }
- });
- }
- for (var i = 0; i < rawtags.length; i++) {
- var found = false;
- for (var j = 0; j < tags.length; j++) {
- if (tags[j] == rawtags[i]) {
- found = true;
- break;
- }
- }
- if (!found)
- tags.push(rawtags[i]);
- }
+function renderHistory(title, tags) {
//console.debug(tags);
var id = urlpath ? location.pathname.slice(urlpath.length + 1, location.pathname.length).split('/')[1] : location.pathname.split('/')[1];
return {
@@ -263,8 +227,8 @@ function renderHistory(view) {
};
}
-function generateHistory(view, notehistory) {
- var info = renderHistory(view);
+function generateHistory(title, tags, notehistory) {
+ var info = renderHistory(title, tags);
//keep any pinned data
var pinned = false;
for (var i = 0; i < notehistory.length; i++) {
diff --git a/public/js/index.js b/public/js/index.js
index bdd4c822..4be11e86 100644
--- a/public/js/index.js
+++ b/public/js/index.js
@@ -1,16 +1,11 @@
/* 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 url = require('js-url');
+var randomColor = require('randomcolor');
var _ = require("lodash");
@@ -28,7 +23,6 @@ var noteurl = common.noteurl;
var checkLoginStateChanged = common.checkLoginStateChanged;
-require('./pretty');
var extra = require('./extra');
var md = extra.md;
var updateLastChange = extra.updateLastChange;
@@ -41,6 +35,7 @@ var deduplicatedHeaderId = extra.deduplicatedHeaderId;
var renderTOC = extra.renderTOC;
var renderTitle = extra.renderTitle;
var renderFilename = extra.renderFilename;
+var renderTags = extra.renderTags;
var scrollToHash = extra.scrollToHash;
var updateLastChangeUser = extra.updateLastChangeUser;
var updateOwner = extra.updateOwner;
@@ -1541,6 +1536,7 @@ function onGoogleClientLoaded() {
googleApiAuth(true);
buildImportFromGoogleDrive();
}
+window.onGoogleClientLoaded = onGoogleClientLoaded;
// export to google drive
ui.toolbar.export.googleDrive.click(function (e) {
var token = gapi.auth.getToken();
@@ -3414,7 +3410,7 @@ var updateHistoryDebounce = 600;
var updateHistory = _.debounce(updateHistoryInner, updateHistoryDebounce)
function updateHistoryInner() {
- writeHistory(ui.area.markdown);
+ writeHistory(renderFilename(ui.area.markdown), renderTags(ui.area.markdown));
}
function updateDataAttrs(src, des) {
@@ -3732,8 +3728,6 @@ function matchInContainer(text) {
}
}
-var emojify = require('emojify.js');
-
$(editor.getInputField())
.textcomplete([
{ // emoji strategy
diff --git a/public/js/locale.js b/public/js/locale.js
index 484ce22f..702496e7 100644
--- a/public/js/locale.js
+++ b/public/js/locale.js
@@ -1,5 +1,3 @@
-require('./cover');
-
var lang = "en";
var userLang = navigator.language || navigator.userLanguage;
var userLangCode = userLang.split('-')[0];
diff --git a/public/js/pretty.js b/public/js/pretty.js
index c5211202..59403586 100644
--- a/public/js/pretty.js
+++ b/public/js/pretty.js
@@ -1,3 +1,6 @@
+/* other vendors plugin */
+var S = require('string');
+
var extra = require('./extra');
var md = extra.md;
var finishView = extra.finishView;
@@ -12,7 +15,7 @@ var parseMeta = extra.parseMeta;
var preventXSS = require('./render').preventXSS;
var markdown = $("#doc.markdown-body");
-var text = $('<textarea/>').html(markdown.html()).text();
+var text = S(markdown.html()).unescapeHTML().s;
var lastMeta = md.meta;
md.meta = {};
var rendered = md.render(text);
diff --git a/public/js/public.js b/public/js/public.js
deleted file mode 100644
index f83ef41f..00000000
--- a/public/js/public.js
+++ /dev/null
@@ -1,25 +0,0 @@
-/* jquery and jquery plugins */
-require('../vendor/showup/showup');
-
-require('prismjs/themes/prism.css');
-require('highlight.js/styles/github-gist.css');
-
-/* other vendors plugin */
-require('string');
-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('./extra');
-require('./syncscroll');
-require('./history');
-require('./pretty');
-require('./render');
diff --git a/public/js/slide.js b/public/js/slide.js
index 2536c602..c260de6d 100644
--- a/public/js/slide.js
+++ b/public/js/slide.js
@@ -1,30 +1,13 @@
-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 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 updateLastChange = extraModule.updateLastChange;
var finishView = extraModule.finishView;
-require('./render');
+var preventXSS = require('./render').preventXSS;
var body = $(".slides").html();
$(".slides").html(S(body).unescapeHTML().s);
diff --git a/public/views/foot.ejs b/public/views/foot.ejs
index e2af5b0e..a322b0af 100644
--- a/public/views/foot.ejs
+++ b/public/views/foot.ejs
@@ -16,6 +16,7 @@
<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/emojify.js/dist/js/emojify.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/jqueryui/1.12.1/jquery-ui.min.js"></script>
diff --git a/public/views/help-modal.ejs b/public/views/help-modal.ejs
index fd8bfbff..08fee9c0 100644
--- a/public/views/help-modal.ejs
+++ b/public/views/help-modal.ejs
@@ -113,7 +113,7 @@
<td>```javascript<br>var i = 0;<br>```</td>
</tr>
<tr>
- <td><img align="absmiddle" alt=":smile:" class="emoji" src="./vendor/emojify/images/smile.png" title=":smile:"></img></td>
+ <td><img align="absmiddle" alt=":smile:" class="emoji" src="./vendor/emojify.js/dist/images/basic/smile.png" title=":smile:"></img></td>
<td>:smile:</td>
</tr>
<tr>
diff --git a/public/views/index.ejs b/public/views/index.ejs
index 7c0b8c95..e97f9385 100644
--- a/public/views/index.ejs
+++ b/public/views/index.ejs
@@ -142,7 +142,7 @@
<div class="mastfoot">
<div class="inner">
<h6 class="social-foot">
- <iframe src="//ghbtns.com/github-btn.html?user=hackmdio&repo=hackmd&type=star&count=true" frameborder="0" scrolling="0" width="90px" height="20px"></iframe>
+ <iframe src="//ghbtns.com/github-btn.html?user=hackmdio&repo=hackmd&type=star&count=true" frameborder="0" scrolling="0" width="104px" height="20px"></iframe>
</h6>
<p>
&copy; 2016 <a href="https://www.facebook.com/TakeHackMD" target="_blank"><i class="fa fa-facebook-square"></i> HackMD</a> | <a href="<%- url %>/s/release-notes" target="_blank"><%= __('Releases') %></a>
diff --git a/public/views/pretty.ejs b/public/views/pretty.ejs
index 21632ec2..75650536 100644
--- a/public/views/pretty.ejs
+++ b/public/views/pretty.ejs
@@ -98,6 +98,7 @@
<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/emojify.js/dist/js/emojify.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/jqueryui/1.12.1/jquery-ui.min.js"></script>
diff --git a/public/views/slide.ejs b/public/views/slide.ejs
index dedfc98d..9dbefa6f 100644
--- a/public/views/slide.ejs
+++ b/public/views/slide.ejs
@@ -100,6 +100,7 @@
<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/emojify.js/dist/js/emojify.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/jqueryui/1.12.1/jquery-ui.min.js"></script>