Added a second page to proof, that the connection is persisted
authorKai Moritz <kai@juplo.de>
Thu, 21 Jan 2016 15:58:46 +0000 (16:58 +0100)
committerKai Moritz <kai@juplo.de>
Sat, 30 Jan 2016 13:35:11 +0000 (14:35 +0100)
src/main/java/de/juplo/yourshouter/ProfileController.java [new file with mode: 0644]
src/main/resources/templates/home.html
src/main/resources/templates/profile.html [new file with mode: 0644]

diff --git a/src/main/java/de/juplo/yourshouter/ProfileController.java b/src/main/java/de/juplo/yourshouter/ProfileController.java
new file mode 100644 (file)
index 0000000..35cadc8
--- /dev/null
@@ -0,0 +1,36 @@
+package de.juplo.yourshouter;
+
+import javax.inject.Inject;
+
+import org.springframework.social.facebook.api.Facebook;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+
+/**
+ * Controller, that handles requests to the root of the application.
+ *
+ * @author Kai Moritz
+ */
+@Controller
+public class ProfileController
+{
+  private final Facebook facebook;
+
+
+  @Inject
+  public ProfileController(Facebook facebook)
+  {
+    this.facebook = facebook;
+  }
+
+
+  @RequestMapping(value = "/profile.html", method = RequestMethod.GET)
+  public String show(Model model)
+  {
+    model.addAttribute("profile", facebook.userOperations().getUserProfile());
+    return "profile";
+  }
+}
index 04d9d8a..b4d0074 100644 (file)
@@ -7,6 +7,7 @@
     <h1>Hello, <span th:text="${user.name}">Some User</span>!</h1>
     <ul>
       <li><a href="connect/facebookConnected.html" th:href="@{/connect/facebook.html}">Show connection-status</a></li>
+      <li><a href="profile.html" th:href="@{/profile.html}">Show public profile-data</a></li>
     </ul>
   </body>
 </html>
diff --git a/src/main/resources/templates/profile.html b/src/main/resources/templates/profile.html
new file mode 100644 (file)
index 0000000..f0b3dab
--- /dev/null
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
+  <head>
+    <title>Hello Facebook</title>
+  </head>
+  <body>
+    <p>Back <a href="home.html" th:href="@{/}">HOME</a></p>
+    <hr />
+    <h1>Public available profile-data</h1>
+    <ul>
+      <li><strong>ID:</strong> <em th:text="${profile.id}">123456789</em></li>
+      <li><strong>Name:</strong> <em th:text="${profile.name}">Kai Moritz</em></li>
+      <li><strong>First Name:</strong> <em th:text="${profile.firstName}">Kai</em></li>
+      <li><strong>Last Name:</strong> <em th:text="${profile.lastName}">Moritz</em></li>
+      <li><strong>Gender:</strong> <em th:text="${profile.gender}">male</em></li>
+      <li><strong>Verified:</strong> <em th:text="${profile.verified}">true</em></li>
+      <li th:if="${profile.cover}"><strong>Cover:</strong> <img src="" th:src="${profile.cover.source}" alt="1234567" th:alt="${profile.cover.id}" /></li>
+    </ul>
+  </body>
+</html>