From abf92821558e435e145c3e7feeea63db72f2ea00 Mon Sep 17 00:00:00 2001 From: Nadav Ivgi Date: Tue, 6 Mar 2018 07:02:16 +0200 Subject: [PATCH] Dynamically locate bootswatch directory, mount to /_theme The previous implementation using symlinks does not work on npm (which doesn't allow symlinks) --- src/app.js | 2 ++ static/bootswatch | 1 - views/layout.pug | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) delete mode 120000 static/bootswatch diff --git a/src/app.js b/src/app.js index afeb199..2f055ef 100644 --- a/src/app.js +++ b/src/app.js @@ -1,3 +1,4 @@ +import path from 'path' import { pwrap, pick, fcurrency, fmsat, pngPixel } from './lib/util' // Setup @@ -40,6 +41,7 @@ app.use(require('csurf')({ cookie: true })) // Static assets app.use('/_assets', require('stylus').middleware({ src: conf.static_dir, serve: true })) app.use('/_assets', require('express').static(conf.static_dir)) +app.use('/_themes', require('express').static(path.resolve(require.resolve('bootswatch/package'), '..', 'dist'))) // Create invoice app.post('/_invoice', pwrap(async (req, res) => { diff --git a/static/bootswatch b/static/bootswatch deleted file mode 120000 index e897b61..0000000 --- a/static/bootswatch +++ /dev/null @@ -1 +0,0 @@ -../node_modules/bootswatch/dist \ No newline at end of file diff --git a/views/layout.pug b/views/layout.pug index d2608ab..4c43046 100644 --- a/views/layout.pug +++ b/views/layout.pug @@ -10,7 +10,7 @@ block head title= title - link(rel='stylesheet', href='_assets/bootswatch/'+conf.theme+'/bootstrap.min.css') + link(rel='stylesheet', href='_themes/'+conf.theme+'/bootstrap.min.css') link(rel='stylesheet', href='_assets/style.css') noscript: style .yesscript{display:none}