Skip to content

Commit 38cf2f7

Browse files
authored
Merge pull request #471 from butlerx/reveal/theme
add the ability to set slide theme in slide options
2 parents 6e11960 + 0c82770 commit 38cf2f7

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

lib/response.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ var moment = require('moment')
1313
var config = require('./config')
1414
var logger = require('./logger')
1515
var models = require('./models')
16+
var utils = require('./utils')
1617

1718
// public
1819
var response = {
@@ -574,6 +575,7 @@ function showPublishSlide (req, res, next) {
574575
updatetime: updatetime,
575576
url: origin,
576577
body: markdown,
578+
theme: utils.isRevealTheme(meta.slideOptions.theme),
577579
meta: JSON.stringify(extracted.meta),
578580
useCDN: config.usecdn,
579581
owner: note.owner ? note.owner.id : null,

lib/utils.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
'use strict'
2+
const fs = require('fs')
3+
const path = require('path')
24

35
exports.isSQLite = function isSQLite (sequelize) {
46
return sequelize.options.dialect === 'sqlite'
@@ -23,3 +25,10 @@ exports.getImageMimeType = function getImageMimeType (imagePath) {
2325
return undefined
2426
}
2527
}
28+
29+
exports.isRevealTheme = function isRevealTheme (theme) {
30+
if (fs.existsSync(path.join(__dirname, '..', 'public', 'build', 'reveal.js', 'css', 'theme', theme + '.css'))) {
31+
return theme
32+
}
33+
return undefined
34+
}

public/views/slide.ejs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,11 @@
3030
<% } %>
3131

3232
<!-- For reveal.js theme -->
33+
<% if(typeof theme !== 'undefined' && theme) { %>
34+
<link rel="stylesheet" href="<%- url %>/build/reveal.js/css/theme/<%= theme %>.css" id="theme">
35+
<% } else { %>
3336
<link rel="stylesheet" href="<%- url %>/build/reveal.js/css/theme/black.css" id="theme">
37+
<% } %>
3438
<!-- For syntax highlighting -->
3539
<link rel="stylesheet" href="<%- url %>/build/reveal.js/lib/css/zenburn.css">
3640
<!-- For overwrite reveal.js -->

0 commit comments

Comments
 (0)