summaryrefslogtreecommitdiff
path: root/public/views/html.hbs
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/views/html.hbs
parent60414febee5fd14743fd80cad9d681c3027272dd (diff)
Added support of export to HTML, and changed the navbar menu for consistency
Diffstat (limited to 'public/views/html.hbs')
-rw-r--r--public/views/html.hbs166
1 files changed, 166 insertions, 0 deletions
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