From bee5bbbf0e3de3f6cc153ae15f0a70c710ff1a8d Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Mon, 15 Oct 2018 11:54:57 +0200 Subject: [PATCH] Move files_drop to compiled handlebars Signed-off-by: Roeland Jago Douma --- apps/files_sharing/js/files_drop.js | 14 ++-------- apps/files_sharing/js/templates.js | 28 +++++++++++++++++++ .../js/templates/files_drop.handlebars | 7 +++++ .../lib/Controller/ShareController.php | 1 + build/compile-handlebars-templates.sh | 3 ++ 5 files changed, 41 insertions(+), 12 deletions(-) create mode 100644 apps/files_sharing/js/templates.js create mode 100644 apps/files_sharing/js/templates/files_drop.handlebars diff --git a/apps/files_sharing/js/files_drop.js b/apps/files_sharing/js/files_drop.js index 8d1273f187..d10a61e0df 100644 --- a/apps/files_sharing/js/files_drop.js +++ b/apps/files_sharing/js/files_drop.js @@ -9,14 +9,7 @@ */ (function ($) { - var TEMPLATE = - '
  • ' + - '{{#if isUploading}}' + - ' {{name}}' + - '{{else}}' + - ' {{name}}' + - '{{/if}}' + - '
  • '; + var Drop = { /** @type {Function} **/ _template: undefined, @@ -130,10 +123,7 @@ * @private */ template: function () { - if (!this._template) { - this._template = Handlebars.compile(TEMPLATE); - } - return this._template; + return OCA.Sharing.Templates['files_drop']; } }; diff --git a/apps/files_sharing/js/templates.js b/apps/files_sharing/js/templates.js new file mode 100644 index 0000000000..ce7409b465 --- /dev/null +++ b/apps/files_sharing/js/templates.js @@ -0,0 +1,28 @@ +(function() { + var template = Handlebars.template, templates = OCA.Sharing.Templates = OCA.Sharing.Templates || {}; +templates['files_drop'] = template({"1":function(container,depth0,helpers,partials,data) { + var helper; + + return "\n " + + container.escapeExpression(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : (container.nullContext || {}),{"name":"name","hash":{},"data":data}) : helper))) + + "\n"; +},"3":function(container,depth0,helpers,partials,data) { + var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression; + + return " " + + alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper))) + + "\n"; +},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) { + var stack1, helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression; + + return "
  • \n '" + + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.isUploading : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.program(3, data, 0),"data":data})) != null ? stack1 : "") + + "
  • \n"; +},"useData":true}); +})(); \ No newline at end of file diff --git a/apps/files_sharing/js/templates/files_drop.handlebars b/apps/files_sharing/js/templates/files_drop.handlebars new file mode 100644 index 0000000000..4dea497f8d --- /dev/null +++ b/apps/files_sharing/js/templates/files_drop.handlebars @@ -0,0 +1,7 @@ +
  • + '{{#if isUploading}} + {{name}} + {{else}} + {{name}} + {{/if}} +
  • diff --git a/apps/files_sharing/lib/Controller/ShareController.php b/apps/files_sharing/lib/Controller/ShareController.php index 2cc34dde8b..8e9cc5a963 100644 --- a/apps/files_sharing/lib/Controller/ShareController.php +++ b/apps/files_sharing/lib/Controller/ShareController.php @@ -387,6 +387,7 @@ class ShareController extends AuthPublicShareController { \OCP\Util::addScript('files', 'file-upload'); \OCP\Util::addStyle('files_sharing', 'publicView'); \OCP\Util::addScript('files_sharing', 'public'); + \OCP\Util::addScript('files_sharing', 'templates'); \OCP\Util::addScript('files_sharing', 'public_note'); \OCP\Util::addScript('files', 'fileactions'); \OCP\Util::addScript('files', 'fileactionsmenu'); diff --git a/build/compile-handlebars-templates.sh b/build/compile-handlebars-templates.sh index 52954333f6..493b3757e0 100755 --- a/build/compile-handlebars-templates.sh +++ b/build/compile-handlebars-templates.sh @@ -28,6 +28,9 @@ handlebars -n OCA.Versions.Templates apps/files_versions/js/templates -f apps/fi # Workflowengine handlebars -n OCA.WorkflowEngine.Templates apps/workflowengine/js/templates -f apps/workflowengine/js/templates.js +# Sharing +handlebars -n OCA.Sharing.Templates apps/files_sharing/js/templates -f apps/files_sharing/js/templates.js + if [[ $(git diff --name-only) ]]; then echo "Please submit your compiled handlebars templates" echo