Updated slide mode

This commit is contained in:
Wu Cheng-Han 2015-12-18 09:40:52 -06:00
parent 54b33f181f
commit 031c96c72d
6 changed files with 42 additions and 22 deletions

4
app.js
View file

@ -358,10 +358,8 @@ app.get("/features", response.showFeatures);
app.get("/s/:shortid", response.showPublishNote); app.get("/s/:shortid", response.showPublishNote);
//publish note actions //publish note actions
app.get("/s/:shortid/:action", response.publishNoteActions); app.get("/s/:shortid/:action", response.publishNoteActions);
//get publish slide
//add p
app.get("/p/:shortid", response.showPublishSlide); app.get("/p/:shortid", response.showPublishSlide);
//get note by id //get note by id
app.get("/:noteId", response.showNote); app.get("/:noteId", response.showNote);
//note actions //note actions

View file

@ -24,8 +24,8 @@ var Mustache = require('mustache');
var opts = { var opts = {
userBasePath: process.cwd(), userBasePath: process.cwd(),
revealBasePath: path.resolve(require.resolve('reveal.js'), '..', '..'), revealBasePath: path.resolve(require.resolve('reveal.js'), '..', '..'),
template: fs.readFileSync(path.join('.', '/public/views/templates', 'reveal.html')).toString(), template: fs.readFileSync(path.join('.', '/public/views/slide', 'reveal.hbs')).toString(),
templateListing: fs.readFileSync(path.join('.', '/public/views/templates', 'listing.html')).toString(), templateListing: fs.readFileSync(path.join('.', '/public/views/slide', 'listing.hbs')).toString(),
theme: 'css/theme/black.css', theme: 'css/theme/black.css',
highlightTheme: 'zenburn', highlightTheme: 'zenburn',
separator: '^(\r\n?|\n)---(\r\n?|\n)$', separator: '^(\r\n?|\n)---(\r\n?|\n)$',
@ -404,7 +404,6 @@ function publishNoteActions(req, res, next) {
} }
} }
function showPublishSlide(req, res, next) { function showPublishSlide(req, res, next) {
var shortid = req.params.shortid; var shortid = req.params.shortid;
if (shortId.isValid(shortid)) { if (shortId.isValid(shortid)) {
@ -425,8 +424,12 @@ function showPublishSlide(req, res, next) {
return; return;
} }
var body = LZString.decompressFromBase64(data.rows[0].content); 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; 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 //reveal.js render
var render = function (res, markdown) { var render = function (res, title, markdown) {
var slides = md.slidify(markdown, opts); var slides = md.slidify(markdown, opts);
res.end(Mustache.to_html(opts.template, { res.end(Mustache.to_html(opts.template, {
title: title,
theme: opts.theme, theme: opts.theme,
highlightTheme: opts.highlightTheme, highlightTheme: opts.highlightTheme,
slides: slides, slides: slides,

View file

@ -283,7 +283,6 @@ var ui = {
shortStatus: $(".ui-short-status"), shortStatus: $(".ui-short-status"),
status: $(".ui-status"), status: $(".ui-status"),
new: $(".ui-new"), new: $(".ui-new"),
slide: $(".ui-slide"),
publish: $(".ui-publish"), publish: $(".ui-publish"),
download: { download: {
markdown: $(".ui-download-markdown"), markdown: $(".ui-download-markdown"),
@ -296,6 +295,10 @@ var ui = {
dropbox: $(".ui-import-dropbox"), dropbox: $(".ui-import-dropbox"),
clipboard: $(".ui-import-clipboard") clipboard: $(".ui-import-clipboard")
}, },
beta: {
pdf: $(".ui-beta-pdf"),
slide: $(".ui-beta-slide")
},
mode: $(".ui-mode"), mode: $(".ui-mode"),
edit: $(".ui-edit"), edit: $(".ui-edit"),
view: $(".ui-view"), view: $(".ui-view"),
@ -793,7 +796,6 @@ function closestIndex(arr, closestTo) {
var url = window.location.protocol + '//' + window.location.host + window.location.pathname; var url = window.location.protocol + '//' + window.location.host + window.location.pathname;
//share //share
ui.toolbar.publish.attr("href", url + "/publish"); ui.toolbar.publish.attr("href", url + "/publish");
ui.toolbar.slide.attr("href", url + "/slide");
//download //download
//markdown //markdown
ui.toolbar.download.markdown.click(function () { ui.toolbar.download.markdown.click(function () {
@ -853,6 +855,11 @@ ui.toolbar.uploadImage.bind('change', function (e) {
ui.toc.dropdown.click(function (e) { ui.toc.dropdown.click(function (e) {
e.stopPropagation(); 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() { function scrollToTop() {
if (currentMode == modeType.both) { if (currentMode == modeType.both) {

View file

@ -21,14 +21,18 @@
<a data-target="#" data-toggle="dropdown" class="btn btn-link"> <a data-target="#" data-toggle="dropdown" class="btn btn-link">
<i class="fa fa-caret-down"></i> <i class="fa fa-caret-down"></i>
</a> </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 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>
<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 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>
<li class="divider"></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 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 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>
@ -88,11 +92,6 @@
<i class="fa fa-plus"></i> New <i class="fa fa-plus"></i> New
</a> </a>
</li> </li>
<li>
<a href="#" target="_blank" class="ui-slide">
<i class="fa fa-television"></i> Slide
</a>
</li>
<li> <li>
<a href="#" target="_blank" class="ui-publish"> <a href="#" target="_blank" class="ui-publish">
<i class="fa fa-print"></i> Publish <i class="fa fa-print"></i> Publish
@ -103,6 +102,12 @@
Menu <i class="fa fa-caret-down"></i> Menu <i class="fa fa-caret-down"></i>
</a> </a>
<ul class="dropdown-menu" role="menu" aria-labelledby="menu"> <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 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 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>
@ -123,4 +128,4 @@
</ul> </ul>
</div> </div>
</nav> </nav>
<div class="ui-spinner unselectable hidden-print"></div> <div class="ui-spinner unselectable hidden-print"></div>

View file

@ -2,7 +2,13 @@
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="utf-8"> <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/css/reveal.css">
<link rel="stylesheet" href="/vendor/reveal.js/{{{theme}}}" id="theme"> <link rel="stylesheet" href="/vendor/reveal.js/{{{theme}}}" id="theme">
<!-- For syntax highlighting --> <!-- For syntax highlighting -->
@ -19,7 +25,7 @@
<div class="reveal"> <div class="reveal">
<div class="slides">{{{slides}}}</div> <div class="slides">{{{slides}}}</div>
</div> </div>
<script src="/vendor/reveal.js/lib/js/head.min.js"></script> <script src="/vendor/reveal.js/lib/js/head.min.js"></script>
<script src="/vendor/reveal.js/js/reveal.js"></script> <script src="/vendor/reveal.js/js/reveal.js"></script>
<script src="/vendor/string.min.js"></script> <script src="/vendor/string.min.js"></script>
@ -57,7 +63,7 @@
progress: true, progress: true,
history: true, history: true,
center: true, center: true,
transition: 'default', transition: 'slide',
dependencies: deps dependencies: deps
}; };