Author: cziegeler
Date: Mon Mar 28 16:28:36 2016
New Revision: 1736903
URL: http://svn.apache.org/viewvc?rev=1736903&view=rev
Log:
Update entry layout
Added:
sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/model/PropertiesSupport.java
(with props)
Modified:
sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/model/Stream.java
sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/model/StreamEntry.java
sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/model/StreamInfo.java
sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/model/UserInfo.java
sling/trunk/samples/slingshot/src/main/resources/SLING-INF/content/libs/slingshot/Streamentry/html.jsp
sling/trunk/samples/slingshot/src/main/resources/SLING-INF/content/slingshot/resources/css/slingshot.css
Added:
sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/model/PropertiesSupport.java
URL:
http://svn.apache.org/viewvc/sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/model/PropertiesSupport.java?rev=1736903&view=auto
==============================================================================
---
sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/model/PropertiesSupport.java
(added)
+++
sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/model/PropertiesSupport.java
Mon Mar 28 16:28:36 2016
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.sling.sample.slingshot.model;
+
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ResourceUtil;
+import org.apache.sling.api.resource.ValueMap;
+
+public abstract class PropertiesSupport {
+
+ protected final Resource resource;
+
+ private volatile ValueMap properties;
+
+ public PropertiesSupport(final Resource resource) {
+ this.resource = resource;
+ }
+
+ protected ValueMap getProperties() {
+ if ( this.properties == null ) {
+ if ( this.resource == null ) {
+ this.properties = ResourceUtil.getValueMap(null);
+ } else {
+ this.properties = resource.getValueMap();
+ }
+ }
+ return this.properties;
+ }
+
+}
Propchange:
sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/model/PropertiesSupport.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/model/PropertiesSupport.java
------------------------------------------------------------------------------
svn:keywords = author date id revision rev url
Modified:
sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/model/Stream.java
URL:
http://svn.apache.org/viewvc/sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/model/Stream.java?rev=1736903&r1=1736902&r2=1736903&view=diff
==============================================================================
---
sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/model/Stream.java
(original)
+++
sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/model/Stream.java
Mon Mar 28 16:28:36 2016
@@ -35,7 +35,7 @@ public class Stream {
public StreamInfo getInfo() {
if ( info == null ) {
- info = new StreamInfo(this.resource.getChild("info"));
+ info = new StreamInfo(this.resource == null ? null :
this.resource.getChild("info"));
}
return info;
}
Modified:
sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/model/StreamEntry.java
URL:
http://svn.apache.org/viewvc/sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/model/StreamEntry.java?rev=1736903&r1=1736902&r2=1736903&view=diff
==============================================================================
---
sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/model/StreamEntry.java
(original)
+++
sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/model/StreamEntry.java
Mon Mar 28 16:28:36 2016
@@ -20,14 +20,58 @@ package org.apache.sling.sample.slingsho
import org.apache.sling.api.resource.Resource;
-public class StreamEntry {
+public class StreamEntry extends PropertiesSupport {
/** The resource type for a stream entry. */
public static final String RESOURCETYPE = "slingshot/Streamentry";
- private final Resource resource;
+ public static final String PROPERTY_TITLE = "title";
+
+ public static final String PROPERTY_DESCRIPTION = "description";
+
+ public static final String PROPERTY_LOCATION = "location";
+
+ public static final String PROPERTY_TAGS = "tags";
+
+ private volatile Stream stream;
public StreamEntry(final Resource resource) {
- this.resource = resource;
+ super(resource);
+ }
+
+ public String getTitle() {
+ String value = this.getProperties().get(PROPERTY_TITLE, String.class);
+ if ( value == null ) {
+ if ( resource != null ) {
+ value = resource.getName();
+ } else {
+ value = "No Title";
+ }
+ }
+ return value;
+ }
+
+ public String getDescription() {
+ final String value = this.getProperties().get(PROPERTY_DESCRIPTION,
"");
+ return value;
+ }
+
+ public Stream getStream() {
+ if ( this.stream == null ) {
+ if ( resource == null ) {
+ stream = new Stream(null);
+ } else {
+ Resource rsrc = this.resource.getParent();
+ while (rsrc != null &&
!rsrc.isResourceType(Stream.RESOURCETYPE) ) {
+ rsrc = rsrc.getParent();
+ }
+ stream = new Stream(rsrc);
+ }
+ }
+ return stream;
+ }
+
+ public String getLocation() {
+ return this.getProperties().get(PROPERTY_LOCATION, String.class);
}
}
Modified:
sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/model/StreamInfo.java
URL:
http://svn.apache.org/viewvc/sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/model/StreamInfo.java?rev=1736903&r1=1736902&r2=1736903&view=diff
==============================================================================
---
sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/model/StreamInfo.java
(original)
+++
sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/model/StreamInfo.java
Mon Mar 28 16:28:36 2016
@@ -19,7 +19,7 @@ package org.apache.sling.sample.slingsho
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ValueMap;
-public class StreamInfo {
+public class StreamInfo extends PropertiesSupport {
/** The resource type for a stream info. */
public static final String RESOURCETYPE = "slingshot/Streaminfo";
@@ -30,21 +30,10 @@ public class StreamInfo {
public static final String PATH_PHOTO = "photo";
- private final Resource resource;
-
- private volatile ValueMap properties;
-
private volatile long entryCount = -1;
public StreamInfo(final Resource resource) {
- this.resource = resource;
- }
-
- private ValueMap getProperties() {
- if ( this.properties == null ) {
- this.properties = resource.getValueMap();
- }
- return this.properties;
+ super(resource);
}
public String getTitle() {
Modified:
sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/model/UserInfo.java
URL:
http://svn.apache.org/viewvc/sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/model/UserInfo.java?rev=1736903&r1=1736902&r2=1736903&view=diff
==============================================================================
---
sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/model/UserInfo.java
(original)
+++
sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/model/UserInfo.java
Mon Mar 28 16:28:36 2016
@@ -17,9 +17,8 @@
package org.apache.sling.sample.slingshot.model;
import org.apache.sling.api.resource.Resource;
-import org.apache.sling.api.resource.ValueMap;
-public class UserInfo {
+public class UserInfo extends PropertiesSupport {
/** The resource type for a user info. */
public static final String RESOURCETYPE = "slingshot/Userinfo";
@@ -30,19 +29,8 @@ public class UserInfo {
public static final String PATH_PHOTO = "photo";
- private final Resource resource;
-
- private volatile ValueMap properties;
-
public UserInfo(final Resource resource) {
- this.resource = resource;
- }
-
- private ValueMap getProperties() {
- if ( this.properties == null ) {
- this.properties = resource.getValueMap();
- }
- return this.properties;
+ super(resource);
}
public String getName() {
Modified:
sling/trunk/samples/slingshot/src/main/resources/SLING-INF/content/libs/slingshot/Streamentry/html.jsp
URL:
http://svn.apache.org/viewvc/sling/trunk/samples/slingshot/src/main/resources/SLING-INF/content/libs/slingshot/Streamentry/html.jsp?rev=1736903&r1=1736902&r2=1736903&view=diff
==============================================================================
---
sling/trunk/samples/slingshot/src/main/resources/SLING-INF/content/libs/slingshot/Streamentry/html.jsp
(original)
+++
sling/trunk/samples/slingshot/src/main/resources/SLING-INF/content/libs/slingshot/Streamentry/html.jsp
Mon Mar 28 16:28:36 2016
@@ -20,16 +20,15 @@
org.apache.sling.api.resource.ResourceUtil,
org.apache.sling.api.resource.ValueMap,
org.apache.sling.api.request.ResponseUtil,
- org.apache.sling.sample.slingshot.SlingshotConstants,
+ org.apache.sling.sample.slingshot.model.StreamEntry,
org.apache.sling.sample.slingshot.SlingshotUtil,
org.apache.sling.sample.slingshot.ratings.RatingsService,
org.apache.sling.sample.slingshot.ratings.RatingsUtil"%><%
%><%@taglib prefix="sling" uri="http://sling.apache.org/taglibs/sling/1.0" %><%
%><sling:defineObjects/><%
+ final StreamEntry entry = new StreamEntry(resource);
+
final RatingsService ratingsService =
sling.getService(RatingsService.class);
- final ValueMap attributes = resource.getValueMap();
- final String title =
ResponseUtil.escapeXml(attributes.get(SlingshotConstants.PROPERTY_TITLE,
resource.getName()));
- final String streamName =
ResponseUtil.escapeXml(resource.getParent().getValueMap().get(SlingshotConstants.PROPERTY_TITLE,
resource.getParent().getName()));
String imagePath = null;
final Resource imagesResource =
resource.getResourceResolver().getResource(resource, "images");
@@ -41,35 +40,24 @@
}
%><html>
<head>
- <title><%= title %></title>
+ <title><%= ResponseUtil.escapeXml(entry.getTitle()) %></title>
<sling:include resource="<%= resource %>" replaceSelectors="head"/>
</head>
<body>
<sling:include resource="<%= resource %>" replaceSelectors="menu"/>
<div class="jumbotron">
<div class="container">
- <h1><%= title %></h1>
- <p>Explore the world of bla....</p>
+ <h1><%= ResponseUtil.escapeXml(entry.getStream().getInfo().getTitle())
%></h1>
+ <p><%=
ResponseUtil.escapeXml(entry.getStream().getInfo().getDescription()) %></p>
</div>
</div>
<div class="container">
- <ul class="nav nav-tabs">
- <li role="presentation" class="active"><a href="#">Home</a></li>
- <li role="presentation"><a href="#">Comments</a></li>
- <li role="presentation"><a href="#">Edit</a></li>
- </ul>
- <img class="img-responsive center-block" src="<%=
request.getContextPath() %><%= imagePath %>"/>
- <div style="width:30%; float:left; padding:15px; display:block;">
-
<p><%=ResponseUtil.escapeXml(attributes.get(SlingshotConstants.PROPERTY_DESCRIPTION,
""))%></p>
- <% if ( attributes.get(SlingshotConstants.PROPERTY_LOCATION) != null )
{ %>
- <p>Location</p>
-
<p><%=ResponseUtil.escapeXml(attributes.get(SlingshotConstants.PROPERTY_LOCATION,
""))%></p>
- <% } %>
- <% if ( slingRequest.getRemoteUser() != null &&
slingRequest.getRemoteUser().equals(SlingshotUtil.getUserId(resource)) ) { %>
- <button class="ui-button ui-form-button ui-slingshot-clickable"
- data-link="<%= request.getContextPath()
%><%=resource.getName() %>.edit.html" type="button">Edit</button>
- <% } %>
- <div class="metro">
+ <h1><%= ResponseUtil.escapeXml(entry.getTitle()) %></h1>
+ <div class="row">
+ <div class="col-xs-12 col-md-8">
+ <img class="img-responsive center-block" src="<%=
request.getContextPath() %><%= imagePath %>"/>
+ </div>
+ <div class="col-xs-6 col-md-4">
<div id="rating"
data-score-hint="Rating: "
data-show-score="true"
@@ -82,8 +70,9 @@
<span class="score-hint">Rating: <%=
ratingsService.getRating(resource) %></span>
</div>
<div class="fg-green rating active" id="own_rating" style="height:
auto;">
- <ul><li title="bad" class="rated"></li><li title="poor"></li><li
title="regular"></li><li title="good"></li><li title="gorgeous"></li></ul><span
class="score-hint">Current score: <%= ratingsService.getRating(resource,
request.getRemoteUser()) %></span></div>
- <script>
+ <ul><li title="bad" class="rated"></li><li title="poor"></li><li
title="regular"></li><li title="good"></li><li title="gorgeous"></li></ul><span
class="score-hint">Current score: <%= ratingsService.getRating(resource,
request.getRemoteUser()) %></span>
+ </div>
+ <script>
$(function(){
$("#own_rating").rating({
static: false,
@@ -93,17 +82,27 @@
showScore: true,
click: function(value, rating) {
rating.rate(value);
- $.post( "<%= resource.getName()
%>.ratings", { <%= RatingsUtil.PROPERTY_RATING %> : value }, function( data ) {
- $("#rating").rating("rate",
data.rating);
- }, "json");
+ $.post( "<%= resource.getName()
%>.ratings", { <%= RatingsUtil.PROPERTY_RATING %> : value }, function( data ) {
+ $("#rating").rating("rate",
data.rating);
+ }, "json");
}
});
});
- </script>
+ </script>
</div>
</div>
- <hr/>
- <sling:include resource="<%= resource %>" replaceSelectors="comments"/>
+ <div class="row">
+ <p><%=ResponseUtil.escapeXml(entry.getDescription())%></p>
+ <% if ( entry.getLocation() != null ) { %>
+ <p>Location</p>
+ <p><%=ResponseUtil.escapeXml(entry.getLocation())%></p>
+ <% } %>
+ <% if ( slingRequest.getRemoteUser() != null &&
slingRequest.getRemoteUser().equals(SlingshotUtil.getUserId(resource)) ) { %>
+ <button class="ui-button ui-form-button ui-slingshot-clickable"
+ data-link="<%= request.getContextPath()
%><%=resource.getName() %>.edit.html" type="button">Edit</button>
+ <% } %>
+ </div>
+ <sling:include resource="<%= resource %>" replaceSelectors="comments"/>
</div>
<sling:include resource="<%= resource %>" replaceSelectors="bottom"/>
</body>
Modified:
sling/trunk/samples/slingshot/src/main/resources/SLING-INF/content/slingshot/resources/css/slingshot.css
URL:
http://svn.apache.org/viewvc/sling/trunk/samples/slingshot/src/main/resources/SLING-INF/content/slingshot/resources/css/slingshot.css?rev=1736903&r1=1736902&r2=1736903&view=diff
==============================================================================
---
sling/trunk/samples/slingshot/src/main/resources/SLING-INF/content/slingshot/resources/css/slingshot.css
(original)
+++
sling/trunk/samples/slingshot/src/main/resources/SLING-INF/content/slingshot/resources/css/slingshot.css
Mon Mar 28 16:28:36 2016
@@ -31,7 +31,10 @@ body.login {
-o-background-size: cover;
background-size: cover;
}
-
+.jumbotron {
+ padding-bottom: 10px;
+ padding-top: 8px;
+}
.form-signin {
max-width: 330px;
padding: 15px;