From 031c96c72d168a23cca0c609f46e019eced8bc64 Mon Sep 17 00:00:00 2001
From: Wu Cheng-Han <jacky_cute0808@hotmail.com>
Date: Fri, 18 Dec 2015 09:40:52 -0600
Subject: [PATCH] Updated slide mode

---
 app.js                                        |  4 +---
 lib/response.js                               | 14 +++++++----
 public/js/index.js                            | 11 +++++++--
 public/views/header.ejs                       | 23 +++++++++++--------
 .../listing.html => slide/listing.hbs}        |  0
 .../reveal.html => slide/reveal.hbs}          | 12 +++++++---
 6 files changed, 42 insertions(+), 22 deletions(-)
 rename public/views/{templates/listing.html => slide/listing.hbs} (100%)
 rename public/views/{templates/reveal.html => slide/reveal.hbs} (86%)

diff --git a/app.js b/app.js
index 8ebcaac..64b5b5f 100644
--- a/app.js
+++ b/app.js
@@ -358,10 +358,8 @@ app.get("/features", response.showFeatures);
 app.get("/s/:shortid", response.showPublishNote);
 //publish note actions
 app.get("/s/:shortid/:action", response.publishNoteActions);
-
-//add p
+//get publish slide
 app.get("/p/:shortid", response.showPublishSlide);
-
 //get note by id
 app.get("/:noteId", response.showNote);
 //note actions
diff --git a/lib/response.js b/lib/response.js
index 640e83b..375fc3f 100644
--- a/lib/response.js
+++ b/lib/response.js
@@ -24,8 +24,8 @@ var Mustache = require('mustache');
 var opts = {
     userBasePath: process.cwd(),
     revealBasePath: path.resolve(require.resolve('reveal.js'), '..', '..'),
-    template: fs.readFileSync(path.join('.', '/public/views/templates', 'reveal.html')).toString(),
-    templateListing: fs.readFileSync(path.join('.', '/public/views/templates', 'listing.html')).toString(),
+    template: fs.readFileSync(path.join('.', '/public/views/slide', 'reveal.hbs')).toString(),
+    templateListing: fs.readFileSync(path.join('.', '/public/views/slide', 'listing.hbs')).toString(),
     theme: 'css/theme/black.css',
     highlightTheme: 'zenburn',
     separator: '^(\r\n?|\n)---(\r\n?|\n)$',
@@ -404,7 +404,6 @@ function publishNoteActions(req, res, next) {
     }
 }
 
-
 function showPublishSlide(req, res, next) {
     var shortid = req.params.shortid;
     if (shortId.isValid(shortid)) {
@@ -425,8 +424,12 @@ function showPublishSlide(req, res, next) {
                         return;
                     }
                     var body = LZString.decompressFromBase64(data.rows[0].content);
+                    var title = data.rows[0].title;
+                    var decodedTitle = LZString.decompressFromBase64(title);
+                    if (decodedTitle) title = decodedTitle;
+                    title = Note.generateWebTitle(title);
                     var text = S(body).escapeHTML().s;
-                    render(res, text);
+                    render(res, title, text);
                 });
             });
         });
@@ -436,10 +439,11 @@ function showPublishSlide(req, res, next) {
 }
 
 //reveal.js render
-var render = function (res, markdown) {
+var render = function (res, title, markdown) {
     var slides = md.slidify(markdown, opts);
 
     res.end(Mustache.to_html(opts.template, {
+        title: title,
         theme: opts.theme,
         highlightTheme: opts.highlightTheme,
         slides: slides,
diff --git a/public/js/index.js b/public/js/index.js
index 4706d21..8841074 100644
--- a/public/js/index.js
+++ b/public/js/index.js
@@ -283,7 +283,6 @@ var ui = {
         shortStatus: $(".ui-short-status"),
         status: $(".ui-status"),
         new: $(".ui-new"),
-        slide: $(".ui-slide"),
         publish: $(".ui-publish"),
         download: {
             markdown: $(".ui-download-markdown"),
@@ -296,6 +295,10 @@ var ui = {
             dropbox: $(".ui-import-dropbox"),
             clipboard: $(".ui-import-clipboard")
         },
+        beta: {
+            pdf: $(".ui-beta-pdf"),
+            slide: $(".ui-beta-slide")
+        },
         mode: $(".ui-mode"),
         edit: $(".ui-edit"),
         view: $(".ui-view"),
@@ -793,7 +796,6 @@ function closestIndex(arr, closestTo) {
 var url = window.location.protocol + '//' + window.location.host + window.location.pathname;
 //share
 ui.toolbar.publish.attr("href", url + "/publish");
-ui.toolbar.slide.attr("href", url + "/slide");
 //download
 //markdown
 ui.toolbar.download.markdown.click(function () {
@@ -853,6 +855,11 @@ ui.toolbar.uploadImage.bind('change', function (e) {
 ui.toc.dropdown.click(function (e) {
     e.stopPropagation();
 });
+//beta
+//pdf
+ui.toolbar.beta.pdf.attr("download", "").attr("href", url + "/pdf");
+//slide
+ui.toolbar.beta.slide.attr("href", url + "/slide");
 
 function scrollToTop() {
     if (currentMode == modeType.both) {
diff --git a/public/views/header.ejs b/public/views/header.ejs
index 47246a1..c98202c 100644
--- a/public/views/header.ejs
+++ b/public/views/header.ejs
@@ -21,14 +21,18 @@
             <a data-target="#" data-toggle="dropdown" class="btn btn-link">
                 <i class="fa fa-caret-down"></i>
             </a>
-            <ul class="dropdown-menu" role="menu" aria-labelledby="menu">
+            <ul class="dropdown-menu list" role="menu" aria-labelledby="menu">
                 <li role="presentation"><a role="menuitem" class="ui-new" tabindex="-1" href="./new" target="_blank"><i class="fa fa-plus fa-fw"></i> New</a>
                 </li>
-                <li role="presentation"><a role="menuitem" class="ui-slide" tabindex="-1" href="#" target="_blank"><i class="fa fa-television fa-fw"></i> Slides</a>
-                </li>
                 <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">Beta</li>
+                <li role="presentation"><a role="menuitem" class="ui-beta-pdf" tabindex="-1" href="#" target="_self"><i class="fa fa-file-pdf-o fa-fw"></i> Export PDF</a>
+                </li>
+                <li role="presentation"><a role="menuitem" class="ui-beta-slide" tabindex="-1" href="#" target="_blank"><i class="fa fa-tv fa-fw"></i> Slide Mode</a>
+                </li>
+                <li class="divider"></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>
@@ -88,11 +92,6 @@
                     <i class="fa fa-plus"></i> New
                 </a>
             </li>
-            <li>
-                <a href="#" target="_blank" class="ui-slide">
-                    <i class="fa fa-television"></i> Slide
-                </a>
-            </li>
             <li>
                 <a href="#" target="_blank" class="ui-publish">
                     <i class="fa fa-print"></i> Publish
@@ -103,6 +102,12 @@
                     Menu <i class="fa fa-caret-down"></i>
                 </a>
                 <ul class="dropdown-menu" role="menu" aria-labelledby="menu">
+                    <li class="dropdown-header">Beta</li>
+                    <li role="presentation"><a role="menuitem" class="ui-beta-pdf" tabindex="-1" href="#" target="_self"><i class="fa fa-file-pdf-o fa-fw"></i> Export PDF</a>
+                    </li>
+                    <li role="presentation"><a role="menuitem" class="ui-beta-slide" tabindex="-1" href="#" target="_blank"><i class="fa fa-tv fa-fw"></i> Slide Mode</a>
+                    </li>
+                    <li class="divider"></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>
@@ -123,4 +128,4 @@
         </ul>
     </div>
 </nav>
-<div class="ui-spinner unselectable hidden-print"></div>
+<div class="ui-spinner unselectable hidden-print"></div>
\ No newline at end of file
diff --git a/public/views/templates/listing.html b/public/views/slide/listing.hbs
similarity index 100%
rename from public/views/templates/listing.html
rename to public/views/slide/listing.hbs
diff --git a/public/views/templates/reveal.html b/public/views/slide/reveal.hbs
similarity index 86%
rename from public/views/templates/reveal.html
rename to public/views/slide/reveal.hbs
index 04b8c9f..876a7ba 100644
--- a/public/views/templates/reveal.html
+++ b/public/views/slide/reveal.hbs
@@ -2,7 +2,13 @@
 <html lang="en">
     <head>
         <meta charset="utf-8">
-        <title>Reveal.js</title>
+        <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="/vendor/reveal.js/css/reveal.css">
         <link rel="stylesheet" href="/vendor/reveal.js/{{{theme}}}" id="theme">
         <!-- For syntax highlighting -->
@@ -19,7 +25,7 @@
         <div class="reveal">
             <div class="slides">{{{slides}}}</div>
         </div>
-
+        
         <script src="/vendor/reveal.js/lib/js/head.min.js"></script>
         <script src="/vendor/reveal.js/js/reveal.js"></script>
         <script src="/vendor/string.min.js"></script>
@@ -57,7 +63,7 @@
               progress: true,
               history: true,
               center: true,
-              transition: 'default',
+              transition: 'slide',
               dependencies: deps
             };