Skip to content

Commit d6dec55

Browse files
committed
Merge pull request #43 from x000032001/master
Add Slide Mode
2 parents 75ae505 + f51b737 commit d6dec55

81 files changed

Lines changed: 14277 additions & 7 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

app.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,10 @@ app.get("/features", response.showFeatures);
357357
app.get("/s/:shortid", response.showPublishNote);
358358
//publish note actions
359359
app.get("/s/:shortid/:action", response.publishNoteActions);
360+
361+
//add p
362+
app.get("/p/:shortid", response.showPublishSlide);
363+
360364
//get note by id
361365
app.get("/:noteId", response.showNote);
362366
//note actions
@@ -391,4 +395,4 @@ if (config.usessl) {
391395
}
392396
process.on('uncaughtException', function (err) {
393397
logger.error(err);
394-
});
398+
});

lib/response.js

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,23 @@ var config = require("../config.js");
1616
var db = require("./db.js");
1717
var Note = require("./note.js");
1818

19+
//slides
20+
var md = require('reveal.js/plugin/markdown/markdown');
21+
var Mustache = require('mustache');
22+
23+
var opts = {
24+
userBasePath: process.cwd(),
25+
revealBasePath: path.resolve(require.resolve('reveal.js'), '..', '..'),
26+
template: fs.readFileSync(path.join('.', 'templates', 'reveal.html')).toString(),
27+
templateListing: fs.readFileSync(path.join('.', 'templates', 'listing.html')).toString(),
28+
theme: 'css/theme/league.css',
29+
highlightTheme: 'zenburn',
30+
separator: '^(\r\n?|\n)---(\r\n?|\n)$',
31+
verticalSeparator: '^(\r\n?|\n)----(\r\n?|\n)$',
32+
revealOptions: {}
33+
};
34+
35+
1936
//public
2037
var response = {
2138
errorForbidden: function (res) {
@@ -34,6 +51,7 @@ var response = {
3451
showFeatures: showFeatures,
3552
showNote: showNote,
3653
showPublishNote: showPublishNote,
54+
showPublishSlide: showPublishSlide,
3755
showIndex: showIndex,
3856
noteActions: noteActions,
3957
publishNoteActions: publishNoteActions
@@ -231,6 +249,26 @@ function actionPublish(req, res, noteId) {
231249
});
232250
}
233251

252+
function actionSlide(req, res, noteId) {
253+
db.readFromDB(noteId, function (err, data) {
254+
if (err) {
255+
responseError(res, "404", "Not Found", "oops.");
256+
return;
257+
}
258+
var owner = data.rows[0].owner;
259+
var permission = "freely";
260+
if (owner && owner != "null") {
261+
permission = "editable";
262+
}
263+
Note.findOrNewNote(noteId, permission, function (err, note) {
264+
if (err) {
265+
responseError(res, "404", "Not Found", "oops.");
266+
return;
267+
}
268+
res.redirect("/p/" + note.shortid);
269+
});
270+
});
271+
}
234272
//pretty api is deprecated
235273
function actionPretty(req, res, noteId) {
236274
db.readFromDB(noteId, function (err, data) {
@@ -327,6 +365,9 @@ function noteActions(req, res, next) {
327365
case "pretty": //pretty deprecated
328366
actionPublish(req, res, noteId);
329367
break;
368+
case "slide":
369+
actionSlide(req, res, noteId);
370+
break;
330371
case "download":
331372
actionDownload(req, res, noteId);
332373
break;
@@ -363,4 +404,46 @@ function publishNoteActions(req, res, next) {
363404
}
364405
}
365406

407+
408+
function showPublishSlide(req, res, next) {
409+
var shortid = req.params.shortid;
410+
if (shortId.isValid(shortid)) {
411+
Note.findNote(shortid, function (err, note) {
412+
if (err || !note) {
413+
responseError(res, "404", "Not Found", "oops.");
414+
return;
415+
}
416+
//increase note viewcount
417+
Note.increaseViewCount(note, function (err, note) {
418+
if (err || !note) {
419+
responseError(res, "404", "Not Found", "oops.");
420+
return;
421+
}
422+
db.readFromDB(note.id, function (err, data) {
423+
if (err) {
424+
responseError(res, "404", "Not Found", "oops.");
425+
return;
426+
}
427+
var body = LZString.decompressFromBase64(data.rows[0].content);
428+
var text = S(body).escapeHTML().s;
429+
render(res, text);
430+
});
431+
});
432+
});
433+
} else {
434+
responseError(res, "404", "Not Found", "oops.");
435+
}
436+
}
437+
var render = function(res, markdown) {
438+
var slides = md.slidify(markdown, opts);
439+
440+
res.end(Mustache.to_html(opts.template, {
441+
theme: opts.theme,
442+
highlightTheme: opts.highlighTheme,
443+
slides: slides,
444+
options: JSON.stringify(opts.revealOptions, null, 2)
445+
}));
446+
};
447+
448+
366449
module.exports = response;

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@
4444
"socket.io": "1.3.5",
4545
"string": "^3.2.0",
4646
"toobusy-js": "^0.4.1",
47-
"winston": "^1.0.0"
47+
"winston": "^1.0.0",
48+
"mustache": "2.1.3",
49+
"reveal.js": "3.1.0"
4850
},
4951
"engines": {
5052
"node": "0.10.x"

public/css/print/paper.css

Lines changed: 202 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,202 @@
1+
/* Default Print Stylesheet Template
2+
by Rob Glazebrook of CSSnewbie.com
3+
Last Updated: June 4, 2008
4+
5+
Feel free (nay, compelled) to edit, append, and
6+
manipulate this file as you see fit. */
7+
8+
9+
@media print {
10+
11+
/* SECTION 1: Set default width, margin, float, and
12+
background. This prevents elements from extending
13+
beyond the edge of the printed page, and prevents
14+
unnecessary background images from printing */
15+
html {
16+
background: #fff;
17+
width: auto;
18+
height: auto;
19+
overflow: visible;
20+
}
21+
body {
22+
background: #fff;
23+
font-size: 20pt;
24+
width: auto;
25+
height: auto;
26+
border: 0;
27+
margin: 0 5%;
28+
padding: 0;
29+
overflow: visible;
30+
float: none !important;
31+
}
32+
33+
/* SECTION 2: Remove any elements not needed in print.
34+
This would include navigation, ads, sidebars, etc. */
35+
.nestedarrow,
36+
.controls,
37+
.fork-reveal,
38+
.share-reveal,
39+
.state-background,
40+
.reveal .progress,
41+
.reveal .backgrounds {
42+
display: none !important;
43+
}
44+
45+
/* SECTION 3: Set body font face, size, and color.
46+
Consider using a serif font for readability. */
47+
body, p, td, li, div {
48+
font-size: 20pt!important;
49+
font-family: Georgia, "Times New Roman", Times, serif !important;
50+
color: #000;
51+
}
52+
53+
/* SECTION 4: Set heading font face, sizes, and color.
54+
Differentiate your headings from your body text.
55+
Perhaps use a large sans-serif for distinction. */
56+
h1,h2,h3,h4,h5,h6 {
57+
color: #000!important;
58+
height: auto;
59+
line-height: normal;
60+
font-family: Georgia, "Times New Roman", Times, serif !important;
61+
text-shadow: 0 0 0 #000 !important;
62+
text-align: left;
63+
letter-spacing: normal;
64+
}
65+
/* Need to reduce the size of the fonts for printing */
66+
h1 { font-size: 28pt !important; }
67+
h2 { font-size: 24pt !important; }
68+
h3 { font-size: 22pt !important; }
69+
h4 { font-size: 22pt !important; font-variant: small-caps; }
70+
h5 { font-size: 21pt !important; }
71+
h6 { font-size: 20pt !important; font-style: italic; }
72+
73+
/* SECTION 5: Make hyperlinks more usable.
74+
Ensure links are underlined, and consider appending
75+
the URL to the end of the link for usability. */
76+
a:link,
77+
a:visited {
78+
color: #000 !important;
79+
font-weight: bold;
80+
text-decoration: underline;
81+
}
82+
/*
83+
.reveal a:link:after,
84+
.reveal a:visited:after {
85+
content: " (" attr(href) ") ";
86+
color: #222 !important;
87+
font-size: 90%;
88+
}
89+
*/
90+
91+
92+
/* SECTION 6: more reveal.js specific additions by @skypanther */
93+
ul, ol, div, p {
94+
visibility: visible;
95+
position: static;
96+
width: auto;
97+
height: auto;
98+
display: block;
99+
overflow: visible;
100+
margin: 0;
101+
text-align: left !important;
102+
}
103+
.reveal pre,
104+
.reveal table {
105+
margin-left: 0;
106+
margin-right: 0;
107+
}
108+
.reveal pre code {
109+
padding: 20px;
110+
border: 1px solid #ddd;
111+
}
112+
.reveal blockquote {
113+
margin: 20px 0;
114+
}
115+
.reveal .slides {
116+
position: static !important;
117+
width: auto !important;
118+
height: auto !important;
119+
120+
left: 0 !important;
121+
top: 0 !important;
122+
margin-left: 0 !important;
123+
margin-top: 0 !important;
124+
padding: 0 !important;
125+
zoom: 1 !important;
126+
127+
overflow: visible !important;
128+
display: block !important;
129+
130+
text-align: left !important;
131+
-webkit-perspective: none;
132+
-moz-perspective: none;
133+
-ms-perspective: none;
134+
perspective: none;
135+
136+
-webkit-perspective-origin: 50% 50%;
137+
-moz-perspective-origin: 50% 50%;
138+
-ms-perspective-origin: 50% 50%;
139+
perspective-origin: 50% 50%;
140+
}
141+
.reveal .slides section {
142+
visibility: visible !important;
143+
position: static !important;
144+
width: 100% !important;
145+
height: auto !important;
146+
display: block !important;
147+
overflow: visible !important;
148+
149+
left: 0 !important;
150+
top: 0 !important;
151+
margin-left: 0 !important;
152+
margin-top: 0 !important;
153+
padding: 60px 20px !important;
154+
z-index: auto !important;
155+
156+
opacity: 1 !important;
157+
158+
page-break-after: always !important;
159+
160+
-webkit-transform-style: flat !important;
161+
-moz-transform-style: flat !important;
162+
-ms-transform-style: flat !important;
163+
transform-style: flat !important;
164+
165+
-webkit-transform: none !important;
166+
-moz-transform: none !important;
167+
-ms-transform: none !important;
168+
transform: none !important;
169+
170+
-webkit-transition: none !important;
171+
-moz-transition: none !important;
172+
-ms-transition: none !important;
173+
transition: none !important;
174+
}
175+
.reveal .slides section.stack {
176+
padding: 0 !important;
177+
}
178+
.reveal section:last-of-type {
179+
page-break-after: avoid !important;
180+
}
181+
.reveal section .fragment {
182+
opacity: 1 !important;
183+
visibility: visible !important;
184+
185+
-webkit-transform: none !important;
186+
-moz-transform: none !important;
187+
-ms-transform: none !important;
188+
transform: none !important;
189+
}
190+
.reveal section img {
191+
display: block;
192+
margin: 15px 0px;
193+
background: rgba(255,255,255,1);
194+
border: 1px solid #666;
195+
box-shadow: none;
196+
}
197+
198+
.reveal section small {
199+
font-size: 0.8em;
200+
}
201+
202+
}

0 commit comments

Comments
 (0)