diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2018-09-27 13:18:26 +0200 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2018-09-27 20:16:08 +0200 |
commit | ae1250f422126808691a99de45ec1ae0574678da (patch) | |
tree | a8528046f0e02037535dc83c5aa3ee7826b25881 /apps/files | |
parent | d9842314586c8f19c5c2e763b8e142aa00bd5469 (diff) | |
download | nextcloud-server-ae1250f422126808691a99de45ec1ae0574678da.tar.gz nextcloud-server-ae1250f422126808691a99de45ec1ae0574678da.zip |
Compile filesummary handlebars
Fixes #11030
For https://github.com/orgs/nextcloud/projects/18
This template is now compiled so this no longer has to happen in the
browser. Another step towards a stricter CSP.
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'apps/files')
-rw-r--r-- | apps/files/js/filesummary.handlebars | 7 | ||||
-rw-r--r-- | apps/files/js/filesummary.js | 19 | ||||
-rw-r--r-- | apps/files/js/filesummary_template.js | 10 | ||||
-rw-r--r-- | apps/files/js/merged-index.json | 1 |
4 files changed, 24 insertions, 13 deletions
diff --git a/apps/files/js/filesummary.handlebars b/apps/files/js/filesummary.handlebars new file mode 100644 index 00000000000..f975a2a7737 --- /dev/null +++ b/apps/files/js/filesummary.handlebars @@ -0,0 +1,7 @@ +<span class="info"> + <span class="dirinfo"></span> + <span class="connector">{{connectorLabel}}</span> + <span class="fileinfo"></span> + <span class="hiddeninfo"></span> + <span class="filter"></span> +</span> diff --git a/apps/files/js/filesummary.js b/apps/files/js/filesummary.js index 7545654ec44..ed369ff0723 100644 --- a/apps/files/js/filesummary.js +++ b/apps/files/js/filesummary.js @@ -20,15 +20,6 @@ */ (function() { - var INFO_TEMPLATE = - '<span class="info">' + - '<span class="dirinfo"></span>' + - '<span class="connector">{{connectorLabel}}</span>' + - '<span class="fileinfo"></span>' + - '<span class="hiddeninfo"></span>' + - '<span class="filter"></span>' + - '</span>'; - /** * The FileSummary class encapsulates the file summary values and * the logic to render it in the given container @@ -200,10 +191,12 @@ }, _infoTemplate: function(data) { - if (!this._infoTemplateCompiled) { - this._infoTemplateCompiled = Handlebars.compile(INFO_TEMPLATE); - } - return this._infoTemplateCompiled(_.extend({ + /* NOTE: To update the template make changes in filesummary.handlebars + * and run: + * + * handlebars -n OCA.Files.FileSummary.Templates filesummary.handlebars -f filesummary_template.js + */ + return OCA.Files.FileSummary.Templates['filesummary'](_.extend({ connectorLabel: t('files', '{dirs} and {files}', {dirs: '', files: ''}) }, data)); }, diff --git a/apps/files/js/filesummary_template.js b/apps/files/js/filesummary_template.js new file mode 100644 index 00000000000..c535c43cae5 --- /dev/null +++ b/apps/files/js/filesummary_template.js @@ -0,0 +1,10 @@ +(function() { + var template = Handlebars.template, templates = OCA.Files.FileSummary.Templates = OCA.Files.FileSummary.Templates || {}; +templates['filesummary'] = template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) { + var helper; + + return "<span class=\"info\">\n <span class=\"dirinfo\"></span>\n <span class=\"connector\">" + + container.escapeExpression(((helper = (helper = helpers.connectorLabel || (depth0 != null ? depth0.connectorLabel : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0,{"name":"connectorLabel","hash":{},"data":data}) : helper))) + + "</span>\n <span class=\"fileinfo\"></span>\n <span class=\"hiddeninfo\"></span>\n <span class=\"filter\"></span>\n</span>\n"; +},"useData":true}); +})();
\ No newline at end of file diff --git a/apps/files/js/merged-index.json b/apps/files/js/merged-index.json index cd7e72e1a51..5b2227b1d3a 100644 --- a/apps/files/js/merged-index.json +++ b/apps/files/js/merged-index.json @@ -6,6 +6,7 @@ "jquery-visibility.js", "fileinfomodel.js", "filesummary.js", + "filesummary_template.js", "filemultiselectmenu.js", "breadcrumb.js", "filelist.js", |