[pollen] branch feature/createPreviewRessource created (now ed60d64)
This is an automated email from the git hooks/post-receive script. New change to branch feature/createPreviewRessource in repository pollen. See http://git.chorem.org/pollen.git at ed60d64 remove debug code This branch includes the following new commits: new 58fc68e resize picture for preview new d067e68 mapping accept name of ressource at the end of url new 590bf52 improve printResource new eefa9e6 add default preview if no image resource new ed60d64 remove debug code The 5 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit ed60d64a8be38ac8827e08970cb66d312d5c2324 Author: Adrien Garandel <a.garandel@dralagen.fr> Date: Tue Aug 12 18:35:17 2014 +0200 remove debug code commit eefa9e6a97ce948e992f99c3681b09b6f633a867 Author: Adrien Garandel <a.garandel@dralagen.fr> Date: Tue Aug 12 18:32:21 2014 +0200 add default preview if no image resource commit d067e6873f036a75f2994ff933ae4856c7513ed3 Author: Adrien Garandel <a.garandel@dralagen.fr> Date: Tue Aug 12 17:48:16 2014 +0200 mapping accept name of ressource at the end of url commit 590bf52169a854466da50924c122deb119ea566c Author: Adrien Garandel <a.garandel@dralagen.fr> Date: Tue Aug 12 17:49:15 2014 +0200 improve printResource commit 58fc68e808b675a30276298e507fdceef0bd10e0 Author: Adrien Garandel <a.garandel@dralagen.fr> Date: Tue Aug 12 17:47:22 2014 +0200 resize picture for preview -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/createPreviewRessource in repository pollen. See http://git.chorem.org/pollen.git commit 58fc68e808b675a30276298e507fdceef0bd10e0 Author: Adrien Garandel <a.garandel@dralagen.fr> Date: Tue Aug 12 17:47:22 2014 +0200 resize picture for preview --- .../pollen/rest/api/v1/PollenResourceApi.java | 42 ++++++++++++++++++++-- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollenResourceApi.java b/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollenResourceApi.java index 7db0f32..0b5f931 100644 --- a/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollenResourceApi.java +++ b/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollenResourceApi.java @@ -1,5 +1,6 @@ package org.chorem.pollen.rest.api.v1; +import org.apache.commons.io.IOUtils; import org.chorem.pollen.persistence.entity.PollenResource; import org.chorem.pollen.services.bean.*; import org.chorem.pollen.services.service.PollenResourceService; @@ -7,7 +8,13 @@ import org.debux.webmotion.server.WebMotionController; import org.debux.webmotion.server.call.UploadFile; import org.debux.webmotion.server.render.Render; -import java.io.FileNotFoundException; +import javax.imageio.ImageIO; +import javax.imageio.ImageReader; +import javax.imageio.stream.ImageInputStream; +import java.awt.*; +import java.awt.image.BufferedImage; +import java.io.*; +import java.util.Iterator; /** * Created on 10/07/14. @@ -23,11 +30,40 @@ public class PollenResourceApi extends WebMotionController { return renderStream(resource.getResourceContent(), resource.getContentType()); } - public Render getPreviewResource(PollenResourceService pollenResourceService, PollenEntityId<PollenResource> resourceId) { + public Render getPreviewResource(PollenResourceService pollenResourceService, PollenEntityId<PollenResource> resourceId) throws IOException { ResourceStreamBean resource = pollenResourceService.getResource(resourceId.getEntityId()); - return renderStream(resource.getResourceContent(), resource.getContentType()); + ImageInputStream iis = ImageIO.createImageInputStream(resource.getResourceContent()); + + Iterator<ImageReader> readers = ImageIO.getImageReaders(iis); + if (!readers.hasNext()) { + throw new IOException("Unreadable source. No format can be found."); + } + + ImageReader reader = readers.next(); + String format = reader.getFormatName(); + + BufferedImage source = ImageIO.read(iis); + + int width, height; + if (source.getWidth() > source.getHeight()) { + width = 200; + height = width * source.getHeight() / source.getWidth(); + } else { + height = 200; + width = height * source.getWidth() / source.getHeight(); + } + + BufferedImage destination = new BufferedImage(width, height, source.getType()); + Graphics2D g = destination.createGraphics(); + g.drawImage(source, 0, 0, width, height, null); + g.dispose(); + + ByteArrayOutputStream output = new ByteArrayOutputStream(); + ImageIO.write(destination, format, output); + + return renderStream(new ByteArrayInputStream(output.toByteArray()), resource.getContentType()); } public ResourceMetaBean getMetaResource(PollenResourceService pollenResourceService, PollenEntityId<PollenResource> resourceId) { -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/createPreviewRessource in repository pollen. See http://git.chorem.org/pollen.git commit d067e6873f036a75f2994ff933ae4856c7513ed3 Author: Adrien Garandel <a.garandel@dralagen.fr> Date: Tue Aug 12 17:48:16 2014 +0200 mapping accept name of ressource at the end of url --- pollen-rest-api/src/main/resources/mapping | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pollen-rest-api/src/main/resources/mapping b/pollen-rest-api/src/main/resources/mapping index f219150..d0dbfd1 100644 --- a/pollen-rest-api/src/main/resources/mapping +++ b/pollen-rest-api/src/main/resources/mapping @@ -123,6 +123,10 @@ POST /v1/resources PollenResourceApi.createResou POST /v1/resources/{resourceId} PollenResourceApi.editResource DELETE /v1/resources/{resourceId} PollenResourceApi.deleteResource +GET /v1/resources/{resourceId}/meta/{n} forward:/v1/resources/{resourceId}/meta +GET /v1/resources/{resourceId}/preview/{n} forward:/v1/resources/{resourceId}/preview +GET /v1/resources/{resourceId}/{n} forward:/v1/resources/{resourceId} + # PollenUserApi GET /v1/users PollenUserApi.getUsers -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/createPreviewRessource in repository pollen. See http://git.chorem.org/pollen.git commit 590bf52169a854466da50924c122deb119ea566c Author: Adrien Garandel <a.garandel@dralagen.fr> Date: Tue Aug 12 17:49:15 2014 +0200 improve printResource --- pollen-ui-angular/src/main/webapp/js/directives.js | 29 ++++++++++++++++++-- pollen-ui-angular/src/main/webapp/less/style.less | 32 +++++----------------- .../src/main/webapp/partials/inline-poll.html | 2 +- .../src/main/webapp/partials/printResource.html | 7 +++-- 4 files changed, 38 insertions(+), 32 deletions(-) diff --git a/pollen-ui-angular/src/main/webapp/js/directives.js b/pollen-ui-angular/src/main/webapp/js/directives.js index 8d32590..b123ee1 100644 --- a/pollen-ui-angular/src/main/webapp/js/directives.js +++ b/pollen-ui-angular/src/main/webapp/js/directives.js @@ -460,12 +460,12 @@ angular.module('pollenDirective', []) ///// PRINT RESOURCE ///// ////////////////////////////////////// -.directive("printResource", ['$timeout', function ($timeout) { +.directive("printResource", ['$timeout', '$http', function ($timeout, $http) { return { restrict : "E", scope : { image : "=", - name : "=" + meta : "=" }, transclude : true, templateUrl : "partials/printResource.html", @@ -477,6 +477,15 @@ angular.module('pollenDirective', []) if (angular.isDefined(newVal)) { scope.resourceURL = conf.restURL+"/resources/"+scope.image; scope.previewURL = scope.resourceURL+"/preview"; + + if (scope.meta.hasOwnProperty("name")) { + scope.resourceURL += "/" + scope.meta.name; + scope.previewURL += "/" + scope.meta.name; + } + + console.log(scope.meta.type); + scope.isImage = isImage(scope.meta.type); + $(element).find('div').spin(false); } else { @@ -497,8 +506,22 @@ angular.module('pollenDirective', []) }); }; + var isImage = function (type) { + var allTypeAccepted = ["image/jpeg", "image/png", "image/gif"]; + + for (var i in allTypeAccepted) { + console.log(allTypeAccepted[i]); + if (allTypeAccepted[i] == type) { + return true; + } + } + return false; + }; + element.bind("click", function () { - toggleZoom(); + if (scope.isImage) { + toggleZoom(); + } }); } } diff --git a/pollen-ui-angular/src/main/webapp/less/style.less b/pollen-ui-angular/src/main/webapp/less/style.less index d2ced80..bef8bdf 100644 --- a/pollen-ui-angular/src/main/webapp/less/style.less +++ b/pollen-ui-angular/src/main/webapp/less/style.less @@ -55,9 +55,7 @@ body { } .navbar .dropdown-menu { - padding: 0; - padding-top: 15px; - padding-bottom: 5px; + padding: 15px 0 5px; left:auto; right:0px; @@ -302,8 +300,7 @@ body { text-align:center; table { - margin:auto; - margin-bottom:8px; + margin: auto auto 8px; } #poll-inline { @@ -362,10 +359,7 @@ body { .pollChoice { min-width:150px; - padding-left:5px; - padding-right:5px; - padding-top:10px; - padding-bottom:5px; + padding: 10px 5px 5px; text-align:center; border:1px solid @border-color; @@ -457,10 +451,7 @@ a { td { border-bottom:1px solid @border-color; - padding-top:5px; - padding-bottom:15px; - padding-left:5px; - padding-right:5px; + padding: 5px 5px 15px; vertical-align:top; } @@ -486,10 +477,7 @@ a { border:3px solid @border-color; tr th, tr td { - padding-top:8px; - padding-bottom:8px; - padding-left:5px; - padding-right:5px; + padding: 8px 5px; border:1px solid @border-color; &.weight { @@ -511,10 +499,7 @@ label.label-block { } .table-result { - margin-left: auto; - margin-right: auto; - margin-top:5px; - margin-bottom:15px; + margin: 5px auto 15px; tr { td, th { @@ -586,10 +571,7 @@ footer { display:inline-block; max-width:100%; max-height:100%; - margin-top:1.25%; - margin-bottom:0px; - margin-left:1.25%; - margin-right:1.25%; + margin: 1.25% 1.25% 0px; padding:8px; background-color:@border-color; border-radius:8px; diff --git a/pollen-ui-angular/src/main/webapp/partials/inline-poll.html b/pollen-ui-angular/src/main/webapp/partials/inline-poll.html index 1da8c67..e8b6da4 100644 --- a/pollen-ui-angular/src/main/webapp/partials/inline-poll.html +++ b/pollen-ui-angular/src/main/webapp/partials/inline-poll.html @@ -53,7 +53,7 @@ <info-error error="choice.restError.choiceValue[0]" data="choice.choiceValue"></info-error> <input type="button" class="btn btn-default" ng-if="data.poll.choiceAddAllowed && (choice.permission || !choice.id) || globalVariables.editMode" ng-show="showEditHover" ng-click="editChoice(choice, $event);" value="..."/> <br/> - <print-resource image="choice.choiceValue.id" name="choice.choiceValue.meta.name"></print-resource> + <print-resource image="choice.choiceValue.id" meta="choice.choiceValue.meta"></print-resource> </div> diff --git a/pollen-ui-angular/src/main/webapp/partials/printResource.html b/pollen-ui-angular/src/main/webapp/partials/printResource.html index 810e708..875f8d1 100644 --- a/pollen-ui-angular/src/main/webapp/partials/printResource.html +++ b/pollen-ui-angular/src/main/webapp/partials/printResource.html @@ -1,7 +1,8 @@ -<div class="preview"><img ng-attr-src="{{previewURL}}" /></div> -<div ng-show="showImage" class="full"> +<div class="preview" ng-if="isImage"><img ng-attr-src="{{previewURL}}" /></div> +<div class="preview" ng-if="!isImage"><a ng-attr-href="{{resourceURL}}"><img ng-attr-src="{{previewURL}}" /></a></div> +<div ng-if="showImage && isImage" class="full"> <div class="full-content"> - <span>{{name}}</span> + <span>{{meta.name}}</span> <img ng-attr-src="{{resourceURL}}" /> </div> </div> \ No newline at end of file -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/createPreviewRessource in repository pollen. See http://git.chorem.org/pollen.git commit eefa9e6a97ce948e992f99c3681b09b6f633a867 Author: Adrien Garandel <a.garandel@dralagen.fr> Date: Tue Aug 12 18:32:21 2014 +0200 add default preview if no image resource --- pollen-rest-api/pom.xml | 1 + .../org/chorem/pollen/rest/api/v1/PollenResourceApi.java | 13 ++++++++++--- pollen-rest-api/src/main/resources/default.jpg | Bin 0 -> 8374 bytes 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/pollen-rest-api/pom.xml b/pollen-rest-api/pom.xml index af88551..8ec1831 100644 --- a/pollen-rest-api/pom.xml +++ b/pollen-rest-api/pom.xml @@ -204,6 +204,7 @@ <includes> <include>**/mapping</include> <include>**/*.properties</include> + <include>**/*.jpg</include> </includes> <filtering>true</filtering> </resource> diff --git a/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollenResourceApi.java b/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollenResourceApi.java index 0b5f931..44cde35 100644 --- a/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollenResourceApi.java +++ b/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollenResourceApi.java @@ -1,5 +1,6 @@ package org.chorem.pollen.rest.api.v1; +import com.sun.corba.se.spi.orbutil.fsm.Input; import org.apache.commons.io.IOUtils; import org.chorem.pollen.persistence.entity.PollenResource; import org.chorem.pollen.services.bean.*; @@ -38,9 +39,15 @@ public class PollenResourceApi extends WebMotionController { Iterator<ImageReader> readers = ImageIO.getImageReaders(iis); if (!readers.hasNext()) { - throw new IOException("Unreadable source. No format can be found."); + InputStream defaultFile = PollenResourceApi.class.getResourceAsStream("/default.jpg"); + + iis = ImageIO.createImageInputStream(new ByteArrayInputStream( + IOUtils.toByteArray(defaultFile))); + readers = ImageIO.getImageReaders(iis); + if (!readers.hasNext()) { + throw new IOException("Unreadable source. No format can be found."); + } } - ImageReader reader = readers.next(); String format = reader.getFormatName(); @@ -63,7 +70,7 @@ public class PollenResourceApi extends WebMotionController { ByteArrayOutputStream output = new ByteArrayOutputStream(); ImageIO.write(destination, format, output); - return renderStream(new ByteArrayInputStream(output.toByteArray()), resource.getContentType()); + return renderStream(new ByteArrayInputStream(output.toByteArray()), format); } public ResourceMetaBean getMetaResource(PollenResourceService pollenResourceService, PollenEntityId<PollenResource> resourceId) { diff --git a/pollen-rest-api/src/main/resources/default.jpg b/pollen-rest-api/src/main/resources/default.jpg new file mode 100644 index 0000000..60aaa5d Binary files /dev/null and b/pollen-rest-api/src/main/resources/default.jpg differ -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/createPreviewRessource in repository pollen. See http://git.chorem.org/pollen.git commit ed60d64a8be38ac8827e08970cb66d312d5c2324 Author: Adrien Garandel <a.garandel@dralagen.fr> Date: Tue Aug 12 18:35:17 2014 +0200 remove debug code --- pollen-ui-angular/src/main/webapp/js/directives.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/pollen-ui-angular/src/main/webapp/js/directives.js b/pollen-ui-angular/src/main/webapp/js/directives.js index b123ee1..34e8fdd 100644 --- a/pollen-ui-angular/src/main/webapp/js/directives.js +++ b/pollen-ui-angular/src/main/webapp/js/directives.js @@ -483,7 +483,6 @@ angular.module('pollenDirective', []) scope.previewURL += "/" + scope.meta.name; } - console.log(scope.meta.type); scope.isImage = isImage(scope.meta.type); $(element).find('div').spin(false); @@ -510,7 +509,6 @@ angular.module('pollenDirective', []) var allTypeAccepted = ["image/jpeg", "image/png", "image/gif"]; for (var i in allTypeAccepted) { - console.log(allTypeAccepted[i]); if (allTypeAccepted[i] == type) { return true; } -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
participants (1)
-
chorem.org scm