You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by bd...@apache.org on 2010/12/07 16:10:50 UTC
svn commit: r1043087 - in /sling/trunk/samples/slingbucks: ./ src/ src/main/
src/main/java/ src/main/java/org/ src/main/java/org/apache/
src/main/java/org/apache/sling/ src/main/java/org/apache/sling/slingbucks/
src/main/java/org/apache/sling/slingbuck...
Author: bdelacretaz
Date: Tue Dec 7 15:10:49 2010
New Revision: 1043087
URL: http://svn.apache.org/viewvc?rev=1043087&view=rev
Log:
SLING-1887 - Slingbucks sample
Added:
sling/trunk/samples/slingbucks/ (with props)
sling/trunk/samples/slingbucks/README.txt (with props)
sling/trunk/samples/slingbucks/pom.xml (with props)
sling/trunk/samples/slingbucks/src/
sling/trunk/samples/slingbucks/src/main/
sling/trunk/samples/slingbucks/src/main/java/
sling/trunk/samples/slingbucks/src/main/java/org/
sling/trunk/samples/slingbucks/src/main/java/org/apache/
sling/trunk/samples/slingbucks/src/main/java/org/apache/sling/
sling/trunk/samples/slingbucks/src/main/java/org/apache/sling/slingbucks/
sling/trunk/samples/slingbucks/src/main/java/org/apache/sling/slingbucks/server/
sling/trunk/samples/slingbucks/src/main/java/org/apache/sling/slingbucks/server/ConfirmedOrdersObserver.java (with props)
sling/trunk/samples/slingbucks/src/main/java/org/apache/sling/slingbucks/server/HexNodeNameGenerator.java (with props)
sling/trunk/samples/slingbucks/src/main/java/org/apache/sling/slingbucks/server/SlingbucksConstants.java (with props)
sling/trunk/samples/slingbucks/src/main/resources/
sling/trunk/samples/slingbucks/src/main/resources/SLING-CONTENT/
sling/trunk/samples/slingbucks/src/main/resources/SLING-CONTENT/apps/
sling/trunk/samples/slingbucks/src/main/resources/SLING-CONTENT/apps/slingbucks/
sling/trunk/samples/slingbucks/src/main/resources/SLING-CONTENT/apps/slingbucks/common/
sling/trunk/samples/slingbucks/src/main/resources/SLING-CONTENT/apps/slingbucks/common/head.esp
sling/trunk/samples/slingbucks/src/main/resources/SLING-CONTENT/apps/slingbucks/common/slingbucks.css (with props)
sling/trunk/samples/slingbucks/src/main/resources/SLING-CONTENT/apps/slingbucks/common/slingbucks.js (with props)
sling/trunk/samples/slingbucks/src/main/resources/SLING-CONTENT/apps/slingbucks/confirmed/
sling/trunk/samples/slingbucks/src/main/resources/SLING-CONTENT/apps/slingbucks/confirmed/confirmed.esp
sling/trunk/samples/slingbucks/src/main/resources/SLING-CONTENT/apps/slingbucks/options/
sling/trunk/samples/slingbucks/src/main/resources/SLING-CONTENT/apps/slingbucks/options/options.esp
sling/trunk/samples/slingbucks/src/main/resources/SLING-CONTENT/apps/slingbucks/order/
sling/trunk/samples/slingbucks/src/main/resources/SLING-CONTENT/apps/slingbucks/order/backoffice.esp
sling/trunk/samples/slingbucks/src/main/resources/SLING-CONTENT/apps/slingbucks/order/order.esp
sling/trunk/samples/slingbucks/src/main/resources/SLING-CONTENT/apps/slingbucks/order/price.esp
sling/trunk/samples/slingbucks/src/main/resources/SLING-CONTENT/apps/slingbucks/orders/
sling/trunk/samples/slingbucks/src/main/resources/SLING-CONTENT/apps/slingbucks/orders/orders.esp
sling/trunk/samples/slingbucks/src/main/resources/SLING-CONTENT/content/
sling/trunk/samples/slingbucks/src/main/resources/SLING-CONTENT/content/slingbucks/
sling/trunk/samples/slingbucks/src/main/resources/SLING-CONTENT/content/slingbucks/private.json (with props)
sling/trunk/samples/slingbucks/src/main/resources/SLING-CONTENT/content/slingbucks/public.json (with props)
sling/trunk/samples/slingbucks/src/main/resources/SLING-CONTENT/content/slingbucks/readonly/
sling/trunk/samples/slingbucks/src/main/resources/SLING-CONTENT/content/slingbucks/readonly/options.json (with props)
Propchange: sling/trunk/samples/slingbucks/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue Dec 7 15:10:49 2010
@@ -0,0 +1,12 @@
+target
+bin
+*.iml
+*.ipr
+*.iws
+.settings
+.project
+.classpath
+.externalToolBuilders
+maven-eclipse.xml
+
+
Added: sling/trunk/samples/slingbucks/README.txt
URL: http://svn.apache.org/viewvc/sling/trunk/samples/slingbucks/README.txt?rev=1043087&view=auto
==============================================================================
--- sling/trunk/samples/slingbucks/README.txt (added)
+++ sling/trunk/samples/slingbucks/README.txt Tue Dec 7 15:10:49 2010
@@ -0,0 +1,56 @@
+Sling Slingbucks sample
+-----------------------
+
+WHY THIS SAMPLE?
+----------------
+This simple coffee-ordering app demonstrates how Sling promotes RESTful
+application design, and how much you can do with little code.
+
+It was presented at ApacheCon North America 2010, slides can be found at
+http://www.slideshare.net/bdelacretaz/restful-slingbdelacretaz2010
+
+It is inspired by the excellent "How to GET a Cup of Coffee" article by
+Jim Webber, Savas Parastatidis & Ian Robinson at InfoQ:
+http://www.infoq.com/articles/webber-rest-workflow
+
+HOW TO INSTALL
+--------------
+Build this bundle and install it in Sling.
+
+For example, if Sling is running on port 8080 (which happens if you start
+the launchpad/testing module with "mvn jetty:run"), this will build and
+install it:
+
+ mvn -P autoInstallBundle clean install -Dsling.url=http://localhost:8080/system/console
+
+The OSGi console at http://localhost:8080/system/console/bundles must then
+list the "org.apache.sling.samples.slingbucks" bundle as active.
+
+HOW TO TEST
+-----------
+Start at
+
+ http://localhost:8080/content/slingbucks/public/orders.html
+
+and follow the instructions.
+
+The coffee shop employee's view of things is at
+
+ http://localhost:8080/content/slingbucks/private/confirmed.html
+
+Confirmed orders appear there five seconds after they are last modified,
+you need to refresh that page to see them.
+
+To change the coffee options, you can play with the nodes under
+/content/slingbucks/readonly/options/fields, the structure should be
+self-explanatory.
+
+The Sling explorer at
+
+ http://localhost:8080/.explorer.html
+
+can be used to modify those nodes, besides the usual POST requests that the
+SlingPostServlet handles.
+
+
+
Propchange: sling/trunk/samples/slingbucks/README.txt
------------------------------------------------------------------------------
svn:eol-style = native
Added: sling/trunk/samples/slingbucks/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/samples/slingbucks/pom.xml?rev=1043087&view=auto
==============================================================================
--- sling/trunk/samples/slingbucks/pom.xml (added)
+++ sling/trunk/samples/slingbucks/pom.xml Tue Dec 7 15:10:49 2010
@@ -0,0 +1,85 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>sling</artifactId>
+ <version>9</version>
+ </parent>
+
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.samples.slingbucks</artifactId>
+ <version>0.9.9-SNAPSHOT</version>
+ <packaging>bundle</packaging>
+ <name>Slingbucks - sample coffee store management application</name>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-scr-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Private-Package>org.apache.sling.slingbucks.server.*</Private-Package>
+ <Sling-Initial-Content>SLING-CONTENT</Sling-Initial-Content>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.api</artifactId>
+ <version>2.1.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.servlets.post</artifactId>
+ <version>2.1.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.jcr.api</artifactId>
+ <version>2.1.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.scr.annotations</artifactId>
+ <version>1.2.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.jcr</groupId>
+ <artifactId>jcr</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+</project>
Propchange: sling/trunk/samples/slingbucks/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: sling/trunk/samples/slingbucks/src/main/java/org/apache/sling/slingbucks/server/ConfirmedOrdersObserver.java
URL: http://svn.apache.org/viewvc/sling/trunk/samples/slingbucks/src/main/java/org/apache/sling/slingbucks/server/ConfirmedOrdersObserver.java?rev=1043087&view=auto
==============================================================================
--- sling/trunk/samples/slingbucks/src/main/java/org/apache/sling/slingbucks/server/ConfirmedOrdersObserver.java (added)
+++ sling/trunk/samples/slingbucks/src/main/java/org/apache/sling/slingbucks/server/ConfirmedOrdersObserver.java Tue Dec 7 15:10:49 2010
@@ -0,0 +1,171 @@
+/*
+ * 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.slingbucks.server;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Calendar;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.jcr.Item;
+import javax.jcr.Node;
+import javax.jcr.Property;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.observation.Event;
+import javax.jcr.observation.EventIterator;
+import javax.jcr.observation.EventListener;
+import javax.jcr.observation.ObservationManager;
+
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.sling.jcr.api.SlingRepository;
+import org.osgi.service.component.ComponentContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/** Move confirmed orders under CONFIRMED_ORDERS_PATH,
+ * by observing changes under ORDERS_PATH
+ */
+@Component
+public class ConfirmedOrdersObserver implements EventListener, Runnable {
+ private Logger log = LoggerFactory.getLogger(getClass());
+
+ @Reference
+ private SlingRepository repository;
+
+ private Session session;
+ private ObservationManager observationManager;
+
+ private Set<String> changedPropertyPaths = new HashSet<String>();
+ private static final long WAIT_AFTER_LAST_CHANGE_MSEC = 5000;
+ private boolean running;
+
+ protected void activate(ComponentContext context) throws Exception {
+ session = repository.loginAdministrative(null);
+ running = true;
+
+ final Thread t = new Thread(this, getClass().getName());
+ t.setDaemon(true);
+ t.start();
+
+ // Listen for changes to our orders
+ if (repository.getDescriptor(Repository.OPTION_OBSERVATION_SUPPORTED).equals("true")) {
+ observationManager = session.getWorkspace().getObservationManager();
+ final String[] types = { "nt:unstructured" };
+ final boolean isDeep = true;
+ final boolean noLocal = true;
+ final String path = SlingbucksConstants.ORDERS_PATH;
+ observationManager.addEventListener(this, Event.PROPERTY_CHANGED | Event.PROPERTY_ADDED, path, isDeep, null, types, noLocal);
+ log.info("Observing property changes to {} nodes under {}", Arrays.asList(types), path);
+ }
+
+ }
+
+ protected void deactivate(ComponentContext componentContext) throws RepositoryException {
+ running = false;
+ if(observationManager != null) {
+ observationManager.removeEventListener(this);
+ }
+ if (session != null) {
+ session.logout();
+ session = null;
+ }
+ }
+
+ public void onEvent(EventIterator it) {
+ while (it.hasNext()) {
+ // Accumulate the changed paths and store time of the last change event
+ try {
+ final String path = it.nextEvent().getPath();
+ if(path.endsWith(SlingbucksConstants.CONFIRMED_ORDER_PROPERTY_NAME)) {
+ synchronized (changedPropertyPaths) {
+ log.debug("onEvent: property {} changed", path);
+ changedPropertyPaths.add(path);
+ }
+ }
+ } catch(Exception e) {
+ log.warn(e.getClass().getName() + " in onEvent", e);
+ }
+ }
+ }
+
+ private void runOneCycle() throws Exception {
+ if(changedPropertyPaths.isEmpty()) {
+ return;
+ }
+
+ final List<String> paths = new ArrayList<String>();
+ final List<String> toRetry = new ArrayList<String>();
+ synchronized (changedPropertyPaths) {
+ paths.addAll(changedPropertyPaths);
+ changedPropertyPaths.clear();
+ }
+
+ try {
+ while(!paths.isEmpty()) {
+ final String path = paths.remove(0);
+ if(session.itemExists(path)) {
+ final Item it = session.getItem(path);
+ if(!it.isNode()) {
+ final Property p = (Property)it;
+ final Node n = p.getParent();
+ if(!n.hasProperty(SlingbucksConstants.LAST_MODIFIED_PROPERTY_NAME)) {
+ log.debug("Node {} doesn't have property {}, ignored", n.getPath(), SlingbucksConstants.LAST_MODIFIED_PROPERTY_NAME);
+ } else {
+ Calendar lastMod = n.getProperty(SlingbucksConstants.LAST_MODIFIED_PROPERTY_NAME).getDate();
+ if(System.currentTimeMillis() - lastMod.getTime().getTime() < WAIT_AFTER_LAST_CHANGE_MSEC) {
+ log.debug("Node {} modified more recently than {} msec, ignored", n.getPath(), WAIT_AFTER_LAST_CHANGE_MSEC);
+ toRetry.add(path);
+ } else {
+ final String targetPath = SlingbucksConstants.CONFIRMED_ORDERS_PATH + "/" + n.getName();
+ session.getWorkspace().move(n.getPath(), targetPath);
+ log.info("Confirmed order node {} moved to {}", n.getPath(), targetPath);
+ }
+ }
+ }
+ }
+ }
+ } finally {
+ // Re-add any paths that we didn't process
+ synchronized (changedPropertyPaths) {
+ changedPropertyPaths.addAll(paths);
+ changedPropertyPaths.addAll(toRetry);
+ }
+ }
+ }
+
+ public void run() {
+ log.info("Background thread {} starting", Thread.currentThread().getName());
+ while(running) {
+ try {
+ runOneCycle();
+ } catch(Exception e) {
+ log.warn(e.getClass().getName() + " in background thread", e);
+ }
+
+ try {
+ Thread.sleep(1000L);
+ } catch(InterruptedException ignore) {
+ }
+ }
+ log.info("Background thread {} done", Thread.currentThread().getName());
+ }
+}
Propchange: sling/trunk/samples/slingbucks/src/main/java/org/apache/sling/slingbucks/server/ConfirmedOrdersObserver.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: sling/trunk/samples/slingbucks/src/main/java/org/apache/sling/slingbucks/server/ConfirmedOrdersObserver.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision Rev URL
Added: sling/trunk/samples/slingbucks/src/main/java/org/apache/sling/slingbucks/server/HexNodeNameGenerator.java
URL: http://svn.apache.org/viewvc/sling/trunk/samples/slingbucks/src/main/java/org/apache/sling/slingbucks/server/HexNodeNameGenerator.java?rev=1043087&view=auto
==============================================================================
--- sling/trunk/samples/slingbucks/src/main/java/org/apache/sling/slingbucks/server/HexNodeNameGenerator.java (added)
+++ sling/trunk/samples/slingbucks/src/main/java/org/apache/sling/slingbucks/server/HexNodeNameGenerator.java Tue Dec 7 15:10:49 2010
@@ -0,0 +1,58 @@
+/*
+ * 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.slingbucks.server;
+
+import java.util.Random;
+
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Service;
+import org.apache.sling.api.SlingHttpServletRequest;
+import org.apache.sling.servlets.post.NodeNameGenerator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/** Generate hard-to-guess node names for our coffee orders.
+ *
+ * Sling calls this for all "create node" requests to its
+ * POST servlet. This reacts to POST on our ORDERS_PATH, and
+ * returns a somewhat long random hex string for the node name.
+ */
+@Component
+@Service
+public class HexNodeNameGenerator implements NodeNameGenerator {
+ private static final Random random = new Random(System.currentTimeMillis());
+ private final Logger log = LoggerFactory.getLogger(getClass());
+
+ /** @inheritDoc */
+ public String getNodeName(
+ SlingHttpServletRequest request,
+ String parentPath,
+ boolean requirePrefix,
+ NodeNameGenerator defaultNng)
+ {
+ if(SlingbucksConstants.ORDERS_PATH.equals(parentPath)) {
+ final StringBuilder name = new StringBuilder();
+ for(int i=0; i < 2; i++) {
+ name.append(Long.toHexString(random.nextLong()));
+ }
+ log.debug("Called for {} parent path, node name is {}", parentPath, name.toString());
+ return name.toString();
+ }
+ log.debug("Path does not match {}, doing nothing", SlingbucksConstants.ORDERS_PATH);
+ return null;
+ }
+}
\ No newline at end of file
Propchange: sling/trunk/samples/slingbucks/src/main/java/org/apache/sling/slingbucks/server/HexNodeNameGenerator.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: sling/trunk/samples/slingbucks/src/main/java/org/apache/sling/slingbucks/server/HexNodeNameGenerator.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision Rev URL
Added: sling/trunk/samples/slingbucks/src/main/java/org/apache/sling/slingbucks/server/SlingbucksConstants.java
URL: http://svn.apache.org/viewvc/sling/trunk/samples/slingbucks/src/main/java/org/apache/sling/slingbucks/server/SlingbucksConstants.java?rev=1043087&view=auto
==============================================================================
--- sling/trunk/samples/slingbucks/src/main/java/org/apache/sling/slingbucks/server/SlingbucksConstants.java (added)
+++ sling/trunk/samples/slingbucks/src/main/java/org/apache/sling/slingbucks/server/SlingbucksConstants.java Tue Dec 7 15:10:49 2010
@@ -0,0 +1,28 @@
+/*
+ * 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.slingbucks.server;
+
+public class SlingbucksConstants {
+ public static final String CONTENT_PATH = "/content/slingbucks";
+ public static final String PUBLIC_PATH = CONTENT_PATH + "/public";
+ public static final String PRIVATE_PATH = CONTENT_PATH + "/private";
+ public static final String ORDERS_PATH = PUBLIC_PATH + "/orders";
+ public static final String CONFIRMED_ORDERS_PATH = PRIVATE_PATH + "/confirmed";
+
+ public static final String CONFIRMED_ORDER_PROPERTY_NAME = "orderConfirmed";
+ public static final String LAST_MODIFIED_PROPERTY_NAME = "lastModified";
+}
Propchange: sling/trunk/samples/slingbucks/src/main/java/org/apache/sling/slingbucks/server/SlingbucksConstants.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: sling/trunk/samples/slingbucks/src/main/java/org/apache/sling/slingbucks/server/SlingbucksConstants.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision Rev URL
Added: sling/trunk/samples/slingbucks/src/main/resources/SLING-CONTENT/apps/slingbucks/common/head.esp
URL: http://svn.apache.org/viewvc/sling/trunk/samples/slingbucks/src/main/resources/SLING-CONTENT/apps/slingbucks/common/head.esp?rev=1043087&view=auto
==============================================================================
--- sling/trunk/samples/slingbucks/src/main/resources/SLING-CONTENT/apps/slingbucks/common/head.esp (added)
+++ sling/trunk/samples/slingbucks/src/main/resources/SLING-CONTENT/apps/slingbucks/common/head.esp Tue Dec 7 15:10:49 2010
@@ -0,0 +1,24 @@
+<%
+/*
+ * 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.
+ */
+%>
+
+<link rel="slingbucks/options" href="/content/slingbucks/readonly/options.tidy.-1.json"/>
+<link rel="stylesheet" href="/apps/slingbucks/common/slingbucks.css"/>
+<script src="/apps/slingbucks/common/slingbucks.js"></script>
\ No newline at end of file
Added: sling/trunk/samples/slingbucks/src/main/resources/SLING-CONTENT/apps/slingbucks/common/slingbucks.css
URL: http://svn.apache.org/viewvc/sling/trunk/samples/slingbucks/src/main/resources/SLING-CONTENT/apps/slingbucks/common/slingbucks.css?rev=1043087&view=auto
==============================================================================
--- sling/trunk/samples/slingbucks/src/main/resources/SLING-CONTENT/apps/slingbucks/common/slingbucks.css (added)
+++ sling/trunk/samples/slingbucks/src/main/resources/SLING-CONTENT/apps/slingbucks/common/slingbucks.css Tue Dec 7 15:10:49 2010
@@ -0,0 +1,57 @@
+/*
+ * 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.
+ */
+
+body {
+ font-family: Georgia, Verdana, Arial, Sans-Serif;
+}
+
+h1, h3, h3, h4 {
+ border-bottom: solid #CC0033 1px;
+}
+
+#orderHead {
+ margin-bottom: 1em;
+}
+
+#orderHead,
+#orderBody {
+ border: solid #CCCCCC 1px;
+ padding: 1em;
+}
+
+#customerName .fieldValue,
+#price .fieldValue
+{
+ font-weight:bold;
+ font-size:120%;
+}
+
+.fieldName {
+ color:#666666;
+ padding-top: 0.2em;
+}
+
+.backofficeOrder {
+ border: solid #CCCCCC 1px;
+ padding: 1em;
+}
+
+.backofficeOrder .option b {
+ font-size: 120%;
+ }
Propchange: sling/trunk/samples/slingbucks/src/main/resources/SLING-CONTENT/apps/slingbucks/common/slingbucks.css
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: sling/trunk/samples/slingbucks/src/main/resources/SLING-CONTENT/apps/slingbucks/common/slingbucks.css
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision Rev URL
Added: sling/trunk/samples/slingbucks/src/main/resources/SLING-CONTENT/apps/slingbucks/common/slingbucks.js
URL: http://svn.apache.org/viewvc/sling/trunk/samples/slingbucks/src/main/resources/SLING-CONTENT/apps/slingbucks/common/slingbucks.js?rev=1043087&view=auto
==============================================================================
--- sling/trunk/samples/slingbucks/src/main/resources/SLING-CONTENT/apps/slingbucks/common/slingbucks.js (added)
+++ sling/trunk/samples/slingbucks/src/main/resources/SLING-CONTENT/apps/slingbucks/common/slingbucks.js Tue Dec 7 15:10:49 2010
@@ -0,0 +1,24 @@
+/*
+ * 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.
+ */
+function clearLastModified() {
+ var lastMod = document.getElementById("lastModified");
+ if(lastMod) {
+ lastMod.value="";
+ }
+}
\ No newline at end of file
Propchange: sling/trunk/samples/slingbucks/src/main/resources/SLING-CONTENT/apps/slingbucks/common/slingbucks.js
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: sling/trunk/samples/slingbucks/src/main/resources/SLING-CONTENT/apps/slingbucks/common/slingbucks.js
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision Rev URL
Added: sling/trunk/samples/slingbucks/src/main/resources/SLING-CONTENT/apps/slingbucks/confirmed/confirmed.esp
URL: http://svn.apache.org/viewvc/sling/trunk/samples/slingbucks/src/main/resources/SLING-CONTENT/apps/slingbucks/confirmed/confirmed.esp?rev=1043087&view=auto
==============================================================================
--- sling/trunk/samples/slingbucks/src/main/resources/SLING-CONTENT/apps/slingbucks/confirmed/confirmed.esp (added)
+++ sling/trunk/samples/slingbucks/src/main/resources/SLING-CONTENT/apps/slingbucks/confirmed/confirmed.esp Tue Dec 7 15:10:49 2010
@@ -0,0 +1,37 @@
+<%
+/*
+ * 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.
+ */
+%>
+
+<html>
+<head>
+<title><%= currentNode["jcr:title"] %></title>
+<% load("../common/head.esp"); %>
+
+</head>
+<body>
+<h1><%= currentNode["jcr:title"] %></h1>
+<%
+var childNodes = currentNode.getChildren();
+for(i in childNodes) {
+ sling.include(childNodes[i].path, "replaceSelectors=backoffice");
+}
+%>
+</body>
+</html>
\ No newline at end of file
Added: sling/trunk/samples/slingbucks/src/main/resources/SLING-CONTENT/apps/slingbucks/options/options.esp
URL: http://svn.apache.org/viewvc/sling/trunk/samples/slingbucks/src/main/resources/SLING-CONTENT/apps/slingbucks/options/options.esp?rev=1043087&view=auto
==============================================================================
--- sling/trunk/samples/slingbucks/src/main/resources/SLING-CONTENT/apps/slingbucks/options/options.esp (added)
+++ sling/trunk/samples/slingbucks/src/main/resources/SLING-CONTENT/apps/slingbucks/options/options.esp Tue Dec 7 15:10:49 2010
@@ -0,0 +1,71 @@
+<%
+/*
+ * 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.
+ */
+%>
+
+<%
+// Make sure current node has a "fields" subnode,
+// and visit it
+if(currentNode["fields"]) {
+ var fields = currentNode["fields"];
+ for(i in fields) {
+ var f = fields[i];
+
+ // If field has a jcr:title property, we can use it
+ if(f["jcr:title"]) {
+ // Add a prefix in front of option names for
+ // easier differentiation later on
+ var fieldName = "opt_" + i;
+ // Generate HTML <select> for our field
+ %>
+ <div class="field">
+ <div class="fieldName">
+ <%= f["jcr:title"] %>
+ </div>
+ <div class="fieldValue">
+ <select name="<%= fieldName %>">
+ <options>
+ <%
+ for(j in f) {
+ var opt = f[j];
+ if(opt["jcr:title"]) {
+ %>
+ <option value="<%= j %>"><%= opt["jcr:title"] %></option>
+ <%
+ }
+ }
+ %>
+ </select>
+ </div>
+ </div>
+ <%
+ }
+ }
+}
+%>
+
+<!--
+// Set appropriate resource type on created coffee order
+-->
+<input type="hidden" name="sling:resourceType" value="slingbucks/order"/>
+
+<!--
+Let Sling set lastModified automatically
+-->
+<input type="hidden" id="lastModified" name="lastModified" value=""/>
\ No newline at end of file
Added: sling/trunk/samples/slingbucks/src/main/resources/SLING-CONTENT/apps/slingbucks/order/backoffice.esp
URL: http://svn.apache.org/viewvc/sling/trunk/samples/slingbucks/src/main/resources/SLING-CONTENT/apps/slingbucks/order/backoffice.esp?rev=1043087&view=auto
==============================================================================
--- sling/trunk/samples/slingbucks/src/main/resources/SLING-CONTENT/apps/slingbucks/order/backoffice.esp (added)
+++ sling/trunk/samples/slingbucks/src/main/resources/SLING-CONTENT/apps/slingbucks/order/backoffice.esp Tue Dec 7 15:10:49 2010
@@ -0,0 +1,47 @@
+<%
+/*
+ * 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.
+ */
+%>
+
+<div class="backofficeOrder">
+ <h2><%= currentNode.customerName %></h2>
+
+ <%
+ var OPT_PREFIX_REGEXP = /^opt_/;
+
+ for(prop in currentNode) {
+ if(!prop.match(OPT_PREFIX_REGEXP)) {
+ continue;
+ }
+ var name = prop.replace(OPT_PREFIX_REGEXP,"");
+ var value = currentNode[prop];
+
+ %><span class="option"><%= name %><span class="spacer"> </span><b><%= value %></b></span><span class="spacer"> </span><%
+ }
+ %>
+ <div class="price">
+ Price: <b><% sling.include(resource.path, "replaceSelectors=price"); %></b>
+ </div>
+ <form method="POST" action="<%= currentNode.path %>">
+ <input type="hidden" name=":operation" value="delete"/>
+ <input type="hidden" name="source" value="<%= currentNode.path %>"/>
+ <input type="hidden" name=":redirect" value="<%= currentNode.getParent().path %>.html"/>
+ <input type="submit" value="Delivered - delete this order"/>
+ </form>
+</div>
\ No newline at end of file
Added: sling/trunk/samples/slingbucks/src/main/resources/SLING-CONTENT/apps/slingbucks/order/order.esp
URL: http://svn.apache.org/viewvc/sling/trunk/samples/slingbucks/src/main/resources/SLING-CONTENT/apps/slingbucks/order/order.esp?rev=1043087&view=auto
==============================================================================
--- sling/trunk/samples/slingbucks/src/main/resources/SLING-CONTENT/apps/slingbucks/order/order.esp (added)
+++ sling/trunk/samples/slingbucks/src/main/resources/SLING-CONTENT/apps/slingbucks/order/order.esp Tue Dec 7 15:10:49 2010
@@ -0,0 +1,80 @@
+<%
+/*
+ * 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.
+ */
+%>
+
+<%
+var confirmed = currentNode["orderConfirmed"];
+var pageTitle = "Please review and confirm your order";
+if(confirmed) {
+ pageTitle = "Your order is confirmed";
+}
+%>
+<html>
+<head>
+<title><%= pageTitle %></title>
+<% load("../common/head.esp"); %>
+<link rel="slingbucks/order/price" href="<%= resource.path %>.price.html"/>
+</head>
+<body>
+<h1><%= pageTitle %></h1>
+
+<form method="POST" onSubmit="return clearLastModified()">
+
+<div id="orderHead">
+ <div class="field" id="customerName">
+ <div class="fieldName">Your name</div>
+ <div class="fieldValue"><%= currentNode.customerName %></div>
+ </div>
+
+ <div class="field" id="price">
+ <div class="fieldName">Price of your order</div>
+ <div class="fieldValue"><% sling.include(resource.path, "replaceSelectors=price"); %></div>
+ </div>
+</div>
+
+<% if(confirmed) { %>
+ <div id="orderBody">
+ Your order number is <b><%= currentNode.name %></b>
+ <br/>
+ Please pick it up at the
+ counter when called.
+ </div>
+<% } else { %>
+ <div id="orderBody">
+ <% sling.include("/content/slingbucks/readonly/options"); %>
+ </div>
+ <div class="submit">
+ <input type="submit" value="Recalculate"/>
+ <span class="spacer"/>
+ <input type="submit" name="orderConfirmed" value="Confirm this order"/>
+ </div>
+<% } %>
+
+<input type="hidden" name=":redirect" value="*.html"/>
+
+</form>
+
+<script src="/system/sling.js"></script>
+<script>
+Sling.wizard();
+</script>
+
+</body>
+</html>
\ No newline at end of file
Added: sling/trunk/samples/slingbucks/src/main/resources/SLING-CONTENT/apps/slingbucks/order/price.esp
URL: http://svn.apache.org/viewvc/sling/trunk/samples/slingbucks/src/main/resources/SLING-CONTENT/apps/slingbucks/order/price.esp?rev=1043087&view=auto
==============================================================================
--- sling/trunk/samples/slingbucks/src/main/resources/SLING-CONTENT/apps/slingbucks/order/price.esp (added)
+++ sling/trunk/samples/slingbucks/src/main/resources/SLING-CONTENT/apps/slingbucks/order/price.esp Tue Dec 7 15:10:49 2010
@@ -0,0 +1,80 @@
+<%
+/*
+ * 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.
+ */
+%>
+
+<%
+// Get the fields node, where prices are defined
+var fields = resource.getResourceResolver().resolve("/content/slingbucks/readonly/options/fields");
+
+var FIELDS_PATH = "/content/slingbucks/readonly/options/fields";
+var OPT_PREFIX_REGEXP = /^opt_/;
+
+function getPriceProperty(fieldName, value, propertyName) {
+ if(fieldName.match(OPT_PREFIX_REGEXP)) {
+ fieldName = fieldName.replace(OPT_PREFIX_REGEXP,"");
+ } else {
+ return null;
+ }
+
+ // Path of price property P is like
+ // FIELDS_PATH + coffeetype/capuccino/priceOffset
+ // Get that resource and get our property under it
+ var path = FIELDS_PATH + "/" + fieldName + "/" + value;
+ var fieldResource = resource.getResourceResolver().resolve(path);
+ if(fieldResource) {
+ var props = fieldResource.adaptTo(Packages.org.apache.sling.api.resource.ValueMap);
+ if(props) {
+ var value = props.get(propertyName);
+ if(value) {
+ return value;
+ }
+ }
+ }
+ return null;
+}
+
+// Enumerate the properties of the current order node,
+// find the price in our fields definition, and
+// accumulate if found
+var price = 0;
+
+// First using priceOffset, to compute the base price
+for(i in currentNode) {
+ var prop = currentNode[i];
+ var offset = getPriceProperty(i, prop, "priceOffset");
+ if(offset) {
+ price += offset;
+ }
+}
+
+// Then using priceFactor and multiply
+for(i in currentNode) {
+ var prop = currentNode[i];
+ var factor = getPriceProperty(i, prop, "priceFactor");
+ if(factor) {
+ price *= factor;
+ }
+}
+
+// And round price
+price = Math.round(price * 10) / 10;
+
+%>
+<%= price %>
\ No newline at end of file
Added: sling/trunk/samples/slingbucks/src/main/resources/SLING-CONTENT/apps/slingbucks/orders/orders.esp
URL: http://svn.apache.org/viewvc/sling/trunk/samples/slingbucks/src/main/resources/SLING-CONTENT/apps/slingbucks/orders/orders.esp?rev=1043087&view=auto
==============================================================================
--- sling/trunk/samples/slingbucks/src/main/resources/SLING-CONTENT/apps/slingbucks/orders/orders.esp (added)
+++ sling/trunk/samples/slingbucks/src/main/resources/SLING-CONTENT/apps/slingbucks/orders/orders.esp Tue Dec 7 15:10:49 2010
@@ -0,0 +1,54 @@
+<%
+/*
+ * 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.
+ */
+%>
+
+<html>
+<head>
+<title><%= currentNode["jcr:title"] %></title>
+<% load("../common/head.esp"); %>
+</head>
+<body>
+<h1><%= currentNode["jcr:title"] %></h1>
+
+<form method="POST" action="/content/slingbucks/public/orders/" onSubmit="return clearLastModified()">
+
+<div id="orderHead">
+ <div class="field">
+ <div class="fieldName">Your name</div>
+ <div class="fieldValue">
+ <input type="text" name="customerName" style="width:100%" value="Anonymous Coffee Drinker"/>
+ </div>
+ </div>
+</div>
+
+<div id="orderBody">
+ <% sling.include("/content/slingbucks/readonly/options"); %>
+</div>
+
+<input type="hidden" name=":redirect" value="*.html"/>
+
+<div class="submit">
+<input type="submit" value="Order coffee"/>
+</div>
+
+</form>
+
+</body>
+</html>
\ No newline at end of file
Added: sling/trunk/samples/slingbucks/src/main/resources/SLING-CONTENT/content/slingbucks/private.json
URL: http://svn.apache.org/viewvc/sling/trunk/samples/slingbucks/src/main/resources/SLING-CONTENT/content/slingbucks/private.json?rev=1043087&view=auto
==============================================================================
--- sling/trunk/samples/slingbucks/src/main/resources/SLING-CONTENT/content/slingbucks/private.json (added)
+++ sling/trunk/samples/slingbucks/src/main/resources/SLING-CONTENT/content/slingbucks/private.json Tue Dec 7 15:10:49 2010
@@ -0,0 +1,7 @@
+{
+ "jcr:primaryType" : "nt:unstructured",
+ "confirmed" : {
+ "jcr:title" : "Confirmed orders",
+ "sling:resourceType" : "slingbucks/confirmed"
+ }
+}
\ No newline at end of file
Propchange: sling/trunk/samples/slingbucks/src/main/resources/SLING-CONTENT/content/slingbucks/private.json
------------------------------------------------------------------------------
svn:eol-style = native
Added: sling/trunk/samples/slingbucks/src/main/resources/SLING-CONTENT/content/slingbucks/public.json
URL: http://svn.apache.org/viewvc/sling/trunk/samples/slingbucks/src/main/resources/SLING-CONTENT/content/slingbucks/public.json?rev=1043087&view=auto
==============================================================================
--- sling/trunk/samples/slingbucks/src/main/resources/SLING-CONTENT/content/slingbucks/public.json (added)
+++ sling/trunk/samples/slingbucks/src/main/resources/SLING-CONTENT/content/slingbucks/public.json Tue Dec 7 15:10:49 2010
@@ -0,0 +1,7 @@
+{
+ "jcr:primaryType" : "nt:unstructured",
+ "orders" : {
+ "jcr:title" : "Welcome to Slingbucks. Please order here.",
+ "sling:resourceType" : "slingbucks/orders"
+ }
+}
\ No newline at end of file
Propchange: sling/trunk/samples/slingbucks/src/main/resources/SLING-CONTENT/content/slingbucks/public.json
------------------------------------------------------------------------------
svn:eol-style = native
Added: sling/trunk/samples/slingbucks/src/main/resources/SLING-CONTENT/content/slingbucks/readonly/options.json
URL: http://svn.apache.org/viewvc/sling/trunk/samples/slingbucks/src/main/resources/SLING-CONTENT/content/slingbucks/readonly/options.json?rev=1043087&view=auto
==============================================================================
--- sling/trunk/samples/slingbucks/src/main/resources/SLING-CONTENT/content/slingbucks/readonly/options.json (added)
+++ sling/trunk/samples/slingbucks/src/main/resources/SLING-CONTENT/content/slingbucks/readonly/options.json Tue Dec 7 15:10:49 2010
@@ -0,0 +1,74 @@
+{
+ "jcr:primaryType" : "nt:unstructured",
+ "jcr:title" : "Coffee store options",
+ "jcr:description" : "Defines ordering options for our customers",
+ "sling:resourceType" : "slingbucks/options",
+ "fields" : {
+ "coffeetype" : {
+ "jcr:title" : "Coffee type",
+ "espresso" : {
+ "jcr:title" : "Espresso",
+ "jcr:description" : "The Italian job",
+ "priceOffset" : 2.20
+ },
+ "capuccino" : {
+ "jcr:title" : "Capuccino",
+ "jcr:description" : "The one with cream on top",
+ "priceOffset" : 3.40
+ },
+ "macchiato" : {
+ "jcr:title" : "Macchiato",
+ "jcr:description" : "Espresso, hot milk and cream",
+ "priceOffset" : 4.30
+ }
+ },
+ "size" : {
+ "jcr:title" : "Size",
+ "small" : {
+ "jcr:title" : "Small",
+ "jcr:description" : "1dl",
+ "priceFactor" : 1
+ },
+ "medium" : {
+ "jcr:title" : "Medium",
+ "jcr:description" : "2dl",
+ "priceFactor" : 1.5
+ },
+ "large" : {
+ "jcr:title" : "Large",
+ "jcr:description" : "5dl",
+ "priceFactor" : 2
+ }
+ },
+ "sugar" : {
+ "jcr:title" : "Sugar",
+ "none" : {
+ "jcr:title" : "No sugar",
+ "priceFactor" : 1
+ },
+ "white" : {
+ "jcr:title" : "White sugar",
+ "priceFactor" : 1.1
+ },
+ "raw" : {
+ "jcr:title" : "Raw sugar",
+ "priceFactor" : 1.2
+ }
+ },
+ "cup" : {
+ "jcr:title" : "Cup type",
+ "plastic" : {
+ "jcr:title" : "Standard plastic",
+ "priceFactor" : 1
+ },
+ "rosewood" : {
+ "jcr:title" : "Rosewood",
+ "priceFactor" : 5
+ },
+ "china" : {
+ "jcr:title" : "Industrial china",
+ "priceFactor" : 1.5
+ }
+ }
+ }
+}
\ No newline at end of file
Propchange: sling/trunk/samples/slingbucks/src/main/resources/SLING-CONTENT/content/slingbucks/readonly/options.json
------------------------------------------------------------------------------
svn:eol-style = native