From 557e428c819e970931833486af69302ef75ce8ac Mon Sep 17 00:00:00 2001 From: Rodrigo Ferreira de Souza Date: Mon, 18 May 2015 18:43:45 -0300 Subject: [PATCH] Remove profile / add extra javascript files from cycle2 --- CHANGES.rst | 5 +- src/collective/js/cycle2/configure.zcml | 12 +++- .../cycle2/profiles/default/browserlayer.xml | 7 --- .../js/cycle2/profiles/default/jsregistry.xml | 12 ---- .../js/cycle2/profiles/default/metadata.xml | 2 +- .../resources/jquery.cycle2.caption2.min.js | 2 + .../resources/jquery.cycle2.carousel.min.js | 2 + .../jquery.cycle2.center.js | 0 .../jquery.cycle2.center.min.js | 0 .../resources/jquery.cycle2.flip.min.js | 2 + .../resources/jquery.cycle2.ie-fade.min.js | 2 + .../{static => resources}/jquery.cycle2.js | 0 .../jquery.cycle2.min.js | 0 .../resources/jquery.cycle2.scrollVert.min.js | 2 + .../resources/jquery.cycle2.shuffle.min.js | 2 + .../jquery.cycle2.swipe.js | 0 .../jquery.cycle2.swipe.min.js | 0 .../resources/jquery.cycle2.tile.min.js | 2 + .../resources/jquery.cycle2.video.min.js | 2 + src/collective/js/cycle2/testing.py | 29 ---------- src/collective/js/cycle2/tests/__init__.py | 0 src/collective/js/cycle2/tests/test_setup.py | 55 ------------------- src/collective/js/cycle2/upgrades/__init__.py | 28 ++++++++++ .../js/cycle2/upgrades/configure.zcml | 30 ++++++++++ .../profiles/default/browserlayer.xml | 6 ++ .../upgrades/profiles/default/metadata.xml | 4 ++ 26 files changed, 98 insertions(+), 108 deletions(-) delete mode 100644 src/collective/js/cycle2/profiles/default/browserlayer.xml delete mode 100644 src/collective/js/cycle2/profiles/default/jsregistry.xml create mode 100644 src/collective/js/cycle2/resources/jquery.cycle2.caption2.min.js create mode 100644 src/collective/js/cycle2/resources/jquery.cycle2.carousel.min.js rename src/collective/js/cycle2/{static => resources}/jquery.cycle2.center.js (100%) rename src/collective/js/cycle2/{static => resources}/jquery.cycle2.center.min.js (100%) create mode 100644 src/collective/js/cycle2/resources/jquery.cycle2.flip.min.js create mode 100644 src/collective/js/cycle2/resources/jquery.cycle2.ie-fade.min.js rename src/collective/js/cycle2/{static => resources}/jquery.cycle2.js (100%) rename src/collective/js/cycle2/{static => resources}/jquery.cycle2.min.js (100%) create mode 100644 src/collective/js/cycle2/resources/jquery.cycle2.scrollVert.min.js create mode 100644 src/collective/js/cycle2/resources/jquery.cycle2.shuffle.min.js rename src/collective/js/cycle2/{static => resources}/jquery.cycle2.swipe.js (100%) rename src/collective/js/cycle2/{static => resources}/jquery.cycle2.swipe.min.js (100%) create mode 100644 src/collective/js/cycle2/resources/jquery.cycle2.tile.min.js create mode 100644 src/collective/js/cycle2/resources/jquery.cycle2.video.min.js delete mode 100644 src/collective/js/cycle2/testing.py delete mode 100644 src/collective/js/cycle2/tests/__init__.py delete mode 100644 src/collective/js/cycle2/tests/test_setup.py create mode 100644 src/collective/js/cycle2/upgrades/__init__.py create mode 100644 src/collective/js/cycle2/upgrades/configure.zcml create mode 100644 src/collective/js/cycle2/upgrades/profiles/default/browserlayer.xml create mode 100644 src/collective/js/cycle2/upgrades/profiles/default/metadata.xml diff --git a/CHANGES.rst b/CHANGES.rst index 04c8d56..7b8a0d9 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -6,10 +6,13 @@ There's a frood who really knows where his towel is. 1.0a2 (unreleased) ------------------ -- Nothing changed yet. +- Remove profile (unregister resources) and add extra javascript files from cyle2. (closes `#1`_) + [rodfersou] 1.0a1 (2014-10-20) ------------------ - Initial release. + +.. _`#1`: https://github.com/collective/collective.js.cycle2/issues/1 diff --git a/src/collective/js/cycle2/configure.zcml b/src/collective/js/cycle2/configure.zcml index 4e18b19..06fac0a 100644 --- a/src/collective/js/cycle2/configure.zcml +++ b/src/collective/js/cycle2/configure.zcml @@ -2,12 +2,13 @@ xmlns="http://namespaces.zope.org/zope" xmlns:browser="http://namespaces.zope.org/browser" xmlns:five="http://namespaces.zope.org/five" - xmlns:genericsetup="http://namespaces.zope.org/genericsetup" + xmlns:gs="http://namespaces.zope.org/genericsetup" i18n_domain="collective.js.cycle2"> - + - + + + diff --git a/src/collective/js/cycle2/profiles/default/browserlayer.xml b/src/collective/js/cycle2/profiles/default/browserlayer.xml deleted file mode 100644 index 38f6f8f..0000000 --- a/src/collective/js/cycle2/profiles/default/browserlayer.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - diff --git a/src/collective/js/cycle2/profiles/default/jsregistry.xml b/src/collective/js/cycle2/profiles/default/jsregistry.xml deleted file mode 100644 index a2bb3e0..0000000 --- a/src/collective/js/cycle2/profiles/default/jsregistry.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - diff --git a/src/collective/js/cycle2/profiles/default/metadata.xml b/src/collective/js/cycle2/profiles/default/metadata.xml index b22370d..3c0f850 100644 --- a/src/collective/js/cycle2/profiles/default/metadata.xml +++ b/src/collective/js/cycle2/profiles/default/metadata.xml @@ -1,4 +1,4 @@ - 1000 + 1001 diff --git a/src/collective/js/cycle2/resources/jquery.cycle2.caption2.min.js b/src/collective/js/cycle2/resources/jquery.cycle2.caption2.min.js new file mode 100644 index 0000000..72292e0 --- /dev/null +++ b/src/collective/js/cycle2/resources/jquery.cycle2.caption2.min.js @@ -0,0 +1,2 @@ +/* Plugin for Cycle2; Copyright (c) 2012 M. Alsup; v20141007 */ +!function(a){"use strict";function b(b,c,d,e){"caption2"===c.captionPlugin&&a.each(["caption","overlay"],function(){var a,b=this+"Fx",f=c[b+"Out"]||"hide",g=d[this+"Template"],h=c.API.getComponent(this),i=c[b+"Sel"],j=c.speed;c.sync&&(j/=2),a=i?h.find(i):h,h.length&&g?("hide"==f&&(j=0),a[f](j,function(){var k=c.API.tmpl(g,d,c,e);h.html(k),a=i?h.find(i):h,i&&a.hide(),f=c[b+"In"]||"show",a[f](j)})):h.hide()})}function c(b,c,d,e){"caption2"===c.captionPlugin&&a.each(["caption","overlay"],function(){var a=d[this+"Template"],b=c.API.getComponent(this);b.length&&a&&b.html(c.API.tmpl(a,d,c,e))})}a.extend(a.fn.cycle.defaults,{captionFxOut:"fadeOut",captionFxIn:"fadeIn",captionFxSel:void 0,overlayFxOut:"fadeOut",overlayFxIn:"fadeIn",overlayFxSel:void 0}),a(document).on("cycle-bootstrap",function(a,d){d.container.on("cycle-update-view-before",b),d.container.one("cycle-update-view-after",c)})}(jQuery); \ No newline at end of file diff --git a/src/collective/js/cycle2/resources/jquery.cycle2.carousel.min.js b/src/collective/js/cycle2/resources/jquery.cycle2.carousel.min.js new file mode 100644 index 0000000..8a287f0 --- /dev/null +++ b/src/collective/js/cycle2/resources/jquery.cycle2.carousel.min.js @@ -0,0 +1,2 @@ +/* Plugin for Cycle2; Copyright (c) 2012 M. Alsup; v20141007 */ +!function(a){"use strict";a(document).on("cycle-bootstrap",function(a,b,c){"carousel"===b.fx&&(c.getSlideIndex=function(a){var b=this.opts()._carouselWrap.children(),c=b.index(a);return c%b.length},c.next=function(){var a=b.reverse?-1:1;b.allowWrap===!1&&b.currSlide+a>b.slideCount-b.carouselVisible||(b.API.advanceSlide(a),b.API.trigger("cycle-next",[b]).log("cycle-next"))})}),a.fn.cycle.transitions.carousel={preInit:function(b){b.hideNonActive=!1,b.container.on("cycle-destroyed",a.proxy(this.onDestroy,b.API)),b.API.stopTransition=this.stopTransition;for(var c=0;cb.slideCount&&(b.carouselVisible=b.slideCount-1);var h=b.carouselVisible||b.slides.length,i={display:g?"block":"inline-block",position:"static"};if(b.container.css({position:"relative",overflow:"hidden"}),b.slides.css(i),b._currSlide=b.currSlide,f=a('').prependTo(b.container).css({margin:0,padding:0,top:0,left:0,position:"absolute"}).append(b.slides),b._carouselWrap=f,g||f.css("white-space","nowrap"),b.allowWrap!==!1){for(d=0;d<(void 0===b.carouselVisible?2:1);d++){for(c=0;c0;var l=b._currSlide,m=b.slideCount-b.carouselVisible;i>0&&b.nextSlide>m&&l==m?i=0:i>0&&b.nextSlide>m?i=b.nextSlide-l-(b.nextSlide-m):0>i&&b.currSlide>m&&b.nextSlide>m?i=0:0>i&&b.currSlide>m?i+=b.currSlide-m:l=b.currSlide,g=this.getScroll(b,j,l,i),b.API.opts()._currSlide=b.nextSlide>m?m:b.nextSlide}else e&&0===b.nextSlide?(g=this.getDim(b,b.currSlide,j),f=this.genCallback(b,e,j,f)):e||b.nextSlide!=b.slideCount-1?g=this.getScroll(b,j,b.currSlide,i):(g=this.getDim(b,b.currSlide,j),f=this.genCallback(b,e,j,f));h[j?"top":"left"]=e?"-="+g:"+="+g,b.throttleSpeed&&(k=g/a(b.slides[0])[j?"height":"width"]()*b.speed),b._carouselWrap.animate(h,k,b.easing,f)},getDim:function(b,c,d){var e=a(b.slides[c]);return e[d?"outerHeight":"outerWidth"](!0)},getScroll:function(a,b,c,d){var e,f=0;if(d>0)for(e=c;c+d>e;e++)f+=this.getDim(a,e,b);else for(e=c;e>c+d;e--)f+=this.getDim(a,e,b);return f},genCallback:function(b,c,d,e){return function(){var c=a(b.slides[b.nextSlide]).position(),f=0-c[d?"top":"left"]+(b.carouselOffset||0);b._carouselWrap.css(b.carouselVertical?"top":"left",f),e()}},stopTransition:function(){var a=this.opts();a.slides.stop(!1,!0),a._carouselWrap.stop(!1,!0)},onDestroy:function(){var b=this.opts();b._carouselResizeThrottle&&a(window).off("resize",b._carouselResizeThrottle),b.slides.prependTo(b.container),b._carouselWrap.remove()}}}(jQuery); \ No newline at end of file diff --git a/src/collective/js/cycle2/static/jquery.cycle2.center.js b/src/collective/js/cycle2/resources/jquery.cycle2.center.js similarity index 100% rename from src/collective/js/cycle2/static/jquery.cycle2.center.js rename to src/collective/js/cycle2/resources/jquery.cycle2.center.js diff --git a/src/collective/js/cycle2/static/jquery.cycle2.center.min.js b/src/collective/js/cycle2/resources/jquery.cycle2.center.min.js similarity index 100% rename from src/collective/js/cycle2/static/jquery.cycle2.center.min.js rename to src/collective/js/cycle2/resources/jquery.cycle2.center.min.js diff --git a/src/collective/js/cycle2/resources/jquery.cycle2.flip.min.js b/src/collective/js/cycle2/resources/jquery.cycle2.flip.min.js new file mode 100644 index 0000000..aef8be3 --- /dev/null +++ b/src/collective/js/cycle2/resources/jquery.cycle2.flip.min.js @@ -0,0 +1,2 @@ +/* Plugin for Cycle2; Copyright (c) 2012 M. Alsup; v20141007 */ +!function(a){"use strict";function b(b){return{preInit:function(a){a.slides.css(d)},transition:function(c,d,e,f,g){var h=c,i=a(d),j=a(e),k=h.speed/2;b.call(j,-90),j.css({display:"block",visibility:"visible","background-position":"-90px",opacity:1}),i.css("background-position","0px"),i.animate({backgroundPosition:90},{step:b,duration:k,easing:h.easeOut||h.easing,complete:function(){c.API.updateView(!1,!0),j.animate({backgroundPosition:0},{step:b,duration:k,easing:h.easeIn||h.easing,complete:g})}})}}}function c(b){return function(c){var d=a(this);d.css({"-webkit-transform":"rotate"+b+"("+c+"deg)","-moz-transform":"rotate"+b+"("+c+"deg)","-ms-transform":"rotate"+b+"("+c+"deg)","-o-transform":"rotate"+b+"("+c+"deg)",transform:"rotate"+b+"("+c+"deg)"})}}var d,e=document.createElement("div").style,f=a.fn.cycle.transitions,g=void 0!==e.transform||void 0!==e.MozTransform||void 0!==e.webkitTransform||void 0!==e.oTransform||void 0!==e.msTransform;g&&void 0!==e.msTransform&&(e.msTransform="rotateY(0deg)",e.msTransform||(g=!1)),g?(f.flipHorz=b(c("Y")),f.flipVert=b(c("X")),d={"-webkit-backface-visibility":"hidden","-moz-backface-visibility":"hidden","-o-backface-visibility":"hidden","backface-visibility":"hidden"}):(f.flipHorz=f.scrollHorz,f.flipVert=f.scrollVert||f.scrollHorz)}(jQuery); \ No newline at end of file diff --git a/src/collective/js/cycle2/resources/jquery.cycle2.ie-fade.min.js b/src/collective/js/cycle2/resources/jquery.cycle2.ie-fade.min.js new file mode 100644 index 0000000..91532bd --- /dev/null +++ b/src/collective/js/cycle2/resources/jquery.cycle2.ie-fade.min.js @@ -0,0 +1,2 @@ +/* Plugin for Cycle2; Copyright (c) 2012 M. Alsup; v20141007 */ +!function(a){"use strict";function b(a,b,c){if(a&&c.style.filter){b._filter=c.style.filter;try{c.style.removeAttribute("filter")}catch(d){}}else!a&&b._filter&&(c.style.filter=b._filter)}a.extend(a.fn.cycle.transitions,{fade:{before:function(c,d,e,f){var g=c.API.getSlideOpts(c.nextSlide).slideCss||{};c.API.stackSlides(d,e,f),c.cssBefore=a.extend(g,{opacity:0,visibility:"visible",display:"block"}),c.animIn={opacity:1},c.animOut={opacity:0},b(!0,c,e)},after:function(a,c,d){b(!1,a,d)}},fadeout:{before:function(c,d,e,f){var g=c.API.getSlideOpts(c.nextSlide).slideCss||{};c.API.stackSlides(d,e,f),c.cssAfter=a.extend(g,{opacity:0,visibility:"hidden"}),c.cssBefore=a.extend(g,{opacity:1,visibility:"visible",display:"block"}),c.animOut={opacity:0},b(!0,c,e)},after:function(a,c,d){b(!1,a,d)}}})}(jQuery); \ No newline at end of file diff --git a/src/collective/js/cycle2/static/jquery.cycle2.js b/src/collective/js/cycle2/resources/jquery.cycle2.js similarity index 100% rename from src/collective/js/cycle2/static/jquery.cycle2.js rename to src/collective/js/cycle2/resources/jquery.cycle2.js diff --git a/src/collective/js/cycle2/static/jquery.cycle2.min.js b/src/collective/js/cycle2/resources/jquery.cycle2.min.js similarity index 100% rename from src/collective/js/cycle2/static/jquery.cycle2.min.js rename to src/collective/js/cycle2/resources/jquery.cycle2.min.js diff --git a/src/collective/js/cycle2/resources/jquery.cycle2.scrollVert.min.js b/src/collective/js/cycle2/resources/jquery.cycle2.scrollVert.min.js new file mode 100644 index 0000000..5ebb4a9 --- /dev/null +++ b/src/collective/js/cycle2/resources/jquery.cycle2.scrollVert.min.js @@ -0,0 +1,2 @@ +/* Plugin for Cycle2; Copyright (c) 2012 M. Alsup; v20141007 */ +!function(a){"use strict";a.fn.cycle.transitions.scrollVert={before:function(a,b,c,d){a.API.stackSlides(a,b,c,d);var e=a.container.css("overflow","hidden").height();a.cssBefore={top:d?-e:e,left:0,opacity:1,display:"block",visibility:"visible"},a.animIn={top:0},a.animOut={top:d?e:-e}}}}(jQuery); \ No newline at end of file diff --git a/src/collective/js/cycle2/resources/jquery.cycle2.shuffle.min.js b/src/collective/js/cycle2/resources/jquery.cycle2.shuffle.min.js new file mode 100644 index 0000000..5074db3 --- /dev/null +++ b/src/collective/js/cycle2/resources/jquery.cycle2.shuffle.min.js @@ -0,0 +1,2 @@ +/* Plugin for Cycle2; Copyright (c) 2012 M. Alsup; v20141007 */ +!function(a){"use strict";a.fn.cycle.transitions.shuffle={transition:function(b,c,d,e,f){function g(a){this.stack(b,c,d,e),a()}a(d).css({display:"block",visibility:"visible"});var h=b.container.css("overflow","visible").width(),i=b.speed/2,j=e?c:d;b=b.API.getSlideOpts(e?b.currSlide:b.nextSlide);var k={left:-h,top:15},l=b.slideCss||{left:0,top:0};void 0!==b.shuffleLeft?k.left=k.left+parseInt(b.shuffleLeft,10)||0:void 0!==b.shuffleRight&&(k.left=h+parseInt(b.shuffleRight,10)||0),b.shuffleTop&&(k.top=b.shuffleTop),a(j).animate(k,i,b.easeIn||b.easing).queue("fx",a.proxy(g,this)).animate(l,i,b.easeOut||b.easing,f)},stack:function(b,c,d,e){var f,g;if(e)b.API.stackSlides(d,c,e),a(c).css("zIndex",1);else{for(g=1,f=b.nextSlide-1;f>=0;f--)a(b.slides[f]).css("zIndex",g++);for(f=b.slideCount-1;f>b.nextSlide;f--)a(b.slides[f]).css("zIndex",g++);a(d).css("zIndex",b.maxZ),a(c).css("zIndex",b.maxZ-1)}}}}(jQuery); \ No newline at end of file diff --git a/src/collective/js/cycle2/static/jquery.cycle2.swipe.js b/src/collective/js/cycle2/resources/jquery.cycle2.swipe.js similarity index 100% rename from src/collective/js/cycle2/static/jquery.cycle2.swipe.js rename to src/collective/js/cycle2/resources/jquery.cycle2.swipe.js diff --git a/src/collective/js/cycle2/static/jquery.cycle2.swipe.min.js b/src/collective/js/cycle2/resources/jquery.cycle2.swipe.min.js similarity index 100% rename from src/collective/js/cycle2/static/jquery.cycle2.swipe.min.js rename to src/collective/js/cycle2/resources/jquery.cycle2.swipe.min.js diff --git a/src/collective/js/cycle2/resources/jquery.cycle2.tile.min.js b/src/collective/js/cycle2/resources/jquery.cycle2.tile.min.js new file mode 100644 index 0000000..4d59136 --- /dev/null +++ b/src/collective/js/cycle2/resources/jquery.cycle2.tile.min.js @@ -0,0 +1,2 @@ +/* Plugin for Cycle2; Copyright (c) 2012 M. Alsup; v20141007 */ +!function(a){"use strict";a.fn.cycle.transitions.tileSlide=a.fn.cycle.transitions.tileBlind={before:function(b,c,d,e){b.API.stackSlides(c,d,e),a(c).css({display:"block",visibility:"visible"}),b.container.css("overflow","hidden"),b.tileDelay=b.tileDelay||"tileSlide"==b.fx?100:125,b.tileCount=b.tileCount||7,b.tileVertical=b.tileVertical!==!1,b.container.data("cycleTileInitialized")||(b.container.on("cycle-destroyed",a.proxy(this.onDestroy,b.API)),b.container.data("cycleTileInitialized",!0))},transition:function(b,c,d,e,f){function g(a){m.eq(a).animate(t,{duration:b.speed,easing:b.easing,complete:function(){(e?p-1===a:0===a)&&b._tileAniCallback()}}),setTimeout(function(){(e?p-1!==a:0!==a)&&g(e?a+1:a-1)},b.tileDelay)}b.slides.not(c).not(d).css("visibility","hidden");var h,i,j,k,l,m=a(),n=a(c),o=a(d),p=b.tileCount,q=b.tileVertical,r=b.container.height(),s=b.container.width();q?(i=Math.floor(s/p),k=s-i*(p-1),j=l=r):(i=k=s,j=Math.floor(r/p),l=r-j*(p-1)),b.container.find(".cycle-tiles-container").remove();var t,u={left:0,top:0,overflow:"hidden",position:"absolute",margin:0,padding:0};t=q?"tileSlide"==b.fx?{top:r}:{width:0}:"tileSlide"==b.fx?{left:s}:{height:0};var v=a('
');v.css({zIndex:n.css("z-index"),overflow:"visible",position:"absolute",top:0,left:0,direction:"ltr"}),v.insertBefore(d);for(var w=0;p>w;w++)h=a("
").css(u).css({width:p-1===w?k:i,height:p-1===w?l:j,marginLeft:q?w*i:0,marginTop:q?0:w*j}).append(n.clone().css({position:"relative",maxWidth:"none",width:n.width(),margin:0,padding:0,marginLeft:q?-(w*i):0,marginTop:q?0:-(w*j)})),m=m.add(h);v.append(m),n.css("visibility","hidden"),o.css({opacity:1,display:"block",visibility:"visible"}),g(e?0:p-1),b._tileAniCallback=function(){o.css({display:"block",visibility:"visible"}),n.css("visibility","hidden"),v.remove(),f()}},stopTransition:function(a){a.container.find("*").stop(!0,!0),a._tileAniCallback&&a._tileAniCallback()},onDestroy:function(){var a=this.opts();a.container.find(".cycle-tiles-container").remove()}}}(jQuery); \ No newline at end of file diff --git a/src/collective/js/cycle2/resources/jquery.cycle2.video.min.js b/src/collective/js/cycle2/resources/jquery.cycle2.video.min.js new file mode 100644 index 0000000..1c415dc --- /dev/null +++ b/src/collective/js/cycle2/resources/jquery.cycle2.video.min.js @@ -0,0 +1,2 @@ +/* Plugin for Cycle2; Copyright (c) 2012 M. Alsup; v20141007 */ +!function(a){"use strict";function b(){try{this.playVideo()}catch(a){}}function c(){try{this.pauseVideo()}catch(a){}}var d='
';a.extend(a.fn.cycle.defaults,{youtubeAllowFullScreen:!0,youtubeAutostart:!1,youtubeAutostop:!0}),a(document).on("cycle-bootstrap",function(e,f){f.youtube&&(f.hideNonActive=!1,f.container.find(f.slides).each(function(b){if(void 0!==a(this).attr("href")){var c,e=a(this),g=e.attr("href"),h=f.youtubeAllowFullScreen?"true":"false";g+=(/\?/.test(g)?"&":"?")+"enablejsapi=1",f.youtubeAutostart&&f.startingSlide===b&&(g+="&autoplay=1"),c=f.API.tmpl(d,{url:g,allowFullScreen:h}),e.replaceWith(c)}}),f.slides=f.slides.replace(/(\b>?a\b)/,"div.cycle-youtube"),f.youtubeAutostart&&f.container.on("cycle-initialized cycle-after",function(c,d){var e="cycle-initialized"==c.type?d.currSlide:d.nextSlide;a(d.slides[e]).find("object,embed").each(b)}),f.youtubeAutostop&&f.container.on("cycle-before",function(b,d){a(d.slides[d.currSlide]).find("object,embed").each(c)}))})}(jQuery); \ No newline at end of file diff --git a/src/collective/js/cycle2/testing.py b/src/collective/js/cycle2/testing.py deleted file mode 100644 index 1d8321c..0000000 --- a/src/collective/js/cycle2/testing.py +++ /dev/null @@ -1,29 +0,0 @@ -# -*- coding: utf-8 -*- -from plone.app.testing import PloneSandboxLayer -from plone.app.testing import PLONE_FIXTURE -from plone.app.testing import IntegrationTesting -from plone.app.testing import FunctionalTesting - -from plone.testing.z2 import ZSERVER_FIXTURE - - -class Fixture(PloneSandboxLayer): - - defaultBases = (PLONE_FIXTURE,) - - def setUpZope(self, app, configurationContext): - import collective.js.cycle2 - self.loadZCML(package=collective.js.cycle2) - - def setUpPloneSite(self, portal): - self.applyProfile(portal, 'collective.js.cycle2:default') - -FIXTURE = Fixture() -INTEGRATION_TESTING = IntegrationTesting( - bases=(FIXTURE,), - name='collective.js.cycle2:Integration', -) -FUNCTIONAL_TESTING = FunctionalTesting( - bases=(FIXTURE, ZSERVER_FIXTURE), - name='collective.js.cycle2:Functional', -) diff --git a/src/collective/js/cycle2/tests/__init__.py b/src/collective/js/cycle2/tests/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/src/collective/js/cycle2/tests/test_setup.py b/src/collective/js/cycle2/tests/test_setup.py deleted file mode 100644 index cfdec62..0000000 --- a/src/collective/js/cycle2/tests/test_setup.py +++ /dev/null @@ -1,55 +0,0 @@ -# -*- coding: utf-8 -*- -from collective.js.cycle2.interfaces import IAddOnInstalled -from collective.js.cycle2.testing import INTEGRATION_TESTING -from plone.browserlayer.utils import registered_layers - -import unittest - -PROJECTNAME = 'collective.js.cycle2' - -JS = [ - '++resource++collective.js.cycle2/jquery.cycle2.min.js', - '++resource++collective.js.cycle2/jquery.cycle2.center.min.js', - '++resource++collective.js.cycle2/jquery.cycle2.swipe.min.js', -] - - -class InstallTestCase(unittest.TestCase): - - layer = INTEGRATION_TESTING - - def setUp(self): - self.portal = self.layer['portal'] - self.qi = self.portal['portal_quickinstaller'] - - def test_installed(self): - self.assertTrue(self.qi.isProductInstalled(PROJECTNAME)) - - def test_browser_layer_installed(self): - self.assertIn(IAddOnInstalled, registered_layers()) - - def test_jsregistry(self): - resource_ids = self.portal.portal_javascripts.getResourceIds() - for js in JS: - self.assertIn(js, resource_ids, js + ' not found on registry') - - -class UninstallTestCase(unittest.TestCase): - - layer = INTEGRATION_TESTING - - def setUp(self): - self.portal = self.layer['portal'] - self.qi = self.portal['portal_quickinstaller'] - self.qi.uninstallProducts(products=[PROJECTNAME]) - - def test_uninstalled(self): - self.assertFalse(self.qi.isProductInstalled(PROJECTNAME)) - - def test_browser_layer_removed(self): - self.assertNotIn(IAddOnInstalled, registered_layers()) - - def test_jsregistry_removed(self): - resource_ids = self.portal.portal_javascripts.getResourceIds() - for js in JS: - self.assertNotIn(js, resource_ids, js + ' found on registry') diff --git a/src/collective/js/cycle2/upgrades/__init__.py b/src/collective/js/cycle2/upgrades/__init__.py new file mode 100644 index 0000000..f61b2f4 --- /dev/null +++ b/src/collective/js/cycle2/upgrades/__init__.py @@ -0,0 +1,28 @@ +from plone.app.upgrade.utils import loadMigrationProfile +from zope.component.hooks import getSite + +import logging + + +logger = logging.getLogger('collective.js.cycle2') + + +def remove_profile(context): + """Profiles should not be mantained into JS packages""" + + profile = 'profile-collective.js.cycle2:default' + loadMigrationProfile(context, profile) + logger.info('Remove browser layer') + + site = getSite() + js_tool = site.portal_javascripts + ids_to_remove = [ + "++resource++collective.js.cycle2/jquery.cycle2.min.js", + "++resource++collective.js.cycle2/jquery.cycle2.center.min.js", + "++resource++collective.js.cycle2/jquery.cycle2.swipe.min.js" + ] + for js_id in ids_to_remove: + js_tool.unregisterResource(js_id) + logger.info('"{0}" resource was removed"'.format(js_id)) + js_tool.cookResources() + logger.info('JS resources were cooked') diff --git a/src/collective/js/cycle2/upgrades/configure.zcml b/src/collective/js/cycle2/upgrades/configure.zcml new file mode 100644 index 0000000..8cf4a11 --- /dev/null +++ b/src/collective/js/cycle2/upgrades/configure.zcml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + diff --git a/src/collective/js/cycle2/upgrades/profiles/default/browserlayer.xml b/src/collective/js/cycle2/upgrades/profiles/default/browserlayer.xml new file mode 100644 index 0000000..d241657 --- /dev/null +++ b/src/collective/js/cycle2/upgrades/profiles/default/browserlayer.xml @@ -0,0 +1,6 @@ + + + + diff --git a/src/collective/js/cycle2/upgrades/profiles/default/metadata.xml b/src/collective/js/cycle2/upgrades/profiles/default/metadata.xml new file mode 100644 index 0000000..3c0f850 --- /dev/null +++ b/src/collective/js/cycle2/upgrades/profiles/default/metadata.xml @@ -0,0 +1,4 @@ + + + 1001 +