diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..caedb30 --- /dev/null +++ b/.gitignore @@ -0,0 +1,42 @@ +# +# Default excludes +# + +# Binaries +*.7z +*.dmg +*.gz +*.iso +*.jar +*.rar +*.tar +*.zip +*.war +*.ear +*.sar +*.class + +# Maven +target/ +pom.xml.tag +pom.xml.releaseBackup +pom.xml.versionsBackup +release.properties + +# IntelliJ project files +*.iml +*.iws +*.ipr +.idea/ + +# eclipse project file +.settings/ +.classpath +.project + +# OS +.DS_Store + +# Misc +*.swp +transaction.log diff --git a/tutorial-juzcret/pom.xml b/tutorial-juzcret/pom.xml index a3b7f08..cbf0416 100644 --- a/tutorial-juzcret/pom.xml +++ b/tutorial-juzcret/pom.xml @@ -17,7 +17,6 @@ - org.juzu @@ -29,6 +28,23 @@ juzu-plugins-servlet 1.0.0-cr1 + + org.juzu + juzu-plugins-less4j + 1.0.0-cr1 + + + org.exoplatform.kernel + exo.kernel.container + 2.4.x-SNAPSHOT + provided + + + servlet-api + javax.servlet + + + @@ -83,16 +99,32 @@ - tutorial-juzcret - - - - - - - - + tutorial-juzcret + + + + org.codehaus.gmaven + gmaven-plugin + 1.5 + + + + compile + + + + + ${project.build.outputDirectory} + + **/*.groovy + + + + + + + + - diff --git a/tutorial-juzcret/src/main/java/org/exoplatform/commons/juzu/KernelProviderFactory.java b/tutorial-juzcret/src/main/java/org/exoplatform/commons/juzu/KernelProviderFactory.java new file mode 100644 index 0000000..5ba9bc2 --- /dev/null +++ b/tutorial-juzcret/src/main/java/org/exoplatform/commons/juzu/KernelProviderFactory.java @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2012 eXo Platform SAS. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.exoplatform.commons.juzu; + +import javax.inject.Provider; +import juzu.inject.ProviderFactory; +import org.exoplatform.container.PortalContainer; +import org.picocontainer.ComponentAdapter; + +/** + * Provides kernel services in Juzu application. + * + * @author Frederic Drouet + */ +public class KernelProviderFactory implements ProviderFactory { + + @Override + public Provider getProvider(final Class implementationType) throws Exception { + final PortalContainer container = PortalContainer.getInstance(); + if (container == null) { + throw new IllegalStateException("Not running in the context of a portal container"); + } + final ComponentAdapter adapter = container.getComponentAdapterOfType(implementationType); + if (adapter != null) { + return new Provider() { + @Override + public T get() { + Object service = adapter.getComponentInstance(container); + if (service == null) { + throw new RuntimeException("Could not obtain service " + implementationType + " from container " + container); + } + return implementationType.cast(service); + } + }; + } else { + return null; + } + } +} \ No newline at end of file diff --git a/tutorial-juzcret/src/main/java/org/juzu/tutorial/JuZcretApplication.java b/tutorial-juzcret/src/main/java/org/juzu/tutorial/JuZcretApplication.java new file mode 100644 index 0000000..ff3cffc --- /dev/null +++ b/tutorial-juzcret/src/main/java/org/juzu/tutorial/JuZcretApplication.java @@ -0,0 +1,56 @@ +/* + * Copyright 2013 eXo Platform SAS + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.juzu.tutorial; + +import javax.inject.Inject; + +import juzu.Action; +import juzu.Path; +import juzu.Response; +import juzu.View; + +import org.juzu.tutorial.services.SecretService; + +public class JuZcretApplication { + + @Inject + SecretService secretService; + + @Inject + @Path("secretWall.gtmpl") + org.juzu.tutorial.templates.secretWall secretWall; + + @Inject + @Path("addSecret.gtmpl") + org.juzu.tutorial.templates.addSecret addSecret; + + @View + public Response.Content index() { + return secretWall.with().secretsList(secretService.getSecrets()).ok(); + } + + @View + public Response.Content addSecretForm() { + return addSecret.ok(); + } + + @Action + public Response.View addSecret(String msg, String imgURL) { + secretService.addSecret(msg, imgURL); + return JuZcretApplication_.index(); + } +} diff --git a/tutorial-juzcret/src/main/java/org/juzu/tutorial/assets/css/juzcret.less b/tutorial-juzcret/src/main/java/org/juzu/tutorial/assets/css/juzcret.less new file mode 100644 index 0000000..cbca049 --- /dev/null +++ b/tutorial-juzcret/src/main/java/org/juzu/tutorial/assets/css/juzcret.less @@ -0,0 +1,306 @@ +// Variables +//======================================= +@heightSecretItem: 238px; +@secretItemGutter: 6px; +@secretActionHeight: 43px; + +// Mixins +//======================================= + +// Opacity +.opacity(@opacity) { + opacity: @opacity; + // IE8 filter + @opacity-ie: (@opacity * 100); + filter: ~"alpha(opacity=@{opacity-ie})"; +} +// Border Radius CSS3 +.border-radius(@border-radius) { + -webkit-border-radius: @border-radius; + -moz-border-radius: @border-radius; + -ms-border-radius: @border-radius; // IE9 only + border-radius: @border-radius; +} +// Transform CSS3 +.transform(@transform) { + -webkit-transform: @transform; + -moz-transform: @transform; + -ms-transform: @transform; // IE9 only + transform: @transform; +} +// Transitions CSS3 +.transition(@transition) { + -webkit-transition: @transition; + -o-transition: @transition; + transition: @transition; +} +// Translate CSS +.translate(@x; @y) { + -webkit-transform: translate(@x, @y); + -ms-transform: translate(@x, @y); // IE9 only + -o-transform: translate(@x, @y); + transform: translate(@x, @y); +} + +// Common Style +//======================================= +.secret-wall-container { + padding: 20px 30px; + .btn-primary { + padding-right: 20px; + padding-left: 20px; + } +} +.secret-wall-container, .secret-wall-container * { + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; +} +.secret-wall-heading { + margin-bottom: 10px; + .btn { + margin-top: 6px; + } +} +.secret-wall-list { + margin: 0 -@secretItemGutter; + > li { + float: left; + padding: @secretItemGutter; + width: 100% / 3; + .secret-image { + background-repeat: no-repeat; + background-size: cover; + background-color: #000; + position: relative; + height: @heightSecretItem; + width: 100%; + display: block; + &:before { + background: none repeat scroll 0 0 rgba(0, 0, 0, 0.5); + content: ""; + display: block; + height: 100%; + position: absolute; + width: 100%; + } + } + .secret-mesage { + bottom: 65px; + color: #fff; + font-size: 20px; + font-weight: normal; + left: 25px; + line-height: 24px; + position: absolute; + right: 25px; + text-align: center; + top: 25px; + } + .secret-action { + border-top: 1px solid rgba(255, 255, 255, 0.5); + bottom: 0; + height: 0; + left: 0; + line-height: @secretActionHeight; + padding: 0 25px; + position: absolute; + right: 0; + text-align: right; + overflow: hidden; + .transition(all 200ms ease-out 0s); + + .secr-toggle-link { + + .secr-toggle-link { + margin-left: 15px; + } + > i { + margin-right: 5px; + } + .numb { + color: #fff; + font-size: 13px; + } + .uiIconComment { + margin-top: 2px; + } + } + } + .popover { + max-width: 500px; + top: auto; + bottom: 46px; + left: auto; + right: -205px; + width: 500px; + margin: 0px; + .close { + line-height: 16px; + padding: 1px 5px; + position: absolute; + right: 0; + top: 0; + } + .media { + > .pull-left { + > img { + width: 36px; + height: 36px; + .border-radius(2px); + } + } + } + } + &:hover, &.open-popover { + .secret-action { + height: @secretActionHeight; + } + } + &.open-popover { + .popover-secret { + .opacity(1); + display: block; + } + } + &:nth-child(3n+3) { + .popover{ + right: -1px; + .arrow { + left: auto; + right: 34px; + } + } + } + } +} +.secret-popup { + width: 500; + height: 280px; + background: #fff; + border: 1px solid rgba(0, 0, 0, 0.5); + display: none; + &.in { + display: block; + } +} +.popover-secret { + .popover-content { + padding: 15px; + } +} +.secr-comments-box { + .secr-viewall { + font-size: 13px; + margin-bottom: 15px; + } +} +.secr-comments-list { + margin-bottom: 20px; + max-height: 150px; + overflow: auto; + > li { + line-height: 18px; + + li { + margin-top: 20px; + } + .media { + > .pull-left { + display: block; + } + } + .cm-user-name { + font-weight: bold; + } + .cm-time { + color: #999999; + font-size: 12px; + margin-left: 5px; + } + } +} +.secr-create-comment { + .btn-primary { + float: right; + margin-left: 10px; + margin-top: 3px; + } + .secr-write-comment { + .fluid-colum { + float: left; + width: 100%; + > .inner { + margin-left: 46px; + } + } + .media { + > .media-body { + margin-left: 46px; + padding-top: 3px; + } + } + textarea { + height: 29px; + resize: none; + width: 100%; + &:focus { + box-shadow:none; + } + } + } +} +.share-secret-form { + .form-title { + margin: 0 0 10px; + text-shadow: none; + } + textarea { + min-width: 271px; + max-width: 271px; + max-height: 300px; + margin-bottom: 10px; + min-height: 80px; + } + textarea, input { + margin-bottom: 5px; + } +} +.dropdown.share-secret-dropdown { + .dropdown-menu { + left: auto; + margin-top: 20px; + right: -1px; + text-align: left; + &:after, &:before { + content: ""; + position: absolute; + bottom: 100%; + } + &:before { + border-left: 15px solid transparent; + border-right: 15px solid transparent; + border-bottom: 15px solid rgba(0, 0, 0, 0.2); + right: 45px; + } + &:after { + border-left: 14px solid transparent; + border-right: 14px solid transparent; + border-bottom: 14px solid #fff; + right: 46px; + } + } + .share-secret-form { + padding: 20px 30px; + } +} + +.share-secret-box { + display: inline-block; + text-align: left; + margin-top: 20px; + .title { + text-align: center; + } + .btn { + min-width: 78px; + } +} \ No newline at end of file diff --git a/tutorial-juzcret/src/main/java/org/juzu/tutorial/models/Secret.java b/tutorial-juzcret/src/main/java/org/juzu/tutorial/models/Secret.java new file mode 100644 index 0000000..2570783 --- /dev/null +++ b/tutorial-juzcret/src/main/java/org/juzu/tutorial/models/Secret.java @@ -0,0 +1,57 @@ +/* + * Copyright 2013 eXo Platform SAS + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.juzu.tutorial.models; + +import java.io.Serializable; +import java.util.Date; + +public class Secret implements Serializable { + + private static final long serialVersionUID = 9216333356065206889L; + + private String message; + + private String imageURL; + + private Date createdDate; + + public Secret() { + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public String getImageURL() { + return imageURL; + } + + public void setImageURL(String imageURL) { + this.imageURL = imageURL; + } + + public Date getCreatedDate() { + return createdDate; + } + + public void setCreatedDate(Date createdDate) { + this.createdDate = createdDate; + } +} diff --git a/tutorial-juzcret/src/main/java/org/juzu/tutorial/package-info.java b/tutorial-juzcret/src/main/java/org/juzu/tutorial/package-info.java index 04ba989..14d7ff3 100644 --- a/tutorial-juzcret/src/main/java/org/juzu/tutorial/package-info.java +++ b/tutorial-juzcret/src/main/java/org/juzu/tutorial/package-info.java @@ -14,6 +14,19 @@ * limitations under the License. */ -@juzu.Application +@juzu.Application(defaultController = org.juzu.tutorial.JuZcretApplication.class) +@Bindings({ @Binding(value = org.juzu.tutorial.services.SecretService.class, implementation = org.juzu.tutorial.services.SecretServiceMemImpl.class) }) @juzu.plugin.servlet.Servlet(value = "/") +@Less(@Stylesheet("css/juzcret.less")) +@Assets("*") +//@Stylesheets({@Stylesheet(id = "juzcret.css", value = "css/juzcret.css")}) +//@Assets("*") package org.juzu.tutorial; + +import juzu.plugin.binding.Binding; +import juzu.plugin.binding.Bindings; +import juzu.plugin.asset.Stylesheets; +import juzu.plugin.asset.Stylesheet; +import juzu.plugin.asset.Assets; + +import juzu.plugin.less4j.Less; \ No newline at end of file diff --git a/tutorial-juzcret/src/main/java/org/juzu/tutorial/Controller.java b/tutorial-juzcret/src/main/java/org/juzu/tutorial/services/SecretService.java similarity index 64% rename from tutorial-juzcret/src/main/java/org/juzu/tutorial/Controller.java rename to tutorial-juzcret/src/main/java/org/juzu/tutorial/services/SecretService.java index 788506b..e42e6bf 100644 --- a/tutorial-juzcret/src/main/java/org/juzu/tutorial/Controller.java +++ b/tutorial-juzcret/src/main/java/org/juzu/tutorial/services/SecretService.java @@ -14,24 +14,19 @@ * limitations under the License. */ -package org.juzu.tutorial; +package org.juzu.tutorial.services; -import juzu.Path; -import juzu.View; -import juzu.Response; -import juzu.template.Template; +import java.util.List; -import javax.inject.Inject; -import java.io.IOException; +import org.juzu.tutorial.models.Secret; -public class Controller { +/** + * Created by The eXo Platform SAS Author : Thibault Clement + * tclement@exoplatform.com 9/6/14 + */ +public interface SecretService { - @Inject - @Path("index.gtmpl") - Template index; + public List getSecrets(); - @View - public Response.Content index() throws IOException { - return index.ok(); - } + public void addSecret(String message, String imageUrl); } diff --git a/tutorial-juzcret/src/main/java/org/juzu/tutorial/services/SecretServiceMemImpl.java b/tutorial-juzcret/src/main/java/org/juzu/tutorial/services/SecretServiceMemImpl.java new file mode 100644 index 0000000..03f214f --- /dev/null +++ b/tutorial-juzcret/src/main/java/org/juzu/tutorial/services/SecretServiceMemImpl.java @@ -0,0 +1,67 @@ +/* + * Copyright 2013 eXo Platform SAS + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.juzu.tutorial.services; + +import javax.inject.Singleton; + +import java.util.Date; +import java.util.LinkedList; +import java.util.List; + +import org.juzu.tutorial.models.Secret; + +/** + * Created by The eXo Platform SAS + * Author : Thibault Clement + * tclement@exoplatform.com + * 9/6/14 + */ +@Singleton +public class SecretServiceMemImpl implements SecretService { + + private List secretsList; + + public List getSecrets() { + if (secretsList == null) { + secretsList = new LinkedList(); + addFakeSecrets(); + } + return secretsList; +// return Collections.emptyList(); + } + + public void addSecret(String message, String imageUrl) { + Secret secret = new Secret(); + secret.setMessage(message); + secret.setImageURL(imageUrl); + secret.setCreatedDate(new Date()); + secretsList.add(secret); + } + + private void addFakeSecrets() { + addSecret("Yesterday I said I missed my PL meeting because I have to many work. In fact I was drinking free beer in Barbetta pub", + "https://c1.staticflickr.com/3/2385/2345543856_6d0fbafb66_z.jpg?zz=1"); + addSecret("I have a master degree but I still use Google to calculate 3*8", + "https://yy2.staticflickr.com/7244/7245177220_3f17ee9fb8_z.jpg"); + addSecret("I am in relationship for 2 years. He is awesome, powerful and I never go out without him. His name is Linux", + "http://fc02.deviantart.net/fs71/f/2009/364/9/d/christmas_love_by_skubaNiec.jpg"); + addSecret("I spent 2 hours a day to train my cat to perform a backflip", + "http://fc06.deviantart.net/fs15/i/2007/008/e/b/colour_cat_wallpaper_by_jellyplant.jpg"); + addSecret("I pretend to be a spy when I go out. In reality my job is to perform photocopy at the embassy", + "https://c2.staticflickr.com/2/1230/5108154392_3cc02cac67_z.jpg"); + } + } \ No newline at end of file diff --git a/tutorial-juzcret/src/main/java/org/juzu/tutorial/templates/addSecret.gtmpl b/tutorial-juzcret/src/main/java/org/juzu/tutorial/templates/addSecret.gtmpl new file mode 100644 index 0000000..cb6fb76 --- /dev/null +++ b/tutorial-juzcret/src/main/java/org/juzu/tutorial/templates/addSecret.gtmpl @@ -0,0 +1,39 @@ +
+
+
+
+

JuZcret Portlet

+
+ +
+
+
+ +
+
\ No newline at end of file diff --git a/tutorial-juzcret/src/main/java/org/juzu/tutorial/templates/index.gtmpl b/tutorial-juzcret/src/main/java/org/juzu/tutorial/templates/index.gtmpl deleted file mode 100644 index 5e1c309..0000000 --- a/tutorial-juzcret/src/main/java/org/juzu/tutorial/templates/index.gtmpl +++ /dev/null @@ -1 +0,0 @@ -Hello World \ No newline at end of file diff --git a/tutorial-juzcret/src/main/java/org/juzu/tutorial/templates/secretWall.gtmpl b/tutorial-juzcret/src/main/java/org/juzu/tutorial/templates/secretWall.gtmpl new file mode 100644 index 0000000..93e2c30 --- /dev/null +++ b/tutorial-juzcret/src/main/java/org/juzu/tutorial/templates/secretWall.gtmpl @@ -0,0 +1,118 @@ +#{param name=secretsList/} + +
+
+
+
+

JuZcret Portlet

+
+ +
+
+
    + <% secretsList.each { secret -> %> +
  • +
    +
    ${secret.message}
    +
    + 8 + 6 +
    +
    + +
    +
    +
    + + +
    + +
    + +
    +
    +
    + avatar +
    + +
    +
    +
    +
    +
    +
    +
    +
    +
  • + <% } %> +
+
\ No newline at end of file diff --git a/tutorial-juzcret/src/main/resources/META-INF/services/juzu.inject.ProviderFactory b/tutorial-juzcret/src/main/resources/META-INF/services/juzu.inject.ProviderFactory new file mode 100644 index 0000000..c98a9a2 --- /dev/null +++ b/tutorial-juzcret/src/main/resources/META-INF/services/juzu.inject.ProviderFactory @@ -0,0 +1 @@ +org.exoplatform.commons.juzu.KernelProviderFactory \ No newline at end of file diff --git a/tutorial-juzcret/src/main/resources/rebel.xml b/tutorial-juzcret/src/main/resources/rebel.xml new file mode 100644 index 0000000..f7a11f0 --- /dev/null +++ b/tutorial-juzcret/src/main/resources/rebel.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tutorial-juzcret/src/main/webapp/WEB-INF/portlet.xml b/tutorial-juzcret/src/main/webapp/WEB-INF/portlet.xml index 91f7e28..d2862e3 100644 --- a/tutorial-juzcret/src/main/webapp/WEB-INF/portlet.xml +++ b/tutorial-juzcret/src/main/webapp/WEB-INF/portlet.xml @@ -5,8 +5,8 @@ xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"> - SampleApplication - Juzu Sample Application + JuzcretApplication + Juzu Secret Application juzu.bridge.portlet.JuzuPortlet juzu.app_name @@ -16,7 +16,7 @@ text/html - Sample Application + Secret Application