From f30b7bc83bcd0cf1e2d10ee1a9b09f18c714e4b8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Benoi=CC=82t=20Pin?= Date: Thu, 28 Nov 2013 15:06:08 +0100 Subject: [PATCH 01/16] bugfix localisation. --- skins/custom_content/document_edit_template.pt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/skins/custom_content/document_edit_template.pt b/skins/custom_content/document_edit_template.pt index 65b4c9c..8755973 100644 --- a/skins/custom_content/document_edit_template.pt +++ b/skins/custom_content/document_edit_template.pt @@ -1,10 +1,10 @@ - + Document edit form - +
generic_header macro @@ -20,7 +20,7 @@

- +
-- 2.20.1 From 3ddc4b58178f6faae14b1afa3548e2b5fc8b8281 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Benoi=CC=82t=20Pin?= Date: Fri, 29 Nov 2013 11:09:02 +0100 Subject: [PATCH 02/16] xmllint de folder_factories --- skins/content/folder_factories.pt | 44 ++++++++++++++----------------- 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/skins/content/folder_factories.pt b/skins/content/folder_factories.pt index fca79ae..6581687 100644 --- a/skins/content/folder_factories.pt +++ b/skins/content/folder_factories.pt @@ -1,49 +1,45 @@ - - + + folder_factories - -
- +
- - - - +

Type
+ + + - + -
-
- - +
+
+ + - + - -

Type Name

- - Content name
+ + Content name - + - +
+
+ - - \ No newline at end of file + -- 2.20.1 From 2b582ca6aead4eff492c8191d5a90633d1e0ff19 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Benoi=CC=82t=20Pin?= Date: Fri, 29 Nov 2013 13:53:13 +0100 Subject: [PATCH 03/16] code mort. --- skins/ajax_scripts/ajax_form_manager.js | 1 - 1 file changed, 1 deletion(-) diff --git a/skins/ajax_scripts/ajax_form_manager.js b/skins/ajax_scripts/ajax_form_manager.js index 214c6f6..6fff36f 100644 --- a/skins/ajax_scripts/ajax_form_manager.js +++ b/skins/ajax_scripts/ajax_form_manager.js @@ -17,7 +17,6 @@ FormManager = function(form, responseTextDest, lazy) { var thisManager = this; this.form.onsubmit = function(evt) { thisManager.submit(evt); }; this.form.onclick = function(evt) { thisManager.click(evt); }; - this.submitButton = null; /* raised on form submit */ this.onBeforeSubmit = null; -- 2.20.1 From ac77e020edc6dff3d0ce497324e347f7a8d54a34 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Benoi=CC=82t=20Pin?= Date: Fri, 29 Nov 2013 13:54:13 +0100 Subject: [PATCH 04/16] =?utf8?q?Ajout=20du=20type=20correct=20m=C3=AAme=20?= =?utf8?q?si=20touche=20entr=C3=A9e.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- skins/content/folder_factories.pt | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/skins/content/folder_factories.pt b/skins/content/folder_factories.pt index 6581687..5a76798 100644 --- a/skins/content/folder_factories.pt +++ b/skins/content/folder_factories.pt @@ -10,7 +10,7 @@
-
+ @@ -40,6 +40,29 @@

+ -- 2.20.1 From 2a4365077b1a34197b3d41a7070e2546d6aa2fb1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Beno=C3=AEt=20Pin?= Date: Sat, 30 Nov 2013 16:09:35 +0100 Subject: [PATCH 05/16] =?utf8?q?Modernisation=20du=20handle=20ajax=20racin?= =?utf8?q?e.=20On=20utilise=20l'API=20html5=20de=20l'objet=20history,=20et?= =?utf8?q?=20on=20arr=C3=AAte=20de=20s'emmerder=20avec=20le=20hack=20du=20?= =?utf8?q?#.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- skins/ajax_scripts/root_handlers.js | 134 ++++++++-------------------- 1 file changed, 36 insertions(+), 98 deletions(-) diff --git a/skins/ajax_scripts/root_handlers.js b/skins/ajax_scripts/root_handlers.js index e114140..47ac1d7 100644 --- a/skins/ajax_scripts/root_handlers.js +++ b/skins/ajax_scripts/root_handlers.js @@ -1,4 +1,4 @@ -// © Benoît PIN 2006-2009 +// © Benoît PIN 2006-2013 // http://plinn.org // Licence GPL // @@ -12,57 +12,10 @@ var AjaxLinkHandler; var reProtocol = /^\s*[a-z]+:/; -AjaxLinkHandler = function(locationPollInterval) { - var thisHandler = this; - this.previousHash = '#' + location.href; - location.hash = location.href; - setInterval(function(){thisHandler.checkLocation();}, locationPollInterval) - addListener(document.body, 'click', function(evt){thisHandler.handleClick(evt);}); - if (browser.isIE55 || browser.isIE6up) { - var ie_historyFrm = document.createElement('iframe'); - ie_historyFrm.setAttribute('src', portal_url() + '/scrape_ie_history'); - with (ie_historyFrm.style) { - border="0"; - width="1px"; - height="1px"; - position="absolute"; - bottom="0"; - right="0"; - visibility="visible"; - } - document.body.appendChild(ie_historyFrm); - this.historyFrame = ie_historyFrm; - } -}; - -AjaxLinkHandler.prototype.checkLocation = function() { - if ((this.previousHash != location.hash) && location.hash) { - var rawUrl = unescape(location.hash.slice(1)); - - var urlHash = rawUrl.split('#'); - var url = urlHash[0]; - var hash = urlHash[1]; - - var ajaxParams='ajax=1&_browserObjectUrl=' + escape(absolute_url()); - var urlQueryStart = url.indexOf('?'); - if (urlQueryStart != -1) - url += '&' + ajaxParams; - else - url += '?' + ajaxParams; - - try { - var fi = new FragmentImporter(url); - if (hash) { - var thisHandler = this; - fi.onAfterPopulate = function(){thisHandler.loadHash('#' + hash);}; - } - fi.load(rawUrl); - } - catch (e) { - window.location.href = rawUrl; - } - } - this.previousHash = location.hash; +AjaxLinkHandler = function() { + var self = this; + addListener(document.body, 'click', function(evt){self.handleClick(evt);}); + addListener(window, 'popstate', function(evt){self.handlePopState(evt);}); }; AjaxLinkHandler.prototype.handleClick = function(evt){ @@ -73,16 +26,7 @@ AjaxLinkHandler.prototype.handleClick = function(evt){ return; } target.blur(); - // prevent click glitches from IE :(( - if (browser.isIE55 || browser.isIE6up) { - if (_disableRootClickHandler) - return; - else { - _disableRootClickHandler = true; - setTimeout("_disableRootClickHandler=false", 100); - } - } - + if (target.target) return; @@ -99,40 +43,39 @@ AjaxLinkHandler.prototype.handleClick = function(evt){ url = absolute_url() + '/' + target.getAttribute('href', 2); if (!url) return; - - if (browser.isGecko) - url = encodeURIComponent(url); - var query = target.search; - if ((query && query.search("noajax=1") != -1) || target.name == 'noajax') - return; - - disableDefault(evt); - this.loadUrl(url); -}; -if (browser.isIE55 || browser.isIE6up) { - AjaxLinkHandler.prototype.loadUrl = function(url) { - if (location.hash.slice(1) == url) - url += '#' - this.historyFrame.contentWindow.location.search = '?url=' + escape(url); - location.hash = escape(url); - }; -} -else { - AjaxLinkHandler.prototype.loadUrl = function(url) { - if (location.hash.slice(1) == url) - url += '#' - location.hash = escape(url); - }; -} + var query = target.search; + if ((query && query.search("noajax=1") != -1) || target.name == 'noajax') + return; + + disableDefault(evt); + this.loadUrl(url); +}; -AjaxLinkHandler.prototype.loadHash = function(hash) { - this.previousHash = hash; - location.hash = hash; +AjaxLinkHandler.prototype.handlePopState = function (evt, extra) { + if (evt.state) + this.loadUrl(evt.state, true); }; -AjaxLinkHandler.prototype.ie_loadHistory = function(url) { - location.hash = escape(url); +AjaxLinkHandler.prototype.loadUrl = function(url, noPush) { + var rawUrl = url; + var ajaxParams='ajax=1&_browserObjectUrl=' + escape(absolute_url()); + var urlQueryStart = url.indexOf('?'); + if (urlQueryStart != -1) + url += '&' + ajaxParams; + else + url += '?' + ajaxParams; + + try { + var fi = new FragmentImporter(url); + fi.load(); + } + catch (e) { + window.location.href = rawUrl; + return; + } + if (!noPush) + history.pushState(rawUrl, '', rawUrl) }; function ajaxSubmitFormHandler(evt) { @@ -144,20 +87,15 @@ function ajaxSubmitFormHandler(evt) { if (form.nodeName == 'FORM') { var fm = new FormManager(form, document.getElementById("mainCell")); fm.submitButton = target; - //disableDefault(evt); break; } } } - } function _addRootHandlers() { - if ((AJAX_CONFIG & 1) == 1) { + if ((AJAX_CONFIG & 1) == 1 && history.pushState !== undefined) { window.linkHandler = new AjaxLinkHandler(200); - if (browser.isIE55 || browser.isIE6up) { - _disableRootClickHandler = false; - } } if ((AJAX_CONFIG & 2) == 2) { addListener(document, 'click', ajaxSubmitFormHandler); -- 2.20.1 From c0074b891b1f9f79f152b1c2f50431d77ea77192 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Benoi=CC=82t=20Pin?= Date: Mon, 2 Dec 2013 10:46:57 +0100 Subject: [PATCH 06/16] =?utf8?q?Ajout=20dans=20l=E2=80=99historique=20des?= =?utf8?q?=20chargements=20de=20formulaires.=20TODO=C2=A0:=20tester=20la?= =?utf8?q?=20m=C3=A9thode=20(post=20/=20get)=20et=20agir=20en=20fonction.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- skins/ajax_scripts/ajax_form_manager.js | 1 + 1 file changed, 1 insertion(+) diff --git a/skins/ajax_scripts/ajax_form_manager.js b/skins/ajax_scripts/ajax_form_manager.js index 6fff36f..508a4f9 100644 --- a/skins/ajax_scripts/ajax_form_manager.js +++ b/skins/ajax_scripts/ajax_form_manager.js @@ -424,6 +424,7 @@ FormManager.prototype.loadResponse = function(req) { var onAfterPopulate = this.onAfterPopulate; onAfterPopulate(); this.scrollToPortalMessage(); + history.pushState(absolute_url(), document.title, absolute_url()); }; FormManager.prototype.scrollToPortalMessage = function() { -- 2.20.1 From 29135020818ee259b01d55ba0808c653be143732 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Benoi=CC=82t=20Pin?= Date: Tue, 3 Dec 2013 21:01:30 +0100 Subject: [PATCH 07/16] =?utf8?q?Quelques=20ajustement=20des=20types=20auto?= =?utf8?q?ris=C3=A9s=20dans=20les=20conteneurs.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- profiles/photo/types/CMF_Site.xml | 2 -- profiles/photo/types/Huge_Plinn_Folder.xml | 5 +---- profiles/photo/types/Plinn_Folder.xml | 2 +- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/profiles/photo/types/CMF_Site.xml b/profiles/photo/types/CMF_Site.xml index d36c06c..b530b34 100644 --- a/profiles/photo/types/CMF_Site.xml +++ b/profiles/photo/types/CMF_Site.xml @@ -18,9 +18,7 @@ - - diff --git a/profiles/photo/types/Huge_Plinn_Folder.xml b/profiles/photo/types/Huge_Plinn_Folder.xml index 38799ea..79b48ac 100644 --- a/profiles/photo/types/Huge_Plinn_Folder.xml +++ b/profiles/photo/types/Huge_Plinn_Folder.xml @@ -17,12 +17,9 @@ - - + - - diff --git a/profiles/photo/types/Plinn_Folder.xml b/profiles/photo/types/Plinn_Folder.xml index c33863b..bdcf384 100644 --- a/profiles/photo/types/Plinn_Folder.xml +++ b/profiles/photo/types/Plinn_Folder.xml @@ -1,5 +1,5 @@ - Folder Date: Tue, 3 Dec 2013 23:30:31 +0100 Subject: [PATCH 08/16] =?utf8?q?D=C3=A9but=20d=E2=80=99impl=C3=A9mentation?= =?utf8?q?=20de=20l=E2=80=99upload=20par=20glisser=20/=20d=C3=A9poser=20da?= =?utf8?q?ns=20les=20dossiers=20Plinn.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- skins/ajax_scripts/folder_contents_script.js | 62 ++++++++++++++++++++ skins/photo_theme/folder_contents_macros.pt | 7 ++- 2 files changed, 67 insertions(+), 2 deletions(-) diff --git a/skins/ajax_scripts/folder_contents_script.js b/skins/ajax_scripts/folder_contents_script.js index ece076d..dc31b4c 100644 --- a/skins/ajax_scripts/folder_contents_script.js +++ b/skins/ajax_scripts/folder_contents_script.js @@ -7,6 +7,7 @@ var FolderDDropControler; var DropTarget; var loadListing; +var DDFolderUploader; (function(){ @@ -240,4 +241,65 @@ loadListing = function(evt) { return false; } +DDFolderUploader = function(dropbox, uploadUrl, listing) { + DDFileUploaderBase.apply(this, [dropbox, uploadUrl]); + this.listing = listing; + var thead = listing; + do { + thead = thead.previousSibling; + } while (thead.tagName !== 'THEAD') + + var cells = thead.getElementsByTagName('th'); + var cell; + this.tableSpan = 0; + for (var i = 0 ; i < cells.length ; i++) { + cell = cells[i]; + this.tableSpan += cell.getAttribute('colspan') ? Number(cell.getAttribute('colspan')) : 1; + } + var lastRow = listing.lastChild; + while(lastRow && lastRow.tagName !== 'TR') { + lastRow = lastRow.previousSibling; + } + this.lastRowClassName = lastRow ? lastRow.className : 'even'; +}; + +copyPrototype(DDFolderUploader, DDFileUploaderBase); + + +DDFolderUploader.prototype.createRow = function(file) { + var row = document.createElement('tr'); + row.file = file; + row.className = this.lastRowClassName === 'even' ? 'odd' : 'even'; + this.lastRowClassName = row.className; + var td = document.createElement('td'); + td.setAttribute('colspan', this.tableSpan); + td.innerHTML = file.name; + row.appendChild(td); + this.listing.appendChild(row); + return row; +}; + +// Methods about upload +DDFolderUploader.prototype.handleFiles = function(files) { + var file, i, row; + for (i = 0; i < files.length; i++) { + file = files[i]; + row = this.createRow(file); + this.uploadQueuePush(row); + } +}; + +DDFolderUploader.prototype.beforeUpload = function(item) { + // To be implemented by decendant. +}; + +DDFolderUploader.prototype.uploadCompleteHandlerCB = function(req) { + // To be implemented by descendant. +}; + +DDFolderUploader.prototype.progressHandlerCB = function(progress) { + // To be implemented by descendant. + // 0 <= progress <= 1 +}; + }()); \ No newline at end of file diff --git a/skins/photo_theme/folder_contents_macros.pt b/skins/photo_theme/folder_contents_macros.pt index 00d2ee9..bd8e7f5 100644 --- a/skins/photo_theme/folder_contents_macros.pt +++ b/skins/photo_theme/folder_contents_macros.pt @@ -77,7 +77,7 @@ batch navigation -- 2.20.1 From c16f83a556d4c464ba923e53d3db28ff5590a84b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Benoi=CC=82t=20Pin?= Date: Wed, 4 Dec 2013 11:22:46 +0100 Subject: [PATCH 09/16] coquille-- --- Folder.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Folder.py b/Folder.py index 2458bf1..7b193fe 100644 --- a/Folder.py +++ b/Folder.py @@ -349,7 +349,7 @@ class PlinnFolder(CMFCatalogAware, PortalFolder, DefaultDublinCoreImpl) : meth = method_id and getattr(ob, method_id) or (lambda : 'Not implemented') RESPONSE.setStatus(httpRespCode) RESPONSE.setHeader('Content-Type', 'text/xml;;charset=utf-8') - return '%s>' % meth().strip() + return '%s' % meth().strip() # ## overload to maintain ownership if authenticated user has 'Manage portal' permission -- 2.20.1 From 06fa1d97467280400e2031d488e40bb9b658e903 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Benoi=CC=82t=20Pin?= Date: Wed, 4 Dec 2013 14:29:53 +0100 Subject: [PATCH 10/16] =?utf8?q?On=20r=C3=A9cup=C3=A8re=20le=20snipet=20d?= =?utf8?q?=E2=80=99apr=C3=A8s=20upload=20sur=20le=20dossier=20si=20le=20co?= =?utf8?q?ntenu=20n=E2=80=99en=20a=20pas=20de=20d=C3=A9fini.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- Folder.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Folder.py b/Folder.py index 7b193fe..b762702 100644 --- a/Folder.py +++ b/Folder.py @@ -343,13 +343,19 @@ class PlinnFolder(CMFCatalogAware, PortalFolder, DefaultDublinCoreImpl) : ob.PUT(REQUEST, RESPONSE) ob.orig_name = fileName - + # get method from ob created / refreshed ti = ob.getTypeInfo() method_id = ti.queryMethodID('jsupload_snippet') - meth = method_id and getattr(ob, method_id) or (lambda : 'Not implemented') + meth = getattr(ob, method_id) if method_id else None + if not meth : + # get method from container that receive uploaded content + ti = self.getTypeInfo() + method_id = ti.queryMethodID('jsupload_snippet') + meth = getattr(self, method_id) if method_id else lambda : 'Not implemented' + RESPONSE.setStatus(httpRespCode) RESPONSE.setHeader('Content-Type', 'text/xml;;charset=utf-8') - return '%s' % meth().strip() + return '%s' % meth(ob).strip() # ## overload to maintain ownership if authenticated user has 'Manage portal' permission -- 2.20.1 From decd413cb0fb290e9ddb185252dee51dc8b6b9ec Mon Sep 17 00:00:00 2001 From: =?utf8?q?Benoi=CC=82t=20Pin?= Date: Wed, 4 Dec 2013 14:32:48 +0100 Subject: [PATCH 11/16] =?utf8?q?Avancement=20sur=20l=E2=80=99upload=20par?= =?utf8?q?=20glisser=20/=20d=C3=A9poser=20dans=20les=20dossiers.=20On=20af?= =?utf8?q?fiche=20le=20fragment=20html=20apr=C3=A8s=20upload.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- profiles/default/types.xml | 0 profiles/default/types/CMF_Site.xml | 2 -- profiles/default/types/Huge_Plinn_Folder.xml | 6 ++---- profiles/default/types/Photo.xml | 1 + profiles/photo/types/Huge_Plinn_Folder.xml | 1 + profiles/photo/types/Photo.xml | 1 + skins/ajax_scripts/folder_contents_script.js | 14 +++++++++++++- skins/photo_theme/folder_contents_macros.pt | 4 ++-- skins/photo_theme/folder_jsupload_snippet.py | 15 +++++++++++++++ .../folder_jsupload_snippet_template.pt | 5 +++++ 10 files changed, 40 insertions(+), 9 deletions(-) mode change 100755 => 100644 profiles/default/types.xml create mode 100644 skins/photo_theme/folder_jsupload_snippet.py create mode 100644 skins/photo_theme/folder_jsupload_snippet_template.pt diff --git a/profiles/default/types.xml b/profiles/default/types.xml old mode 100755 new mode 100644 diff --git a/profiles/default/types/CMF_Site.xml b/profiles/default/types/CMF_Site.xml index d36c06c..b530b34 100644 --- a/profiles/default/types/CMF_Site.xml +++ b/profiles/default/types/CMF_Site.xml @@ -18,9 +18,7 @@ - - diff --git a/profiles/default/types/Huge_Plinn_Folder.xml b/profiles/default/types/Huge_Plinn_Folder.xml index 38799ea..b589b21 100644 --- a/profiles/default/types/Huge_Plinn_Folder.xml +++ b/profiles/default/types/Huge_Plinn_Folder.xml @@ -17,17 +17,15 @@ - - + - - False + False + False + False + - + lock diff --git a/skins/photo_theme/folder_jsupload_snippet.py b/skins/photo_theme/folder_jsupload_snippet.py new file mode 100644 index 0000000..f932675 --- /dev/null +++ b/skins/photo_theme/folder_jsupload_snippet.py @@ -0,0 +1,15 @@ +##parameters=ob +from Products.CMFCore.utils import getUtilityByInterfaceName +utool = getUtilityByInterfaceName('Products.CMFCore.interfaces.IURLTool') +locale_date_fmt = context.locale_date_fmt() +infos = {'checkbox' : True, + 'url' : ob.absolute_url(), + 'lock' : False, + 'modified' : ob.modified().strftime(locale_date_fmt), + 'title_or_id' : ob.title_or_id(), + 'position' : context.getObjectPosition(ob.getId()), + 'type' : ob.Type() or None, + 'id' : ob.getId(), + 'icon': '%s/%s' % (utool(), ob.getIcon())} + +return context.folder_jsupload_snippet_template(listItemInfos=[infos]) \ No newline at end of file diff --git a/skins/photo_theme/folder_jsupload_snippet_template.pt b/skins/photo_theme/folder_jsupload_snippet_template.pt new file mode 100644 index 0000000..8b1e813 --- /dev/null +++ b/skins/photo_theme/folder_jsupload_snippet_template.pt @@ -0,0 +1,5 @@ + + +
+ + \ No newline at end of file -- 2.20.1 From a8d9cafde69dd2360870cc971f8e7393c4f5a0de Mon Sep 17 00:00:00 2001 From: =?utf8?q?Benoi=CC=82t=20Pin?= Date: Wed, 4 Dec 2013 20:37:03 +0100 Subject: [PATCH 12/16] =?utf8?q?noms=20de=20fichiers=20encod=C3=A9s.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- Folder.py | 4 ++-- skins/ajax_scripts/fileupload.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Folder.py b/Folder.py index b762702..4db6725 100644 --- a/Folder.py +++ b/Folder.py @@ -31,6 +31,7 @@ from zExceptions import Unauthorized import sys import warnings from cgi import escape +from urllib import unquote from OFS import Moniker from ZODB.POSException import ConflictError import OFS.subscribers @@ -297,8 +298,7 @@ class PlinnFolder(CMFCatalogAware, PortalFolder, DefaultDublinCoreImpl) : """ self.dav__init(REQUEST, RESPONSE) - - fileName = REQUEST.getHeader('X-File-Name', '') + fileName = unquote(REQUEST.getHeader('X-File-Name', '')) validId = makeValidId(self, fileName, allow_dup=True) ifhdr = REQUEST.get_header('If', '') diff --git a/skins/ajax_scripts/fileupload.js b/skins/ajax_scripts/fileupload.js index bf36628..675ff13 100644 --- a/skins/ajax_scripts/fileupload.js +++ b/skins/ajax_scripts/fileupload.js @@ -68,7 +68,7 @@ DDFileUploaderBase.prototype.upload = function(item) { req.open("PUT", this.uploadUrl); req.setRequestHeader("Content-Type", file.type); - req.setRequestHeader("X-File-Name", file.name); + req.setRequestHeader("X-File-Name", encodeURI(file.name)); addListener(reader, 'load', function(evt){ try { -- 2.20.1 From 326a6677709320dc5149de76f6ae2bdea31fe4fa Mon Sep 17 00:00:00 2001 From: =?utf8?q?Benoi=CC=82t=20Pin?= Date: Wed, 4 Dec 2013 21:07:15 +0100 Subject: [PATCH 13/16] =?utf8?q?Dans=20le=20cas=20(courant)=20o=C3=B9=20l?= =?utf8?q?=E2=80=99objet=20cr=C3=A9=C3=A9=20impl=C3=A9mente=20DublinCore,?= =?utf8?q?=20alors=20on=20initialise=20le=20titre=20avec=20le=20nom=20du?= =?utf8?q?=20fichier=20original=20et=20le=20format=20(content-type).?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- Folder.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Folder.py b/Folder.py index 4db6725..8691fcf 100644 --- a/Folder.py +++ b/Folder.py @@ -58,6 +58,7 @@ from Products.CMFCore.utils import _checkPermission, getToolByName from Products.CMFCore.utils import getUtilityByInterfaceName from Products.CMFCore.CMFCatalogAware import CMFCatalogAware from Products.CMFCore.PortalFolder import PortalFolder, ContentFilter +from Products.CMFCore.interfaces import IDublinCore from Products.CMFDefault.DublinCore import DefaultDublinCoreImpl from zope.interface import implements @@ -325,6 +326,9 @@ class PlinnFolder(CMFCatalogAware, PortalFolder, DefaultDublinCoreImpl) : ob = self.PUT_factory(validId, typ, body) self._setObject(validId, ob) ob = self._getOb(validId) + if IDublinCore.providedBy(ob) : + ob.editMetadata(title=fileName, + format=typ) httpRespCode = 201 else : httpRespCode = 200 -- 2.20.1 From 61413cff15e2ca1a1b698c5b82973d1713997225 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Benoi=CC=82t=20Pin?= Date: Wed, 4 Dec 2013 23:32:09 +0100 Subject: [PATCH 14/16] Retrait print de debug. --- File.py | 1 - 1 file changed, 1 deletion(-) diff --git a/File.py b/File.py index dfb22c4..22a1101 100755 --- a/File.py +++ b/File.py @@ -101,7 +101,6 @@ class File(BlobFile, CMFFile) : if orig_name : self.orig_name = orig_name - print self.absolute_url(), self.Format() if self.Format() == 'application/x-shockwave-flash' : if file : try : -- 2.20.1 From 522ae82bd3a30e30ed50c444fd93164479a8e051 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Benoi=CC=82t=20Pin?= Date: Wed, 4 Dec 2013 23:32:56 +0100 Subject: [PATCH 15/16] =?utf8?q?Ajout=20barre=20de=20progression=20de=20l?= =?utf8?q?=E2=80=99upload=20du=20fichier=20courant.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- skins/ajax_scripts/folder_contents_script.js | 26 +++++++++++++++----- skins/custom_generic/zpt_stylesheet.css.dtml | 13 +++++++++- 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/skins/ajax_scripts/folder_contents_script.js b/skins/ajax_scripts/folder_contents_script.js index 7204a4e..d427939 100644 --- a/skins/ajax_scripts/folder_contents_script.js +++ b/skins/ajax_scripts/folder_contents_script.js @@ -244,6 +244,7 @@ loadListing = function(evt) { DDFolderUploader = function(dropbox, uploadUrl, listing) { DDFileUploaderBase.apply(this, [dropbox, uploadUrl]); this.listing = listing; + this.progressBarMaxSize = listing.clientWidth; var thead = listing; do { thead = thead.previousSibling; @@ -273,9 +274,19 @@ DDFolderUploader.prototype.createRow = function(file) { this.lastRowClassName = row.className; var td = document.createElement('td'); td.setAttribute('colspan', this.tableSpan); - td.innerHTML = file.name; + var relSpan = document.createElement('span'); + relSpan.style.position = 'relative'; + td.appendChild(relSpan); + var progressBar = document.createElement('span'); + progressBar.className = 'upload-progress'; + row.progressBar = progressBar; + relSpan.appendChild(progressBar); + var fileNameSpan = document.createElement('span'); + fileNameSpan.innerHTML = file.name; + td.appendChild(fileNameSpan); row.appendChild(td); this.listing.appendChild(row); + this.progressBarMaxSize = row.clientWidth; return row; }; @@ -290,28 +301,31 @@ DDFolderUploader.prototype.handleFiles = function(files) { }; DDFolderUploader.prototype.beforeUpload = function(item) { - this.uploadedItem = item; - // To be implemented by decendant. + this.uploadedItem = item; + this.progressBar = item.progressBar; }; DDFolderUploader.prototype.uploadCompleteHandlerCB = function(req) { var item = this.uploadedItem; var row = getCopyOfNode(req.responseXML.documentElement.firstChild); - row.className = item.className; + row.className = item.className; if (req.status === 200) { // update - console.log('todo'); + console.log('todo'); } else if(req.status === 201) { // creation this.listing.replaceChild(row, item); + this.progressBarMaxSize = row.clientWidth; } }; DDFolderUploader.prototype.progressHandlerCB = function(progress) { - // To be implemented by descendant. // 0 <= progress <= 1 + var size = this.progressBarMaxSize * progress; + size = Math.round(size); + this.progressBar.style.width = size + 'px'; }; }()); \ No newline at end of file diff --git a/skins/custom_generic/zpt_stylesheet.css.dtml b/skins/custom_generic/zpt_stylesheet.css.dtml index 8acbdab..77011e0 100644 --- a/skins/custom_generic/zpt_stylesheet.css.dtml +++ b/skins/custom_generic/zpt_stylesheet.css.dtml @@ -390,7 +390,18 @@ textarea { } .listing .even { background-color: &dtml-evenRowBackgroundColor;; -} +} + +.listing span.upload-progress { + display: block; + position:absolute; + background:#ef8e32; + height:4px; + border-radius:2px; + width:0; + top:3px; +} + /* Batched navigation */ -- 2.20.1 From dcb4d334efa90367fc247c73be69590b50260143 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Benoi=CC=82t=20Pin?= Date: Wed, 4 Dec 2013 23:53:36 +0100 Subject: [PATCH 16/16] =?utf8?q?Si=20la=20cr=C3=A9ation=20du=20type=20adoc?= =?utf8?q?=20n=E2=80=99est=20pas=20possible=20(pas=20autoris=C3=A9e)=20on?= =?utf8?q?=20cr=C3=A9e=20alors=20un=20fichier=20en=20recours.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- Folder.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Folder.py b/Folder.py index 8691fcf..05b7129 100644 --- a/Folder.py +++ b/Folder.py @@ -323,9 +323,13 @@ class PlinnFolder(CMFCatalogAware, PortalFolder, DefaultDublinCoreImpl) : typ, enc=guess_content_type(validId, body) if self.checkIdAvailable(validId) : - ob = self.PUT_factory(validId, typ, body) - self._setObject(validId, ob) - ob = self._getOb(validId) + try : + ob = self.PUT_factory(validId, typ, body) + self._setObject(validId, ob) + ob = self._getOb(validId) + except ValueError : # maybe "Disallowed subobject type". Fallback to file type. + validId = self.invokeFactory('File', validId) + ob = self._getOb(validId) if IDublinCore.providedBy(ob) : ob.editMetadata(title=fileName, format=typ) -- 2.20.1