From 335efcc43b2ac731794cf0bea92c249d8b2a5cd5 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Mon, 1 Oct 2018 10:43:17 +0200 Subject: [PATCH 1/2] Move to 1 template file for files Signed-off-by: Roeland Jago Douma --- apps/files/js/filesummary.js | 2 +- apps/files/js/merged-index.json | 2 +- .../{filesummary_template.js => templates.js} | 2 +- .../js/templates/detailsview.handlebars.js | 28 ------------------- .../js/{ => templates}/filesummary.handlebars | 0 .../lib/Controller/ShareController.php | 2 +- build/compile-handlebars-templates.sh | 2 +- 7 files changed, 5 insertions(+), 33 deletions(-) rename apps/files/js/{filesummary_template.js => templates.js} (85%) delete mode 100644 apps/files/js/templates/detailsview.handlebars.js rename apps/files/js/{ => templates}/filesummary.handlebars (100%) diff --git a/apps/files/js/filesummary.js b/apps/files/js/filesummary.js index ed369ff0723..c866ccb4ff5 100644 --- a/apps/files/js/filesummary.js +++ b/apps/files/js/filesummary.js @@ -196,7 +196,7 @@ * * handlebars -n OCA.Files.FileSummary.Templates filesummary.handlebars -f filesummary_template.js */ - return OCA.Files.FileSummary.Templates['filesummary'](_.extend({ + return OCA.Files.Templates['filesummary'](_.extend({ connectorLabel: t('files', '{dirs} and {files}', {dirs: '', files: ''}) }, data)); }, diff --git a/apps/files/js/merged-index.json b/apps/files/js/merged-index.json index 5b2227b1d3a..e891d10bdae 100644 --- a/apps/files/js/merged-index.json +++ b/apps/files/js/merged-index.json @@ -1,12 +1,12 @@ [ "app.js", + "templates.js", "file-upload.js", "newfilemenu.js", "jquery.fileupload.js", "jquery-visibility.js", "fileinfomodel.js", "filesummary.js", - "filesummary_template.js", "filemultiselectmenu.js", "breadcrumb.js", "filelist.js", diff --git a/apps/files/js/filesummary_template.js b/apps/files/js/templates.js similarity index 85% rename from apps/files/js/filesummary_template.js rename to apps/files/js/templates.js index 67a4d6b4e86..325592a3f88 100644 --- a/apps/files/js/filesummary_template.js +++ b/apps/files/js/templates.js @@ -1,5 +1,5 @@ (function() { - var template = Handlebars.template, templates = OCA.Files.FileSummary.Templates = OCA.Files.FileSummary.Templates || {}; + var template = Handlebars.template, templates = OCA.Files.Templates = OCA.Files.Templates || {}; templates['filesummary'] = template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) { var helper; diff --git a/apps/files/js/templates/detailsview.handlebars.js b/apps/files/js/templates/detailsview.handlebars.js deleted file mode 100644 index c109da77a63..00000000000 --- a/apps/files/js/templates/detailsview.handlebars.js +++ /dev/null @@ -1,28 +0,0 @@ -(function() { - var template = Handlebars.template, templates = OCA.Files.Templates = OCA.Files.Templates || {}; -templates['detailsview'] = template({"1":function(container,depth0,helpers,partials,data) { - var stack1; - - return "\n"; -},"2":function(container,depth0,helpers,partials,data) { - var helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression; - - return "
  • \n " - + alias4(((helper = (helper = helpers.label || (depth0 != null ? depth0.label : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"label","hash":{},"data":data}) : helper))) - + "\n
  • \n"; -},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) { - var stack1, helper, alias1=depth0 != null ? depth0 : {}; - - return "
    \n" - + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.tabHeaders : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") - + "
    \n
    \n\n"; -},"useData":true}); -})(); diff --git a/apps/files/js/filesummary.handlebars b/apps/files/js/templates/filesummary.handlebars similarity index 100% rename from apps/files/js/filesummary.handlebars rename to apps/files/js/templates/filesummary.handlebars diff --git a/apps/files_sharing/lib/Controller/ShareController.php b/apps/files_sharing/lib/Controller/ShareController.php index 9057f7abaed..2cc34dde8bb 100644 --- a/apps/files_sharing/lib/Controller/ShareController.php +++ b/apps/files_sharing/lib/Controller/ShareController.php @@ -397,7 +397,7 @@ class ShareController extends AuthPublicShareController { // JS required for folders \OCP\Util::addStyle('files', 'merged'); \OCP\Util::addScript('files', 'filesummary'); - \OCP\Util::addScript('files', 'filesummary_template'); + \OCP\Util::addScript('files', 'templates'); \OCP\Util::addScript('files', 'breadcrumb'); \OCP\Util::addScript('files', 'fileinfomodel'); \OCP\Util::addScript('files', 'newfilemenu'); diff --git a/build/compile-handlebars-templates.sh b/build/compile-handlebars-templates.sh index 80e2e661f4d..585406c4e8f 100755 --- a/build/compile-handlebars-templates.sh +++ b/build/compile-handlebars-templates.sh @@ -11,7 +11,7 @@ handlebars -n OC.Settings.Templates settings/js/authtoken.handlebars -f setting handlebars -n OC.ContactsMenu.Templates core/js/contactsmenu -f core/js/contactsmenu_templates.js # Files app -handlebars -n OCA.Files.FileSummary.Templates apps/files/js/filesummary.handlebars -f apps/files/js/filesummary_template.js +handlebars -n OCA.Files.Templates apps/files/js/templates -f apps/files/js/templates.js if [[ $(git diff --name-only) ]]; then echo "Please submit your compiled handlebars templates" From 40934ab15b2a6989a3ab067aec4654309dbd6c43 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Mon, 1 Oct 2018 10:52:56 +0200 Subject: [PATCH 2/2] Move the filemultiselectmenu over to compiled handlebars Signed-off-by: Roeland Jago Douma --- apps/files/js/filemultiselectmenu.js | 19 ++---------- apps/files/js/templates.js | 29 +++++++++++++++++++ .../templates/filemultiselectmenu.handlebars | 14 +++++++++ 3 files changed, 45 insertions(+), 17 deletions(-) create mode 100644 apps/files/js/templates/filemultiselectmenu.handlebars diff --git a/apps/files/js/filemultiselectmenu.js b/apps/files/js/filemultiselectmenu.js index d587d1fbdb2..d50fe28eace 100644 --- a/apps/files/js/filemultiselectmenu.js +++ b/apps/files/js/filemultiselectmenu.js @@ -9,21 +9,6 @@ */ (function() { - var TEMPLATE_MENU = - ''; - var FileMultiSelectMenu = OC.Backbone.View.extend({ tagName: 'div', className: 'filesSelectMenu popovermenu bubble menu-center', @@ -34,12 +19,12 @@ events: { 'click a.action': '_onClickAction' }, - template: Handlebars.compile(TEMPLATE_MENU), + /** * Renders the menu with the currently set items */ render: function() { - this.$el.html(this.template({ + this.$el.html(OCA.Files.Templates['filemultiselectmenu']({ items: this._scopes })); }, diff --git a/apps/files/js/templates.js b/apps/files/js/templates.js index 325592a3f88..8ada62b6d60 100644 --- a/apps/files/js/templates.js +++ b/apps/files/js/templates.js @@ -1,5 +1,34 @@ (function() { var template = Handlebars.template, templates = OCA.Files.Templates = OCA.Files.Templates || {}; +templates['filemultiselectmenu'] = template({"1":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 \n" + + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.iconClass : depth0),{"name":"if","hash":{},"fn":container.program(2, data, 0),"inverse":container.program(4, data, 0),"data":data})) != null ? stack1 : "") + + " " + + alias4(((helper = (helper = helpers.displayName || (depth0 != null ? depth0.displayName : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"displayName","hash":{},"data":data}) : helper))) + + "\n \n
  • \n"; +},"2":function(container,depth0,helpers,partials,data) { + var helper; + + return " \n"; +},"4":function(container,depth0,helpers,partials,data) { + return " \n"; +},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) { + var stack1; + + return "
      \n" + + ((stack1 = helpers.each.call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.items : depth0),{"name":"each","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + "
    \n"; +},"useData":true}); templates['filesummary'] = template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) { var helper; diff --git a/apps/files/js/templates/filemultiselectmenu.handlebars b/apps/files/js/templates/filemultiselectmenu.handlebars new file mode 100644 index 00000000000..9a723920db9 --- /dev/null +++ b/apps/files/js/templates/filemultiselectmenu.handlebars @@ -0,0 +1,14 @@ +