From 070003a4142fe46f75a99970547e1e0eaac4ff7c Mon Sep 17 00:00:00 2001 From: juliandescottes Date: Mon, 30 Nov 2015 14:22:11 +0100 Subject: [PATCH] Issue #344 : Escape django template tags --- Gruntfile.js | 4 ++-- src/js/controller/PalettesListController.js | 2 +- src/js/controller/dialogs/BrowseLocalController.js | 2 +- src/js/controller/settings/ImportController.js | 2 +- .../settings/exportimage/GifExportController.js | 2 +- .../settings/exportimage/PngExportController.js | 2 +- src/js/devtools/DrawingTestSuiteController.js | 6 +++--- .../service/storage/FileDownloadStorageService.js | 2 +- src/js/utils/Template.js | 2 +- src/templates/dialogs/browse-local.html | 8 ++++---- src/templates/dialogs/cheatsheet.html | 8 ++++---- src/templates/dialogs/create-palette.html | 8 ++++---- src/templates/drawing-tools.html | 2 +- src/templates/layers-list.html | 2 +- src/templates/misc-templates.html | 14 +++++++------- src/templates/palettes-list.html | 4 ++-- src/templates/settings/import.html | 2 +- 17 files changed, 36 insertions(+), 36 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index e17c9c3..a1ba082 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -205,11 +205,11 @@ module.exports = function(grunt) { options: { patterns: [{ match: /^(.|[\r\n])*/, - replacement: "", + replacement: "{% raw %}", description : "Remove everything before body-main-start comment" },{ match: /(.|[\r\n])*$/, - replacement: "", + replacement: "{% endraw %}", description : "Remove everything after body-main-end comment" },{ match: /([\r\n]) /g, diff --git a/src/js/controller/PalettesListController.js b/src/js/controller/PalettesListController.js index af70f65..846e400 100644 --- a/src/js/controller/PalettesListController.js +++ b/src/js/controller/PalettesListController.js @@ -51,7 +51,7 @@ var palettes = this.paletteService.getPalettes(); var html = palettes.map(function (palette) { - return pskl.utils.Template.replace('', palette); + return pskl.utils.Template.replace('', palette); }).join(''); this.colorPaletteSelect_.innerHTML = html; }; diff --git a/src/js/controller/dialogs/BrowseLocalController.js b/src/js/controller/dialogs/BrowseLocalController.js index adbe1d5..be559f6 100644 --- a/src/js/controller/dialogs/BrowseLocalController.js +++ b/src/js/controller/dialogs/BrowseLocalController.js @@ -47,7 +47,7 @@ }); keys.forEach((function (key) { - var date = pskl.utils.DateUtils.format(key.date, '${Y}/${M}/${D} ${H}:${m}'); + var date = pskl.utils.DateUtils.format(key.date, '{{Y}}/{{M}}/{{D}} {{H}}:{{m}}'); html += pskl.utils.Template.replace(this.localStorageItemTemplate_, {name : key.name, date : date}); }).bind(this)); diff --git a/src/js/controller/settings/ImportController.js b/src/js/controller/settings/ImportController.js index 1f06ee6..d144efc 100644 --- a/src/js/controller/settings/ImportController.js +++ b/src/js/controller/settings/ImportController.js @@ -32,7 +32,7 @@ var previousInfo = pskl.app.backupService.getPreviousPiskelInfo(); if (previousInfo) { var previousSessionTemplate_ = pskl.utils.Template.get('previous-session-info-template'); - var date = pskl.utils.DateUtils.format(previousInfo.date, '${H}:${m} - ${Y}/${M}/${D}'); + var date = pskl.utils.DateUtils.format(previousInfo.date, '{{H}}:{{m}} - {{Y}}/{{M}}/{{D}}'); previousSessionContainer.innerHTML = pskl.utils.Template.replace(previousSessionTemplate_, { name : previousInfo.name, date : date diff --git a/src/js/controller/settings/exportimage/GifExportController.js b/src/js/controller/settings/exportimage/GifExportController.js index 0d697ea..5c46e69 100644 --- a/src/js/controller/settings/exportimage/GifExportController.js +++ b/src/js/controller/settings/exportimage/GifExportController.js @@ -153,7 +153,7 @@ // FIXME : JD : HORRIBLE COPY/PASTA (JD later : where???) ns.GifExportController.prototype.updateStatus_ = function (imageUrl, error) { if (imageUrl) { - var linkTpl = '${shortLink}'; + var linkTpl = '{{shortLink}}'; var linkHtml = pskl.utils.Template.replace(linkTpl, { link : imageUrl, shortLink : this.shorten_(imageUrl, URL_MAX_LENGTH, '...') diff --git a/src/js/controller/settings/exportimage/PngExportController.js b/src/js/controller/settings/exportimage/PngExportController.js index 19ace4f..12ee126 100644 --- a/src/js/controller/settings/exportimage/PngExportController.js +++ b/src/js/controller/settings/exportimage/PngExportController.js @@ -98,7 +98,7 @@ ns.PngExportController.prototype.updateStatus_ = function (imageUrl, error) { if (imageUrl) { - var linkTpl = '${shortLink}'; + var linkTpl = '{{shortLink}}'; var linkHtml = pskl.utils.Template.replace(linkTpl, { link : imageUrl, shortLink : this.shorten_(imageUrl, URL_MAX_LENGTH, '...') diff --git a/src/js/devtools/DrawingTestSuiteController.js b/src/js/devtools/DrawingTestSuiteController.js index 96ad560..483929b 100644 --- a/src/js/devtools/DrawingTestSuiteController.js +++ b/src/js/devtools/DrawingTestSuiteController.js @@ -21,7 +21,7 @@ var testSuiteStatus = document.createElement('li'); testSuiteStatus.innerHTML = pskl.utils.Template.replace( - 'Test Suite [${path}]', + 'Test Suite [{{path}}]', {path : this.shortenPath_(this.suitePath)} ); this.testListElt.appendChild(testSuiteStatus); @@ -51,7 +51,7 @@ var testCaseStatus = document.createElement('li'); testCaseStatus.innerHTML = pskl.utils.Template.replace( - '[${path}] finished : ${status}', + '[{{path}}] finished : {{status}}', {path : this.shortenPath_(testPath), status : status ? 'OK' : 'KO', color : status ? 'green' : 'red'} ); this.testListElt.appendChild(testCaseStatus); @@ -64,7 +64,7 @@ var testSuiteStatus = document.createElement('li'); testSuiteStatus.innerHTML = pskl.utils.Template.replace( - 'Test finished : ${status} (${elapsed} seconds)', + 'Test finished : {{status}} ({{elapsed}} seconds)', {status : status, elapsed : elapsed} ); this.testListElt.appendChild(testSuiteStatus); diff --git a/src/js/service/storage/FileDownloadStorageService.js b/src/js/service/storage/FileDownloadStorageService.js index 6ee5aea..87814f1 100644 --- a/src/js/service/storage/FileDownloadStorageService.js +++ b/src/js/service/storage/FileDownloadStorageService.js @@ -10,7 +10,7 @@ pskl.utils.BlobUtils.stringToBlob(serialized, function(blob) { var piskelName = piskel.getDescriptor().name; - var timestamp = pskl.utils.DateUtils.format(new Date(), '${Y}${M}${D}-${H}${m}${s}'); + var timestamp = pskl.utils.DateUtils.format(new Date(), '{{Y}}{{M}}{{D}}-{{H}}{{m}}{{s}}'); var fileName = piskelName + '-' + timestamp + '.piskel'; try { diff --git a/src/js/utils/Template.js b/src/js/utils/Template.js index c5b2e41..ade063b 100644 --- a/src/js/utils/Template.js +++ b/src/js/utils/Template.js @@ -49,7 +49,7 @@ value = ''; } } - template = template.replace(new RegExp('\\$\\{' + key + '\\}', 'g'), value); + template = template.replace(new RegExp('\\{\\{' + key + '\\}\\}', 'g'), value); } } return template; diff --git a/src/templates/dialogs/browse-local.html b/src/templates/dialogs/browse-local.html index b6f80ba..b358253 100644 --- a/src/templates/dialogs/browse-local.html +++ b/src/templates/dialogs/browse-local.html @@ -21,9 +21,9 @@ \ No newline at end of file diff --git a/src/templates/dialogs/cheatsheet.html b/src/templates/dialogs/cheatsheet.html index 6d2191d..bcbec7a 100644 --- a/src/templates/dialogs/cheatsheet.html +++ b/src/templates/dialogs/cheatsheet.html @@ -41,9 +41,9 @@ \ No newline at end of file diff --git a/src/templates/dialogs/create-palette.html b/src/templates/dialogs/create-palette.html index cae390df..31f8842 100644 --- a/src/templates/dialogs/create-palette.html +++ b/src/templates/dialogs/create-palette.html @@ -75,10 +75,10 @@ \ No newline at end of file diff --git a/src/templates/drawing-tools.html b/src/templates/drawing-tools.html index 5b29661..e50de90 100644 --- a/src/templates/drawing-tools.html +++ b/src/templates/drawing-tools.html @@ -35,6 +35,6 @@ \ No newline at end of file diff --git a/src/templates/layers-list.html b/src/templates/layers-list.html index 3bc8a82..36b8385 100644 --- a/src/templates/layers-list.html +++ b/src/templates/layers-list.html @@ -34,6 +34,6 @@ diff --git a/src/templates/misc-templates.html b/src/templates/misc-templates.html index a1c0c82..41fc2c0 100644 --- a/src/templates/misc-templates.html +++ b/src/templates/misc-templates.html @@ -1,32 +1,32 @@
\ No newline at end of file diff --git a/src/templates/palettes-list.html b/src/templates/palettes-list.html index 02fdde2..ef7824b 100644 --- a/src/templates/palettes-list.html +++ b/src/templates/palettes-list.html @@ -11,8 +11,8 @@
diff --git a/src/templates/settings/import.html b/src/templates/settings/import.html index b23ec91..87c2687 100644 --- a/src/templates/settings/import.html +++ b/src/templates/settings/import.html @@ -45,7 +45,7 @@