check if reveal theme exists

This commit is contained in:
butlerx 2017-06-01 09:47:52 +01:00
parent e5834c077f
commit c531d96f66
No known key found for this signature in database
GPG key ID: B37CA765BAA89170
2 changed files with 11 additions and 1 deletions

View file

@ -13,6 +13,7 @@ var moment = require('moment')
var config = require('./config')
var logger = require('./logger')
var models = require('./models')
var utils = require('./utils')
// public
var response = {
@ -574,7 +575,7 @@ function showPublishSlide (req, res, next) {
updatetime: updatetime,
url: origin,
body: markdown,
theme: meta.slideOptions.theme,
theme: utils.isRevealTheme(meta.slideOptions.theme),
meta: JSON.stringify(extracted.meta),
useCDN: config.usecdn,
owner: note.owner ? note.owner.id : null,

View file

@ -1,4 +1,6 @@
'use strict'
const fs = require('fs')
const path = require('path')
exports.isSQLite = function isSQLite (sequelize) {
return sequelize.options.dialect === 'sqlite'
@ -23,3 +25,10 @@ exports.getImageMimeType = function getImageMimeType (imagePath) {
return undefined
}
}
exports.isRevealTheme = function isRevealTheme (theme) {
if (fs.existsSync(path.join(process.cwd(), 'public', 'build', 'reveal.js', 'css', 'theme', theme + '.css'))) {
return theme
}
return undefined
}