You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@juneau.apache.org by ja...@apache.org on 2017/06/11 17:59:30 UTC
incubator-juneau git commit: Improvements to REST examples.
Repository: incubator-juneau
Updated Branches:
refs/heads/master cf8c4f944 -> 4eb151d1a
Improvements to REST examples.
Project: http://git-wip-us.apache.org/repos/asf/incubator-juneau/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-juneau/commit/4eb151d1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-juneau/tree/4eb151d1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-juneau/diff/4eb151d1
Branch: refs/heads/master
Commit: 4eb151d1a020b0fc058e46b7f6c3269fba46ad93
Parents: cf8c4f9
Author: JamesBognar <ja...@apache.org>
Authored: Sun Jun 11 13:59:28 2017 -0400
Committer: JamesBognar <ja...@apache.org>
Committed: Sun Jun 11 13:59:28 2017 -0400
----------------------------------------------------------------------
.../juneau/examples/rest/AtomFeedResource.java | 4 +-
.../examples/rest/JsonSchemaResource.java | 4 +-
.../juneau/examples/rest/RootResources.java | 3 +-
.../rest/addressbook/AddressBookResource.java | 4 +-
.../widget/ContentTypeLinksColumnWidget.java | 48 ++++++++++++++++++++
.../rest/widget/ContentTypeLinksRowWidget.java | 48 ++++++++++++++++++++
.../rest/widget/ContentTypeLinksWidget.java | 48 --------------------
7 files changed, 103 insertions(+), 56 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4eb151d1/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/AtomFeedResource.java
----------------------------------------------------------------------
diff --git a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/AtomFeedResource.java b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/AtomFeedResource.java
index fcfe9b9..9da4e94 100644
--- a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/AtomFeedResource.java
+++ b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/AtomFeedResource.java
@@ -37,7 +37,7 @@ import org.apache.juneau.rest.widget.*;
aside=""
+ "<div style='min-width:200px' class='text'>"
+ " <p>Shows how to produce ATOM feeds in a variety of languages.</p>"
- + " <p>$W{contentTypeLinks}</p>"
+ + " <p>$W{contentTypeLinksRow}</p>"
+ "</div>",
css="aside {display:table-caption;}"
),
@@ -47,7 +47,7 @@ import org.apache.juneau.rest.widget.*;
@Property(name=RDF_addRootProperty, value="true")
},
widgets={
- ContentTypeLinksWidget.class
+ ContentTypeLinksRowWidget.class
},
encoders=GzipEncoder.class
)
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4eb151d1/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/JsonSchemaResource.java
----------------------------------------------------------------------
diff --git a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/JsonSchemaResource.java b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/JsonSchemaResource.java
index 6b1fffb..ad8d26f 100644
--- a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/JsonSchemaResource.java
+++ b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/JsonSchemaResource.java
@@ -30,11 +30,11 @@ import org.apache.juneau.rest.widget.*;
aside=""
+ "<div style='min-width:200px' class='text'>"
+ " <p>Shows how to produce JSON-Schema documents in a variety of languages using the JSON-Schema DTOs.</p>"
- + " <p>$W{contentTypeLinks}</p>"
+ + " <p>$W{contentTypeLinksColumn}</p>"
+ "</div>"
),
widgets={
- ContentTypeLinksWidget.class
+ ContentTypeLinksColumnWidget.class
}
)
public class JsonSchemaResource extends ResourceJena {
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4eb151d1/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/RootResources.java
----------------------------------------------------------------------
diff --git a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/RootResources.java b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/RootResources.java
index 3f572e6..14adedc 100644
--- a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/RootResources.java
+++ b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/RootResources.java
@@ -40,8 +40,7 @@ import org.apache.juneau.rest.widget.*;
),
widgets={
PoweredByJuneauWidget.class,
- PoweredByApacheWidget.class,
- ContentTypeLinksWidget.class
+ PoweredByApacheWidget.class
},
children={
HelloWorldResource.class,
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4eb151d1/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/addressbook/AddressBookResource.java
----------------------------------------------------------------------
diff --git a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/addressbook/AddressBookResource.java b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/addressbook/AddressBookResource.java
index 6677c29..81278b2 100644
--- a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/addressbook/AddressBookResource.java
+++ b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/addressbook/AddressBookResource.java
@@ -59,7 +59,7 @@ import org.apache.juneau.utils.*;
+ " <li>Widgets"
+ " </ul>"
+ " <p style='text-weight:bold;text-decoration:underline;'>Available Content Types</p>"
- + " $W{contentTypeLinks}"
+ + " $W{contentTypeLinksColumn}"
+ "</div>",
footer="$W{poweredByJuneau}"
),
@@ -67,7 +67,7 @@ import org.apache.juneau.utils.*;
// Widgets for $W variables above.
widgets={
PoweredByJuneauWidget.class,
- ContentTypeLinksWidget.class
+ ContentTypeLinksColumnWidget.class
},
// Properties that get applied to all serializers and parsers.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4eb151d1/juneau-rest/src/main/java/org/apache/juneau/rest/widget/ContentTypeLinksColumnWidget.java
----------------------------------------------------------------------
diff --git a/juneau-rest/src/main/java/org/apache/juneau/rest/widget/ContentTypeLinksColumnWidget.java b/juneau-rest/src/main/java/org/apache/juneau/rest/widget/ContentTypeLinksColumnWidget.java
new file mode 100644
index 0000000..1440d80
--- /dev/null
+++ b/juneau-rest/src/main/java/org/apache/juneau/rest/widget/ContentTypeLinksColumnWidget.java
@@ -0,0 +1,48 @@
+// ***************************************************************************************************************************
+// * 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.juneau.rest.widget;
+
+import static org.apache.juneau.dto.html5.HtmlBuilder.*;
+
+import java.util.*;
+
+import org.apache.juneau.*;
+import org.apache.juneau.dto.html5.*;
+import org.apache.juneau.html.*;
+import org.apache.juneau.http.*;
+import org.apache.juneau.rest.*;
+
+/**
+ * Widget that returns back a list of hyperlinks for rendering the contents of a page in a variety of content types.
+ * <p>
+ * The variable it resolves is <js>"$W{contentTypeLinksColumn}"</js>.
+ */
+public class ContentTypeLinksColumnWidget extends Widget {
+
+ @Override /* Widget */
+ public String getName() {
+ return "contentTypeLinksColumn";
+ }
+
+ @Override /* Widget */
+ public String resolve(RestRequest req) throws Exception {
+ UriResolver uriResolver = req.getUriResolver();
+ P p = p();
+ List<MediaType> l = new ArrayList<MediaType>(req.getSerializerGroup().getSupportedMediaTypes());
+ Collections.sort(l);
+ for (MediaType mt : l)
+ p.child(a()._class("link").href(uriResolver.resolve("request:/?plainText=true&Accept="+mt)).child(mt)).child(br());
+ return HtmlSerializer.DEFAULT_SQ.serialize(p);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4eb151d1/juneau-rest/src/main/java/org/apache/juneau/rest/widget/ContentTypeLinksRowWidget.java
----------------------------------------------------------------------
diff --git a/juneau-rest/src/main/java/org/apache/juneau/rest/widget/ContentTypeLinksRowWidget.java b/juneau-rest/src/main/java/org/apache/juneau/rest/widget/ContentTypeLinksRowWidget.java
new file mode 100644
index 0000000..d6cbde9
--- /dev/null
+++ b/juneau-rest/src/main/java/org/apache/juneau/rest/widget/ContentTypeLinksRowWidget.java
@@ -0,0 +1,48 @@
+// ***************************************************************************************************************************
+// * 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.juneau.rest.widget;
+
+import static org.apache.juneau.dto.html5.HtmlBuilder.*;
+
+import java.util.*;
+
+import org.apache.juneau.*;
+import org.apache.juneau.dto.html5.*;
+import org.apache.juneau.html.*;
+import org.apache.juneau.http.*;
+import org.apache.juneau.rest.*;
+
+/**
+ * Widget that returns back a list of hyperlinks for rendering the contents of a page in a variety of content types.
+ * <p>
+ * The variable it resolves is <js>"$W{contentTypeLinksRow}"</js>.
+ */
+public class ContentTypeLinksRowWidget extends Widget {
+
+ @Override /* Widget */
+ public String getName() {
+ return "contentTypeLinksRow";
+ }
+
+ @Override /* Widget */
+ public String resolve(RestRequest req) throws Exception {
+ UriResolver uriResolver = req.getUriResolver();
+ P p = p();
+ List<MediaType> l = new ArrayList<MediaType>(req.getSerializerGroup().getSupportedMediaTypes());
+ Collections.sort(l);
+ for (MediaType mt : l)
+ p.style("max-width:1200px").child(a()._class("link").href(uriResolver.resolve("request:/?plainText=true&Accept="+mt)).children(mt)).child("\u00AD");
+ return HtmlSerializer.DEFAULT_SQ.serialize(p);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4eb151d1/juneau-rest/src/main/java/org/apache/juneau/rest/widget/ContentTypeLinksWidget.java
----------------------------------------------------------------------
diff --git a/juneau-rest/src/main/java/org/apache/juneau/rest/widget/ContentTypeLinksWidget.java b/juneau-rest/src/main/java/org/apache/juneau/rest/widget/ContentTypeLinksWidget.java
deleted file mode 100644
index 67dee3f..0000000
--- a/juneau-rest/src/main/java/org/apache/juneau/rest/widget/ContentTypeLinksWidget.java
+++ /dev/null
@@ -1,48 +0,0 @@
-// ***************************************************************************************************************************
-// * 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.juneau.rest.widget;
-
-import static org.apache.juneau.dto.html5.HtmlBuilder.*;
-
-import java.util.*;
-
-import org.apache.juneau.*;
-import org.apache.juneau.dto.html5.*;
-import org.apache.juneau.html.*;
-import org.apache.juneau.http.*;
-import org.apache.juneau.rest.*;
-
-/**
- * Widget that returns back a list of hyperlinks for rendering the contents of a page in a variety of content types.
- * <p>
- * The variable it resolves is <js>"$W{contentTypeLinks}"</js>.
- */
-public class ContentTypeLinksWidget extends Widget {
-
- @Override /* Widget */
- public String getName() {
- return "contentTypeLinks";
- }
-
- @Override /* Widget */
- public String resolve(RestRequest req) throws Exception {
- UriResolver uriResolver = req.getUriResolver();
- P p = p();
- List<MediaType> l = new ArrayList<MediaType>(req.getSerializerGroup().getSupportedMediaTypes());
- Collections.sort(l);
- for (MediaType mt : l)
- p.child(a()._class("link").href(uriResolver.resolve("request:/?plainText=true&Accept="+mt)).child(mt)).child(br());
- return HtmlSerializer.DEFAULT_SQ.serialize(p);
- }
-
-}