summaryrefslogtreecommitdiff
path: root/public
diff options
context:
space:
mode:
authorWu Cheng-Han2015-09-25 19:09:43 +0800
committerWu Cheng-Han2015-09-25 19:09:43 +0800
commit5f82df7eb2f37b06684e380fd261b8eb9ea2d50b (patch)
treebdffc648391cbce4f7f9a3b235687e2a8593627f /public
parent60414febee5fd14743fd80cad9d681c3027272dd (diff)
Added support of export to HTML, and changed the navbar menu for consistency
Diffstat (limited to '')
-rw-r--r--public/css/compress.sh1
-rw-r--r--public/css/html.min.css1
-rw-r--r--public/js/extra.js62
-rw-r--r--public/js/index.js13
-rw-r--r--public/views/header.ejs22
-rw-r--r--public/views/html.hbs166
6 files changed, 253 insertions, 12 deletions
diff --git a/public/css/compress.sh b/public/css/compress.sh
new file mode 100644
index 00000000..560ed422
--- /dev/null
+++ b/public/css/compress.sh
@@ -0,0 +1 @@
+cleancss -o html.min.css github-extract.css markdown.css extra.css site.css \ No newline at end of file
diff --git a/public/css/html.min.css b/public/css/html.min.css
new file mode 100644
index 00000000..679c0142
--- /dev/null
+++ b/public/css/html.min.css
@@ -0,0 +1 @@
+.markdown-body h1,.markdown-body h2{padding-bottom:.3em;border-bottom:1px solid #eee}.markdown-body{overflow:hidden;font-size:1pc;line-height:1.6;word-wrap:break-word}.markdown-body>:first-child{margin-top:0!important}.markdown-body>:last-child{margin-bottom:0!important}.markdown-body .absent{color:#c00}.markdown-body .anchor{position:absolute;top:0;bottom:0;left:0;display:block;padding-right:6px;padding-left:30px;margin-left:-30px}.markdown-body .anchor:focus{outline:0}.markdown-body h1,.markdown-body h2,.markdown-body h3,.markdown-body h4,.markdown-body h5,.markdown-body h6{position:relative;margin-top:1em;margin-bottom:1pc;font-weight:700;line-height:1.4}.markdown-body h1 .octicon-link,.markdown-body h2 .octicon-link,.markdown-body h3 .octicon-link,.markdown-body h4 .octicon-link,.markdown-body h5 .octicon-link,.markdown-body h6 .octicon-link{display:none;color:#000;vertical-align:middle}.markdown-body h1:hover .anchor,.markdown-body h2:hover .anchor,.markdown-body h3:hover .anchor,.markdown-body h4:hover .anchor,.markdown-body h5:hover .anchor,.markdown-body h6:hover .anchor{padding-left:8px;margin-left:-30px;line-height:1;text-decoration:none}.markdown-body h1:hover .anchor .octicon-link,.markdown-body h2:hover .anchor .octicon-link,.markdown-body h3:hover .anchor .octicon-link,.markdown-body h4:hover .anchor .octicon-link,.markdown-body h5:hover .anchor .octicon-link,.markdown-body h6:hover .anchor .octicon-link{display:inline-block}.markdown-body h1 code,.markdown-body h1 tt,.markdown-body h2 code,.markdown-body h2 tt,.markdown-body h3 code,.markdown-body h3 tt,.markdown-body h4 code,.markdown-body h4 tt,.markdown-body h5 code,.markdown-body h5 tt,.markdown-body h6 code,.markdown-body h6 tt{font-size:inherit}.markdown-body h1{font-size:2.25em;line-height:1.2}.markdown-body h2{font-size:1.75em;line-height:1.225}.markdown-body h3{font-size:1.5em;line-height:1.43}.markdown-body h4{font-size:1.25em}.markdown-body h5{font-size:1em}.markdown-body h6{font-size:1em;color:#777}.markdown-body blockquote,.markdown-body dl,.markdown-body ol,.markdown-body p,.markdown-body pre,.markdown-body table,.markdown-body ul{margin-top:0;margin-bottom:1pc}.markdown-body hr{height:4px;padding:0;margin:1pc 0;background-color:#e7e7e7;border:0}.markdown-body ol,.markdown-body ul{padding-left:2em}.markdown-body ol.no-list,.markdown-body ul.no-list{padding:0;list-style-type:none}.markdown-body ol ol,.markdown-body ol ul,.markdown-body ul ol,.markdown-body ul ul{margin-top:0;margin-bottom:0}.markdown-body li>p{margin-top:1pc}.markdown-body dl{padding:0}.markdown-body dl dt{padding:0;margin-top:1pc;font-size:1em;font-style:italic;font-weight:700}.markdown-body dl dd{padding:0 1pc;margin-bottom:1pc}.markdown-body blockquote{padding:0 15px;color:#777;border-left:4px solid #ddd}.markdown-body blockquote>:first-child{margin-top:0}.markdown-body blockquote>:last-child{margin-bottom:0}.markdown-body table{display:block;width:100%;overflow:auto;word-break:normal;word-break:keep-all}.markdown-body table th{font-weight:700}.markdown-body table td,.markdown-body table th{padding:6px 13px;border:1px solid #ddd}.markdown-body table tr{background-color:#fff;border-top:1px solid #ccc}.markdown-body table tr:nth-child(2n){background-color:#f8f8f8}.markdown-body img{max-width:100%;-moz-box-sizing:border-box;box-sizing:border-box}.markdown-body .emoji{width:20px;height:20px;max-width:none;margin-bottom:0}.markdown-body span.frame{display:block;overflow:hidden}.markdown-body span.frame>span{display:block;float:left;width:auto;padding:7px;margin:13px 0 0;overflow:hidden;border:1px solid #ddd}.markdown-body span.frame span img{display:block;float:left}.markdown-body span.frame span span{display:block;padding:5px 0 0;clear:both;color:#333}.markdown-body span.align-center{display:block;overflow:hidden;clear:both}.markdown-body span.align-center>span{display:block;margin:13px auto 0;overflow:hidden;text-align:center}.markdown-body span.align-center span img{margin:0 auto;text-align:center}.markdown-body span.align-right{display:block;overflow:hidden;clear:both}.markdown-body span.align-right>span{display:block;margin:13px 0 0;overflow:hidden;text-align:right}.markdown-body span.align-right span img{margin:0;text-align:right}.markdown-body span.float-left{display:block;float:left;margin-right:13px;overflow:hidden}.markdown-body span.float-left span{margin:13px 0 0}.markdown-body span.float-right{display:block;float:right;margin-left:13px;overflow:hidden}.markdown-body span.float-right>span{display:block;margin:13px auto 0;overflow:hidden;text-align:right}.markdown-body code,.markdown-body tt{padding:.2em 0;margin:0;font-size:85%;background-color:rgba(0,0,0,.04);border-radius:3px}.markdown-body code:after,.markdown-body code:before,.markdown-body tt:after,.markdown-body tt:before{letter-spacing:-.2em;content:"\00a0"}.markdown-body code br,.markdown-body tt br{display:none}.markdown-body del code{text-decoration:inherit}.markdown-body pre>code{padding:0;margin:0;font-size:100%;word-break:normal;white-space:pre;background:0 0;border:0}.markdown-body .highlight{margin-bottom:1pc}.markdown-body .highlight pre,.markdown-body pre{padding:1pc;overflow:auto;font-size:85%;line-height:1.45;background-color:#f7f7f7;border-radius:3px}.markdown-body .highlight pre{margin-bottom:0;word-break:normal}.markdown-body pre code,.markdown-body pre tt{display:inline;max-width:initial;padding:0;margin:0;overflow:initial;line-height:inherit;word-wrap:normal;background-color:transparent;border:0}.markdown-body pre code:after,.markdown-body pre code:before,.markdown-body pre tt:after,.markdown-body pre tt:before{content:normal}.markdown-body .csv-data td,.markdown-body .csv-data th{padding:5px;overflow:hidden;font-size:9pt;line-height:1;text-align:left;white-space:nowrap}.markdown-body .csv-data .blob-line-num{padding:10px 8px 9px;text-align:right;background:#fff;border:0}.markdown-body .csv-data tr{border-top:0}.markdown-body .csv-data th{font-weight:700;background:#f8f8f8;border-top:0}.news .alert .markdown-body blockquote{padding:0 0 0 40px;border:0}.activity-tab .news .alert .commits,.activity-tab .news .markdown-body blockquote{padding-left:0}.task-list-item{list-style-type:none}.task-list-item label{font-weight:400}.task-list-item.enabled label{cursor:pointer}.task-list-item+.task-list-item{margin-top:3px}.task-list-item-checkbox{float:left;margin:.31em 0 .2em -1.3em!important;vertical-align:middle;cursor:default!important}.markdown-body{font-family:"Helvetica Neue",Helvetica,Arial,"Microsoft JhengHei",Meiryo,"MS ゴシック","MS Gothic",sans-serif;padding-top:40px;padding-bottom:40px;max-width:758px}.markdown-body pre{word-wrap:normal;border:inherit!important}.markdown-body code{color:inherit!important}.markdown-body pre code .wrapper{display:-webkit-inline-flex;display:-moz-inline-flex;display:-ms-inline-flex;display:-o-inline-flex;display:inline-flex}.markdown-body pre code .gutter{float:left;overflow:hidden;-webkit-user-select:none;user-select:none}.markdown-body pre code .gutter.linenumber{text-align:right;position:relative;display:inline-block;float:right;cursor:default;z-index:4;padding:0 8px 0 0;min-width:20px;box-sizing:content-box;color:#afafaf!important;border-right:3px solid #6ce26c!important}.markdown-body .flow-chart,.markdown-body .sequence-diagram,.vimeo,.youtube{text-align:center}.markdown-body pre code .gutter.linenumber>span:before{content:attr(data-linenumber)}.markdown-body pre code .code{float:left;margin:0 0 0 1pc}.markdown-body .gist .line-numbers{border-left:none;border-top:none;border-bottom:none}.markdown-body .gist .line-data{border:none}.markdown-body .gist table{border-spacing:0;border-collapse:inherit!important}.markdown-body code[data-gist-id]{background:0 0;padding:0}.markdown-body code[data-gist-id]:after,.markdown-body code[data-gist-id]:before{content:''}.markdown-body .flow-chart{margin-bottom:40px}svg{width:100%;max-height:70vh}.vimeo,.youtube{position:relative;cursor:pointer;display:table;max-width:540px;background-position:center center;background-repeat:no-repeat;background-size:contain;background-color:#000}.vimeo img,.youtube img{position:absolute;margin:auto;top:0;left:0;right:0;bottom:0}.vimeo .icon,.youtube .icon{position:absolute;height:auto;width:auto;top:50%;left:50%;margin-top:-40px;margin-left:-40px;color:#fff;opacity:.3;-webkit-transition:opacity .2s;transition:opacity .2s}.vimeo:hover .icon,.youtube:hover .icon{opacity:.6;-webkit-transition:opacity .2s;transition:opacity .2s}h1:hover .header-link,h2:hover .header-link,h3:hover .header-link,h4:hover .header-link,h5:hover .header-link,h6:hover .header-link{opacity:1;-webkit-transition:opacity .2s ease-in-out .1s;-moz-transition:opacity .2s ease-in-out .1s;-o-transition:opacity .2s ease-in-out .1s;transition:opacity .2s ease-in-out .1s}.header-link{position:relative;left:.5em;opacity:0;font-size:.8em;-webkit-transition:opacity .2s ease-in-out .1s;-moz-transition:opacity .2s ease-in-out .1s;-o-transition:opacity .2s ease-in-out .1s;transition:opacity .2s ease-in-out .1s}.ui-infobar{max-width:758px;margin-top:25px;margin-bottom:-25px;color:#777}.ui-toc{position:fixed;bottom:20px;z-index:10000}.ui-toc-label{opacity:.3;background-color:#ccc;border:none;-webkit-transition:opacity .2s;transition:opacity .2s}.ui-toc .open .ui-toc-label{opacity:1;color:#fff;-webkit-transition:opacity .2s;transition:opacity .2s}.ui-toc-label:focus{opacity:.3;background-color:#ccc;color:#000}.ui-toc-label:hover{opacity:1;background-color:#ccc;-webkit-transition:opacity .2s;transition:opacity .2s}.ui-toc-dropdown{margin-top:23px;margin-bottom:20px;padding-left:10px;padding-right:10px;max-width:45vw;width:25vw;max-height:65vh;overflow:auto}.ui-toc-dropdown a{overflow:hidden;text-overflow:ellipsis;white-space:pre}.ui-toc-dropdown .nav>li>a{display:block;padding:4px 20px;font-size:13px;font-weight:500;color:#767676}.ui-toc-dropdown .nav>li>a:focus,.ui-toc-dropdown .nav>li>a:hover{padding-left:19px;color:#000;text-decoration:none;background-color:transparent;border-left:1px solid #000}.ui-toc-dropdown .nav>.active:focus>a,.ui-toc-dropdown .nav>.active:hover>a,.ui-toc-dropdown .nav>.active>a{padding-left:18px;font-weight:700;color:#000;background-color:transparent;border-left:2px solid #000}.ui-toc-dropdown .nav .nav{display:none;padding-bottom:10px}.ui-toc-dropdown .nav>.active>ul{display:block}.ui-toc-dropdown .nav .nav>li>a{padding-top:1px;padding-bottom:1px;padding-left:30px;font-size:9pt;font-weight:400}.ui-toc-dropdown .nav .nav>li>ul>li>a{padding-top:1px;padding-bottom:1px;padding-left:40px;font-size:9pt;font-weight:400}.ui-toc-dropdown .nav .nav>li>a:focus,.ui-toc-dropdown .nav .nav>li>a:hover{padding-left:29px}.ui-toc-dropdown .nav .nav>li>ul>li>a:focus,.ui-toc-dropdown .nav .nav>li>ul>li>a:hover{padding-left:39px}.ui-toc-dropdown .nav .nav>.active:focus>a,.ui-toc-dropdown .nav .nav>.active:hover>a,.ui-toc-dropdown .nav .nav>.active>a{padding-left:28px;font-weight:500}.ui-toc-dropdown .nav .nav>.active>.nav>.active:focus>a,.ui-toc-dropdown .nav .nav>.active>.nav>.active:hover>a,.ui-toc-dropdown .nav .nav>.active>.nav>.active>a{padding-left:38px;font-weight:500}.ui-affix-toc{position:fixed;top:0;max-width:15vw;max-height:70vh;overflow:auto}.back-to-top,.go-to-bottom{display:block;padding:4px 10px;margin-top:10px;margin-left:10px;font-size:9pt;font-weight:500;color:#999}.back-to-top:focus,.back-to-top:hover,.go-to-bottom:focus,.go-to-bottom:hover{color:#563d7c;text-decoration:none}.go-to-bottom{margin-top:0}small span{line-height:22px}small .dropdown{display:inline-block}small .dropdown a:focus,small .dropdown a:hover{text-decoration:none}.unselectable{-moz-user-select:none;-khtml-user-select:none;-webkit-user-select:none;-o-user-select:none;user-select:none}@media print{blockquote,div,img,pre,table{page-break-inside:avoid!important}a[href]:after{font-size:9pt!important}}@font-face{font-family:'Source Code Pro';font-style:normal;font-weight:300;src:local('Source Code Pro Light'),local('SourceCodePro-Light'),url(https://fonts.gstatic.com/s/sourcecodepro/v6/leqv3v-yTsJNC7nFznSMqUBls_1aQwi4AfipSOlE3SU.ttf) format('truetype')}@font-face{font-family:'Source Code Pro';font-style:normal;font-weight:400;src:local('Source Code Pro'),local('SourceCodePro-Regular'),url(https://fonts.gstatic.com/s/sourcecodepro/v6/mrl8jkM18OlOQN8JLgasD1zCdIATDt8zXO3QNtzVeJ8.ttf) format('truetype')}@font-face{font-family:'Source Code Pro';font-style:normal;font-weight:500;src:local('Source Code Pro Medium'),local('SourceCodePro-Medium'),url(https://fonts.gstatic.com/s/sourcecodepro/v6/leqv3v-yTsJNC7nFznSMqdgxThF69EFTxeh70dQtJtE.ttf) format('truetype')}@font-face{font-family:'Source Sans Pro';font-style:normal;font-weight:300;src:local('Source Sans Pro Light'),local('SourceSansPro-Light'),url(https://fonts.gstatic.com/s/sourcesanspro/v9/toadOcfmlt9b38dHJxOBGEBls_1aQwi4AfipSOlE3SU.ttf) format('truetype')}@font-face{font-family:'Source Sans Pro';font-style:normal;font-weight:400;src:local('Source Sans Pro'),local('SourceSansPro-Regular'),url(https://fonts.gstatic.com/s/sourcesanspro/v9/ODelI1aHBYDBqgeIAH2zlFzCdIATDt8zXO3QNtzVeJ8.ttf) format('truetype')}@font-face{font-family:'Source Sans Pro';font-style:normal;font-weight:600;src:local('Source Sans Pro Semibold'),local('SourceSansPro-Semibold'),url(https://fonts.gstatic.com/s/sourcesanspro/v9/toadOcfmlt9b38dHJxOBGGvd-IutAbwf5FQ8ZpuI2w4.ttf) format('truetype')}@font-face{font-family:'Source Sans Pro';font-style:italic;font-weight:300;src:local('Source Sans Pro Light Italic'),local('SourceSansPro-LightIt'),url(https://fonts.gstatic.com/s/sourcesanspro/v9/fpTVHK8qsXbIeTHTrnQH6I48KljrVa8Zcyi9xGGohEU.ttf) format('truetype')}@font-face{font-family:'Source Sans Pro';font-style:italic;font-weight:400;src:local('Source Sans Pro Italic'),local('SourceSansPro-It'),url(https://fonts.gstatic.com/s/sourcesanspro/v9/M2Jd71oPJhLKp0zdtTvoM6xot8ENfkYez2Lz7rcrw70.ttf) format('truetype')}@font-face{font-family:'Source Sans Pro';font-style:italic;font-weight:600;src:local('Source Sans Pro Semibold Italic'),local('SourceSansPro-SemiboldIt'),url(https://fonts.gstatic.com/s/sourcesanspro/v9/fpTVHK8qsXbIeTHTrnQH6KjMMkbXdLGS8FpAnMJn5J0.ttf) format('truetype')}@font-face{font-family:'Source Serif Pro';font-style:normal;font-weight:400;src:local('Source Serif Pro'),local('SourceSerifPro-Regular'),url(https://fonts.gstatic.com/s/sourceserifpro/v4/CeUM4np2c42DV49nanp55WdjwOOpWxWrsXXkZJyNRnI.ttf) format('truetype')}body{font-smoothing:subpixel-antialiased!important;-webkit-font-smoothing:subpixel-antialiased!important;-moz-osx-font-smoothing:auto!important;text-shadow:1px 1px 1px rgba(0,0,0,.004);-webkit-overflow-scrolling:touch;font-family:"Source Sans Pro",Helvetica,Arial,"Microsoft JhengHei UI","Meiryo UI","MS Pゴシック","MS PGothic",sans-serif;letter-spacing:.025em}:focus{outline:0!important}::-moz-focus-inner{border:0!important}body.modal-open{overflow-y:auto;padding-right:0!important} \ No newline at end of file
diff --git a/public/js/extra.js b/public/js/extra.js
index fd150bea..3a0f006e 100644
--- a/public/js/extra.js
+++ b/public/js/extra.js
@@ -212,8 +212,70 @@ function postProcess(code) {
result.find('a:not([target])').attr('target', '_blank');
return result;
}
+
+//extract markdown body to html and compile to template
+function exportToHTML(view) {
+ var title = renderTitle(ui.area.markdown);
+ var filename = renderFilename(ui.area.markdown) + '.html';
+ var src = view.clone();
+ var eles = src.find('*');
+ //remove syncscroll parts
+ eles.removeClass('part');
+ src.find('*[class=""]').removeAttr('class');
+ eles.removeAttr('data-startline data-endline');
+ eles.find("a[href^='#'][smoothhashscroll]").removeAttr('smoothhashscroll');
+ //remove gist content
+ src.find("code[data-gist-id]").children().remove();
+ //disable todo list
+ src.find("input.task-list-item-checkbox").attr('disabled', '');
+ //replace emoji image path
+ src.find("img.emoji").each(function (key, value) {
+ var name = $(value).attr('alt');
+ name = name.substr(1);
+ name = name.slice(0, name.length - 1);
+ $(value).attr('src', 'https://www.tortue.me/emoji/' + name + '.png');
+ });
+ //replace video to iframe
+ src.find("div[videoid]").each(function (key, value) {
+ var id = $(value).attr('videoid');
+ var style = $(value).attr('style');
+ var url = null;
+ if ($(value).hasClass('youtube')) {
+ url = 'https://www.youtube.com/embed/';
+ } else if ($(value).hasClass('vimeo')) {
+ url = 'https://player.vimeo.com/video/';
}
+ if (url) {
+ var iframe = $('<iframe frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>');
+ iframe.attr('src', url + id);
+ iframe.attr('style', style);
+ $(value).html(iframe);
}
+ });
+ //generate toc
+ var toc = $('#toc').clone();
+ toc.find('*').removeClass('active');
+ var tocAffix = $('#toc-affix').clone();
+ tocAffix.find('*').removeClass('active');
+ //generate html via template
+ $.get('/css/html.min.css', function (css) {
+ $.get('/views/html.hbs', function (data) {
+ var template = Handlebars.compile(data);
+ var context = {
+ title: title,
+ css: css,
+ html: src[0].outerHTML,
+ toc: toc.html(),
+ 'toc-affix': tocAffix.html()
+ };
+ var html = template(context);
+ // console.log(html);
+ var blob = new Blob([html], {
+ type: "text/html;charset=utf-8"
+ });
+ saveAs(blob, filename);
+ });
+ });
}
//jQuery sortByDepth
diff --git a/public/js/index.js b/public/js/index.js
index 8e1bd41d..8bfecede 100644
--- a/public/js/index.js
+++ b/public/js/index.js
@@ -285,9 +285,10 @@ var ui = {
new: $(".ui-new"),
publish: $(".ui-publish"),
download: {
- markdown: $(".ui-download-markdown")
+ markdown: $(".ui-download-markdown"),
+ html: $(".ui-download-html")
},
- save: {
+ export: {
dropbox: $(".ui-save-dropbox")
},
import: {
@@ -801,8 +802,12 @@ ui.toolbar.download.markdown.click(function () {
});
saveAs(blob, filename);
});
-//save to dropbox
-ui.toolbar.save.dropbox.click(function () {
+//html
+ui.toolbar.download.html.click(function () {
+ exportToHTML(ui.area.markdown);
+});
+//export to dropbox
+ui.toolbar.export.dropbox.click(function () {
var filename = renderFilename(ui.area.markdown) + '.md';
var options = {
files: [
diff --git a/public/views/header.ejs b/public/views/header.ejs
index 88e63374..3e33e1e9 100644
--- a/public/views/header.ejs
+++ b/public/views/header.ejs
@@ -27,20 +27,22 @@
<li role="presentation"><a role="menuitem" class="ui-publish" tabindex="-1" href="#" target="_blank"><i class="fa fa-print fa-fw"></i> Publish</a>
</li>
<li class="divider"></li>
- <li class="dropdown-header">Save</li>
+ <li class="dropdown-header">Export</li>
<li role="presentation"><a role="menuitem" class="ui-save-dropbox" tabindex="-1" href="#" target="_self"><i class="fa fa-dropbox fa-fw"></i> Dropbox</a>
</li>
<li class="divider"></li>
- <li class="dropdown-header">Download</li>
- <li role="presentation"><a role="menuitem" class="ui-download-markdown" tabindex="-1" href="#" target="_self"><i class="fa fa-file-text fa-fw"></i> Markdown</a>
- </li>
- <li class="divider"></li>
<li class="dropdown-header">Import</li>
<li role="presentation"><a role="menuitem" class="ui-import-dropbox" tabindex="-1" href="#" target="_self"><i class="fa fa-dropbox fa-fw"></i> Dropbox</a>
</li>
<li role="presentation"><a role="menuitem" class="ui-import-clipboard" href="#" data-toggle="modal" data-target="#clipboardModal"><i class="fa fa-clipboard fa-fw"></i> Clipboard</a>
</li>
<li class="divider"></li>
+ <li class="dropdown-header">Download</li>
+ <li role="presentation"><a role="menuitem" class="ui-download-markdown" tabindex="-1" href="#" target="_self"><i class="fa fa-file-text fa-fw"></i> Markdown</a>
+ </li>
+ <li role="presentation"><a role="menuitem" class="ui-download-html" tabindex="-1" href="#" target="_self"><i class="fa fa-file-code-o fa-fw"></i> HTML</a>
+ </li>
+ <li class="divider"></li>
<li><a href="https://www.facebook.com/messages/866415986748945" class="ui-feedback" title="Feedback" target="_blank"><i class="fa fa-bullhorn fa-fw"></i> Feedback</a>
</li>
</ul>
@@ -94,17 +96,21 @@
Menu <i class="fa fa-caret-down"></i>
</a>
<ul class="dropdown-menu" role="menu" aria-labelledby="menu">
- <li class="dropdown-header">Save</li>
+ <li class="dropdown-header">Export</li>
<li role="presentation"><a role="menuitem" class="ui-save-dropbox" tabindex="-1" href="#" target="_self"><i class="fa fa-dropbox fa-fw"></i> Dropbox</a>
</li>
- <li role="presentation"><a role="menuitem" class="ui-download-markdown" tabindex="-1" href="#" target="_self"><i class="fa fa-file-text fa-fw"></i> Markdown</a>
- </li>
<li class="divider"></li>
<li class="dropdown-header">Import</li>
<li role="presentation"><a role="menuitem" class="ui-import-dropbox" tabindex="-1" href="#" target="_self"><i class="fa fa-dropbox fa-fw"></i> Dropbox</a>
</li>
<li role="presentation"><a role="menuitem" class="ui-import-clipboard" href="#" data-toggle="modal" data-target="#clipboardModal"><i class="fa fa-clipboard fa-fw"></i> Clipboard</a>
</li>
+ <li class="divider"></li>
+ <li class="dropdown-header">Download</li>
+ <li role="presentation"><a role="menuitem" class="ui-download-markdown" tabindex="-1" href="#" target="_self"><i class="fa fa-file-text fa-fw"></i> Markdown</a>
+ </li>
+ <li role="presentation"><a role="menuitem" class="ui-download-html" tabindex="-1" href="#" target="_self"><i class="fa fa-file-code-o fa-fw"></i> HTML</a>
+ </li>
</ul>
</li>
</ul>
diff --git a/public/views/html.hbs b/public/views/html.hbs
new file mode 100644
index 00000000..5ae63253
--- /dev/null
+++ b/public/views/html.hbs
@@ -0,0 +1,166 @@
+<!DOCTYPE html>
+
+<html lang="en">
+
+<head>
+ <meta charset="utf-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
+ <meta name="apple-mobile-web-app-capable" content="yes">
+ <meta name="apple-mobile-web-app-status-bar-style" content="black">
+ <meta name="mobile-web-app-capable" content="yes">
+ <title>
+ {{title}}
+ </title>
+ <link rel="icon" type="image/png" href="https://hackmd.io/favicon.png">
+ <link rel="apple-touch-icon" href="https://hackmd.io/apple-touch-icon.png">
+
+ <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
+ <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/highlight.js/8.8.0/styles/github-gist.min.css">
+ <style>
+ {{{css}}}
+ </style>
+</head>
+
+<body>
+ {{{html}}}
+ <div class="ui-toc dropup unselectable hidden-print" style="display:none;">
+ <div class="pull-right dropdown">
+ <a id="tocLabel" class="ui-toc-label btn btn-default" data-target="#" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false" title="Table of content">
+ <i class="fa fa-bars"></i>
+ </a>
+ <ul id="toc" class="ui-toc-dropdown dropdown-menu" aria-labelledby="tocLabel">
+ {{{toc}}}
+ </ul>
+ </div>
+ </div>
+ <div id="toc-affix" class="ui-affix-toc ui-toc-dropdown unselectable hidden-print" data-spy="affix" style="top:17px;display:none;">
+ {{{toc-affix}}}
+ </div>
+ <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
+ <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js" defer></script>
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/gist-embed/2.2/gist-embed.min.js" defer></script>
+ <script>
+ var markdown = $(".markdown-body");
+ //smooth all hash trigger scrolling
+ function smoothHashScroll() {
+ var hashElements = $("a[href^='#']").toArray();
+ for (var i = 0; i < hashElements.length; i++) {
+ var element = hashElements[i];
+ var $element = $(element);
+ var hash = element.hash;
+ if (hash) {
+ $element.on('click', function (e) {
+ // store hash
+ var hash = this.hash;
+ if ($(hash).length <= 0) return;
+ // prevent default anchor click behavior
+ e.preventDefault();
+ // animate
+ $('body, html').stop(true, true).animate({
+ scrollTop: $(hash).offset().top
+ }, 100, "linear", function () {
+ // when done, add hash to url
+ // (default click behaviour)
+ window.location.hash = hash;
+ });
+ });
+ }
+ }
+ }
+
+ smoothHashScroll();
+ var toc = $('.ui-toc');
+ var tocAffix = $('.ui-affix-toc');
+ var tocDropdown = $('.ui-toc-dropdown');
+ //toc
+ tocDropdown.click(function (e) {
+ e.stopPropagation();
+ });
+
+ var enoughForAffixToc = true;
+
+ function generateScrollspy() {
+ $(document.body).scrollspy({
+ target: ''
+ });
+ $(document.body).scrollspy('refresh');
+ if (enoughForAffixToc) {
+ toc.hide();
+ tocAffix.show();
+ } else {
+ tocAffix.hide();
+ toc.show();
+ }
+ $(document.body).scroll();
+ }
+
+ function windowResize() {
+ //toc right
+ var paddingRight = parseFloat(markdown.css('padding-right'));
+ var right = ($(window).width() - (markdown.offset().left + markdown.outerWidth() - paddingRight));
+ toc.css('right', right + 'px');
+ //affix toc left
+ var newbool;
+ var rightMargin = (markdown.parent().outerWidth() - markdown.outerWidth()) / 2;
+ //for ipad or wider device
+ if (rightMargin >= 133) {
+ newbool = true;
+ var affixLeftMargin = (tocAffix.outerWidth() - tocAffix.width()) / 2;
+ var left = markdown.offset().left + markdown.outerWidth() - affixLeftMargin;
+ tocAffix.css('left', left + 'px');
+ } else {
+ newbool = false;
+ }
+ if (newbool != enoughForAffixToc) {
+ enoughForAffixToc = newbool;
+ generateScrollspy();
+ }
+ }
+ $(window).resize(function () {
+ windowResize();
+ });
+ $(document).ready(function () {
+ windowResize();
+ generateScrollspy();
+ });
+
+ //remove hash
+ function removeHash() {
+ window.location.hash = '';
+ }
+
+ var backtotop = $('.back-to-top');
+ var gotobottom = $('.go-to-bottom');
+
+ backtotop.click(function (e) {
+ e.preventDefault();
+ e.stopPropagation();
+ if (scrollToTop)
+ scrollToTop();
+ removeHash();
+ });
+ gotobottom.click(function (e) {
+ e.preventDefault();
+ e.stopPropagation();
+ if (scrollToBottom)
+ scrollToBottom();
+ removeHash();
+ });
+
+ function scrollToTop() {
+ $('body, html').stop(true, true).animate({
+ scrollTop: 0
+ }, 100, "linear");
+ }
+
+ function scrollToBottom() {
+ $('body, html').stop(true, true).animate({
+ scrollTop: $(document.body)[0].scrollHeight
+ }, 100, "linear");
+ }
+ </script>
+</body>
+
+</html> \ No newline at end of file