From 62b29ecb652b356f2b28b4b3ccf1c24058c24157 Mon Sep 17 00:00:00 2001 From: David Date: Mon, 10 Apr 2017 10:46:44 -0400 Subject: [PATCH] Make theme able to load custom javascript (#1211) * Make theme able to load custom javascript - Look for the field 'customScript' in editorTheme (settings.js) - Add it to mustach context - Load list on template side (index.mst) * Add unit tests for customScripts * Code review edits : generic behavior for theme.page.[css|scripts] - Use the same way to share css and javascript files from a theme - Allow string instead of array for theme.page.scripts - Remove old customScript field --- editor/templates/index.mst | 3 +++ red/api/theme.js | 39 +++++++++++++++++++++++++------------- test/red/api/theme_spec.js | 9 ++++++++- 3 files changed, 37 insertions(+), 14 deletions(-) diff --git a/editor/templates/index.mst b/editor/templates/index.mst index e150a7a22..4194eda27 100644 --- a/editor/templates/index.mst +++ b/editor/templates/index.mst @@ -199,6 +199,9 @@ +{{# page.scripts }} + +{{/ page.scripts }} diff --git a/red/api/theme.js b/red/api/theme.js index 742d7349d..6d5dba3d7 100644 --- a/red/api/theme.js +++ b/red/api/theme.js @@ -57,6 +57,24 @@ function serveFile(app,baseUrl,file) { } } +function serveFilesFromTheme(themeValue, themeApp, directory) { + var result = []; + if (themeValue) { + var array = themeValue; + if (!util.isArray(array)) { + array = [array]; + } + + for (i=0;i