diff --git a/src/backend/configurations/config.yaml b/src/backend/configurations/config.yaml index f3f17e6..9947f45 100644 --- a/src/backend/configurations/config.yaml +++ b/src/backend/configurations/config.yaml @@ -10,17 +10,17 @@ production: listenOnHttps: false enableHTTPBasicAuth: true default_render: - view: {{{DEFAULT_VIEW}}}{{^DEFAULT_VIEW}}/index/view.html{{{/DEFAULT_VIEW}} - model: {{{DEFAULT_MODEL}}}{{^DEFAULT_MODEL}}/index/model.json{{{/DEFAULT_MODEL}} - controller: {{{DEFAULT_CONTROLLER}}}{{^DEFAULT_CONTROLLER}}/index/controller.js{{{/DEFAULT_CONTROLLER}} + view: $_[DEFAULT_VIEW]$_[^DEFAULT_VIEW]/index/view.html$_[/DEFAULT_VIEW] + model: $_[DEFAULT_MODEL]$_[^DEFAULT_MODEL]/index/model.json$_[/DEFAULT_MODEL] + controller: $_[DEFAULT_CONTROLLER]$_[^DEFAULT_CONTROLLER]/index/controller.js$_[/DEFAULT_CONTROLLER] log: level: info file: './logs/pro-logs.log' #Where log file will be saved. Date will be concatenated before the name. maxSize: 10000000 #(10MB) Maximum file log size, if one file reaches it, a new file is created. maxFiles: 30 # Max Files that can be created per day reaching the maxSize. auth: - user: {{{LOGIN_USER}}}{{^LOGIN_USER}}governify-admin{{{/LOGIN_USER}} - password: {{{LOGIN_PASSWORD}}}{{^LOGIN_PASSWORD}}governify-project{{{/LOGIN_PASSWORD}} + user: $_[LOGIN_USER]$_[^LOGIN_USER]governify-admin$_[/LOGIN_USER] + password: $_[LOGIN_PASSWORD]$_[^LOGIN_PASSWORD]governify-project$_[/LOGIN_PASSWORD] development: server: @@ -34,12 +34,12 @@ development: listenOnHttps: false enableHTTPBasicAuth: true default_render: - view: {{{DEFAULT_VIEW}}}{{^DEFAULT_VIEW}}/index/view.html{{{/DEFAULT_VIEW}} - model: {{{DEFAULT_MODEL}}}{{^DEFAULT_MODEL}}/index/model.json{{{/DEFAULT_MODEL}} - controller: {{{DEFAULT_CONTROLLER}}}{{^DEFAULT_CONTROLLER}}/index/controller.js{{{/DEFAULT_CONTROLLER}} + view: $_[DEFAULT_VIEW]$_[^DEFAULT_VIEW]/index/view.html$_[/DEFAULT_VIEW] + model: $_[DEFAULT_MODEL]$_[^DEFAULT_MODEL]/index/model.json$_[/DEFAULT_MODEL] + controller: $_[DEFAULT_CONTROLLER]$_[^DEFAULT_CONTROLLER]/index/controller.js$_[/DEFAULT_CONTROLLER] auth: - user: {{{LOGIN_USER}}}{{^LOGIN_USER}}governify-admin{{{/LOGIN_USER}} - password: {{{LOGIN_PASSWORD}}}{{^LOGIN_PASSWORD}}governify-project{{{/LOGIN_PASSWORD}} + user: $_[LOGIN_USER]$_[^LOGIN_USER]governify-admin$_[/LOGIN_USER] + password: $_[LOGIN_PASSWORD]$_[^LOGIN_PASSWORD]governify-project$_[/LOGIN_PASSWORD] log: level: debug @@ -59,13 +59,13 @@ testing: listenOnHttps: false enableHTTPBasicAuth: false default_render: - view: {{{DEFAULT_VIEW}}}{{^DEFAULT_VIEW}}/index/view.html{{{/DEFAULT_VIEW}} - model: {{{DEFAULT_MODEL}}}{{^DEFAULT_MODEL}}/index/model.json{{{/DEFAULT_MODEL}} - controller: {{{DEFAULT_CONTROLLER}}}{{^DEFAULT_CONTROLLER}}/index/controller.js{{{/DEFAULT_CONTROLLER}} + view: $_[DEFAULT_VIEW]$_[^DEFAULT_VIEW]/index/view.html$_[/DEFAULT_VIEW] + model: $_[DEFAULT_MODEL]$_[^DEFAULT_MODEL]/index/model.json$_[/DEFAULT_MODEL] + controller: $_[DEFAULT_CONTROLLER]$_[^DEFAULT_CONTROLLER]/index/controller.js$_[/DEFAULT_CONTROLLER] auth: - user: {{{LOGIN_USER}}}{{^LOGIN_USER}}governify-admin{{{/LOGIN_USER}} - password: {{{LOGIN_PASSWORD}}}{{^LOGIN_PASSWORD}}governify-project{{{/LOGIN_PASSWORD}} + user: $_[LOGIN_USER]$_[^LOGIN_USER]governify-admin$_[/LOGIN_USER] + password: $_[LOGIN_PASSWORD]$_[^LOGIN_PASSWORD]governify-project$_[/LOGIN_PASSWORD] log: file: './logs/test-logs.log' #Where log file will be saved. Date will be concatenated before the name. maxSize: 10000000 #(10MB) Maximum file log size, if one file reaches it, a new file is created. diff --git a/src/backend/configurations/index.js b/src/backend/configurations/index.js index 527840f..ae6d788 100644 --- a/src/backend/configurations/index.js +++ b/src/backend/configurations/index.js @@ -27,6 +27,7 @@ const jsyaml = require('js-yaml'); const fs = require('fs'); const path = require('path'); const mustache = require("mustache"); +mustache.escape = function (text) { return text; }; /* * Export functions and Objects @@ -50,7 +51,8 @@ function _addConfiguration(uri, encoding) { configStringTemplate = fs.readFileSync(path.join(__dirname, uri), encoding); } - configString = mustache.render(configStringTemplate, process.env); + + configString = mustache.render(configStringTemplate, process.env, {}, ['$_[', ']']); var newConfigurations = jsyaml.safeLoad(configString)[process.env.NODE_ENV ? process.env.NODE_ENV : 'development']; diff --git a/src/backend/model.mustache b/src/backend/layout.html similarity index 82% rename from src/backend/model.mustache rename to src/backend/layout.html index adfa261..2d38d06 100644 --- a/src/backend/model.mustache +++ b/src/backend/layout.html @@ -6,13 +6,22 @@ - + + + --> - + + + + + + @@ -94,10 +103,10 @@ .module('renderApp') .controller('renderController', function ($scope, $http, $location, $state, $stateParams, $templateRequest, $sce, $compile, $q) { console.log('Render Controller Initialized'); - $compile($('#my-element').html(`{{{ FILE_VIEW }}}`).contents())($scope); - $scope.model = {{{ FILE_MODEL }}}; - {{{ FILE_CONTROLLER }}} - + $compile($('#my-element').html(`$_[FILE_VIEW]`).contents())($scope); + $scope.model = $_[FILE_MODEL]; + $_[FILE_CONTROLLER] + }); diff --git a/src/backend/routes.js b/src/backend/routes.js index c6ca7c8..8cfd7e7 100644 --- a/src/backend/routes.js +++ b/src/backend/routes.js @@ -26,6 +26,7 @@ const fs = require('fs'); const axios = require('axios') const jsyaml = require('js-yaml') const mustache = require("mustache"); +mustache.escape = function (text) { return text; }; const config = require('./configurations') const logger = require("./logger"); @@ -96,8 +97,8 @@ router.get("/render", async function (req, res) { FILE_VIEW: fileView } logger.info("Displaying render"); - var htmlTemplate = fs.readFileSync('./src/backend/model.mustache', 'utf8'); - var htmlRendered = mustache.render(htmlTemplate, files) + var htmlTemplate = fs.readFileSync('./src/backend/layout.html', 'utf8'); + var htmlRendered = mustache.render(htmlTemplate, files, {}, ['$_[', ']']); res.send(htmlRendered); } catch (err) { logger.warning('Error getting files: ' + err)